From 23502b72f8cd8a9ec2fd28387f7788aeef54c2d1 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 2 Aug 2012 02:21:45 +0900 Subject: create config file if not exist. also locate openvpn binary when building eip configparser defaults. implement half of feature #356 --- src/leap/baseapp/config.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 src/leap/baseapp/config.py (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/config.py b/src/leap/baseapp/config.py deleted file mode 100644 index efdb4726..00000000 --- a/src/leap/baseapp/config.py +++ /dev/null @@ -1,40 +0,0 @@ -import ConfigParser -import os - - -def get_config(config_file=None): - """ - temporary method for getting configs, - mainly for early stage development process. - in the future we will get preferences - from the storage api - """ - config = ConfigParser.ConfigParser() - #config.readfp(open('defaults.cfg')) - #XXX does this work on win / mac also??? - conf_path_list = ['eip.cfg', # XXX build a - # proper path with platform-specific places - # XXX make .config/foo - os.path.expanduser('~/.eip.cfg')] - if config_file: - config.readfp(config_file) - else: - config.read(conf_path_list) - return config - - -# XXX wrapper around config? to get default values - -def get_with_defaults(config, section, option): - if config.has_option(section, option): - return config.get(section, option) - else: - # XXX lookup in defaults dict??? - pass - - -def get_vpn_stdout_mockup(): - command = "python" - args = ["-u", "-c", "from eip_client import fakeclient;\ -fakeclient.write_output()"] - return command, args -- cgit v1.2.3 From 3e95ac1493da40b77bec110e0c59c2f11aeb2b62 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 2 Aug 2012 03:48:24 +0900 Subject: start with disconnected icon --- src/leap/baseapp/mainwindow.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 68b6de8f..f2c48acc 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -222,6 +222,7 @@ technolust") self.trayIconMenu.addAction(self.quitAction) self.trayIcon = QSystemTrayIcon(self) + self.setIcon('disconnected') self.trayIcon.setContextMenu(self.trayIconMenu) def createLogBrowser(self): -- cgit v1.2.3 From 81613b2ef70e5d73b7c34eb4b78ee63189b45ab6 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 3 Aug 2012 09:42:14 +0900 Subject: pkexec check --- src/leap/baseapp/dialogs.py | 22 ++++++++++++++++++++++ src/leap/baseapp/mainwindow.py | 25 +++++++++++++++++++++---- src/leap/baseapp/permcheck.py | 10 ++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 src/leap/baseapp/dialogs.py create mode 100644 src/leap/baseapp/permcheck.py (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py new file mode 100644 index 00000000..d4e51a39 --- /dev/null +++ b/src/leap/baseapp/dialogs.py @@ -0,0 +1,22 @@ +from PyQt4.QtGui import (QDialog, QFrame, QPushButton, QLabel, QMessageBox) + + +class ErrorDialog(QDialog): + def __init__(self, parent=None): + super(ErrorDialog, self).__init__(parent) + + frameStyle = QFrame.Sunken | QFrame.Panel + self.warningLabel = QLabel() + self.warningLabel.setFrameStyle(frameStyle) + self.warningButton = QPushButton("QMessageBox.&warning()") + + def warningMessage(self, msg, label): + msgBox = QMessageBox(QMessageBox.Warning, + "QMessageBox.warning()", msg, + QMessageBox.NoButton, self) + msgBox.addButton("&Ok", QMessageBox.AcceptRole) + msgBox.addButton("&Cancel", QMessageBox.RejectRole) + if msgBox.exec_() == QMessageBox.AcceptRole: + self.warningLabel.setText("Save Again") + else: + self.warningLabel.setText("Continue") diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index f2c48acc..fec49282 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -11,8 +11,9 @@ from PyQt4.QtGui import (QMainWindow, QWidget, QVBoxLayout, QMessageBox, QTextBrowser, qApp) from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) +from leap.baseapp.dialogs import ErrorDialog +from leap.eip.conductor import EIPConductor, EIPNoCommandError from leap.gui import mainwindow_rc -from leap.eip.conductor import EIPConductor class LeapWindow(QMainWindow): @@ -64,15 +65,24 @@ class LeapWindow(QMainWindow): # we pass a tuple of signals that will be # triggered when status changes. # + self.trayIcon.show() config_file = getattr(opts, 'config_file', None) + self.conductor = EIPConductor( watcher_cb=self.newLogLine.emit, config_file=config_file, status_signals=(self.statusChange.emit, )) - self.trayIcon.show() + if self.conductor.missing_pkexec is True: + dialog = ErrorDialog() + dialog.warningMessage( + 'We could not find pkexec in your ' + 'system.
Do you want to try ' + 'setuid workaround? ' + '(DOES NOTHING YET)', + 'error') - self.setWindowTitle("Leap") + self.setWindowTitle("LEAP Client") self.resize(400, 300) self.set_statusbarMessage('ready') @@ -316,7 +326,14 @@ technolust") stub for running child process with vpn """ if self.vpn_service_started is False: - self.conductor.connect() + try: + self.conductor.connect() + except EIPNoCommandError: + dialog = ErrorDialog() + dialog.warningMessage( + 'No suitable openvpn command found. ' + '
(Might be a permissions problem)', + 'error') if self.debugmode: self.startStopButton.setText('&Disconnect') self.vpn_service_started = True diff --git a/src/leap/baseapp/permcheck.py b/src/leap/baseapp/permcheck.py new file mode 100644 index 00000000..58748761 --- /dev/null +++ b/src/leap/baseapp/permcheck.py @@ -0,0 +1,10 @@ +import os + +from leap.util.fileutil import which + + +def is_pkexec_in_system(): + pkexec_path = which('pkexec') + if not pkexec_path: + return False + return os.access(pkexec_path, os.X_OK) -- cgit v1.2.3 From 5c34052ef9261a47947e3e03616fe34b099b9fa4 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 3 Aug 2012 10:18:50 +0900 Subject: stub for daemon mode; disabled by now until #383 is fixed --- src/leap/baseapp/mainwindow.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index fec49282..cd6600b4 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -59,19 +59,23 @@ class LeapWindow(QMainWindow): mainLayout.addWidget(self.loggerBox) widget.setLayout(mainLayout) + self.trayIcon.show() + config_file = getattr(opts, 'config_file', None) + # # conductor is in charge of all # vpn-related configuration / monitoring. # we pass a tuple of signals that will be # triggered when status changes. # - self.trayIcon.show() - config_file = getattr(opts, 'config_file', None) self.conductor = EIPConductor( watcher_cb=self.newLogLine.emit, config_file=config_file, - status_signals=(self.statusChange.emit, )) + status_signals=(self.statusChange.emit, ), + debug=self.debugmode) + + print('debugmode:%s' % self.debugmode) if self.conductor.missing_pkexec is True: dialog = ErrorDialog() -- cgit v1.2.3 From 0bb8cca027ab32a54f6792ab1b1368e2f1845368 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 3 Aug 2012 10:46:22 +0900 Subject: check also for a suitable polkit-authentication-agent running fix #382. --- src/leap/baseapp/mainwindow.py | 10 ++++++++++ src/leap/baseapp/permcheck.py | 7 +++++++ 2 files changed, 17 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index cd6600b4..0e2f4e1d 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -77,6 +77,16 @@ class LeapWindow(QMainWindow): print('debugmode:%s' % self.debugmode) + if self.conductor.missing_auth_agent is True: + dialog = ErrorDialog() + dialog.warningMessage( + 'We could not find any authentication ' + 'agent in your system.
' + 'Make sure you have ' + 'polkit-gnome-authentication-agent-1 ' + 'running and try again.', + 'error') + if self.conductor.missing_pkexec is True: dialog = ErrorDialog() dialog.warningMessage( diff --git a/src/leap/baseapp/permcheck.py b/src/leap/baseapp/permcheck.py index 58748761..6b74cb6e 100644 --- a/src/leap/baseapp/permcheck.py +++ b/src/leap/baseapp/permcheck.py @@ -1,3 +1,4 @@ +import commands import os from leap.util.fileutil import which @@ -8,3 +9,9 @@ def is_pkexec_in_system(): if not pkexec_path: return False return os.access(pkexec_path, os.X_OK) + + +def is_auth_agent_running(): + return bool( + commands.getoutput( + 'ps aux | grep polkit-[g]nome-authentication-agent-1')) -- cgit v1.2.3 From 36b0dfacca794e9cb899b5dde2dae3b8bbc6cc43 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 7 Aug 2012 04:14:06 +0900 Subject: build default provider openvpn config. preparation for completion of #356, #355, #354, #182 if no default openvpn config is present, we build one with a preset template and the remote_ip of the eip service as the only input. right now we're taking it from the eip.cfg file. --- src/leap/baseapp/mainwindow.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 0e2f4e1d..d5251a5c 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -75,7 +75,7 @@ class LeapWindow(QMainWindow): status_signals=(self.statusChange.emit, ), debug=self.debugmode) - print('debugmode:%s' % self.debugmode) + #print('debugmode:%s' % self.debugmode) if self.conductor.missing_auth_agent is True: dialog = ErrorDialog() @@ -310,11 +310,11 @@ technolust") updating icon, status bar, etc. """ - print('STATUS CHANGED! (on Qt-land)') - print('%s -> %s' % (status.previous, status.current)) + #print('STATUS CHANGED! (on Qt-land)') + #print('%s -> %s' % (status.previous, status.current)) icon_name = self.conductor.get_icon_name() self.setIcon(icon_name) - print 'icon = ', icon_name + #print 'icon = ', icon_name # change connection pixmap widget self.setConnWidget(icon_name) -- cgit v1.2.3 From 530e10214a6f018909714b288d997df13ab4f9df Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 8 Aug 2012 06:53:10 +0900 Subject: check for bad permissions on vpn key files --- src/leap/baseapp/dialogs.py | 11 +++++++++++ src/leap/baseapp/mainwindow.py | 14 +++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py index d4e51a39..4b1b5b62 100644 --- a/src/leap/baseapp/dialogs.py +++ b/src/leap/baseapp/dialogs.py @@ -20,3 +20,14 @@ class ErrorDialog(QDialog): self.warningLabel.setText("Save Again") else: self.warningLabel.setText("Continue") + + def criticalMessage(self, msg, label): + msgBox = QMessageBox(QMessageBox.Critical, + "QMessageBox.critical()", msg, + QMessageBox.NoButton, self) + msgBox.addButton("&Ok", QMessageBox.AcceptRole) + msgBox.addButton("&Cancel", QMessageBox.RejectRole) + if msgBox.exec_() == QMessageBox.AcceptRole: + self.warningLabel.setText("Save Again") + else: + self.warningLabel.setText("Continue") diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index d5251a5c..cbdd2d07 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -12,7 +12,12 @@ from PyQt4.QtGui import (QMainWindow, QWidget, QVBoxLayout, QMessageBox, from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) from leap.baseapp.dialogs import ErrorDialog -from leap.eip.conductor import EIPConductor, EIPNoCommandError +from leap.eip.conductor import (EIPConductor, + EIPNoCommandError) + +from leap.eip.config import (EIPInitBadKeyFilePermError) +# from leap.eip import exceptions as eip_exceptions + from leap.gui import mainwindow_rc @@ -68,14 +73,17 @@ class LeapWindow(QMainWindow): # we pass a tuple of signals that will be # triggered when status changes. # - self.conductor = EIPConductor( watcher_cb=self.newLogLine.emit, config_file=config_file, status_signals=(self.statusChange.emit, ), debug=self.debugmode) - #print('debugmode:%s' % self.debugmode) + if self.conductor.bad_keyfile_perms is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'The vpn keys file has bad permissions', + 'error') if self.conductor.missing_auth_agent is True: dialog = ErrorDialog() -- cgit v1.2.3 From e81ddf7648e1075a15d8add11cd975a73aa09926 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 8 Aug 2012 07:01:27 +0900 Subject: catch missing keyfile error --- src/leap/baseapp/mainwindow.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index cbdd2d07..c54eb97f 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -79,6 +79,19 @@ class LeapWindow(QMainWindow): status_signals=(self.statusChange.emit, ), debug=self.debugmode) + # bunch of self checks. + # XXX move somewhere else alltogether. + + if self.conductor.missing_vpn_keyfile is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'Could not find the vpn keys file', + 'error') + + # ... btw, review pending. + # os.kill of subprocess fails if we have + # some of this errors. + if self.conductor.bad_keyfile_perms is True: dialog = ErrorDialog() dialog.criticalMessage( -- cgit v1.2.3 From c217bd1f1456cf10ceabf698ea6f4dd8f636f454 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 8 Aug 2012 07:22:36 +0900 Subject: check for validity of the remote_ip entry (is ip?) --- src/leap/baseapp/mainwindow.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index c54eb97f..85129a9b 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -79,8 +79,17 @@ class LeapWindow(QMainWindow): status_signals=(self.statusChange.emit, ), debug=self.debugmode) + # # bunch of self checks. # XXX move somewhere else alltogether. + # + + if self.conductor.missing_provider is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'Missing provider. Add a remote_ip entry ' + 'under section [provider] in eip.cfg', + 'error') if self.conductor.missing_vpn_keyfile is True: dialog = ErrorDialog() @@ -92,6 +101,13 @@ class LeapWindow(QMainWindow): # os.kill of subprocess fails if we have # some of this errors. + if self.conductor.bad_provider is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'Bad provider entry. Check that remote_ip entry ' + 'has an IP under section [provider] in eip.cfg', + 'error') + if self.conductor.bad_keyfile_perms is True: dialog = ErrorDialog() dialog.criticalMessage( -- cgit v1.2.3 From 07ed489ed46140d6de814667ab3e64c6076f3776 Mon Sep 17 00:00:00 2001 From: antialias Date: Tue, 14 Aug 2012 16:10:11 -0700 Subject: Works and is now ready to write tests for. --- src/leap/baseapp/mainwindow.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 85129a9b..544667f4 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -19,6 +19,7 @@ from leap.eip.config import (EIPInitBadKeyFilePermError) # from leap.eip import exceptions as eip_exceptions from leap.gui import mainwindow_rc +from leap.EIPConnection import EIPConnection class LeapWindow(QMainWindow): @@ -46,7 +47,6 @@ class LeapWindow(QMainWindow): self.timer = QTimer() # bind signals - self.trayIcon.activated.connect(self.iconActivated) self.newLogLine.connect(self.onLoggerNewLine) self.statusChange.connect(self.onStatusChange) @@ -73,7 +73,8 @@ class LeapWindow(QMainWindow): # we pass a tuple of signals that will be # triggered when status changes. # - self.conductor = EIPConductor( + config_file = getattr(opts, 'config_file', None) + self.conductor = EIPConnection( watcher_cb=self.newLogLine.emit, config_file=config_file, status_signals=(self.statusChange.emit, ), @@ -424,7 +425,7 @@ technolust") # XXX remove all access to manager layer # from here. - if self.conductor.manager.with_errors: + if self.conductor.with_errors: #XXX how to wait on pkexec??? #something better that this workaround, plz!! time.sleep(10) @@ -448,7 +449,7 @@ technolust") # status i/o - status = self.conductor.manager.get_status_io() + status = self.conductor.get_status_io() if status and self.debugmode: #XXX move this to systray menu indicators ts, (tun_read, tun_write, tcp_read, tcp_write, auth_read) = status -- cgit v1.2.3 From f5948577939dce4f85dd86f37c0823a0a852e074 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 21 Aug 2012 03:11:32 +0900 Subject: fix imports + style cleaning --- src/leap/baseapp/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 544667f4..4d1eee79 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -19,7 +19,7 @@ from leap.eip.config import (EIPInitBadKeyFilePermError) # from leap.eip import exceptions as eip_exceptions from leap.gui import mainwindow_rc -from leap.EIPConnection import EIPConnection +from leap.eip.eipconnection import EIPConnection class LeapWindow(QMainWindow): -- cgit v1.2.3 From 738b4bf8c6b75a1d73b7fa3e1a5edb69adf9d8a0 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 21 Aug 2012 04:58:05 +0900 Subject: fix out-of-sync refactor. manually merge changes from the develop branch that were lost due to having branched a previous state when refactored former "conductor" class. also, moved more exceptions to its own file. --- src/leap/baseapp/mainwindow.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 4d1eee79..c5bdd8e9 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -12,14 +12,14 @@ from PyQt4.QtGui import (QMainWindow, QWidget, QVBoxLayout, QMessageBox, from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) from leap.baseapp.dialogs import ErrorDialog -from leap.eip.conductor import (EIPConductor, - EIPNoCommandError) -from leap.eip.config import (EIPInitBadKeyFilePermError) -# from leap.eip import exceptions as eip_exceptions +#from leap.eip.conductor import (EIPConductor, + #EIPNoCommandError) +#from leap.eip.config import (EIPInitBadKeyFilePermError) +from leap.eip import exceptions as eip_exceptions +from leap.eip.eipconnection import EIPConnection from leap.gui import mainwindow_rc -from leap.eip.eipconnection import EIPConnection class LeapWindow(QMainWindow): @@ -380,7 +380,7 @@ technolust") if self.vpn_service_started is False: try: self.conductor.connect() - except EIPNoCommandError: + except eip_exceptions.EIPNoCommandError: dialog = ErrorDialog() dialog.warningMessage( 'No suitable openvpn command found. ' -- cgit v1.2.3 From af77050ce07ad884a39459a12bf22b74f6a858ab Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 22 Aug 2012 01:29:41 +0900 Subject: clean imports and remove connection base method --- src/leap/baseapp/mainwindow.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index c5bdd8e9..bc844437 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -13,9 +13,6 @@ from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) from leap.baseapp.dialogs import ErrorDialog -#from leap.eip.conductor import (EIPConductor, - #EIPNoCommandError) -#from leap.eip.config import (EIPInitBadKeyFilePermError) from leap.eip import exceptions as eip_exceptions from leap.eip.eipconnection import EIPConnection -- cgit v1.2.3 From dc10833bedcdecf081a7c79678614c5521445164 Mon Sep 17 00:00:00 2001 From: antialias Date: Wed, 22 Aug 2012 19:47:41 -0700 Subject: grabs a definition.json file if one isn't present. includes some basic error handling and tests. uses the requests library for network interactions and mocks for simulating network states. --- src/leap/baseapp/mainwindow.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index bc844437..912a51b6 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -11,6 +11,8 @@ from PyQt4.QtGui import (QMainWindow, QWidget, QVBoxLayout, QMessageBox, QTextBrowser, qApp) from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) +from leap.base.configuration import Configuration + from leap.baseapp.dialogs import ErrorDialog from leap.eip import exceptions as eip_exceptions @@ -18,6 +20,9 @@ from leap.eip.eipconnection import EIPConnection from leap.gui import mainwindow_rc +#TODO: Get rid of this and do something clever +DEFAULT_PROVIDER_URL = "http://localhost/definition.json" + class LeapWindow(QMainWindow): #XXX tbd: refactor into model / view / controller @@ -30,6 +35,8 @@ class LeapWindow(QMainWindow): super(LeapWindow, self).__init__() self.debugmode = getattr(opts, 'debug', False) + self.configuration = Configuration() + self.vpn_service_started = False self.createWindowHeader() @@ -81,6 +88,12 @@ class LeapWindow(QMainWindow): # bunch of self checks. # XXX move somewhere else alltogether. # + if self.configuration.error is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'There is a problem with the default ' + 'definition.json file', + 'error') if self.conductor.missing_provider is True: dialog = ErrorDialog() -- cgit v1.2.3 From 31cd15909308a7e9c617381012014a531944d903 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 28 Aug 2012 22:35:00 +0900 Subject: fix import --- src/leap/baseapp/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 912a51b6..086e905a 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -11,7 +11,7 @@ from PyQt4.QtGui import (QMainWindow, QWidget, QVBoxLayout, QMessageBox, QTextBrowser, qApp) from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) -from leap.base.configuration import Configuration +from leap.base.config import Configuration from leap.baseapp.dialogs import ErrorDialog -- cgit v1.2.3 From 06883461f2daa616b2e3c842f53d9422703cd9c7 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 28 Aug 2012 23:08:39 +0900 Subject: eip_checks called from main app. removed "configuration" object. checks are called from conductor. --- src/leap/baseapp/mainwindow.py | 43 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 086e905a..d7f4ecac 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -11,18 +11,11 @@ from PyQt4.QtGui import (QMainWindow, QWidget, QVBoxLayout, QMessageBox, QTextBrowser, qApp) from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) -from leap.base.config import Configuration - from leap.baseapp.dialogs import ErrorDialog - from leap.eip import exceptions as eip_exceptions from leap.eip.eipconnection import EIPConnection - from leap.gui import mainwindow_rc -#TODO: Get rid of this and do something clever -DEFAULT_PROVIDER_URL = "http://localhost/definition.json" - class LeapWindow(QMainWindow): #XXX tbd: refactor into model / view / controller @@ -35,9 +28,7 @@ class LeapWindow(QMainWindow): super(LeapWindow, self).__init__() self.debugmode = getattr(opts, 'debug', False) - self.configuration = Configuration() - - self.vpn_service_started = False + self.eip_service_started = False self.createWindowHeader() self.createIconGroupBox() @@ -69,7 +60,9 @@ class LeapWindow(QMainWindow): widget.setLayout(mainLayout) self.trayIcon.show() - config_file = getattr(opts, 'config_file', None) + self.setWindowTitle("LEAP Client") + self.resize(400, 300) + self.set_statusbarMessage('ready') # # conductor is in charge of all @@ -84,15 +77,19 @@ class LeapWindow(QMainWindow): status_signals=(self.statusChange.emit, ), debug=self.debugmode) + # XXX remove skip download when sample service is ready + self.conductor.run_checks(skip_download=True) + + ####### error checking ################ # # bunch of self checks. # XXX move somewhere else alltogether. # - if self.configuration.error is True: + if self.conductor.missing_definition is True: dialog = ErrorDialog() dialog.criticalMessage( - 'There is a problem with the default ' - 'definition.json file', + 'The default ' + 'definition.json file cannot be found', 'error') if self.conductor.missing_provider is True: @@ -144,10 +141,7 @@ class LeapWindow(QMainWindow): '(DOES NOTHING YET)', 'error') - self.setWindowTitle("LEAP Client") - self.resize(400, 300) - - self.set_statusbarMessage('ready') + ############ end error checking ################### if self.conductor.autostart: self.start_or_stopVPN() @@ -387,9 +381,10 @@ technolust") """ stub for running child process with vpn """ - if self.vpn_service_started is False: + if self.eip_service_started is False: try: self.conductor.connect() + # XXX move this to error queue except eip_exceptions.EIPNoCommandError: dialog = ErrorDialog() dialog.warningMessage( @@ -398,7 +393,7 @@ technolust") 'error') if self.debugmode: self.startStopButton.setText('&Disconnect') - self.vpn_service_started = True + self.eip_service_started = True # XXX what is optimum polling interval? # too little is overkill, too much @@ -406,13 +401,11 @@ technolust") self.timer.start(250.0) return - if self.vpn_service_started is True: + if self.eip_service_started is True: self.conductor.disconnect() - # FIXME this should trigger also - # statuschange event. why isn't working?? if self.debugmode: self.startStopButton.setText('&Connect') - self.vpn_service_started = False + self.eip_service_started = False self.timer.stop() return @@ -430,7 +423,7 @@ technolust") # XXX it's too expensive to poll # continously. move to signal events instead. - if not self.vpn_service_started: + if not self.eip_service_started: return # XXX remove all access to manager layer -- cgit v1.2.3 From 396d815e318d03df4e21269aa8c3e6c0e6f7fad0 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 30 Aug 2012 06:00:03 +0900 Subject: working with options only from cli --- src/leap/baseapp/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index d7f4ecac..2f7a14dd 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -431,7 +431,7 @@ technolust") if self.conductor.with_errors: #XXX how to wait on pkexec??? #something better that this workaround, plz!! - time.sleep(10) + time.sleep(5) print('errors. disconnect.') self.start_or_stopVPN() # is stop -- cgit v1.2.3 From d75ef7982aaf96572ea26b1986b3578d9b1eca06 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 04:45:48 +0900 Subject: first attempt at class splitting war on spaguetti! :D --- src/leap/baseapp/mainwindow.py | 506 ++++++++++++++++++++++------------------- 1 file changed, 270 insertions(+), 236 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 2f7a14dd..ca9b79b3 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -2,7 +2,9 @@ #!/usr/bin/env python import logging import time +logging.basicConfig() logger = logging.getLogger(name=__name__) +logger.setLevel(logging.DEBUG) from PyQt4.QtGui import (QMainWindow, QWidget, QVBoxLayout, QMessageBox, QSystemTrayIcon, QGroupBox, QLabel, QPixmap, @@ -14,63 +16,22 @@ from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) from leap.baseapp.dialogs import ErrorDialog from leap.eip import exceptions as eip_exceptions from leap.eip.eipconnection import EIPConnection -from leap.gui import mainwindow_rc - - -class LeapWindow(QMainWindow): - #XXX tbd: refactor into model / view / controller - #and put in its own modules... - - newLogLine = pyqtSignal([str]) - statusChange = pyqtSignal([object]) - - def __init__(self, opts): - super(LeapWindow, self).__init__() - self.debugmode = getattr(opts, 'debug', False) - - self.eip_service_started = False - - self.createWindowHeader() - self.createIconGroupBox() - self.createActions() - self.createTrayIcon() - if self.debugmode: - self.createLogBrowser() - - # create timer - self.timer = QTimer() - - # bind signals - self.trayIcon.activated.connect(self.iconActivated) - self.newLogLine.connect(self.onLoggerNewLine) - self.statusChange.connect(self.onStatusChange) - self.timer.timeout.connect(self.onTimerTick) - - widget = QWidget() - self.setCentralWidget(widget) +from leap.gui import mainwindow_rc - # add widgets to layout - mainLayout = QVBoxLayout() - mainLayout.addWidget(self.headerBox) - mainLayout.addWidget(self.statusIconBox) - if self.debugmode: - mainLayout.addWidget(self.statusBox) - mainLayout.addWidget(self.loggerBox) - widget.setLayout(mainLayout) - self.trayIcon.show() - self.setWindowTitle("LEAP Client") - self.resize(400, 300) - self.set_statusbarMessage('ready') +class EIPConductorApp(object): + 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.conductor = EIPConnection( watcher_cb=self.newLogLine.emit, config_file=config_file, @@ -79,7 +40,11 @@ class LeapWindow(QMainWindow): # XXX remove skip download when sample service is ready self.conductor.run_checks(skip_download=True) + self.error_check() + if self.conductor.autostart: + self.start_or_stopVPN() + def error_check(self): ####### error checking ################ # # bunch of self checks. @@ -142,78 +107,89 @@ class LeapWindow(QMainWindow): 'error') ############ end error checking ################### - - if self.conductor.autostart: - self.start_or_stopVPN() - - def closeEvent(self, event): + @pyqtSlot() + def statusUpdate(self): """ - redefines close event (persistent window behaviour) + called on timer tick + polls status and updates ui with real time + info about transferred bytes / connection state. """ - if self.trayIcon.isVisible() and not self.debugmode: - QMessageBox.information(self, "Systray", - "The program will keep running " - "in the system tray. To " - "terminate the program, choose " - "Quit in the " - "context menu of the system tray entry.") - self.hide() - event.ignore() + # XXX it's too expensive to poll + # continously. move to signal events instead. + + 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) + print('errors. disconnect.') + self.start_or_stopVPN() # is stop + + state = self.conductor.poll_connection_state() + if not state: + return + + ts, con_status, ok, ip, remote = state + self.set_statusbarMessage(con_status) + self.setIconToolTip() + + ts = time.strftime("%a %b %d %X", ts) if self.debugmode: - self.cleanupAndQuit() + self.updateTS.setText(ts) + self.status_label.setText(con_status) + self.ip_label.setText(ip) + self.remote_label.setText(remote) - def setIcon(self, name): - icon = self.Icons.get(name) - self.trayIcon.setIcon(icon) - self.setWindowIcon(icon) + # status i/o - def setToolTip(self): - """ - get readable status and place it on systray tooltip - """ - status = self.conductor.status.get_readable_status() - self.trayIcon.setToolTip(status) + status = self.conductor.get_status_io() + if status and self.debugmode: + #XXX move this to systray menu indicators + ts, (tun_read, tun_write, tcp_read, tcp_write, auth_read) = status + ts = time.strftime("%a %b %d %X", ts) + self.updateTS.setText(ts) + self.tun_read_bytes.setText(tun_read) + self.tun_write_bytes.setText(tun_write) - def iconActivated(self, reason): + @pyqtSlot() + def start_or_stopVPN(self): """ - handles left click, left double click - showing the trayicon menu + stub for running child process with vpn """ - #XXX there's a bug here! - #menu shows on (0,0) corner first time, - #until double clicked at least once. - if reason in (QSystemTrayIcon.Trigger, - QSystemTrayIcon.DoubleClick): - self.trayIconMenu.show() + if self.eip_service_started is False: + try: + self.conductor.connect() + # XXX move this to error queue + except eip_exceptions.EIPNoCommandError: + dialog = ErrorDialog() + dialog.warningMessage( + 'No suitable openvpn command found. ' + '
(Might be a permissions problem)', + 'error') + if self.debugmode: + self.startStopButton.setText('&Disconnect') + self.eip_service_started = True - def createWindowHeader(self): - """ - description lines for main window - """ - #XXX good candidate to refactor out! :) - self.headerBox = QGroupBox() - self.headerLabel = QLabel("Encryption \ -Internet Proxy") - self.headerLabelSub = QLabel("trust your \ -technolust") + # XXX what is optimum polling interval? + # too little is overkill, too much + # will miss transition states.. - pixmap = QPixmap(':/images/leapfrog.jpg') - frog_lbl = QLabel() - frog_lbl.setPixmap(pixmap) + self.timer.start(250.0) + return + if self.eip_service_started is True: + self.conductor.disconnect() + if self.debugmode: + self.startStopButton.setText('&Connect') + self.eip_service_started = False + self.timer.stop() + return - headerLayout = QHBoxLayout() - headerLayout.addWidget(frog_lbl) - headerLayout.addWidget(self.headerLabel) - headerLayout.addWidget(self.headerLabelSub) - headerLayout.addStretch() - self.headerBox.setLayout(headerLayout) - def getIcon(self, icon_name): - # XXX get from connection dict - icons = {'disconnected': 0, - 'connecting': 1, - 'connected': 2} - return icons.get(icon_name, None) +class StatusAwareTrayIcon(object): def createIconGroupBox(self): """ @@ -254,6 +230,25 @@ technolust") statusIconLayout.itemAt(2).widget().hide() self.statusIconBox.setLayout(statusIconLayout) + def createTrayIcon(self): + """ + creates the tray icon + """ + self.trayIconMenu = QMenu(self) + + self.trayIconMenu.addAction(self.connectVPNAction) + self.trayIconMenu.addAction(self.dis_connectAction) + self.trayIconMenu.addSeparator() + self.trayIconMenu.addAction(self.minimizeAction) + self.trayIconMenu.addAction(self.maximizeAction) + self.trayIconMenu.addAction(self.restoreAction) + self.trayIconMenu.addSeparator() + self.trayIconMenu.addAction(self.quitAction) + + self.trayIcon = QSystemTrayIcon(self) + self.setIcon('disconnected') + self.trayIcon.setContextMenu(self.trayIconMenu) + def createActions(self): """ creates actions to be binded to tray icon @@ -261,8 +256,9 @@ technolust") self.connectVPNAction = QAction("Connect to &VPN", self, triggered=self.hide) # XXX change action name on (dis)connect - self.dis_connectAction = QAction("&(Dis)connect", self, - triggered=self.start_or_stopVPN) + self.dis_connectAction = QAction( + "&(Dis)connect", self, + triggered=lambda: self.start_or_stopVPN()) self.minimizeAction = QAction("Mi&nimize", self, triggered=self.hide) self.maximizeAction = QAction("Ma&ximize", self, @@ -272,24 +268,128 @@ technolust") self.quitAction = QAction("&Quit", self, triggered=self.cleanupAndQuit) - def createTrayIcon(self): + def setConnWidget(self, icon_name): + #print 'changing icon to %s' % icon_name + oldlayout = self.statusIconBox.layout() + + # XXX reuse with icons + # XXX move states to StateWidget + states = {"disconnected": 0, + "connecting": 1, + "connected": 2} + + for i in range(3): + oldlayout.itemAt(i).widget().hide() + new = states[icon_name] + oldlayout.itemAt(new).widget().show() + + def setIcon(self, name): + icon = self.Icons.get(name) + self.trayIcon.setIcon(icon) + self.setWindowIcon(icon) + + def getIcon(self, icon_name): + # XXX get from connection dict + icons = {'disconnected': 0, + 'connecting': 1, + 'connected': 2} + return icons.get(icon_name, None) + + def setIconToolTip(self): """ - creates the tray icon + get readable status and place it on systray tooltip """ - self.trayIconMenu = QMenu(self) + status = self.conductor.status.get_readable_status() + self.trayIcon.setToolTip(status) - self.trayIconMenu.addAction(self.connectVPNAction) - self.trayIconMenu.addAction(self.dis_connectAction) - self.trayIconMenu.addSeparator() - self.trayIconMenu.addAction(self.minimizeAction) - self.trayIconMenu.addAction(self.maximizeAction) - self.trayIconMenu.addAction(self.restoreAction) - self.trayIconMenu.addSeparator() - self.trayIconMenu.addAction(self.quitAction) + def iconActivated(self, reason): + """ + handles left click, left double click + showing the trayicon menu + """ + #XXX there's a bug here! + #menu shows on (0,0) corner first time, + #until double clicked at least once. + if reason in (QSystemTrayIcon.Trigger, + QSystemTrayIcon.DoubleClick): + self.trayIconMenu.show() - self.trayIcon = QSystemTrayIcon(self) - self.setIcon('disconnected') - self.trayIcon.setContextMenu(self.trayIconMenu) + @pyqtSlot() + def onTimerTick(self): + self.statusUpdate() + + @pyqtSlot(object) + def onStatusChange(self, status): + """ + slot for status changes. triggers new signals for + updating icon, status bar, etc. + """ + + #print('STATUS CHANGED! (on Qt-land)') + #print('%s -> %s' % (status.previous, status.current)) + icon_name = self.conductor.get_icon_name() + self.setIcon(icon_name) + #print 'icon = ', icon_name + + # change connection pixmap widget + self.setConnWidget(icon_name) + + +class LeapMainWindow(object): + + def createWindowHeader(self): + """ + description lines for main window + """ + #XXX good candidate to refactor out! :) + self.headerBox = QGroupBox() + self.headerLabel = QLabel("Encryption \ +Internet Proxy") + self.headerLabelSub = QLabel("trust your \ +technolust") + + pixmap = QPixmap(':/images/leapfrog.jpg') + frog_lbl = QLabel() + frog_lbl.setPixmap(pixmap) + + headerLayout = QHBoxLayout() + headerLayout.addWidget(frog_lbl) + headerLayout.addWidget(self.headerLabel) + headerLayout.addWidget(self.headerLabelSub) + headerLayout.addStretch() + self.headerBox.setLayout(headerLayout) + + def set_statusbarMessage(self, msg): + self.statusBar().showMessage(msg) + + def closeEvent(self, event): + """ + redefines close event (persistent window behaviour) + """ + if self.trayIcon.isVisible() and not self.debugmode: + QMessageBox.information(self, "Systray", + "The program will keep running " + "in the system tray. To " + "terminate the program, choose " + "Quit in the " + "context menu of the system tray entry.") + self.hide() + event.ignore() + if self.debugmode: + self.cleanupAndQuit() + + def cleanupAndQuit(self): + """ + cleans state before shutting down app. + """ + # TODO:make sure to shutdown all child process / threads + # in conductor + # XXX send signal instead? + self.conductor.cleanup() + qApp.quit() + + +class LogPane(object): def createLogBrowser(self): """ @@ -301,7 +401,7 @@ technolust") self.logbrowser = QTextBrowser() startStopButton = QPushButton("&Connect") - startStopButton.clicked.connect(self.start_or_stopVPN) + #startStopButton.clicked.connect(self.start_or_stopVPN) self.startStopButton = startStopButton logging_layout.addWidget(self.logbrowser) @@ -342,130 +442,64 @@ technolust") if self.debugmode: self.logbrowser.append(line[:-1]) - def set_statusbarMessage(self, msg): - self.statusBar().showMessage(msg) - - @pyqtSlot(object) - def onStatusChange(self, status): - """ - slot for status changes. triggers new signals for - updating icon, status bar, etc. - """ - - #print('STATUS CHANGED! (on Qt-land)') - #print('%s -> %s' % (status.previous, status.current)) - icon_name = self.conductor.get_icon_name() - self.setIcon(icon_name) - #print 'icon = ', icon_name - - # change connection pixmap widget - self.setConnWidget(icon_name) - - def setConnWidget(self, icon_name): - #print 'changing icon to %s' % icon_name - oldlayout = self.statusIconBox.layout() - - # XXX reuse with icons - # XXX move states to StateWidget - states = {"disconnected": 0, - "connecting": 1, - "connected": 2} - - for i in range(3): - oldlayout.itemAt(i).widget().hide() - new = states[icon_name] - oldlayout.itemAt(new).widget().show() - @pyqtSlot() - def start_or_stopVPN(self): - """ - stub for running child process with vpn - """ - if self.eip_service_started is False: - try: - self.conductor.connect() - # XXX move this to error queue - except eip_exceptions.EIPNoCommandError: - dialog = ErrorDialog() - dialog.warningMessage( - 'No suitable openvpn command found. ' - '
(Might be a permissions problem)', - 'error') - if self.debugmode: - self.startStopButton.setText('&Disconnect') - self.eip_service_started = True +# XXX +# main (leave only this here) +class LeapWindow(QMainWindow, LeapMainWindow, EIPConductorApp, + StatusAwareTrayIcon, + LogPane): - # XXX what is optimum polling interval? - # too little is overkill, too much - # will miss transition states.. + newLogLine = pyqtSignal([str]) + statusChange = pyqtSignal([object]) - self.timer.start(250.0) - return - if self.eip_service_started is True: - self.conductor.disconnect() - if self.debugmode: - self.startStopButton.setText('&Connect') - self.eip_service_started = False - self.timer.stop() - return + def __init__(self, opts): + logger.debug('init leap window') + super(LeapWindow, self).__init__() - @pyqtSlot() - def onTimerTick(self): - self.statusUpdate() + self.debugmode = getattr(opts, 'debug', False) + self.eip_service_started = False - @pyqtSlot() - def statusUpdate(self): - """ - called on timer tick - polls status and updates ui with real time - info about transferred bytes / connection state. - """ - # XXX it's too expensive to poll - # continously. move to signal events instead. + # create timer + self.timer = QTimer() - if not self.eip_service_started: - return + if self.debugmode: + self.createLogBrowser() + EIPConductorApp.__init__(self, opts=opts) - # 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) - print('errors. disconnect.') - self.start_or_stopVPN() # is stop + # LeapWindow init + self.createWindowHeader() - state = self.conductor.poll_connection_state() - if not state: - return + # StatusAwareTrayIcon init + self.createIconGroupBox() + self.createActions() + self.createTrayIcon() - ts, con_status, ok, ip, remote = state - self.set_statusbarMessage(con_status) - self.setToolTip() + widget = QWidget() + self.setCentralWidget(widget) - ts = time.strftime("%a %b %d %X", ts) + # add widgets to layout + mainLayout = QVBoxLayout() + mainLayout.addWidget(self.headerBox) + mainLayout.addWidget(self.statusIconBox) if self.debugmode: - self.updateTS.setText(ts) - self.status_label.setText(con_status) - self.ip_label.setText(ip) - self.remote_label.setText(remote) + mainLayout.addWidget(self.statusBox) + mainLayout.addWidget(self.loggerBox) + widget.setLayout(mainLayout) - # status i/o + # move to icons? + self.trayIcon.show() + self.setWindowTitle("LEAP Client") + self.resize(400, 300) + self.set_statusbarMessage('ready') - status = self.conductor.get_status_io() - if status and self.debugmode: - #XXX move this to systray menu indicators - ts, (tun_read, tun_write, tcp_read, tcp_write, auth_read) = status - ts = time.strftime("%a %b %d %X", ts) - self.updateTS.setText(ts) - self.tun_read_bytes.setText(tun_read) - self.tun_write_bytes.setText(tun_write) + # bind signals + # XXX move to parent classes init?? + self.trayIcon.activated.connect(self.iconActivated) + self.newLogLine.connect(lambda line: self.onLoggerNewLine(line)) + self.statusChange.connect(lambda status: self.onStatusChange(status)) + self.timer.timeout.connect(lambda: self.onTimerTick()) - def cleanupAndQuit(self): - """ - cleans state before shutting down app. - """ - # TODO:make sure to shutdown all child process / threads - # in conductor - self.conductor.cleanup() - qApp.quit() + # move to eipconductor init? + if self.debugmode: + self.startStopButton.clicked.connect( + lambda: self.start_or_stopVPN()) -- cgit v1.2.3 From 3fbc512a49923ac73d2413a083e0bb1f7e163866 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 05:20:31 +0900 Subject: actual split of classes into own modules still a bit rough, but makes everything a bit more readable. --- src/leap/baseapp/eip.py | 175 ++++++++++++++++ src/leap/baseapp/leap_app.py | 57 +++++ src/leap/baseapp/log.py | 56 +++++ src/leap/baseapp/mainwindow.py | 466 ++--------------------------------------- src/leap/baseapp/systray.py | 150 +++++++++++++ 5 files changed, 461 insertions(+), 443 deletions(-) create mode 100644 src/leap/baseapp/eip.py create mode 100644 src/leap/baseapp/leap_app.py create mode 100644 src/leap/baseapp/log.py create mode 100644 src/leap/baseapp/systray.py (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py new file mode 100644 index 00000000..e8b9fe53 --- /dev/null +++ b/src/leap/baseapp/eip.py @@ -0,0 +1,175 @@ +import time + +from PyQt4 import QtCore + +from leap.baseapp.dialogs import ErrorDialog +from leap.eip import exceptions as eip_exceptions +from leap.eip.eipconnection import EIPConnection + + +class EIPConductorApp(object): + + 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.conductor = EIPConnection( + watcher_cb=self.newLogLine.emit, + config_file=config_file, + status_signals=(self.statusChange.emit, ), + debug=self.debugmode) + + # XXX remove skip download when sample service is ready + self.conductor.run_checks(skip_download=True) + self.error_check() + if self.conductor.autostart: + self.start_or_stopVPN() + + def error_check(self): + ####### error checking ################ + # + # bunch of self checks. + # XXX move somewhere else alltogether. + # + if self.conductor.missing_definition is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'The default ' + 'definition.json file cannot be found', + 'error') + + if self.conductor.missing_provider is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'Missing provider. Add a remote_ip entry ' + 'under section [provider] in eip.cfg', + 'error') + + if self.conductor.missing_vpn_keyfile is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'Could not find the vpn keys file', + 'error') + + # ... btw, review pending. + # os.kill of subprocess fails if we have + # some of this errors. + + if self.conductor.bad_provider is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'Bad provider entry. Check that remote_ip entry ' + 'has an IP under section [provider] in eip.cfg', + 'error') + + if self.conductor.bad_keyfile_perms is True: + dialog = ErrorDialog() + dialog.criticalMessage( + 'The vpn keys file has bad permissions', + 'error') + + if self.conductor.missing_auth_agent is True: + dialog = ErrorDialog() + dialog.warningMessage( + 'We could not find any authentication ' + 'agent in your system.
' + 'Make sure you have ' + 'polkit-gnome-authentication-agent-1 ' + 'running and try again.', + 'error') + + if self.conductor.missing_pkexec is True: + dialog = ErrorDialog() + dialog.warningMessage( + 'We could not find pkexec in your ' + 'system.
Do you want to try ' + 'setuid workaround? ' + '(DOES NOTHING YET)', + 'error') + + @QtCore.pyqtSlot() + def statusUpdate(self): + """ + called on timer tick + polls status and updates ui with real time + info about transferred bytes / connection state. + """ + # XXX it's too expensive to poll + # continously. move to signal events instead. + + 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) + print('errors. disconnect.') + self.start_or_stopVPN() # is stop + + state = self.conductor.poll_connection_state() + if not state: + return + + ts, con_status, ok, ip, remote = state + self.set_statusbarMessage(con_status) + self.setIconToolTip() + + ts = time.strftime("%a %b %d %X", ts) + if self.debugmode: + self.updateTS.setText(ts) + self.status_label.setText(con_status) + self.ip_label.setText(ip) + self.remote_label.setText(remote) + + # status i/o + + status = self.conductor.get_status_io() + if status and self.debugmode: + #XXX move this to systray menu indicators + ts, (tun_read, tun_write, tcp_read, tcp_write, auth_read) = status + ts = time.strftime("%a %b %d %X", ts) + self.updateTS.setText(ts) + self.tun_read_bytes.setText(tun_read) + self.tun_write_bytes.setText(tun_write) + + @QtCore.pyqtSlot() + def start_or_stopVPN(self): + """ + stub for running child process with vpn + """ + if self.eip_service_started is False: + try: + self.conductor.connect() + # XXX move this to error queue + except eip_exceptions.EIPNoCommandError: + dialog = ErrorDialog() + dialog.warningMessage( + 'No suitable openvpn command found. ' + '
(Might be a permissions problem)', + 'error') + if self.debugmode: + self.startStopButton.setText('&Disconnect') + self.eip_service_started = True + + # XXX what is optimum polling interval? + # too little is overkill, too much + # will miss transition states.. + + self.timer.start(250.0) + return + if self.eip_service_started is True: + self.conductor.disconnect() + if self.debugmode: + self.startStopButton.setText('&Connect') + self.eip_service_started = False + self.timer.stop() + return diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py new file mode 100644 index 00000000..fb736ee3 --- /dev/null +++ b/src/leap/baseapp/leap_app.py @@ -0,0 +1,57 @@ +from PyQt4 import QtGui + +from leap.gui import mainwindow_rc + + +class MainWindow(object): + + def createWindowHeader(self): + """ + description lines for main window + """ + self.headerBox = QtGui.QGroupBox() + self.headerLabel = QtGui.QLabel("Encryption \ +Internet Proxy") + self.headerLabelSub = QtGui.QLabel("trust your \ +technolust") + + pixmap = QtGui.QPixmap(':/images/leapfrog.jpg') + frog_lbl = QtGui.QLabel() + frog_lbl.setPixmap(pixmap) + + headerLayout = QtGui.QHBoxLayout() + headerLayout.addWidget(frog_lbl) + headerLayout.addWidget(self.headerLabel) + headerLayout.addWidget(self.headerLabelSub) + headerLayout.addStretch() + self.headerBox.setLayout(headerLayout) + + def set_statusbarMessage(self, msg): + self.statusBar().showMessage(msg) + + def closeEvent(self, event): + """ + redefines close event (persistent window behaviour) + """ + if self.trayIcon.isVisible() and not self.debugmode: + QtGui.QMessageBox.information( + self, "Systray", + "The program will keep running " + "in the system tray. To " + "terminate the program, choose " + "Quit in the " + "context menu of the system tray entry.") + self.hide() + event.ignore() + if self.debugmode: + self.cleanupAndQuit() + + def cleanupAndQuit(self): + """ + cleans state before shutting down app. + """ + # TODO:make sure to shutdown all child process / threads + # in conductor + # XXX send signal instead? + self.conductor.cleanup() + QtGui.qApp.quit() diff --git a/src/leap/baseapp/log.py b/src/leap/baseapp/log.py new file mode 100644 index 00000000..139de845 --- /dev/null +++ b/src/leap/baseapp/log.py @@ -0,0 +1,56 @@ +from PyQt4 import QtGui +from PyQt4 import QtCore + + +class LogPane(object): + + def createLogBrowser(self): + """ + creates Browser widget for displaying logs + (in debug mode only). + """ + self.loggerBox = QtGui.QGroupBox() + logging_layout = QtGui.QVBoxLayout() + self.logbrowser = QtGui.QTextBrowser() + + startStopButton = QtGui.QPushButton("&Connect") + #startStopButton.clicked.connect(self.start_or_stopVPN) + self.startStopButton = startStopButton + + logging_layout.addWidget(self.logbrowser) + logging_layout.addWidget(self.startStopButton) + self.loggerBox.setLayout(logging_layout) + + # status box + + self.statusBox = QtGui.QGroupBox() + grid = QtGui.QGridLayout() + + self.updateTS = QtGui.QLabel('') + self.status_label = QtGui.QLabel('Disconnected') + self.ip_label = QtGui.QLabel('') + self.remote_label = QtGui.QLabel('') + + tun_read_label = QtGui.QLabel("tun read") + self.tun_read_bytes = QtGui.QLabel("0") + tun_write_label = QtGui.QLabel("tun write") + self.tun_write_bytes = QtGui.QLabel("0") + + grid.addWidget(self.updateTS, 0, 0) + grid.addWidget(self.status_label, 0, 1) + grid.addWidget(self.ip_label, 1, 0) + grid.addWidget(self.remote_label, 1, 1) + grid.addWidget(tun_read_label, 2, 0) + grid.addWidget(self.tun_read_bytes, 2, 1) + grid.addWidget(tun_write_label, 3, 0) + grid.addWidget(self.tun_write_bytes, 3, 1) + + self.statusBox.setLayout(grid) + + @QtCore.pyqtSlot(str) + def onLoggerNewLine(self, line): + """ + simple slot: writes new line to logger Pane. + """ + if self.debugmode: + self.logbrowser.append(line[:-1]) diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index ca9b79b3..917fc184 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -1,456 +1,31 @@ # vim: set fileencoding=utf-8 : #!/usr/bin/env python import logging -import time logging.basicConfig() logger = logging.getLogger(name=__name__) logger.setLevel(logging.DEBUG) -from PyQt4.QtGui import (QMainWindow, QWidget, QVBoxLayout, QMessageBox, - QSystemTrayIcon, QGroupBox, QLabel, QPixmap, - QHBoxLayout, QIcon, - QPushButton, QGridLayout, QAction, QMenu, - QTextBrowser, qApp) -from PyQt4.QtCore import (pyqtSlot, pyqtSignal, QTimer) +from PyQt4 import QtCore +from PyQt4 import QtGui -from leap.baseapp.dialogs import ErrorDialog -from leap.eip import exceptions as eip_exceptions -from leap.eip.eipconnection import EIPConnection +from leap.baseapp.eip import EIPConductorApp +from leap.baseapp.log import LogPane +from leap.baseapp.systray import StatusAwareTrayIcon +from leap.baseapp.leap_app import MainWindow from leap.gui import mainwindow_rc -class EIPConductorApp(object): - - 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.conductor = EIPConnection( - watcher_cb=self.newLogLine.emit, - config_file=config_file, - status_signals=(self.statusChange.emit, ), - debug=self.debugmode) - - # XXX remove skip download when sample service is ready - self.conductor.run_checks(skip_download=True) - self.error_check() - if self.conductor.autostart: - self.start_or_stopVPN() - - def error_check(self): - ####### error checking ################ - # - # bunch of self checks. - # XXX move somewhere else alltogether. - # - if self.conductor.missing_definition is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'The default ' - 'definition.json file cannot be found', - 'error') - - if self.conductor.missing_provider is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'Missing provider. Add a remote_ip entry ' - 'under section [provider] in eip.cfg', - 'error') - - if self.conductor.missing_vpn_keyfile is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'Could not find the vpn keys file', - 'error') - - # ... btw, review pending. - # os.kill of subprocess fails if we have - # some of this errors. - - if self.conductor.bad_provider is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'Bad provider entry. Check that remote_ip entry ' - 'has an IP under section [provider] in eip.cfg', - 'error') - - if self.conductor.bad_keyfile_perms is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'The vpn keys file has bad permissions', - 'error') - - if self.conductor.missing_auth_agent is True: - dialog = ErrorDialog() - dialog.warningMessage( - 'We could not find any authentication ' - 'agent in your system.
' - 'Make sure you have ' - 'polkit-gnome-authentication-agent-1 ' - 'running and try again.', - 'error') - - if self.conductor.missing_pkexec is True: - dialog = ErrorDialog() - dialog.warningMessage( - 'We could not find pkexec in your ' - 'system.
Do you want to try ' - 'setuid workaround? ' - '(DOES NOTHING YET)', - 'error') - - ############ end error checking ################### - @pyqtSlot() - def statusUpdate(self): - """ - called on timer tick - polls status and updates ui with real time - info about transferred bytes / connection state. - """ - # XXX it's too expensive to poll - # continously. move to signal events instead. - - 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) - print('errors. disconnect.') - self.start_or_stopVPN() # is stop - - state = self.conductor.poll_connection_state() - if not state: - return - - ts, con_status, ok, ip, remote = state - self.set_statusbarMessage(con_status) - self.setIconToolTip() - - ts = time.strftime("%a %b %d %X", ts) - if self.debugmode: - self.updateTS.setText(ts) - self.status_label.setText(con_status) - self.ip_label.setText(ip) - self.remote_label.setText(remote) - - # status i/o - - status = self.conductor.get_status_io() - if status and self.debugmode: - #XXX move this to systray menu indicators - ts, (tun_read, tun_write, tcp_read, tcp_write, auth_read) = status - ts = time.strftime("%a %b %d %X", ts) - self.updateTS.setText(ts) - self.tun_read_bytes.setText(tun_read) - self.tun_write_bytes.setText(tun_write) - - @pyqtSlot() - def start_or_stopVPN(self): - """ - stub for running child process with vpn - """ - if self.eip_service_started is False: - try: - self.conductor.connect() - # XXX move this to error queue - except eip_exceptions.EIPNoCommandError: - dialog = ErrorDialog() - dialog.warningMessage( - 'No suitable openvpn command found. ' - '
(Might be a permissions problem)', - 'error') - if self.debugmode: - self.startStopButton.setText('&Disconnect') - self.eip_service_started = True - - # XXX what is optimum polling interval? - # too little is overkill, too much - # will miss transition states.. - - self.timer.start(250.0) - return - if self.eip_service_started is True: - self.conductor.disconnect() - if self.debugmode: - self.startStopButton.setText('&Connect') - self.eip_service_started = False - self.timer.stop() - return - - -class StatusAwareTrayIcon(object): - - def createIconGroupBox(self): - """ - dummy icongroupbox - (to be removed from here -- reference only) - """ - icons = { - 'disconnected': ':/images/conn_error.png', - 'connecting': ':/images/conn_connecting.png', - 'connected': ':/images/conn_connected.png' - } - con_widgets = { - 'disconnected': QLabel(), - 'connecting': QLabel(), - 'connected': QLabel(), - } - con_widgets['disconnected'].setPixmap( - QPixmap(icons['disconnected'])) - con_widgets['connecting'].setPixmap( - QPixmap(icons['connecting'])) - con_widgets['connected'].setPixmap( - QPixmap(icons['connected'])), - self.ConnectionWidgets = con_widgets - - con_icons = { - 'disconnected': QIcon(icons['disconnected']), - 'connecting': QIcon(icons['connecting']), - 'connected': QIcon(icons['connected']) - } - self.Icons = con_icons - - self.statusIconBox = QGroupBox("Connection Status") - statusIconLayout = QHBoxLayout() - statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) - statusIconLayout.addWidget(self.ConnectionWidgets['connecting']) - statusIconLayout.addWidget(self.ConnectionWidgets['connected']) - statusIconLayout.itemAt(1).widget().hide() - statusIconLayout.itemAt(2).widget().hide() - self.statusIconBox.setLayout(statusIconLayout) - - def createTrayIcon(self): - """ - creates the tray icon - """ - self.trayIconMenu = QMenu(self) - - self.trayIconMenu.addAction(self.connectVPNAction) - self.trayIconMenu.addAction(self.dis_connectAction) - self.trayIconMenu.addSeparator() - self.trayIconMenu.addAction(self.minimizeAction) - self.trayIconMenu.addAction(self.maximizeAction) - self.trayIconMenu.addAction(self.restoreAction) - self.trayIconMenu.addSeparator() - self.trayIconMenu.addAction(self.quitAction) - - self.trayIcon = QSystemTrayIcon(self) - self.setIcon('disconnected') - self.trayIcon.setContextMenu(self.trayIconMenu) - - def createActions(self): - """ - creates actions to be binded to tray icon - """ - self.connectVPNAction = QAction("Connect to &VPN", self, - triggered=self.hide) - # XXX change action name on (dis)connect - self.dis_connectAction = QAction( - "&(Dis)connect", self, - triggered=lambda: self.start_or_stopVPN()) - self.minimizeAction = QAction("Mi&nimize", self, - triggered=self.hide) - self.maximizeAction = QAction("Ma&ximize", self, - triggered=self.showMaximized) - self.restoreAction = QAction("&Restore", self, - triggered=self.showNormal) - self.quitAction = QAction("&Quit", self, - triggered=self.cleanupAndQuit) - - def setConnWidget(self, icon_name): - #print 'changing icon to %s' % icon_name - oldlayout = self.statusIconBox.layout() - - # XXX reuse with icons - # XXX move states to StateWidget - states = {"disconnected": 0, - "connecting": 1, - "connected": 2} - - for i in range(3): - oldlayout.itemAt(i).widget().hide() - new = states[icon_name] - oldlayout.itemAt(new).widget().show() - - def setIcon(self, name): - icon = self.Icons.get(name) - self.trayIcon.setIcon(icon) - self.setWindowIcon(icon) - - def getIcon(self, icon_name): - # XXX get from connection dict - icons = {'disconnected': 0, - 'connecting': 1, - 'connected': 2} - return icons.get(icon_name, None) - - def setIconToolTip(self): - """ - get readable status and place it on systray tooltip - """ - status = self.conductor.status.get_readable_status() - self.trayIcon.setToolTip(status) - - def iconActivated(self, reason): - """ - handles left click, left double click - showing the trayicon menu - """ - #XXX there's a bug here! - #menu shows on (0,0) corner first time, - #until double clicked at least once. - if reason in (QSystemTrayIcon.Trigger, - QSystemTrayIcon.DoubleClick): - self.trayIconMenu.show() - - @pyqtSlot() - def onTimerTick(self): - self.statusUpdate() - - @pyqtSlot(object) - def onStatusChange(self, status): - """ - slot for status changes. triggers new signals for - updating icon, status bar, etc. - """ - - #print('STATUS CHANGED! (on Qt-land)') - #print('%s -> %s' % (status.previous, status.current)) - icon_name = self.conductor.get_icon_name() - self.setIcon(icon_name) - #print 'icon = ', icon_name - - # change connection pixmap widget - self.setConnWidget(icon_name) - - -class LeapMainWindow(object): - - def createWindowHeader(self): - """ - description lines for main window - """ - #XXX good candidate to refactor out! :) - self.headerBox = QGroupBox() - self.headerLabel = QLabel("Encryption \ -Internet Proxy") - self.headerLabelSub = QLabel("trust your \ -technolust") - - pixmap = QPixmap(':/images/leapfrog.jpg') - frog_lbl = QLabel() - frog_lbl.setPixmap(pixmap) - - headerLayout = QHBoxLayout() - headerLayout.addWidget(frog_lbl) - headerLayout.addWidget(self.headerLabel) - headerLayout.addWidget(self.headerLabelSub) - headerLayout.addStretch() - self.headerBox.setLayout(headerLayout) - - def set_statusbarMessage(self, msg): - self.statusBar().showMessage(msg) - - def closeEvent(self, event): - """ - redefines close event (persistent window behaviour) - """ - if self.trayIcon.isVisible() and not self.debugmode: - QMessageBox.information(self, "Systray", - "The program will keep running " - "in the system tray. To " - "terminate the program, choose " - "Quit in the " - "context menu of the system tray entry.") - self.hide() - event.ignore() - if self.debugmode: - self.cleanupAndQuit() - - def cleanupAndQuit(self): - """ - cleans state before shutting down app. - """ - # TODO:make sure to shutdown all child process / threads - # in conductor - # XXX send signal instead? - self.conductor.cleanup() - qApp.quit() - - -class LogPane(object): - - def createLogBrowser(self): - """ - creates Browser widget for displaying logs - (in debug mode only). - """ - self.loggerBox = QGroupBox() - logging_layout = QVBoxLayout() - self.logbrowser = QTextBrowser() - - startStopButton = QPushButton("&Connect") - #startStopButton.clicked.connect(self.start_or_stopVPN) - self.startStopButton = startStopButton - - logging_layout.addWidget(self.logbrowser) - logging_layout.addWidget(self.startStopButton) - self.loggerBox.setLayout(logging_layout) - - # status box - - self.statusBox = QGroupBox() - grid = QGridLayout() - - self.updateTS = QLabel('') - self.status_label = QLabel('Disconnected') - self.ip_label = QLabel('') - self.remote_label = QLabel('') - - tun_read_label = QLabel("tun read") - self.tun_read_bytes = QLabel("0") - tun_write_label = QLabel("tun write") - self.tun_write_bytes = QLabel("0") - - grid.addWidget(self.updateTS, 0, 0) - grid.addWidget(self.status_label, 0, 1) - grid.addWidget(self.ip_label, 1, 0) - grid.addWidget(self.remote_label, 1, 1) - grid.addWidget(tun_read_label, 2, 0) - grid.addWidget(self.tun_read_bytes, 2, 1) - grid.addWidget(tun_write_label, 3, 0) - grid.addWidget(self.tun_write_bytes, 3, 1) - - self.statusBox.setLayout(grid) - - @pyqtSlot(str) - def onLoggerNewLine(self, line): - """ - simple slot: writes new line to logger Pane. - """ - if self.debugmode: - self.logbrowser.append(line[:-1]) - - -# XXX -# main (leave only this here) -class LeapWindow(QMainWindow, LeapMainWindow, EIPConductorApp, +class LeapWindow(QtGui.QMainWindow, + MainWindow, EIPConductorApp, StatusAwareTrayIcon, LogPane): - newLogLine = pyqtSignal([str]) - statusChange = pyqtSignal([object]) + # move to log + newLogLine = QtCore.pyqtSignal([str]) + + # move to icons + statusChange = QtCore.pyqtSignal([object]) def __init__(self, opts): logger.debug('init leap window') @@ -459,8 +34,10 @@ class LeapWindow(QMainWindow, LeapMainWindow, EIPConductorApp, self.debugmode = getattr(opts, 'debug', False) self.eip_service_started = False - # create timer - self.timer = QTimer() + # create timer ############################## + # move to Icons init?? + self.timer = QtCore.QTimer() + ############################################# if self.debugmode: self.createLogBrowser() @@ -469,22 +46,25 @@ class LeapWindow(QMainWindow, LeapMainWindow, EIPConductorApp, # LeapWindow init self.createWindowHeader() - # StatusAwareTrayIcon init + # StatusAwareTrayIcon init ################### self.createIconGroupBox() self.createActions() self.createTrayIcon() + ############################################## - widget = QWidget() + # move to MainWindow init #################### + widget = QtGui.QWidget() self.setCentralWidget(widget) # add widgets to layout - mainLayout = QVBoxLayout() + mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(self.headerBox) mainLayout.addWidget(self.statusIconBox) if self.debugmode: mainLayout.addWidget(self.statusBox) mainLayout.addWidget(self.loggerBox) widget.setLayout(mainLayout) + ############################################### # move to icons? self.trayIcon.show() diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py new file mode 100644 index 00000000..7ef5cb01 --- /dev/null +++ b/src/leap/baseapp/systray.py @@ -0,0 +1,150 @@ +from PyQt4 import QtCore +from PyQt4 import QtGui + +from leap.gui import mainwindow_rc + + +class StatusAwareTrayIcon(object): + + def createIconGroupBox(self): + """ + dummy icongroupbox + (to be removed from here -- reference only) + """ + icons = { + 'disconnected': ':/images/conn_error.png', + 'connecting': ':/images/conn_connecting.png', + 'connected': ':/images/conn_connected.png' + } + con_widgets = { + 'disconnected': QtGui.QLabel(), + 'connecting': QtGui.QLabel(), + 'connected': QtGui.QLabel(), + } + con_widgets['disconnected'].setPixmap( + QtGui.QPixmap(icons['disconnected'])) + con_widgets['connecting'].setPixmap( + QtGui.QPixmap(icons['connecting'])) + con_widgets['connected'].setPixmap( + QtGui.QPixmap(icons['connected'])), + self.ConnectionWidgets = con_widgets + + con_icons = { + 'disconnected': QtGui.QIcon(icons['disconnected']), + 'connecting': QtGui.QIcon(icons['connecting']), + 'connected': QtGui.QIcon(icons['connected']) + } + self.Icons = con_icons + + self.statusIconBox = QtGui.QGroupBox("Connection Status") + statusIconLayout = QtGui.QHBoxLayout() + statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) + statusIconLayout.addWidget(self.ConnectionWidgets['connecting']) + statusIconLayout.addWidget(self.ConnectionWidgets['connected']) + statusIconLayout.itemAt(1).widget().hide() + statusIconLayout.itemAt(2).widget().hide() + self.statusIconBox.setLayout(statusIconLayout) + + def createTrayIcon(self): + """ + creates the tray icon + """ + self.trayIconMenu = QtGui.QMenu(self) + + self.trayIconMenu.addAction(self.connectVPNAction) + self.trayIconMenu.addAction(self.dis_connectAction) + self.trayIconMenu.addSeparator() + self.trayIconMenu.addAction(self.minimizeAction) + self.trayIconMenu.addAction(self.maximizeAction) + self.trayIconMenu.addAction(self.restoreAction) + self.trayIconMenu.addSeparator() + self.trayIconMenu.addAction(self.quitAction) + + self.trayIcon = QtGui.QSystemTrayIcon(self) + self.setIcon('disconnected') + self.trayIcon.setContextMenu(self.trayIconMenu) + + def createActions(self): + """ + creates actions to be binded to tray icon + """ + self.connectVPNAction = QtGui.QAction("Connect to &VPN", self, + triggered=self.hide) + # XXX change action name on (dis)connect + self.dis_connectAction = QtGui.QAction( + "&(Dis)connect", self, + triggered=lambda: self.start_or_stopVPN()) + self.minimizeAction = QtGui.QAction("Mi&nimize", self, + triggered=self.hide) + self.maximizeAction = QtGui.QAction("Ma&ximize", self, + triggered=self.showMaximized) + self.restoreAction = QtGui.QAction("&Restore", self, + triggered=self.showNormal) + self.quitAction = QtGui.QAction("&Quit", self, + triggered=self.cleanupAndQuit) + + def setConnWidget(self, icon_name): + #print 'changing icon to %s' % icon_name + oldlayout = self.statusIconBox.layout() + + # XXX reuse with icons + # XXX move states to StateWidget + states = {"disconnected": 0, + "connecting": 1, + "connected": 2} + + for i in range(3): + oldlayout.itemAt(i).widget().hide() + new = states[icon_name] + oldlayout.itemAt(new).widget().show() + + def setIcon(self, name): + icon = self.Icons.get(name) + self.trayIcon.setIcon(icon) + self.setWindowIcon(icon) + + def getIcon(self, icon_name): + # XXX get from connection dict + icons = {'disconnected': 0, + 'connecting': 1, + 'connected': 2} + return icons.get(icon_name, None) + + def setIconToolTip(self): + """ + get readable status and place it on systray tooltip + """ + status = self.conductor.status.get_readable_status() + self.trayIcon.setToolTip(status) + + def iconActivated(self, reason): + """ + handles left click, left double click + showing the trayicon menu + """ + #XXX there's a bug here! + #menu shows on (0,0) corner first time, + #until double clicked at least once. + if reason in (QtGui.QSystemTrayIcon.Trigger, + QtGui.QSystemTrayIcon.DoubleClick): + self.trayIconMenu.show() + + @QtCore.pyqtSlot() + def onTimerTick(self): + self.statusUpdate() + + @QtCore.pyqtSlot(object) + def onStatusChange(self, status): + """ + slot for status changes. triggers new signals for + updating icon, status bar, etc. + """ + + #print('STATUS CHANGED! (on Qt-land)') + #print('%s -> %s' % (status.previous, status.current)) + icon_name = self.conductor.get_icon_name() + self.setIcon(icon_name) + #print 'icon = ', icon_name + + # change connection pixmap widget + self.setConnWidget(icon_name) -- cgit v1.2.3 From b0b2b342b698bbe5851e9312cd830938f8d564a5 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 06:01:50 +0900 Subject: further cleaning of main window by moving init functions to their base classes. plus a bit of juggling with order. --- src/leap/baseapp/eip.py | 13 +++++++-- src/leap/baseapp/leap_app.py | 22 ++++++++++++++ src/leap/baseapp/mainwindow.py | 66 ++++++++++-------------------------------- src/leap/baseapp/systray.py | 11 +++++++ 4 files changed, 60 insertions(+), 52 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index e8b9fe53..a67fd916 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -19,6 +19,8 @@ class EIPConductorApp(object): opts = kwargs.pop('opts') config_file = getattr(opts, 'config_file', None) + self.eip_service_started = False + self.conductor = EIPConnection( watcher_cb=self.newLogLine.emit, config_file=config_file, @@ -28,8 +30,15 @@ class EIPConductorApp(object): # XXX remove skip download when sample service is ready self.conductor.run_checks(skip_download=True) self.error_check() - if self.conductor.autostart: - self.start_or_stopVPN() + + # XXX should receive "ready" signal + #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 ################ diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index fb736ee3..1b4d7747 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -5,6 +5,28 @@ from leap.gui import mainwindow_rc class MainWindow(object): + def __init__(self, *args, **kwargs): + # XXX set initial visibility + # debug = no visible + + widget = QtGui.QWidget() + self.setCentralWidget(widget) + + self.createWindowHeader() + + # add widgets to layout + mainLayout = QtGui.QVBoxLayout() + mainLayout.addWidget(self.headerBox) + mainLayout.addWidget(self.statusIconBox) + if self.debugmode: + mainLayout.addWidget(self.statusBox) + mainLayout.addWidget(self.loggerBox) + widget.setLayout(mainLayout) + + self.setWindowTitle("LEAP Client") + self.resize(400, 300) + self.set_statusbarMessage('ready') + def createWindowHeader(self): """ description lines for main window diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 917fc184..7cd02979 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -13,73 +13,39 @@ from leap.baseapp.log import LogPane from leap.baseapp.systray import StatusAwareTrayIcon from leap.baseapp.leap_app import MainWindow -from leap.gui import mainwindow_rc - class LeapWindow(QtGui.QMainWindow, MainWindow, EIPConductorApp, StatusAwareTrayIcon, LogPane): - # move to log newLogLine = QtCore.pyqtSignal([str]) - - # move to icons statusChange = QtCore.pyqtSignal([object]) def __init__(self, opts): logger.debug('init leap window') - super(LeapWindow, self).__init__() - self.debugmode = getattr(opts, 'debug', False) - self.eip_service_started = False - - # create timer ############################## - # move to Icons init?? - self.timer = QtCore.QTimer() - ############################################# + super(LeapWindow, self).__init__() if self.debugmode: self.createLogBrowser() EIPConductorApp.__init__(self, opts=opts) - - # LeapWindow init - self.createWindowHeader() - - # StatusAwareTrayIcon init ################### - self.createIconGroupBox() - self.createActions() - self.createTrayIcon() - ############################################## - - # move to MainWindow init #################### - widget = QtGui.QWidget() - self.setCentralWidget(widget) - - # add widgets to layout - mainLayout = QtGui.QVBoxLayout() - mainLayout.addWidget(self.headerBox) - mainLayout.addWidget(self.statusIconBox) - if self.debugmode: - mainLayout.addWidget(self.statusBox) - mainLayout.addWidget(self.loggerBox) - widget.setLayout(mainLayout) - ############################################### - - # move to icons? - self.trayIcon.show() - self.setWindowTitle("LEAP Client") - self.resize(400, 300) - self.set_statusbarMessage('ready') + StatusAwareTrayIcon.__init__(self) + MainWindow.__init__(self) # bind signals # XXX move to parent classes init?? self.trayIcon.activated.connect(self.iconActivated) - self.newLogLine.connect(lambda line: self.onLoggerNewLine(line)) - self.statusChange.connect(lambda status: self.onStatusChange(status)) - self.timer.timeout.connect(lambda: self.onTimerTick()) - - # move to eipconductor init? - if self.debugmode: - self.startStopButton.clicked.connect( - lambda: self.start_or_stopVPN()) + self.newLogLine.connect( + lambda line: self.onLoggerNewLine(line)) + self.statusChange.connect( + lambda status: self.onStatusChange(status)) + self.timer.timeout.connect( + lambda: self.onTimerTick()) + + # ... all ready. go! + + # could send "ready" signal instead + # eipapp should catch that + if self.conductor.autostart: + self.start_or_stopVPN() diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 7ef5cb01..249a4f7e 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -6,6 +6,17 @@ from leap.gui import mainwindow_rc class StatusAwareTrayIcon(object): + def __init__(self, *args, **kwargs): + # StatusAwareTrayIcon init ################### + self.createIconGroupBox() + self.createActions() + self.createTrayIcon() + + self.trayIcon.show() + ############################################## + + self.timer = QtCore.QTimer() + def createIconGroupBox(self): """ dummy icongroupbox -- cgit v1.2.3 From 1826d9a0d5400c21a3f7af73eda2e843f0639271 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 06:37:45 +0900 Subject: add little docstrings to classes --- src/leap/baseapp/eip.py | 45 ++++++++++++++++++++++++++---------------- src/leap/baseapp/leap_app.py | 4 ++++ src/leap/baseapp/log.py | 4 ++++ src/leap/baseapp/mainwindow.py | 6 ++++++ src/leap/baseapp/systray.py | 10 +++++++--- 5 files changed, 49 insertions(+), 20 deletions(-) (limited to 'src/leap/baseapp') 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): -- cgit v1.2.3 From 8ef9f6f6f155b4acd0a69f1611058c4f0ba07d42 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 06:58:15 +0900 Subject: refactor icon/iconpath dict closes #331 --- src/leap/baseapp/systray.py | 61 ++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 3fb64db1..f3832473 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -11,6 +11,24 @@ class StatusAwareTrayIcon(object): get updated from conductor status polling. """ + states = { + "disconnected": 0, + "connecting": 1, + "connected": 2} + + iconpath = { + "disconnected": ':/images/conn_error.png', + "connecting": ':/images/conn_connecting.png', + "connected": ':/images/conn_connected.png'} + + Icons = { + 'disconnected': lambda self: QtGui.QIcon( + self.iconpath['disconnected']), + 'connecting': lambda self: QtGui.QIcon( + self.iconpath['connecting']), + 'connected': lambda self: QtGui.QIcon( + self.iconpath['connected']) + } def __init__(self, *args, **kwargs): self.createIconGroupBox() @@ -26,31 +44,22 @@ class StatusAwareTrayIcon(object): dummy icongroupbox (to be removed from here -- reference only) """ - icons = { - 'disconnected': ':/images/conn_error.png', - 'connecting': ':/images/conn_connecting.png', - 'connected': ':/images/conn_connected.png' - } con_widgets = { 'disconnected': QtGui.QLabel(), 'connecting': QtGui.QLabel(), 'connected': QtGui.QLabel(), } con_widgets['disconnected'].setPixmap( - QtGui.QPixmap(icons['disconnected'])) + QtGui.QPixmap( + self.iconpath['disconnected'])) con_widgets['connecting'].setPixmap( - QtGui.QPixmap(icons['connecting'])) + QtGui.QPixmap( + self.iconpath['connecting'])) con_widgets['connected'].setPixmap( - QtGui.QPixmap(icons['connected'])), + QtGui.QPixmap( + self.iconpath['connected'])), self.ConnectionWidgets = con_widgets - con_icons = { - 'disconnected': QtGui.QIcon(icons['disconnected']), - 'connecting': QtGui.QIcon(icons['connecting']), - 'connected': QtGui.QIcon(icons['connected']) - } - self.Icons = con_icons - self.statusIconBox = QtGui.QGroupBox("Connection Status") statusIconLayout = QtGui.QHBoxLayout() statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) @@ -99,31 +108,20 @@ class StatusAwareTrayIcon(object): triggered=self.cleanupAndQuit) def setConnWidget(self, icon_name): - #print 'changing icon to %s' % icon_name oldlayout = self.statusIconBox.layout() - # XXX reuse with icons - # XXX move states to StateWidget - states = {"disconnected": 0, - "connecting": 1, - "connected": 2} - for i in range(3): oldlayout.itemAt(i).widget().hide() - new = states[icon_name] + new = self.states[icon_name] oldlayout.itemAt(new).widget().show() def setIcon(self, name): - icon = self.Icons.get(name) + icon = self.Icons.get(name)(self) self.trayIcon.setIcon(icon) self.setWindowIcon(icon) def getIcon(self, icon_name): - # XXX get from connection dict - icons = {'disconnected': 0, - 'connecting': 1, - 'connected': 2} - return icons.get(icon_name, None) + return self.states.get(icon_name, None) def setIconToolTip(self): """ @@ -154,12 +152,7 @@ class StatusAwareTrayIcon(object): slot for status changes. triggers new signals for updating icon, status bar, etc. """ - - #print('STATUS CHANGED! (on Qt-land)') - #print('%s -> %s' % (status.previous, status.current)) icon_name = self.conductor.get_icon_name() self.setIcon(icon_name) - #print 'icon = ', icon_name - # change connection pixmap widget self.setConnWidget(icon_name) -- cgit v1.2.3 From 3b752fcfac7a18891e2f948acae0cb4781678647 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 4 Sep 2012 07:11:01 +0900 Subject: put timer constant instead of hardcoded value --- src/leap/baseapp/constants.py | 1 + src/leap/baseapp/eip.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 src/leap/baseapp/constants.py (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/constants.py b/src/leap/baseapp/constants.py new file mode 100644 index 00000000..763df23b --- /dev/null +++ b/src/leap/baseapp/constants.py @@ -0,0 +1 @@ +TIMER_MILLISECONDS = 250.0 diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 6c3249ff..029ce0ba 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -3,6 +3,7 @@ import time from PyQt4 import QtCore from leap.baseapp.dialogs import ErrorDialog +from leap.baseapp import constants from leap.eip import exceptions as eip_exceptions from leap.eip.eipconnection import EIPConnection @@ -182,8 +183,7 @@ class EIPConductorApp(object): # should bring it here? # to its own class? - # XXX get constant from somewhere else - self.timer.start(250.0) + self.timer.start(constants.TIMER_MILLISECONDS) return if self.eip_service_started is True: -- cgit v1.2.3 From a2804c3de1470db98d8c6aa8a01e2de1aa1718a1 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 5 Sep 2012 07:42:10 +0900 Subject: app wide logging handler --- src/leap/baseapp/eip.py | 9 +++++++-- src/leap/baseapp/leap_app.py | 6 ++++++ src/leap/baseapp/mainwindow.py | 5 ++--- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 029ce0ba..e0da63a2 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -1,3 +1,4 @@ +import logging import time from PyQt4 import QtCore @@ -7,6 +8,8 @@ from leap.baseapp import constants from leap.eip import exceptions as eip_exceptions from leap.eip.eipconnection import EIPConnection +logger = logging.getLogger(name=__name__) + class EIPConductorApp(object): """ @@ -126,8 +129,10 @@ class EIPConductorApp(object): if self.conductor.with_errors: #XXX how to wait on pkexec??? #something better that this workaround, plz!! - time.sleep(2) - print('errors. disconnect.') + time.sleep(5) + #print('errors. disconnect.') + logger.debug('timeout') + logger.error('errors. disconnect') self.start_or_stopVPN() # is stop state = self.conductor.poll_connection_state() diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index def95da1..85644360 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -1,7 +1,11 @@ +import logging + from PyQt4 import QtGui from leap.gui import mainwindow_rc +logger = logging.getLogger(name=__name__) + class MainWindow(object): """ @@ -79,5 +83,7 @@ technolust") # TODO:make sure to shutdown all child process / threads # in conductor # XXX send signal instead? + logger.info('Shutting down') self.conductor.cleanup() + logger.info('Exiting') QtGui.qApp.quit() diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index ac7fe9c4..e87f5844 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -1,9 +1,6 @@ # vim: set fileencoding=utf-8 : #!/usr/bin/env python import logging -logging.basicConfig() -logger = logging.getLogger(name=__name__) -logger.setLevel(logging.DEBUG) from PyQt4 import QtCore from PyQt4 import QtGui @@ -13,6 +10,8 @@ from leap.baseapp.log import LogPane from leap.baseapp.systray import StatusAwareTrayIcon from leap.baseapp.leap_app import MainWindow +logger = logging.getLogger(name=__name__) + class LeapWindow(QtGui.QMainWindow, MainWindow, EIPConductorApp, -- cgit v1.2.3 From 535e584ba978a7a234a52df14f89197fbc3cea14 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 5 Sep 2012 07:59:35 +0900 Subject: openvpn messages log to eip.openvpn logger so we can get them to file / stdout even if our log viewer is not launched. --- src/leap/baseapp/eip.py | 1 - src/leap/baseapp/log.py | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index e0da63a2..856cb197 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -130,7 +130,6 @@ class EIPConductorApp(object): #XXX how to wait on pkexec??? #something better that this workaround, plz!! time.sleep(5) - #print('errors. disconnect.') logger.debug('timeout') logger.error('errors. disconnect') self.start_or_stopVPN() # is stop diff --git a/src/leap/baseapp/log.py b/src/leap/baseapp/log.py index 0c98eb94..3580e987 100644 --- a/src/leap/baseapp/log.py +++ b/src/leap/baseapp/log.py @@ -1,6 +1,10 @@ +import logging + from PyQt4 import QtGui from PyQt4 import QtCore +vpnlogger = logging.getLogger('leap.openvpn') + class LogPane(object): """ @@ -56,5 +60,7 @@ class LogPane(object): """ simple slot: writes new line to logger Pane. """ + msg = line[:-1] if self.debugmode: - self.logbrowser.append(line[:-1]) + self.logbrowser.append(msg) + vpnlogger.info(msg) -- cgit v1.2.3 From c190b7f66cc1977d0e058bfa2d8fc1a850326320 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 5 Sep 2012 10:23:24 +0900 Subject: missing_pkexec error converted to "auto" error. idea is that we define user messages in the exceptions, and queue them during (conductor) checks. user facing dialogs get constucted from exception attrs. if critical, log as such and exit. --- src/leap/baseapp/dialogs.py | 17 ++++++------- src/leap/baseapp/eip.py | 59 +++++++++++++++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 28 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py index 4b1b5b62..d37a234c 100644 --- a/src/leap/baseapp/dialogs.py +++ b/src/leap/baseapp/dialogs.py @@ -4,7 +4,6 @@ from PyQt4.QtGui import (QDialog, QFrame, QPushButton, QLabel, QMessageBox) class ErrorDialog(QDialog): def __init__(self, parent=None): super(ErrorDialog, self).__init__(parent) - frameStyle = QFrame.Sunken | QFrame.Panel self.warningLabel = QLabel() self.warningLabel.setFrameStyle(frameStyle) @@ -15,19 +14,17 @@ class ErrorDialog(QDialog): "QMessageBox.warning()", msg, QMessageBox.NoButton, self) msgBox.addButton("&Ok", QMessageBox.AcceptRole) - msgBox.addButton("&Cancel", QMessageBox.RejectRole) if msgBox.exec_() == QMessageBox.AcceptRole: - self.warningLabel.setText("Save Again") - else: - self.warningLabel.setText("Continue") + pass + # do whatever we want to do after + # closing the dialog. we can pass that + # in the constructor def criticalMessage(self, msg, label): msgBox = QMessageBox(QMessageBox.Critical, "QMessageBox.critical()", msg, QMessageBox.NoButton, self) msgBox.addButton("&Ok", QMessageBox.AcceptRole) - msgBox.addButton("&Cancel", QMessageBox.RejectRole) - if msgBox.exec_() == QMessageBox.AcceptRole: - self.warningLabel.setText("Save Again") - else: - self.warningLabel.setText("Continue") + msgBox.exec_() + import sys + sys.exit() diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 856cb197..dd88b7f5 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -12,6 +12,7 @@ logger = logging.getLogger(name=__name__) class EIPConductorApp(object): + # XXX EIPConductorMixin ? """ initializes an instance of EIPConnection, gathers errors, and passes status-change signals @@ -51,8 +52,38 @@ class EIPConductorApp(object): lambda: self.start_or_stopVPN()) def error_check(self): - - # XXX refactor (by #504) + logger.debug('error check') + + ##################################### + # XXX refactor in progress (by #504) + errq = self.conductor.error_queue + while errq.qsize() != 0: + logger.debug('%s errors left in conductor queue', errq.qsize()) + error = errq.get() + logger.error('%s: %s', error.__class__.__name__, error.message) + + if issubclass(error.__class__, eip_exceptions.EIPClientError): + if error.critical: + logger.critical(error.message) + logger.error('quitting') + + # XXX + # check headless = False before + # launching dialog. + # (for Qt tests) + + dialog = ErrorDialog() + if getattr(error, 'usermessage', None): + message = error.usermessage + else: + message = error.message + dialog.criticalMessage(message, 'error') + else: + logger.exception(error.message) + else: + import traceback + traceback.print_exc() + raise error if self.conductor.missing_definition is True: dialog = ErrorDialog() @@ -78,12 +109,14 @@ class EIPConductorApp(object): # os.kill of subprocess fails if we have # some of this errors. - if self.conductor.bad_provider is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'Bad provider entry. Check that remote_ip entry ' - 'has an IP under section [provider] in eip.cfg', - 'error') + # deprecated. + # get something alike. + #if self.conductor.bad_provider is True: + #dialog = ErrorDialog() + #dialog.criticalMessage( + #'Bad provider entry. Check that remote_ip entry ' + #'has an IP under section [provider] in eip.cfg', + #'error') if self.conductor.bad_keyfile_perms is True: dialog = ErrorDialog() @@ -91,16 +124,6 @@ class EIPConductorApp(object): 'The vpn keys file has bad permissions', 'error') - if self.conductor.missing_auth_agent is True: - dialog = ErrorDialog() - dialog.warningMessage( - 'We could not find any authentication ' - 'agent in your system.
' - 'Make sure you have ' - 'polkit-gnome-authentication-agent-1 ' - 'running and try again.', - 'error') - if self.conductor.missing_pkexec is True: dialog = ErrorDialog() dialog.warningMessage( -- cgit v1.2.3 From 8148bc9c8c113c41fcb18b397669b1f13447c653 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 6 Sep 2012 02:27:04 +0900 Subject: more generic error handler in EipConductorAppMixin documentation of the Exception Hierarchy and attributes. also a bit of general cleanup around error handling in conductor. Hopefully to be polished an abstracted to leap.base with time. not all errors are converted (and the old with_errors/ignoring errors) are still there, but we should be using this style of handlers from now on. wrapping up with this pseudo-feature for now. as we work on individual features we can mimick the exceptions that are working. --- src/leap/baseapp/constants.py | 5 ++ src/leap/baseapp/dialogs.py | 19 +++++- src/leap/baseapp/eip.py | 150 +++++++++++++++++++++-------------------- src/leap/baseapp/leap_app.py | 2 +- src/leap/baseapp/log.py | 3 +- src/leap/baseapp/mainwindow.py | 20 +++--- src/leap/baseapp/systray.py | 2 +- 7 files changed, 113 insertions(+), 88 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/constants.py b/src/leap/baseapp/constants.py index 763df23b..e312be21 100644 --- a/src/leap/baseapp/constants.py +++ b/src/leap/baseapp/constants.py @@ -1 +1,6 @@ +# This timer used for polling vpn manager state. + +# XXX what is an optimum polling interval? +# too little will be overkill, too much will +# miss transition states. TIMER_MILLISECONDS = 250.0 diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py index d37a234c..d4acb09d 100644 --- a/src/leap/baseapp/dialogs.py +++ b/src/leap/baseapp/dialogs.py @@ -1,14 +1,25 @@ +import logging + from PyQt4.QtGui import (QDialog, QFrame, QPushButton, QLabel, QMessageBox) +logger = logging.getLogger(name=__name__) + class ErrorDialog(QDialog): - def __init__(self, parent=None): + def __init__(self, parent=None, errtype=None, msg=None, label=None): super(ErrorDialog, self).__init__(parent) frameStyle = QFrame.Sunken | QFrame.Panel self.warningLabel = QLabel() self.warningLabel.setFrameStyle(frameStyle) self.warningButton = QPushButton("QMessageBox.&warning()") + if msg is not None: + self.msg = msg + if label is not None: + self.label = label + if errtype == "critical": + self.criticalMessage(self.msg, self.label) + def warningMessage(self, msg, label): msgBox = QMessageBox(QMessageBox.Warning, "QMessageBox.warning()", msg, @@ -26,5 +37,11 @@ class ErrorDialog(QDialog): QMessageBox.NoButton, self) msgBox.addButton("&Ok", QMessageBox.AcceptRole) msgBox.exec_() + + # It's critical, so we exit. + # We should better emit a signal and connect it + # with the proper shutdownAndQuit method, but + # this suffices for now. + logger.info('Quitting') import sys sys.exit() diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index dd88b7f5..afdb7adc 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -11,8 +11,7 @@ from leap.eip.eipconnection import EIPConnection logger = logging.getLogger(name=__name__) -class EIPConductorApp(object): - # XXX EIPConductorMixin ? +class EIPConductorAppMixin(object): """ initializes an instance of EIPConnection, gathers errors, and passes status-change signals @@ -52,86 +51,90 @@ class EIPConductorApp(object): lambda: self.start_or_stopVPN()) def error_check(self): + """ + consumes the conductor error queue. + pops errors, and acts accordingly (launching user dialogs). + """ logger.debug('error check') ##################################### # XXX refactor in progress (by #504) + errq = self.conductor.error_queue while errq.qsize() != 0: logger.debug('%s errors left in conductor queue', errq.qsize()) error = errq.get() + + # redundant log, debugging the loop. logger.error('%s: %s', error.__class__.__name__, error.message) if issubclass(error.__class__, eip_exceptions.EIPClientError): - if error.critical: - logger.critical(error.message) - logger.error('quitting') - - # XXX - # check headless = False before - # launching dialog. - # (for Qt tests) - - dialog = ErrorDialog() - if getattr(error, 'usermessage', None): - message = error.usermessage - else: - message = error.message - dialog.criticalMessage(message, 'error') - else: - logger.exception(error.message) + self.handle_eip_error(error) + else: + # This is not quite working. FIXME import traceback traceback.print_exc() raise error - if self.conductor.missing_definition is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'The default ' - 'definition.json file cannot be found', - 'error') + if error.failfirst is True: + break - if self.conductor.missing_provider is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'Missing provider. Add a remote_ip entry ' - 'under section [provider] in eip.cfg', - 'error') + ############################################# + # old errors to check + # write test for them and them remove + # their corpses from here. - if self.conductor.missing_vpn_keyfile is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'Could not find the vpn keys file', - 'error') + #if self.conductor.missing_vpn_keyfile is True: + #dialog = ErrorDialog() + #dialog.criticalMessage( + #'Could not find the vpn keys file', + #'error') - # ... btw, review pending. - # os.kill of subprocess fails if we have - # some of this errors. + #if self.conductor.bad_keyfile_perms is True: + #dialog = ErrorDialog() + #dialog.criticalMessage( + #'The vpn keys file has bad permissions', + #'error') - # deprecated. - # get something alike. - #if self.conductor.bad_provider is True: + # deprecated. configchecker takes care of that. + #if self.conductor.missing_definition is True: #dialog = ErrorDialog() #dialog.criticalMessage( - #'Bad provider entry. Check that remote_ip entry ' - #'has an IP under section [provider] in eip.cfg', + #'The default ' + #'definition.json file cannot be found', #'error') - if self.conductor.bad_keyfile_perms is True: - dialog = ErrorDialog() - dialog.criticalMessage( - 'The vpn keys file has bad permissions', - 'error') + def handle_eip_error(self, error): + """ + check severity and launches + dialogs informing user about the errors. + in the future we plan to derive errors to + our log viewer. + """ - if self.conductor.missing_pkexec is True: + if getattr(error, 'usermessage', None): + message = error.usermessage + else: + message = error.message + + # XXX + # check headless = False before + # launching dialog. + # (so Qt tests can assert stuff) + + if error.critical: + logger.critical(error.message) + #critical error (non recoverable), + #we give user some info and quit. + #(critical error dialog will exit app) + ErrorDialog(errtype="critical", + msg=message, + label="critical error") + + else: dialog = ErrorDialog() - dialog.warningMessage( - 'We could not find pkexec in your ' - 'system.
Do you want to try ' - 'setuid workaround? ' - '(DOES NOTHING YET)', - 'error') + dialog.warningMessage(message, 'error') @QtCore.pyqtSlot() def statusUpdate(self): @@ -188,29 +191,30 @@ class EIPConductorApp(object): """ stub for running child process with vpn """ + if self.conductor.has_errors(): + logger.debug('not starting vpn; conductor has errors') + if self.eip_service_started is False: try: self.conductor.connect() - # XXX move this to error queue - except eip_exceptions.EIPNoCommandError: - dialog = ErrorDialog() - dialog.warningMessage( - 'No suitable openvpn command found. ' - '
(Might be a permissions problem)', - 'error') - if self.debugmode: - self.startStopButton.setText('&Disconnect') - self.eip_service_started = True - # XXX what is optimum polling interval? - # too little is overkill, too much - # will miss transition states.. + except eip_exceptions.EIPNoCommandError as exc: + self.handle_eip_error(exc) + + except Exception as err: + # raise generic exception (Bad Thing Happened?) + logger.exception(err) + else: + # no errors, so go on. + if self.debugmode: + self.startStopButton.setText('&Disconnect') + self.eip_service_started = True - # XXX decouple! (timer is init by icons class). - # should bring it here? - # to its own class? + # XXX decouple! (timer is init by icons class). + # we could bring Timer Init to this Mixin + # or to its own Mixin. + self.timer.start(constants.TIMER_MILLISECONDS) - self.timer.start(constants.TIMER_MILLISECONDS) return if self.eip_service_started is True: diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 85644360..f91b2329 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -7,7 +7,7 @@ from leap.gui import mainwindow_rc logger = logging.getLogger(name=__name__) -class MainWindow(object): +class MainWindowMixin(object): """ create the main window for leap app diff --git a/src/leap/baseapp/log.py b/src/leap/baseapp/log.py index 3580e987..8a7f81c3 100644 --- a/src/leap/baseapp/log.py +++ b/src/leap/baseapp/log.py @@ -6,7 +6,7 @@ from PyQt4 import QtCore vpnlogger = logging.getLogger('leap.openvpn') -class LogPane(object): +class LogPaneMixin(object): """ a simple log pane that writes new lines as they come @@ -22,7 +22,6 @@ class LogPane(object): self.logbrowser = QtGui.QTextBrowser() startStopButton = QtGui.QPushButton("&Connect") - #startStopButton.clicked.connect(self.start_or_stopVPN) self.startStopButton = startStopButton logging_layout.addWidget(self.logbrowser) diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index e87f5844..10b23d9a 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -5,18 +5,18 @@ import logging from PyQt4 import QtCore from PyQt4 import QtGui -from leap.baseapp.eip import EIPConductorApp -from leap.baseapp.log import LogPane -from leap.baseapp.systray import StatusAwareTrayIcon -from leap.baseapp.leap_app import MainWindow +from leap.baseapp.eip import EIPConductorAppMixin +from leap.baseapp.log import LogPaneMixin +from leap.baseapp.systray import StatusAwareTrayIconMixin +from leap.baseapp.leap_app import MainWindowMixin logger = logging.getLogger(name=__name__) class LeapWindow(QtGui.QMainWindow, - MainWindow, EIPConductorApp, - StatusAwareTrayIcon, - LogPane): + MainWindowMixin, EIPConductorAppMixin, + StatusAwareTrayIconMixin, + LogPaneMixin): """ main window for the leap app. Initializes all of its base classes @@ -34,9 +34,9 @@ class LeapWindow(QtGui.QMainWindow, super(LeapWindow, self).__init__() if self.debugmode: self.createLogBrowser() - EIPConductorApp.__init__(self, opts=opts) - StatusAwareTrayIcon.__init__(self) - MainWindow.__init__(self) + EIPConductorAppMixin.__init__(self, opts=opts) + StatusAwareTrayIconMixin.__init__(self) + MainWindowMixin.__init__(self) # bind signals # XXX move to parent classes init?? diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index f3832473..c696ee74 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -4,7 +4,7 @@ from PyQt4 import QtGui from leap.gui import mainwindow_rc -class StatusAwareTrayIcon(object): +class StatusAwareTrayIconMixin(object): """ a mix of several functions needed to create a systray and make it -- cgit v1.2.3 From 75f4128f5ed515c4df57275bf1479ccdf741c83f Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 6 Sep 2012 03:15:53 +0900 Subject: make tests pass. forgot to update eipconnection tests after #504 changes :( --- src/leap/baseapp/eip.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index afdb7adc..f26c9f88 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -193,6 +193,7 @@ class EIPConductorAppMixin(object): """ if self.conductor.has_errors(): logger.debug('not starting vpn; conductor has errors') + #import ipdb;ipdb.set_trace() if self.eip_service_started is False: try: -- cgit v1.2.3 From fc8a54a40645412e9c738723e54159bfda40cfde Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 6 Sep 2012 04:18:27 +0900 Subject: openvpn management socket is a temp path on each run --- src/leap/baseapp/eip.py | 1 - 1 file changed, 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index f26c9f88..afdb7adc 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -193,7 +193,6 @@ class EIPConductorAppMixin(object): """ if self.conductor.has_errors(): logger.debug('not starting vpn; conductor has errors') - #import ipdb;ipdb.set_trace() if self.eip_service_started is False: try: -- cgit v1.2.3 From 18109193b239be6e7ecc4c2d07c9c999e33081f8 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 12 Sep 2012 21:29:49 +0000 Subject: checks for systray in unity --- src/leap/baseapp/dialogs.py | 12 +++++++ src/leap/baseapp/unitychecks.py | 79 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/leap/baseapp/unitychecks.py (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py index d4acb09d..af531154 100644 --- a/src/leap/baseapp/dialogs.py +++ b/src/leap/baseapp/dialogs.py @@ -1,3 +1,4 @@ +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 import logging from PyQt4.QtGui import (QDialog, QFrame, QPushButton, QLabel, QMessageBox) @@ -31,6 +32,7 @@ class ErrorDialog(QDialog): # closing the dialog. we can pass that # in the constructor + def criticalMessage(self, msg, label): msgBox = QMessageBox(QMessageBox.Critical, "QMessageBox.critical()", msg, @@ -45,3 +47,13 @@ class ErrorDialog(QDialog): logger.info('Quitting') import sys sys.exit() + + def confirmMessage(self, msg, label, action): + msgBox = QMessageBox(QMessageBox.Critical, + "QMessageBox.critical()", msg, + QMessageBox.NoButton, self) + msgBox.addButton("&Ok", QMessageBox.AcceptRole) + msgBox.addButton("&Cancel", QMessageBox.RejectRole) + + if msgBox.exec_() == QMessageBox.AcceptRole: + action() diff --git a/src/leap/baseapp/unitychecks.py b/src/leap/baseapp/unitychecks.py new file mode 100644 index 00000000..aa644c5f --- /dev/null +++ b/src/leap/baseapp/unitychecks.py @@ -0,0 +1,79 @@ +#!/usr/bin/python2 +# vim: tabstop=8 expandtab shiftwidth=5 softtabstop=4 +""" +modified from code from the starcal2 project +copyright Saeed Rasooli +License: GPL +""" +import logging +import platform +import sys +from subprocess import Popen, PIPE + +logging.basicConfig() +logger = logging.getLogger(__name__) +logger.setLevel('DEBUG') + +from leap.base.constants import APP_NAME +from leap.baseapp.dialogs import ErrorDialog + +get_whitelist = lambda: eval(Popen(['gsettings', 'get', 'com.canonical.Unity.Panel', 'systray-whitelist'], stdout=PIPE).communicate()[0]) + +set_whitelist = lambda ls: Popen(['gsettings', 'set', 'com.canonical.Unity.Panel', 'systray-whitelist', repr(ls)]) + +def add_to_whitelist(): + ls = get_whitelist() + if not APP_NAME in ls: + ls.append(APP_NAME) + set_whitelist(ls) + +def remove_from_whitelist(): + ls = get_whitelist() + if APP_NAME in ls: + ls.remove(APP_NAME) + set_whitelist(ls) + +def is_unity_running(): + (output, error) = Popen('ps aux | grep [u]nity-panel-service', stdout=PIPE, shell=True).communicate() + output = bool(str(output)) + if not output: + (output, error) = Popen('ps aux | grep [u]nity-2d-panel', stdout=PIPE, shell=True).communicate() + output = bool(str(output)) + return output + +def need_to_add(): + if is_unity_running(): + wlist = get_whitelist() + if not (APP_NAME in wlist or 'all' in wlist): + logger.debug('need to add') + return True + return False + +def add_and_restart(): + add_to_whitelist() + Popen('LANG=en_US.UTF-8 unity', shell=True) + +MSG = "Seems that you are using a Unity desktop and Leap is not allowed to use Tray icon. Press OK to add Leap to Unity's white list and then restart Unity" + +def do_check(): + if platform.system() == "Linux" and need_to_add(): + dialog = ErrorDialog() + dialog.confirmMessage( + MSG, + "add to systray?", + add_and_restart) + +if __name__=='__main__': + if len(sys.argv)>1: + cmd = sys.argv[1] + if cmd=='add': + add_to_whitelist() + elif cmd=='rm': + remove_from_whitelist() + elif cmd=='print': + print get_whitelist() + elif cmd=="check": + from PyQt4.QtGui import QApplication + app = QApplication(sys.argv) + do_check() + -- cgit v1.2.3 From ddd11604a5ae376ba27f70c9eb9a6971e749b1f9 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 12 Sep 2012 08:49:13 +0900 Subject: pep8 --- src/leap/baseapp/dialogs.py | 1 - src/leap/baseapp/unitychecks.py | 45 +++++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 14 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py index af531154..3cb539cf 100644 --- a/src/leap/baseapp/dialogs.py +++ b/src/leap/baseapp/dialogs.py @@ -32,7 +32,6 @@ class ErrorDialog(QDialog): # closing the dialog. we can pass that # in the constructor - def criticalMessage(self, msg, label): msgBox = QMessageBox(QMessageBox.Critical, "QMessageBox.critical()", msg, diff --git a/src/leap/baseapp/unitychecks.py b/src/leap/baseapp/unitychecks.py index aa644c5f..72c9ee6f 100644 --- a/src/leap/baseapp/unitychecks.py +++ b/src/leap/baseapp/unitychecks.py @@ -17,9 +17,14 @@ logger.setLevel('DEBUG') from leap.base.constants import APP_NAME from leap.baseapp.dialogs import ErrorDialog -get_whitelist = lambda: eval(Popen(['gsettings', 'get', 'com.canonical.Unity.Panel', 'systray-whitelist'], stdout=PIPE).communicate()[0]) +get_whitelist = lambda: eval( + Popen(['gsettings', 'get', 'com.canonical.Unity.Panel', + 'systray-whitelist'], stdout=PIPE).communicate()[0]) + +set_whitelist = lambda ls: Popen( + ['gsettings', 'set', + 'com.canonical.Unity.Panel', 'systray-whitelist', repr(ls)]) -set_whitelist = lambda ls: Popen(['gsettings', 'set', 'com.canonical.Unity.Panel', 'systray-whitelist', repr(ls)]) def add_to_whitelist(): ls = get_whitelist() @@ -27,21 +32,29 @@ def add_to_whitelist(): ls.append(APP_NAME) set_whitelist(ls) + def remove_from_whitelist(): ls = get_whitelist() if APP_NAME in ls: ls.remove(APP_NAME) set_whitelist(ls) + def is_unity_running(): - (output, error) = Popen('ps aux | grep [u]nity-panel-service', stdout=PIPE, shell=True).communicate() + #XXX use psutil instead + (output, error) = Popen( + 'ps aux | grep [u]nity-panel-service', + stdout=PIPE, shell=True).communicate() output = bool(str(output)) if not output: - (output, error) = Popen('ps aux | grep [u]nity-2d-panel', stdout=PIPE, shell=True).communicate() + (output, error) = Popen( + 'ps aux | grep [u]nity-2d-panel', + stdout=PIPE, shell=True).communicate() output = bool(str(output)) return output -def need_to_add(): + +def need_to_add(): if is_unity_running(): wlist = get_whitelist() if not (APP_NAME in wlist or 'all' in wlist): @@ -49,11 +62,17 @@ def need_to_add(): return True return False + def add_and_restart(): add_to_whitelist() Popen('LANG=en_US.UTF-8 unity', shell=True) -MSG = "Seems that you are using a Unity desktop and Leap is not allowed to use Tray icon. Press OK to add Leap to Unity's white list and then restart Unity" + +MSG = ("Seems that you are using a Unity desktop " + "and %s is not allowed to use Tray icon. " + "Press OK to add %s to Unity's white list " + "and then restart Unity" % (APP_NAME, APP_NAME)) + def do_check(): if platform.system() == "Linux" and need_to_add(): @@ -63,17 +82,17 @@ def do_check(): "add to systray?", add_and_restart) -if __name__=='__main__': - if len(sys.argv)>1: + +if __name__ == '__main__': + if len(sys.argv) > 1: cmd = sys.argv[1] - if cmd=='add': + if cmd == 'add': add_to_whitelist() - elif cmd=='rm': + elif cmd == 'rm': remove_from_whitelist() - elif cmd=='print': + elif cmd == 'print': print get_whitelist() - elif cmd=="check": + elif cmd == "check": from PyQt4.QtGui import QApplication app = QApplication(sys.argv) do_check() - -- cgit v1.2.3 From 99058b9f6536a3717ab82a9d77b09d5489334eb5 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 12 Sep 2012 10:32:22 +0900 Subject: add openvpn-verb option to cli. Closes #534. accepts int [1-6] that get passed to openvpn invocation. We should filter out the polling "state"/"status" commands from the log if we want it to be real useful. --- src/leap/baseapp/eip.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index afdb7adc..515ae58d 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -35,7 +35,8 @@ class EIPConductorAppMixin(object): watcher_cb=self.newLogLine.emit, config_file=config_file, status_signals=(self.statusChange.emit, ), - debug=self.debugmode) + debug=self.debugmode, + ovpn_verbosity=opts.openvpn_verb) # XXX remove skip download when sample service is ready self.conductor.run_checks(skip_download=True) -- cgit v1.2.3 From 3c26d5b5427e788aebfa174de3f0689bb1e146d2 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 13 Sep 2012 04:55:21 +0900 Subject: display about and aboutqt dialogs --- src/leap/baseapp/systray.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index c696ee74..762dac13 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -1,6 +1,7 @@ from PyQt4 import QtCore from PyQt4 import QtGui +from leap import __version__ as VERSION from leap.gui import mainwindow_rc @@ -82,6 +83,9 @@ class StatusAwareTrayIconMixin(object): self.trayIconMenu.addAction(self.maximizeAction) self.trayIconMenu.addAction(self.restoreAction) self.trayIconMenu.addSeparator() + self.trayIconMenu.addAction(self.aboutAct) + self.trayIconMenu.addAction(self.aboutQtAct) + self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.quitAction) self.trayIcon = QtGui.QSystemTrayIcon(self) @@ -104,9 +108,19 @@ class StatusAwareTrayIconMixin(object): triggered=self.showMaximized) self.restoreAction = QtGui.QAction("&Restore", self, triggered=self.showNormal) + self.aboutAct = QtGui.QAction("&About", self, + triggered=self.about) + self.aboutQtAct = QtGui.QAction("About Q&t", self, + triggered=QtGui.qApp.aboutQt) self.quitAction = QtGui.QAction("&Quit", self, triggered=self.cleanupAndQuit) + def about(self): + # move to widget + QtGui.QMessageBox.about(self, "About", + "Running LEAP client
" + "version %s" % VERSION) + def setConnWidget(self, icon_name): oldlayout = self.statusIconBox.layout() -- cgit v1.2.3 From ffa95a22b2073f75d51af32232e150bf36395f31 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 13 Sep 2012 04:55:55 +0900 Subject: remove debug logging --- src/leap/baseapp/unitychecks.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/unitychecks.py b/src/leap/baseapp/unitychecks.py index 72c9ee6f..2d06f629 100644 --- a/src/leap/baseapp/unitychecks.py +++ b/src/leap/baseapp/unitychecks.py @@ -10,9 +10,7 @@ import platform import sys from subprocess import Popen, PIPE -logging.basicConfig() logger = logging.getLogger(__name__) -logger.setLevel('DEBUG') from leap.base.constants import APP_NAME from leap.baseapp.dialogs import ErrorDialog -- cgit v1.2.3 From 71cedd4e4a882765862496d77c7f04173ab4712a Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 13 Sep 2012 16:38:22 +0900 Subject: fix race condition on app init still fragile; sometimes the qt app inits faster and make the send command miss the not yet created managemente socket. --- src/leap/baseapp/eip.py | 9 +++++++-- src/leap/baseapp/leap_app.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 515ae58d..68bd2f24 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -151,13 +151,18 @@ class EIPConductorAppMixin(object): # from openvpn manager) if not self.eip_service_started: + # there is a race condition + # going on here. Depending on how long we take + # to init the qt app, the management socket + # is not ready yet. return if self.conductor.with_errors: #XXX how to wait on pkexec??? #something better that this workaround, plz!! - time.sleep(5) - logger.debug('timeout') + #I removed the pkexec pass authentication at all. + #time.sleep(5) + #logger.debug('timeout') logger.error('errors. disconnect') self.start_or_stopVPN() # is stop diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index f91b2329..f861f945 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -45,7 +45,7 @@ class MainWindowMixin(object): self.headerLabelSub = QtGui.QLabel("trust your \ technolust") - pixmap = QtGui.QPixmap(':/images/leapfrog.jpg') + pixmap = QtGui.QPixmap(':/images/leap-color-small.png') frog_lbl = QtGui.QLabel() frog_lbl.setPixmap(pixmap) -- cgit v1.2.3 From 1e9ae8c5cf64a347ee59b24ad426a8ed929127c1 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 14 Sep 2012 03:07:02 +0900 Subject: init icon --- src/leap/baseapp/leap_app.py | 2 +- src/leap/baseapp/systray.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index f861f945..18b5084b 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -85,5 +85,5 @@ technolust") # XXX send signal instead? logger.info('Shutting down') self.conductor.cleanup() - logger.info('Exiting') + logger.info('Exiting. Bye.') QtGui.qApp.quit() diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 762dac13..67448ba0 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -61,7 +61,7 @@ class StatusAwareTrayIconMixin(object): self.iconpath['connected'])), self.ConnectionWidgets = con_widgets - self.statusIconBox = QtGui.QGroupBox("Connection Status") + self.statusIconBox = QtGui.QGroupBox("EIP Connection Status") statusIconLayout = QtGui.QHBoxLayout() statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) statusIconLayout.addWidget(self.ConnectionWidgets['connecting']) -- cgit v1.2.3 From add7973b3d1633b2776cb90f237415c6cac65d99 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 14 Sep 2012 08:34:59 +0900 Subject: set app icon (shows on window, minimized icons and about dialog) --- src/leap/baseapp/leap_app.py | 24 ++++++++++------ src/leap/baseapp/systray.py | 68 +++++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 27 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 18b5084b..208c4e7c 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -7,6 +7,9 @@ from leap.gui import mainwindow_rc logger = logging.getLogger(name=__name__) +APP_LOGO = ':/images/leap-color-small.png' + + class MainWindowMixin(object): """ create the main window @@ -32,25 +35,30 @@ class MainWindowMixin(object): widget.setLayout(mainLayout) self.setWindowTitle("LEAP Client") + self.set_app_icon() self.resize(400, 300) self.set_statusbarMessage('ready') + def set_app_icon(self): + icon = QtGui.QIcon(APP_LOGO) + self.setWindowIcon(icon) + def createWindowHeader(self): """ description lines for main window """ self.headerBox = QtGui.QGroupBox() - self.headerLabel = QtGui.QLabel("Encryption \ -Internet Proxy") - self.headerLabelSub = QtGui.QLabel("trust your \ -technolust") + self.headerLabel = QtGui.QLabel( + "LEAP Encryption Access Project") + self.headerLabelSub = QtGui.QLabel( + "
your internet encryption toolkit") - pixmap = QtGui.QPixmap(':/images/leap-color-small.png') - frog_lbl = QtGui.QLabel() - frog_lbl.setPixmap(pixmap) + pixmap = QtGui.QPixmap(APP_LOGO) + leap_lbl = QtGui.QLabel() + leap_lbl.setPixmap(pixmap) headerLayout = QtGui.QHBoxLayout() - headerLayout.addWidget(frog_lbl) + headerLayout.addWidget(leap_lbl) headerLayout.addWidget(self.headerLabel) headerLayout.addWidget(self.headerLabelSub) headerLayout.addStretch() diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 67448ba0..dd872de0 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -1,9 +1,18 @@ +import logging + from PyQt4 import QtCore from PyQt4 import QtGui from leap import __version__ as VERSION from leap.gui import mainwindow_rc +logger = logging.getLogger(__name__) + + +class PseudoAction(QtGui.QAction): + def isSeparator(self): + return True + class StatusAwareTrayIconMixin(object): """ @@ -76,12 +85,15 @@ class StatusAwareTrayIconMixin(object): """ self.trayIconMenu = QtGui.QMenu(self) - self.trayIconMenu.addAction(self.connectVPNAction) - self.trayIconMenu.addAction(self.dis_connectAction) + self.trayIconMenu.addAction(self.statusAct) + self.trayIconMenu.addAction(self.connAct) + #self.trayIconMenu.addAction(self.dis_connectAction) + #self.trayIconMenu.addSeparator() + #self.trayIconMenu.addAction(self.minimizeAction) + #self.trayIconMenu.addAction(self.maximizeAction) + #self.trayIconMenu.addAction(self.restoreAction) self.trayIconMenu.addSeparator() - self.trayIconMenu.addAction(self.minimizeAction) - self.trayIconMenu.addAction(self.maximizeAction) - self.trayIconMenu.addAction(self.restoreAction) + self.trayIconMenu.addAction(self.detailsAct) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.aboutAct) self.trayIconMenu.addAction(self.aboutQtAct) @@ -92,22 +104,32 @@ class StatusAwareTrayIconMixin(object): self.setIcon('disconnected') self.trayIcon.setContextMenu(self.trayIconMenu) + def bad(self): + logger.error('this should not be called') + def createActions(self): """ creates actions to be binded to tray icon """ - self.connectVPNAction = QtGui.QAction("Connect to &VPN", self, - triggered=self.hide) # XXX change action name on (dis)connect - self.dis_connectAction = QtGui.QAction( - "&(Dis)connect", self, - triggered=lambda: self.start_or_stopVPN()) - self.minimizeAction = QtGui.QAction("Mi&nimize", self, - triggered=self.hide) - self.maximizeAction = QtGui.QAction("Ma&ximize", self, - triggered=self.showMaximized) - self.restoreAction = QtGui.QAction("&Restore", self, - triggered=self.showNormal) + statusAct = PseudoAction( + "Encryption OFF", self) # , + statusAct.setSeparator(True) + self.statusAct = statusAct + self.statusAct.isSeparator = lambda: True + #triggered=self.bad) + self.connAct = QtGui.QAction(" turn &on", self, + triggered=lambda: self.start_or_stopVPN()) + + self.detailsAct = QtGui.QAction("&Details...", + self, + triggered=self.detailsWin) + #self.minimizeAction = QtGui.QAction("Mi&nimize", self, + #triggered=self.hide) + #self.maximizeAction = QtGui.QAction("Ma&ximize", self, + #triggered=self.showMaximized) + #self.restoreAction = QtGui.QAction("&Restore", self, + #triggered=self.showNormal) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About Q&t", self, @@ -115,11 +137,19 @@ class StatusAwareTrayIconMixin(object): self.quitAction = QtGui.QAction("&Quit", self, triggered=self.cleanupAndQuit) + def detailsWin(self): + logger.debug('details win toggle') + # XXX toggle main window visibility + # if visible: self.hide + # if hidden: self.show + def about(self): # move to widget QtGui.QMessageBox.about(self, "About", - "Running LEAP client
" - "version %s" % VERSION) + "LEAP client
" + "(version %s)
" + "" + "https://leap.se" % VERSION) def setConnWidget(self, icon_name): oldlayout = self.statusIconBox.layout() @@ -132,7 +162,7 @@ class StatusAwareTrayIconMixin(object): def setIcon(self, name): icon = self.Icons.get(name)(self) self.trayIcon.setIcon(icon) - self.setWindowIcon(icon) + #self.setWindowIcon(icon) def getIcon(self, icon_name): return self.states.get(icon_name, None) -- cgit v1.2.3 From 0d35f2a82bf15504ace2135af3e0c66ae1c16874 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 18 Sep 2012 11:11:43 +0900 Subject: do_branding command added to setup --- src/leap/baseapp/eip.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 515ae58d..ff6a79ac 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -1,5 +1,7 @@ +from __future__ import print_function import logging import time +import sys from PyQt4 import QtCore @@ -38,8 +40,9 @@ class EIPConductorAppMixin(object): debug=self.debugmode, ovpn_verbosity=opts.openvpn_verb) - # XXX remove skip download when sample service is ready - self.conductor.run_checks(skip_download=True) + # XXX get skip_download from cli flag + skip_download = False + self.conductor.run_checks(skip_download=skip_download) self.error_check() # XXX should receive "ready" signal @@ -58,13 +61,11 @@ class EIPConductorAppMixin(object): """ logger.debug('error check') - ##################################### - # XXX refactor in progress (by #504) - errq = self.conductor.error_queue while errq.qsize() != 0: logger.debug('%s errors left in conductor queue', errq.qsize()) - error = errq.get() + # we get exception and original traceback from queue + error, tb = errq.get() # redundant log, debugging the loop. logger.error('%s: %s', error.__class__.__name__, error.message) @@ -73,10 +74,8 @@ class EIPConductorAppMixin(object): self.handle_eip_error(error) else: - # This is not quite working. FIXME - import traceback - traceback.print_exc() - raise error + # deprecated form of raising exception. + raise error, None, tb if error.failfirst is True: break -- cgit v1.2.3 From 89735a5fd3c81e8aba3cb7b1d4836c1bf1e8c098 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 18 Sep 2012 22:55:45 +0900 Subject: cert verification and malformed json checks --- src/leap/baseapp/eip.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index ff6a79ac..8ebd84ae 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -131,6 +131,8 @@ class EIPConductorAppMixin(object): ErrorDialog(errtype="critical", msg=message, label="critical error") + elif error.warning: + logger.warning(error.message) else: dialog = ErrorDialog() -- cgit v1.2.3 From c4509cf794a79fc7922d47765154148de8eacf46 Mon Sep 17 00:00:00 2001 From: antialias Date: Tue, 18 Sep 2012 18:07:46 -0400 Subject: removed checks and changes involving systray-whitelist and unity because it works without them on Ubuntu 11.10 & 12.04. --- src/leap/baseapp/unitychecks.py | 96 ----------------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 src/leap/baseapp/unitychecks.py (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/unitychecks.py b/src/leap/baseapp/unitychecks.py deleted file mode 100644 index 2d06f629..00000000 --- a/src/leap/baseapp/unitychecks.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/python2 -# vim: tabstop=8 expandtab shiftwidth=5 softtabstop=4 -""" -modified from code from the starcal2 project -copyright Saeed Rasooli -License: GPL -""" -import logging -import platform -import sys -from subprocess import Popen, PIPE - -logger = logging.getLogger(__name__) - -from leap.base.constants import APP_NAME -from leap.baseapp.dialogs import ErrorDialog - -get_whitelist = lambda: eval( - Popen(['gsettings', 'get', 'com.canonical.Unity.Panel', - 'systray-whitelist'], stdout=PIPE).communicate()[0]) - -set_whitelist = lambda ls: Popen( - ['gsettings', 'set', - 'com.canonical.Unity.Panel', 'systray-whitelist', repr(ls)]) - - -def add_to_whitelist(): - ls = get_whitelist() - if not APP_NAME in ls: - ls.append(APP_NAME) - set_whitelist(ls) - - -def remove_from_whitelist(): - ls = get_whitelist() - if APP_NAME in ls: - ls.remove(APP_NAME) - set_whitelist(ls) - - -def is_unity_running(): - #XXX use psutil instead - (output, error) = Popen( - 'ps aux | grep [u]nity-panel-service', - stdout=PIPE, shell=True).communicate() - output = bool(str(output)) - if not output: - (output, error) = Popen( - 'ps aux | grep [u]nity-2d-panel', - stdout=PIPE, shell=True).communicate() - output = bool(str(output)) - return output - - -def need_to_add(): - if is_unity_running(): - wlist = get_whitelist() - if not (APP_NAME in wlist or 'all' in wlist): - logger.debug('need to add') - return True - return False - - -def add_and_restart(): - add_to_whitelist() - Popen('LANG=en_US.UTF-8 unity', shell=True) - - -MSG = ("Seems that you are using a Unity desktop " - "and %s is not allowed to use Tray icon. " - "Press OK to add %s to Unity's white list " - "and then restart Unity" % (APP_NAME, APP_NAME)) - - -def do_check(): - if platform.system() == "Linux" and need_to_add(): - dialog = ErrorDialog() - dialog.confirmMessage( - MSG, - "add to systray?", - add_and_restart) - - -if __name__ == '__main__': - if len(sys.argv) > 1: - cmd = sys.argv[1] - if cmd == 'add': - add_to_whitelist() - elif cmd == 'rm': - remove_from_whitelist() - elif cmd == 'print': - print get_whitelist() - elif cmd == "check": - from PyQt4.QtGui import QApplication - app = QApplication(sys.argv) - do_check() -- cgit v1.2.3 From cbd474e49e12e5fc0677dafe331b9c5ab3a2539a Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 20 Sep 2012 03:57:05 +0900 Subject: start hidden, and toggle details window from menu --- src/leap/baseapp/eip.py | 2 +- src/leap/baseapp/systray.py | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 6c147cb4..6d6b79cb 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -152,7 +152,7 @@ class EIPConductorAppMixin(object): # from openvpn manager) if not self.eip_service_started: - # there is a race condition + # there is a race condition # going on here. Depending on how long we take # to init the qt app, the management socket # is not ready yet. diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index dd872de0..f98bfa76 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -3,6 +3,7 @@ import logging from PyQt4 import QtCore from PyQt4 import QtGui +from leap import __branding as BRANDING from leap import __version__ as VERSION from leap.gui import mainwindow_rc @@ -138,18 +139,23 @@ class StatusAwareTrayIconMixin(object): triggered=self.cleanupAndQuit) def detailsWin(self): - logger.debug('details win toggle') - # XXX toggle main window visibility - # if visible: self.hide - # if hidden: self.show + visible = self.isVisible() + if visible: + self.hide() + else: + self.show() def about(self): # move to widget - QtGui.QMessageBox.about(self, "About", - "LEAP client
" - "(version %s)
" - "" - "https://leap.se" % VERSION) + flavor = BRANDING.get('short_name', None) + content = ("LEAP client
" + "(version %s)
" % VERSION) + if flavor: + content = content + ('
Flavor: %s
' % flavor) + content = content + ( + "
" + "https://leap.se") + QtGui.QMessageBox.about(self, "About", content) def setConnWidget(self, icon_name): oldlayout = self.statusIconBox.layout() -- cgit v1.2.3 From f2749fa3ff1df5875d3bc0b932a408031fee9874 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 20 Sep 2012 04:39:50 +0900 Subject: toggle connection on/off --- src/leap/baseapp/eip.py | 3 ++- src/leap/baseapp/systray.py | 26 +++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 6d6b79cb..98ff7142 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -216,12 +216,12 @@ class EIPConductorAppMixin(object): if self.debugmode: self.startStopButton.setText('&Disconnect') self.eip_service_started = True + self.toggleEIPAct() # XXX decouple! (timer is init by icons class). # we could bring Timer Init to this Mixin # or to its own Mixin. self.timer.start(constants.TIMER_MILLISECONDS) - return if self.eip_service_started is True: @@ -229,5 +229,6 @@ class EIPConductorAppMixin(object): if self.debugmode: self.startStopButton.setText('&Connect') self.eip_service_started = False + self.toggleEIPAct() self.timer.stop() return diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index f98bfa76..39a23f49 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -5,16 +5,12 @@ from PyQt4 import QtGui from leap import __branding as BRANDING from leap import __version__ as VERSION + from leap.gui import mainwindow_rc logger = logging.getLogger(__name__) -class PseudoAction(QtGui.QAction): - def isSeparator(self): - return True - - class StatusAwareTrayIconMixin(object): """ a mix of several functions needed @@ -86,10 +82,7 @@ class StatusAwareTrayIconMixin(object): """ self.trayIconMenu = QtGui.QMenu(self) - self.trayIconMenu.addAction(self.statusAct) self.trayIconMenu.addAction(self.connAct) - #self.trayIconMenu.addAction(self.dis_connectAction) - #self.trayIconMenu.addSeparator() #self.trayIconMenu.addAction(self.minimizeAction) #self.trayIconMenu.addAction(self.maximizeAction) #self.trayIconMenu.addAction(self.restoreAction) @@ -113,13 +106,7 @@ class StatusAwareTrayIconMixin(object): creates actions to be binded to tray icon """ # XXX change action name on (dis)connect - statusAct = PseudoAction( - "Encryption OFF", self) # , - statusAct.setSeparator(True) - self.statusAct = statusAct - self.statusAct.isSeparator = lambda: True - #triggered=self.bad) - self.connAct = QtGui.QAction(" turn &on", self, + self.connAct = QtGui.QAction("Encryption ON turn &off", self, triggered=lambda: self.start_or_stopVPN()) self.detailsAct = QtGui.QAction("&Details...", @@ -138,6 +125,15 @@ class StatusAwareTrayIconMixin(object): self.quitAction = QtGui.QAction("&Quit", self, triggered=self.cleanupAndQuit) + def toggleEIPAct(self): + # 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: + self.connAct.setText('Encryption ON turn o&ff') + else: + self.connAct.setText('Encryption OFF turn &on') + def detailsWin(self): visible = self.isVisible() if visible: -- cgit v1.2.3 From d1ebe98239fbc2baffa345558d396fa539e79202 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 21 Sep 2012 06:32:40 +0900 Subject: added --no-provider-checks and --no-ca-verify for ease of debugging Close #604 --- src/leap/baseapp/eip.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 98ff7142..b0e14be7 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -1,7 +1,7 @@ from __future__ import print_function import logging import time -import sys +#import sys from PyQt4 import QtCore @@ -40,9 +40,11 @@ class EIPConductorAppMixin(object): debug=self.debugmode, ovpn_verbosity=opts.openvpn_verb) - # XXX get skip_download from cli flag - skip_download = False - self.conductor.run_checks(skip_download=skip_download) + skip_download = opts.no_provider_checks + skip_verify = opts.no_ca_verify + self.conductor.run_checks( + skip_download=skip_download, + skip_verify=skip_verify) self.error_check() # XXX should receive "ready" signal -- cgit v1.2.3 From 3fd7b55de96484e02accb991fb2c0c3ce0aa9883 Mon Sep 17 00:00:00 2001 From: antialias Date: Tue, 25 Sep 2012 17:37:48 -0400 Subject: First check for threaded network checks. TODO: tests. --- src/leap/baseapp/mainwindow.py | 3 +++ src/leap/baseapp/network.py | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/leap/baseapp/network.py (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 10b23d9a..7b2ecb1d 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -8,6 +8,7 @@ from PyQt4 import QtGui from leap.baseapp.eip import EIPConductorAppMixin 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 logger = logging.getLogger(name=__name__) @@ -16,6 +17,7 @@ logger = logging.getLogger(name=__name__) class LeapWindow(QtGui.QMainWindow, MainWindowMixin, EIPConductorAppMixin, StatusAwareTrayIconMixin, + NetworkCheckerAppMixin, LogPaneMixin): """ main window for the leap app. @@ -36,6 +38,7 @@ class LeapWindow(QtGui.QMainWindow, self.createLogBrowser() EIPConductorAppMixin.__init__(self, opts=opts) StatusAwareTrayIconMixin.__init__(self) + NetworkCheckerAppMixin.__init__(self) MainWindowMixin.__init__(self) # bind signals diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py new file mode 100644 index 00000000..42a42fcd --- /dev/null +++ b/src/leap/baseapp/network.py @@ -0,0 +1,56 @@ +from __future__ import print_function +import logging +import time +logger = logging.getLogger(name=__name__) + +from leap.base.network import NetworkChecker +from leap.baseapp.dialogs import ErrorDialog + + +class NetworkCheckerAppMixin(object): + """ + initialize an instance of the Network Checker, + which gathers error and passes them on. + """ + + def __init__(self, *args, **kwargs): + opts = kwargs.pop('opts', None) + config_file = getattr(opts, 'config_file', None) + + self.network_checker_started = False + + self.network_checker = NetworkChecker( + watcher_cb=self.newLogLine.emit, + status_signals=(self.statusChange.emit, ), + debug=self.debugmode) + + self.network_checker.run_checks() + self.error_check() + + def error_check(self): + """ + consumes the conductor error queue. + pops errors, and acts accordingly (launching user dialogs). + """ + logger.debug('error check') + + errq = self.conductor.error_queue + while errq.qsize() != 0: + logger.debug('%s errors left in conductor queue', errq.qsize()) + # we get exception and original traceback from queue + error, tb = errq.get() + + # redundant log, debugging the loop. + logger.error('%s: %s', error.__class__.__name__, error.message) + + if issubclass(error.__class__, eip_exceptions.EIPClientError): + self.handle_eip_error(error) + + else: + # deprecated form of raising exception. + raise error, None, tb + + if error.failfirst is True: + break + + -- cgit v1.2.3 From 58344bb28c1c0f25ed37624ff487cc8f24821d52 Mon Sep 17 00:00:00 2001 From: antialias Date: Fri, 28 Sep 2012 18:16:47 -0400 Subject: Functionality to shutdown network checker when openvpn is stopped. But thread not being successfully killed. --- src/leap/baseapp/eip.py | 2 ++ src/leap/baseapp/network.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index b0e14be7..ad074abc 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -224,9 +224,11 @@ class EIPConductorAppMixin(object): # we could bring Timer Init to this Mixin # or to its own Mixin. self.timer.start(constants.TIMER_MILLISECONDS) + self.network_checker.start() return if self.eip_service_started is True: + self.network_checker.stop() self.conductor.disconnect() if self.debugmode: self.startStopButton.setText('&Connect') diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index 42a42fcd..75690cc9 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -36,7 +36,7 @@ class NetworkCheckerAppMixin(object): errq = self.conductor.error_queue while errq.qsize() != 0: - logger.debug('%s errors left in conductor queue', errq.qsize()) + logger.debug('%s errors left in network queue', errq.qsize()) # we get exception and original traceback from queue error, tb = errq.get() @@ -44,7 +44,7 @@ class NetworkCheckerAppMixin(object): logger.error('%s: %s', error.__class__.__name__, error.message) if issubclass(error.__class__, eip_exceptions.EIPClientError): - self.handle_eip_error(error) + self.handle_network_error(error) else: # deprecated form of raising exception. @@ -53,4 +53,5 @@ class NetworkCheckerAppMixin(object): if error.failfirst is True: break - + def handle_network_error(self, error): + pass -- cgit v1.2.3 From 95ce59c8833cb2ba951630080cdbc1e6d756a666 Mon Sep 17 00:00:00 2001 From: antialias Date: Mon, 1 Oct 2012 15:10:55 -0400 Subject: Still some QT related problems. Hand off to kali to fix. --- src/leap/baseapp/mainwindow.py | 14 ++++++++++++++ src/leap/baseapp/network.py | 36 +----------------------------------- 2 files changed, 15 insertions(+), 35 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 7b2ecb1d..000db8c9 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -28,6 +28,7 @@ class LeapWindow(QtGui.QMainWindow, newLogLine = QtCore.pyqtSignal([str]) statusChange = QtCore.pyqtSignal([object]) + networkError = QtCore.pyqtSignal([object]) def __init__(self, opts): logger.debug('init leap window') @@ -57,3 +58,16 @@ class LeapWindow(QtGui.QMainWindow, # eipapp should catch that 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 + + # XXX + # check headless = False before + # launching dialog. + # (so Qt tests can assert stuff) + + dialog = ErrorDialog() + dialog.warningMessage(message, 'error') diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index 75690cc9..c73e8062 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -14,44 +14,10 @@ class NetworkCheckerAppMixin(object): """ def __init__(self, *args, **kwargs): - opts = kwargs.pop('opts', None) - config_file = getattr(opts, 'config_file', None) - - self.network_checker_started = False - self.network_checker = NetworkChecker( watcher_cb=self.newLogLine.emit, - status_signals=(self.statusChange.emit, ), + error_cb=self.handle_network_error, debug=self.debugmode) self.network_checker.run_checks() - self.error_check() - - def error_check(self): - """ - consumes the conductor error queue. - pops errors, and acts accordingly (launching user dialogs). - """ - logger.debug('error check') - - errq = self.conductor.error_queue - while errq.qsize() != 0: - logger.debug('%s errors left in network queue', errq.qsize()) - # we get exception and original traceback from queue - error, tb = errq.get() - - # redundant log, debugging the loop. - logger.error('%s: %s', error.__class__.__name__, error.message) - - if issubclass(error.__class__, eip_exceptions.EIPClientError): - self.handle_network_error(error) - - else: - # deprecated form of raising exception. - raise error, None, tb - - if error.failfirst is True: - break - def handle_network_error(self, error): - pass -- cgit v1.2.3 From bbbeef10fd581fa29090b95b8f46f4641f7e5f41 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 2 Oct 2012 05:33:28 +0900 Subject: remove ui header --- src/leap/baseapp/leap_app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 208c4e7c..fffff0bb 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -23,11 +23,11 @@ class MainWindowMixin(object): widget = QtGui.QWidget() self.setCentralWidget(widget) - self.createWindowHeader() + #self.createWindowHeader() # add widgets to layout mainLayout = QtGui.QVBoxLayout() - mainLayout.addWidget(self.headerBox) + #mainLayout.addWidget(self.headerBox) mainLayout.addWidget(self.statusIconBox) if self.debugmode: mainLayout.addWidget(self.statusBox) -- cgit v1.2.3 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/baseapp/eip.py | 24 +++++++++++++++--------- src/leap/baseapp/leap_app.py | 4 ++-- src/leap/baseapp/mainwindow.py | 23 ++++++++++++++++++----- src/leap/baseapp/systray.py | 1 + 4 files changed, 36 insertions(+), 16 deletions(-) (limited to 'src/leap/baseapp') 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 From 51dee24be94567334dfb8765cbd3bb23dcae9ee3 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 04:10:50 +0900 Subject: init QSettings - save window geometry --- src/leap/baseapp/leap_app.py | 10 +++++++++- src/leap/baseapp/mainwindow.py | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 98ca292e..49f7ceda 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 @@ -35,7 +39,7 @@ class MainWindowMixin(object): self.setWindowTitle("LEAP Client") self.set_app_icon() - self.resize(400, 300) + #self.resize(400, 300) self.set_statusbarMessage('ready') logger.debug('set ready.........') @@ -88,6 +92,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 55be55f7..d3656cd4 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -30,14 +30,19 @@ class LeapWindow(QtGui.QMainWindow, 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) MainWindowMixin.__init__(self) + settings = QtCore.QSettings() + geom = settings.value("Geometry") + if geom: + self.restoreGeometry(geom) + self.initchecks = InitChecksThread(self.run_eip_checks) # bind signals -- cgit v1.2.3 From a92ea6fcc5e2e10c6df6d41b52a5d98044317eba Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 05:32:15 +0900 Subject: wizard called from main app if not run before. --- src/leap/baseapp/mainwindow.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index d3656cd4..63242fd2 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -26,6 +26,7 @@ class LeapWindow(QtGui.QMainWindow, newLogLine = QtCore.pyqtSignal([str]) statusChange = QtCore.pyqtSignal([object]) + initReady = QtCore.pyqtSignal([]) def __init__(self, opts): logger.debug('init leap window') @@ -42,6 +43,7 @@ class LeapWindow(QtGui.QMainWindow, geom = settings.value("Geometry") if geom: self.restoreGeometry(geom) + self.wizard_done = settings.value("FirstRunWizardDone") self.initchecks = InitChecksThread(self.run_eip_checks) @@ -55,9 +57,20 @@ class LeapWindow(QtGui.QMainWindow, lambda status: self.onStatusChange(status)) self.timer.timeout.connect( lambda: self.onTimerTick()) + self.initReady.connect(self.runchecks_and_eipconnect) # ... all ready. go! - + if self.wizard_done: + self.initReady.emit() + else: + # need to run 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() -- cgit v1.2.3 From b9d1b57976984d1032b3abc810f462a80fdc55aa Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 07:00:42 +0900 Subject: focus fix for wizard --- src/leap/baseapp/mainwindow.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 63242fd2..1accac30 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -26,6 +26,7 @@ class LeapWindow(QtGui.QMainWindow, newLogLine = QtCore.pyqtSignal([str]) statusChange = QtCore.pyqtSignal([object]) + mainappReady = QtCore.pyqtSignal([]) initReady = QtCore.pyqtSignal([]) def __init__(self, opts): @@ -57,13 +58,22 @@ class LeapWindow(QtGui.QMainWindow, lambda status: self.onStatusChange(status)) self.timer.timeout.connect( lambda: self.onTimerTick()) + + # 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, -- cgit v1.2.3 From 3e2eb0cb1878a9494650ea1278ef2f9211ebdaac Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 10:10:04 +0900 Subject: add menu for running wizard at will it's still buggy in that it does not bother to stop the ongoing checks or connection. we should take care of that soon. --- src/leap/baseapp/leap_app.py | 46 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 49f7ceda..460d1269 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -27,9 +27,9 @@ class MainWindowMixin(object): widget = QtGui.QWidget() self.setCentralWidget(widget) + mainLayout = QtGui.QVBoxLayout() # add widgets to layout #self.createWindowHeader() - mainLayout = QtGui.QVBoxLayout() #mainLayout.addWidget(self.headerBox) mainLayout.addWidget(self.statusIconBox) if self.debugmode: @@ -37,11 +37,51 @@ class MainWindowMixin(object): 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') - logger.debug('set 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) -- cgit v1.2.3 From 31c0afa5eb9bc7566ca39099520e8adc7b531e22 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 20:15:12 +0900 Subject: pep8 --- src/leap/baseapp/mainwindow.py | 5 +++-- src/leap/baseapp/network.py | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 000db8c9..e48666a4 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -10,6 +10,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.baseapp import dialogs logger = logging.getLogger(name=__name__) @@ -68,6 +69,6 @@ class LeapWindow(QtGui.QMainWindow, # check headless = False before # launching dialog. # (so Qt tests can assert stuff) - - dialog = ErrorDialog() + + dialog = dialogs.ErrorDialog() dialog.warningMessage(message, 'error') diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index c73e8062..f1859c7a 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -1,10 +1,10 @@ from __future__ import print_function + import logging -import time logger = logging.getLogger(name=__name__) from leap.base.network import NetworkChecker -from leap.baseapp.dialogs import ErrorDialog +#from leap.baseapp.dialogs import ErrorDialog class NetworkCheckerAppMixin(object): @@ -20,4 +20,3 @@ class NetworkCheckerAppMixin(object): debug=self.debugmode) self.network_checker.run_checks() - -- cgit v1.2.3 From 1cbf954d9eda71cabfa58811c09bc63cfe9465d5 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 21:21:22 +0900 Subject: add comments to netchecks --- src/leap/baseapp/network.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index f1859c7a..fbf9376f 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -3,7 +3,7 @@ from __future__ import print_function import logging logger = logging.getLogger(name=__name__) -from leap.base.network import NetworkChecker +from leap.base.network import NetworkCheckerThread #from leap.baseapp.dialogs import ErrorDialog @@ -14,9 +14,12 @@ class NetworkCheckerAppMixin(object): """ def __init__(self, *args, **kwargs): - self.network_checker = NetworkChecker( + self.network_checker = NetworkCheckerThread( + # XXX watcher? remove ----- watcher_cb=self.newLogLine.emit, - error_cb=self.handle_network_error, + # XXX what callback? ------ + error_cb=None, debug=self.debugmode) + # XXX move run_checks to slot self.network_checker.run_checks() -- cgit v1.2.3 From 6cd947041b3352bebddf3863a86b0a15f8222bcf Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 5 Oct 2012 21:22:36 +0900 Subject: fix seticon call breakage when interface dies --- src/leap/baseapp/systray.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 39a23f49..adcfe9b9 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -162,9 +162,10 @@ class StatusAwareTrayIconMixin(object): oldlayout.itemAt(new).widget().show() def setIcon(self, name): - icon = self.Icons.get(name)(self) - self.trayIcon.setIcon(icon) - #self.setWindowIcon(icon) + icon_fun = self.Icons.get(name) + if icon_fun and callable(icon_fun): + icon = icon_fun(self) + self.trayIcon.setIcon(icon) def getIcon(self, icon_name): return self.states.get(icon_name, None) -- cgit v1.2.3 From 6728eb9afb21bad867e4052a6190a9bdb34c928a Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 8 Oct 2012 07:50:24 +0900 Subject: popup dialog error when network error happens we are shutting down for now. we should be acting upon failures in the near future. lowered the recurrent checks interval to 10 seconds. --- src/leap/baseapp/mainwindow.py | 2 ++ src/leap/baseapp/network.py | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index e48666a4..fdbaf693 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -52,6 +52,8 @@ class LeapWindow(QtGui.QMainWindow, lambda status: self.onStatusChange(status)) self.timer.timeout.connect( lambda: self.onTimerTick()) + self.networkError.connect( + lambda exc: self.onNetworkError(exc)) # ... all ready. go! diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index fbf9376f..077d5164 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -1,10 +1,13 @@ from __future__ import print_function import logging + logger = logging.getLogger(name=__name__) +from PyQt4 import QtCore + +from leap.baseapp.dialogs import ErrorDialog from leap.base.network import NetworkCheckerThread -#from leap.baseapp.dialogs import ErrorDialog class NetworkCheckerAppMixin(object): @@ -15,11 +18,23 @@ class NetworkCheckerAppMixin(object): def __init__(self, *args, **kwargs): self.network_checker = NetworkCheckerThread( - # XXX watcher? remove ----- - watcher_cb=self.newLogLine.emit, - # XXX what callback? ------ - error_cb=None, + error_cb=self.networkError.emit, debug=self.debugmode) # XXX move run_checks to slot self.network_checker.run_checks() + + @QtCore.pyqtSlot(object) + def onNetworkError(self, exc): + """ + slot that receives a network exceptions + and raises a user error message + """ + logger.debug('handling network exception') + logger.error(exc.message) + dialog = ErrorDialog(parent=self) + + if exc.critical: + dialog.criticalMessage(exc.usermessage, "network error") + else: + dialog.warningMessage(exc.usermessage, "network error") -- cgit v1.2.3 From 479710e977327774b9ba9e1839f75b4a38b51e5f Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 8 Oct 2012 09:32:34 +0900 Subject: add leap-status to main window in non-debug mode not very DRY but just to have it ready for rc cut. --- src/leap/baseapp/eip.py | 1 + src/leap/baseapp/leap_app.py | 42 ++++++++++++++++++++++-------------------- src/leap/baseapp/mainwindow.py | 37 +++++++++++++------------------------ src/leap/baseapp/systray.py | 41 +++++++++++++++++++++++++++++------------ 4 files changed, 65 insertions(+), 56 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index e291de34..311470f2 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -36,6 +36,7 @@ class EIPConductorAppMixin(object): self.conductor = EIPConnection( watcher_cb=self.newLogLine.emit, config_file=config_file, + checker_signals=(self.changeLeapStatus.emit, ), status_signals=(self.statusChange.emit, ), debug=self.debugmode, ovpn_verbosity=opts.openvpn_verb) diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 460d1269..f9eb3bb1 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -31,6 +31,8 @@ class MainWindowMixin(object): # add widgets to layout #self.createWindowHeader() #mainLayout.addWidget(self.headerBox) + + # created in systray mainLayout.addWidget(self.statusIconBox) if self.debugmode: mainLayout.addWidget(self.statusBox) @@ -87,26 +89,26 @@ class MainWindowMixin(object): icon = QtGui.QIcon(APP_LOGO) self.setWindowIcon(icon) - def createWindowHeader(self): - """ - description lines for main window - """ - self.headerBox = QtGui.QGroupBox() - self.headerLabel = QtGui.QLabel( - "LEAP Encryption Access Project") - self.headerLabelSub = QtGui.QLabel( - "
your internet encryption toolkit") - - pixmap = QtGui.QPixmap(APP_LOGO) - leap_lbl = QtGui.QLabel() - leap_lbl.setPixmap(pixmap) - - headerLayout = QtGui.QHBoxLayout() - headerLayout.addWidget(leap_lbl) - headerLayout.addWidget(self.headerLabel) - headerLayout.addWidget(self.headerLabelSub) - headerLayout.addStretch() - self.headerBox.setLayout(headerLayout) + #def createWindowHeader(self): + #""" + #description lines for main window + #""" + #self.headerBox = QtGui.QGroupBox() + #self.headerLabel = QtGui.QLabel( + #"LEAP Encryption Access Project") + #self.headerLabelSub = QtGui.QLabel( + #"
your internet encryption toolkit") +# + #pixmap = QtGui.QPixmap(APP_LOGO) + #leap_lbl = QtGui.QLabel() + #leap_lbl.setPixmap(pixmap) +# + #headerLayout = QtGui.QHBoxLayout() + #headerLayout.addWidget(leap_lbl) + #headerLayout.addWidget(self.headerLabel) + #headerLayout.addWidget(self.headerLabelSub) + #headerLayout.addStretch() + #self.headerBox.setLayout(headerLayout) def set_statusbarMessage(self, msg): self.statusBar().showMessage(msg) diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 09e0c0bb..bf42f0e7 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -10,7 +10,6 @@ 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.baseapp import dialogs logger = logging.getLogger(name=__name__) @@ -28,11 +27,16 @@ class LeapWindow(QtGui.QMainWindow, """ newLogLine = QtCore.pyqtSignal([str]) - statusChange = QtCore.pyqtSignal([object]) mainappReady = QtCore.pyqtSignal([]) initReady = QtCore.pyqtSignal([]) networkError = QtCore.pyqtSignal([object]) + # XXX fix nomenclature here + # this is eip status change got from vpn management + statusChange = QtCore.pyqtSignal([object]) + # this is global leap status + changeLeapStatus = QtCore.pyqtSignal([str]) + def __init__(self, opts): logger.debug('init leap window') self.debugmode = getattr(opts, 'debug', False) @@ -59,13 +63,18 @@ class LeapWindow(QtGui.QMainWindow, self.trayIcon.activated.connect(self.iconActivated) self.newLogLine.connect( lambda line: self.onLoggerNewLine(line)) - self.statusChange.connect( - lambda status: self.onStatusChange(status)) self.timer.timeout.connect( lambda: self.onTimerTick()) self.networkError.connect( lambda exc: self.onNetworkError(exc)) + # status change. + # TODO unify + self.statusChange.connect( + lambda status: self.onStatusChange(status)) + self.changeLeapStatus.connect( + lambda newstatus: self.onChangeLeapConnStatus(newstatus)) + # do frwizard and init signals self.mainappReady.connect(self.do_first_run_wizard_check) self.initReady.connect(self.runchecks_and_eipconnect) @@ -100,25 +109,5 @@ class InitChecksThread(QtCore.QThread): 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() -# - #TODO: Put all Dialogs in one place - #@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') -#>>>>>>> feature/network_check diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 1939bc09..d5d44f61 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -41,7 +41,7 @@ class StatusAwareTrayIconMixin(object): self.createIconGroupBox() self.createActions() self.createTrayIcon() - logger.debug('showing tray icon................') + #logger.debug('showing tray icon................') self.trayIcon.show() # not sure if this really belongs here, but... @@ -75,6 +75,10 @@ class StatusAwareTrayIconMixin(object): statusIconLayout.addWidget(self.ConnectionWidgets['connected']) statusIconLayout.itemAt(1).widget().hide() statusIconLayout.itemAt(2).widget().hide() + + self.leapConnStatus = QtGui.QLabel("disconnected") + statusIconLayout.addWidget(self.leapConnStatus) + self.statusIconBox.setLayout(statusIconLayout) def createTrayIcon(self): @@ -84,9 +88,6 @@ class StatusAwareTrayIconMixin(object): self.trayIconMenu = QtGui.QMenu(self) self.trayIconMenu.addAction(self.connAct) - #self.trayIconMenu.addAction(self.minimizeAction) - #self.trayIconMenu.addAction(self.maximizeAction) - #self.trayIconMenu.addAction(self.restoreAction) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.detailsAct) self.trayIconMenu.addSeparator() @@ -113,12 +114,6 @@ class StatusAwareTrayIconMixin(object): self.detailsAct = QtGui.QAction("&Details...", self, triggered=self.detailsWin) - #self.minimizeAction = QtGui.QAction("Mi&nimize", self, - #triggered=self.hide) - #self.maximizeAction = QtGui.QAction("Ma&ximize", self, - #triggered=self.showMaximized) - #self.restoreAction = QtGui.QAction("&Restore", self, - #triggered=self.showNormal) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About Q&t", self, @@ -197,10 +192,32 @@ class StatusAwareTrayIconMixin(object): @QtCore.pyqtSlot(object) def onStatusChange(self, status): """ - slot for status changes. triggers new signals for - updating icon, status bar, etc. + updates icon """ icon_name = self.conductor.get_icon_name() + + # XXX refactor. Use QStateMachine + + if icon_name in ("disconnected", "connected"): + self.changeLeapStatus.emit(icon_name) + + if icon_name in ("connecting"): + # let's see how it matches + leap_status_name = self.conductor.get_leap_status() + self.changeLeapStatus.emit(leap_status_name) + self.setIcon(icon_name) # change connection pixmap widget self.setConnWidget(icon_name) + + @QtCore.pyqtSlot(str) + def onChangeLeapConnStatus(self, newstatus): + """ + slot for LEAP status changes + not to be confused with onStatusChange. + this only updates the non-debug LEAP Status line + next to the connection icon. + """ + # XXX move bold to style sheet + self.leapConnStatus.setText( + "%s" % newstatus) -- cgit v1.2.3 From f043f9087232a416bf9fa7dbb0b8f9b6f4e0a04e Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 10 Oct 2012 03:59:01 +0900 Subject: fix for left-click on systray Closes #310 --- src/leap/baseapp/systray.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index d5d44f61..cc5d89df 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -100,6 +100,10 @@ class StatusAwareTrayIconMixin(object): self.setIcon('disconnected') self.trayIcon.setContextMenu(self.trayIconMenu) + #self.trayIconMenu.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + #self.trayIconMenu.customContextMenuRequested.connect( + #self.on_context_menu) + def bad(self): logger.error('this should not be called') @@ -178,12 +182,14 @@ class StatusAwareTrayIconMixin(object): handles left click, left double click showing the trayicon menu """ - #XXX there's a bug here! - #menu shows on (0,0) corner first time, - #until double clicked at least once. if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick): - self.trayIconMenu.show() + context_menu = self.trayIcon.contextMenu() + # for some reason, context_menu.show() + # is failing in a way beyond my understanding. + # (not working the first time it's clicked). + # this works however. + context_menu.exec_(self.trayIcon.geometry().center()) @QtCore.pyqtSlot() def onTimerTick(self): -- cgit v1.2.3 From 48792fa7c25530776b871098fd07b600bfc976ba Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 10 Oct 2012 05:03:31 +0900 Subject: fix connect/disconnect button in debug mode Closes #730 --- src/leap/baseapp/eip.py | 4 ---- src/leap/baseapp/mainwindow.py | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 311470f2..22dc0dd7 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -55,10 +55,6 @@ class EIPConductorAppMixin(object): skip_verify=self.skip_verify) self.error_check() - 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() diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index bf42f0e7..2348c27d 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -50,6 +50,9 @@ class LeapWindow(QtGui.QMainWindow, MainWindowMixin.__init__(self) settings = QtCore.QSettings() + # XXX geom_key = "DebugGeometry" if self.debugmode else "Geometry" + #geom = settings.value(geom_key) + geom = settings.value("Geometry") if geom: self.restoreGeometry(geom) @@ -68,6 +71,10 @@ class LeapWindow(QtGui.QMainWindow, self.networkError.connect( lambda exc: self.onNetworkError(exc)) + if self.debugmode: + self.startStopButton.clicked.connect( + lambda: self.start_or_stopVPN()) + # status change. # TODO unify self.statusChange.connect( -- cgit v1.2.3 From cf7ddd017f20ca4a3020628999562e9b3b82bd0b Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 10 Oct 2012 05:13:29 +0900 Subject: fix geometry saving for debug/regular mode. Closes #732 --- src/leap/baseapp/leap_app.py | 3 ++- src/leap/baseapp/mainwindow.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index f9eb3bb1..6ffb08a8 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -136,7 +136,8 @@ class MainWindowMixin(object): """ # save geometry for restoring settings = QtCore.QSettings() - settings.setValue("Geometry", self.saveGeometry()) + geom_key = "DebugGeometry" if self.debugmode else "Geometry" + settings.setValue(geom_key, self.saveGeometry()) # TODO:make sure to shutdown all child process / threads # in conductor diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 2348c27d..bbb5203c 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -50,8 +50,9 @@ class LeapWindow(QtGui.QMainWindow, MainWindowMixin.__init__(self) settings = QtCore.QSettings() - # XXX geom_key = "DebugGeometry" if self.debugmode else "Geometry" - #geom = settings.value(geom_key) + + geom_key = "DebugGeometry" if self.debugmode else "Geometry" + geom = settings.value(geom_key) geom = settings.value("Geometry") if geom: -- cgit v1.2.3 From 5247c690b786f2b3e026fd3e17529f9fd6962d09 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 10 Oct 2012 05:32:54 +0900 Subject: use signals to pass eip errors across threads Closes #741 --- src/leap/baseapp/eip.py | 32 ++++---------------------------- src/leap/baseapp/mainwindow.py | 5 +++++ 2 files changed, 9 insertions(+), 28 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 22dc0dd7..b67e4444 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -76,7 +76,7 @@ class EIPConductorAppMixin(object): logger.error('%s: %s', error.__class__.__name__, error.message) if issubclass(error.__class__, eip_exceptions.EIPClientError): - self.handle_eip_error(error) + self.triggerEIPError.emit(error) else: # deprecated form of raising exception. @@ -85,32 +85,8 @@ class EIPConductorAppMixin(object): if error.failfirst is True: break - ############################################# - # old errors to check - # write test for them and them remove - # their corpses from here. - - #if self.conductor.missing_vpn_keyfile is True: - #dialog = ErrorDialog() - #dialog.criticalMessage( - #'Could not find the vpn keys file', - #'error') - - #if self.conductor.bad_keyfile_perms is True: - #dialog = ErrorDialog() - #dialog.criticalMessage( - #'The vpn keys file has bad permissions', - #'error') - - # deprecated. configchecker takes care of that. - #if self.conductor.missing_definition is True: - #dialog = ErrorDialog() - #dialog.criticalMessage( - #'The default ' - #'definition.json file cannot be found', - #'error') - - def handle_eip_error(self, error): + @QtCore.pyqtSlot(object) + def onEIPError(self, error): """ check severity and launches dialogs informing user about the errors. @@ -211,7 +187,7 @@ class EIPConductorAppMixin(object): self.conductor.connect() except eip_exceptions.EIPNoCommandError as exc: - self.handle_eip_error(exc) + self.triggerEIPError.emit(exc) except Exception as err: # raise generic exception (Bad Thing Happened?) diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index bbb5203c..87886767 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -26,10 +26,13 @@ class LeapWindow(QtGui.QMainWindow, that gets tricky otherwise. """ + # signals + newLogLine = QtCore.pyqtSignal([str]) mainappReady = QtCore.pyqtSignal([]) initReady = QtCore.pyqtSignal([]) networkError = QtCore.pyqtSignal([object]) + triggerEIPError = QtCore.pyqtSignal([object]) # XXX fix nomenclature here # this is eip status change got from vpn management @@ -71,6 +74,8 @@ class LeapWindow(QtGui.QMainWindow, lambda: self.onTimerTick()) self.networkError.connect( lambda exc: self.onNetworkError(exc)) + self.triggerEIPError.connect( + lambda exc: self.onEIPError(exc)) if self.debugmode: self.startStopButton.clicked.connect( -- cgit v1.2.3 From b70a6664f0603297bf8b20809b5a64677900b405 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 11 Oct 2012 08:23:22 +0900 Subject: add signal to end of eip checks this fixes random error on leap initialization --- src/leap/baseapp/eip.py | 4 +--- src/leap/baseapp/mainwindow.py | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index b67e4444..93dce3ac 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -55,9 +55,7 @@ class EIPConductorAppMixin(object): skip_verify=self.skip_verify) self.error_check() - # XXX should send ready signal instead - if self.conductor.autostart: - self.start_or_stopVPN() + self.start_eipconnection.emit() def error_check(self): """ diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 87886767..3b6cb544 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -33,6 +33,7 @@ class LeapWindow(QtGui.QMainWindow, initReady = QtCore.pyqtSignal([]) networkError = QtCore.pyqtSignal([object]) triggerEIPError = QtCore.pyqtSignal([object]) + start_eipconnection = QtCore.pyqtSignal([]) # XXX fix nomenclature here # this is eip status change got from vpn management @@ -80,6 +81,8 @@ class LeapWindow(QtGui.QMainWindow, if self.debugmode: self.startStopButton.clicked.connect( lambda: self.start_or_stopVPN()) + self.start_eipconnection.connect( + lambda: self.start_or_stopVPN()) # status change. # TODO unify -- cgit v1.2.3 From bc775969e2db31b892526b65a5037470a86b3882 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 19 Oct 2012 06:12:14 +0900 Subject: logic for cert validation widgets in wizard --- src/leap/baseapp/eip.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 93dce3ac..ca2e03c3 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -137,14 +137,14 @@ class EIPConductorAppMixin(object): # is not ready yet. return - if self.conductor.with_errors: + #if self.conductor.with_errors: #XXX how to wait on pkexec??? #something better that this workaround, plz!! #I removed the pkexec pass authentication at all. #time.sleep(5) #logger.debug('timeout') - logger.error('errors. disconnect') - self.start_or_stopVPN() # is stop + #logger.error('errors. disconnect') + #self.start_or_stopVPN() # is stop state = self.conductor.poll_connection_state() if not state: -- cgit v1.2.3 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/leap_app.py | 4 ++-- src/leap/baseapp/mainwindow.py | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 6ffb08a8..d1acb8ba 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -127,8 +127,8 @@ class MainWindowMixin(object): "context menu of the system tray entry.") self.hide() event.ignore() - if self.debugmode: - self.cleanupAndQuit() + return + self.cleanupAndQuit() def cleanupAndQuit(self): """ 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/eip.py | 4 +++- src/leap/baseapp/mainwindow.py | 52 +++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 14 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index ca2e03c3..26a2a1fb 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -25,6 +25,7 @@ class EIPConductorAppMixin(object): def __init__(self, *args, **kwargs): opts = kwargs.pop('opts') config_file = getattr(opts, 'config_file', None) + provider = kwargs.pop('provider') self.eip_service_started = False @@ -39,7 +40,8 @@ class EIPConductorAppMixin(object): checker_signals=(self.changeLeapStatus.emit, ), status_signals=(self.statusChange.emit, ), debug=self.debugmode, - ovpn_verbosity=opts.openvpn_verb) + ovpn_verbosity=opts.openvpn_verb, + provider=provider) self.skip_download = opts.no_provider_checks self.skip_verify = opts.no_ca_verify 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/eip.py | 4 ++-- src/leap/baseapp/mainwindow.py | 24 +++++++++++------------- src/leap/baseapp/systray.py | 14 +++++++------- 3 files changed, 20 insertions(+), 22 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 26a2a1fb..54acbc0e 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -37,8 +37,8 @@ class EIPConductorAppMixin(object): self.conductor = EIPConnection( watcher_cb=self.newLogLine.emit, config_file=config_file, - checker_signals=(self.changeLeapStatus.emit, ), - status_signals=(self.statusChange.emit, ), + checker_signals=(self.eipStatusChange.emit, ), + status_signals=(self.openvpnStatusChange.emit, ), debug=self.debugmode, ovpn_verbosity=opts.openvpn_verb, provider=provider) 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') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index cc5d89df..061de98e 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -196,31 +196,31 @@ class StatusAwareTrayIconMixin(object): self.statusUpdate() @QtCore.pyqtSlot(object) - def onStatusChange(self, status): + def onOpenVPNStatusChange(self, status): """ - updates icon + updates icon, according to the openvpn status change. """ icon_name = self.conductor.get_icon_name() # XXX refactor. Use QStateMachine if icon_name in ("disconnected", "connected"): - self.changeLeapStatus.emit(icon_name) + self.eipStatusChange.emit(icon_name) if icon_name in ("connecting"): # let's see how it matches leap_status_name = self.conductor.get_leap_status() - self.changeLeapStatus.emit(leap_status_name) + self.eipStatusChange.emit(leap_status_name) self.setIcon(icon_name) # change connection pixmap widget self.setConnWidget(icon_name) @QtCore.pyqtSlot(str) - def onChangeLeapConnStatus(self, newstatus): + def onEIPConnStatusChange(self, newstatus): """ - slot for LEAP status changes - not to be confused with onStatusChange. + slot for EIP status changes + not to be confused with onOpenVPNStatusChange. this only updates the non-debug LEAP Status line next to the connection icon. """ -- 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 +++ src/leap/baseapp/systray.py | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') 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() -- cgit v1.2.3 From b66f946c9e7bbdf4bfb7ceb7ffcf340257b2165e Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 26 Oct 2012 05:02:04 +0900 Subject: hide aboutQt menu entry --- src/leap/baseapp/systray.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index bf57c0f8..8777207c 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -92,7 +92,9 @@ class StatusAwareTrayIconMixin(object): self.trayIconMenu.addAction(self.detailsAct) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.aboutAct) - self.trayIconMenu.addAction(self.aboutQtAct) + # we should get this hidden inside the "about" dialog + # (as a little button maybe) + #self.trayIconMenu.addAction(self.aboutQtAct) self.trayIconMenu.addSeparator() self.trayIconMenu.addAction(self.quitAction) -- 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/leap_app.py | 19 ++++++++++++------- src/leap/baseapp/mainwindow.py | 23 ++++++++++++++--------- src/leap/baseapp/systray.py | 5 +---- 3 files changed, 27 insertions(+), 20 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index d1acb8ba..4b63dd2f 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -52,7 +52,7 @@ class MainWindowMixin(object): self.firstRunWizardAct = QtGui.QAction( "&First run wizard...", self, - triggered=self.launch_first_run_wizard) + triggered=self.stop_connection_and_launch_first_run_wizard) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) #self.aboutQtAct = QtGui.QAction("About &Qt", self, @@ -74,16 +74,21 @@ class MainWindowMixin(object): self.menuBar().addMenu(self.settingsMenu) self.menuBar().addMenu(self.helpMenu) - def launch_first_run_wizard(self): + def stop_connection_and_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() + status = self.conductor.get_icon_name() + if status != "disconnected": + self.start_or_stopVPN() + + self.launch_first_run_wizard() + #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) 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() diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 8777207c..06be2975 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -129,12 +129,9 @@ class StatusAwareTrayIconMixin(object): def toggleEIPAct(self): # 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) - # XXX get STATUS CONSTANTS INSTEAD - icon_status = self.conductor.status.get_state_icon() + icon_status = self.conductor.get_icon_name() if icon_status == "connected": self.connAct.setEnabled(True) self.connAct.setText('Encryption ON turn o&ff') -- 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') 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') 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 +++++---------------- src/leap/baseapp/systray.py | 3 +++ 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'src/leap/baseapp') 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() diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 06be2975..94a7a8f2 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -1,4 +1,7 @@ import logging +import sip +sip.setapi('QString', 2) +sip.setapi('QVariant', 2) from PyQt4 import QtCore from PyQt4 import QtGui -- 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') 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') 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 From bd33a6bf8e6b56b4cfa5e2b008edc18d5f6a0c3a Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 14 Nov 2012 02:41:07 +0900 Subject: make the check for valid client cert the trigger for first-run-wizard Closes #803 And with this we've completed all features blocking the release goal: generic client. --- src/leap/baseapp/mainwindow.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 918f1568..41130852 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -14,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.eip.checks import ProviderCertChecker from leap.gui.threads import FunThread logger = logging.getLogger(name=__name__) @@ -125,8 +126,14 @@ class LeapWindow(QtGui.QMainWindow, # do checks (can overlap if wizard was interrupted) if not self.wizard_done: need_wizard = True + if not self.provider_domain: need_wizard = True + else: + pcertchecker = ProviderCertChecker(domain=self.provider_domain) + if not pcertchecker.is_cert_valid(do_raise=False): + logger.warning('missing valid client cert. need wizard') + need_wizard = True # launch wizard if needed if need_wizard: -- cgit v1.2.3 From e111e9de0d33d12503233e754e2e4b01133acec9 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 14 Nov 2012 02:53:28 +0900 Subject: hide the systray icon until the firstrun wizard is complete Closes #762 --- src/leap/baseapp/mainwindow.py | 1 + src/leap/baseapp/systray.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 41130852..f07ebb7d 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -164,4 +164,5 @@ class LeapWindow(QtGui.QMainWindow, self.cleanupAndQuit() def runchecks_and_eipconnect(self): + self.show_systray_icon() self.initchecks.begin() diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 94a7a8f2..49f044aa 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -44,12 +44,14 @@ 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... self.timer = QtCore.QTimer() + def show_systray_icon(self): + #logger.debug('showing tray icon................') + self.trayIcon.show() + def createIconGroupBox(self): """ dummy icongroupbox -- cgit v1.2.3 From c7dec38062e433cd1f098b6f1457acc87b4e6aaf Mon Sep 17 00:00:00 2001 From: antialias Date: Wed, 21 Nov 2012 15:34:32 -0800 Subject: successfully catching ctrl-c but for not quitting in the correct order. --- src/leap/baseapp/mainwindow.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index f07ebb7d..85185ca6 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -40,6 +40,7 @@ class LeapWindow(QtGui.QMainWindow, networkError = QtCore.pyqtSignal([object]) triggerEIPError = QtCore.pyqtSignal([object]) start_eipconnection = QtCore.pyqtSignal([]) + shutdownSignal = QtCore.pyqtSignal([]) # this is status change got from openvpn management openvpnStatusChange = QtCore.pyqtSignal([object]) -- cgit v1.2.3 From a3ce61ea54b0b0f5c1ecd5904379e27cfec885b5 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 28 Nov 2012 02:43:25 +0900 Subject: call shutdown signal from sigint_handler --- src/leap/baseapp/mainwindow.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 85185ca6..8d61bf5c 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -95,6 +95,8 @@ class LeapWindow(QtGui.QMainWindow, lambda: self.start_or_stopVPN()) self.start_eipconnection.connect( lambda: self.start_or_stopVPN()) + self.shutdownSignal.connect( + self.cleanupAndQuit) # status change. # TODO unify @@ -102,7 +104,6 @@ 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()) -- cgit v1.2.3 From cd78d9d552977e8f8fb12b6a2ff56fda9c37bf35 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 7 Dec 2012 05:32:50 +0900 Subject: only remove management socket when shutting down Closes #1090 --- src/leap/baseapp/leap_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index 4b63dd2f..e41cff40 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -148,6 +148,6 @@ class MainWindowMixin(object): # in conductor # XXX send signal instead? logger.info('Shutting down') - self.conductor.cleanup() + self.conductor.cleanup(shutdown=True) logger.info('Exiting. Bye.') QtGui.qApp.quit() -- cgit v1.2.3 From 38cc1758240a3c64db387b0437dcf1517b52da15 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 10 Dec 2012 19:51:53 +0900 Subject: cleanup and rewrite eipconnection/openvpnconnection classes --- src/leap/baseapp/leap_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index e41cff40..4d3aebd6 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -148,6 +148,6 @@ class MainWindowMixin(object): # in conductor # XXX send signal instead? logger.info('Shutting down') - self.conductor.cleanup(shutdown=True) + self.conductor.disconnect(shutdown=True) logger.info('Exiting. Bye.') QtGui.qApp.quit() -- cgit v1.2.3 From 53fa2c134ab2c96376276aa1c0ed74db0aaba218 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 10 Dec 2012 23:20:09 +0900 Subject: get cipher config from eip-service --- src/leap/baseapp/mainwindow.py | 9 +++++++-- src/leap/baseapp/network.py | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 8d61bf5c..65c30bff 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -61,10 +61,15 @@ class LeapWindow(QtGui.QMainWindow, logger.debug('provider: %s', self.provider_domain) logger.debug('eip_username: %s', self.eip_username) + provider = self.provider_domain EIPConductorAppMixin.__init__( - self, opts=opts, provider=self.provider_domain) + self, opts=opts, provider=provider) StatusAwareTrayIconMixin.__init__(self) - NetworkCheckerAppMixin.__init__(self) + + # XXX network checker should probably not + # trigger run_checks on init... but wait + # for ready signal instead... + NetworkCheckerAppMixin.__init__(self, provider=provider) MainWindowMixin.__init__(self) geom_key = "DebugGeometry" if self.debugmode else "Geometry" diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index 077d5164..3e57490d 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -17,11 +17,14 @@ class NetworkCheckerAppMixin(object): """ def __init__(self, *args, **kwargs): + provider = kwargs.pop('provider', None) self.network_checker = NetworkCheckerThread( error_cb=self.networkError.emit, - debug=self.debugmode) + debug=self.debugmode, + provider=provider) - # XXX move run_checks to slot + # XXX move run_checks to slot -- this definitely + # cannot start on init!!! self.network_checker.run_checks() @QtCore.pyqtSlot(object) -- cgit v1.2.3 From 04d423e2a89034dfb86fe305108162fd2a696079 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 12 Dec 2012 03:29:31 +0900 Subject: tests for openvpn options and make the rest of tests pass after some changes in this branch (dirtyness in config files) --- src/leap/baseapp/systray.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 49f044aa..52060ae2 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -217,6 +217,8 @@ class StatusAwareTrayIconMixin(object): updates icon, according to the openvpn status change. """ icon_name = self.conductor.get_icon_name() + if not icon_name: + return # XXX refactor. Use QStateMachine -- cgit v1.2.3 From 4984f2c966d11f529a2a8b722814b748b6a524d2 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 12 Dec 2012 09:16:53 +0900 Subject: changed some values in new style eipconfig --- src/leap/baseapp/eip.py | 2 ++ src/leap/baseapp/network.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 54acbc0e..0d7506b3 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -203,6 +203,8 @@ class EIPConductorAppMixin(object): # we could bring Timer Init to this Mixin # or to its own Mixin. self.timer.start(constants.TIMER_MILLISECONDS) + # XXX EMIT SIGNAL INSTEAD (when first run, + # network checker does not exist...) self.network_checker.start() return diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index 3e57490d..7363cfaa 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -18,13 +18,17 @@ class NetworkCheckerAppMixin(object): def __init__(self, *args, **kwargs): provider = kwargs.pop('provider', None) + if provider: + self.init_network_checker(provider) + + def init_network_checker(self, provider): self.network_checker = NetworkCheckerThread( error_cb=self.networkError.emit, debug=self.debugmode, provider=provider) - # XXX move run_checks to slot -- this definitely - # cannot start on init!!! + @QtCore.pyqtSlot(object) + def runNetworkChecks(self): self.network_checker.run_checks() @QtCore.pyqtSlot(object) -- cgit v1.2.3 From 89694babd14a9b2ba76095911b6884e359a12282 Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 17 Dec 2012 05:05:37 +0900 Subject: network checker launched by signal fixes problem with provider domain not being defined during first run. --- src/leap/baseapp/eip.py | 3 --- src/leap/baseapp/mainwindow.py | 3 +++ src/leap/baseapp/network.py | 14 +++++++++----- src/leap/baseapp/systray.py | 5 +++++ 4 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 0d7506b3..55ecfa79 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -203,9 +203,6 @@ class EIPConductorAppMixin(object): # we could bring Timer Init to this Mixin # or to its own Mixin. self.timer.start(constants.TIMER_MILLISECONDS) - # XXX EMIT SIGNAL INSTEAD (when first run, - # network checker does not exist...) - self.network_checker.start() return if self.eip_service_started is True: diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 65c30bff..02adab65 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -41,6 +41,7 @@ class LeapWindow(QtGui.QMainWindow, triggerEIPError = QtCore.pyqtSignal([object]) start_eipconnection = QtCore.pyqtSignal([]) shutdownSignal = QtCore.pyqtSignal([]) + initNetworkChecker = QtCore.pyqtSignal([]) # this is status change got from openvpn management openvpnStatusChange = QtCore.pyqtSignal([object]) @@ -102,6 +103,8 @@ class LeapWindow(QtGui.QMainWindow, lambda: self.start_or_stopVPN()) self.shutdownSignal.connect( self.cleanupAndQuit) + self.initNetworkChecker.connect( + lambda: self.init_network_checker(self.provider_domain)) # status change. # TODO unify diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index 7363cfaa..a33265e5 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -9,23 +9,27 @@ from PyQt4 import QtCore from leap.baseapp.dialogs import ErrorDialog from leap.base.network import NetworkCheckerThread +from leap.util.misc import null_check + class NetworkCheckerAppMixin(object): """ initialize an instance of the Network Checker, which gathers error and passes them on. """ - def __init__(self, *args, **kwargs): provider = kwargs.pop('provider', None) if provider: self.init_network_checker(provider) def init_network_checker(self, provider): - self.network_checker = NetworkCheckerThread( - error_cb=self.networkError.emit, - debug=self.debugmode, - provider=provider) + null_check(provider, "provider_domain") + if not hasattr(self, 'network_checker'): + self.network_checker = NetworkCheckerThread( + error_cb=self.networkError.emit, + debug=self.debugmode, + provider=provider) + self.network_checker.start() @QtCore.pyqtSlot(object) def runNetworkChecks(self): diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 52060ae2..0dd0f195 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -230,6 +230,11 @@ class StatusAwareTrayIconMixin(object): leap_status_name = self.conductor.get_leap_status() self.eipStatusChange.emit(leap_status_name) + if icon_name == "connected": + # When we change to "connected', we launch + # the network checker. + self.initNetworkChecker.emit() + self.setIcon(icon_name) # change connection pixmap widget self.setConnWidget(icon_name) -- cgit v1.2.3 From b2e1e26e182bc86e01440ab3a93d3953f1fbcb4b Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 27 Dec 2012 07:08:10 +0900 Subject: fix window not raising to front in osx --- src/leap/baseapp/systray.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 0dd0f195..93fab716 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -1,4 +1,6 @@ import logging +import sys + import sip sip.setapi('QString', 2) sip.setapi('QVariant', 2) @@ -156,6 +158,8 @@ class StatusAwareTrayIconMixin(object): self.hide() else: self.show() + if sys.platform == "darwin": + self.raise_() def about(self): # move to widget -- cgit v1.2.3 From f82f81b6766905269d51e08632b42ed2e92c249b Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 9 Jan 2013 00:00:42 +0900 Subject: rename username var --- src/leap/baseapp/mainwindow.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index 02adab65..dd2ecdf0 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -57,10 +57,10 @@ class LeapWindow(QtGui.QMainWindow, settings = QtCore.QSettings() self.provider_domain = settings.value("provider_domain", None) - self.eip_username = settings.value("eip_username", None) + self.username = settings.value("username", None) logger.debug('provider: %s', self.provider_domain) - logger.debug('eip_username: %s', self.eip_username) + logger.debug('username: %s', self.username) provider = self.provider_domain EIPConductorAppMixin.__init__( @@ -160,7 +160,7 @@ class LeapWindow(QtGui.QMainWindow, wizard = FirstRunWizard( self.conductor, parent=self, - eip_username=self.eip_username, + username=self.username, start_eipconnection_signal=self.start_eipconnection, eip_statuschange_signal=self.eipStatusChange, quitcallback=self.onWizardCancel) -- cgit v1.2.3 From 3c19346b5189e993e982aabe8ded2d20c0e0bcd6 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 9 Jan 2013 00:45:20 +0900 Subject: fix provider parameter passed to network check --- src/leap/baseapp/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index dd2ecdf0..b9a451ac 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -104,7 +104,7 @@ class LeapWindow(QtGui.QMainWindow, self.shutdownSignal.connect( self.cleanupAndQuit) self.initNetworkChecker.connect( - lambda: self.init_network_checker(self.provider_domain)) + lambda: self.init_network_checker(self.conductor.provider)) # status change. # TODO unify -- cgit v1.2.3 From c6ab7134f69eea59b0f2f44016d7fc4f2fbfe359 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 9 Jan 2013 01:02:28 +0900 Subject: icon shows when wizard ends --- src/leap/baseapp/mainwindow.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index b9a451ac..b1e5bccf 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -100,7 +100,7 @@ class LeapWindow(QtGui.QMainWindow, self.startStopButton.clicked.connect( lambda: self.start_or_stopVPN()) self.start_eipconnection.connect( - lambda: self.start_or_stopVPN()) + self.do_start_eipconnection) self.shutdownSignal.connect( self.cleanupAndQuit) self.initNetworkChecker.connect( @@ -147,9 +147,9 @@ class LeapWindow(QtGui.QMainWindow, # launch wizard if needed if need_wizard: + logger.debug('running first run wizard') self.launch_first_run_wizard() else: # no wizard needed - logger.debug('running first run wizard') self.initReady.emit() def launch_first_run_wizard(self): @@ -174,5 +174,16 @@ class LeapWindow(QtGui.QMainWindow, self.cleanupAndQuit() def runchecks_and_eipconnect(self): + """ + shows icon and run init checks + """ self.show_systray_icon() self.initchecks.begin() + + def do_start_eipconnection(self): + """ + shows icon and init eip connection + called from the end of wizard + """ + self.show_systray_icon() + self.start_or_stopVPN() -- cgit v1.2.3 From a5b4b7020daebbcb25c016cf1821818b71a2e457 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 9 Jan 2013 06:23:45 +0900 Subject: more missed strings to be translated plus initial translation. --- src/leap/baseapp/eip.py | 4 ++-- src/leap/baseapp/log.py | 4 ++-- src/leap/baseapp/systray.py | 56 +++++++++++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 26 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 55ecfa79..41f4c541 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -195,7 +195,7 @@ class EIPConductorAppMixin(object): else: # no errors, so go on. if self.debugmode: - self.startStopButton.setText('&Disconnect') + self.startStopButton.setText(self.tr('&Disconnect')) self.eip_service_started = True self.toggleEIPAct() @@ -209,7 +209,7 @@ class EIPConductorAppMixin(object): self.network_checker.stop() self.conductor.disconnect() if self.debugmode: - self.startStopButton.setText('&Connect') + self.startStopButton.setText(self.tr('&Connect')) self.eip_service_started = False self.toggleEIPAct() self.timer.stop() diff --git a/src/leap/baseapp/log.py b/src/leap/baseapp/log.py index 8a7f81c3..95cfc918 100644 --- a/src/leap/baseapp/log.py +++ b/src/leap/baseapp/log.py @@ -21,7 +21,7 @@ class LogPaneMixin(object): logging_layout = QtGui.QVBoxLayout() self.logbrowser = QtGui.QTextBrowser() - startStopButton = QtGui.QPushButton("&Connect") + startStopButton = QtGui.QPushButton(self.tr("&Connect")) self.startStopButton = startStopButton logging_layout.addWidget(self.logbrowser) @@ -34,7 +34,7 @@ class LogPaneMixin(object): grid = QtGui.QGridLayout() self.updateTS = QtGui.QLabel('') - self.status_label = QtGui.QLabel('Disconnected') + self.status_label = QtGui.QLabel(self.tr('Disconnected')) self.ip_label = QtGui.QLabel('') self.remote_label = QtGui.QLabel('') diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py index 93fab716..77eb3fe9 100644 --- a/src/leap/baseapp/systray.py +++ b/src/leap/baseapp/systray.py @@ -75,7 +75,8 @@ class StatusAwareTrayIconMixin(object): self.iconpath['connected'])), self.ConnectionWidgets = con_widgets - self.statusIconBox = QtGui.QGroupBox("EIP Connection Status") + self.statusIconBox = QtGui.QGroupBox( + self.tr("EIP Connection Status")) statusIconLayout = QtGui.QHBoxLayout() statusIconLayout.addWidget(self.ConnectionWidgets['disconnected']) statusIconLayout.addWidget(self.ConnectionWidgets['connecting']) @@ -83,7 +84,8 @@ class StatusAwareTrayIconMixin(object): statusIconLayout.itemAt(1).widget().hide() statusIconLayout.itemAt(2).widget().hide() - self.leapConnStatus = QtGui.QLabel("disconnected") + self.leapConnStatus = QtGui.QLabel( + self.tr("disconnected")) statusIconLayout.addWidget(self.leapConnStatus) self.statusIconBox.setLayout(statusIconLayout) @@ -113,26 +115,32 @@ class StatusAwareTrayIconMixin(object): #self.trayIconMenu.customContextMenuRequested.connect( #self.on_context_menu) - def bad(self): - logger.error('this should not be called') + #def bad(self): + #logger.error('this should not be called') def createActions(self): """ creates actions to be binded to tray icon """ # XXX change action name on (dis)connect - self.connAct = QtGui.QAction("Encryption ON turn &off", self, - triggered=lambda: self.start_or_stopVPN()) - - self.detailsAct = QtGui.QAction("&Details...", - self, - triggered=self.detailsWin) - self.aboutAct = QtGui.QAction("&About", self, - triggered=self.about) - self.aboutQtAct = QtGui.QAction("About Q&t", self, - triggered=QtGui.qApp.aboutQt) - self.quitAction = QtGui.QAction("&Quit", self, - triggered=self.cleanupAndQuit) + self.connAct = QtGui.QAction( + self.tr("Encryption ON turn &off"), + self, + triggered=lambda: self.start_or_stopVPN()) + + self.detailsAct = QtGui.QAction( + self.tr("&Details..."), + self, + triggered=self.detailsWin) + self.aboutAct = QtGui.QAction( + self.tr("&About"), self, + triggered=self.about) + self.aboutQtAct = QtGui.QAction( + self.tr("About Q&t"), self, + triggered=QtGui.qApp.aboutQt) + self.quitAction = QtGui.QAction( + self.tr("&Quit"), self, + triggered=self.cleanupAndQuit) def toggleEIPAct(self): # this is too simple by now. @@ -141,15 +149,17 @@ class StatusAwareTrayIconMixin(object): icon_status = self.conductor.get_icon_name() if icon_status == "connected": self.connAct.setEnabled(True) - self.connAct.setText('Encryption ON turn o&ff') + self.connAct.setText( + self.tr('Encryption ON turn o&ff')) return if icon_status == "disconnected": self.connAct.setEnabled(True) - self.connAct.setText('Encryption OFF turn &on') + self.connAct.setText( + self.tr('Encryption OFF turn &on')) return if icon_status == "connecting": self.connAct.setDisabled(True) - self.connAct.setText('connecting...') + self.connAct.setText(self.tr('connecting...')) return def detailsWin(self): @@ -164,14 +174,15 @@ class StatusAwareTrayIconMixin(object): def about(self): # move to widget flavor = BRANDING.get('short_name', None) - content = ("LEAP client
" - "(version %s)
" % VERSION) + content = self.tr( + ("LEAP client
" + "(version %s)
" % VERSION)) if flavor: content = content + ('
Flavor: %s
' % flavor) content = content + ( "
" "https://leap.se") - QtGui.QMessageBox.about(self, "About", content) + QtGui.QMessageBox.about(self, self.tr("About"), content) def setConnWidget(self, icon_name): oldlayout = self.statusIconBox.layout() @@ -209,6 +220,7 @@ class StatusAwareTrayIconMixin(object): # is failing in a way beyond my understanding. # (not working the first time it's clicked). # this works however. + # XXX in osx it shows some glitches. context_menu.exec_(self.trayIcon.geometry().center()) @QtCore.pyqtSlot() -- cgit v1.2.3 From 348eb0852d6f1b8b2b72baba8a236bc30a6f2a4e Mon Sep 17 00:00:00 2001 From: antialias Date: Fri, 16 Nov 2012 17:38:46 -0800 Subject: reads and searches for strings from openvpn logs via the management interface. --- src/leap/baseapp/eip.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 41f4c541..f18a62e7 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -174,6 +174,10 @@ class EIPConductorAppMixin(object): self.tun_read_bytes.setText(tun_read) self.tun_write_bytes.setText(tun_write) + # connection information via management interface + log = self.conductor.get_log() + self.network_checker.parse_log(log) + @QtCore.pyqtSlot() def start_or_stopVPN(self): """ -- cgit v1.2.3 From 14f433c16de60753d122d5946df68e8e82285ca3 Mon Sep 17 00:00:00 2001 From: antialias Date: Mon, 19 Nov 2012 16:16:01 -0800 Subject: implemented abstracted layer with matching and passed callback. tests as well. --- src/leap/baseapp/eip.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index f18a62e7..4fcbee3f 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -9,6 +9,7 @@ from leap.baseapp.dialogs import ErrorDialog from leap.baseapp import constants from leap.eip import exceptions as eip_exceptions from leap.eip.eipconnection import EIPConnection +from leap.base.checks import EVENT_CONNECT_REFUSED logger = logging.getLogger(name=__name__) @@ -176,7 +177,8 @@ class EIPConductorAppMixin(object): # connection information via management interface log = self.conductor.get_log() - self.network_checker.parse_log(log) + error_matrix = [(EVENT_CONNECT_REFUSED, (self.start_or_stopVPN, ))] + self.network_checker.checker.parse_log_and_react(log, error_matrix) @QtCore.pyqtSlot() def start_or_stopVPN(self): -- cgit v1.2.3 From bf39c45eddc62733fdb72b4f46cdb81ec649cb30 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 16 Jan 2013 00:58:22 +0900 Subject: handle loss of tun iface trigger only one dialog and disconnect. additional cleanup of log handling. --- src/leap/baseapp/log.py | 6 ++++-- src/leap/baseapp/network.py | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/log.py b/src/leap/baseapp/log.py index 95cfc918..e6a767fb 100644 --- a/src/leap/baseapp/log.py +++ b/src/leap/baseapp/log.py @@ -11,6 +11,7 @@ class LogPaneMixin(object): a simple log pane that writes new lines as they come """ + EXCLUDES = ('MANAGEMENT',) def createLogBrowser(self): """ @@ -60,6 +61,7 @@ class LogPaneMixin(object): simple slot: writes new line to logger Pane. """ msg = line[:-1] - if self.debugmode: + if self.debugmode and all(map(lambda w: w not in msg, + LogPaneMixin.EXCLUDES)): self.logbrowser.append(msg) - vpnlogger.info(msg) + vpnlogger.info(msg) diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index a33265e5..a67f6340 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -17,6 +17,8 @@ class NetworkCheckerAppMixin(object): initialize an instance of the Network Checker, which gathers error and passes them on. """ + ERR_NETERR = False + def __init__(self, *args, **kwargs): provider = kwargs.pop('provider', None) if provider: @@ -41,11 +43,19 @@ class NetworkCheckerAppMixin(object): slot that receives a network exceptions and raises a user error message """ - logger.debug('handling network exception') - logger.error(exc.message) - dialog = ErrorDialog(parent=self) + # FIXME this should not HANDLE anything after + # the network check thread has been stopped. - if exc.critical: - dialog.criticalMessage(exc.usermessage, "network error") - else: - dialog.warningMessage(exc.usermessage, "network error") + logger.debug('handling network exception') + if not self.ERR_NETERR: + self.ERR_NETERR = True + + logger.error(exc.message) + dialog = ErrorDialog(parent=self) + if exc.critical: + dialog.criticalMessage(exc.usermessage, "network error") + else: + dialog.warningMessage(exc.usermessage, "network error") + + self.start_or_stopVPN() + self.network_checker.stop() -- cgit v1.2.3 From 6e9c63f47b98fbfcd3a5104fbfa5cc9d9ffe5143 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 17 Jan 2013 07:31:59 +0900 Subject: osx fixed already running instance check --- src/leap/baseapp/dialogs.py | 9 ++++++--- src/leap/baseapp/eip.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/dialogs.py b/src/leap/baseapp/dialogs.py index 3cb539cf..d256fc99 100644 --- a/src/leap/baseapp/dialogs.py +++ b/src/leap/baseapp/dialogs.py @@ -23,7 +23,8 @@ class ErrorDialog(QDialog): def warningMessage(self, msg, label): msgBox = QMessageBox(QMessageBox.Warning, - "QMessageBox.warning()", msg, + "LEAP Client Error", + msg, QMessageBox.NoButton, self) msgBox.addButton("&Ok", QMessageBox.AcceptRole) if msgBox.exec_() == QMessageBox.AcceptRole: @@ -34,7 +35,8 @@ class ErrorDialog(QDialog): def criticalMessage(self, msg, label): msgBox = QMessageBox(QMessageBox.Critical, - "QMessageBox.critical()", msg, + "LEAP Client Error", + msg, QMessageBox.NoButton, self) msgBox.addButton("&Ok", QMessageBox.AcceptRole) msgBox.exec_() @@ -49,7 +51,8 @@ class ErrorDialog(QDialog): def confirmMessage(self, msg, label, action): msgBox = QMessageBox(QMessageBox.Critical, - "QMessageBox.critical()", msg, + self.tr("LEAP Client Error"), + msg, QMessageBox.NoButton, self) msgBox.addButton("&Ok", QMessageBox.AcceptRole) msgBox.addButton("&Cancel", QMessageBox.RejectRole) diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 4fcbee3f..03a1d6c7 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -22,6 +22,7 @@ class EIPConductorAppMixin(object): Connects the eip connect/disconnect logic to the switches in the app (buttons/menu items). """ + ERR_DIALOG = False def __init__(self, *args, **kwargs): opts = kwargs.pop('opts') @@ -94,6 +95,15 @@ class EIPConductorAppMixin(object): in the future we plan to derive errors to our log viewer. """ + if self.ERR_DIALOG: + logger.warning('another error dialog suppressed') + return + + # XXX this is actually a one-shot. + # On the dialog there should be + # a reset signal binded to the ok button + # or something like that. + self.ERR_DIALOG = True if getattr(error, 'usermessage', None): message = error.usermessage @@ -105,6 +115,7 @@ class EIPConductorAppMixin(object): # launching dialog. # (so Qt tests can assert stuff) + if error.critical: logger.critical(error.message) #critical error (non recoverable), @@ -113,6 +124,7 @@ class EIPConductorAppMixin(object): ErrorDialog(errtype="critical", msg=message, label="critical error") + elif error.warning: logger.warning(error.message) -- cgit v1.2.3 From 6fb952397573f4bc90f4cd9e72b49fcf6256e95c Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 17 Jan 2013 08:07:45 +0900 Subject: localize exit country if we can only if we can find the geoip database, which comes with geoip-database in debian. we will have to think more about this in the future but it's nice to have now for testing. --- src/leap/baseapp/eip.py | 3 +++ src/leap/baseapp/log.py | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 03a1d6c7..4c1fb32d 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -10,6 +10,7 @@ from leap.baseapp import constants from leap.eip import exceptions as eip_exceptions from leap.eip.eipconnection import EIPConnection from leap.base.checks import EVENT_CONNECT_REFUSED +from leap.util import geo logger = logging.getLogger(name=__name__) @@ -175,6 +176,8 @@ class EIPConductorAppMixin(object): self.status_label.setText(con_status) self.ip_label.setText(ip) self.remote_label.setText(remote) + self.remote_country.setText( + geo.get_country_name(remote)) # status i/o diff --git a/src/leap/baseapp/log.py b/src/leap/baseapp/log.py index e6a767fb..636e5bae 100644 --- a/src/leap/baseapp/log.py +++ b/src/leap/baseapp/log.py @@ -38,6 +38,7 @@ class LogPaneMixin(object): self.status_label = QtGui.QLabel(self.tr('Disconnected')) self.ip_label = QtGui.QLabel('') self.remote_label = QtGui.QLabel('') + self.remote_country = QtGui.QLabel('') tun_read_label = QtGui.QLabel("tun read") self.tun_read_bytes = QtGui.QLabel("0") @@ -48,10 +49,11 @@ class LogPaneMixin(object): grid.addWidget(self.status_label, 0, 1) grid.addWidget(self.ip_label, 1, 0) grid.addWidget(self.remote_label, 1, 1) - grid.addWidget(tun_read_label, 2, 0) - grid.addWidget(self.tun_read_bytes, 2, 1) - grid.addWidget(tun_write_label, 3, 0) - grid.addWidget(self.tun_write_bytes, 3, 1) + grid.addWidget(self.remote_country, 2, 1) + grid.addWidget(tun_read_label, 3, 0) + grid.addWidget(self.tun_read_bytes, 3, 1) + grid.addWidget(tun_write_label, 4, 0) + grid.addWidget(self.tun_write_bytes, 4, 1) self.statusBox.setLayout(grid) -- cgit v1.2.3 From 54802bf9c53fc32cfcceb23045c5aeb313c19829 Mon Sep 17 00:00:00 2001 From: kali Date: Fri, 18 Jan 2013 08:45:35 +0900 Subject: fix network checker attr in wizard --- src/leap/baseapp/network.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index a67f6340..d5685504 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -21,12 +21,13 @@ class NetworkCheckerAppMixin(object): def __init__(self, *args, **kwargs): provider = kwargs.pop('provider', None) + self.network_checker = None if provider: self.init_network_checker(provider) def init_network_checker(self, provider): null_check(provider, "provider_domain") - if not hasattr(self, 'network_checker'): + if not self.network_checker: self.network_checker = NetworkCheckerThread( error_cb=self.networkError.emit, debug=self.debugmode, -- cgit v1.2.3 From 407b030bb7d27b797fb27254710a358c9c69f8be Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 24 Jan 2013 01:57:28 +0900 Subject: catch missing messages on last page of wizard --- src/leap/baseapp/eip.py | 7 +++++-- src/leap/baseapp/mainwindow.py | 2 ++ src/leap/baseapp/network.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 4c1fb32d..2f215f00 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -193,21 +193,24 @@ class EIPConductorAppMixin(object): # connection information via management interface log = self.conductor.get_log() error_matrix = [(EVENT_CONNECT_REFUSED, (self.start_or_stopVPN, ))] - self.network_checker.checker.parse_log_and_react(log, error_matrix) + if hasattr(self.network_checker, 'checker'): + self.network_checker.checker.parse_log_and_react(log, error_matrix) @QtCore.pyqtSlot() - def start_or_stopVPN(self): + def start_or_stopVPN(self, **kwargs): """ stub for running child process with vpn """ if self.conductor.has_errors(): logger.debug('not starting vpn; conductor has errors') + return if self.eip_service_started is False: try: self.conductor.connect() except eip_exceptions.EIPNoCommandError as exc: + logger.error('tried to run openvpn but no command is set') self.triggerEIPError.emit(exc) except Exception as err: diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index b1e5bccf..91b0dc61 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -186,4 +186,6 @@ class LeapWindow(QtGui.QMainWindow, called from the end of wizard """ self.show_systray_icon() + # this will setup the command + self.conductor.run_openvpn_checks() self.start_or_stopVPN() diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index d5685504..dc5182a4 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -36,6 +36,7 @@ class NetworkCheckerAppMixin(object): @QtCore.pyqtSlot(object) def runNetworkChecks(self): + logger.debug('running checks (from NetworkChecker Mixin slot)') self.network_checker.run_checks() @QtCore.pyqtSlot(object) -- cgit v1.2.3 From 9cdc193c587631986e579c1ba37a8b982be01238 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 24 Jan 2013 18:47:41 +0900 Subject: all tests green again plus: * added soledad test requirements * removed soledad from run_tests run (+1K tests failing) * added option to run All tests to run_tests script * pep8 cleanup --- src/leap/baseapp/eip.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 2f215f00..adc9ba68 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -101,7 +101,7 @@ class EIPConductorAppMixin(object): return # XXX this is actually a one-shot. - # On the dialog there should be + # On the dialog there should be # a reset signal binded to the ok button # or something like that. self.ERR_DIALOG = True @@ -116,7 +116,6 @@ class EIPConductorAppMixin(object): # launching dialog. # (so Qt tests can assert stuff) - if error.critical: logger.critical(error.message) #critical error (non recoverable), -- cgit v1.2.3 From b3f30d14d8a8e728d904b78e9235d63d25e475d1 Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 30 Jan 2013 06:15:35 +0900 Subject: fix option not in use --- src/leap/baseapp/eip.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/leap/baseapp') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index adc9ba68..b34cc82e 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -46,8 +46,12 @@ class EIPConductorAppMixin(object): ovpn_verbosity=opts.openvpn_verb, provider=provider) - self.skip_download = opts.no_provider_checks - self.skip_verify = opts.no_ca_verify + # Do we want to enable the skip checks w/o being + # in debug mode?? + #self.skip_download = opts.no_provider_checks + #self.skip_verify = opts.no_ca_verify + self.skip_download = False + self.skip_verify = False def run_eip_checks(self): """ -- cgit v1.2.3