From 26dc74bcc9afbe45d6082e95a3a72cda16d2941b Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 17 Sep 2015 10:44:44 -0400 Subject: [bug] fix assignment of the incoming service the second callback was actually broken, not being called when it was supposed to be. the reason is that IncomingMail.startService returns a deferred which callback is called with the loopingCall instance only when the loopingCall is stopped. --- src/leap/bitmask/services/mail/imapcontroller.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/leap/bitmask/services') diff --git a/src/leap/bitmask/services/mail/imapcontroller.py b/src/leap/bitmask/services/mail/imapcontroller.py index e5313477..5053d897 100644 --- a/src/leap/bitmask/services/mail/imapcontroller.py +++ b/src/leap/bitmask/services/mail/imapcontroller.py @@ -27,6 +27,7 @@ class IMAPController(object): """ IMAP Controller. """ + def __init__(self, soledad, keymanager): """ Initialize IMAP variables. @@ -63,12 +64,11 @@ class IMAPController(object): self._soledad, userid=userid) - def start_incoming_service(incoming_mail): - d = incoming_mail.startService() - d.addCallback(lambda started: incoming_mail) - return d - - def assign_incoming_service(incoming_mail): + def start_and_assign_incoming_service(incoming_mail): + # this returns a deferred that will be called when the looping call + # is stopped, we could add any shutdown/cleanup callback to that + # deferred, but unused by the moment. + incoming_mail.startService() self.incoming_mail_service = incoming_mail return incoming_mail @@ -78,8 +78,7 @@ class IMAPController(object): self._soledad, self.imap_factory, userid) - d.addCallback(start_incoming_service) - d.addCallback(assign_incoming_service) + d.addCallback(start_and_assign_incoming_service) d.addErrback(lambda f: logger.error(f.printTraceback())) def stop_imap_service(self): -- cgit v1.2.3