summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/config
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-08-30 17:02:11 -0300
committerTomás Touceda <chiiph@leap.se>2013-08-30 17:02:11 -0300
commitce72a0596d0e2f49037747c0c19988874e0801c9 (patch)
tree706965282ef392cad5e824bfb77b87154be4ef2d /src/leap/bitmask/config
parent56275cfa83a69925fdb13fba84ce05be0de6ba57 (diff)
parent294e70f80ac8feb7ecac14691051037bf0c84afa (diff)
Merge remote-tracking branch 'ivan/feature/3505_preferences-select-gateway-manually' into develop
Diffstat (limited to 'src/leap/bitmask/config')
-rw-r--r--src/leap/bitmask/config/leapsettings.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/leap/bitmask/config/leapsettings.py b/src/leap/bitmask/config/leapsettings.py
index ca94129e..ad67b29e 100644
--- a/src/leap/bitmask/config/leapsettings.py
+++ b/src/leap/bitmask/config/leapsettings.py
@@ -66,6 +66,10 @@ class LeapSettings(object):
REMEMBER_KEY = "RememberUserAndPass"
DEFAULTPROVIDER_KEY = "DefaultProvider"
ALERTMISSING_KEY = "AlertMissingScripts"
+ GATEWAY_KEY = "Gateway"
+
+ # values
+ GATEWAY_AUTOMATIC = "Automatic"
def __init__(self, standalone=False):
"""
@@ -137,6 +141,38 @@ class LeapSettings(object):
return providers
+ def get_selected_gateway(self, provider):
+ """
+ Returns the configured gateway for the given provider.
+
+ :param provider: provider domain
+ :type provider: str
+
+ :rtype: str
+ """
+ leap_assert(len(provider) > 0, "We need a nonempty provider")
+ gateway_key = "{0}/{1}".format(provider, self.GATEWAY_KEY)
+ gateway = self._settings.value(gateway_key, self.GATEWAY_AUTOMATIC)
+
+ return gateway
+
+ def set_selected_gateway(self, provider, gateway):
+ """
+ Saves the configured gateway for the given provider
+
+ :param provider: provider domain
+ :type provider: str
+
+ :param gateway: gateway to use as default
+ :type gateway: str
+ """
+
+ leap_assert(len(provider) > 0, "We need a nonempty provider")
+ leap_assert_type(gateway, (str, unicode))
+
+ gateway_key = "{0}/{1}".format(provider, self.GATEWAY_KEY)
+ self._settings.setValue(gateway_key, gateway)
+
def get_enabled_services(self, provider):
"""
Returns a list of enabled services for the given provider