diff options
author | Kali Kaneko <kali@leap.se> | 2013-08-20 17:45:32 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2013-08-20 17:45:32 +0200 |
commit | 48c151fb66621ebf6557603ab87ea7cde2312de1 (patch) | |
tree | 07562b7bab84bfa4f43fa7ede417419aacdb81a2 /src | |
parent | eb5e965274aa5a7b84821f45d7bfeca318f994f6 (diff) | |
parent | 4f088e9222e01247abc6a7b43fb41d63d4203e6b (diff) |
Merge remote-tracking branch 'chiiph/bug/various_fixes' into develop
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/mail/imap/fetch.py | 5 | ||||
-rw-r--r-- | src/leap/mail/imap/server.py | 8 | ||||
-rw-r--r-- | src/leap/mail/imap/service/imap.py | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/leap/mail/imap/fetch.py b/src/leap/mail/imap/fetch.py index 4eb90b4..3b15c6a 100644 --- a/src/leap/mail/imap/fetch.py +++ b/src/leap/mail/imap/fetch.py @@ -36,6 +36,7 @@ from leap.common.events.events_pb2 import IMAP_MSG_PROCESSING from leap.common.events.events_pb2 import IMAP_MSG_DECRYPTED from leap.common.events.events_pb2 import IMAP_MSG_SAVED_LOCALLY from leap.common.events.events_pb2 import IMAP_MSG_DELETED_INCOMING +from leap.common.events.events_pb2 import IMAP_UNREAD_MAIL logger = logging.getLogger(__name__) @@ -134,6 +135,8 @@ class LeapIncomingMail(object): log.msg("there are %s mails" % (num_mails,)) leap_events.signal( IMAP_FETCHED_INCOMING, str(num_mails), str(fetched_ts)) + leap_events.signal( + IMAP_UNREAD_MAIL, str(self._inbox.getUnseenCount())) return doclist except ssl.SSLError as exc: logger.warning('SSL Error while syncing soledad: %r' % (exc,)) @@ -178,7 +181,7 @@ class LeapIncomingMail(object): logger.warning("Error while decrypting msg: %r" % (exc,)) decrdata = "" ok = False - leap_events.signal(IMAP_MSG_DECRYPTED, ok) + leap_events.signal(IMAP_MSG_DECRYPTED, "1" if ok else "0") # XXX TODO: defer this properly return self._process_decrypted(doc, decrdata) diff --git a/src/leap/mail/imap/server.py b/src/leap/mail/imap/server.py index 51df86e..7890a76 100644 --- a/src/leap/mail/imap/server.py +++ b/src/leap/mail/imap/server.py @@ -38,6 +38,8 @@ from twisted.python import log from leap.common.check import leap_assert, leap_assert_type from leap.soledad import Soledad from leap.soledad.sqlcipher import SQLCipherDatabase +from leap.common.events import signal +from leap.common.events import events_pb2 as proto logger = logging.getLogger(__name__) @@ -162,6 +164,7 @@ class SoledadBackedAccount(WithMsgFields, IndexedDB): TYPE_SUBS_IDX = 'by-type-and-subscribed' TYPE_MBOX_SEEN_IDX = 'by-type-and-mbox-and-seen' TYPE_MBOX_RECT_IDX = 'by-type-and-mbox-and-recent' + TYPE_MBOX_RECT_SEEN_IDX = 'by-type-and-mbox-and-recent-and-seen' KTYPE = WithMsgFields.TYPE_KEY MBOX_VAL = WithMsgFields.TYPE_MBOX_VAL @@ -178,6 +181,7 @@ class SoledadBackedAccount(WithMsgFields, IndexedDB): # messages TYPE_MBOX_SEEN_IDX: [KTYPE, MBOX_VAL, 'bool(seen)'], TYPE_MBOX_RECT_IDX: [KTYPE, MBOX_VAL, 'bool(recent)'], + TYPE_MBOX_RECT_SEEN_IDX: [KTYPE, MBOX_VAL, 'bool(recent)', 'bool(seen)'], } INBOX_NAME = "INBOX" @@ -989,8 +993,8 @@ class MessageCollection(WithMsgFields, IndexedDB): """ return (doc for doc in self._soledad.get_from_index( - SoledadBackedAccount.TYPE_MBOX_RECT_IDX, - self.TYPE_MESSAGE_VAL, self.mbox, '1')) + SoledadBackedAccount.TYPE_MBOX_RECT_SEEN_IDX, + self.TYPE_MESSAGE_VAL, self.mbox, '1', '0')) def get_unseen(self): """ diff --git a/src/leap/mail/imap/service/imap.py b/src/leap/mail/imap/service/imap.py index 380324c..6b2a61d 100644 --- a/src/leap/mail/imap/service/imap.py +++ b/src/leap/mail/imap/service/imap.py @@ -89,7 +89,7 @@ class LeapIMAPServer(imap4.IMAP4Server): def authenticateLogin(self, username, password): # all is allowed so far. use realm instead - leap_events.signal(IMAP_CLIENT_LOGIN, True) + leap_events.signal(IMAP_CLIENT_LOGIN, "1") return imap4.IAccount, self.theAccount, lambda: None |