Sun, 09 Sep 2018 17:43:35 +0200
Added some TODO comments to note some enhancement ideas.
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 | """ |
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 | 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
|
28 | """ |
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 | 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
|
30 | |
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 | @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
|
32 | @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
|
33 | @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
|
34 | 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
|
35 | "Keepalive", "CleanSession", "Username", "Password", "WillTopic", |
31
40582e448c4b
Added a connect timeout function with a settable timeout value.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
30
diff
changeset
|
36 | "WillMessage", "WillQos", "WillRetain", "TlsEnable", "TlsCaCert", |
40582e448c4b
Added a connect timeout function with a settable timeout value.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
30
diff
changeset
|
37 | "ConnectionTimeout". |
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", |
31
40582e448c4b
Added a connect timeout function with a settable timeout value.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
30
diff
changeset
|
100 | "WillQos", "WillRetain", "TlsEnable", "TlsCaCert", |
40582e448c4b
Added a connect timeout function with a settable timeout value.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
30
diff
changeset
|
101 | "ConnectionTimeout". |
11
90d3ebed4cc0
Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10
diff
changeset
|
102 | @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
|
103 | """ |
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 | 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
|
105 | 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
|
106 | |
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 | # 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
|
108 | self.clientIdEdit.setText(options["ClientId"]) |
31
40582e448c4b
Added a connect timeout function with a settable timeout value.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
30
diff
changeset
|
109 | self.connectionTimeoutSpinBox.setValue(options["ConnectionTimeout"]) |
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
|
110 | 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
|
111 | 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
|
112 | |
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 | # 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
|
114 | self.usernameEdit.setText(options["Username"]) |
22
545979c7dcd4
MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
20
diff
changeset
|
115 | 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
|
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 | # 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
|
118 | 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
|
119 | 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
|
120 | 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
|
121 | self.willMessageEdit.setPlainText(options["WillMessage"]) |
25
01d44a4decf5
MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
22
diff
changeset
|
122 | |
01d44a4decf5
MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
22
diff
changeset
|
123 | # TLS parameters |
01d44a4decf5
MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
22
diff
changeset
|
124 | self.tlsEnableCheckBox.setChecked(options["TlsEnable"]) |
01d44a4decf5
MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
22
diff
changeset
|
125 | 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
|
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 | 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
|
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 | 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
|
130 | |
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 | @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
|
132 | "ClientId", "Keepalive", "CleanSession", "Username", "Password", |
25
01d44a4decf5
MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
22
diff
changeset
|
133 | "WillTopic", "WillMessage", "WillQos", "WillRetain", "TlsEnable", |
31
40582e448c4b
Added a connect timeout function with a settable timeout value.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
30
diff
changeset
|
134 | "TlsCaCert", "ConnectionTimeout". |
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
|
135 | @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
|
136 | """ |
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 | 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
|
138 | "ClientId": self.clientIdEdit.text(), |
31
40582e448c4b
Added a connect timeout function with a settable timeout value.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
30
diff
changeset
|
139 | "ConnectionTimeout": self.connectionTimeoutSpinBox.value(), |
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
|
140 | "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
|
141 | "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
|
142 | "Username": self.usernameEdit.text(), |
22
545979c7dcd4
MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
20
diff
changeset
|
143 | "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
|
144 | "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
|
145 | "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
|
146 | "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
|
147 | "WillRetain": self.willRetainCheckBox.isChecked(), |
25
01d44a4decf5
MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
22
diff
changeset
|
148 | "TlsEnable": self.tlsEnableCheckBox.isChecked(), |
01d44a4decf5
MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
22
diff
changeset
|
149 | "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
|
150 | } |
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
|
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 | @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
|
153 | 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
|
154 | """ |
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 | 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
|
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 | @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
|
158 | @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
|
159 | """ |
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 | 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
|
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 | @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
|
163 | 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
|
164 | """ |
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 | 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
|
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 | @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
|
168 | @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
|
169 | """ |
3737a78bb6c5
MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
18
diff
changeset
|
170 | self.__updateOkButton() |