summaryrefslogtreecommitdiffstats
path: root/src/mqtt/qmqttclient.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Doc: Add valid value to QMqttClient::protocolVersionAndreas Eliasson7 days1-0/+1
| | | | | | | | | | As described in the ProtocolVersion enum description, MQTT Standard 5 is also a valid value. Fixes: QTBUG-120947 Pick-to: 6.7 6.5 6.2 5.15 Change-Id: I27ed8ad1d31201abb195c35ab56ced3ad08494cc Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Windows: Fix crash on QMqttClient destructionMaurice Kalinowski2023-03-301-1/+6
| | | | | | | | | | | | | | | On Windows, sending DISCONNECT might return data before the QMqttConnection is destroyed, causing it to invoke on bogus QMqttClient members. Hence, set a flag to avoid this event, but still aim to send a disconnect to the broker to nicely quit. Fixes: QTBUG-111846 Pick-to: 6.5 6.4 6.2 Change-Id: Ia94865c9b404ecbd814150c313679aa10b3f6aa0 Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Doc: Expose QMqttClient ctor docsPaul Wicking2022-08-291-1/+1
| | | | | | | | | | The documentation comment isn't a QDoc comment, so the docs aren't generated. Fixes: QTBUG-105873 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I176ea1c7ed2460bbeb1700a4d74a81b439215306 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-161-28/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ie4309963c8e17d4e7dad602f61a660246d5e23cb Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Ensure error gets reported for the state in which it has been occurredKonstantin Ritt2021-01-041-3/+2
| | | | | | | | | | | | | | In certain scenarios, it is important to distinguish errors occurred within particular states. A common example is: if network error occurred for a connected and operational client, one could try to reconnect and restore previous MQTT session using the same clientId and cleanSession=false, without having to bother the user if that succeуded; however if network error occurred during connection to MQTT broker, the behavior is completely different. Change-Id: Id1e90b7916f3e2ab32320518d0da1100014e5dd1 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* [BiC] Fix dangling pointer dereferencing when destroying QMqttClientKonstantin Ritt2020-08-181-0/+9
| | | | | | | | | | | when QMqttClient gets destroyed in Connected state, d->m_connection in its destructor (indirectly called by ~QObject) sends DISCONNECT Control packet and then closes connection, causing transportConnectionClosed() to call m_clientPrivate->setStateAndError(), which, in its turn, accesses [a partially destroyed] QMqttClient instance Change-Id: I216f700d92838dc25e385fe2d449f3ad93a642e6 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-041-2/+2
|\ | | | | | | Change-Id: I6fa6962ac8618f5fe59a67dfe6bec060cc274227
| * Fix documentation of the qos argument meaningKonstantin Ritt2020-03-311-2/+2
| | | | | | | | | | | | Change-Id: I530ca158ca01a4d793bad9a5ea2eaf12f6098506 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* | Qt6: Remove deprecated functionMaurice Kalinowski2019-10-111-17/+0
|/ | | | | | | | | has been superseded by QMqttClient::connectToHostEncrypted(const QSslConfiguration&). Change-Id: Ia4660be10a53f69ee310f253603a8530668f6332 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Add autoKeepAlive to QMqttClientMaurice Kalinowski2019-08-201-4/+52
| | | | | | | | | | | | | In certain scenarios, a user wants to manually handle the keepAlive. Introduce autoKeepAlive as a property. If set to false, then the user needs to handle the keepAlive by invoking requestPing. The default for this property is true and keeps the current behavior. Task-number: QTBUG-76782 Change-Id: I073874e6bdacf3c8d128c20431606affe1d9eeb1 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-111-3/+1
|\ | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: I39fabafba7b8bd591909ed6e32be619b1db73cf0
| * Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-07-031-3/+1
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/mqtt/qmqttclient.cpp Change-Id: I2b050319270fb365416623998c758ab9ec63f69d
| | * Fix documentation about keepAliveMaurice Kalinowski2019-07-021-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Initially the keepAlive was considered to be specified in ms to more match the Qt API. However, no server allows this granularity and the specs also state seconds. Internally it was using this pattern already. Change-Id: I0a25d1ef636c2b909997223c631dc248b613536c Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* | | Update deprecation of QMqttClient::connectToHostEncryptedMaurice Kalinowski2019-04-041-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Added documentation flag and also mark the function itself as deprecated. Change-Id: I4cc84b2c79ee0849d09b91e1778f38da5478b3c0 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-03-161-0/+3
|\| | | | | | | | | | | Change-Id: I11bde6a2389cd66c6d945d9f8bd32528dc43cc31
| * | Disconnect when keepAlive fails to receive pingrespMaurice Kalinowski2019-03-141-0/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | The specs state that a client SHOULD disconnect after not receiving a pingresp. So far, this needed to be checked manually. However, on Linux a disrupted network connection does not imply QTcpSocket to switch to disconnected state. Hence the client continues to consider the connection active, leading to lost messages and incorrect state. Task-number: QTBUG-74279 Change-Id: I6d8e540f7e89c621e5c010669085882d25440b0a Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* | Deprecate QMqttClient::connectToHostEncrypted(const QString)Maurice Kalinowski2019-03-041-0/+2
| | | | | | | | | | Change-Id: I3f972f2887ba8fb49ada648ade1f3a8637aef42f Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* | Add secure connection with QSslConfigurationMaurice Kalinowski2019-03-041-0/+13
|/ | | | | | | | | | | | | | Previous approach to use application wide configurations can break behavior. Also using a peerName is not sufficient in some cases. Hence, introduce QMqttClient::connectToHostEncrypted with QSslConfiguration as an argument, which should fulfill all needs. [ChangeLog][QMqttClient] Added secure connection with QSslConfiguration Task-number: QTBUG-73378 Change-Id: I3b91d2c7c02a3affd5dc67a7b486ebe78f4e1cc2 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Reject connection request while in connecting stateMaurice Kalinowski2018-11-151-0/+5
| | | | | | | | Otherwise might lead to side effects. Task-number: QTBUG-71795 Change-Id: Iad2cbe7613e08d1f90f497d1d65ed2da924f0aeb Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Update documentationMaurice Kalinowski2018-08-171-0/+12
| | | | | | | | | A couple of enums and member functions have been added since the last update. Change-Id: Ie1a32a9b827a6ce9d203026a46519b73921edaa8 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-08-111-0/+4
|\ | | | | | | Change-Id: Ib911bd894617ac51a7fde2c361203ca0a1e556b2
| * Update documentation on QMqttClient::setTransportMaurice Kalinowski2018-08-091-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | The client does not take ownership on connection management. This has not been made clear in the documentation so far and caused to wrong usage of the client. Task-number: QTBUG-69305 Task-number: QTBUG-68031 Change-Id: I11186478e241c860760aa187d03458ccb7601eee Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* | Add documentation for MQTT 5.0 related featuresMaurice Kalinowski2018-08-091-1/+150
| | | | | | | | | | | | | | | | MQTT 5.0 has been added in the Qt 5.12 release. Change-Id: I614ad162e836c82f86f21fa3e6fca6f0c3805b01 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* | MQTT5: Introduce AUTH supportMaurice Kalinowski2018-08-021-0/+14
| | | | | | | | | | | | Task-number: QTPM-1455 Change-Id: I8eef500fe5eb0e8a36f449534c70e35487c04a7b Reviewed-by: hjk <hjk@qt.io>
* | Disallow property changes while connectedMaurice Kalinowski2018-08-021-4/+76
| | | | | | | | | | | | | | | | | | Certain properties cannot be changed while connected and hence this should be reflected in the behavior. Task-number: QTBUG-67176 Change-Id: Ib9baafa1ac8d99d7a071839c892187efb51491e0 Reviewed-by: hjk <hjk@qt.io>
* | MQTT5: Introduce QMqttUnsubscriptionPropertiesMaurice Kalinowski2018-07-261-1/+6
| | | | | | | | | | | | | | | | | | While removing a subscription, properties can be passed. V5.0 only specifies user properties. Task-number: QTPM-1454 Change-Id: Id068875c1947c9479175f6e5458713e038f7454f Reviewed-by: hjk <hjk@qt.io>
* | Move qWarning to categorized loggingMaurice Kalinowski2018-07-261-5/+8
| | | | | | | | | | | | | | | | | | | | qWarning could potentially quit an application while it is easily possible to recover from an error state. Hence avoid usage of qWarning inside the module. Task-number: QTBUG-69544 Change-Id: I7340f38d80e6716450fbcd0918226e9435d37daa Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* | Cleanup according to analyzersMaurice Kalinowski2018-07-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | After applying clang-tidy and codemodel of Qt Creator, apply a couple of changes to make the code more clean. Remaining items are kept because either they touch released code or no mean to optimize (i.e. padding on QSharedData based classes). Change-Id: I8bea85432e3bacfb01bd3672a9e863a66c07216f Reviewed-by: hjk <hjk@qt.io>
* | MQTT5: Add support for last will propertiesMaurice Kalinowski2018-07-241-0/+12
| | | | | | | | | | | | Task-number: QTPM-1451 Change-Id: I26a12b944eddb029f7fffe8c1af1610ff79cc494 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* | MQTT5: Introduce QMqttSubscriptionPropertiesMaurice Kalinowski2018-07-201-1/+6
| | | | | | | | | | Change-Id: Ic41646937a0fd19a839cff8beb9c456bb005011d Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* | MQTT5: Introduce QMqttPublishPropertiesMaurice Kalinowski2018-07-201-1/+7
| | | | | | | | | | Change-Id: I3bbf3c51d43df0e4260eb90433881b57177d7c1c Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* | MQTT5: Add support for connection propertiesMaurice Kalinowski2018-07-201-0/+18
| | | | | | | | | | | | | | | | | | Connection properties can request certain features when connecting to a remote host. Furthermore, the broker is able to tell a client its feature set. Change-Id: I1d8813cb7966f31cacd984468640f808b834d69b Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* | MQTT5: Add initial supportMaurice Kalinowski2018-07-201-2/+1
| | | | | | | | | | | | | | | | | | With this patch it is possible to set the version to MQTT5 and use the same features as against version 3.1.1. No MQTT5 specific features are enabled. Change-Id: I129ff8a2c996d7bcc582565fccda9e38edc48c62 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* | Allow overwriting client defaultsMaurice Kalinowski2018-06-131-0/+9
|/ | | | | | | | | | Some test brokers require credentials to allow a connection. To be able to verify the module against those, add a mean to pass those to the client and run the auto tests without modification. Change-Id: I10b8e2343f7fc66199d70f5f238f69b07665110a Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Fix disconnectFromHost when in connecting stateMaurice Kalinowski2018-02-161-3/+10
| | | | | | | | | | | While the client or rather its underlying transport is trying to connect to a broker, a user might want to cancel this step by calling disconnectFromHost. Previously there was an early return, which lead to the client being in a bogus state. Task-number: QTBUG-66412 Change-Id: If6e9b778b8d10f7951631ebd1a0017c870ba6c18 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Fix reconnecting after transport errorMaurice Kalinowski2018-02-021-0/+1
| | | | | | | | | | | In case a connection fails due to a transport error, the client must be able to try to reconnect. Hence, reset the error state when connectToHost is called. Furthermore the socket needs to be re-created if it has been instantiated by QMqttClient previously. Task-number: QTBUG-65726 Change-Id: Id54e5f91a8ca4d0c7be6f51f1ad79e090c681584 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Fix error state handlingMaurice Kalinowski2018-02-021-1/+1
| | | | | | | Checking for NoError was done on the wrong variable. Change-Id: I3206333c0e69124ac22ccddcd329a63b7df0f761 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Fix subscriptions at reconnectv1.0Maurice Kalinowski2017-11-151-0/+3
| | | | | | | | | | | | When a client reconnects with a cleanSession, all previous subscriptions need to be disabled due to not being valid anymore. Furthermore, a broker can decide to not restore a session even though cleanSession was false. Take this into account by disabling existing subscriptions in that case as well. Task-number: QTBUG-64042 Change-Id: I618bc1fe4bb30651a34d70ec9d9e95e48b1c25d5 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Introduce specific types for topic names and filtersLorenz Haas2017-11-151-4/+4
| | | | | | | | | | | For "topics" the standard defines topic names and topic filters with specific characteristics. QMqttTopicName and QMqttTopicFilter implement this requirements. [ChangeLog][General] Added QMqttTopicName and QMqttTopicFilter Change-Id: Ie2b6851ec9249f20d05c4b8df3c2f27afc2be4b9 Reviewed-by: hjk <hjk@qt.io>
* Clean upMaurice Kalinowski2017-11-141-3/+3
| | | | | | | | Second argument is superfluous in this case. Change-Id: Id0b5444741375000929d26ea8567ba85b33f2ba7 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Remove indirection from QMqttConnection to data valuesMaurice Kalinowski2017-11-141-3/+4
| | | | | | | | | | Instead of querying the properties each time from the client, prefer to use QMqttClientPrivate, which stores the value types. Change-Id: I3f199029dc82077bd67a46a922206502b6519dfd Reviewed-by: Lorenz Haas <lorenz.haas@histomatics.de> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Do not block on connectToHostwip/brokerMaurice Kalinowski2017-11-101-6/+3
| | | | | | | | | | There is no reason to use waitForConnected, instead asynchronously react when the connection is established. As a side-effect UWP can use this module now without any issue as well. Change-Id: Ib30f13e42a8cb5c17f83aca594139926e056b932 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Doc: Edit QMqttClient::ClientError docsLeena Miettinen2017-11-091-8/+9
| | | | | Change-Id: I1f533a26e9e8fd20ec7f5ad2416fe56cab76e24e Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Doc: Add docs for QMqttClient::ProtocolViolationLeena Miettinen2017-11-081-0/+3
| | | | | Change-Id: I247ce3538a5c360cd0fd15551f3d3ccd3195406c Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Refactor state and error handlingMaurice Kalinowski2017-10-181-8/+64
| | | | | | | | | | | | Rename State to ClientState to avoid clashing names with other state management. Introduce ClientError to provide further information on occurring errors. Error values 1-5 are from the standard, followed by Qt specific error values. Change-Id: Ica1b703845e93e923fd1af4e3fb6ffb95de8390d Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Allow client IDs that do not follow the standard's adviceLorenz Haas2017-10-171-0/+1
| | | | | | | | | Make sure that the auto generated client ID is accepted by a standard compliant server. On the other hand do not forbid client IDs longer than 23 characters because servers MAY allow longer IDs. Change-Id: I6ccbd140586c2327b8675cd7aeb31bdde0d51f27 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Doc: Adding and editing the docsMaurice Kalinowski2017-10-161-70/+92
| | | | | | | | | | | | While there has been some initial API documentation for the preview release, incorporate further updates to make the module fully documented. Additional minor updates due to API changes. Task-number: QTBUG-63362 Change-Id: Ib472e4d4d18d505e77fdef3c14483c31628f8546 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Update license headersJani Heikkinen2017-09-251-5/+13
| | | | | Change-Id: If9b7f82a71ec554b152485ddd91a9d105019c6ce Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Change signature of QMqttClient::subscribeMaurice Kalinowski2017-09-011-3/+4
| | | | | | | | | | | | Instead of returning a QSharedPointer, return the same pointer. This improves readability as well as using the subscription from a user perspective. The ownership has to stay with the client though, otherwise behavior is unexpected. Change-Id: I72d3c15a12faf45c9575af8b3a790dfff1a30c2a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Doc fixesMaurice Kalinowski2017-09-011-5/+5
| | | | | Change-Id: I5000baabdc176ea1fe5c597258c143d27e2a1247 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>