summaryrefslogtreecommitdiff
path: root/src/leap/baseapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/baseapp')
-rw-r--r--src/leap/baseapp/eip.py24
-rw-r--r--src/leap/baseapp/leap_app.py58
-rw-r--r--src/leap/baseapp/mainwindow.py72
-rw-r--r--src/leap/baseapp/systray.py1
4 files changed, 129 insertions, 26 deletions
diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py
index ad074abc..e291de34 100644
--- a/src/leap/baseapp/eip.py
+++ b/src/leap/baseapp/eip.py
@@ -40,22 +40,28 @@ class EIPConductorAppMixin(object):
debug=self.debugmode,
ovpn_verbosity=opts.openvpn_verb)
- skip_download = opts.no_provider_checks
- skip_verify = opts.no_ca_verify
+ self.skip_download = opts.no_provider_checks
+ self.skip_verify = opts.no_ca_verify
+
+ def run_eip_checks(self):
+ """
+ runs eip checks and
+ the error checking loop
+ """
+ logger.debug('running EIP CHECKS')
self.conductor.run_checks(
- skip_download=skip_download,
- skip_verify=skip_verify)
+ skip_download=self.skip_download,
+ skip_verify=self.skip_verify)
self.error_check()
- # XXX should receive "ready" signal
- # it is called from LeapWindow now.
- #if self.conductor.autostart:
- #self.start_or_stopVPN()
-
if self.debugmode:
self.startStopButton.clicked.connect(
lambda: self.start_or_stopVPN())
+ # XXX should send ready signal instead
+ if self.conductor.autostart:
+ self.start_or_stopVPN()
+
def error_check(self):
"""
consumes the conductor error queue.
diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py
index 208c4e7c..460d1269 100644
--- a/src/leap/baseapp/leap_app.py
+++ b/src/leap/baseapp/leap_app.py
@@ -1,5 +1,9 @@
import logging
+import sip
+sip.setapi('QVariant', 2)
+
+from PyQt4 import QtCore
from PyQt4 import QtGui
from leap.gui import mainwindow_rc
@@ -23,22 +27,62 @@ class MainWindowMixin(object):
widget = QtGui.QWidget()
self.setCentralWidget(widget)
- self.createWindowHeader()
-
- # add widgets to layout
mainLayout = QtGui.QVBoxLayout()
- mainLayout.addWidget(self.headerBox)
+ # add widgets to layout
+ #self.createWindowHeader()
+ #mainLayout.addWidget(self.headerBox)
mainLayout.addWidget(self.statusIconBox)
if self.debugmode:
mainLayout.addWidget(self.statusBox)
mainLayout.addWidget(self.loggerBox)
widget.setLayout(mainLayout)
+ self.createMainActions()
+ self.createMainMenus()
+
self.setWindowTitle("LEAP Client")
self.set_app_icon()
- self.resize(400, 300)
self.set_statusbarMessage('ready')
+ def createMainActions(self):
+ #self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O",
+ #triggered=self.open)
+
+ self.firstRunWizardAct = QtGui.QAction(
+ "&First run wizard...", self,
+ triggered=self.launch_first_run_wizard)
+ self.aboutAct = QtGui.QAction("&About", self, triggered=self.about)
+
+ #self.aboutQtAct = QtGui.QAction("About &Qt", self,
+ #triggered=QtGui.qApp.aboutQt)
+
+ def createMainMenus(self):
+ self.connMenu = QtGui.QMenu("&Connections", self)
+ #self.viewMenu.addSeparator()
+ self.connMenu.addAction(self.quitAction)
+
+ self.settingsMenu = QtGui.QMenu("&Settings", self)
+ self.settingsMenu.addAction(self.firstRunWizardAct)
+
+ self.helpMenu = QtGui.QMenu("&Help", self)
+ self.helpMenu.addAction(self.aboutAct)
+ #self.helpMenu.addAction(self.aboutQtAct)
+
+ self.menuBar().addMenu(self.connMenu)
+ self.menuBar().addMenu(self.settingsMenu)
+ self.menuBar().addMenu(self.helpMenu)
+
+ def launch_first_run_wizard(self):
+ settings = QtCore.QSettings()
+ settings.setValue('FirstRunWizardDone', False)
+ logger.debug('should run first run wizard again...')
+
+ from leap.gui.firstrunwizard import FirstRunWizard
+ wizard = FirstRunWizard(
+ parent=self,
+ success_cb=self.initReady.emit)
+ wizard.show()
+
def set_app_icon(self):
icon = QtGui.QIcon(APP_LOGO)
self.setWindowIcon(icon)
@@ -88,6 +132,10 @@ class MainWindowMixin(object):
"""
cleans state before shutting down app.
"""
+ # save geometry for restoring
+ settings = QtCore.QSettings()
+ settings.setValue("Geometry", self.saveGeometry())
+
# TODO:make sure to shutdown all child process / threads
# in conductor
# XXX send signal instead?
diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py
index fdbaf693..09e0c0bb 100644
--- a/src/leap/baseapp/mainwindow.py
+++ b/src/leap/baseapp/mainwindow.py
@@ -29,22 +29,33 @@ class LeapWindow(QtGui.QMainWindow,
newLogLine = QtCore.pyqtSignal([str])
statusChange = QtCore.pyqtSignal([object])
+ mainappReady = QtCore.pyqtSignal([])
+ initReady = QtCore.pyqtSignal([])
networkError = QtCore.pyqtSignal([object])
def __init__(self, opts):
logger.debug('init leap window')
self.debugmode = getattr(opts, 'debug', False)
-
super(LeapWindow, self).__init__()
if self.debugmode:
self.createLogBrowser()
+
EIPConductorAppMixin.__init__(self, opts=opts)
StatusAwareTrayIconMixin.__init__(self)
NetworkCheckerAppMixin.__init__(self)
MainWindowMixin.__init__(self)
+ settings = QtCore.QSettings()
+ geom = settings.value("Geometry")
+ if geom:
+ self.restoreGeometry(geom)
+ self.wizard_done = settings.value("FirstRunWizardDone")
+
+ self.initchecks = InitChecksThread(self.run_eip_checks)
+
# bind signals
- # XXX move to parent classes init??
+ self.initchecks.finished.connect(
+ lambda: logger.debug('Initial checks finished'))
self.trayIcon.activated.connect(self.iconActivated)
self.newLogLine.connect(
lambda line: self.onLoggerNewLine(line))
@@ -55,22 +66,59 @@ class LeapWindow(QtGui.QMainWindow,
self.networkError.connect(
lambda exc: self.onNetworkError(exc))
+ # do frwizard and init signals
+ self.mainappReady.connect(self.do_first_run_wizard_check)
+ self.initReady.connect(self.runchecks_and_eipconnect)
+
# ... all ready. go!
+ # calls do_first_run_wizard_check
+ self.mainappReady.emit()
+
+ def do_first_run_wizard_check(self):
+ logger.debug('first run wizard check...')
+ if self.wizard_done:
+ self.initReady.emit()
+ else:
+ # need to run first-run-wizard
+ logger.debug('running first run wizard')
+ from leap.gui.firstrunwizard import FirstRunWizard
+ wizard = FirstRunWizard(
+ parent=self,
+ success_cb=self.initReady.emit)
+ wizard.show()
+
+ def runchecks_and_eipconnect(self):
+ self.initchecks.begin()
+
+class InitChecksThread(QtCore.QThread):
+
+ def __init__(self, fun, parent=None):
+ QtCore.QThread.__init__(self, parent)
+ self.fun = fun
+
+ def run(self):
+ self.fun()
+
+#<<<<<<< HEAD
+ def begin(self):
+ self.start()
+#=======
# could send "ready" signal instead
# eipapp should catch that
- if self.conductor.autostart:
- self.start_or_stopVPN()
-
+ #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
-
+ #@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 = dialogs.ErrorDialog()
- dialog.warningMessage(message, 'error')
+#
+ #dialog = dialogs.ErrorDialog()
+ #dialog.warningMessage(message, 'error')
+#>>>>>>> feature/network_check
diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py
index adcfe9b9..1939bc09 100644
--- a/src/leap/baseapp/systray.py
+++ b/src/leap/baseapp/systray.py
@@ -41,6 +41,7 @@ class StatusAwareTrayIconMixin(object):
self.createIconGroupBox()
self.createActions()
self.createTrayIcon()
+ logger.debug('showing tray icon................')
self.trayIcon.show()
# not sure if this really belongs here, but...