]>
Commit | Line | Data |
---|---|---|
f6e5692e JR |
1 | http://marc.info/?l=mutt-dev&m=128045511126422 |
2 | ||
3 | Make "move to trash folder" use IMAP COPY. | |
4 | ||
5 | by Paul Miller (jettero) | |
6 | ||
7 | --- a/imap/imap.c | |
8 | +++ b/imap/imap.c | |
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; | |
12 | break; | |
13 | + case M_EXPIRED: /* imap_fast_trash version of M_DELETED */ | |
14 | + if (hdrs[n]->purged) | |
15 | + break; | |
16 | + if (hdrs[n]->deleted != HEADER_DATA(hdrs[n])->deleted) | |
17 | + match = invert ^ hdrs[n]->deleted; | |
18 | + break; | |
19 | case M_FLAG: | |
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 | |
23 | ||
24 | return -1; | |
25 | } | |
26 | + | |
27 | +int imap_fast_trash() { | |
28 | + | |
29 | + if( Context->magic == M_IMAP && mx_is_imap(TrashPath) ) { | |
30 | + IMAP_MBOX mx; | |
31 | + IMAP_DATA *idata = (IMAP_DATA *) Context->data; | |
32 | + char mbox[LONG_STRING]; | |
33 | + char mmbox[LONG_STRING]; | |
34 | + int rc; | |
35 | + dprint(1, (debugfile, "[itf] trashcan seems to be on imap.\n")); | |
36 | + | |
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")); | |
40 | + | |
41 | + imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox)); | |
42 | + if (!*mbox) | |
43 | + strfcpy (mbox, "INBOX", sizeof (mbox)); | |
44 | + imap_munge_mbox_name (mmbox, sizeof (mmbox), mbox); | |
45 | + | |
46 | + rc = imap_exec_msgset (idata, "UID COPY", mmbox, M_EXPIRED, 0, 0); | |
47 | + if (!rc) { | |
48 | + dprint (1, (debugfile, "imap_copy_messages: No messages del-tagged\n")); | |
49 | + rc = -1; | |
50 | + goto old_way; | |
51 | + | |
52 | + } else if (rc < 0) { | |
53 | + dprint (1, (debugfile, "could not queue copy\n")); | |
54 | + goto old_way; | |
55 | + | |
56 | + } else { | |
57 | + mutt_message (_("Copying %d messages to %s..."), rc, mbox); | |
58 | + return 0; | |
59 | + } | |
60 | + | |
61 | + } else { | |
62 | + dprint(1, (debugfile, "[itf] trashcan seems to be on a different account.\n")); | |
63 | + } | |
64 | + | |
65 | + old_way: | |
66 | + FREE (&mx.mbox); /* we probably only need to free this when the parse works */ | |
67 | + | |
68 | + } else { | |
69 | + dprint(1, (debugfile, "[itf] failed to parse TrashPath.\n" )); | |
70 | + } | |
71 | + | |
72 | + dprint(1, (debugfile, "[itf] giving up and trying old fasioned way.\n" )); | |
73 | + } | |
74 | + | |
75 | + return 1; | |
76 | +} | |
77 | --- a/imap/imap.h | |
78 | +++ b/imap/imap.h | |
79 | @@ -72,4 +72,7 @@ void imap_keepalive (void); | |
80 | ||
81 | int imap_account_match (const ACCOUNT* a1, const ACCOUNT* a2); | |
82 | ||
83 | +/* trash */ | |
84 | +int imap_fast_trash(); | |
85 | + | |
86 | #endif | |
87 | --- a/mx.c | |
88 | +++ b/mx.c | |
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 */ | |
92 | ||
93 | + #ifdef USE_IMAP | |
94 | + if( !imap_fast_trash() ) | |
95 | + return 0; | |
96 | + #endif | |
97 | + | |
98 | if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL) | |
99 | { | |
100 | for (i = 0 ; i < ctx->msgcount ; i++) |