1
0
mirror of https://github.com/qt/qtmqtt.git synced 2026-10-25 16:16:26 +00:00
Commit Graph

112 Commits

Author SHA1 Message Date
Maurice Kalinowski
0ea88f5824 Fix handling of multiple wildcards
The matching check for topic filters did not take into account that a
mixture of wildcards is valid. While # is only allowed a single time,
using + is valid in multiple occasions and can also me mixed with other
wildcards.

Fixes: QTBUG-104478
Pick-to: 6.2
Change-Id: I04129d5fbbb21c95115a15d74c6787804a8d0b10
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
(cherry picked from commit 95b38eafb5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 81854688bd)
2023-11-30 16:19:22 +00:00
Maurice Kalinowski
a762ce9405 Fix topic wildcard checks
A topic can have multiple '+' wildcards, but isValid was searching for
the wrong wildcard at the second instance.

Pick-to: 6.2
Change-Id: I83e3fa258ef01b26388c0e6fd8c17a0a140ab75a
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
(cherry picked from commit fb417c44dd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit f6a737c636)
2023-11-30 16:19:22 +00:00
Friedemann Kleint
d0e8ed66b3 Remove remains of qmake conversion from CMakeLists.txt files
Change-Id: I5b961e2c9f5cd1736f7fcce502aeec2d47677818
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 58abef008e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-02-10 12:00:06 +00:00
Marc Mutz
1f9db883c7 Monthly re-run of clang-tidy qt-* checks (11/2022)
Change-Id: I00c8db5d6b8d37b2ea3bcee29982901c8acf5490
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2022-11-02 18:11:07 +01:00
Maurice Kalinowski
5277f58a2a Fix potential race condition for receiving messages
When iterating through the list of active subscriptions to emit the
messageReceived signal, the handler can add further subscriptions, which
renders the iterator to be invalid. Instead store the subscriptions in a
list, which are supposed to receive the signal and only act upon these.

