Skip to content

Commit

Permalink
debian/patches: features/imap_fast_trash.
Browse files Browse the repository at this point in the history
  • Loading branch information
df7cb committed Aug 25, 2010
1 parent 2c5aa1a commit bc3ca5d
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
mutt (1.5.20-10~unrel1) UNRELEASED; urgency=low

* debian/patches: features/imap_fast_trash.

-- Christoph Berg <myon@debian.org> Wed, 25 Aug 2010 11:11:43 +0200

mutt (1.5.20-9) unstable; urgency=low

* hurd-i386 fixes:
Expand Down
93 changes: 93 additions & 0 deletions debian/patches/features/imap_fast_trash
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
http://marc.info/?l=mutt-dev&m=128045511126422

Make "move to trash folder" use IMAP COPY.

by Paul Miller (jettero)

diff --git a/imap/imap.c b/imap/imap.c
index f08b4ea..47a8035 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -2028,3 +2028,54 @@ int imap_complete(char* dest, size_t dlen, char* path) {

return -1;
}
+
+int imap_fast_trash() {
+
+ if( Context->magic == M_IMAP && mx_is_imap(TrashPath) ) {
+ IMAP_MBOX mx;
+ IMAP_DATA *idata = (IMAP_DATA *) Context->data;
+ char mbox[LONG_STRING];
+ char mmbox[LONG_STRING];
+ int rc;
+ dprint(1, (debugfile, "[itf] trashcan seems to be on imap.\n"));
+
+ if ( imap_parse_path(TrashPath, &mx) == 0 ) {
+ if( mutt_account_match(&(idata->conn->account), &(mx.account)) ) {
+ dprint(1, (debugfile, "[itf] trashcan seems to be on the same account.\n"));
+
+ imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox));
+ if (!*mbox)
+ strfcpy (mbox, "INBOX", sizeof (mbox));
+ imap_munge_mbox_name (mmbox, sizeof (mmbox), mbox);
+
+ rc = imap_exec_msgset (idata, "UID COPY", mmbox, M_DELETED, 0, 0);
+ if (!rc) {
+ dprint (1, (debugfile, "imap_copy_messages: No messages del-tagged\n"));
+ rc = -1;
+ goto old_way;
+
+ } else if (rc < 0) {
+ dprint (1, (debugfile, "could not queue copy\n"));
+ goto old_way;
+
+ } else {
+ mutt_message (_("Copying %d messages to %s..."), rc, mbox);
+ return 0;
+ }
+
+ } else {
+ dprint(1, (debugfile, "[itf] trashcan seems to be on a different account.\n"));
+ }
+
+ old_way:
+ FREE (&mx.mbox); /* we probably only need to free this when the parse works */
+
+ } else {
+ dprint(1, (debugfile, "[itf] failed to parse TrashPath.\n" ));
+ }
+
+ dprint(1, (debugfile, "[itf] giving up and trying old fasioned way.\n" ));
+ }
+
+ return 1;
+}
diff --git a/imap/imap.h b/imap/imap.h
index 74d7e13..99cd454 100644
--- a/imap/imap.h
+++ b/imap/imap.h
@@ -72,4 +72,7 @@ void imap_keepalive (void);

int imap_account_match (const ACCOUNT* a1, const ACCOUNT* a2);

+/* trash */
+int imap_fast_trash();
+
#endif
diff --git a/mx.c b/mx.c
index 78aafcc..38c4e7f 100644
--- a/mx.c
+++ b/mx.c
@@ -828,6 +828,11 @@ static int trash_append (CONTEXT *ctx)
&& stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
return 0; /* we are in the trash folder: simple sync */

+ #ifdef USE_IMAP
+ if( !imap_fast_trash() )
+ return 0;
+ #endif
+
if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
{
for (i = 0 ; i < ctx->msgcount ; i++)
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ features/ifdef
features/xtitles
features/trash-folder
features/purge-message
features/imap_fast_trash
features/sensible_browser_position
features-old/patch-1.5.4.vk.pgp_verbose_mime
features/compressed-folders
Expand Down

0 comments on commit bc3ca5d

Please sign in to comment.