summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorantialias <antialias@leap.se>2012-10-01 15:10:55 -0400
committerantialias <antialias@leap.se>2012-10-01 15:10:55 -0400
commit95ce59c8833cb2ba951630080cdbc1e6d756a666 (patch)
tree8434a07650ef78497daff7e2f9f100a500adf9b4 /src
parentc75b27484a999f70a6e28e521f236cf2d403edd1 (diff)
Still some QT related problems. Hand off to kali to fix.
Diffstat (limited to 'src')
-rw-r--r--src/leap/base/network.py8
-rw-r--r--src/leap/baseapp/mainwindow.py14
-rw-r--r--src/leap/baseapp/network.py36
3 files changed, 18 insertions, 40 deletions
diff --git a/src/leap/base/network.py b/src/leap/base/network.py
index 92fb7635..159e9b21 100644
--- a/src/leap/base/network.py
+++ b/src/leap/base/network.py
@@ -21,15 +21,15 @@ class NetworkChecker(object):
def __init__(self, *args, **kwargs):
self.status_signals = kwargs.pop('status_signals', None)
self.watcher_cb = kwargs.pop('status_signals', None)
- self.excp_logger = lambda exc: logger.error("%s", exc.message)
+ self.error_cb = kwargs.pop('error_cb',
+ lambda exc: logger.error("%s", exc.message))
self.shutdown = threading.Event()
self.checker = LeapNetworkChecker()
def start(self):
- self.process_handle = self._launch_recurrent_network_checks((self.excp_logger,))
+ self.process_handle = self._launch_recurrent_network_checks((self.error_cb,))
def stop(self):
- #TODO: Thread still not being stopped when openvpn is stopped.
self.shutdown.set()
logger.debug("network checked stopped.")
@@ -70,5 +70,3 @@ class NetworkChecker(object):
self._network_checks_thread,
(fail_callbacks,))
return watcher
-
-
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index 7b2ecb1d..000db8c9 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -28,6 +28,7 @@ class LeapWindow(QtGui.QMainWindow,
newLogLine = QtCore.pyqtSignal([str])
statusChange = QtCore.pyqtSignal([object])
+ networkError = QtCore.pyqtSignal([object])
def __init__(self, opts):
logger.debug('init leap window')
@@ -57,3 +58,16 @@ class LeapWindow(QtGui.QMainWindow,
# eipapp should catch that
if self.conductor.autostart:
self.start_or_stopVPN()
+
+ #TODO: Put all Dialogs in one place
+ @QtCore.pyqtSlot()
+ def raise_Network_Error(self, exc):
+ message = exc.message
+
+ # XXX
+ # check headless = False before
+ # launching dialog.
+ # (so Qt tests can assert stuff)
+
+ dialog = ErrorDialog()
+ dialog.warningMessage(message, 'error')
diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py
index 75690cc9..c73e8062 100644
--- a/src/leap/baseapp/network.py
+++ b/src/leap/baseapp/network.py
@@ -14,44 +14,10 @@ class NetworkCheckerAppMixin(object):
"""
def __init__(self, *args, **kwargs):
- opts = kwargs.pop('opts', None)
- config_file = getattr(opts, 'config_file', None)
-
- self.network_checker_started = False
-
self.network_checker = NetworkChecker(
watcher_cb=self.newLogLine.emit,
- status_signals=(self.statusChange.emit, ),
+ error_cb=self.handle_network_error,
debug=self.debugmode)
self.network_checker.run_checks()
- self.error_check()
-
- def error_check(self):
- """
- consumes the conductor error queue.
- pops errors, and acts accordingly (launching user dialogs).
- """
- logger.debug('error check')
-
- errq = self.conductor.error_queue
- while errq.qsize() != 0:
- logger.debug('%s errors left in network queue', errq.qsize())
- # we get exception and original traceback from queue
- error, tb = errq.get()
-
- # redundant log, debugging the loop.
- logger.error('%s: %s', error.__class__.__name__, error.message)
-
- if issubclass(error.__class__, eip_exceptions.EIPClientError):
- self.handle_network_error(error)
-
- else:
- # deprecated form of raising exception.
- raise error, None, tb
-
- if error.failfirst is True:
- break
- def handle_network_error(self, error):
- pass