summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/gui')
-rw-r--r--src/leap/bitmask/gui/eip_status.py28
-rw-r--r--src/leap/bitmask/gui/mail_status.py29
-rw-r--r--src/leap/bitmask/gui/mainwindow.py22
-rw-r--r--src/leap/bitmask/gui/systray.py49
4 files changed, 88 insertions, 40 deletions
diff --git a/src/leap/bitmask/gui/eip_status.py b/src/leap/bitmask/gui/eip_status.py
index 324586c0..c41d9706 100644
--- a/src/leap/bitmask/gui/eip_status.py
+++ b/src/leap/bitmask/gui/eip_status.py
@@ -26,6 +26,7 @@ from PySide import QtCore, QtGui
from leap.bitmask.services.eip.connection import EIPConnection
from leap.bitmask.services.eip.vpnprocess import VPNManager
+from leap.bitmask.services import get_service_display_name, EIP_SERVICE
from leap.bitmask.platform_init import IS_LINUX
from leap.bitmask.util.averages import RateMovingAverage
from leap.common.check import leap_assert_type
@@ -58,6 +59,7 @@ class EIPStatusWidget(QtGui.QWidget):
# set systray tooltip status
self._eip_status = ""
+ self._service_name = get_service_display_name(EIP_SERVICE)
self.ui.eip_bandwidth.hide()
@@ -181,21 +183,22 @@ class EIPStatusWidget(QtGui.QWidget):
def set_systray(self, systray):
"""
- Sets the systray object to use.
+ Sets the systray object to use and adds the service line for EIP.
:param systray: Systray object
:type systray: QtGui.QSystemTrayIcon
"""
leap_assert_type(systray, QtGui.QSystemTrayIcon)
self._systray = systray
- self._systray.setToolTip(self.tr("All services are OFF"))
+ eip_status = self.tr("{0}: OFF").format(self._service_name)
+ self._systray.set_service_tooltip(EIP_SERVICE, eip_status)
def _update_systray_tooltip(self):
"""
- Updates the system tray icon tooltip using the eip and mx status.
+ Updates the system tray tooltip using the eip status.
"""
- status = self.tr("Encrypted Internet: {0}").format(self._eip_status)
- self._systray.setToolTip(status)
+ eip_status = u"{0}: {1}".format(self._service_name, self._eip_status)
+ self._systray.set_service_tooltip(EIP_SERVICE, eip_status)
def set_action_eip_startstop(self, action_eip_startstop):
"""
@@ -245,7 +248,7 @@ class EIPStatusWidget(QtGui.QWidget):
# probably the best thing would be to make a transitional
# transition there, but that's more involved.
self.eip_button.hide()
- msg = self.tr("You must login to use Encrypted Internet")
+ msg = self.tr("You must login to use {0}".format(self._service_name))
self.eip_label.setText(msg)
@QtCore.Slot()
@@ -393,10 +396,8 @@ class EIPStatusWidget(QtGui.QWidget):
# the UI won't update properly
QtCore.QTimer.singleShot(
0, self.eipconnection.qtsigs.do_disconnect_signal)
- QtCore.QTimer.singleShot(0, partial(self.set_eip_status,
- self.tr("Unable to start VPN, "
- "it's already "
- "running.")))
+ msg = self.tr("Unable to start VPN, it's already running.")
+ QtCore.QTimer.singleShot(0, partial(self.set_eip_status, msg))
else:
self.set_eip_status(status)
@@ -418,14 +419,15 @@ class EIPStatusWidget(QtGui.QWidget):
"""
selected_pixmap = self.ERROR_ICON
selected_pixmap_tray = self.ERROR_ICON_TRAY
- tray_message = self.tr("Encrypted Internet: OFF")
+ tray_message = self.tr("{0}: OFF".format(self._service_name))
if status in ("WAIT", "AUTH", "GET_CONFIG",
"RECONNECTING", "ASSIGN_IP"):
selected_pixmap = self.CONNECTING_ICON
selected_pixmap_tray = self.CONNECTING_ICON_TRAY
- tray_message = self.tr("Encrypted Internet: Starting...")
+ tray_message = self.tr("{0}: Starting...").format(
+ self._service_name)
elif status in ("CONNECTED"):
- tray_message = self.tr("Encrypted Internet: ON")
+ tray_message = self.tr("{0}: ON".format(self._service_name))
selected_pixmap = self.CONNECTED_ICON
selected_pixmap_tray = self.CONNECTED_ICON_TRAY
self._eip_status = 'ON'
diff --git a/src/leap/bitmask/gui/mail_status.py b/src/leap/bitmask/gui/mail_status.py
index d637fd52..e89fb376 100644
--- a/src/leap/bitmask/gui/mail_status.py
+++ b/src/leap/bitmask/gui/mail_status.py
@@ -22,6 +22,7 @@ import logging
from PySide import QtCore, QtGui
from leap.bitmask.platform_init import IS_LINUX
+from leap.bitmask.services import get_service_display_name, MX_SERVICE
from leap.common.check import leap_assert, leap_assert_type
from leap.common.events import register
from leap.common.events import events_pb2 as proto
@@ -58,6 +59,7 @@ class MailStatusWidget(QtGui.QWidget):
# set systray tooltip status
self._mx_status = ""
+ self._service_name = get_service_display_name(MX_SERVICE)
# Set the Mail status icons
self.CONNECTING_ICON = None
@@ -150,29 +152,22 @@ class MailStatusWidget(QtGui.QWidget):
def set_systray(self, systray):
"""
- Sets the systray object to use.
+ Sets the systray object to use and adds the service line for MX.
:param systray: Systray object
:type systray: QtGui.QSystemTrayIcon
"""
leap_assert_type(systray, QtGui.QSystemTrayIcon)
self._systray = systray
- self._systray.setToolTip(self.tr("All services are OFF"))
+ mx_status = self.tr("{0}: OFF").format(self._service_name)
+ self._systray.set_service_tooltip(MX_SERVICE, mx_status)
def _update_systray_tooltip(self):
"""
- Updates the system tray icon tooltip using the eip and mx status.
+ Updates the system tray tooltip using the mx status.
"""
- # TODO: Figure out how to handle this with the two status in different
- # classes
- # XXX right now we could connect the state transition signals of the
- # two connection machines (EIP/Mail) to a class that keeps track of the
- # state -- kali
- # status = self.tr("Encrypted Internet: {0}").format(self._eip_status)
- # status += '\n'
- # status += self.tr("Mail is {0}").format(self._mx_status)
- # self._systray.setToolTip(status)
- pass
+ mx_status = u"{0}: {1}".format(self._service_name, self._mx_status)
+ self._systray.set_service_tooltip(MX_SERVICE, mx_status)
def set_action_mail_status(self, action_mail_status):
"""
@@ -213,7 +208,8 @@ class MailStatusWidget(QtGui.QWidget):
icon = self.ERROR_ICON
if ready == 0:
self.ui.lblMailStatus.setText(
- self.tr("You must be logged in to use encrypted email."))
+ self.tr("You must be logged in to use {0}.").format(
+ self._service_name))
elif ready == 1:
icon = self.CONNECTING_ICON
self._mx_status = self.tr('Starting..')
@@ -436,5 +432,6 @@ class MailStatusWidget(QtGui.QWidget):
Displays the correct UI for the disabled state.
"""
self._disabled = True
- self._set_mail_status(
- self.tr("You must be logged in to use encrypted email."), -1)
+ status = self.tr("You must be logged in to use {0}.").format(
+ self._service_name)
+ self._set_mail_status(status, -1)
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index 91bbe9cb..f3043809 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -36,6 +36,7 @@ from leap.bitmask.gui import statemachines
from leap.bitmask.gui.eip_status import EIPStatusWidget
from leap.bitmask.gui.mail_status import MailStatusWidget
from leap.bitmask.gui.wizard import Wizard
+from leap.bitmask.gui.systray import SysTray
from leap.bitmask import provider
from leap.bitmask.platform_init import IS_WIN, IS_MAC
@@ -44,6 +45,7 @@ from leap.bitmask.provider.providerbootstrapper import ProviderBootstrapper
from leap.bitmask.services.mail import conductor as mail_conductor
+from leap.bitmask.services import EIP_SERVICE, MX_SERVICE
from leap.bitmask.services.eip import eipconfig
from leap.bitmask.services.eip import get_openvpn_management
from leap.bitmask.services.eip.eipbootstrapper import EIPBootstrapper
@@ -86,9 +88,6 @@ class MainWindow(QtGui.QMainWindow):
LOGIN_INDEX = 0
EIP_STATUS_INDEX = 1
- OPENVPN_SERVICE = "openvpn"
- MX_SERVICE = "mx"
-
# Signals
eip_needs_login = QtCore.Signal([])
new_updates = QtCore.Signal(object)
@@ -597,8 +596,8 @@ class MainWindow(QtGui.QMainWindow):
for service in provider_config.get_services():
services.add(service)
- self.ui.eipWidget.setVisible(self.OPENVPN_SERVICE in services)
- self.ui.mailWidget.setVisible(self.MX_SERVICE in services)
+ self.ui.eipWidget.setVisible(EIP_SERVICE in services)
+ self.ui.mailWidget.setVisible(MX_SERVICE in services)
#
# systray
@@ -628,12 +627,13 @@ class MainWindow(QtGui.QMainWindow):
systrayMenu.addAction(self._action_mail_status)
systrayMenu.addSeparator()
systrayMenu.addAction(self.ui.action_quit)
- self._systray = QtGui.QSystemTrayIcon(self)
+ self._systray = SysTray(self)
self._systray.setContextMenu(systrayMenu)
self._systray.setIcon(self._eip_status.ERROR_ICON_TRAY)
self._systray.setVisible(True)
self._systray.activated.connect(self._tray_activated)
+ self._mail_status.set_systray(self._systray)
self._eip_status.set_systray(self._systray)
def _tray_activated(self, reason=None):
@@ -936,7 +936,7 @@ class MainWindow(QtGui.QMainWindow):
# TODO separate UI from logic.
# TODO soledad should check if we want to run only over EIP.
if self._provider_config.provides_mx() and \
- self._enabled_services.count(self.MX_SERVICE) > 0:
+ self._enabled_services.count(MX_SERVICE) > 0:
self._mail_status.about_to_start()
self._soledad_bootstrapper.run_soledad_setup_checks(
@@ -1037,7 +1037,7 @@ class MainWindow(QtGui.QMainWindow):
# TODO for simmetry, this should be called start_smtp_service
# (and delegate all the checks to the conductor)
if self._provider_config.provides_mx() and \
- self._enabled_services.count(self.MX_SERVICE) > 0:
+ self._enabled_services.count(MX_SERVICE) > 0:
self._mail_conductor.smtp_bootstrapper.run_smtp_setup_checks(
self._provider_config,
self._mail_conductor.smtp_config,
@@ -1066,7 +1066,7 @@ class MainWindow(QtGui.QMainWindow):
self.soledad_ready
"""
if self._provider_config.provides_mx() and \
- self._enabled_services.count(self.MX_SERVICE) > 0:
+ self._enabled_services.count(MX_SERVICE) > 0:
self._mail_conductor.start_imap_service()
def _on_mail_client_logged_in(self, req):
@@ -1416,7 +1416,7 @@ class MainWindow(QtGui.QMainWindow):
provider_config = self._get_best_provider_config()
if provider_config.provides_eip() and \
- self._enabled_services.count(self.OPENVPN_SERVICE) > 0 and \
+ self._enabled_services.count(EIP_SERVICE) > 0 and \
not self._already_started_eip:
# XXX this should be handled by the state machine.
@@ -1427,7 +1427,7 @@ class MainWindow(QtGui.QMainWindow):
download_if_needed=True)
self._already_started_eip = True
elif not self._already_started_eip:
- if self._enabled_services.count(self.OPENVPN_SERVICE) > 0:
+ if self._enabled_services.count(EIP_SERVICE) > 0:
self._eip_status.set_eip_status(
self.tr("Not supported"),
error=True)
diff --git a/src/leap/bitmask/gui/systray.py b/src/leap/bitmask/gui/systray.py
new file mode 100644
index 00000000..d30b5f32
--- /dev/null
+++ b/src/leap/bitmask/gui/systray.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+# systray.py
+# Copyright (C) 2013 LEAP
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Custom system tray manager.
+"""
+
+from PySide import QtGui
+
+from leap.common.check import leap_assert_type
+
+
+class SysTray(QtGui.QSystemTrayIcon):
+ """
+ Custom system tray that allows us to use a more 'intelligent' tooltip.
+ """
+
+ def __init__(self, parent=None):
+ QtGui.QSystemTrayIcon.__init__(self, parent)
+ self._services = {}
+
+ def set_service_tooltip(self, service, tooltip):
+ """
+ Sets the service tooltip.
+
+ :param service: service name identifier
+ :type service: unicode
+ :param tooltip: tooltip to display for that service
+ :type tooltip: unicode
+ """
+ leap_assert_type(service, unicode)
+ leap_assert_type(tooltip, unicode)
+
+ self._services[service] = tooltip
+ tooltip = "\n".join(self._services.values())
+ self.setToolTip(tooltip)