summaryrefslogtreecommitdiff
path: root/src/leap/baseapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/baseapp')
-rw-r--r--src/leap/baseapp/dialogs.py9
-rw-r--r--src/leap/baseapp/eip.py25
-rw-r--r--src/leap/baseapp/log.py20
-rw-r--r--src/leap/baseapp/mainwindow.py23
-rw-r--r--src/leap/baseapp/network.py24
-rw-r--r--src/leap/baseapp/systray.py60
6 files changed, 113 insertions, 48 deletions
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 55ecfa79..4c1fb32d 100644
--- a/src/leap/baseapp/eip.py
+++ b/src/leap/baseapp/eip.py
@@ -9,6 +9,8 @@ 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
+from leap.util import geo
logger = logging.getLogger(name=__name__)
@@ -21,6 +23,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')
@@ -93,6 +96,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
@@ -104,6 +116,7 @@ class EIPConductorAppMixin(object):
# launching dialog.
# (so Qt tests can assert stuff)
+
if error.critical:
logger.critical(error.message)
#critical error (non recoverable),
@@ -112,6 +125,7 @@ class EIPConductorAppMixin(object):
ErrorDialog(errtype="critical",
msg=message,
label="critical error")
+
elif error.warning:
logger.warning(error.message)
@@ -162,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
@@ -174,6 +190,11 @@ 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()
+ 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):
"""
@@ -195,7 +216,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 +230,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..636e5bae 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):
"""
@@ -21,7 +22,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,9 +35,10 @@ 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('')
+ self.remote_country = QtGui.QLabel('')
tun_read_label = QtGui.QLabel("tun read")
self.tun_read_bytes = QtGui.QLabel("0")
@@ -47,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)
@@ -60,6 +63,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/mainwindow.py b/src/leap/baseapp/mainwindow.py
index 02adab65..b1e5bccf 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__(
@@ -100,11 +100,11 @@ 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(
- lambda: self.init_network_checker(self.provider_domain))
+ lambda: self.init_network_checker(self.conductor.provider))
# status change.
# TODO unify
@@ -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):
@@ -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)
@@ -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()
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()
diff --git a/src/leap/baseapp/systray.py b/src/leap/baseapp/systray.py
index 0dd0f195..77eb3fe9 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)
@@ -73,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'])
@@ -81,7 +84,8 @@ class StatusAwareTrayIconMixin(object):
statusIconLayout.itemAt(1).widget().hide()
statusIconLayout.itemAt(2).widget().hide()
- self.leapConnStatus = QtGui.QLabel("<b>disconnected</b>")
+ self.leapConnStatus = QtGui.QLabel(
+ self.tr("<b>disconnected</b>"))
statusIconLayout.addWidget(self.leapConnStatus)
self.statusIconBox.setLayout(statusIconLayout)
@@ -111,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.
@@ -139,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):
@@ -156,18 +168,21 @@ class StatusAwareTrayIconMixin(object):
self.hide()
else:
self.show()
+ if sys.platform == "darwin":
+ self.raise_()
def about(self):
# move to widget
flavor = BRANDING.get('short_name', None)
- content = ("LEAP client<br>"
- "(version <b>%s</b>)<br>" % VERSION)
+ content = self.tr(
+ ("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)
+ QtGui.QMessageBox.about(self, self.tr("About"), content)
def setConnWidget(self, icon_name):
oldlayout = self.statusIconBox.layout()
@@ -205,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()