summaryrefslogtreecommitdiff
path: root/src/leap/baseapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/baseapp')
-rw-r--r--src/leap/baseapp/eip.py1
-rw-r--r--src/leap/baseapp/leap_app.py2
-rw-r--r--src/leap/baseapp/mainwindow.py12
-rw-r--r--src/leap/baseapp/network.py21
-rw-r--r--src/leap/baseapp/systray.py7
5 files changed, 34 insertions, 9 deletions
diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py
index 54acbc0e..55ecfa79 100644
--- a/src/leap/baseapp/eip.py
+++ b/src/leap/baseapp/eip.py
@@ -203,7 +203,6 @@ class EIPConductorAppMixin(object):
# we could bring Timer Init to this Mixin
# or to its own Mixin.
self.timer.start(constants.TIMER_MILLISECONDS)
- self.network_checker.start()
return
if self.eip_service_started is True:
diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py
index 4b63dd2f..4d3aebd6 100644
--- a/src/leap/baseapp/leap_app.py
+++ b/src/leap/baseapp/leap_app.py
@@ -148,6 +148,6 @@ class MainWindowMixin(object):
# in conductor
# XXX send signal instead?
logger.info('Shutting down')
- self.conductor.cleanup()
+ self.conductor.disconnect(shutdown=True)
logger.info('Exiting. Bye.')
QtGui.qApp.quit()
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index 8d61bf5c..02adab65 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -41,6 +41,7 @@ class LeapWindow(QtGui.QMainWindow,
triggerEIPError = QtCore.pyqtSignal([object])
start_eipconnection = QtCore.pyqtSignal([])
shutdownSignal = QtCore.pyqtSignal([])
+ initNetworkChecker = QtCore.pyqtSignal([])
# this is status change got from openvpn management
openvpnStatusChange = QtCore.pyqtSignal([object])
@@ -61,10 +62,15 @@ class LeapWindow(QtGui.QMainWindow,
logger.debug('provider: %s', self.provider_domain)
logger.debug('eip_username: %s', self.eip_username)
+ provider = self.provider_domain
EIPConductorAppMixin.__init__(
- self, opts=opts, provider=self.provider_domain)
+ self, opts=opts, provider=provider)
StatusAwareTrayIconMixin.__init__(self)
- NetworkCheckerAppMixin.__init__(self)
+
+ # XXX network checker should probably not
+ # trigger run_checks on init... but wait
+ # for ready signal instead...
+ NetworkCheckerAppMixin.__init__(self, provider=provider)
MainWindowMixin.__init__(self)
geom_key = "DebugGeometry" if self.debugmode else "Geometry"
@@ -97,6 +103,8 @@ class LeapWindow(QtGui.QMainWindow,
lambda: self.start_or_stopVPN())
self.shutdownSignal.connect(
self.cleanupAndQuit)
+ self.initNetworkChecker.connect(
+ lambda: self.init_network_checker(self.provider_domain))
# status change.
# TODO unify
diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py
index 077d5164..a33265e5 100644
--- a/src/leap/baseapp/network.py
+++ b/src/leap/baseapp/network.py
@@ -9,19 +9,30 @@ from PyQt4 import QtCore
from leap.baseapp.dialogs import ErrorDialog
from leap.base.network import NetworkCheckerThread
+from leap.util.misc import null_check
+
class NetworkCheckerAppMixin(object):
"""
initialize an instance of the Network Checker,
which gathers error and passes them on.
"""
-
def __init__(self, *args, **kwargs):
- self.network_checker = NetworkCheckerThread(
- error_cb=self.networkError.emit,
- debug=self.debugmode)
+ provider = kwargs.pop('provider', None)
+ if provider:
+ self.init_network_checker(provider)
+
+ def init_network_checker(self, provider):
+ null_check(provider, "provider_domain")
+ if not hasattr(self, 'network_checker'):
+ self.network_checker = NetworkCheckerThread(
+ error_cb=self.networkError.emit,
+ debug=self.debugmode,
+ provider=provider)
+ self.network_checker.start()
- # XXX move run_checks to slot
+ @QtCore.pyqtSlot(object)
+ def runNetworkChecks(self):
self.network_checker.run_checks()
@QtCore.pyqtSlot(object)
diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py
index 49f044aa..0dd0f195 100644
--- a/src/leap/baseapp/systray.py
+++ b/src/leap/baseapp/systray.py
@@ -217,6 +217,8 @@ class StatusAwareTrayIconMixin(object):
updates icon, according to the openvpn status change.
"""
icon_name = self.conductor.get_icon_name()
+ if not icon_name:
+ return
# XXX refactor. Use QStateMachine
@@ -228,6 +230,11 @@ class StatusAwareTrayIconMixin(object):
leap_status_name = self.conductor.get_leap_status()
self.eipStatusChange.emit(leap_status_name)
+ if icon_name == "connected":
+ # When we change to "connected', we launch
+ # the network checker.
+ self.initNetworkChecker.emit()
+
self.setIcon(icon_name)
# change connection pixmap widget
self.setConnWidget(icon_name)