diff options
Diffstat (limited to 'src/leap/bitmask/core')
-rw-r--r-- | src/leap/bitmask/core/mail_services.py | 20 | ||||
-rw-r--r-- | src/leap/bitmask/core/service.py | 5 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index d2967f89..f971c1a2 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -435,8 +435,6 @@ class StandardMailService(service.MultiService, HookableService): # TODO factor out Mail Service to inside mail package. - subscribed_to_hooks = ('on_new_keymanager_instance',) - def __init__(self, basedir): self._basedir = basedir self._soledad_sessions = {} @@ -502,12 +500,22 @@ class StandardMailService(service.MultiService, HookableService): def hook_on_bonafide_auth(self, **kw): # TODO: if it's expired we should renew it userid = kw['username'] + + # turn on incoming mail service for the user that just logged in + multiservice = self.getServiceNamed('incoming_mail') + incoming = multiservice.getServiceNamed(userid) + log.msg('looking for incoming mail service for auth: %s' % userid) + if incoming: + incoming.startService() + + # check if smtp cert exists username, provider = userid.split('@') cert_path = _get_smtp_client_cert_path(self._basedir, provider, username) if os.path.exists(cert_path): return + # fetch smtp cert and store bonafide = self.parent.getServiceNamed("bonafide") _, cert_str = yield bonafide.do_get_smtp_cert(userid) @@ -518,6 +526,14 @@ class StandardMailService(service.MultiService, HookableService): outf.write(cert_str) check_and_fix_urw_only(cert_path) + def hook_on_bonafide_logout(self, **kw): + username = kw['username'] + multiservice = self.getServiceNamed('incoming_mail') + incoming = multiservice.getServiceNamed(username) + log.msg('looking for incoming mail service for logout: %s' % username) + if incoming: + incoming.stopService() + # commands def do_status(self): diff --git a/src/leap/bitmask/core/service.py b/src/leap/bitmask/core/service.py index de99ea55..1a544acf 100644 --- a/src/leap/bitmask/core/service.py +++ b/src/leap/bitmask/core/service.py @@ -89,6 +89,7 @@ class BitmaskBackend(configurable.ConfigurableService): bf.register_hook('on_passphrase_change', listener='soledad') bf.register_hook('on_bonafide_auth', listener='keymanager') bf.register_hook('on_bonafide_auth', listener='mail') + bf.register_hook('on_bonafide_logout', listener='mail') def _start_child_service(self, name): log.msg('starting backend child service: %s' % name) @@ -156,13 +157,13 @@ class BitmaskBackend(configurable.ConfigurableService): def _maybe_init_service(self, label, klass, *args, **kw): try: - self.getServiceNamed(label) + service = self.getServiceNamed(label) except KeyError: log.msg("initializing service: %s" % label) service = klass(*args, **kw) service.setName(label) service.setServiceParent(self) - return service + return service def do_stats(self): return self.core_commands.do_stats() |