diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-11-01 10:50:38 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-11-01 10:50:38 -0300 |
commit | 23e9034664edf6b2a01a677c4fa4e6efd880e364 (patch) | |
tree | fc90f154cf81cbaf48dd2d4a738a379591c4e7c7 /src/leap/bitmask/gui/preferenceswindow.py | |
parent | a06b5719f028e619a4b3800fb346ed3c984e4d25 (diff) | |
parent | 80fde752f0bf7946869361f6a77d1952f9339636 (diff) |
Merge branch 'release-0.3.6'0.3.6
Diffstat (limited to 'src/leap/bitmask/gui/preferenceswindow.py')
-rw-r--r-- | src/leap/bitmask/gui/preferenceswindow.py | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/src/leap/bitmask/gui/preferenceswindow.py b/src/leap/bitmask/gui/preferenceswindow.py index 58cb05ba..acb39b07 100644 --- a/src/leap/bitmask/gui/preferenceswindow.py +++ b/src/leap/bitmask/gui/preferenceswindow.py @@ -40,12 +40,14 @@ class PreferencesWindow(QtGui.QDialog): """ Window that displays the preferences. """ - def __init__(self, parent, srp_auth): + def __init__(self, parent, srp_auth, provider_config): """ :param parent: parent object of the PreferencesWindow. :parent type: QWidget :param srp_auth: SRPAuth object configured in the main app. :type srp_auth: SRPAuth + :param provider_config: ProviderConfig object. + :type provider_config: ProviderConfig """ QtGui.QDialog.__init__(self, parent) self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic") @@ -72,6 +74,36 @@ class PreferencesWindow(QtGui.QDialog): else: self._add_configured_providers() + pw_enabled = False + + # check if the user is logged in + if srp_auth is not None and srp_auth.get_token() is not None: + # check if provider has 'mx' ... + domain = provider_config.get_domain() + self._select_provider_by_name(domain) + if provider_config.provides_mx(): + enabled_services = self._settings.get_enabled_services(domain) + mx_name = get_service_display_name('mx') + + # ... and if the user have it enabled + if 'mx' not in enabled_services: + msg = self.tr("You need to enable {0} in order to change " + "the password.".format(mx_name)) + self._set_password_change_status(msg, error=True) + else: + msg = self.tr( + "You need to wait until {0} is ready in " + "order to change the password.".format(mx_name)) + self._set_password_change_status(msg) + else: + pw_enabled = True + else: + msg = self.tr( + "In order to change your password you need to be logged in.") + self._set_password_change_status(msg) + + self.ui.gbPasswordChange.setEnabled(pw_enabled) + def set_soledad_ready(self, soledad): """ SLOT @@ -84,6 +116,7 @@ class PreferencesWindow(QtGui.QDialog): :type soledad: Soledad """ self._soledad = soledad + self.ui.lblPasswordChangeStatus.setVisible(False) self.ui.gbPasswordChange.setEnabled(True) def _set_password_change_status(self, status, error=False, success=False): @@ -98,6 +131,9 @@ class PreferencesWindow(QtGui.QDialog): elif success: status = "<font color='green'><b>%s</b></font>" % (status,) + if not self.ui.gbPasswordChange.isEnabled(): + status = "<font color='black'>%s</font>" % (status,) + self.ui.lblPasswordChangeStatus.setVisible(True) self.ui.lblPasswordChangeStatus.setText(status) @@ -156,7 +192,7 @@ class PreferencesWindow(QtGui.QDialog): """ logger.debug("SRP password changed successfully.") try: - self._soledad.change_passphrase(str(new_password)) + self._soledad.change_passphrase(new_password) logger.debug("Soledad password changed successfully.") except NoStorageSecret: logger.debug( @@ -218,6 +254,16 @@ class PreferencesWindow(QtGui.QDialog): for provider in self._settings.get_configured_providers(): self.ui.cbProvidersServices.addItem(provider) + def _select_provider_by_name(self, name): + """ + Given a provider name/domain, selects it in the combobox. + + :param name: name or domain for the provider + :type name: str + """ + provider_index = self.ui.cbProvidersServices.findText(name) + self.ui.cbProvidersServices.setCurrentIndex(provider_index) + def _service_selection_changed(self, service, state): """ SLOT |