MqttMonitor/MqttConnectionOptionsDialog.py

Thu, 06 Sep 2018 19:34:49 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 06 Sep 2018 19:34:49 +0200
branch
connection_profiles
changeset 22
545979c7dcd4
parent 20
3737a78bb6c5
child 25
01d44a4decf5
permissions
-rw-r--r--

MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.

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
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
16
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
17 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
18
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
19 from Utilities.crypto import pwConvert
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
20
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
21
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 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
23 """
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 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
25 """
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 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
27 """
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 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
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 @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
31 @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
32 @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
33 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
34 "Keepalive", "CleanSession", "Username", "Password", "WillTopic",
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
35 "WillMessage", "WillQos", "WillRetain".
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 11
diff changeset
36 @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
37 @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
38 @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
39 """
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 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
41 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
42
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.__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
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.__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
46
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
47 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
48
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
49 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
50 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
51 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
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 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62
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.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
64
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
65 @pyqtSlot()
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
66 def on_generateIdButton_clicked(self):
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
67 """
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
68 Private slot to generate a client ID.
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
69 """
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
70 uuid = QUuid.createUuid()
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
71 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
72
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
73 @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
74 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
75 """
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
76 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
77
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 @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
79 @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
80 """
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 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
82 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
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 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
85 """
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 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
87
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 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
89 default values.
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
90
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
91 @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
92 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
93 "CleanSession", "Username", "Password", "WillTopic", "WillMessage",
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
94 "WillQos", "WillRetain".
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
95 @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
96 """
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
97 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
98 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
99
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
100 # 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
101 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
102 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
103 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
104
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 # 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
106 self.usernameEdit.setText(options["Username"])
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
107 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
108
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 # 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
110 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
111 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
112 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
113 self.willMessageEdit.setPlainText(options["WillMessage"])
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 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
116 """
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 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
118
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 @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
120 "ClientId", "Keepalive", "CleanSession", "Username", "Password",
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
121 "WillTopic", "WillMessage", "WillQos", "WillRetain".
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
122 @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
123 """
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 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
125 "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
126 "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
127 "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
128 "Username": self.usernameEdit.text(),
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
129 "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
130 "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
131 "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
132 "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
133 "WillRetain": self.willRetainCheckBox.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
134 }
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
135
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
136 @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
137 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
138 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
139 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
140
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
141 @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
142 @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
143 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
144 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
145
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
146 @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
147 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
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 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
150
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 @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
152 @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
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 self.__updateOkButton()

eric ide

mercurial