1 http://marc.info/?l=mutt-dev&m=128045511126422
3 Make "move to trash folder" use IMAP COPY.
5 by Paul Miller (jettero)
7 diff --git a/imap/imap.c b/imap/imap.c
8 index f08b4ea..47a8035 100644
11 @@ -2028,3 +2028,54 @@ int imap_complete(char* dest, size_t dlen, char* path) {
16 +int imap_fast_trash() {
18 + if( Context->magic == M_IMAP && mx_is_imap(TrashPath) ) {
20 + IMAP_DATA *idata = (IMAP_DATA *) Context->data;
21 + char mbox[LONG_STRING];
22 + char mmbox[LONG_STRING];
24 + dprint(1, (debugfile, "[itf] trashcan seems to be on imap.\n"));
26 + if ( imap_parse_path(TrashPath, &mx) == 0 ) {
27 + if( mutt_account_match(&(idata->conn->account), &(mx.account)) ) {
28 + dprint(1, (debugfile, "[itf] trashcan seems to be on the same account.\n"));
30 + imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox));
32 + strfcpy (mbox, "INBOX", sizeof (mbox));
33 + imap_munge_mbox_name (mmbox, sizeof (mmbox), mbox);
35 + rc = imap_exec_msgset (idata, "UID COPY", mmbox, M_DELETED, 0, 0);
37 + dprint (1, (debugfile, "imap_copy_messages: No messages del-tagged\n"));
41 + } else if (rc < 0) {
42 + dprint (1, (debugfile, "could not queue copy\n"));
46 + mutt_message (_("Copying %d messages to %s..."), rc, mbox);
51 + dprint(1, (debugfile, "[itf] trashcan seems to be on a different account.\n"));
55 + FREE (&mx.mbox); /* we probably only need to free this when the parse works */
58 + dprint(1, (debugfile, "[itf] failed to parse TrashPath.\n" ));
61 + dprint(1, (debugfile, "[itf] giving up and trying old fasioned way.\n" ));
66 diff --git a/imap/imap.h b/imap/imap.h
67 index 74d7e13..99cd454 100644
70 @@ -72,4 +72,7 @@ void imap_keepalive (void);
72 int imap_account_match (const ACCOUNT* a1, const ACCOUNT* a2);
75 +int imap_fast_trash();
78 diff --git a/mx.c b/mx.c
79 index 78aafcc..38c4e7f 100644
82 @@ -828,6 +828,11 @@ static int trash_append (CONTEXT *ctx)
83 && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
84 return 0; /* we are in the trash folder: simple sync */
87 + if( !imap_fast_trash() )
91 if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
93 for (i = 0 ; i < ctx->msgcount ; i++)