summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-09-04 17:09:29 -0700
committerelijah <elijah@riseup.net>2014-09-19 14:23:14 -0700
commit4e7c4b48b4255ceac06900fa9e65824c52e15ba7 (patch)
tree2bdf6e00c02545239b97f09bdc90bbb7d7e73baa /src
parentc7304e54e40cd9151e6d00a8441aaf48b68c9bcc (diff)
single pref win: enabled/disable services via preferences window, account page.
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/gui/account.py43
-rw-r--r--src/leap/bitmask/gui/app.py68
-rw-r--r--src/leap/bitmask/gui/mainwindow.py87
-rw-r--r--src/leap/bitmask/gui/preferences_account_page.py103
-rw-r--r--src/leap/bitmask/gui/preferences_email_page.py7
-rw-r--r--src/leap/bitmask/gui/preferences_vpn_page.py54
-rw-r--r--src/leap/bitmask/gui/preferenceswindow.py90
-rw-r--r--src/leap/bitmask/gui/ui/preferences_account_page.ui67
-rw-r--r--src/leap/bitmask/services/eip/conductor.py6
9 files changed, 304 insertions, 221 deletions
diff --git a/src/leap/bitmask/gui/account.py b/src/leap/bitmask/gui/account.py
new file mode 100644
index 00000000..b08053a9
--- /dev/null
+++ b/src/leap/bitmask/gui/account.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) 2014 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/>.
+"""
+A frontend GUI object to hold the current username and domain.
+"""
+
+from leap.bitmask.util import make_address
+from leap.bitmask.config.leapsettings import LeapSettings
+
+class Account():
+
+ def __init__(self, username, domain):
+ self._settings = LeapSettings()
+ self.username = username
+ self.domain = domain
+
+ if self.username is not None:
+ self.address = make_address(self.username, self.domain)
+ else:
+ self.address = self.domain
+
+ def services(self):
+ """
+ returns a list of service name strings
+
+ TODO: this should depend not just on the domain
+ """
+ return self._settings.get_enabled_services(self.domain)
+
+
diff --git a/src/leap/bitmask/gui/app.py b/src/leap/bitmask/gui/app.py
new file mode 100644
index 00000000..7fcf69af
--- /dev/null
+++ b/src/leap/bitmask/gui/app.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) 2014 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/>.
+"""
+A single App instances holds the signals that are shared among different
+frontend UI components. The App also keeps a reference to the backend object
+and the signaler get signals from the backend.
+"""
+import logging
+
+from functools import partial
+from PySide import QtCore, QtGui
+
+from leap.bitmask.config.leapsettings import LeapSettings
+from leap.bitmask.backend.backend_proxy import BackendProxy
+from leap.bitmask.backend.leapsignaler import LeapSignaler
+
+logger = logging.getLogger(__name__)
+
+class App(QtGui.QWidget):
+
+ #preferences_saved = QtCore.Signal()
+
+ # the user has changed which services are enabled for a particular account
+ # args: account (Account), active services (list of str)
+ service_selection_changed = QtCore.Signal(object, list)
+
+ def __init__(self):
+ QtGui.QWidget.__init__(self)
+
+ self.settings = LeapSettings()
+ self.backend = BackendProxy()
+ self.signaler = LeapSignaler()
+ self.signaler.start()
+
+ # periodically check if the backend is alive
+ self._backend_checker = QtCore.QTimer(self)
+ self._backend_checker.timeout.connect(self._check_backend_status)
+ self._backend_checker.start(2000)
+
+
+ @QtCore.Slot()
+ def _check_backend_status(self):
+ """
+ TRIGGERS:
+ self._backend_checker.timeout
+
+ Check that the backend is running. Otherwise show an error to the user.
+ """
+ if not self.backend.online:
+ logger.critical("Backend is not online.")
+ QtGui.QMessageBox.critical(
+ self, self.tr("Application error"),
+ self.tr("There is a problem contacting the backend, please "
+ "restart Bitmask."))
+ self._backend_checker.stop()
diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py
index 243fe117..b106364d 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -45,6 +45,8 @@ from leap.bitmask.gui.preferenceswindow import PreferencesWindow
from leap.bitmask.gui.systray import SysTray
from leap.bitmask.gui.wizard import Wizard
from leap.bitmask.gui.providers import Providers
+from leap.bitmask.gui.account import Account
+from leap.bitmask.gui.app import App
from leap.bitmask.platform_init import IS_WIN, IS_MAC, IS_LINUX
from leap.bitmask.platform_init import locks
@@ -126,19 +128,10 @@ class MainWindow(QtGui.QMainWindow):
self.ui.setupUi(self)
self.menuBar().setNativeMenuBar(not IS_LINUX)
- self._backend = BackendProxy()
-
- # periodically check if the backend is alive
- self._backend_checker = QtCore.QTimer(self)
- self._backend_checker.timeout.connect(self._check_backend_status)
- self._backend_checker.start(2000)
-
- self._leap_signaler = LeapSignaler()
- self._leap_signaler.start()
-
- self._settings = LeapSettings()
- # gateway = self._settings.get_selected_gateway(provider)
- # self._backend.settings_set_selected_gateway(provider, gateway)
+ self.app = App()
+ self._backend = self.app.backend
+ self._leap_signaler = self.app.signaler
+ self._settings = self.app.settings
# Login Widget
self._login_widget = LoginWidget(self._settings, self)
@@ -154,6 +147,7 @@ class MainWindow(QtGui.QMainWindow):
# Qt Signal Connections #####################################
# TODO separate logic from ui signals.
+ self.app.service_selection_changed.connect(self._update_eip_enabled_status)
self._login_widget.login.connect(self._login)
self._login_widget.cancel_login.connect(self._cancel_login)
self._login_widget.logout.connect(self._logout)
@@ -245,9 +239,6 @@ class MainWindow(QtGui.QMainWindow):
self._action_visible = QtGui.QAction(self.tr("Show Main Window"), self)
self._action_visible.triggered.connect(self._ensure_visible)
- # disable buttons for now, may come back later.
- # self.ui.btnPreferences.clicked.connect(self._show_preferences)
-
self._enabled_services = []
self._ui_mx_visible = True
self._ui_eip_visible = True
@@ -342,23 +333,6 @@ class MainWindow(QtGui.QMainWindow):
logger.error("Bad call to the backend:")
logger.error(data)
- @QtCore.Slot()
- def _check_backend_status(self):
- """
- TRIGGERS:
- self._backend_checker.timeout
-
- Check that the backend is running. Otherwise show an error to the user.
- """
- online = self._backend.online
- if not online:
- logger.critical("Backend is not online.")
- QtGui.QMessageBox.critical(
- self, self.tr("Application error"),
- self.tr("There is a problem contacting the backend, please "
- "restart Bitmask."))
- self._backend_checker.stop()
-
def _backend_connect(self, only_tracked=False):
"""
Connect to backend signals.
@@ -598,21 +572,18 @@ class MainWindow(QtGui.QMainWindow):
Display the preferences window.
"""
- user = self._logged_user
- domain = self._providers.get_selected_provider()
+ account = Account(self._logged_user,
+ self._providers.get_selected_provider())
if self.preferences is not None:
self.preferences.close()
- self.preferences = PreferencesWindow(self, user, domain,
- self._backend,
- self._soledad_started,
- self._leap_signaler)
+ self.preferences = PreferencesWindow(self, account, self.app)
self.preferences.show()
- @QtCore.Slot()
- def _update_eip_enabled_status(self):
+ @QtCore.Slot(object, list)
+ def _update_eip_enabled_status(self, account=None, services=None):
"""
TRIGGER:
- PreferencesWindow.preferences_saved
+ App.service_selection_changed
Enable or disable the EIP start/stop actions and stop EIP if the user
disabled that service.
@@ -620,24 +591,35 @@ class MainWindow(QtGui.QMainWindow):
:returns: if the eip actions were enabled or disabled
:rtype: bool
"""
- settings = self._settings
- default_provider = settings.get_defaultprovider()
+ if account is not None:
+ domain = account.domain
+ else:
+ # I am not sure why, but asking for the currently selected
+ # provider here give you the WRONG provider
+ domain = self.app.settings.get_defaultprovider()
- if default_provider is None:
+ if domain is None:
logger.warning("Trying to update eip enabled status but there's no"
" default provider. Disabling EIP for the time"
" being...")
self._backend_cannot_start_eip()
return
- self._trying_to_start_eip = settings.get_autostart_eip()
- self._backend.eip_can_start(domain=default_provider)
+ if not EIP_SERVICE in self.app.settings.get_enabled_services(domain):
+ self._eip_conductor.terminate()
+ def hide():
+ self.app.backend.eip_can_start(domain=domain)
+ QtDelayedCall(100, hide)
+ # ^^ VERY VERY Hacky, but with the simple state machine,
+ # there is no way to signal 'disconnect and then disable'
+
+ else:
+ self._trying_to_start_eip = self.app.settings.get_autostart_eip()
+ if not self._trying_to_start_eip:
+ self._backend.eip_setup(provider=domain, skip_network=True)
+ # check if EIP can start (will trigger widget update)
+ self.app.backend.eip_can_start(domain=domain)
- # If we don't want to start eip, we leave everything
- # initialized to quickly start it
- if not self._trying_to_start_eip:
- self._backend.eip_setup(provider=default_provider,
- skip_network=True)
def _backend_can_start_eip(self):
"""
@@ -657,7 +639,6 @@ class MainWindow(QtGui.QMainWindow):
enabled_services = []
if default_provider is not None:
enabled_services = settings.get_enabled_services(default_provider)
-
eip_enabled = False
if EIP_SERVICE in enabled_services:
eip_enabled = True
diff --git a/src/leap/bitmask/gui/preferences_account_page.py b/src/leap/bitmask/gui/preferences_account_page.py
index 9cc94482..bb90aab5 100644
--- a/src/leap/bitmask/gui/preferences_account_page.py
+++ b/src/leap/bitmask/gui/preferences_account_page.py
@@ -22,35 +22,29 @@ from functools import partial
from PySide import QtCore, QtGui
from ui_preferences_account_page import Ui_PreferencesAccountPage
+from leap.bitmask.services import get_service_display_name
+from leap.bitmask.config.leapsettings import LeapSettings
logger = logging.getLogger(__name__)
class PreferencesAccountPage(QtGui.QWidget):
- """
- """
-
- def __init__(self, parent):
+ def __init__(self, parent, account, app):
"""
"""
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_PreferencesAccountPage()
self.ui.setupUi(self)
- self.show()
- self._selected_services = set()
- #self._leap_signaler.prov_get_supported_services.connect(self._load_services)
+ self.account = account
+ self.app = app
- @QtCore.Slot()
- def set_soledad_ready(self):
- """
- TRIGGERS:
- parent.soledad_ready
+ self._selected_services = set()
+ self.ui.change_password_label.setVisible(False)
+ self.ui.provider_services_label.setVisible(False)
- It notifies when the soledad object as ready to use.
- """
- #self.ui.lblPasswordChangeStatus.setVisible(False)
- #self.ui.gbPasswordChange.setEnabled(True)
+ app.signaler.prov_get_supported_services.connect(self._load_services)
+ app.backend.provider_get_supported_services(domain=account.domain)
@QtCore.Slot(str, int)
def _service_selection_changed(self, service, state):
@@ -72,94 +66,49 @@ class PreferencesAccountPage(QtGui.QWidget):
else:
self._selected_services = \
self._selected_services.difference(set([service]))
+ services = list(self._selected_services)
# We hide the maybe-visible status label after a change
- self.ui.lblProvidersServicesStatus.setVisible(False)
+ self.ui.provider_services_label.setVisible(False)
- @QtCore.Slot(str)
- def _populate_services(self, domain):
- """
- TRIGGERS:
- self.ui.cbProvidersServices.currentIndexChanged[unicode]
-
- Fill the services list with the selected provider's services.
-
- :param domain: the domain of the provider to load services from.
- :type domain: str
- """
- # We hide the maybe-visible status label after a change
- self.ui.lblProvidersServicesStatus.setVisible(False)
+ # write to config
+ self.app.settings.set_enabled_services(self.account.domain, services)
- if not domain:
- return
+ # emit signal alerting change
+ self.app.service_selection_changed.emit(self.account, services)
- # set the proper connection for the 'save' button
- try:
- self.ui.pbSaveServices.clicked.disconnect()
- except RuntimeError:
- pass # Signal was not connected
-
- save_services = partial(self._save_enabled_services, domain)
- self.ui.pbSaveServices.clicked.connect(save_services)
-
- self._backend.provider_get_supported_services(domain=domain)
@QtCore.Slot(str)
def _load_services(self, services):
"""
TRIGGERS:
- self.ui.cbProvidersServices.currentIndexChanged[unicode]
+ prov_get_supported_services
Loads the services that the provider provides into the UI for
the user to enable or disable.
- :param domain: the domain of the provider to load services from.
- :type domain: str
+ :param services: list of supported service names
+ :type services: list of str
"""
- domain = self.ui.cbProvidersServices.currentText()
- services_conf = self._settings.get_enabled_services(domain)
+ services_conf = self.account.services()
- # discard changes if other provider is selected
self._selected_services = set()
- # from: http://stackoverflow.com/a/13103617/687989
# remove existing checkboxes
- layout = self.ui.vlServices
+ layout = self.ui.provider_services_layout
for i in reversed(range(layout.count())):
layout.itemAt(i).widget().setParent(None)
- # add one checkbox per service and set the current configured value
+ # add one checkbox per service and set the current value
+ # from what is saved in settings.
for service in services:
try:
- checkbox = QtGui.QCheckBox(self)
- service_label = get_service_display_name(service)
- checkbox.setText(service_label)
-
- self.ui.vlServices.addWidget(checkbox)
+ checkbox = QtGui.QCheckBox(
+ get_service_display_name(service), self)
+ self.ui.provider_services_layout.addWidget(checkbox)
checkbox.stateChanged.connect(
partial(self._service_selection_changed, service))
-
checkbox.setChecked(service in services_conf)
except ValueError:
logger.error("Something went wrong while trying to "
"load service %s" % (service,))
-
- @QtCore.Slot(str)
- def _save_enabled_services(self, provider):
- """
- TRIGGERS:
- self.ui.pbSaveServices.clicked
-
- Saves the new enabled services settings to the configuration file.
-
- :param provider: the provider config that we need to save.
- :type provider: str
- """
- services = list(self._selected_services)
- self._settings.set_enabled_services(provider, services)
-
- msg = self.tr(
- "Services settings for provider '{0}' saved.".format(provider))
- logger.debug(msg)
- self._set_providers_services_status(msg, success=True)
- self.preferences_saved.emit()
diff --git a/src/leap/bitmask/gui/preferences_email_page.py b/src/leap/bitmask/gui/preferences_email_page.py
index 08ff5463..da902802 100644
--- a/src/leap/bitmask/gui/preferences_email_page.py
+++ b/src/leap/bitmask/gui/preferences_email_page.py
@@ -28,11 +28,14 @@ class PreferencesEmailPage(QtGui.QWidget):
"""
- def __init__(self, parent):
+ def __init__(self, parent, account, app):
"""
"""
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_PreferencesEmailPage()
self.ui.setupUi(self)
- self.show()
+
+ self.parent = parent
+ self.account = account
+ self.app = app
diff --git a/src/leap/bitmask/gui/preferences_vpn_page.py b/src/leap/bitmask/gui/preferences_vpn_page.py
index ba1366e4..a8f074d2 100644
--- a/src/leap/bitmask/gui/preferences_vpn_page.py
+++ b/src/leap/bitmask/gui/preferences_vpn_page.py
@@ -28,23 +28,22 @@ class PreferencesVpnPage(QtGui.QWidget):
Page in the preferences window that shows VPN settings
"""
- def __init__(self, parent, domain, backend, leap_signaler):
+ def __init__(self, parent, account, app):
"""
:param parent: parent object of the EIPPreferencesWindow.
:type parent: QWidget
- :param domain: the selected by default domain.
- :type domain: unicode
+ :param account: the currently active account
+ :type account: Account
- :param backend: Backend being used
- :type backend: Backend
+ :param app: shared App instance
+ :type app: App
"""
QtGui.QWidget.__init__(self, parent)
self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic")
- self._settings = LeapSettings()
- self._leap_signaler = leap_signaler
- self._backend = backend
+ self.account = account
+ self.app = app
# Load UI
self.ui = Ui_PreferencesVpnPage()
@@ -53,10 +52,14 @@ class PreferencesVpnPage(QtGui.QWidget):
# Connections
self.ui.gateways_list.clicked.connect(self._save_selected_gateway)
+ sig = self.app.signaler
+ sig.eip_get_gateways_list.connect(self._update_gateways_list)
+ sig.eip_get_gateways_list_error.connect(self._gateways_list_error)
+ sig.eip_uninitialized_provider.connect(
+ self._gateways_list_uninitialized)
- self._domain = domain
- self._backend_connect()
- self._backend.eip_get_gateways_list(domain=domain)
+ # Trigger update
+ self.app.backend.eip_get_gateways_list(domain=self.account.domain)
def _flash_error(self, message):
"""
@@ -94,12 +97,13 @@ class PreferencesVpnPage(QtGui.QWidget):
item = self.ui.gateways_list.currentItem()
if item.text() == self.AUTOMATIC_GATEWAY_LABEL:
- gateway = self._settings.GATEWAY_AUTOMATIC
+ gateway = self.app.settings.GATEWAY_AUTOMATIC
else:
gateway = item.data(QtCore.Qt.UserRole)
- self._settings.set_selected_gateway(self._domain, gateway)
- self._backend.settings_set_selected_gateway(provider=self._domain,
- gateway=gateway)
+ self.app.settings.set_selected_gateway(self.account.domain, gateway)
+ self.app.backend.settings_set_selected_gateway(
+ provider=self.account.domain,
+ gateway=gateway)
@QtCore.Slot(list)
def _update_gateways_list(self, gateways):
@@ -116,8 +120,8 @@ class PreferencesVpnPage(QtGui.QWidget):
self.ui.gateways_list.clear()
self.ui.gateways_list.addItem(self.AUTOMATIC_GATEWAY_LABEL)
- selected_gateway = self._settings.get_selected_gateway(
- self._domain)
+ selected_gateway = self.app.settings.get_selected_gateway(
+ self.account.domain)
index = 0
for idx, (gw_name, gw_ip, gw_country) in enumerate(gateways):
@@ -144,7 +148,15 @@ class PreferencesVpnPage(QtGui.QWidget):
self.tr("Error loading configuration file."))
self.ui.gateways_list.setEnabled(False)
- def _backend_connect(self):
- sig = self._leap_signaler
- sig.eip_get_gateways_list.connect(self._update_gateways_list)
- sig.eip_get_gateways_list_error.connect(self._gateways_list_error)
+ @QtCore.Slot()
+ def _gateways_list_uninitialized(self):
+ """
+ TRIGGERS:
+ Signaler.eip_uninitialized_provider
+
+ The requested provider in not initialized yet, so we give the user an
+ error msg.
+ """
+ self._flash_error(
+ self.tr("This is an uninitialized provider, please log in first."))
+ self.ui.gateways_list.setEnabled(False)
diff --git a/src/leap/bitmask/gui/preferenceswindow.py b/src/leap/bitmask/gui/preferenceswindow.py
index a9c301c4..35a875fa 100644
--- a/src/leap/bitmask/gui/preferenceswindow.py
+++ b/src/leap/bitmask/gui/preferenceswindow.py
@@ -22,16 +22,13 @@ import logging
from PySide import QtCore, QtGui
-from leap.bitmask.config.leapsettings import LeapSettings
+from leap.bitmask.services import EIP_SERVICE, MX_SERVICE
from leap.bitmask.gui.ui_preferences import Ui_Preferences
-
from leap.bitmask.gui.preferences_account_page import PreferencesAccountPage
from leap.bitmask.gui.preferences_vpn_page import PreferencesVpnPage
from leap.bitmask.gui.preferences_email_page import PreferencesEmailPage
-from leap.bitmask.services import get_service_display_name, MX_SERVICE
-
logger = logging.getLogger(__name__)
@@ -39,9 +36,8 @@ class PreferencesWindow(QtGui.QDialog):
"""
Window that displays the preferences.
"""
- preferences_saved = QtCore.Signal()
- def __init__(self, parent, username, domain, backend, soledad_started, leap_signaler):
+ def __init__(self, parent, account, app):
"""
:param parent: parent object of the PreferencesWindow.
:parent type: QWidget
@@ -51,30 +47,26 @@ class PreferencesWindow(QtGui.QDialog):
:type domain: unicode
:param backend: Backend being used
:type backend: Backend
- :param soledad_started: whether soledad has started or not
- :type soledad_started: bool
:param leap_signaler: signal server
:type leap_signaler: LeapSignaler
"""
QtGui.QDialog.__init__(self, parent)
self._parent = parent
- self._username = username
- self._domain = domain
- self._leap_signaler = leap_signaler
- self._backend = backend
- self._soledad_started = soledad_started
-
- self._settings = LeapSettings()
+ self.account = account
+ self.app = app
- # Load UI
self.ui = Ui_Preferences()
self.ui.setupUi(self)
self.ui.close_button.clicked.connect(self.close)
+ self.ui.account_label.setText(account.address)
+
+ self.app.service_selection_changed.connect(self._update_icons)
self._add_icons()
self._add_pages()
+ self._update_icons(self.account, self.account.services())
def _add_icons(self):
"""
@@ -86,26 +78,31 @@ class PreferencesWindow(QtGui.QDialog):
icon_width = list_widget.width - (2 x nav_widget.spacing) - 2
icon_height = 56 seems to look ok
"""
- account_button = QtGui.QListWidgetItem(self.ui.nav_widget)
- account_button.setIcon(QtGui.QIcon(":/images/black/32/user.png"))
- account_button.setText(self.tr("Account"))
- account_button.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
- account_button.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
- account_button.setSizeHint(QtCore.QSize(98,56))
-
- vpn_button = QtGui.QListWidgetItem(self.ui.nav_widget)
- vpn_button.setIcon(QtGui.QIcon(":/images/black/32/earth.png"))
- vpn_button.setText(self.tr("VPN"))
- vpn_button.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
- vpn_button.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
- vpn_button.setSizeHint(QtCore.QSize(98,56))
-
- email_button = QtGui.QListWidgetItem(self.ui.nav_widget)
- email_button.setIcon(QtGui.QIcon(":/images/black/32/email.png"))
- email_button.setText(self.tr("Email"))
- email_button.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
- email_button.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
- email_button.setSizeHint(QtCore.QSize(98,56))
+ account_item = QtGui.QListWidgetItem(self.ui.nav_widget)
+ account_item.setIcon(QtGui.QIcon(":/images/black/32/user.png"))
+ account_item.setText(self.tr("Account"))
+ account_item.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
+ account_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
+ account_item.setSizeHint(QtCore.QSize(98,56))
+ self._account_item = account_item
+
+ vpn_item = QtGui.QListWidgetItem(self.ui.nav_widget)
+ vpn_item.setHidden(True)
+ vpn_item.setIcon(QtGui.QIcon(":/images/black/32/earth.png"))
+ vpn_item.setText(self.tr("VPN"))
+ vpn_item.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
+ vpn_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
+ vpn_item.setSizeHint(QtCore.QSize(98,56))
+ self._vpn_item = vpn_item
+
+ email_item = QtGui.QListWidgetItem(self.ui.nav_widget)
+ email_item.setHidden(True)
+ email_item.setIcon(QtGui.QIcon(":/images/black/32/email.png"))
+ email_item.setText(self.tr("Email"))
+ email_item.setTextAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
+ email_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
+ email_item.setSizeHint(QtCore.QSize(98,56))
+ self._email_item = email_item
self.ui.nav_widget.currentItemChanged.connect(self._change_page)
self.ui.nav_widget.setCurrentRow(0)
@@ -114,9 +111,9 @@ class PreferencesWindow(QtGui.QDialog):
"""
Adds the pages for the different configuration categories.
"""
- self.ui.pages_widget.addWidget(PreferencesAccountPage(self))
- self.ui.pages_widget.addWidget(PreferencesVpnPage(self, self._domain, self._backend, self._leap_signaler))
- self.ui.pages_widget.addWidget(PreferencesEmailPage(self))
+ self.ui.pages_widget.addWidget(PreferencesAccountPage(self, self.account, self.app))
+ self.ui.pages_widget.addWidget(PreferencesVpnPage(self, self.account, self.app))
+ self.ui.pages_widget.addWidget(PreferencesEmailPage(self, self.account, self.app))
#
# Slots
@@ -144,3 +141,18 @@ class PreferencesWindow(QtGui.QDialog):
if not current:
current = previous
self.ui.pages_widget.setCurrentIndex(self.ui.nav_widget.row(current))
+
+ @QtCore.Slot(object, list)
+ def _update_icons(self, account, services):
+ """
+ TRIGGERS:
+ self.app.service_selection_changed
+
+ Change which icons are visible.
+ """
+ if account != self.account:
+ return
+
+ self._vpn_item.setHidden(not EIP_SERVICE in services)
+ #self._email_item.setHidden(not MX_SERVICE in services)
+ # ^^ disable email for now, there is nothing there yet.
diff --git a/src/leap/bitmask/gui/ui/preferences_account_page.ui b/src/leap/bitmask/gui/ui/preferences_account_page.ui
index 4e58b2ab..9b6d885b 100644
--- a/src/leap/bitmask/gui/ui/preferences_account_page.ui
+++ b/src/leap/bitmask/gui/ui/preferences_account_page.ui
@@ -15,23 +15,28 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QPushButton" name="btnChangePassword">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Change Password</string>
+ <widget class="QGroupBox" name="provider_services_box">
+ <property name="title">
+ <string>Services</string>
</property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="lblChangePasswordStatus">
- <property name="text">
- <string>&lt;change password status&gt;</string>
+ <property name="flat">
+ <bool>false</bool>
</property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="1" column="0">
+ <layout class="QVBoxLayout" name="provider_services_layout"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="provider_services_label">
+ <property name="text">
+ <string>&lt;provider_services_label&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>
@@ -51,24 +56,28 @@
</spacer>
</item>
<item>
- <widget class="QGroupBox" name="gbServices">
+ <widget class="QGroupBox" name="groupBox">
<property name="title">
- <string>Services</string>
+ <string>Password</string>
</property>
- <property name="flat">
- <bool>false</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="1" column="0">
- <layout class="QVBoxLayout" name="vlServices"/>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="lblProvidersServicesStatus">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QPushButton" name="change_password_button">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
- <string>&lt; Providers Services Status &gt;</string>
+ <string>Change Password</string>
</property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="change_password_label">
+ <property name="text">
+ <string>&lt;change_password_label&gt;</string>
</property>
</widget>
</item>
diff --git a/src/leap/bitmask/services/eip/conductor.py b/src/leap/bitmask/services/eip/conductor.py
index 0ee56628..01dd7449 100644
--- a/src/leap/bitmask/services/eip/conductor.py
+++ b/src/leap/bitmask/services/eip/conductor.py
@@ -124,6 +124,12 @@ class EIPConductor(object):
"""
self._backend.tear_fw_down()
+ def terminate(self):
+ """
+ Turn off VPN
+ """
+ self.qtsigs.do_disconnect_signal.emit()
+
@QtCore.Slot()
def _start_eip(self):
"""