diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-06-04 17:52:38 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-06-04 17:52:38 +0000 |
commit | 77cc256ed6094b52f0d552e8744b9722d28ff396 (patch) | |
tree | ac1c8034a42da1a0db8ed760983263d53754f318 /imap.c | |
parent | 70a06cd47ab03c4fff76ec218f7cc92574600fd6 (diff) | |
download | fetchmail-77cc256ed6094b52f0d552e8744b9722d28ff396.tar.gz fetchmail-77cc256ed6094b52f0d552e8744b9722d28ff396.tar.bz2 fetchmail-77cc256ed6094b52f0d552e8744b9722d28ff396.zip |
Rob Funk was right.
svn path=/trunk/; revision=1062
Diffstat (limited to 'imap.c')
-rw-r--r-- | imap.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -51,7 +51,9 @@ int imap_ok (int sock, char *argbuf) char *cp; /* - * Handle both "* 42 UNSEEN" and "* OK [UNSEEN 42] 42". + * Handle both "* 42 UNSEEN" (if tha ever happens) and + * "* OK [UNSEEN 42] 42". Note that what this gets us is + * a minimum index, not a count. */ unseen = 0; for (cp = buf; *cp && !isdigit(*cp); cp++) @@ -398,7 +400,7 @@ static int imap_getrange(int sock, int ok; /* find out how many messages are waiting */ - recent = unseen = 0; + recent = unseen = -1; ok = gen_transact(sock, "SELECT %s", folder ? folder : "INBOX"); if (ok != 0) { @@ -408,12 +410,19 @@ static int imap_getrange(int sock, *countp = count; - if (unseen) /* optional response, but better if we see it */ - *newp = unseen; - else if (recent) /* mandatory */ + /* + * Note: because IMAP has an is_old method, this number is used + * only for the "X messages (Y unseen)" notification. Accordingly + * it doesn't matter much that it can be wrong (e.g. if we see an + * UNSEEN response but not all messages above the first UNSEEN one + * are likewise). + */ + if (unseen >= 0) /* optional, but better if we see it */ + *newp = count - unseen + 1; + else if (recent >= 0) /* mandatory */ *newp = recent; else - *newp = -1; /* should never happen, RECENT is mandatory */ + *newp = -1; /* should never happen, RECENT is mandatory */ deletecount = 0; |