summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap/service/imap.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-08-06 10:10:43 -0300
committerTomás Touceda <chiiph@leap.se>2013-08-06 10:10:43 -0300
commitefe498757821622f4f0661a3ed13babb9c41aa02 (patch)
tree9610f3d88591834c7b75180409aa1fa00f4947df /src/leap/mail/imap/service/imap.py
parentf619933783d5c863ece67d68c034236508beea93 (diff)
parent2c2f3a291d33591190af4cefbcd2225c11e86712 (diff)
Merge remote-tracking branch 'kali/feature/refactor_imap_fetch' into develop
Diffstat (limited to 'src/leap/mail/imap/service/imap.py')
-rw-r--r--src/leap/mail/imap/service/imap.py32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/leap/mail/imap/service/imap.py b/src/leap/mail/imap/service/imap.py
index 49d54e3..9e331b6 100644
--- a/src/leap/mail/imap/service/imap.py
+++ b/src/leap/mail/imap/service/imap.py
@@ -20,15 +20,13 @@ Imap service initialization
import logging
logger = logging.getLogger(__name__)
-#from twisted.application import internet, service
from twisted.internet.protocol import ServerFactory
-from twisted.internet.task import LoopingCall
from twisted.mail import imap4
from twisted.python import log
from leap.common.check import leap_assert, leap_assert_type
-from leap.common.keymanager import KeyManager
+from leap.keymanager import KeyManager
from leap.mail.imap.server import SoledadBackedAccount
from leap.mail.imap.fetch import LeapIncomingMail
from leap.soledad import Soledad
@@ -36,8 +34,8 @@ from leap.soledad import Soledad
IMAP_PORT = 9930
# The default port in which imap service will run
-#INCOMING_CHECK_PERIOD = 10
-INCOMING_CHECK_PERIOD = 5
+# INCOMING_CHECK_PERIOD = 5
+INCOMING_CHECK_PERIOD = 60
# The period between succesive checks of the incoming mail
# queue (in seconds)
@@ -127,6 +125,9 @@ class LeapIMAPFactory(ServerFactory):
def run_service(*args, **kwargs):
"""
Main entry point to run the service from the client.
+
+ :returns: the LoopingCall instance that will have to be stoppped
+ before shutting down the client.
"""
leap_assert(len(args) == 2)
soledad, keymanager = args
@@ -139,29 +140,16 @@ def run_service(*args, **kwargs):
uuid = soledad._get_uuid()
factory = LeapIMAPFactory(uuid, soledad)
- # ---- for application framework
- #application = service.Application("LEAP IMAP4 Local Service")
- #imapService = internet.TCPServer(port, factory)
- #imapService.setServiceParent(application)
-
from twisted.internet import reactor
reactor.listenTCP(port, factory)
fetcher = LeapIncomingMail(
keymanager,
soledad,
- factory.theAccount)
+ factory.theAccount,
+ check_period)
- lc = LoopingCall(fetcher.fetch)
- lc.start(check_period)
+ fetcher.start_loop()
- # ---- for application framework
- #internet.TimerService(
- #check_period,
- #fetcher.fetch).setServiceParent(application)
-
- logger.debug('----------------------------------------')
logger.debug("IMAP4 Server is RUNNING in port %s" % (port,))
-
- #log.msg("IMAP4 Server is RUNNING in port %s" % (port,))
- #return application
+ return fetcher