Fixes: QTBUG-106203
Pick-to: 6.4 6.2 5.15
Change-Id: I790a6081c332e82da8e53b15df8ad8494f35cc46
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2022-10-19 06:41:12 +02:00
Marc Mutz
fe687108b6 Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:

  auto QtContainerClass = anyOf(
      expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
      expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.

Change-Id: Ieb49171212fd72c685ba27cb39aaec9cbaf3a701
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-10 20:28:18 +02:00
Maurice Kalinowski
56439080fa Fix wildcard filter matching
Each sub item in the filter tree needs to be directly compared. Using
startsWith causes invalid elements to be marked as matching.

Fixes: QTBUG-92817
Pick-to: 6.4 6.2 5.15
Change-Id: I439d9325b58fd0aa57fb4ead8db48edb4188ebee
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2022-09-29 08:34:31 +02:00
Lucie Gérard
3012258ec3 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I9caf6ad52cd6a0a63ce7ff37ce189ec4b368befd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2022-08-23 10:00:53 +02:00
Alexandru Croitor
10354c36cc CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers
Change-Id: I3459287fe6f9b2d257e283d6a85d9269741f5df1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-28 11:42:22 +02:00
Lucie Gérard
d431a18c5c Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I40135f08b4e89e8e034ec764ffed3273fc60646a
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2022-07-07 10:10:51 +02:00
Lucie Gérard
edd6855344 Use SPDX license identifiers
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>
2022-06-16 10:22:20 +02:00
Maurice Kalinowski
e7324b5de6 Add support for nolocal subscriptions
No Local subscription allow for filtering on the server side.
If a client subscribes and publishes a message on the same topic,
it will not be routed back.

Fixes: QTBUG-100862
Change-Id: I363361d0267aba740d07483c04ce0d4c30b5e14c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2022-05-03 08:21:30 +00:00
Alexandru Croitor
42c369b43b CMake: Bump almost all cmake_minimum_required calls to 3.16
Needed for subsequent change that will check and error out if the
version is lower than 3.16. We do that to ensure all policies
introduced by CMake up to version 3.16 have their behavior set to
NEW.

Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: Ib00e7ecb09111745f3f9165b40fd1d9ae606e75a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-09-22 19:51:54 +02:00
Joerg Bornemann
f9ebebfce7 CMake: Disable usage of CMake API compatibility wrappers
Setting the QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS variable
in the project ensures we ported away from old API calls.

Task-number: QTBUG-86815
Change-Id: I589f0192370a932ac10088656eaee1e35a41ea73
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-26 21:04:15 +02:00
Joerg Bornemann
e9521ed745 Remove qmake project files
Task-number: QTBUG-88742
Change-Id: Ic545c3f2f3cff91e69e540d32a27ee02206ecf71
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2021-05-03 10:21:56 +02:00
Jani Heikkinen
5735946c27 Update dependencies on 'dev'
Also, remove optional dependency to websockets, which is not
part of Qt 6.0 and fix compile error against unsigned comparison.

Switch default test configuration to not launch TLS brokers.
Latest COIN updates causes paho to fail in the SSL setup.

Task-number: QTBUG-88189
Change-Id: I9d31f9e54801d269122878ab4cf7541512fdbe98
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-11-11 12:41:25 +01:00
Sona Kurazyan
87fbd09c2b Use QList instead of QVector in qtmqtt
Task-number: QTBUG-84469
Change-Id: Id8d2f39fabaec11babddf22cd7e77fb06048d2db
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-06-25 12:09:52 +02:00
Maurice Kalinowski
7477c29f47 Prefer utf8 instead of local8Bit
Change-Id: I19343409b5b9b9deeba37b8ef6a8ac688ec74341
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-06-03 16:21:40 +02:00
Alexandru Croitor
5ea20cc458 CMake: Regenerate projects
And use an updated coin instruction file.

Change-Id: I852d38febe9ecaa86c516b7f4a0451d0f80d8011
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-05-26 17:43:51 +02:00
Alexandru Croitor
a450023285 Merge remote-tracking branch 'origin/wip/cmake' into dev
Change-Id: I5074da47986bcc826d3990238b02ebe7e6cc3d2e
2020-05-26 17:38:47 +02:00
Maurice Kalinowski
07b7baf3ca Regenerate projects
Change-Id: I8b306c077030ffe1904d42f813f3b7cacc35a0c9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-05-26 15:23:16 +00:00
Konstantin Ritt
f702420627 Tst_QMqttClient: fix the FakeServer's response regarding payload size
Change-Id: Ia4df16b8ad37c1d241b959dfc4c3194b770c7813
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2020-05-06 11:16:06 +00:00
Maurice Kalinowski
e1ac865ac6 Add runtime check for different test server
Some test servers might have different configurations.
For instance, mosquitto broker provides a different
default value for topic aliases.

Change-Id: I00bc9c6b27d06358a352f9c0adb04e4044666aac
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-05-06 08:30:54 +02:00
Maurice Kalinowski
824635b275 Increase waiting time
mosquitto MQTT5 support seems to wait longer to send
will messages.

Change-Id: I2c13609e228319ce8fefc5e79d4f99bbfe0b061b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-05-06 08:30:51 +02:00
Alexandru Croitor
113f7ee864 Regenerate projects
Change-Id: I7574a6156e4c340ba94007176287a5d1bcb7f9e1
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-11-15 13:02:47 +00:00
Alexandru Croitor
77807be39b Add build and test instructions
Change-Id: I99a459ff5e7381c656105853db559568d2b272d9
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-06 09:08:37 +00:00
Maurice Kalinowski
4e5af443ef Add initial support for cmake
Change-Id: I40153b0f225d67afebfaf3ff0b1c43a9c2f69b8c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-09-02 07:06:48 +00:00
Maurice Kalinowski
dcf3bbb980 Add autoKeepAlive to QMqttClient
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>
2019-08-20 15:21:36 +02:00
Qt Forward Merge Bot
9a2e77fc1f Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	.qmake.conf

Change-Id: I39fabafba7b8bd591909ed6e32be619b1db73cf0
2019-07-11 14:44:26 +02:00
Liang Qi
f0a4f3f43b Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	.qmake.conf
	src/mqtt/qmqttclient.cpp

Change-Id: I2b050319270fb365416623998c758ab9ec63f69d
2019-07-03 09:29:12 +02:00
Maurice Kalinowski
d25a0abe78 Allow empty will messages
A will message is allowed to be empty. Hence, check whether a will topic
exists to identify incorporating the last will to the connect message.

Task-number: QTBUG-76783
Change-Id: Ifb7f5467e8e7e70c6d9c050b36a35df2419f4171
Reviewed-by: hjk <hjk@qt.io>
2019-07-02 12:52:04 +02:00
hjk
2c24a9ec62 Avoid deprecated use of QTime
Change-Id: If95c4f918b83057001bc43e01e9450ba1d08b475
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2019-07-01 15:42:31 +02:00
Qt Forward Merge Bot
96f3395cb8 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: Ia2af053a10b3b33a3f73bd3d10636e33ad2519c4
2019-04-27 03:03:26 +02:00
Qt Forward Merge Bot
93c3948c13 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: Ibf7dd449a020d2a1c4b391c91b019d9a5b68fa8b
2019-04-20 03:00:26 +02:00
Qt Forward Merge Bot
72257654cc Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Ice5a082f2a2a5e5341b8dbf0a2f0133ec8d303ca
2019-04-20 03:00:22 +02:00
Maurice Kalinowski
acff2f2611 Fix server test code
For MQTT 5 the fake server did not send any property information. Hence,
the client (potentially) read among the buffer.

Change-Id: I58c7d1b4a1f15a0803c04495c82537f648c8a642
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-04-18 08:13:48 +00:00
Maurice Kalinowski
c8a837521b Add libfuzzer test for receiving data
Change-Id: If08d050a92db812e95a668d141d8774e56f9516e
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-04-18 08:13:42 +00:00
Maurice Kalinowski
8ac8f61c76 Add secure connection with QSslConfiguration
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>
2019-03-04 09:02:12 +00:00
Maurice Kalinowski
7d2525e623 Rename shared subscription functions
As agreed on the review process, using sharedSubscription(Name) is more
verbose and descriptive.

Change-Id: I81fa5d9f74ecd12d3b90d485f67b52dfb4f70bf5
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2018-09-12 10:42:52 +00:00
Maurice Kalinowski
b3ee3a0fe1 Add test for subscription overlap
Furthermore also verifies subscription IDs are handled
properly.

Change-Id: I7bad65d6cbbe60fb005056dc0e31ef4e7a0a8ffa
Reviewed-by: hjk <hjk@qt.io>
2018-08-20 06:28:08 +00:00
Qt Forward Merge Bot
4bae427962 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I780e10a6fa43d24e2770be9b610a0579d4e66454
2018-08-18 03:00:50 +02:00
Kevin Funk
d84eeec724 Fix CMake unit tests
Before failed with:
.../qtmqtt/tests/auto/cmake/build/module_includes/main.cpp:4:16: fatal error: QMqtt: No such file or directory
       #include <QMqtt>
                ^~~~~~~

Task-number: QTBUG-68343
Change-Id: I1000f533b2b29558f3c2b0d23c64c2c621e641e5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-16 09:37:52 +00:00
Maurice Kalinowski
5ef7e409fb Add support for message status updates
A user might be interested in knowing the exact state of a message while
publishing or when a message is received.

Task-number: QTPM-1453
Task-number: QTBUG-66599
Change-Id: Ibf977f76ba6078b5b525ba00b6988d4b69960176
Reviewed-by: hjk <hjk@qt.io>
2018-08-14 03:47:04 +00:00
Maurice Kalinowski
d7cd172677 Fix tests for brokers with no server connection properties
VerneMQ does not send any server connection properties at all and relies
on the default values set by the standard. All other implementations
behave differently so far, mostly to set lower limits (i.e. max packet
size).

Change-Id: I01824640021651cfe752523803b9797aed197fc9
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-08-10 13:23:26 +00:00
Maurice Kalinowski
e8bdfe7b4c Rename QMqttPublishProperties::subscriptionIdentifiers
The standard did not mention it explicitly to be a list. However,
quoting "Multiple Subscription Identifiers will be included if the
publication is the result of a match to more than one subscription, in
this case their order is not significant" clearly indicates that
multiple subscription ids can be part of a publish message.

Change-Id: I1a45564a719847020e24aec7d0385807f3be3aa4
Reviewed-by: hjk <hjk@qt.io>
2018-08-09 10:30:36 +00:00
Maurice Kalinowski
b9ac8d04f2 MQTT5: Rename QMqttServerConnectionProperties::reasonString
Use reason() as name for consistency with other cases.

Change-Id: I9219a0fd47520f10f1c4b85fd0c4428dcc2d39a1
Reviewed-by: hjk <hjk@qt.io>
2018-08-09 10:30:17 +00:00
Maurice Kalinowski
0deebaab6d MQTT5: Introduce support for topic aliases
Task-number: QTPM-1490
Change-Id: Ie666d4c0dd75c08083a6860f345144ee1efb3d83
Reviewed-by: hjk <hjk@qt.io>
2018-08-08 04:39:20 +00:00
Maurice Kalinowski
4ffc9efc7b MQTT5: Introduce AUTH support
Task-number: QTPM-1455
Change-Id: I8eef500fe5eb0e8a36f449534c70e35487c04a7b
Reviewed-by: hjk <hjk@qt.io>
2018-08-02 09:15:55 +00:00
Maurice Kalinowski
bcc2a4e7b5 Disallow property changes while connected
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>
2018-08-02 07:43:40 +00:00
Maurice Kalinowski
001c3e7edc MQTT5: Add support for shared subscriptions
The scheme to create a shared subscription is $share/sharename/
topicfilter. During QMqttSubscription creation, the topic gets split and
shareName is a newly introduced property to verify whether a
subscription has been shared.

Task-number: QTPM-1452
Change-Id: I99c1aa9bb3bf8db2a930ce031c1a0a4882f01bcd
Reviewed-by: hjk <hjk@qt.io>
2018-07-30 11:52:32 +00:00