summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-08-05 13:38:12 +0200
committerKali Kaneko <kali@leap.se>2013-08-06 16:50:11 +0200
commitf757e73a4d2fb05e90dba306c4d918f6aa7f1413 (patch)
treeac6354f902ee36d2f2f6ccdd3627aa0e92aa588c /src
parent63d1e561c7d3705196216e11dd8bf267de8fb8ff (diff)
start imap service
Diffstat (limited to 'src')
-rw-r--r--src/leap/gui/mainwindow.py61
-rw-r--r--src/leap/services/mail/imap.py4
2 files changed, 52 insertions, 13 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index c938a064..07ad9b9a 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -45,6 +45,7 @@ from leap.services.eip.providerbootstrapper import ProviderBootstrapper
# XXX: Soledad might not work out of the box in Windows, issue #2932
from leap.services.soledad.soledadbootstrapper import SoledadBootstrapper
from leap.services.mail.smtpbootstrapper import SMTPBootstrapper
+from leap.services.mail import imap
from leap.platform_init import IS_WIN, IS_MAC
from leap.platform_init.initializers import init_platform
@@ -94,6 +95,7 @@ class MainWindow(QtGui.QMainWindow):
# Signals
new_updates = QtCore.Signal(object)
raise_window = QtCore.Signal([])
+ soledad_ready = QtCore.Signal([])
# We use this flag to detect abnormal terminations
user_stopped_eip = False
@@ -140,6 +142,9 @@ class MainWindow(QtGui.QMainWindow):
self.ui.stackedWidget.widget(self.LOGIN_INDEX))
self.ui.loginLayout.addWidget(self._login_widget)
+ # Signals
+ # TODO separate logic from ui signals.
+
self._login_widget.login.connect(self._login)
self._login_widget.cancel_login.connect(self._cancel_login)
self._login_widget.show_wizard.connect(
@@ -260,7 +265,9 @@ class MainWindow(QtGui.QMainWindow):
self.ui.lblNewUpdates.setVisible(False)
self.ui.btnMore.setVisible(False)
self.ui.btnMore.clicked.connect(self._updates_details)
+
self.new_updates.connect(self._react_to_new_updates)
+ self.soledad_ready.connect(self._start_imap_service)
init_platform()
@@ -273,6 +280,7 @@ class MainWindow(QtGui.QMainWindow):
self._soledad = None
self._keymanager = None
+ self._imap_service = None
self._login_defer = None
self._download_provider_defer = None
@@ -949,6 +957,15 @@ class MainWindow(QtGui.QMainWindow):
self._soledad = self._soledad_bootstrapper.soledad
self._keymanager = self._soledad_bootstrapper.keymanager
+ # Ok, now soledad is ready, so we can allow other things that
+ # depend on soledad to start.
+
+ # this will trigger start_imap_service
+ self.soledad_ready.emit()
+
+ # TODO connect all these activations to the soledad_ready
+ # signal so the logic is clearer to follow.
+
if self._provider_config.provides_mx() and \
self._enabled_services.count(self.MX_SERVICE) > 0:
self._smtp_bootstrapper.run_smtp_setup_checks(
@@ -967,7 +984,7 @@ class MainWindow(QtGui.QMainWindow):
#self._status_panel.set_eip_status(
# self.tr("MX is disabled"))
- # Service control methods: eip
+ # Service control methods: smtp
def _smtp_bootstrapped_stage(self, data):
"""
@@ -1009,6 +1026,19 @@ class MainWindow(QtGui.QMainWindow):
smtp_key=client_cert,
encrypted_only=False)
+ def _start_imap_service(self):
+ """
+ SLOT
+ TRIGGERS:
+ soledad_ready
+ """
+ logger.debug('Starting imap service')
+ logger.debug('DEBUG: NOT STARTING IT REALLY ----------------')
+
+ #self._imap_service = imap.start_imap_service(
+ #self._soledad,
+ #self._keymanager)
+
def _get_socket_host(self):
"""
Returns the socket and port to be used for VPN
@@ -1398,6 +1428,9 @@ class MainWindow(QtGui.QMainWindow):
"""
logger.debug('About to quit, doing cleanup...')
+ if self._imap_service is not None:
+ self._imap_service.stop()
+
if self._srp_auth is not None:
if self._srp_auth.get_session_id() is not None or \
self._srp_auth.get_token() is not None:
@@ -1410,16 +1443,28 @@ class MainWindow(QtGui.QMainWindow):
else:
logger.error("No instance of soledad was found.")
- logger.debug('Cleaning pidfiles')
- self._cleanup_pidfiles()
-
logger.debug('Terminating vpn')
self._vpn.terminate(shutdown=True)
+ if self._login_defer:
+ logger.debug("Cancelling login defer.")
+ self._login_defer.cancel()
+
+ if self._download_provider_defer:
+ logger.debug("Cancelling download provider defer.")
+ self._download_provider_defer.cancel()
+
+ # TODO missing any more cancels?
+
+ logger.debug('Cleaning pidfiles')
+ self._cleanup_pidfiles()
+
def quit(self):
"""
Cleanup and tidely close the main window before quitting.
"""
+ # TODO: separate the shutting down of services from the
+ # UI stuff.
self._cleanup_and_quit()
self._really_quit = True
@@ -1430,14 +1475,6 @@ class MainWindow(QtGui.QMainWindow):
if self._logger_window:
self._logger_window.close()
- if self._login_defer:
- logger.debug("Cancelling login defer.")
- self._login_defer.cancel()
-
- if self._download_provider_defer:
- logger.debug("Cancelling download provider defer.")
- self._download_provider_defer.cancel()
-
self.close()
if self._quit_callback:
diff --git a/src/leap/services/mail/imap.py b/src/leap/services/mail/imap.py
index 65fbe3b5..5fdc7492 100644
--- a/src/leap/services/mail/imap.py
+++ b/src/leap/services/mail/imap.py
@@ -29,6 +29,8 @@ logger = logging.getLogger(__name__)
def start_imap_service(*args, **kwargs):
"""
Initializes and run imap service.
+
+ :returns: twisted.internet.task.LoopingCall instance
"""
logger.debug('Launching imap service')
@@ -36,4 +38,4 @@ def start_imap_service(*args, **kwargs):
log.startLogging(open('/tmp/leap-imap.log', 'w'))
log.startLogging(sys.stdout)
- imap.run_service(*args, **kwargs)
+ return imap.run_service(*args, **kwargs)