summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/mail/conductor.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-04-04 16:58:18 -0300
committerTomás Touceda <chiiph@leap.se>2014-04-04 16:58:18 -0300
commit81715dc47d77934c4f67d2527a56c28f58f0345d (patch)
tree6e66940af735e089803c5ce05ad1ce1df16c9d1e /src/leap/bitmask/services/mail/conductor.py
parent496036f15cf257d16b6594770812da64a249280c (diff)
parenteb4cdab9c6b8ff66bb4667cc6195d2c366122540 (diff)
Merge branch 'release-0.5.0'
Diffstat (limited to 'src/leap/bitmask/services/mail/conductor.py')
-rw-r--r--src/leap/bitmask/services/mail/conductor.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/leap/bitmask/services/mail/conductor.py b/src/leap/bitmask/services/mail/conductor.py
index addf9bef..79f324dc 100644
--- a/src/leap/bitmask/services/mail/conductor.py
+++ b/src/leap/bitmask/services/mail/conductor.py
@@ -35,6 +35,7 @@ from leap.common.check import leap_assert
from leap.common.events import register as leap_register
from leap.common.events import events_pb2 as leap_events
+
logger = logging.getLogger(__name__)
@@ -72,6 +73,8 @@ class IMAPControl(object):
"""
Starts imap service.
"""
+ from leap.bitmask.config import flags
+
logger.debug('Starting imap service')
leap_assert(sameProxiedObjects(self._soledad, None)
is not True,
@@ -81,16 +84,25 @@ class IMAPControl(object):
"We need a non-null keymanager for initializing imap "
"service")
+ offline = flags.OFFLINE
self.imap_service, self.imap_port, \
self.imap_factory = imap.start_imap_service(
self._soledad,
self._keymanager,
- userid=self.userid)
- self.imap_service.start_loop()
+ userid=self.userid,
+ offline=offline)
+
+ if offline is False:
+ logger.debug("Starting loop")
+ self.imap_service.start_loop()
- def stop_imap_service(self):
+ def stop_imap_service(self, cv):
"""
Stops imap service (fetcher, factory and port).
+
+ :param cv: A condition variable to which we can signal when imap
+ indeed stops.
+ :type cv: threading.Condition
"""
self.imap_connection.qtsigs.disconnecting_signal.emit()
# TODO We should homogenize both services.
@@ -102,7 +114,14 @@ class IMAPControl(object):
# Stop listening on the IMAP port
self.imap_port.stopListening()
# Stop the protocol
- self.imap_factory.doStop()
+ self.imap_factory.theAccount.closed = True
+ self.imap_factory.doStop(cv)
+ else:
+ # main window does not have to wait because there's no service to
+ # be stopped, so we release the condition variable
+ cv.acquire()
+ cv.notify()
+ cv.release()
def fetch_incoming_mail(self):
"""
@@ -339,7 +358,7 @@ class MailConductor(IMAPControl, SMTPControl):
self._mail_machine = None
self._mail_connection = mail_connection.MailConnection()
- self.userid = None
+ self._userid = None
@property
def userid(self):
@@ -388,3 +407,4 @@ class MailConductor(IMAPControl, SMTPControl):
qtsigs.connecting_signal.connect(widget.mail_state_connecting)
qtsigs.disconnecting_signal.connect(widget.mail_state_disconnecting)
qtsigs.disconnected_signal.connect(widget.mail_state_disconnected)
+ qtsigs.soledad_invalid_auth_token.connect(widget.soledad_invalid_auth_token)