summaryrefslogtreecommitdiff
path: root/src/leap/bitmask
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-07-10 11:32:36 -0300
committerTomás Touceda <chiiph@leap.se>2014-07-10 11:32:36 -0300
commitc0cc3f6f13ef8bc3dadec86bede2b286cea4e966 (patch)
tree5588c3ab7725980d325f8717ba1298083f573ddf /src/leap/bitmask
parent4793149d6d1276feaabcc89b90f209dc70355b20 (diff)
parent9a0760848f038dc0271b8c9adabf8aefe4db594e (diff)
Merge remote-tracking branch 'refs/remotes/ivan/feature/5813_wizard-providers-order' into develop
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r--src/leap/bitmask/gui/wizard.py69
-rw-r--r--src/leap/bitmask/provider/pinned.py10
2 files changed, 61 insertions, 18 deletions
diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py
index f66c553d..4f67958f 100644
--- a/src/leap/bitmask/gui/wizard.py
+++ b/src/leap/bitmask/gui/wizard.py
@@ -83,7 +83,8 @@ class Wizard(QtGui.QWizard):
self.ui.grpCheckProvider.setVisible(False)
self._connect_and_track(self.ui.btnCheck.clicked, self._check_provider)
- self._connect_and_track(self.ui.lnProvider.returnPressed, self._check_provider)
+ self._connect_and_track(self.ui.lnProvider.returnPressed,
+ self._check_provider)
self._backend = backend
self._backend_connect()
@@ -98,22 +99,24 @@ class Wizard(QtGui.QWizard):
self._provider_select_defer = None
self._provider_setup_defer = None
- self._connect_and_track(self.currentIdChanged, self._current_id_changed)
+ self._connect_and_track(self.currentIdChanged,
+ self._current_id_changed)
- self._connect_and_track(self.ui.lnProvider.textChanged, self._enable_check)
+ self._connect_and_track(self.ui.lnProvider.textChanged,
+ self._enable_check)
self._connect_and_track(self.ui.rbNewProvider.toggled,
- lambda x: self._enable_check())
+ lambda x: self._enable_check())
self._connect_and_track(self.ui.cbProviders.currentIndexChanged[int],
- self._reset_provider_check)
+ self._reset_provider_check)
self._connect_and_track(self.ui.lblUser.returnPressed,
- self._focus_password)
+ self._focus_password)
self._connect_and_track(self.ui.lblPassword.returnPressed,
- self._focus_second_password)
+ self._focus_second_password)
self._connect_and_track(self.ui.lblPassword2.returnPressed,
- self._register)
+ self._register)
self._connect_and_track(self.ui.btnRegister.clicked,
- self._register)
+ self._register)
self._connect_and_track(self.ui.rbExistingProvider.toggled,
self._skip_provider_checks)
@@ -184,21 +187,55 @@ class Wizard(QtGui.QWizard):
:param pinned: list of pinned providers
:type pinned: list of str
+
+
+ How the combobox items are arranged:
+ -----------------------------------
+
+ First run:
+
+ demo.bitmask.net
+ --
+ pinned2.org
+ pinned1.org
+ pinned3.org
+
+ After some usage:
+
+ added-by-user.org
+ pinned-but-then-used.org
+ ---
+ demo.bitmask.net
+ pinned1.org
+ pinned3.org
+ pinned2.org
+
+ In other words:
+ * There are two sections.
+ * Section one consists of all the providers that the user has used.
+ If this is empty, than use demo.bitmask.net for this section.
+ This list is sorted alphabetically.
+ * Section two consists of all the pinned or 'pre seeded' providers,
+ minus any providers that are now in section one. This last list
+ is in random order.
"""
ls = LeapSettings()
- providers = ls.get_configured_providers()
- if not providers and not pinned:
+ user_added = ls.get_configured_providers()
+ if not user_added and not pinned:
self.ui.rbExistingProvider.setEnabled(False)
self.ui.label_8.setEnabled(False) # 'https://' label
self.ui.cbProviders.setEnabled(False)
return
- user_added = []
+ user_added.sort()
+
+ if not user_added:
+ user_added = [pinned.pop(0)]
- # separate pinned providers from user added ones
- for p in providers:
- if p not in pinned:
- user_added.append(p)
+ # separate unused pinned providers from user added ones
+ for p in user_added:
+ if p in pinned:
+ pinned.remove(p)
if user_added:
self.ui.cbProviders.addItems(user_added)
diff --git a/src/leap/bitmask/provider/pinned.py b/src/leap/bitmask/provider/pinned.py
index 38851621..6fd2fa70 100644
--- a/src/leap/bitmask/provider/pinned.py
+++ b/src/leap/bitmask/provider/pinned.py
@@ -32,6 +32,7 @@ class PinnedProviders(object):
CONFIG_KEY = "config"
CACERT_KEY = "cacert"
+ PREFERRED_PROVIDER = pinned_demobitmask.DOMAIN
PROVIDERS = {
pinned_demobitmask.DOMAIN: {
@@ -50,11 +51,16 @@ class PinnedProviders(object):
@classmethod
def domains(self):
"""
- Return the domains that are pinned in here
+ Return the domains that are pinned in here.
+ The first domain in the list is the preferred one.
:rtype: list of str
"""
- return self.PROVIDERS.keys()
+ domains = self.PROVIDERS.keys()
+ domains.remove(self.PREFERRED_PROVIDER)
+ domains.insert(0, self.PREFERRED_PROVIDER)
+
+ return domains
@classmethod
def save_hardcoded(self, domain, provider_path, cacert_path):