5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to edit the MQTT connection profiles. |
7 Module implementing a dialog to edit the MQTT connection profiles. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
|
11 |
|
12 import collections |
10 import collections |
13 |
11 |
14 from PyQt5.QtCore import pyqtSlot, Qt, QUuid |
12 from PyQt5.QtCore import pyqtSlot, Qt, QUuid |
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton, \ |
13 from PyQt5.QtWidgets import ( |
16 QListWidgetItem, QInputDialog, QLineEdit |
14 QDialog, QDialogButtonBox, QAbstractButton, QListWidgetItem, QInputDialog, |
|
15 QLineEdit |
|
16 ) |
17 |
17 |
18 from E5Gui import E5MessageBox |
18 from E5Gui import E5MessageBox |
19 from E5Gui.E5PathPicker import E5PathPickerModes |
19 from E5Gui.E5PathPicker import E5PathPickerModes |
20 |
20 |
21 from .Ui_MqttConnectionProfilesDialog import Ui_MqttConnectionProfilesDialog |
21 from .Ui_MqttConnectionProfilesDialog import Ui_MqttConnectionProfilesDialog |
266 } |
266 } |
267 if profile["TlsEnable"]: |
267 if profile["TlsEnable"]: |
268 if self.tlsCertsFileButton.isChecked(): |
268 if self.tlsCertsFileButton.isChecked(): |
269 profile["TlsCaCert"] = self.tlsCertsFilePicker.text() |
269 profile["TlsCaCert"] = self.tlsCertsFilePicker.text() |
270 elif self.tlsSelfSignedCertsButton.isChecked(): |
270 elif self.tlsSelfSignedCertsButton.isChecked(): |
271 profile["TlsCaCert"] = \ |
271 profile["TlsCaCert"] = ( |
272 self.tlsSelfSignedCertsFilePicker.text() |
272 self.tlsSelfSignedCertsFilePicker.text()) |
273 profile["TlsClientCert"] = \ |
273 profile["TlsClientCert"] = ( |
274 self.tlsSelfSignedClientCertFilePicker.text() |
274 self.tlsSelfSignedClientCertFilePicker.text()) |
275 profile["TlsClientKey"] = \ |
275 profile["TlsClientKey"] = ( |
276 self.tlsSelfSignedClientKeyFilePicker.text() |
276 self.tlsSelfSignedClientKeyFilePicker.text()) |
277 |
277 |
278 self.__profiles[profileName] = profile |
278 self.__profiles[profileName] = profile |
279 self.__profilesChanged = True |
279 self.__profilesChanged = True |
280 |
280 |
281 return profileName |
281 return profileName |
471 enable = (bool(self.profileEdit.text()) and |
471 enable = (bool(self.profileEdit.text()) and |
472 bool(self.brokerAddressEdit.text())) |
472 bool(self.brokerAddressEdit.text())) |
473 |
473 |
474 # condition 2: if client ID is empty, clean session must be selected |
474 # condition 2: if client ID is empty, clean session must be selected |
475 if not self.__populatingProfile: |
475 if not self.__populatingProfile: |
476 if self.clientIdEdit.text() == "" and \ |
476 if ( |
477 not self.cleanSessionCheckBox.isChecked(): |
477 self.clientIdEdit.text() == "" and |
|
478 not self.cleanSessionCheckBox.isChecked() |
|
479 ): |
478 enable = False |
480 enable = False |
479 E5MessageBox.critical( |
481 E5MessageBox.critical( |
480 self, |
482 self, |
481 self.tr("Invalid Connection Parameters"), |
483 self.tr("Invalid Connection Parameters"), |
482 self.tr("An empty Client ID requires a clean session.")) |
484 self.tr("An empty Client ID requires a clean session.")) |