1 http://marc.info/?l=mutt-dev&m=128045511126422
3 Make "move to trash folder" use IMAP COPY.
5 by Paul Miller (jettero)
9 @@ -893,6 +893,12 @@ static int imap_make_msg_set (IMAP_DATA*
10 if (hdrs[n]->deleted != HEADER_DATA(hdrs[n])->deleted)
11 match = invert ^ hdrs[n]->deleted;
13 + case M_EXPIRED: /* imap_fast_trash version of M_DELETED */
14 + if (hdrs[n]->purged)
16 + if (hdrs[n]->deleted != HEADER_DATA(hdrs[n])->deleted)
17 + match = invert ^ hdrs[n]->deleted;
20 if (hdrs[n]->flagged != HEADER_DATA(hdrs[n])->flagged)
21 match = invert ^ hdrs[n]->flagged;
22 @@ -2028,3 +2034,54 @@ int imap_complete(char* dest, size_t dle
27 +int imap_fast_trash() {
29 + if( Context->magic == M_IMAP && mx_is_imap(TrashPath) ) {
31 + IMAP_DATA *idata = (IMAP_DATA *) Context->data;
32 + char mbox[LONG_STRING];
33 + char mmbox[LONG_STRING];
35 + dprint(1, (debugfile, "[itf] trashcan seems to be on imap.\n"));
37 + if ( imap_parse_path(TrashPath, &mx) == 0 ) {
38 + if( mutt_account_match(&(idata->conn->account), &(mx.account)) ) {
39 + dprint(1, (debugfile, "[itf] trashcan seems to be on the same account.\n"));
41 + imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox));
43 + strfcpy (mbox, "INBOX", sizeof (mbox));
44 + imap_munge_mbox_name (mmbox, sizeof (mmbox), mbox);
46 + rc = imap_exec_msgset (idata, "UID COPY", mmbox, M_EXPIRED, 0, 0);
48 + dprint (1, (debugfile, "imap_copy_messages: No messages del-tagged\n"));
52 + } else if (rc < 0) {
53 + dprint (1, (debugfile, "could not queue copy\n"));
57 + mutt_message (_("Copying %d messages to %s..."), rc, mbox);
62 + dprint(1, (debugfile, "[itf] trashcan seems to be on a different account.\n"));
66 + FREE (&mx.mbox); /* we probably only need to free this when the parse works */
69 + dprint(1, (debugfile, "[itf] failed to parse TrashPath.\n" ));
72 + dprint(1, (debugfile, "[itf] giving up and trying old fasioned way.\n" ));
79 @@ -72,4 +72,7 @@ void imap_keepalive (void);
81 int imap_account_match (const ACCOUNT* a1, const ACCOUNT* a2);
84 +int imap_fast_trash();
89 @@ -802,6 +802,11 @@ static int trash_append (CONTEXT *ctx)
90 && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
91 return 0; /* we are in the trash folder: simple sync */
94 + if( !imap_fast_trash() )
98 if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
100 for (i = 0 ; i < ctx->msgcount ; i++)