[PATCH v2 4/6] Add check for IDLE in capabilities
    Ethan Glasser-Camp 
    ethan at betacantrips.com
       
    Sun May 22 08:19:29 BST 2011
    
    
  
If the server doesn't support IDLE, we fall back to the standard
noop() keepalive.
This commit was originally by James Bunton <jamesbunton at fastmail.fm>.
Signed-off-by: Ethan Glasser-Camp <ethan at betacantrips.com>
---
Hi, this is a revised patch 4 that changes the warning and fixes a
stupid bug I introduced last time around.  With this, I think all the
feedback on the patch series has been addressed.
 offlineimap/imapserver.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
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()
-- 
1.7.4.1
    
    
More information about the OfflineIMAP-project
mailing list