diff options
Diffstat (limited to 'mail/src/leap')
-rw-r--r-- | mail/src/leap/mail/imap/fetch.py | 10 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/server.py | 5 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/service/imap-server.tac | 2 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/service/imap.py | 17 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/tests/__init__.py | 4 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/tests/test_imap.py | 4 | ||||
-rw-r--r-- | mail/src/leap/mail/smtp/__init__.py | 5 | ||||
-rw-r--r-- | mail/src/leap/mail/smtp/tests/__init__.py | 2 |
8 files changed, 27 insertions, 22 deletions
diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py index 592e4e32..2b25d820 100644 --- a/mail/src/leap/mail/imap/fetch.py +++ b/mail/src/leap/mail/imap/fetch.py @@ -29,7 +29,8 @@ from twisted.internet.threads import deferToThread from leap.common import events as leap_events from leap.common.check import leap_assert, leap_assert_type -from leap.soledad import Soledad +from leap.soledad.client import Soledad +from leap.soledad.common.crypto import ENC_SCHEME_KEY, ENC_JSON_KEY from leap.common.events.events_pb2 import IMAP_FETCHED_INCOMING from leap.common.events.events_pb2 import IMAP_MSG_PROCESSING @@ -47,9 +48,6 @@ class LeapIncomingMail(object): Fetches mail from the incoming queue. """ - ENC_SCHEME_KEY = "_enc_scheme" - ENC_JSON_KEY = "_enc_json" - RECENT_FLAG = "\\Recent" INCOMING_KEY = "incoming" @@ -157,11 +155,11 @@ class LeapIncomingMail(object): leap_events.signal( IMAP_MSG_PROCESSING, str(index), str(num_mails)) keys = doc.content.keys() - if self.ENC_SCHEME_KEY in keys and self.ENC_JSON_KEY in keys: + if ENC_SCHEME_KEY in keys and 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] + encdata = doc.content[ENC_JSON_KEY] defer.Deferred(self._decrypt_msg(doc, encdata)) else: logger.debug('This does not look like a proper msg.') diff --git a/mail/src/leap/mail/imap/server.py b/mail/src/leap/mail/imap/server.py index 7890a76b..a69eb3fc 100644 --- a/mail/src/leap/mail/imap/server.py +++ b/mail/src/leap/mail/imap/server.py @@ -36,10 +36,7 @@ from twisted.python import log #import u1db 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 +from leap.soledad.client import Soledad logger = logging.getLogger(__name__) diff --git a/mail/src/leap/mail/imap/service/imap-server.tac b/mail/src/leap/mail/imap/service/imap-server.tac index 16d04bb0..8638be29 100644 --- a/mail/src/leap/mail/imap/service/imap-server.tac +++ b/mail/src/leap/mail/imap/service/imap-server.tac @@ -3,7 +3,7 @@ import os from xdg import BaseDirectory -from leap.soledad import Soledad +from leap.soledad.client import Soledad from leap.mail.imap.service import imap diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py index 94c2c642..9e9a524f 100644 --- a/mail/src/leap/mail/imap/service/imap.py +++ b/mail/src/leap/mail/imap/service/imap.py @@ -20,19 +20,20 @@ Imap service initialization from copy import copy import logging -logger = logging.getLogger(__name__) from twisted.internet.protocol import ServerFactory - +from twisted.internet.error import CannotListenError from twisted.mail import imap4 from twisted.python import log +logger = logging.getLogger(__name__) + from leap.common import events as leap_events from leap.common.check import leap_assert, leap_assert_type from leap.keymanager import KeyManager from leap.mail.imap.server import SoledadBackedAccount from leap.mail.imap.fetch import LeapIncomingMail -from leap.soledad import Soledad +from leap.soledad.client import Soledad # The default port in which imap service will run IMAP_PORT = 1984 @@ -162,13 +163,17 @@ def run_service(*args, **kwargs): soledad, factory.theAccount, check_period) + except CannotListenError: + logger.error("IMAP Service failed to start: " + "cannot listen in port %s" % (port,)) except Exception as exc: - # XXX cannot listen? logger.error("Error launching IMAP service: %r" % (exc,)) - leap_events.signal(IMAP_SERVICE_FAILED_TO_START, str(port)) - return else: + # all good. fetcher.start_loop() logger.debug("IMAP4 Server is RUNNING in port %s" % (port,)) leap_events.signal(IMAP_SERVICE_STARTED, str(port)) return fetcher + + # not ok, signal error. + leap_events.signal(IMAP_SERVICE_FAILED_TO_START, str(port)) diff --git a/mail/src/leap/mail/imap/tests/__init__.py b/mail/src/leap/mail/imap/tests/__init__.py index fdeda76e..f3d5ca6f 100644 --- a/mail/src/leap/mail/imap/tests/__init__.py +++ b/mail/src/leap/mail/imap/tests/__init__.py @@ -22,8 +22,8 @@ import u1db from leap.common.testing.basetest import BaseLeapTest -from leap.soledad import Soledad -from leap.soledad.document import SoledadDocument +from leap.soledad.client import Soledad +from leap.soledad.common.document import SoledadDocument #----------------------------------------------------------------------------- diff --git a/mail/src/leap/mail/imap/tests/test_imap.py b/mail/src/leap/mail/imap/tests/test_imap.py index 8804fe0e..34117956 100644 --- a/mail/src/leap/mail/imap/tests/test_imap.py +++ b/mail/src/leap/mail/imap/tests/test_imap.py @@ -61,8 +61,8 @@ from leap.mail.imap.server import SoledadMailbox from leap.mail.imap.server import SoledadBackedAccount from leap.mail.imap.server import MessageCollection -from leap.soledad import Soledad -from leap.soledad import SoledadCrypto +from leap.soledad.client import Soledad +from leap.soledad.client import SoledadCrypto def strip(f): diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py index 54f5c810..d5d61bf0 100644 --- a/mail/src/leap/mail/smtp/__init__.py +++ b/mail/src/leap/mail/smtp/__init__.py @@ -18,10 +18,12 @@ """ SMTP relay helper function. """ +import logging from twisted.internet import reactor from twisted.internet.error import CannotListenError +logger = logging.getLogger(__name__) from leap.common.events import proto, signal from leap.mail.smtp.smtprelay import SMTPFactory @@ -76,4 +78,7 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port, reactor.listenTCP(port, factory) signal(proto.SMTP_SERVICE_STARTED, str(smtp_port)) except CannotListenError: + logger.error("STMP Service failed to start: " + "cannot listen in port %s" % ( + smtp_port,)) signal(proto.SMTP_SERVICE_FAILED_TO_START, str(smtp_port)) diff --git a/mail/src/leap/mail/smtp/tests/__init__.py b/mail/src/leap/mail/smtp/tests/__init__.py index d952405b..7fed7dae 100644 --- a/mail/src/leap/mail/smtp/tests/__init__.py +++ b/mail/src/leap/mail/smtp/tests/__init__.py @@ -29,7 +29,7 @@ from mock import Mock from twisted.trial import unittest -from leap.soledad import Soledad +from leap.soledad.client import Soledad from leap.keymanager import ( KeyManager, openpgp, |