From 9ae98cb27ed3c6856a5169f96ce11f278b057e2d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 30 Sep 1997 18:38:10 +0000 Subject: Smart re-polling support. svn path=/trunk/; revision=1437 --- imap.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'imap.c') 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)); } -- cgit v1.2.3