diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2003-02-28 11:02:53 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2003-02-28 11:02:53 +0000 |
commit | 9cb888960d9191a2442bd194e84f3e56ac809eed (patch) | |
tree | d4906366f8459fa3a51d6eebcf6ec3d80ea89774 /imap.c | |
parent | 7b08e9eb937dfe13d8d4b71d5226f288cdb4a67a (diff) | |
download | fetchmail-9cb888960d9191a2442bd194e84f3e56ac809eed.tar.gz fetchmail-9cb888960d9191a2442bd194e84f3e56ac809eed.tar.bz2 fetchmail-9cb888960d9191a2442bd194e84f3e56ac809eed.zip |
IDLE implementation.
svn path=/trunk/; revision=3794
Diffstat (limited to 'imap.c')
-rw-r--r-- | imap.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -544,11 +544,33 @@ static int internal_expunge(int sock) static int imap_idle(int sock) /* start an RFC2177 IDLE */ { + int ok; + + /* special timeout to terminate the IDLE and re-issue it + * at least every 28 minutes: + * (the server may have an inactivity timeout) */ stage = STAGE_IDLE; saved_timeout = mytimeout; - mytimeout = 0; + mytimeout = 1680; /* 28 min */ + + /* enter IDLE mode */ + ok = gen_transact(sock, "IDLE"); - return (gen_transact(sock, "IDLE")); + if(ok == PS_IDLETIMEOUT) { + /* send "DONE" continuation */ + SockWrite(sock, "DONE\r\n", 6); + if (outlevel >= O_MONITOR) + report(stdout, "IMAP> DONE\n"); + + /* restore normal timeout value */ + mytimeout = saved_timeout; + stage = STAGE_FETCH; + + /* get OK IDLE message */ + return imap_ok(sock, NULL); + } else + /* not idle timeout */ + return ok; } static int imap_getrange(int sock, |