summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/imap/cyrus.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/pykolab/imap/cyrus.py b/pykolab/imap/cyrus.py
index ac580c9..f719e10 100644
--- a/pykolab/imap/cyrus.py
+++ b/pykolab/imap/cyrus.py
@@ -90,6 +90,39 @@ 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)
+ if not self.SEP == self.separator:
+ self.separator = self.SEP
+
def login(self, *args, **kw):
"""
Login to the Cyrus IMAP server through cyruslib.CYRUS, but set our