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() self.event.set()
imapobj = self.parent.acquireconnection() imapobj = self.parent.acquireconnection()
imapobj.select(self.folder) imapobj.select(self.folder)
imapobj.idle(callback=callback) 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() self.event.wait()
if self.event.isSet(): if self.event.isSet():
imapobj.noop() imapobj.noop()