From b0dc286e5381d3328f3408b97541818e47865ad5 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Tue, 22 Apr 2014 13:33:37 -0300 Subject: Use QDialog as base for AKM. This allows the akm to be treated as a preferences dialog instead of an extra 'main window'. --- src/leap/bitmask/gui/advanced_key_management.py | 8 +++++--- src/leap/bitmask/gui/mainwindow.py | 6 +++--- src/leap/bitmask/gui/ui/advanced_key_management.ui | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/leap/bitmask/gui/advanced_key_management.py b/src/leap/bitmask/gui/advanced_key_management.py index cbc8c3e3..95e5eedf 100644 --- a/src/leap/bitmask/gui/advanced_key_management.py +++ b/src/leap/bitmask/gui/advanced_key_management.py @@ -30,12 +30,14 @@ from ui_advanced_key_management import Ui_AdvancedKeyManagement logger = logging.getLogger(__name__) -class AdvancedKeyManagement(QtGui.QWidget): +class AdvancedKeyManagement(QtGui.QDialog): """ Advanced Key Management """ - def __init__(self, user, keymanager, soledad): + def __init__(self, parent, user, keymanager, soledad): """ + :param parent: parent object of AdvancedKeyManagement. + :parent type: QWidget :param user: the current logged in user. :type user: unicode :param keymanager: the existing keymanager instance @@ -43,7 +45,7 @@ class AdvancedKeyManagement(QtGui.QWidget): :param soledad: a loaded instance of Soledad :type soledad: Soledad """ - QtGui.QWidget.__init__(self) + QtGui.QDialog.__init__(self, parent) self.ui = Ui_AdvancedKeyManagement() self.ui.setupUi(self) diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index b911e5d8..3296bb04 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -566,9 +566,9 @@ class MainWindow(QtGui.QMainWindow): """ domain = self._login_widget.get_selected_provider() logged_user = "{0}@{1}".format(self._logged_user, domain) - self._akm = AdvancedKeyManagement( - logged_user, self._keymanager, self._soledad) - self._akm.show() + akm = AdvancedKeyManagement( + self, logged_user, self._keymanager, self._soledad) + akm.show() @QtCore.Slot() def _show_preferences(self): diff --git a/src/leap/bitmask/gui/ui/advanced_key_management.ui b/src/leap/bitmask/gui/ui/advanced_key_management.ui index 1112670f..3b567347 100644 --- a/src/leap/bitmask/gui/ui/advanced_key_management.ui +++ b/src/leap/bitmask/gui/ui/advanced_key_management.ui @@ -1,7 +1,7 @@ AdvancedKeyManagement - + 0 -- cgit v1.2.3 From b84bcd9e5282dffe7d1208b84f0ab2e31a28cae5 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Tue, 22 Apr 2014 13:59:30 -0300 Subject: Show specific note for providers not supporting mx. Also add a helper method to disable the ui and show a message. --- src/leap/bitmask/gui/advanced_key_management.py | 32 ++++++++++++++++++++----- 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 @@ -53,14 +56,19 @@ class AdvancedKeyManagement(QtGui.QDialog): # XXX: Temporarily disable the key import. 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("NOTE: " - "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("NOTE: ") + 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() -- cgit v1.2.3 From d0b5734262a59e1ac86e9a9ed74f0744624e3554 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Tue, 22 Apr 2014 14:22:19 -0300 Subject: Add changes file for #5513. --- changes/feature-5513_update-note-in-akm | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/feature-5513_update-note-in-akm diff --git a/changes/feature-5513_update-note-in-akm b/changes/feature-5513_update-note-in-akm new file mode 100644 index 00000000..e0ae0632 --- /dev/null +++ b/changes/feature-5513_update-note-in-akm @@ -0,0 +1 @@ +- Advanced key management: show a note to the user if the provider does not support Encrypted Email. Closes #5513. -- cgit v1.2.3