Changeset View
Changeset View
Standalone View
Standalone View
pykolab/imap/__init__.py
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | def connect(self, uri=None, server=None, domain=None, login=True): | ||||
admin_login = conf.get(backend, 'admin_login') | admin_login = conf.get(backend, 'admin_login') | ||||
admin_password = conf.get(backend, 'admin_password') | admin_password = conf.get(backend, 'admin_password') | ||||
if admin_password is None or admin_password == '': | if admin_password is None or admin_password == '': | ||||
log.error(_("No administrator password is available.")) | log.error(_("No administrator password is available.")) | ||||
if hostname not in self._imap: | if hostname not in self._imap: | ||||
if backend == 'cyrus-imap': | if backend == 'cyrus-imap': | ||||
import cyrus | from . import cyrus | ||||
self._imap[hostname] = cyrus.Cyrus(uri) | self._imap[hostname] = cyrus.Cyrus(uri) | ||||
# Actually connect | # Actually connect | ||||
if login: | if login: | ||||
log.debug(_("Logging on to Cyrus IMAP server %s") % (hostname), level=8) | log.debug(_("Logging on to Cyrus IMAP server %s") % (hostname), level=8) | ||||
self._imap[hostname].login(admin_login, admin_password) | self._imap[hostname].login(admin_login, admin_password) | ||||
self._imap[hostname].logged_in = True | self._imap[hostname].logged_in = True | ||||
elif backend == 'dovecot': | elif backend == 'dovecot': | ||||
import dovecot | from . import dovecot | ||||
self._imap[hostname] = dovecot.Dovecot(uri) | self._imap[hostname] = dovecot.Dovecot(uri) | ||||
# Actually connect | # Actually connect | ||||
if login: | if login: | ||||
log.debug(_("Logging on to Dovecot IMAP server %s") % (hostname), level=8) | log.debug(_("Logging on to Dovecot IMAP server %s") % (hostname), level=8) | ||||
self._imap[hostname].login(admin_login, admin_password) | self._imap[hostname].login(admin_login, admin_password) | ||||
self._imap[hostname].logged_in = True | self._imap[hostname].logged_in = True | ||||
else: | else: | ||||
▲ Show 20 Lines • Show All 1,063 Lines • Show Last 20 Lines |