summaryrefslogtreecommitdiff
path: root/mail
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-03-26 13:21:00 -0300
committerTomás Touceda <chiiph@leap.se>2014-03-26 13:21:00 -0300
commit747c0aa8384af1764860b19e18fb9364380f14d4 (patch)
tree92121d2ccd35ba70d6801b565b2fe905e994c660 /mail
parentcafe1f205792ba7fd836ff96db07c097b242046c (diff)
parenta51e894dae2dcc84d1f67e44e694b59aa19c47e4 (diff)
Merge remote-tracking branch 'refs/remotes/kali/bug/bad-object-in-save-callback' into develop
Diffstat (limited to 'mail')
-rw-r--r--mail/src/leap/mail/imap/fetch.py12
-rw-r--r--mail/src/leap/mail/imap/mailbox.py19
2 files changed, 20 insertions, 11 deletions
diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py
index 5f951c3f..0a97752e 100644
--- a/mail/src/leap/mail/imap/fetch.py
+++ b/mail/src/leap/mail/imap/fetch.py
@@ -402,8 +402,11 @@ class LeapIncomingMail(object):
def _delete_incoming_message(self, doc):
"""
Delete document.
+
+ :param doc: the SoledadDocument to delete
+ :type doc: SoledadDocument
"""
- log.msg("Deleting SoledadDoc %s" % (doc.doc_id))
+ log.msg("Deleting Incoming message: %s" % (doc.doc_id,))
self._soledad.delete_doc(doc)
def _maybe_decrypt_msg(self, data):
@@ -605,12 +608,11 @@ class LeapIncomingMail(object):
def msgSavedCallback(result):
if not empty(result):
leap_events.signal(IMAP_MSG_SAVED_LOCALLY)
- deferLater(reactor, 0, self._delete_incoming_message, result)
+ deferLater(reactor, 0, self._delete_incoming_message, doc)
leap_events.signal(IMAP_MSG_DELETED_INCOMING)
- deferLater(reactor, 1, self._signal_unread_to_ui)
- # XXX should pass a notify_on_disk=True along...
- d = self._inbox.addMessage(data, flags=(self.RECENT_FLAG,))
+ d = self._inbox.addMessage(data, flags=(self.RECENT_FLAG,),
+ notify_on_disk=True)
d.addCallbacks(msgSavedCallback, self._errback)
#
diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py
index 503e38bd..47c7ff11 100644
--- a/mail/src/leap/mail/imap/mailbox.py
+++ b/mail/src/leap/mail/imap/mailbox.py
@@ -439,7 +439,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
r[self.CMD_UNSEEN] = self.getUnseenCount()
return defer.succeed(r)
- def addMessage(self, message, flags, date=None):
+ def addMessage(self, message, flags, date=None, notify_on_disk=False):
"""
Adds a message to this mailbox.
@@ -465,23 +465,29 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
else:
flags = tuple(str(flag) for flag in flags)
- d = self._do_add_message(message, flags=flags, date=date)
+ d = self._do_add_message(message, flags=flags, date=date,
+ notify_on_disk=notify_on_disk)
if PROFILE_CMD:
do_profile_cmd(d, "APPEND")
# A better place for this would be the COPY/APPEND dispatcher
# in server.py, but qtreactor hangs when I do that, so this seems
# to work fine for now.
- d.addCallback(lambda r: self.reactor.callLater(0, self.notify_new))
- d.addCallback(self.cb_signal_unread_to_ui)
+
+ def notifyCallback(x):
+ self.reactor.callLater(0, self.notify_new)
+ return x
+
+ d.addCallback(notifyCallback)
d.addErrback(lambda f: log.msg(f.getTraceback()))
return d
- def _do_add_message(self, message, flags, date):
+ def _do_add_message(self, message, flags, date, notify_on_disk=False):
"""
Calls to the messageCollection add_msg method.
Invoked from addMessage.
"""
- d = self.messages.add_msg(message, flags=flags, date=date)
+ d = self.messages.add_msg(message, flags=flags, date=date,
+ notify_on_disk=notify_on_disk)
return d
def notify_new(self, *args):
@@ -499,6 +505,7 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
l.newMessages(exists, recent)
d = self._get_notify_count()
d.addCallback(cbNotifyNew)
+ d.addCallback(self.cb_signal_unread_to_ui)
@deferred_to_thread
def _get_notify_count(self):