From 36a06801915af61be8503807a465a39025c2b8b7 Mon Sep 17 00:00:00 2001 From: Ethan Glasser-Camp Date: Sun, 22 May 2011 03:19:29 -0400 Subject: [PATCH] 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 . Signed-off-by: Ethan Glasser-Camp Signed-off-by: Nicolas Sebrecht --- offlineimap/imapserver.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index e5613fb..96e8d23 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -411,7 +411,15 @@ class IdleThread(object): self.event.set() imapobj = self.parent.acquireconnection() 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() if self.event.isSet(): imapobj.noop()