summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/gui/eip_preferenceswindow.py35
-rw-r--r--src/leap/bitmask/services/eip/eipconfig.py14
2 files changed, 37 insertions, 12 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/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):