diff options
author | Kali Kaneko <kali@leap.se> | 2015-05-28 19:03:24 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-06-05 16:50:46 -0400 |
commit | 4c12d05d063d42171808c432bee90de67c4042b6 (patch) | |
tree | 7839f7e8cf9f9ac941008f71443c73d168f718ac /src/leap/mail/mail.py | |
parent | 8915db2e1c1a339cf36ae0e28da627bb1a8e040e (diff) |
[refactor] move hooks to account
Diffstat (limited to 'src/leap/mail/mail.py')
-rw-r--r-- | src/leap/mail/mail.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/leap/mail/mail.py b/src/leap/mail/mail.py index bab73cb..fe8226e 100644 --- a/src/leap/mail/mail.py +++ b/src/leap/mail/mail.py @@ -34,6 +34,7 @@ from leap.mail.adaptors.soledad import SoledadMailAdaptor from leap.mail.constants import INBOX_NAME from leap.mail.constants import MessageFlags from leap.mail.mailbox_indexer import MailboxIndexer +from leap.mail.plugins import soledad_sync_hooks from leap.mail.utils import find_charset, CaseInsensitiveDict logger = logging.getLogger(name=__name__) @@ -802,10 +803,17 @@ class Account(object): self.adaptor = self.adaptor_class() self.mbox_indexer = MailboxIndexer(self.store) + # This flag is only used from the imap service for the moment. + # In the future, we should prevent any public method to continue if + # this is set to True. Also, it would be good to plug to the + # authentication layer. + self.session_ended = False + self.deferred_initialization = defer.Deferred() self._ready_cb = ready_cb self._init_d = self._initialize_storage() + self._initialize_sync_hooks() def _initialize_storage(self): @@ -834,6 +842,14 @@ class Account(object): self.deferred_initialization.addCallback(cb, *args, **kw) return self.deferred_initialization + # Sync hooks + + def _initialize_sync_hooks(self): + soledad_sync_hooks.post_sync_uid_reindexer.set_account(self) + + def _teardown_sync_hooks(self): + soledad_sync_hooks.post_sync_uid_reindexer.set_account(None) + # # Public API Starts # @@ -946,3 +962,9 @@ class Account(object): :rtype: MessageCollection """ raise NotImplementedError() + + # Session handling + + def end_session(self): + self._teardown_sync_hooks() + self.session_ended = True |