MqttMonitor/MqttConnectionOptionsDialog.py

Sun, 30 May 2021 18:21:40 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 30 May 2021 18:21:40 +0200
branch
eric7
changeset 92
2fb5c08019fd
parent 86
620022b14cb4
child 97
21f9c010dc42
permissions
-rw-r--r--

Ported the plug-in to PyQt6 for eric7.

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
84
044df16e55aa Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 78
diff changeset
3 # Copyright (c) 2018 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
11
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
92
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
10 from PyQt6.QtCore import pyqtSlot, QUuid
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton
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
12
92
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
13 from EricWidgets import EricMessageBox
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
14 from EricWidgets.EricPathPicker import EricPathPickerModes
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
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
16 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
17
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
18 from Utilities.crypto import pwConvert
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
19
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
20
7e0e921dc7ea Started to implement 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 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
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 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
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 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
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 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
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 @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
30 @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
31 @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
32 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
33 "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
34 "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
35 "ConnectionTimeout".
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 """
86
620022b14cb4 Implemented some code simplifications.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 84
diff changeset
40 super().__init__(parent)
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
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
92
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
45 self.tlsCertsFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
46 self.tlsCertsFilePicker.setFilters(
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
47 self.tr("Certificate Files (*.crt *.pem);;All Files (*)"))
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
48
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
49 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
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 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
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 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
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 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
56 """
78
a22328182bc2 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 66
diff changeset
57 if (
a22328182bc2 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 66
diff changeset
58 self.clientIdEdit.text() == "" and
a22328182bc2 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 66
diff changeset
59 not self.cleanSessionCheckBox.isChecked()
a22328182bc2 Removed support for Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 66
diff changeset
60 ):
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
61 enable = False
92
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
62 EricMessageBox.critical(
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
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
92
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
69 self.buttonBox.button(
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
70 QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
71
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
72 @pyqtSlot()
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
73 def on_generateIdButton_clicked(self):
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
74 """
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
75 Private slot to generate a client ID.
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
76 """
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
77 uuid = QUuid.createUuid()
92
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
78 self.clientIdEdit.setText(
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
79 uuid.toString(QUuid.StringFormat.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
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 @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
82 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
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 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
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 @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
87 @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
88 """
92
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
89 if button == self.buttonBox.button(
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
90 QDialogButtonBox.StandardButton.RestoreDefaults
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
91 ):
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
92 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
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 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
95 """
7e0e921dc7ea Started to implement 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 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
97
7e0e921dc7ea Started to implement 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 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
99 default values.
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
100
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
101 @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
102 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
103 "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
104 "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
105 "ConnectionTimeout".
11
90d3ebed4cc0 Finished implementing the connection options dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10
diff changeset
106 @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
107 """
7e0e921dc7ea Started to implement 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 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
109 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
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 # 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
112 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
113 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
114 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
115 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
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 # 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
118 self.usernameEdit.setText(options["Username"])
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
119 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
120
7e0e921dc7ea Started to implement 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 # 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
122 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
123 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
124 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
125 self.willMessageEdit.setPlainText(options["WillMessage"])
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
126
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
127 # TLS parameters
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
128 self.tlsEnableCheckBox.setChecked(options["TlsEnable"])
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
129 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
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 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
132 """
7e0e921dc7ea Started to implement 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 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
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 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
136 "ClientId", "Keepalive", "CleanSession", "Username", "Password",
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
137 "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
138 "TlsCaCert", "ConnectionTimeout".
92
2fb5c08019fd Ported the plug-in to PyQt6 for eric7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 86
diff changeset
139 @rtype 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
140 """
7e0e921dc7ea Started to implement 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 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
142 "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
143 "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
144 "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
145 "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
146 "Username": self.usernameEdit.text(),
22
545979c7dcd4 MqttClient, MqttConnectionOptionsDialog: added support for encrypted passwords.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 20
diff changeset
147 "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
148 "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
149 "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
150 "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
151 "WillRetain": self.willRetainCheckBox.isChecked(),
25
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
152 "TlsEnable": self.tlsEnableCheckBox.isChecked(),
01d44a4decf5 MqttConnectionOptionsDialog: added support for TLS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 22
diff changeset
153 "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
154 }
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
155
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 @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
157 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
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 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
160
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 @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
162 @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
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 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
165
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 @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
167 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
168 """
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 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
170
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
171 @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
172 @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
173 """
3737a78bb6c5 MqttConnectionOptionsDialog: added some validity checks and added the default value for 'keepalive' setting.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
174 self.__updateOkButton()

eric ide

mercurial