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 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