summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap/service/imap.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/mail/imap/service/imap.py')
-rw-r--r--src/leap/mail/imap/service/imap.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/leap/mail/imap/service/imap.py b/src/leap/mail/imap/service/imap.py
index 6b2a61d..9e9a524 100644
--- a/src/leap/mail/imap/service/imap.py
+++ b/src/leap/mail/imap/service/imap.py
@@ -20,28 +20,27 @@ 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
-IMAP_PORT = 1984
# The default port in which imap service will run
+IMAP_PORT = 1984
-# TODO: Make this configurable
-INCOMING_CHECK_PERIOD = 5
-#INCOMING_CHECK_PERIOD = 60
# The period between succesive checks of the incoming mail
# queue (in seconds)
+INCOMING_CHECK_PERIOD = 300
from leap.common.events.events_pb2 import IMAP_SERVICE_STARTED
from leap.common.events.events_pb2 import IMAP_SERVICE_FAILED_TO_START
@@ -164,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))