summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-10-03 11:25:39 -0300
committerTomás Touceda <chiiph@leap.se>2013-10-03 11:25:39 -0300
commit91fb5281f941af7aa36997a0dec4300d65363fb5 (patch)
treeac35c3c3eb55bcb133173b07f89ad06dfbcc13c5
parent3597f2f043cbe78bb0c7dbc0be4778e2fe9cdd3f (diff)
parent99625ee3ab32791c0ddac946685379940b9f291e (diff)
Merge remote-tracking branch 'ivan/feature/3996_separate-providers-in-wizard' into develop
-rw-r--r--changes/feature-3996_separate-providers-in-wizard1
-rw-r--r--src/leap/bitmask/config/leapsettings.py17
-rw-r--r--src/leap/bitmask/gui/wizard.py28
3 files changed, 44 insertions, 2 deletions
diff --git a/changes/feature-3996_separate-providers-in-wizard b/changes/feature-3996_separate-providers-in-wizard
new file mode 100644
index 00000000..2466d140
--- /dev/null
+++ b/changes/feature-3996_separate-providers-in-wizard
@@ -0,0 +1 @@
+ o Separate pinned providers from user configures ones. Closes #3996.
diff --git a/src/leap/bitmask/config/leapsettings.py b/src/leap/bitmask/config/leapsettings.py
index 338fa475..7ab1ace3 100644
--- a/src/leap/bitmask/config/leapsettings.py
+++ b/src/leap/bitmask/config/leapsettings.py
@@ -67,6 +67,7 @@ class LeapSettings(object):
DEFAULTPROVIDER_KEY = "DefaultProvider"
ALERTMISSING_KEY = "AlertMissingScripts"
GATEWAY_KEY = "Gateway"
+ PINNED_KEY = "Pinned"
# values
GATEWAY_AUTOMATIC = "Automatic"
@@ -134,6 +135,22 @@ class LeapSettings(object):
return providers
+ def is_pinned_provider(self, domain):
+ """
+ Returns True if the domain 'domain' is pinned with the application.
+ False otherwise.
+
+ :param provider: provider domain
+ :type provider: str
+
+ :rtype: bool
+ """
+ leap_assert(len(domain) > 0, "We need a nonempty domain.")
+ pinned_key = "{0}/{1}".format(domain, self.PINNED_KEY)
+ result = to_bool(self._settings.value(pinned_key, False))
+
+ return result
+
def get_selected_gateway(self, provider):
"""
Returns the configured gateway for the given provider.
diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py
index 7cff742e..219270c7 100644
--- a/src/leap/bitmask/gui/wizard.py
+++ b/src/leap/bitmask/gui/wizard.py
@@ -20,6 +20,7 @@ First run wizard
import os
import logging
import json
+import random
from functools import partial
@@ -146,10 +147,33 @@ class Wizard(QtGui.QWizard):
self.ui.label_12.setVisible(False)
self.ui.lblProviderPolicy.setVisible(False)
- # Load configured providers into wizard
+ self._load_configured_providers()
+
+ def _load_configured_providers(self):
+ """
+ Loads the configured providers into the wizard providers combo box.
+ """
ls = LeapSettings()
providers = ls.get_configured_providers()
- self.ui.cbProviders.addItems(providers)
+ pinned = []
+ user_added = []
+
+ # separate pinned providers from user added ones
+ for p in providers:
+ if ls.is_pinned_provider(p):
+ pinned.append(p)
+ else:
+ user_added.append(p)
+
+ if user_added:
+ self.ui.cbProviders.addItems(user_added)
+
+ if user_added and pinned:
+ self.ui.cbProviders.addItem('---')
+
+ if pinned:
+ random.shuffle(pinned) # don't prioritize alphabetically
+ self.ui.cbProviders.addItems(pinned)
def get_domain(self):
return self._domain