summaryrefslogtreecommitdiff
path: root/src/leap/baseapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/baseapp')
-rw-r--r--src/leap/baseapp/eip.py35
-rw-r--r--src/leap/baseapp/leap_app.py26
-rw-r--r--src/leap/baseapp/systray.py74
-rw-r--r--src/leap/baseapp/unitychecks.py96
4 files changed, 92 insertions, 139 deletions
diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py
index 515ae58d..b0e14be7 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,11 @@ 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)
+ 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
@@ -58,13 +63,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 +76,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
@@ -132,6 +133,8 @@ class EIPConductorAppMixin(object):
ErrorDialog(errtype="critical",
msg=message,
label="critical error")
+ elif error.warning:
+ logger.warning(error.message)
else:
dialog = ErrorDialog()
@@ -151,13 +154,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
@@ -210,12 +218,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:
@@ -223,5 +231,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/leap_app.py b/src/leap/baseapp/leap_app.py
index f91b2329..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("<font size=40><b>E</b>ncryption \
-<b>I</b>nternet <b>P</b>roxy</font>")
- self.headerLabelSub = QtGui.QLabel("<i>trust your \
-technolust</i>")
+ self.headerLabel = QtGui.QLabel(
+ "<font size=40>LEAP Encryption Access Project</font>")
+ self.headerLabelSub = QtGui.QLabel(
+ "<br><i>your internet encryption toolkit</i>")
- pixmap = QtGui.QPixmap(':/images/leapfrog.jpg')
- 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()
@@ -85,5 +93,5 @@ technolust</i>")
# 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..39a23f49 100644
--- a/src/leap/baseapp/systray.py
+++ b/src/leap/baseapp/systray.py
@@ -1,9 +1,15 @@
+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
+logger = logging.getLogger(__name__)
+
class StatusAwareTrayIconMixin(object):
"""
@@ -61,7 +67,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'])
@@ -76,12 +82,12 @@ class StatusAwareTrayIconMixin(object):
"""
self.trayIconMenu = QtGui.QMenu(self)
- self.trayIconMenu.addAction(self.connectVPNAction)
- self.trayIconMenu.addAction(self.dis_connectAction)
+ 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.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 +98,26 @@ 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)
+ 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.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 +125,33 @@ 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:
+ self.hide()
+ else:
+ self.show()
+
def about(self):
# move to widget
- QtGui.QMessageBox.about(self, "About",
- "Running LEAP client<br>"
- "version <b>%s</b>" % VERSION)
+ flavor = BRANDING.get('short_name', None)
+ content = ("LEAP client<br>"
+ "(version <b>%s</b>)<br>" % VERSION)
+ if flavor:
+ content = content + ('<br>Flavor: <i>%s</i><br>' % flavor)
+ content = content + (
+ "<br><a href='https://leap.se/'>"
+ "https://leap.se</a>")
+ QtGui.QMessageBox.about(self, "About", content)
def setConnWidget(self, icon_name):
oldlayout = self.statusIconBox.layout()
@@ -132,7 +164,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)
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()