summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/mail/imap/fetch.py8
-rw-r--r--src/leap/mail/imap/server.py7
-rw-r--r--src/leap/mail/imap/service/imap.py2
-rw-r--r--src/leap/mail/smtp/__init__.py1
4 files changed, 11 insertions, 7 deletions
diff --git a/src/leap/mail/imap/fetch.py b/src/leap/mail/imap/fetch.py
index 96568d5..802ce26 100644
--- a/src/leap/mail/imap/fetch.py
+++ b/src/leap/mail/imap/fetch.py
@@ -37,6 +37,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__)
@@ -132,6 +133,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,))
@@ -159,8 +162,7 @@ class LeapIncomingMail(object):
# XXX should check for _enc_scheme == "pubkey" || "none"
# that is what incoming mail uses.
encdata = doc.content[ENC_JSON_KEY]
- d = defer.Deferred(self._decrypt_msg(doc, encdata))
- d.addCallbacks(self._process_decrypted, log.msg)
+ defer.Deferred(self._decrypt_msg(doc, encdata))
else:
logger.debug('This does not look like a proper msg.')
@@ -177,7 +179,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 0192444..a69eb3f 100644
--- a/src/leap/mail/imap/server.py
+++ b/src/leap/mail/imap/server.py
@@ -37,7 +37,6 @@ from twisted.python import log
from leap.common.check import leap_assert, leap_assert_type
from leap.soledad.client import Soledad
-from leap.soledad.client.sqlcipher import SQLCipherDatabase
logger = logging.getLogger(__name__)
@@ -162,6 +161,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 +178,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 +990,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 ccaeee7..4dcb49a 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
diff --git a/src/leap/mail/smtp/__init__.py b/src/leap/mail/smtp/__init__.py
index 1139afa..54f5c81 100644
--- a/src/leap/mail/smtp/__init__.py
+++ b/src/leap/mail/smtp/__init__.py
@@ -20,6 +20,7 @@ SMTP relay helper function.
"""
from twisted.internet import reactor
+from twisted.internet.error import CannotListenError
from leap.common.events import proto, signal