diff options
author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2013-08-30 16:14:06 -0300 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2013-08-30 16:32:15 -0300 |
commit | f29133e7e2244ef7181685af7d93653cb54562e8 (patch) | |
tree | 1b67380e332e23386a3f3475243587fd4cf77d33 /src/leap/bitmask/config/leapsettings.py | |
parent | 2026a2a331edfed91ca66686776cd9d26c2ac58d (diff) |
Add config option to set & get preferred gateway.
Diffstat (limited to 'src/leap/bitmask/config/leapsettings.py')
-rw-r--r-- | src/leap/bitmask/config/leapsettings.py | 36 |
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 |