Add check for IDLE in capabilities

If the server doesn't support IDLE, we fall back to the standard
noop() keepalive.

This commit was originally by James Bunton <jamesbunton@fastmail.fm>.

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Ethan Glasser-Camp 2011-05-22 03:19:29 -04:00 committed by Nicolas Sebrecht
parent d47bd1ff89
commit 36a0680191

View File

@ -411,7 +411,15 @@ class IdleThread(object):
self.event.set()
imapobj = self.parent.acquireconnection()
imapobj.select(self.folder)
if "IDLE" in imapobj.capabilities:
imapobj.idle(callback=callback)
else:
ui = getglobalui()
ui.warn("IMAP IDLE not supported on connection to %s."
"Falling back to old behavior: sleeping until next"
"refresh cycle."
%(imapobj.identifier,))
imapobj.noop()
self.event.wait()
if self.event.isSet():
imapobj.noop()