diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-11-21 11:10:04 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-11-21 11:10:04 -0300 |
commit | 2620cd58a11d524735f0f205a1cd39ad28ad8ddb (patch) | |
tree | 1c80b9701d485b9ff2735205718c81c18c2f3c24 /src/leap/bitmask | |
parent | 8efd282e38331c0decdf7d035ed3a174d1ff55cd (diff) | |
parent | cecd69f72165518a3f1eae13547f34d3b824db7b (diff) |
Merge remote-tracking branch 'ivan/bug/eip-disabled-until-usable' into develop
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r-- | src/leap/bitmask/gui/eip_preferenceswindow.py | 35 | ||||
-rw-r--r-- | src/leap/bitmask/gui/mainwindow.py | 27 | ||||
-rw-r--r-- | src/leap/bitmask/services/eip/eipconfig.py | 14 |
3 files changed, 54 insertions, 22 deletions
diff --git a/src/leap/bitmask/gui/eip_preferenceswindow.py b/src/leap/bitmask/gui/eip_preferenceswindow.py index e0c5d51f..504d1cf1 100644 --- a/src/leap/bitmask/gui/eip_preferenceswindow.py +++ b/src/leap/bitmask/gui/eip_preferenceswindow.py @@ -28,6 +28,7 @@ from leap.bitmask.config.leapsettings import LeapSettings from leap.bitmask.config.providerconfig import ProviderConfig from leap.bitmask.gui.ui_eippreferences import Ui_EIPPreferences from leap.bitmask.services.eip.eipconfig import EIPConfig, VPNGatewaySelector +from leap.bitmask.services.eip.eipconfig import get_eipconfig_path logger = logging.getLogger(__name__) @@ -52,7 +53,7 @@ class EIPPreferencesWindow(QtGui.QDialog): self.ui.lblProvidersGatewayStatus.setVisible(False) # Connections - self.ui.cbProvidersGateway.currentIndexChanged[unicode].connect( + self.ui.cbProvidersGateway.currentIndexChanged[int].connect( self._populate_gateways) self.ui.cbGateways.currentIndexChanged[unicode].connect( @@ -93,7 +94,11 @@ class EIPPreferencesWindow(QtGui.QDialog): return for provider in providers: - self.ui.cbProvidersGateway.addItem(provider) + label = provider + eip_config_path = get_eipconfig_path(provider, relative=False) + if not os.path.isfile(eip_config_path): + label = provider + self.tr(" (uninitialized)") + self.ui.cbProvidersGateway.addItem(label, userData=provider) def _save_selected_gateway(self, provider): """ @@ -120,7 +125,7 @@ class EIPPreferencesWindow(QtGui.QDialog): "Gateway settings for provider '{0}' saved.").format(provider) self._set_providers_gateway_status(msg, success=True) - def _populate_gateways(self, domain): + def _populate_gateways(self, domain_idx): """ SLOT TRIGGERS: @@ -129,15 +134,29 @@ class EIPPreferencesWindow(QtGui.QDialog): Loads the gateways that the provider provides into the UI for the user to select. - :param domain: the domain of the provider to load gateways from. - :type domain: str + :param domain: the domain index of the provider to load gateways from. + :type domain: int """ # We hide the maybe-visible status label after a change self.ui.lblProvidersGatewayStatus.setVisible(False) - if not domain: + if domain_idx == -1: return + domain = self.ui.cbProvidersGateway.itemData(domain_idx) + + if not os.path.isfile(get_eipconfig_path(domain, relative=False)): + self._set_providers_gateway_status( + self.tr("This is an uninitialized provider, " + "please log in first."), + error=True) + self.ui.pbSaveGateway.setEnabled(False) + self.ui.cbGateways.setEnabled(False) + return + else: + self.ui.pbSaveGateway.setEnabled(True) + self.ui.cbGateways.setEnabled(True) + try: # disconnect previously connected save method self.ui.pbSaveGateway.clicked.disconnect() @@ -151,11 +170,9 @@ class EIPPreferencesWindow(QtGui.QDialog): eip_config = EIPConfig() provider_config = ProviderConfig.get_provider_config(domain) - eip_config_path = os.path.join("leap", "providers", - domain, "eip-service.json") api_version = provider_config.get_api_version() eip_config.set_api_version(api_version) - eip_loaded = eip_config.load(eip_config_path) + eip_loaded = eip_config.load(get_eipconfig_path(domain)) if not eip_loaded or provider_config is None: self._set_providers_gateway_status( diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index b0f25af1..e21d6cd2 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -22,7 +22,7 @@ import os from PySide import QtCore, QtGui from twisted.internet import threads -from zope.proxy import ProxyBase, setProxiedObject, sameProxiedObjects +from zope.proxy import ProxyBase, setProxiedObject from leap.bitmask import __version__ as VERSION from leap.bitmask.config.leapsettings import LeapSettings @@ -358,15 +358,19 @@ class MainWindow(QtGui.QMainWindow): Called if the wizard has been cancelled or closed before finishing. + This is executed for the first run wizard only. Any other execution of + the wizard won't reach this point. """ - if self._wizard_firstrun: - providers = self._settings.get_configured_providers() - has_provider_on_disk = len(providers) != 0 - if not has_provider_on_disk: - # if we don't have any provider configured (included a pinned - # one) we can't use the application, so quit. - self.quit() + providers = self._settings.get_configured_providers() + has_provider_on_disk = len(providers) != 0 + if not has_provider_on_disk: + # if we don't have any provider configured (included a pinned + # one) we can't use the application, so quit. + self.quit() else: + # This happens if the user finishes the provider + # setup but does not register + self._wizard = None self._finish_init() def _launch_wizard(self): @@ -538,8 +542,7 @@ class MainWindow(QtGui.QMainWindow): TRIGGERS: self._wizard.accepted - Also called at the end of the constructor if not first run, - and after _rejected_wizard if not first run. + Also called at the end of the constructor if not first run. Implements the behavior after either constructing the mainwindow object, loading the saved user/password, or after @@ -574,6 +577,9 @@ class MainWindow(QtGui.QMainWindow): if possible_password is not None: self._login_widget.set_password(possible_password) self._login() + else: + self.eip_needs_login.emit() + self._wizard = None else: self._try_autostart_eip() @@ -1449,6 +1455,7 @@ class MainWindow(QtGui.QMainWindow): self.tr("Not supported"), error=True) else: + self._eip_status.disable_eip_start() self._eip_status.set_eip_status(self.tr("Disabled")) def _finish_eip_bootstrap(self, data): diff --git a/src/leap/bitmask/services/eip/eipconfig.py b/src/leap/bitmask/services/eip/eipconfig.py index 16ed4cc0..09a3d257 100644 --- a/src/leap/bitmask/services/eip/eipconfig.py +++ b/src/leap/bitmask/services/eip/eipconfig.py @@ -33,17 +33,25 @@ from leap.common.check import leap_assert, leap_assert_type logger = logging.getLogger(__name__) -def get_eipconfig_path(domain): +def get_eipconfig_path(domain, relative=True): """ - Returns relative path for EIP config. + Returns relative or absolute path for EIP config. :param domain: the domain to which this eipconfig belongs to. :type domain: str + :param relative: defines whether the path should be relative or absolute. + :type relative: bool :returns: the path :rtype: str """ leap_assert(domain is not None, "get_eipconfig_path: We need a domain") - return os.path.join("leap", "providers", domain, "eip-service.json") + + path = os.path.join("leap", "providers", domain, "eip-service.json") + + if not relative: + path = os.path.join(get_path_prefix(), path) + + return path def load_eipconfig_if_needed(provider_config, eip_config, domain): |