MqttMonitor/MqttConnectionOptionsDialog.py

Sun, 09 Sep 2018 12:21:19 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 09 Sep 2018 12:21:19 +0200
changeset 30
17ef10819773
parent 25
01d44a4decf5
child 31
40582e448c4b
permissions
-rw-r--r--

Some smaller improvements and added some TODOs.

10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
3 # Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de>
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
4 #
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
5
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter MQTT connection options.
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
12 from PyQt5.QtCore import pyqtSlot, QUuid
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
20
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
15 from E5Gui import E5MessageBox
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
16 from E5Gui.E5PathPicker import E5PathPickerModes
20
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
17
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .Ui_MqttConnectionOptionsDialog import Ui_MqttConnectionOptionsDialog
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
20 from Utilities.crypto import pwConvert
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
21
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 class MqttConnectionOptionsDialog(QDialog, Ui_MqttConnectionOptionsDialog):
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Class implementing a dialog to enter MQTT connection options.
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
30
17ef10819773 Some smaller improvements and added some TODOs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 25
diff changeset
27 # TODO: add 'Clear Will'
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, client, options=None, parent=None):
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param client reference to the MQTT client object
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type MqttClient
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param options dictionary containing the connection options to
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
35 populate the dialog with. It must have the keys "ClientId",
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
36 "Keepalive", "CleanSession", "Username", "Password", "WillTopic",
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
37 "WillMessage", "WillQos", "WillRetain", "TlsEnable", "TlsCaCert".
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
38 @type dict
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param parent reference to the parent widget
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @type QWidget
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 super(MqttConnectionOptionsDialog, self).__init__(parent)
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.setupUi(self)
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__client = client
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
47 self.tlsCertsFilePicker.setMode(E5PathPickerModes.OpenFileMode)
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
48 self.tlsCertsFilePicker.setFilters(
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
49 self.tr("Certificate Files (*.crt *.pem);;All Files (*)"))
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
50
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__populateDefaults(options=options)
20
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
52
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
53 self.__updateOkButton()
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
54
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
55 def __updateOkButton(self):
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
56 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
57 Private method to update the enabled state of the OK button.
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
58 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
59 if self.clientIdEdit.text() == "" and \
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
60 not self.cleanSessionCheckBox.isChecked():
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
61 enable = False
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
62 E5MessageBox.critical(
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
63 self,
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
64 self.tr("Invalid Connection Parameters"),
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
65 self.tr("""An empty Client ID requires a clean session."""))
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
66 else:
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
67 enable = True
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
68
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
69 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
70
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
71 @pyqtSlot()
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
72 def on_generateIdButton_clicked(self):
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
73 """
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
74 Private slot to generate a client ID.
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
75 """
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
76 uuid = QUuid.createUuid()
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
77 self.clientIdEdit.setText(uuid.toString(QUuid.WithoutBraces))
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 @pyqtSlot(QAbstractButton)
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 def on_buttonBox_clicked(self, button):
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 Private slot to handle the press of a button box button.
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @param button button that has been pressed
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 @type QAbstractButton
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 if button == self.buttonBox.button(QDialogButtonBox.RestoreDefaults):
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.__populateDefaults(options=None)
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 def __populateDefaults(self, options=None):
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 Private method to populate the dialog.
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 If no options dictionary is given, the dialog will be populated with
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 default values.
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
96
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
97 @param options dictionary containing the connection options to populate
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
98 the dialog with. It must have the keys "ClientId", "Keepalive",
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
99 "CleanSession", "Username", "Password", "WillTopic", "WillMessage",
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
100 "WillQos", "WillRetain", "TlsEnable", "TlsCaCert".
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
101 @type dict
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 if options is None:
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 options = self.__client.defaultConnectionOptions()
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 # general
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.clientIdEdit.setText(options["ClientId"])
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.keepaliveSpinBox.setValue(options["Keepalive"])
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.cleanSessionCheckBox.setChecked(options["CleanSession"])
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 # user credentials
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.usernameEdit.setText(options["Username"])
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
113 self.passwordEdit.setText(pwConvert(options["Password"], encode=False))
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 # last will and testament
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.willQosSpinBox.setValue(options["WillQos"])
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.willRetainCheckBox.setChecked(options["WillRetain"])
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.willTopicEdit.setText(options["WillTopic"])
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.willMessageEdit.setPlainText(options["WillMessage"])
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
120
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
121 # TLS parameters
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
122 self.tlsEnableCheckBox.setChecked(options["TlsEnable"])
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
123 self.tlsCertsFilePicker.setText(options["TlsCaCert"])
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 def getConnectionOptions(self):
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 Public method get the entered connection options.
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 @return dictionary containing the connection options. It has the keys
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 "ClientId", "Keepalive", "CleanSession", "Username", "Password",
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
131 "WillTopic", "WillMessage", "WillQos", "WillRetain", "TlsEnable",
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
132 "TlsCaCert".
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 @rtype tuple of (int, dict)
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 """
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 return {
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 "ClientId": self.clientIdEdit.text(),
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 "Keepalive": self.keepaliveSpinBox.value(),
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 "CleanSession": self.cleanSessionCheckBox.isChecked(),
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 "Username": self.usernameEdit.text(),
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
140 "Password": pwConvert(self.passwordEdit.text(), encode=True),
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 "WillTopic": self.willTopicEdit.text(),
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 "WillMessage": self.willMessageEdit.toPlainText(),
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 "WillQos": self.willQosSpinBox.value(),
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 "WillRetain": self.willRetainCheckBox.isChecked(),
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
145 "TlsEnable": self.tlsEnableCheckBox.isChecked(),
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
146 "TlsCaCert": self.tlsCertsFilePicker.text()
10
7e0e921dc7ea Started to implement the connection options dialog and methods to specify these connection options connecting to the server.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 }
20
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
148
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
149 @pyqtSlot(str)
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
150 def on_clientIdEdit_textChanged(self, clientId):
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
151 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
152 Private slot handling a change of the client ID string.
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
153
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
154 @param clientId client ID
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
155 @type str
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
156 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
157 self.__updateOkButton()
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
158
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
159 @pyqtSlot(bool)
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
160 def on_cleanSessionCheckBox_clicked(self, checked):
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
161 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
162 Private slot to handle a change of the clean session selection.
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
163
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
164 @param checked current state of the clean session selection
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
165 @type bool
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
166 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
167 self.__updateOkButton()

eric ide

mercurial