diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | driver.c | 8 | ||||
-rw-r--r-- | etrn.c | 1 | ||||
-rw-r--r-- | fetchmail.h | 2 | ||||
-rw-r--r-- | imap.c | 40 | ||||
-rw-r--r-- | odmr.c | 1 | ||||
-rw-r--r-- | pop3.c | 1 |
7 files changed, 34 insertions, 22 deletions
@@ -199,6 +199,9 @@ fetchmail 6.3.0 (not yet released officially): Berlios Bug #4725. Matthias Andree. * Fix "auth ntlm" to send AUTH NTLM (rather than AUTH MSN). Add "auth msn" officially. Reported by Yves Boisjoly. Matthias Andree +* Expunge between IMAP folders when polling multiple folders. + Sunil Shetye. (MA) +* Fix IMAP expunged message counting. Sunil Shetye. (MA) # INTERNAL CHANGES * Switched to automake. Matthias Andree. @@ -1424,6 +1424,14 @@ is restored.")); send_size_warnings(ctl); } } + + /* end-of-mailbox processing before we repoll or switch to another one */ + if (ctl->server.base_protocol->end_mailbox_poll) + { + err = (ctl->server.base_protocol->end_mailbox_poll)(mailserver_socket, ctl); + if (err) + goto cleanUp; + } } while /* * Only re-poll if we either had some actual forwards and @@ -137,6 +137,7 @@ static const struct method etrn = NULL, /* no message trailer */ NULL, /* how to delete a message */ NULL, /* how to mark a message as seen */ + NULL, /* no mailbox support */ etrn_logout, /* log out, we're done */ FALSE, /* no, we can't re-poll */ }; diff --git a/fetchmail.h b/fetchmail.h index fe65c336..bd992827 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -221,6 +221,8 @@ struct method /* describe methods for protocol state machine */ /* delete method */ int (*mark_seen)(int, struct query *, int); /* mark as seen method */ + int (*end_mailbox_poll)(int, struct query *); + /* end-of-mailbox processing */ int (*logout_cmd)(int, struct query *); /* logout command */ flag retry; /* can getrange poll for new messages? */ @@ -101,7 +101,10 @@ static int imap_ok(int sock, char *argbuf) } else if (strstr(buf, "EXPUNGE") && !strstr(buf, "OK")) { - count -= atoi(buf+2); + /* the response "* 10 EXPUNGE" means that the currently + * tenth (i.e. only one) message has been deleted */ + if (atoi(buf+2) > 0) + count--; if (count < 0) count = 0; } @@ -639,29 +642,14 @@ static int imap_getrange(int sock, if (pass > 1) { - /* - * We have to have an expunge here, otherwise the re-poll will - * infinite-loop picking up un-expunged messages -- unless the - * expunge period is one and we've been nuking each message - * just after deletion. - */ - ok = 0; - if (deletions) { - ok = internal_expunge(sock); - if (ok) - { - report(stderr, GT_("expunge failed\n")); - return(ok); - } - } - - /* + /* deleted mails have already been expunged by + * end_mailbox_poll(). + * * recentcount is already set here by the last imap command which * returned RECENT on detecting new mail. if recentcount is 0, wait * for new mail. - */ - - /* this is a while loop because imap_idle() might return on other + * + * this is a while loop because imap_idle() might return on other * mailbox changes also */ while (recentcount == 0 && do_idle) { smtp_close(ctl, 1); @@ -792,7 +780,6 @@ static int imap_getrange(int sock, unseen = -1; *newp = unseen; - count = 0; expunged = 0; deletions = 0; @@ -1108,6 +1095,14 @@ static int imap_mark_seen(int sock, struct query *ctl, int number) number)); } +static int imap_end_mailbox_poll(int sock, struct query *ctl) +/* cleanup mailbox before we idle or switch to another one */ +{ + if (deletions) + internal_expunge(sock); + return(PS_SUCCESS); +} + static int imap_logout(int sock, struct query *ctl) /* send logout command */ { @@ -1142,6 +1137,7 @@ static const struct method imap = imap_trail, /* eat message trailer */ imap_delete, /* delete the message */ imap_mark_seen, /* how to mark a message as seen */ + imap_end_mailbox_poll, /* end-of-mailbox processing */ imap_logout, /* expunge and exit */ TRUE, /* yes, we can re-poll */ }; @@ -226,6 +226,7 @@ static const struct method odmr = NULL, /* no message trailer */ NULL, /* how to delete a message */ NULL, /* how to mark a message as seen */ + NULL, /* no mailbox support */ odmr_logout, /* log out, we're done */ FALSE, /* no, we can't re-poll */ }; @@ -1250,6 +1250,7 @@ static const struct method pop3 = NULL, /* no message trailer */ pop3_delete, /* how to delete a message */ pop3_mark_seen, /* how to mark a message as seen */ + NULL, /* no action at end of mailbox */ pop3_logout, /* log out, we're done */ FALSE, /* no, we can't re-poll */ }; |