diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-08-08 10:39:21 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-08-08 10:39:21 -0300 |
commit | 2d61fd7a27aad51092ccf831c76ce1cd993dacd1 (patch) | |
tree | 1d03c1deaf01bd23050f56bbe7a740caba473604 /src/leap | |
parent | efe498757821622f4f0661a3ed13babb9c41aa02 (diff) | |
parent | 3b005c339e9dc26105b907ccc37c014a9c6734b8 (diff) |
Merge remote-tracking branch 'kali/bug/fix-imap-incoming-processing-r2' into develop
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/mail/imap/fetch.py | 19 | ||||
-rw-r--r-- | src/leap/mail/imap/service/imap.py | 5 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/leap/mail/imap/fetch.py b/src/leap/mail/imap/fetch.py index 1c41813..44b3124 100644 --- a/src/leap/mail/imap/fetch.py +++ b/src/leap/mail/imap/fetch.py @@ -92,7 +92,7 @@ class LeapIncomingMail(object): """ Stops the loop that fetches mail. """ - if self._loop: + if self._loop and self._loop.running is True: self._loop.stop() def _sync_soledad(self): @@ -102,7 +102,7 @@ class LeapIncomingMail(object): try: self._soledad.sync() doclist = self._soledad.get_from_index("just-mail", "*") - #log.msg("there are %s mails" % (len(doclist),)) + log.msg("there are %s mails" % (len(doclist),)) return doclist except ssl.SSLError as exc: logger.warning('SSL Error while syncing soledad: %r' % (exc,)) @@ -116,16 +116,20 @@ class LeapIncomingMail(object): def _process_doclist(self, doclist): log.msg('processing doclist') if not doclist: + logger.debug("no docs found") return for doc in doclist: + logger.debug("processing doc: %s" % doc) keys = doc.content.keys() if self.ENC_SCHEME_KEY in keys and self.ENC_JSON_KEY in keys: # XXX should check for _enc_scheme == "pubkey" || "none" # that is what incoming mail uses. encdata = doc.content[self.ENC_JSON_KEY] - d = defer.Deferred(self._decrypt_msg, doc, encdata) - d.addCallback(self._process_decrypted) + d = defer.Deferred(self._decrypt_msg(doc, encdata)) + d.addCallbacks(self._process_decrypted, log.msg) + else: + logger.debug('This does not look like a proper msg.') def _decrypt_msg(self, doc, encdata): log.msg('decrypting msg') @@ -134,7 +138,9 @@ class LeapIncomingMail(object): encdata, key, # XXX get from public method instead passphrase=self._soledad._passphrase)) - return doc, decrdata + + # XXX TODO: defer this properly + return self._process_decrypted(doc, decrdata) def _process_decrypted(self, doc, data): """ @@ -162,10 +168,9 @@ class LeapIncomingMail(object): if not rawmsg: return False logger.debug('got incoming message: %s' % (rawmsg,)) - #log.msg("we got raw message") # add to inbox and delete from soledad - self.inbox.addMessage(rawmsg, (self.RECENT_FLAG,)) + self._inbox.addMessage(rawmsg, (self.RECENT_FLAG,)) doc_id = doc.doc_id self._soledad.delete_doc(doc) log.msg("deleted doc %s from incoming" % doc_id) diff --git a/src/leap/mail/imap/service/imap.py b/src/leap/mail/imap/service/imap.py index 9e331b6..2ae3012 100644 --- a/src/leap/mail/imap/service/imap.py +++ b/src/leap/mail/imap/service/imap.py @@ -34,8 +34,9 @@ from leap.soledad import Soledad IMAP_PORT = 9930 # The default port in which imap service will run -# INCOMING_CHECK_PERIOD = 5 -INCOMING_CHECK_PERIOD = 60 +# TODO: Make this configurable +INCOMING_CHECK_PERIOD = 5 +#INCOMING_CHECK_PERIOD = 60 # The period between succesive checks of the incoming mail # queue (in seconds) |