diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/bitmask/app.py | 2 | ||||
-rw-r--r-- | src/leap/bitmask/gui/mainwindow.py | 11 | ||||
-rw-r--r-- | src/leap/bitmask/gui/statuspanel.py | 50 | ||||
-rw-r--r-- | src/leap/bitmask/services/eip/vpnlaunchers.py | 8 | ||||
-rw-r--r-- | src/leap/bitmask/util/polkit_agent.py | 24 | ||||
-rw-r--r-- | src/leap/bitmask/util/tests/test_is_release_version.py | 2 |
6 files changed, 68 insertions, 29 deletions
diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index 0dce5e61..158f1afe 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -156,7 +156,7 @@ def main(): from leap.bitmask.gui.mainwindow import MainWindow from leap.bitmask.platform_init import IS_MAC from leap.bitmask.platform_init.locks import we_are_the_one_and_only - from leap.bitmask.util import __version__ as VERSION + from leap.bitmask import __version__ as VERSION from leap.bitmask.util.requirement_checker import check_requirements # pylint: avoid unused import diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 1fdd0792..0950462b 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -58,7 +58,7 @@ from leap.bitmask.services.eip.vpnlaunchers import \ EIPNoPolkitAuthAgentAvailable from leap.bitmask.services.eip.vpnlaunchers import EIPNoTunKextLoaded -from leap.bitmask.util import __version__ as VERSION +from leap.bitmask import __version__ as VERSION from leap.bitmask.util.keyring_helpers import has_keyring from leap.bitmask.util.leap_log_handler import LeapLogHandler @@ -254,14 +254,20 @@ class MainWindow(QtGui.QMainWindow): self._action_eip_provider = QtGui.QAction( self.tr("No default provider"), self) self._action_eip_provider.setEnabled(False) + self._action_eip_status = QtGui.QAction( self.tr("Encrypted internet is OFF"), self) self._action_eip_status.setEnabled(False) - self._status_panel.set_action_eip_status( self._action_eip_status) + self._action_mail_status = QtGui.QAction( + self.tr("Encrypted Mail is OFF"), self) + self._action_mail_status.setEnabled(False) + self._status_panel.set_action_mail_status( + self._action_mail_status) + self._action_eip_startstop = QtGui.QAction( self.tr("Turn OFF"), self) self._action_eip_startstop.triggered.connect( @@ -623,6 +629,7 @@ class MainWindow(QtGui.QMainWindow): systrayMenu.addAction(self._action_eip_provider) systrayMenu.addAction(self._action_eip_status) systrayMenu.addAction(self._action_eip_startstop) + systrayMenu.addAction(self._action_mail_status) systrayMenu.addSeparator() systrayMenu.addAction(self._action_preferences) systrayMenu.addAction(help_action) diff --git a/src/leap/bitmask/gui/statuspanel.py b/src/leap/bitmask/gui/statuspanel.py index 49d7e24a..3a91f08e 100644 --- a/src/leap/bitmask/gui/statuspanel.py +++ b/src/leap/bitmask/gui/statuspanel.py @@ -356,6 +356,16 @@ class StatusPanelWidget(QtGui.QWidget): leap_assert_type(action_eip_status, QtGui.QAction) self._action_eip_status = action_eip_status + def set_action_mail_status(self, action_mail_status): + """ + Sets the action_mail_status to use. + + :param action_mail_status: action_mail_status to be used + :type action_mail_status: QtGui.QAction + """ + leap_assert_type(action_mail_status, QtGui.QAction) + self._action_mail_status = action_mail_status + def set_global_status(self, status, error=False): """ Sets the global status label. @@ -538,6 +548,27 @@ class StatusPanelWidget(QtGui.QWidget): def set_provider(self, provider): self.ui.lblProvider.setText(provider) + def _set_mail_status(self, status, ready=False): + """ + Sets the Encrypted Mail status in the label and in the tray icon. + + :param status: the status text to display + :type status: unicode + :param ready: if mx is ready or not. + :type ready: bool + """ + self.ui.lblMailStatus.setText(status) + + tray_status = self.tr('Encrypted Mail is OFF') + + icon = QtGui.QPixmap(self.MAIL_OFF_ICON) + if ready: + icon = QtGui.QPixmap(self.MAIL_ON_ICON) + tray_status = self.tr('Encrypted Mail is ON') + + self.ui.lblMailIcon.setPixmap(icon) + self._action_mail_status.setText(tray_status) + def _mail_handle_soledad_events(self, req): """ Callback for ... @@ -557,7 +588,7 @@ class StatusPanelWidget(QtGui.QWidget): :param req: Request type :type req: leap.common.events.events_pb2.SignalRequest """ - self.ui.lblMailStatus.setText(self.tr("Starting...")) + self._set_mail_status(self.tr("Starting...")) ext_status = "" @@ -596,7 +627,7 @@ class StatusPanelWidget(QtGui.QWidget): if self._smtp_started and self._imap_started: return - self.ui.lblMailStatus.setText(self.tr("Starting...")) + self._set_mail_status(self.tr("Starting...")) ext_status = "" @@ -644,14 +675,11 @@ class StatusPanelWidget(QtGui.QWidget): ext_status = self.tr("SMTP has started...") self._smtp_started = True if self._smtp_started and self._imap_started: - self.ui.lblMailStatus.setText(self.tr("ON")) - self.ui.lblMailIcon.setPixmap(QtGui.QPixmap(self.MAIL_ON_ICON)) - self.ui.lblMailIcon.setPixmap( - QtGui.QPixmap(":/images/mail-locked.png")) + self._set_mail_status(self.tr("ON"), ready=True) ext_status = "" elif req.event == proto.SMTP_SERVICE_FAILED_TO_START: ext_status = self.tr("SMTP failed to start, check the logs.") - self.ui.lblMailStatus.setText(self.tr("Failed")) + self._set_mail_status(self.tr("Failed")) else: leap_assert(False, "Don't know how to handle this state: %s" @@ -684,19 +712,17 @@ class StatusPanelWidget(QtGui.QWidget): ext_status = self.tr("IMAP has started...") self._imap_started = True if self._smtp_started and self._imap_started: - self.ui.lblMailStatus.setText(self.tr("ON")) - self.ui.lblMailIcon.setPixmap(QtGui.QPixmap(self.MAIL_ON_ICON)) + self._set_mail_status(self.tr("ON"), ready=True) ext_status = "" elif req.event == proto.IMAP_SERVICE_FAILED_TO_START: ext_status = self.tr("IMAP failed to start, check the logs.") - self.ui.lblMailStatus.setText(self.tr("Failed")) + self._set_mail_status(self.tr("Failed")) elif req.event == proto.IMAP_UNREAD_MAIL: if self._smtp_started and self._imap_started: self.ui.lblUnread.setText( self.tr("%s Unread Emails") % (req.content)) self.ui.lblUnread.setVisible(req.content != "0") - self.ui.lblMailStatus.setText(self.tr("ON")) - self.ui.lblMailIcon.setPixmap(QtGui.QPixmap(self.MAIL_ON_ICON)) + self._set_mail_status(self.tr("ON"), ready=True) else: leap_assert(False, "Don't know how to handle this state: %s" diff --git a/src/leap/bitmask/services/eip/vpnlaunchers.py b/src/leap/bitmask/services/eip/vpnlaunchers.py index 49edc8eb..a50da8b9 100644 --- a/src/leap/bitmask/services/eip/vpnlaunchers.py +++ b/src/leap/bitmask/services/eip/vpnlaunchers.py @@ -32,6 +32,7 @@ except ImportError: from abc import ABCMeta, abstractmethod from functools import partial +from time import sleep from leap.bitmask.config.leapsettings import LeapSettings @@ -228,7 +229,11 @@ def _try_to_launch_agent(standalone=False): env = { "PYTHONPATH": os.path.abspath('../../../../lib/')} try: - subprocess.call(["python", "-m", "leap.bitmask.util.polkit_agent"], + # We need to quote the command because subprocess call + # will do "sh -c 'foo'", so if we do not quoute it we'll end + # up with a invocation to the python interpreter. And that + # is bad. + subprocess.call(["python -m leap.bitmask.util.polkit_agent"], shell=True, env=env) except Exception as exc: logger.exception(exc) @@ -316,6 +321,7 @@ class LinuxVPNLauncher(VPNLauncher): if _is_pkexec_in_system(): if not _is_auth_agent_running(): _try_to_launch_agent(ProviderConfig.standalone) + sleep(0.5) if _is_auth_agent_running(): pkexec_possibilities = which(kls.PKEXEC_BIN) leap_assert(len(pkexec_possibilities) > 0, diff --git a/src/leap/bitmask/util/polkit_agent.py b/src/leap/bitmask/util/polkit_agent.py index a4650273..6fda2f88 100644 --- a/src/leap/bitmask/util/polkit_agent.py +++ b/src/leap/bitmask/util/polkit_agent.py @@ -24,24 +24,24 @@ import daemon logger = logging.getLogger(__name__) -BASE_PATH = "/usr/lib/policykit-1-gnome/"\ - + "polkit-%s-authentication-agent-1" - -GNOME_PATH = BASE_PATH % ("gnome",) -KDE_PATH = BASE_PATH % ("kde",) +AUTH_FILE = "polkit-%s-authentication-agent-1" +BASE_PATH_GNO = "/usr/lib/policykit-1-gnome/" +BASE_PATH_KDE = "/usr/lib/kde4/libexec/" +GNO_PATH = BASE_PATH_GNO + AUTH_FILE % ("gnome",) +KDE_PATH = BASE_PATH_KDE + AUTH_FILE % ("kde",) def _launch_agent(): logger.debug('Launching polkit auth agent') - print "launching polkit" try: - subprocess.call(GNOME_PATH) + subprocess.call(GNO_PATH) except Exception as exc: - try: - subprocess.call(KDE_PATH) - except Exception as exc: - logger.error('Exception while running polkit authentication agent ' - '%s' % (exc,)) + logger.error('Exception while running polkit authentication agent ' + '%s' % (exc,)) + # XXX fix KDE launch. See: #3755 + #try: + #subprocess.call(KDE_PATH) + #except Exception as exc: def launch(): diff --git a/src/leap/bitmask/util/tests/test_is_release_version.py b/src/leap/bitmask/util/tests/test_is_release_version.py index 088ec66d..0a0093da 100644 --- a/src/leap/bitmask/util/tests/test_is_release_version.py +++ b/src/leap/bitmask/util/tests/test_is_release_version.py @@ -19,7 +19,7 @@ tests for _is_release_version function """ import unittest -from leap.bitmask.util import _is_release_version as is_release_version +from leap.bitmask import _is_release_version as is_release_version from leap.common.testing.basetest import BaseLeapTest |