summaryrefslogtreecommitdiff
path: root/src/leap/bitmask
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask')
-rw-r--r--src/leap/bitmask/config/leapsettings.py17
-rw-r--r--src/leap/bitmask/gui/ui/wizard.ui53
-rw-r--r--src/leap/bitmask/gui/wizard.py34
-rw-r--r--src/leap/bitmask/services/soledad/soledadbootstrapper.py13
4 files changed, 89 insertions, 28 deletions
diff --git a/src/leap/bitmask/config/leapsettings.py b/src/leap/bitmask/config/leapsettings.py
index dc1af899..4660535a 100644
--- a/src/leap/bitmask/config/leapsettings.py
+++ b/src/leap/bitmask/config/leapsettings.py
@@ -68,6 +68,7 @@ class LeapSettings(object):
AUTOSTARTEIP_KEY = "AutoStartEIP"
ALERTMISSING_KEY = "AlertMissingScripts"
GATEWAY_KEY = "Gateway"
+ PINNED_KEY = "Pinned"
# values
GATEWAY_AUTOMATIC = "Automatic"
@@ -135,6 +136,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/ui/wizard.ui b/src/leap/bitmask/gui/ui/wizard.ui
index b796b795..0f6eef6e 100644
--- a/src/leap/bitmask/gui/ui/wizard.ui
+++ b/src/leap/bitmask/gui/ui/wizard.ui
@@ -269,7 +269,24 @@
<string>Configure or select a provider</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
- <item row="0" column="1">
+ <item row="0" column="0">
+ <widget class="QRadioButton" name="rbNewProvider">
+ <property name="text">
+ <string>Configure new provider:</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QRadioButton" name="rbExistingProvider">
+ <property name="text">
+ <string>Use existing one:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>https://</string>
@@ -279,44 +296,30 @@
</property>
</widget>
</item>
- <item row="0" column="2">
+ <item row="1" column="1">
<widget class="QLineEdit" name="lnProvider"/>
</item>
<item row="1" column="2">
- <widget class="QComboBox" name="cbProviders">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
<widget class="QPushButton" name="btnCheck">
<property name="text">
<string>Check</string>
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QRadioButton" name="rbNewProvider">
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_8">
<property name="text">
- <string>Configure new provider</string>
- </property>
- <property name="checked">
- <bool>true</bool>
+ <string>https://</string>
</property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QRadioButton" name="rbExistingProvider">
- <property name="text">
- <string>Use existing one</string>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QLabel" name="label_8">
- <property name="text">
- <string>https://</string>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="cbProviders">
+ <property name="enabled">
+ <bool>false</bool>
</property>
</widget>
</item>
diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py
index 7cff742e..e3f5904e 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,39 @@ 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)
+ if not providers:
+ self.ui.rbExistingProvider.setEnabled(False)
+ self.ui.label_8.setEnabled(False) # 'https://' label
+ self.ui.cbProviders.setEnabled(False)
+ return
+
+ 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
diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
index 6731cc84..7968dd6a 100644
--- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py
+++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
@@ -321,7 +321,18 @@ class SoledadBootstrapper(AbstractBootstrapper):
gpgbin = os.path.join(
get_path_prefix(), "..", "apps", "mail", "gpg")
else:
- gpgbin = which("gpg")
+ try:
+ gpgbin_options = which("gpg")
+ # gnupg checks that the path to the binary is not a
+ # symlink, so we need to filter those and come up with
+ # just one option.
+ for opt in gpgbin_options:
+ if not os.path.islink(opt):
+ gpgbin = opt
+ break
+ except IndexError as e:
+ logger.debug("Couldn't find the gpg binary!")
+ logger.exception(e)
leap_check(gpgbin is not None, "Could not find gpg binary")
return gpgbin