summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mail/changes/bug_various_fixes5
-rw-r--r--mail/src/leap/mail/imap/fetch.py5
-rw-r--r--mail/src/leap/mail/imap/server.py8
-rw-r--r--mail/src/leap/mail/imap/service/imap.py2
4 files changed, 16 insertions, 4 deletions
diff --git a/mail/changes/bug_various_fixes b/mail/changes/bug_various_fixes
new file mode 100644
index 00000000..f76b21b9
--- /dev/null
+++ b/mail/changes/bug_various_fixes
@@ -0,0 +1,5 @@
+ o Notify of unread email explicitly every time the mailbox is
+ sync'ed.
+ o Fix signals to emit only string in the contents instead of bool or
+ int values.
+ o Improve unseen filter of email. \ No newline at end of file
diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py
index 4eb90b4c..3b15c6a1 100644
--- a/mail/src/leap/mail/imap/fetch.py
+++ b/mail/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/mail/src/leap/mail/imap/server.py b/mail/src/leap/mail/imap/server.py
index 51df86eb..7890a76b 100644
--- a/mail/src/leap/mail/imap/server.py
+++ b/mail/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/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py
index 380324c7..6b2a61da 100644
--- a/mail/src/leap/mail/imap/service/imap.py
+++ b/mail/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