diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-06-13 17:01:05 +0100 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2012-06-13 17:01:05 +0100 |
commit | 44cf0065f458714edec23b1d6b093426cd493de1 (patch) | |
tree | 8f45cf4af1cb64bbaf152f9b931625e8d1f2a431 /pykolab/imap/cyrus.py | |
parent | 185be06162c19d9b4a5bacdfb10912829bcb79b6 (diff) | |
download | pykolab-44cf0065f458714edec23b1d6b093426cd493de1.tar.gz |
Add pykolab.imap.cyrus.Cyrus.connect()
Diffstat (limited to 'pykolab/imap/cyrus.py')
-rw-r--r-- | pykolab/imap/cyrus.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/pykolab/imap/cyrus.py b/pykolab/imap/cyrus.py index ac580c9..af3e5b8 100644 --- a/pykolab/imap/cyrus.py +++ b/pykolab/imap/cyrus.py @@ -24,6 +24,7 @@ from urlparse import urlparse import pykolab +from pykolab.imap import IMAP from pykolab.translate import _ log = pykolab.getLogger('pykolab.imap') @@ -90,6 +91,37 @@ class Cyrus(cyruslib.CYRUS): def __del__(self): pass + def connect(self, uri): + """ + Dummy connect function that checks if the server that we want to + connect to is actually the server we are connected to. + + Uses pykolab.imap.IMAP.connect() in the background. + """ + port = None + + result = urlparse(uri) + + if hasattr(result, 'hostname'): + scheme = result.scheme + hostname = result.hostname + port = result.port + else: + scheme = uri.split(':')[0] + (hostname, port) = uri.split('/')[2].split(':') + + if not port: + if scheme == 'imap': + port = 143 + else: + port = 993 + + if hostname == self.server: + return + + imap = IMAP() + imap.connect(uri=uri) + def login(self, *args, **kw): """ Login to the Cyrus IMAP server through cyruslib.CYRUS, but set our @@ -166,7 +198,7 @@ class Cyrus(cyruslib.CYRUS): #print "server:", server self.connect(self.uri.replace(self.server,server)) - log.debug(_("Setting quota for INBOX folder %s to %s") % (mailfolder,quota), level=8) + log.debug(_("Setting quota for folder %s to %s") % (mailfolder,quota), level=8) try: self.m.setquota(mailfolder, quota) except: |