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/app.py | 3 +++ src/leap/base/connection.py | 10 +++++----- src/leap/baseapp/mainwindow.py | 3 +++ src/leap/baseapp/systray.py | 16 ++++++++++++++-- src/leap/eip/eipconnection.py | 17 +++++++---------- src/leap/gui/firstrunwizard.py | 4 ++-- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/leap/app.py b/src/leap/app.py index a1251ca8..4dd93600 100644 --- a/src/leap/app.py +++ b/src/leap/app.py @@ -1,5 +1,6 @@ # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 import logging + # This is only needed for Python v2 but is harmless for Python v3. import sip sip.setapi('QVariant', 2) @@ -74,6 +75,8 @@ def main(): # if not, it will be set visible # from the systray menu. window.show() + + # run main loop sys.exit(app.exec_()) if __name__ == "__main__": diff --git a/src/leap/base/connection.py b/src/leap/base/connection.py index e478538d..41d13935 100644 --- a/src/leap/base/connection.py +++ b/src/leap/base/connection.py @@ -37,11 +37,11 @@ class Connection(Authentication): """ pass - def shutdown(self): - """ - shutdown and quit - """ - self.desired_con_state = self.status.DISCONNECTED + #def shutdown(self): + #""" + #shutdown and quit + #""" + #self.desired_con_state = self.status.DISCONNECTED def connection_state(self): """ 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) diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 061de98e..bf57c0f8 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -129,10 +129,22 @@ class StatusAwareTrayIconMixin(object): # this is too simple by now. # XXX We need to get the REAL info for Encryption state. # (now is ON as soon as vpn launched) - if self.eip_service_started is True: + + # XXX get STATUS CONSTANTS INSTEAD + + icon_status = self.conductor.status.get_state_icon() + if icon_status == "connected": + self.connAct.setEnabled(True) self.connAct.setText('Encryption ON turn o&ff') - else: + return + if icon_status == "disconnected": + self.connAct.setEnabled(True) self.connAct.setText('Encryption OFF turn &on') + return + if icon_status == "connecting": + self.connAct.setDisabled(True) + self.connAct.setText('connecting...') + return def detailsWin(self): visible = self.isVisible() diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py index d4aeddf6..acd40beb 100644 --- a/src/leap/eip/eipconnection.py +++ b/src/leap/eip/eipconnection.py @@ -106,11 +106,11 @@ class EIPConnection(OpenVPNConnection): logger.debug("disconnect: clicked.") self.status.change_to(self.status.DISCONNECTED) - def shutdown(self): - """ - shutdown and quit - """ - self.desired_con_state = self.status.DISCONNECTED + #def shutdown(self): + #""" + #shutdown and quit + #""" + #self.desired_con_state = self.status.DISCONNECTED def connection_state(self): """ @@ -121,10 +121,6 @@ class EIPConnection(OpenVPNConnection): def poll_connection_state(self): """ """ - # XXX this separation does not - # make sense anymore after having - # merged Connection and Manager classes. - # XXX GET RID OF THIS FUNCTION HERE! try: state = self.get_connection_state() except eip_exceptions.ConnectionRefusedError: @@ -132,7 +128,7 @@ class EIPConnection(OpenVPNConnection): logger.warning('connection refused') return if not state: - #logger.debug('no state') + logger.debug('no state') return (ts, status_step, ok, ip, remote) = state @@ -258,6 +254,7 @@ class EIPConnectionStatus(object): def get_leap_status(self): # XXX improve nomenclature leap_status = { + 0: 'disconnected', 1: 'connecting to gateway', 2: 'connecting to gateway', 3: 'authenticating', diff --git a/src/leap/gui/firstrunwizard.py b/src/leap/gui/firstrunwizard.py index fd49380c..6b9921d9 100755 --- a/src/leap/gui/firstrunwizard.py +++ b/src/leap/gui/firstrunwizard.py @@ -1218,7 +1218,7 @@ class LastPage(QtGui.QWizardPage): def __init__(self, parent=None): super(LastPage, self).__init__(parent) - self.setTitle("Connecting...") + self.setTitle("Connecting to Encrypted Internet Proxy service...") self.setPixmap( QtGui.QWizard.LogoPixmap, @@ -1253,7 +1253,7 @@ class LastPage(QtGui.QWizardPage): statusline.setText(status) def set_finished_status(self): - self.setTitle('You are using an encrypted connection!') + self.setTitle('You are now using an encrypted connection!') finishText = self.wizard().buttonText( QtGui.QWizard.FinishButton) finishText = finishText.replace('&', '') -- cgit v1.2.3