MqttMonitor/MqttConnectionOptionsDialog.py

branch
connection_profiles
changeset 25
01d44a4decf5
parent 22
545979c7dcd4
child 30
17ef10819773
--- a/MqttMonitor/MqttConnectionOptionsDialog.py	Fri Sep 07 18:10:31 2018 +0200
+++ b/MqttMonitor/MqttConnectionOptionsDialog.py	Sat Sep 08 15:28:48 2018 +0200
@@ -13,6 +13,7 @@
 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton
 
 from E5Gui import E5MessageBox
+from E5Gui.E5PathPicker import E5PathPickerModes
 
 from .Ui_MqttConnectionOptionsDialog import Ui_MqttConnectionOptionsDialog
 
@@ -32,7 +33,7 @@
         @param options dictionary containing the connection options to
             populate the dialog with. It must have the keys "ClientId",
             "Keepalive", "CleanSession", "Username", "Password", "WillTopic",
-            "WillMessage", "WillQos", "WillRetain".
+            "WillMessage", "WillQos", "WillRetain", "TlsEnable", "TlsCaCert".
         @type dict
         @param parent reference to the parent widget
         @type QWidget
@@ -42,6 +43,10 @@
         
         self.__client = client
         
+        self.tlsCertsFilePicker.setMode(E5PathPickerModes.OpenFileMode)
+        self.tlsCertsFilePicker.setFilters(
+            self.tr("Certificate Files (*.crt *.pem);;All Files (*)"))
+        
         self.__populateDefaults(options=options)
         
         self.__updateOkButton()
@@ -91,7 +96,7 @@
         @param options dictionary containing the connection options to populate
             the dialog with. It must have the keys "ClientId", "Keepalive",
             "CleanSession", "Username", "Password", "WillTopic", "WillMessage",
-            "WillQos", "WillRetain".
+            "WillQos", "WillRetain", "TlsEnable", "TlsCaCert".
         @type dict
         """
         if options is None:
@@ -111,6 +116,10 @@
         self.willRetainCheckBox.setChecked(options["WillRetain"])
         self.willTopicEdit.setText(options["WillTopic"])
         self.willMessageEdit.setPlainText(options["WillMessage"])
+        
+        # TLS parameters
+        self.tlsEnableCheckBox.setChecked(options["TlsEnable"])
+        self.tlsCertsFilePicker.setText(options["TlsCaCert"])
     
     def getConnectionOptions(self):
         """
@@ -118,7 +127,8 @@
         
         @return dictionary containing the connection options. It has the keys
             "ClientId", "Keepalive", "CleanSession", "Username", "Password",
-            "WillTopic", "WillMessage", "WillQos", "WillRetain".
+            "WillTopic", "WillMessage", "WillQos", "WillRetain", "TlsEnable",
+            "TlsCaCert".
         @rtype tuple of (int, dict)
         """
         return {
@@ -131,6 +141,8 @@
             "WillMessage": self.willMessageEdit.toPlainText(),
             "WillQos": self.willQosSpinBox.value(),
             "WillRetain": self.willRetainCheckBox.isChecked(),
+            "TlsEnable": self.tlsEnableCheckBox.isChecked(),
+            "TlsCaCert": self.tlsCertsFilePicker.text()
         }
     
     @pyqtSlot(str)

eric ide

mercurial