summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/wizard.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-10-04 12:09:58 -0300
committerTomás Touceda <chiiph@leap.se>2013-10-04 12:09:58 -0300
commit584866689560bd2ebea01ecc5e6ae5e79ce7fc81 (patch)
tree4fe300c3c105e17721f79eeece9bbd3745b43d78 /src/leap/bitmask/gui/wizard.py
parent1f0f8efc4cb985c082b3b8fe7b3dc45aed047a47 (diff)
parent759d73ae0728f074e0fb0740269249d0e5066574 (diff)
Merge branch 'release-0.3.4'
Diffstat (limited to 'src/leap/bitmask/gui/wizard.py')
-rw-r--r--src/leap/bitmask/gui/wizard.py79
1 files changed, 71 insertions, 8 deletions
diff --git a/src/leap/bitmask/gui/wizard.py b/src/leap/bitmask/gui/wizard.py
index 45734b81..e3f5904e 100644
--- a/src/leap/bitmask/gui/wizard.py
+++ b/src/leap/bitmask/gui/wizard.py
@@ -14,28 +14,27 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
"""
First run wizard
"""
import os
import logging
import json
+import random
from functools import partial
from PySide import QtCore, QtGui
from twisted.internet import threads
-from leap.bitmask.config import flags
+from leap.bitmask.config.leapsettings import LeapSettings
from leap.bitmask.config.providerconfig import ProviderConfig
from leap.bitmask.crypto.srpregister import SRPRegister
-from leap.bitmask.util.privilege_policies import is_missing_policy_permissions
+from leap.bitmask.provider.providerbootstrapper import ProviderBootstrapper
+from leap.bitmask.services import get_service_display_name, get_supported
from leap.bitmask.util.request_helpers import get_content
from leap.bitmask.util.keyring_helpers import has_keyring
from leap.bitmask.util.password import basic_password_checks
-from leap.bitmask.services.eip.providerbootstrapper import ProviderBootstrapper
-from leap.bitmask.services import get_service_display_name, get_supported
from ui_wizard import Ui_Wizard
@@ -84,6 +83,8 @@ class Wizard(QtGui.QWizard):
self._show_register = False
+ self._use_existing_provider = False
+
self.ui.grpCheckProvider.setVisible(False)
self.ui.btnCheck.clicked.connect(self._check_provider)
self.ui.lnProvider.returnPressed.connect(self._check_provider)
@@ -113,9 +114,6 @@ class Wizard(QtGui.QWizard):
self.currentIdChanged.connect(self._current_id_changed)
- self.ui.lblPassword.setEchoMode(QtGui.QLineEdit.Password)
- self.ui.lblPassword2.setEchoMode(QtGui.QLineEdit.Password)
-
self.ui.lnProvider.textChanged.connect(
self._enable_check)
@@ -128,6 +126,8 @@ class Wizard(QtGui.QWizard):
self.ui.btnRegister.clicked.connect(
self._register)
+ self.ui.rbExistingProvider.toggled.connect(self._skip_provider_checks)
+
usernameRe = QtCore.QRegExp(self.BARE_USERNAME_REGEX)
self.ui.lblUser.setValidator(
QtGui.QRegExpValidator(usernameRe, self))
@@ -147,6 +147,40 @@ class Wizard(QtGui.QWizard):
self.ui.label_12.setVisible(False)
self.ui.lblProviderPolicy.setVisible(False)
+ 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()
+ 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
@@ -318,6 +352,25 @@ class Wizard(QtGui.QWizard):
self._provider_select_defer = self._provider_bootstrapper.\
run_provider_select_checks(self._domain)
+ def _skip_provider_checks(self, skip):
+ """
+ SLOT
+ Triggered:
+ self.ui.rbExistingProvider.toggled
+
+ Allows the user to move to the next page without make any checks,
+ used when we are selecting an already configured provider.
+
+ :param skip: if we should skip checks or not
+ :type skip: bool
+ """
+ if skip:
+ self._reset_provider_check()
+
+ self.page(self.SELECT_PROVIDER_PAGE).set_completed(skip)
+ self.button(QtGui.QWizard.NextButton).setEnabled(skip)
+ self._use_existing_provider = skip
+
def _complete_task(self, data, label, complete=False, complete_page=-1):
"""
Checks a task and completes a page if specified
@@ -564,4 +617,14 @@ class Wizard(QtGui.QWizard):
else:
return self.SERVICES_PAGE
+ if self.currentPage() == self.page(self.SELECT_PROVIDER_PAGE):
+ if self._use_existing_provider:
+ self._domain = self.ui.cbProviders.currentText()
+ self._provider_config = ProviderConfig.get_provider_config(
+ self._domain)
+ if self._show_register:
+ return self.REGISTER_USER_PAGE
+ else:
+ return self.SERVICES_PAGE
+
return QtGui.QWizard.nextId(self)