aboutsummaryrefslogtreecommitdiffstats
path: root/imap.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-09-30 18:38:10 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-09-30 18:38:10 +0000
commit9ae98cb27ed3c6856a5169f96ce11f278b057e2d (patch)
treee436c58e5ebb829307efad5d1f1368d331f8f6af /imap.c
parent3e03d50356bef6820d79e94a8519213f2bfcd9e3 (diff)
downloadfetchmail-9ae98cb27ed3c6856a5169f96ce11f278b057e2d.tar.gz
fetchmail-9ae98cb27ed3c6856a5169f96ce11f278b057e2d.tar.bz2
fetchmail-9ae98cb27ed3c6856a5169f96ce11f278b057e2d.zip
Smart re-polling support.
svn path=/trunk/; revision=1437
Diffstat (limited to 'imap.c')
-rw-r--r--imap.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/imap.c b/imap.c
index ce30d121..9e4a8c3b 100644
--- a/imap.c
+++ b/imap.c
@@ -33,7 +33,7 @@ extern char *strstr(); /* needed on sysV68 R3V7.1. */
#define IMAP4 0 /* IMAP4 rev 0, RFC1730 */
#define IMAP4rev1 1 /* IMAP4 rev 1, RFC2060 */
-static int count, seen, recent, unseen, deletions, expunged, imap_version;
+static int count,seen,recent,unseen, deletions,expunged, imap_version, pass;
int imap_ok(int sock, char *argbuf)
/* parse command response */
@@ -418,11 +418,24 @@ static int imap_getrange(int sock,
/* find out how many messages are waiting */
recent = unseen = -1;
- ok = gen_transact(sock, "SELECT %s", folder ? folder : "INBOX");
- if (ok != 0)
+
+ if (++pass > 1)
{
- error(0, 0, "mailbox selection failed");
- return(ok);
+ ok = gen_transact(sock, "NOOP");
+ if (ok != 0)
+ {
+ error(0, 0, "re-poll failed");
+ return(ok);
+ }
+ }
+ else
+ {
+ ok = gen_transact(sock, "SELECT %s", folder ? folder : "INBOX");
+ if (ok != 0)
+ {
+ error(0, 0, "mailbox selection failed");
+ return(ok);
+ }
}
*countp = count;
@@ -635,6 +648,8 @@ static int imap_delete(int sock, struct query *ctl, int number)
static int imap_logout(int sock, struct query *ctl)
/* send logout command */
{
+
+
/* if expunges after deletion have been suppressed, ship one now */
if (ctl->expunge <= 0 && deletions)
{
@@ -663,11 +678,13 @@ const static struct method imap =
imap_trail, /* eat message trailer */
imap_delete, /* delete the message */
imap_logout, /* expunge and exit */
+ TRUE, /* yes, we can re-poll */
};
int doIMAP(struct query *ctl)
/* retrieve messages using IMAP Version 2bis or Version 4 */
{
+ pass = 0;
return(do_protocol(ctl, &imap));
}