summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/leap/bitmask/gui/advanced_key_management.py38
-rw-r--r--src/leap/bitmask/gui/mainwindow.py12
-rw-r--r--src/leap/bitmask/gui/ui/advanced_key_management.ui2
3 files changed, 40 insertions, 12 deletions
diff --git a/src/leap/bitmask/gui/advanced_key_management.py b/src/leap/bitmask/gui/advanced_key_management.py
index cbc8c3e3..be6b4410 100644
--- a/src/leap/bitmask/gui/advanced_key_management.py
+++ b/src/leap/bitmask/gui/advanced_key_management.py
@@ -30,12 +30,17 @@ 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, 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
@@ -43,7 +48,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)
@@ -52,13 +57,18 @@ class AdvancedKeyManagement(QtGui.QWidget):
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:
@@ -90,6 +100,18 @@ class AdvancedKeyManagement(QtGui.QWidget):
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 f2b2eb3c..907d4ceb 100644
--- a/src/leap/bitmask/gui/mainwindow.py
+++ b/src/leap/bitmask/gui/mainwindow.py
@@ -566,9 +566,15 @@ 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()
+
+ 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, has_mx, 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 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AdvancedKeyManagement</class>
- <widget class="QWidget" name="AdvancedKeyManagement">
+ <widget class="QDialog" name="AdvancedKeyManagement">
<property name="geometry">
<rect>
<x>0</x>