MqttMonitor/MqttConnectionOptionsDialog.py

changeset 31
40582e448c4b
parent 30
17ef10819773
child 32
a71e5b294ebf
equal deleted inserted replaced
30:17ef10819773 31:40582e448c4b
32 @param client reference to the MQTT client object 32 @param client reference to the MQTT client object
33 @type MqttClient 33 @type MqttClient
34 @param options dictionary containing the connection options to 34 @param options dictionary containing the connection options to
35 populate the dialog with. It must have the keys "ClientId", 35 populate the dialog with. It must have the keys "ClientId",
36 "Keepalive", "CleanSession", "Username", "Password", "WillTopic", 36 "Keepalive", "CleanSession", "Username", "Password", "WillTopic",
37 "WillMessage", "WillQos", "WillRetain", "TlsEnable", "TlsCaCert". 37 "WillMessage", "WillQos", "WillRetain", "TlsEnable", "TlsCaCert",
38 "ConnectionTimeout".
38 @type dict 39 @type dict
39 @param parent reference to the parent widget 40 @param parent reference to the parent widget
40 @type QWidget 41 @type QWidget
41 """ 42 """
42 super(MqttConnectionOptionsDialog, self).__init__(parent) 43 super(MqttConnectionOptionsDialog, self).__init__(parent)
95 default values. 96 default values.
96 97
97 @param options dictionary containing the connection options to populate 98 @param options dictionary containing the connection options to populate
98 the dialog with. It must have the keys "ClientId", "Keepalive", 99 the dialog with. It must have the keys "ClientId", "Keepalive",
99 "CleanSession", "Username", "Password", "WillTopic", "WillMessage", 100 "CleanSession", "Username", "Password", "WillTopic", "WillMessage",
100 "WillQos", "WillRetain", "TlsEnable", "TlsCaCert". 101 "WillQos", "WillRetain", "TlsEnable", "TlsCaCert",
102 "ConnectionTimeout".
101 @type dict 103 @type dict
102 """ 104 """
103 if options is None: 105 if options is None:
104 options = self.__client.defaultConnectionOptions() 106 options = self.__client.defaultConnectionOptions()
105 107
106 # general 108 # general
107 self.clientIdEdit.setText(options["ClientId"]) 109 self.clientIdEdit.setText(options["ClientId"])
110 self.connectionTimeoutSpinBox.setValue(options["ConnectionTimeout"])
108 self.keepaliveSpinBox.setValue(options["Keepalive"]) 111 self.keepaliveSpinBox.setValue(options["Keepalive"])
109 self.cleanSessionCheckBox.setChecked(options["CleanSession"]) 112 self.cleanSessionCheckBox.setChecked(options["CleanSession"])
110 113
111 # user credentials 114 # user credentials
112 self.usernameEdit.setText(options["Username"]) 115 self.usernameEdit.setText(options["Username"])
127 Public method get the entered connection options. 130 Public method get the entered connection options.
128 131
129 @return dictionary containing the connection options. It has the keys 132 @return dictionary containing the connection options. It has the keys
130 "ClientId", "Keepalive", "CleanSession", "Username", "Password", 133 "ClientId", "Keepalive", "CleanSession", "Username", "Password",
131 "WillTopic", "WillMessage", "WillQos", "WillRetain", "TlsEnable", 134 "WillTopic", "WillMessage", "WillQos", "WillRetain", "TlsEnable",
132 "TlsCaCert". 135 "TlsCaCert", "ConnectionTimeout".
133 @rtype tuple of (int, dict) 136 @rtype tuple of (int, dict)
134 """ 137 """
135 return { 138 return {
136 "ClientId": self.clientIdEdit.text(), 139 "ClientId": self.clientIdEdit.text(),
140 "ConnectionTimeout": self.connectionTimeoutSpinBox.value(),
137 "Keepalive": self.keepaliveSpinBox.value(), 141 "Keepalive": self.keepaliveSpinBox.value(),
138 "CleanSession": self.cleanSessionCheckBox.isChecked(), 142 "CleanSession": self.cleanSessionCheckBox.isChecked(),
139 "Username": self.usernameEdit.text(), 143 "Username": self.usernameEdit.text(),
140 "Password": pwConvert(self.passwordEdit.text(), encode=True), 144 "Password": pwConvert(self.passwordEdit.text(), encode=True),
141 "WillTopic": self.willTopicEdit.text(), 145 "WillTopic": self.willTopicEdit.text(),

eric ide

mercurial