From 886d04167e51ba07a71393bad5c41b04023db527 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 2 Oct 2012 06:43:15 +0900 Subject: moved eip checks to qthread to let icon show early --- src/leap/app.py | 4 ++++ src/leap/baseapp/eip.py | 24 +++++++++++++++--------- src/leap/baseapp/leap_app.py | 4 ++-- src/leap/baseapp/mainwindow.py | 23 ++++++++++++++++++----- src/leap/baseapp/systray.py | 1 + 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/leap/app.py b/src/leap/app.py index 52ebcaea..3170de4a 100644 --- a/src/leap/app.py +++ b/src/leap/app.py @@ -60,6 +60,10 @@ def main(): window = LeapWindow(opts) if debug: + # we only show the main window + # if debug mode active. + # if not, it will be set visible + # from the systray menu. window.show() sys.exit(app.exec_()) diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index b0e14be7..8007d2b7 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 fffff0bb..98ca292e 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -23,9 +23,8 @@ class MainWindowMixin(object): widget = QtGui.QWidget() self.setCentralWidget(widget) - #self.createWindowHeader() - # add widgets to layout + #self.createWindowHeader() mainLayout = QtGui.QVBoxLayout() #mainLayout.addWidget(self.headerBox) mainLayout.addWidget(self.statusIconBox) @@ -38,6 +37,7 @@ class MainWindowMixin(object): self.set_app_icon() self.resize(400, 300) self.set_statusbarMessage('ready') + logger.debug('set ready.........') def set_app_icon(self): icon = QtGui.QIcon(APP_LOGO) diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 10b23d9a..55be55f7 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -38,8 +38,11 @@ class LeapWindow(QtGui.QMainWindow, StatusAwareTrayIconMixin.__init__(self) MainWindowMixin.__init__(self) + 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)) @@ -50,7 +53,17 @@ class LeapWindow(QtGui.QMainWindow, # ... all ready. go! - # could send "ready" signal instead - # eipapp should catch that - if self.conductor.autostart: - self.start_or_stopVPN() + 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() + + def begin(self): + self.start() diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 39a23f49..0ab37f7f 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... -- cgit v1.2.3