From ac67079632fb96d9da463e0cc9f2367b0ba6886e Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 24 Oct 2012 01:16:05 +0900 Subject: save geometry (was badly merged) --- src/leap/baseapp/mainwindow.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 3b6cb544..df7159ce 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -48,17 +48,18 @@ class LeapWindow(QtGui.QMainWindow, if self.debugmode: self.createLogBrowser() - EIPConductorAppMixin.__init__(self, opts=opts) + settings = QtCore.QSettings() + provider_domain = settings.value("provider_domain", None) + logger.debug('provider: %s', provider_domain) + + EIPConductorAppMixin.__init__( + self, opts=opts, provider=provider_domain) StatusAwareTrayIconMixin.__init__(self) NetworkCheckerAppMixin.__init__(self) MainWindowMixin.__init__(self) - settings = QtCore.QSettings() - geom_key = "DebugGeometry" if self.debugmode else "Geometry" geom = settings.value(geom_key) - - geom = settings.value("Geometry") if geom: self.restoreGeometry(geom) self.wizard_done = settings.value("FirstRunWizardDone") -- cgit v1.2.3 From 0060d3c74adce19fab7215b3788c5197cc05a9ae Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 24 Oct 2012 04:05:19 +0900 Subject: sign up branch ends by triggering eip connection still need to bind signals properly, and block on the validation process until we receive the "connected" signal. but the basic flow is working again, i.e, user should be able to remove the .config/leap folder and get all the needed info from the provider. --- src/leap/baseapp/mainwindow.py | 52 +++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 13 deletions(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index df7159ce..752dba51 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -35,7 +35,8 @@ class LeapWindow(QtGui.QMainWindow, triggerEIPError = QtCore.pyqtSignal([object]) start_eipconnection = QtCore.pyqtSignal([]) - # XXX fix nomenclature here + # XXX fix nomenclature here: + # eipStatusChange vs. leapStatusChange # this is eip status change got from vpn management statusChange = QtCore.pyqtSignal([object]) # this is global leap status @@ -49,11 +50,14 @@ class LeapWindow(QtGui.QMainWindow, self.createLogBrowser() settings = QtCore.QSettings() - provider_domain = settings.value("provider_domain", None) - logger.debug('provider: %s', provider_domain) + self.provider_domain = settings.value("provider_domain", None) + self.eip_username = settings.value("eip_username", None) + + logger.debug('provider: %s', self.provider_domain) + logger.debug('eip_username: %s', self.eip_username) EIPConductorAppMixin.__init__( - self, opts=opts, provider=provider_domain) + self, opts=opts, provider=self.provider_domain) StatusAwareTrayIconMixin.__init__(self) NetworkCheckerAppMixin.__init__(self) MainWindowMixin.__init__(self) @@ -62,13 +66,15 @@ class LeapWindow(QtGui.QMainWindow, geom = settings.value(geom_key) if geom: self.restoreGeometry(geom) + + # XXX check for wizard self.wizard_done = settings.value("FirstRunWizardDone") self.initchecks = InitChecksThread(self.run_eip_checks) # bind signals self.initchecks.finished.connect( - lambda: logger.debug('Initial checks finished')) + lambda: logger.debug('Initial checks thread finished')) self.trayIcon.activated.connect(self.iconActivated) self.newLogLine.connect( lambda line: self.onLoggerNewLine(line)) @@ -92,32 +98,52 @@ class LeapWindow(QtGui.QMainWindow, self.changeLeapStatus.connect( lambda newstatus: self.onChangeLeapConnStatus(newstatus)) - # do frwizard and init signals + # do first run wizard 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 + # connected to do_first_run_wizard_check self.mainappReady.emit() def do_first_run_wizard_check(self): + """ + checks whether first run wizard needs to be run + launches it if needed (with initReady signal as a success callback) + and emits initReady signal if not. + """ + # XXX change DOC string after I remove the success callbac!!! + 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') + need_wizard = False + + # do checks (can overlap if wizard was interrupted) + if not self.wizard_done: + need_wizard = True + if not self.provider_domain: + need_wizard = True + + # launch wizard if needed + if need_wizard: from leap.gui.firstrunwizard import FirstRunWizard wizard = FirstRunWizard( + self.conductor, parent=self, - success_cb=self.initReady.emit) + eip_username=self.eip_username, + start_eipconnection_signal=self.start_eipconnection) wizard.show() + else: # no wizard needed + logger.debug('running first run wizard') + self.initReady.emit() + return def runchecks_and_eipconnect(self): self.initchecks.begin() class InitChecksThread(QtCore.QThread): + # XXX rename as a generic QThread class, + # has nothing specific to initchecks def __init__(self, fun, parent=None): QtCore.QThread.__init__(self, parent) -- cgit v1.2.3 From ff02a21ed6ef879c054b01134744068bdfeda664 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 24 Oct 2012 06:49:51 +0900 Subject: last page of wizard displays the connection steps --- src/leap/baseapp/mainwindow.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 752dba51..c5f956fb 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -35,12 +35,10 @@ class LeapWindow(QtGui.QMainWindow, triggerEIPError = QtCore.pyqtSignal([object]) start_eipconnection = QtCore.pyqtSignal([]) - # XXX fix nomenclature here: - # eipStatusChange vs. leapStatusChange - # this is eip status change got from vpn management - statusChange = QtCore.pyqtSignal([object]) - # this is global leap status - changeLeapStatus = QtCore.pyqtSignal([str]) + # this is status change got from openvpn management + openvpnStatusChange = QtCore.pyqtSignal([object]) + # this is global eip status + eipStatusChange = QtCore.pyqtSignal([str]) def __init__(self, opts): logger.debug('init leap window') @@ -93,10 +91,10 @@ class LeapWindow(QtGui.QMainWindow, # status change. # TODO unify - self.statusChange.connect( - lambda status: self.onStatusChange(status)) - self.changeLeapStatus.connect( - lambda newstatus: self.onChangeLeapConnStatus(newstatus)) + self.openvpnStatusChange.connect( + lambda status: self.onOpenVPNStatusChange(status)) + self.eipStatusChange.connect( + lambda newstatus: self.onEIPConnStatusChange(newstatus)) # do first run wizard and init signals self.mainappReady.connect(self.do_first_run_wizard_check) @@ -109,10 +107,9 @@ class LeapWindow(QtGui.QMainWindow, def do_first_run_wizard_check(self): """ checks whether first run wizard needs to be run - launches it if needed (with initReady signal as a success callback) + launches it if needed and emits initReady signal if not. """ - # XXX change DOC string after I remove the success callbac!!! logger.debug('first run wizard check...') need_wizard = False @@ -130,7 +127,8 @@ class LeapWindow(QtGui.QMainWindow, self.conductor, parent=self, eip_username=self.eip_username, - start_eipconnection_signal=self.start_eipconnection) + start_eipconnection_signal=self.start_eipconnection, + eip_statuschange_signal=self.eipStatusChange) wizard.show() else: # no wizard needed logger.debug('running first run wizard') -- cgit v1.2.3 From 593e4ba1ddf185d14f27c96ffb970fde7a3271fa Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 26 Oct 2012 02:04:34 +0900 Subject: fix systray context menu. Closes #761 --- src/leap/baseapp/mainwindow.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index c5f956fb..38fa4a45 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -95,6 +95,9 @@ class LeapWindow(QtGui.QMainWindow, lambda status: self.onOpenVPNStatusChange(status)) self.eipStatusChange.connect( lambda newstatus: self.onEIPConnStatusChange(newstatus)) + # can I connect 2 signals? + self.eipStatusChange.connect( + lambda newstatus: self.toggleEIPAct()) # do first run wizard and init signals self.mainappReady.connect(self.do_first_run_wizard_check) -- cgit v1.2.3 From 0a8a34879a701a2d045f628403c6a0f8be21dc82 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 26 Oct 2012 05:16:44 +0900 Subject: stop eip connection when first run wizard started Closes #716 --- src/leap/baseapp/mainwindow.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 38fa4a45..8f359dbf 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -125,18 +125,23 @@ class LeapWindow(QtGui.QMainWindow, # launch wizard if needed if need_wizard: - from leap.gui.firstrunwizard import FirstRunWizard - wizard = FirstRunWizard( - self.conductor, - parent=self, - eip_username=self.eip_username, - start_eipconnection_signal=self.start_eipconnection, - eip_statuschange_signal=self.eipStatusChange) - wizard.show() + self.launch_first_run_wizard() else: # no wizard needed logger.debug('running first run wizard') self.initReady.emit() - return + + def launch_first_run_wizard(self): + """ + launches wizard and blocks + """ + from leap.gui.firstrunwizard import FirstRunWizard + wizard = FirstRunWizard( + self.conductor, + parent=self, + eip_username=self.eip_username, + start_eipconnection_signal=self.start_eipconnection, + eip_statuschange_signal=self.eipStatusChange) + wizard.show() def runchecks_and_eipconnect(self): self.initchecks.begin() -- cgit v1.2.3 From c387a52f841e8933ed7282d198ed1ece863979fc Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 6 Nov 2012 01:26:05 +0900 Subject: new validation pages in a reusable MVC style using progress indicators inside QTableWidget --- src/leap/baseapp/mainwindow.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 8f359dbf..8e12b5f6 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -147,16 +147,15 @@ class LeapWindow(QtGui.QMainWindow, self.initchecks.begin() -class InitChecksThread(QtCore.QThread): - # XXX rename as a generic QThread class, - # has nothing specific to initchecks +class FunThread(QtCore.QThread): def __init__(self, fun, parent=None): QtCore.QThread.__init__(self, parent) self.fun = fun def run(self): - self.fun() + if self.fun: + self.fun() def begin(self): self.start() -- cgit v1.2.3 From ad16a72f60ecc84524c22e8912df4eb8a48a2a42 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 6 Nov 2012 16:26:10 +0900 Subject: split wizard into separate files so we don't go nuts yet. --- src/leap/baseapp/mainwindow.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 8e12b5f6..8188f819 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -68,7 +68,7 @@ class LeapWindow(QtGui.QMainWindow, # XXX check for wizard self.wizard_done = settings.value("FirstRunWizardDone") - self.initchecks = InitChecksThread(self.run_eip_checks) + self.initchecks = FunThread(self.run_eip_checks) # bind signals self.initchecks.finished.connect( @@ -148,6 +148,8 @@ class LeapWindow(QtGui.QMainWindow, class FunThread(QtCore.QThread): + # XXX move to gui/threads + # for code consistence def __init__(self, fun, parent=None): QtCore.QThread.__init__(self, parent) -- cgit v1.2.3 From 57bd393492fde434a1e3af60b607e8e9d757b9b3 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 12 Nov 2012 21:48:22 +0900 Subject: moved thread code to gui/threads --- src/leap/baseapp/mainwindow.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 8188f819..2df99074 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -2,6 +2,10 @@ #!/usr/bin/env python import logging +import sip +sip.setapi('QString', 2) +sip.setapi('QVariant', 2) + from PyQt4 import QtCore from PyQt4 import QtGui @@ -10,6 +14,7 @@ from leap.baseapp.log import LogPaneMixin from leap.baseapp.systray import StatusAwareTrayIconMixin from leap.baseapp.network import NetworkCheckerAppMixin from leap.baseapp.leap_app import MainWindowMixin +from leap.gui.threads import FunThread logger = logging.getLogger(name=__name__) @@ -145,19 +150,3 @@ class LeapWindow(QtGui.QMainWindow, def runchecks_and_eipconnect(self): self.initchecks.begin() - - -class FunThread(QtCore.QThread): - # XXX move to gui/threads - # for code consistence - - def __init__(self, fun, parent=None): - QtCore.QThread.__init__(self, parent) - self.fun = fun - - def run(self): - if self.fun: - self.fun() - - def begin(self): - self.start() -- cgit v1.2.3 From 654f3158707e6b89d1dfc15745a1b9f525ee81b9 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 12 Nov 2012 22:01:44 +0900 Subject: fix import path --- src/leap/baseapp/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 2df99074..bd29e608 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -139,7 +139,7 @@ class LeapWindow(QtGui.QMainWindow, """ launches wizard and blocks """ - from leap.gui.firstrunwizard import FirstRunWizard + from leap.gui.firstrun.wizard import FirstRunWizard wizard = FirstRunWizard( self.conductor, parent=self, -- cgit v1.2.3 From 72f3ef94f0d7deffa9adfba6bde57ae3d9c8d165 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 12 Nov 2012 23:03:12 +0900 Subject: connect wizard cancel button with shutdown --- src/leap/baseapp/mainwindow.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp/mainwindow.py') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index bd29e608..918f1568 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -145,8 +145,16 @@ class LeapWindow(QtGui.QMainWindow, parent=self, eip_username=self.eip_username, start_eipconnection_signal=self.start_eipconnection, - eip_statuschange_signal=self.eipStatusChange) + eip_statuschange_signal=self.eipStatusChange, + quitcallback=self.onWizardCancel) wizard.show() + def onWizardCancel(self): + if not self.wizard_done: + logger.debug( + 'clicked on Cancel during first ' + 'run wizard. shutting down') + self.cleanupAndQuit() + def runchecks_and_eipconnect(self): self.initchecks.begin() -- cgit v1.2.3