135 os.path.join("MqttMonitor", "icons", |
135 os.path.join("MqttMonitor", "icons", |
136 "connectionOptions-{0}".format(self.__iconSuffix)) |
136 "connectionOptions-{0}".format(self.__iconSuffix)) |
137 )) |
137 )) |
138 self.__populateBrokerComboBoxes() |
138 self.__populateBrokerComboBoxes() |
139 self.brokerStatusLabel.hide() |
139 self.brokerStatusLabel.hide() |
|
140 self.clearWillButton.setIcon( |
|
141 UI.PixmapCache.getIcon("certificateDelete")) |
140 |
142 |
141 self.subscribeButton.setIcon(UI.PixmapCache.getIcon("plus")) |
143 self.subscribeButton.setIcon(UI.PixmapCache.getIcon("plus")) |
142 self.subscribeButton.setEnabled(False) |
144 self.subscribeButton.setEnabled(False) |
143 self.subscribePropertiesButton.setIcon( |
145 self.subscribePropertiesButton.setIcon( |
144 UI.PixmapCache.getIcon("listSelection")) |
146 UI.PixmapCache.getIcon("listSelection")) |
292 properties |
294 properties |
293 @type dict |
295 @type dict |
294 """ |
296 """ |
295 self.brokerStatusLabel.hide() |
297 self.brokerStatusLabel.hide() |
296 |
298 |
297 # TODO: add support for flags[‘session present’] |
|
298 if rc == 0: |
299 if rc == 0: |
299 self.__connectedToBroker = True |
300 self.__connectedToBroker = True |
300 self.__connectionOptions = None |
301 self.__connectionOptions = None |
|
302 |
|
303 try: |
|
304 sessionPresent = flags["session present"] == 1 |
|
305 except KeyError: |
|
306 sessionPresent = False |
301 |
307 |
302 msg = ( |
308 msg = ( |
303 mqttReasonCode(rc, packetType) |
309 mqttReasonCode(rc, packetType) |
304 if packetType is not None else |
310 if packetType is not None else |
305 mqttConnackMessage(rc) |
311 mqttConnackMessage(rc) |
306 ) |
312 ) |
|
313 if sessionPresent: |
|
314 msg = self.tr("{0} - Session still present").format(msg) |
307 self.__flashBrokerStatusLabel(msg) |
315 self.__flashBrokerStatusLabel(msg) |
308 |
316 |
309 if properties: |
317 if properties: |
310 self.__showProperties("Connect", properties) |
318 self.__showProperties("Connect", properties) |
311 |
319 |
598 """ |
606 """ |
599 if self.__connectionModeProfile: |
607 if self.__connectionModeProfile: |
600 from .MqttConnectionProfilesDialog import ( |
608 from .MqttConnectionProfilesDialog import ( |
601 MqttConnectionProfilesDialog |
609 MqttConnectionProfilesDialog |
602 ) |
610 ) |
|
611 profileName = self.profileComboBox.currentText() |
603 dlg = MqttConnectionProfilesDialog( |
612 dlg = MqttConnectionProfilesDialog( |
604 self.__plugin.getPreferences("BrokerProfiles"), parent=self) |
613 self.__plugin.getPreferences("BrokerProfiles"), |
|
614 currentProfile=profileName, parent=self) |
605 if dlg.exec() == QDialog.DialogCode.Accepted: |
615 if dlg.exec() == QDialog.DialogCode.Accepted: |
606 profilesDict = dlg.getProfiles() |
616 profilesDict = dlg.getProfiles() |
607 self.__plugin.setPreferences("BrokerProfiles", profilesDict) |
617 self.__plugin.setPreferences("BrokerProfiles", profilesDict) |
608 self.__populateProfileComboBox() |
618 self.__populateProfileComboBox() |
609 else: |
619 else: |
1294 host, port)) |
1304 host, port)) |
1295 self.brokerStatusLabel.show() |
1305 self.brokerStatusLabel.show() |
1296 |
1306 |
1297 self.__addBrokerToRecent(host, port) |
1307 self.__addBrokerToRecent(host, port) |
1298 self.connectButton.setEnabled(False) |
1308 self.connectButton.setEnabled(False) |
|
1309 |
|
1310 if self.clearWillButton.isChecked(): |
|
1311 clearWill = True |
|
1312 self.clearWillButton.setChecked(False) |
|
1313 else: |
|
1314 clearWill = False |
|
1315 |
1299 if self.__connectionOptions is None: |
1316 if self.__connectionOptions is None: |
1300 self.__client = self.__createClient() |
1317 self.__client = self.__createClient() |
1301 self.__client.connectToServer(host, port=port) |
1318 self.__client.connectToServer( |
|
1319 host, port=port, clearWill=clearWill) |
1302 else: |
1320 else: |
1303 self.__client = self.__createClient( |
1321 self.__client = self.__createClient( |
1304 clientId=self.__connectionOptions["ClientId"], |
1322 clientId=self.__connectionOptions["ClientId"], |
1305 cleanSession=self.__connectionOptions["CleanSession"], |
1323 cleanSession=self.__connectionOptions["CleanSession"], |
1306 protocol=self.__connectionOptions["Protocol"] |
1324 protocol=self.__connectionOptions["Protocol"] |
1307 ) |
1325 ) |
1308 self.__client.connectToServerWithOptions( |
1326 self.__client.connectToServerWithOptions( |
1309 host, port=port, options=self.__connectionOptions) |
1327 host, port=port, options=self.__connectionOptions, |
|
1328 clearWill=clearWill) |
1310 |
1329 |
1311 def __profileConnectToBroker(self): |
1330 def __profileConnectToBroker(self): |
1312 """ |
1331 """ |
1313 Private method to connect to the broker with selected profile. |
1332 Private method to connect to the broker with selected profile. |
1314 """ |
1333 """ |
1330 host, port)) |
1349 host, port)) |
1331 self.brokerStatusLabel.show() |
1350 self.brokerStatusLabel.show() |
1332 |
1351 |
1333 self.connectButton.setEnabled(False) |
1352 self.connectButton.setEnabled(False) |
1334 |
1353 |
|
1354 if self.clearWillButton.isChecked(): |
|
1355 clearWill = True |
|
1356 self.clearWillButton.setChecked(False) |
|
1357 else: |
|
1358 clearWill = False |
|
1359 |
1335 self.__client = self.__createClient( |
1360 self.__client = self.__createClient( |
1336 clientId=connectionProfile["ClientId"], |
1361 clientId=connectionProfile["ClientId"], |
1337 cleanSession=connectionProfile["CleanSession"], |
1362 cleanSession=connectionProfile["CleanSession"], |
1338 protocol=protocol |
1363 protocol=protocol |
1339 ) |
1364 ) |
1340 self.__client.connectToServerWithOptions( |
1365 self.__client.connectToServerWithOptions( |
1341 host, port=port, options=connectionProfile) |
1366 host, port=port, options=connectionProfile, |
|
1367 clearWill=clearWill) |
1342 |
1368 |
1343 def __showProperties(self, typeStr, properties): |
1369 def __showProperties(self, typeStr, properties): |
1344 """ |
1370 """ |
1345 Private method to display the received properties in the properties |
1371 Private method to display the received properties in the properties |
1346 pane. |
1372 pane. |