diff options
| author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-04-22 13:59:30 -0300 | 
|---|---|---|
| committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-04-22 13:59:30 -0300 | 
| commit | b84bcd9e5282dffe7d1208b84f0ab2e31a28cae5 (patch) | |
| tree | 9d77009df5b3c38e8cab267ba50f959d7b25c119 | |
| parent | b0dc286e5381d3328f3408b97541818e47865ad5 (diff) | |
Show specific note for providers not supporting mx.
Also add a helper method to disable the ui and show a message.
| -rw-r--r-- | src/leap/bitmask/gui/advanced_key_management.py | 32 | ||||
| -rw-r--r-- | src/leap/bitmask/gui/mainwindow.py | 8 | 
2 files changed, 33 insertions, 7 deletions
| diff --git a/src/leap/bitmask/gui/advanced_key_management.py b/src/leap/bitmask/gui/advanced_key_management.py index 95e5eedf..be6b4410 100644 --- a/src/leap/bitmask/gui/advanced_key_management.py +++ b/src/leap/bitmask/gui/advanced_key_management.py @@ -34,10 +34,13 @@ class AdvancedKeyManagement(QtGui.QDialog):      """      Advanced Key Management      """ -    def __init__(self, parent, user, keymanager, soledad): +    def __init__(self, parent, has_mx, user, keymanager, soledad):          """          :param parent: parent object of AdvancedKeyManagement.          :parent type: QWidget +        :param has_mx: defines whether the current provider provides email or +                       not. +        :type has_mx: bool          :param user: the current logged in user.          :type user: unicode          :param keymanager: the existing keymanager instance @@ -54,13 +57,18 @@ class AdvancedKeyManagement(QtGui.QDialog):          self.ui.pbImportKeys.setVisible(False)          # if Soledad is not started yet +        if not has_mx: +            msg = self.tr("The provider that you are using " +                          "does not support {0}.") +            msg = msg.format(get_service_display_name(MX_SERVICE)) +            self._disable_ui(msg) +            return + +        # if Soledad is not started yet          if sameProxiedObjects(soledad, None): -            self.ui.gbMyKeyPair.setEnabled(False) -            self.ui.gbStoredPublicKeys.setEnabled(False) -            msg = self.tr("<span style='color:#0000FF;'>NOTE</span>: " -                          "To use this, you need to enable/start {0}.") +            msg = self.tr("To use this, you need to enable/start {0}.")              msg = msg.format(get_service_display_name(MX_SERVICE)) -            self.ui.lblStatus.setText(msg) +            self._disable_ui(msg)              return          # XXX: since import is disabled this is no longer a dangerous feature.          # else: @@ -92,6 +100,18 @@ class AdvancedKeyManagement(QtGui.QDialog):          self._list_keys() +    def _disable_ui(self, msg): +        """ +        Disable the UI and set a note in the status bar. + +        :param msg: note to display in the status bar. +        :type msg: unicode +        """ +        self.ui.gbMyKeyPair.setEnabled(False) +        self.ui.gbStoredPublicKeys.setEnabled(False) +        msg = self.tr("<span style='color:#0000FF;'>NOTE</span>: ") + msg +        self.ui.lblStatus.setText(msg) +      def _import_keys(self):          """          Imports the user's key pair. diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 3296bb04..b0369e5b 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -566,8 +566,14 @@ class MainWindow(QtGui.QMainWindow):          """          domain = self._login_widget.get_selected_provider()          logged_user = "{0}@{1}".format(self._logged_user, domain) + +        has_mx = True +        if self._logged_user is not None: +            provider_config = self._get_best_provider_config() +            has_mx = provider_config.provides_mx() +          akm = AdvancedKeyManagement( -            self, logged_user, self._keymanager, self._soledad) +            self, has_mx, logged_user, self._keymanager, self._soledad)          akm.show()      @QtCore.Slot() | 
