summaryrefslogtreecommitdiff
path: root/src/leap/baseapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/baseapp')
-rw-r--r--src/leap/baseapp/eip.py45
-rw-r--r--src/leap/baseapp/leap_app.py4
-rw-r--r--src/leap/baseapp/log.py4
-rw-r--r--src/leap/baseapp/mainwindow.py6
-rw-r--r--src/leap/baseapp/systray.py10
5 files changed, 49 insertions, 20 deletions
diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py
index a67fd916..6c3249ff 100644
--- a/src/leap/baseapp/eip.py
+++ b/src/leap/baseapp/eip.py
@@ -8,19 +8,25 @@ from leap.eip.eipconnection import EIPConnection
class EIPConductorApp(object):
+ """
+ initializes an instance of EIPConnection,
+ gathers errors, and passes status-change signals
+ from Qt land along to the conductor.
+ Connects the eip connect/disconnect logic
+ to the switches in the app (buttons/menu items).
+ """
def __init__(self, *args, **kwargs):
- #
- # conductor is in charge of all
- # vpn-related configuration / monitoring.
- # we pass a tuple of signals that will be
- # triggered when status changes.
- #
opts = kwargs.pop('opts')
config_file = getattr(opts, 'config_file', None)
self.eip_service_started = False
+ # conductor (eip connection) is in charge of all
+ # vpn-related configuration / monitoring.
+ # we pass a tuple of signals that will be
+ # triggered when status changes.
+
self.conductor = EIPConnection(
watcher_cb=self.newLogLine.emit,
config_file=config_file,
@@ -32,20 +38,18 @@ class EIPConductorApp(object):
self.error_check()
# XXX should receive "ready" signal
+ # it is called from LeapWindow now.
#if self.conductor.autostart:
#self.start_or_stopVPN()
- # move to eipconductor init?
if self.debugmode:
self.startStopButton.clicked.connect(
lambda: self.start_or_stopVPN())
def error_check(self):
- ####### error checking ################
- #
- # bunch of self checks.
- # XXX move somewhere else alltogether.
- #
+
+ # XXX refactor (by #504)
+
if self.conductor.missing_definition is True:
dialog = ErrorDialog()
dialog.criticalMessage(
@@ -105,22 +109,23 @@ class EIPConductorApp(object):
@QtCore.pyqtSlot()
def statusUpdate(self):
"""
- called on timer tick
polls status and updates ui with real time
info about transferred bytes / connection state.
+ right now is triggered by a timer tick
+ (timer controlled by StatusAwareTrayIcon class)
"""
- # XXX it's too expensive to poll
+ # TODO I guess it's too expensive to poll
# continously. move to signal events instead.
+ # (i.e., subscribe to connection status changes
+ # from openvpn manager)
if not self.eip_service_started:
return
- # XXX remove all access to manager layer
- # from here.
if self.conductor.with_errors:
#XXX how to wait on pkexec???
#something better that this workaround, plz!!
- time.sleep(5)
+ time.sleep(2)
print('errors. disconnect.')
self.start_or_stopVPN() # is stop
@@ -173,8 +178,14 @@ class EIPConductorApp(object):
# too little is overkill, too much
# will miss transition states..
+ # XXX decouple! (timer is init by icons class).
+ # should bring it here?
+ # to its own class?
+
+ # XXX get constant from somewhere else
self.timer.start(250.0)
return
+
if self.eip_service_started is True:
self.conductor.disconnect()
if self.debugmode:
diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py
index 1b4d7747..def95da1 100644
--- a/src/leap/baseapp/leap_app.py
+++ b/src/leap/baseapp/leap_app.py
@@ -4,6 +4,10 @@ from leap.gui import mainwindow_rc
class MainWindow(object):
+ """
+ create the main window
+ for leap app
+ """
def __init__(self, *args, **kwargs):
# XXX set initial visibility
diff --git a/src/leap/baseapp/log.py b/src/leap/baseapp/log.py
index 139de845..0c98eb94 100644
--- a/src/leap/baseapp/log.py
+++ b/src/leap/baseapp/log.py
@@ -3,6 +3,10 @@ from PyQt4 import QtCore
class LogPane(object):
+ """
+ a simple log pane
+ that writes new lines as they come
+ """
def createLogBrowser(self):
"""
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index 7cd02979..ac7fe9c4 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -18,6 +18,12 @@ class LeapWindow(QtGui.QMainWindow,
MainWindow, EIPConductorApp,
StatusAwareTrayIcon,
LogPane):
+ """
+ main window for the leap app.
+ Initializes all of its base classes
+ We keep here some signal initialization
+ that gets tricky otherwise.
+ """
newLogLine = QtCore.pyqtSignal([str])
statusChange = QtCore.pyqtSignal([object])
diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py
index 249a4f7e..3fb64db1 100644
--- a/src/leap/baseapp/systray.py
+++ b/src/leap/baseapp/systray.py
@@ -5,16 +5,20 @@ from leap.gui import mainwindow_rc
class StatusAwareTrayIcon(object):
+ """
+ a mix of several functions needed
+ to create a systray and make it
+ get updated from conductor status
+ polling.
+ """
def __init__(self, *args, **kwargs):
- # StatusAwareTrayIcon init ###################
self.createIconGroupBox()
self.createActions()
self.createTrayIcon()
-
self.trayIcon.show()
- ##############################################
+ # not sure if this really belongs here, but...
self.timer = QtCore.QTimer()
def createIconGroupBox(self):