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

188 Commits

Author SHA1 Message Date
Maurice Kalinowski
91df4c8ef8 Add README for using auto tests
As running the unit tests requires a specific setup, this should be
documented.

Change-Id: Ia9059e6590c54bd232842fc02a4dc91dd630f48f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-02-02 07:59:27 +00:00
Maurice Kalinowski
68fe97befd Fix reconnecting after transport error
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>
2018-02-02 07:59:24 +00:00
Maurice Kalinowski
50a203b7eb Fix error state handling
Checking for NoError was done on the wrong variable.

Change-Id: I3206333c0e69124ac22ccddcd329a63b7df0f761
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2018-02-02 07:59:20 +00:00
Maurice Kalinowski
45d87f0d92 Fix sync.profile
Currently CI was importing all modules and not just qtbase,
which is the only module it depends on.

Change-Id: I4ddb5773be5c4dff81126f885aca1b8c55b0ac49
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-12-15 07:17:03 +00:00
Lorenz Haas
5746eeff17 Fix test for fixed header completeness
The old test yield false if for example 3 bytes where received and the
second byte had no continuation bit but the third byte. In such a case
the third byte, however, is not part of the fixed header any more. Thus
the fixed header must considered complete.

Task-number: QTBUG-64965
Change-Id: Ie2853d11edeabc5ab3d06e98c3628af99a4d9ea8
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-12-05 09:45:02 +00:00
Maurice Kalinowski
6b6d2749e6 Fix subscriptions at reconnect
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>
2017-11-15 14:06:41 +00:00
Maurice Kalinowski
42c9128e48 Refactor QMqttMessage
As the class is exported now, move the data members to a private class.
Furthermore payload should just return a const-ref in case no copy is
needed.

Change-Id: I273d235431b2f4d6e2834b2a9c6934a23daf3962
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-11-15 14:06:33 +00:00
Lorenz Haas
6eca6f914d Introduce specific types for topic names and filters
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>
2017-11-15 13:18:31 +00:00
Maurice Kalinowski
b9369efc1e Refactor version check
Furthermore avoid qFatal and allow the user to gracefully handle an
invalid protocol version.

Change-Id: Idd3cbe9eaa53afd179691890f602354e4e26e9f1
Reviewed-by: Lorenz Haas <lorenz.haas@histomatics.de>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-11-14 07:21:25 +00:00
Maurice Kalinowski
6a6acf7edf Clean up
Second argument is superfluous in this case.

Change-Id: Id0b5444741375000929d26ea8567ba85b33f2ba7
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-11-14 07:21:22 +00:00
Maurice Kalinowski
70b7ee03c5 Fix publishing of data containing arbitrary content
Using QByteArray::append(const char*) checks for \0 and stops copying
into the payload. Instead use the QByteArray version, which ideally just
shares the data or uses the explicit size of the data, ignoring the
content of the data.

Change-Id: Ifdabd7508c738fbd9b3967a745904f1cc95dfb7d
Reviewed-by: Lorenz Haas <lorenz.haas@histomatics.de>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-11-14 07:21:19 +00:00
Maurice Kalinowski
17ce0ba084 Remove indirection from QMqttConnection to data values
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>
2017-11-14 07:21:16 +00:00
Maurice Kalinowski
cd1d60ec71 Do not block on connectToHost
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>
2017-11-10 09:43:33 +00:00
Leena Miettinen
9ec7f0625b Doc: Edit QMqttClient::ClientError docs
Change-Id: I1f533a26e9e8fd20ec7f5ad2416fe56cab76e24e
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-11-09 08:19:51 +00:00
Leena Miettinen
15a17dfdb5 Doc: Add docs for QMqttClient::ProtocolViolation
Change-Id: I247ce3538a5c360cd0fd15551f3d3ccd3195406c
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-11-08 11:59:25 +00:00
Leena Miettinen
c47ec548e7 Doc: Describe publish-and-subscribe, topics, and security
Add an image.

Change-Id: I1b0b1648f0b6a6315073aec86cd96b7ca5402ddc
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-11-08 11:48:02 +00:00
Leena Miettinen
9044b0bfab Doc: Use generic thumbnail for WebSockets MQTT Subscription example
The example has no UI and Qt Creator requires an image for the
Welcome page Examples tab.

Change-Id: I9371583d4fd117a617e4b32c67557600802f18cd
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-11-08 09:39:21 +00:00
Leena Miettinen
f8b878e05b Doc: Add dependency to Qt Web Sockets to enable linking to it
Change-Id: I992306ea2cfcd8eb189f4886508d11de07d92323
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-11-08 09:08:46 +00:00
Leena Miettinen
10d8fb1fef Doc: Add screenshot and details to Qt MQTT example docs
Change-Id: Ib3f1eaac6bc09ee40ea0244c3445eee354f0d965
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-11-08 08:47:29 +00:00
Leena Miettinen
6d4ca0a999 Doc: Add screenshot and details to Simple MQTT Client example docs
Change-Id: Idd0549a40365f12dc7cbe1f73696cb6cef1138f4
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-11-08 08:46:44 +00:00
Leena Miettinen
7bc7efd1b9 Doc: Add docs for MQTT Subscriptions example
Change-Id: Ia5c3b6cc76f6938f4b315215f0c8351f6ae434d9
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-10-26 07:12:28 +00:00
Leena Miettinen
22598170f6 Doc: Fix link to MQTT specification by adding a missing file
This file was somehow overlooked in a previous commit.

Change-Id: Ibfd5622cb23b66559e72e24eaf3112ef4aee45fa
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-10-26 07:12:15 +00:00
Lorenz Haas
dcbadaddea Close connection on protocol violation
According to the standard's section "4.8 Handling errors" the client
must close the current connection if it encounters a protocol violation.

Change-Id: I0be8fb381d42e7d90dd871d3a959fce9d478ea65
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-10-24 15:10:41 +00:00
Maurice Kalinowski
ea0d792a44 Refactor state and error handling
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>
2017-10-18 07:39:03 +00:00
Lorenz Haas
899cd2d31e Allow client IDs that do not follow the standard's advice
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>
2017-10-17 10:57:06 +00:00
Lorenz Haas
460e466c3f Ensure valid read buffer when parsing the fixed header
Since the remaining length can be up to 4 bytes long make sure that
there are enough bytes transmitted to parse the fix header correctly.

Change-Id: I3830d3abb308c86048cac3a00a80067194caa482
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-10-16 08:34:24 +00:00
Maurice Kalinowski
7b41e6039f Doc: Adding and editing the docs
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>
2017-10-16 08:12:51 +00:00
Lorenz Haas
5e7be337f0 Make packet identifier standard conformant
The standard requires that the identifier is non-zero and currently
unused. The identifier has also to be unique in the scope of the client,
not only to SUBSCRIBE, UNSUBSCRIBE, and PUBLISH messages.

Change-Id: Ide1546dbc3282fe256f08f9d3cd779ffea0318a5
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-10-15 12:59:51 +00:00
Maurice Kalinowski
828348f6aa Use Qt5-style connect and QOverload
Change-Id: I589649329858e074f0bbc1feb89bb4da2c1e25b2
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2017-10-12 14:40:43 +00:00
Maurice Kalinowski
d19e693e5c Resize example user interfaces
On some displays they appeared too small.

Change-Id: Iea63f866b3fa7116a4bcb46397d38f4336018594
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-10-10 08:43:16 +00:00
Jani Heikkinen
984527e516 Update license headers
Change-Id: If9b7f82a71ec554b152485ddd91a9d105019c6ce
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-09-25 11:58:23 +00:00
Maurice Kalinowski
0693346b4e Revert "Disable auto tests"
This reverts commit ca21591cdb.

Provisioning scripts should be done now and tests be able to run
on Windows and Linux.

Change-Id: I04eeb12ebcf6486902fa624f55fed0f4728c473d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-23 06:38:07 +00:00
Maurice Kalinowski
776cb76226 Fix launching broker on testmachine
PYTHON3_PATH only returns the directory containing python.
If the environment variable is not set, assume python3 to be in the
path.

Circumvent potential issues when launching the broker, but broker not
being ready to handle connections.

Change-Id: I594e21286bae8b4646fa079c9294d34102c57e66
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-23 06:37:57 +00:00
Maurice Kalinowski
3840db5254 Do not unsubscribe on disconnect
Sending UNSUBSCRIBE for all subscriptions before disconnecting will
cause the broker to not store any messages afterwards by the standard.
However, mosquitto does so and hence conformance tests succeeded even
though they should not have. This was revealed when using the paho
conformance testing broker in the CI.

Task-number: QTBUG-63318
Change-Id: I5c2410b45b7c0e5bf5cebeb13a8aa8dfd9f0ae3a
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-09-23 06:37:51 +00:00
Maurice Kalinowski
ca21591cdb Disable auto tests
Currently updating the provisioning scripts is not possible. Hence, the
paho test broker cannot be installed on test machines and tests not be
run.

Change-Id: I3ba2c5453101dc52378c96684e5324a3c06367a8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2017-09-04 13:49:12 +00:00
Maurice Kalinowski
5986b03bad Change signature of QMqttClient::subscribe
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>
2017-09-01 18:52:20 +00:00
Maurice Kalinowski
efbe33940b Doc fixes
Change-Id: I5000baabdc176ea1fe5c597258c143d27e2a1247
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-09-01 06:57:37 +00:00
Maurice Kalinowski
e3ea7f3b1a Only run tests on supported platforms
Change-Id: I49e3b69cfd514c6a37f8069295b1325548d1f8af
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2017-08-30 13:29:56 +00:00
Maurice Kalinowski
058e2ad073 Update signal signature
Change-Id: Ie76f1bee3e6299ebd3f684faa7c3023716f7098e
Reviewed-by: hjk <hjk@qt.io>
2017-08-30 08:26:51 +00:00
Maurice Kalinowski
1ef601a2a1 Fix includes in example
Change-Id: I1cb67eabaaf3ef40f4e0fe07a2bf5a5852861fe2
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-08-30 08:26:48 +00:00
Maurice Kalinowski
cd7c87b0d8 Rename ping receival signal
Change-Id: I52320fd58305a3ba38c77e2da8589c35b54cd73e
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-08-30 08:26:45 +00:00
Maurice Kalinowski
1252cdd4b1 Rename test class name
Change-Id: I3a4f547bea9101154814060bcf16ff0c2b6c013a
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-08-30 07:37:08 +00:00
Maurice Kalinowski
b383d49034 Remove hardcoded test server
Change-Id: I846a7247850648b5e0f63b91d1bd31caec0d185d
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-08-30 07:37:03 +00:00
Maurice Kalinowski
609fa14f0b Mark benchmark as such and remove testcase config
This disables CI from running the test

Change-Id: I16ca0edc2230ac915f324f1c61fd879d92718849
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-07-24 11:09:44 +00:00
Maurice Kalinowski
1aabd239af Only build benchmarks in release mode
Fixes CI build as well.

Change-Id: I8d36596e89bb266c2e5c51c14dc35025b6192ce0
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-07-24 10:48:35 +00:00
Maurice Kalinowski
b5c372ec0f Fix build with format-security warning set
Change-Id: I8e1ec4978e11acee7cea765fd9929d065c9577ec
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-07-24 10:36:45 +00:00
Maurice Kalinowski
e4a81125a6 Update license header in documentation
Change-Id: Iec89e714175539975cd095d6bd9cdb7b5597ba62
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-07-19 10:48:55 +00:00
Maurice Kalinowski
8494c39d58 header cleanup
Change-Id: I6dbe8e3a7834611c59a2dcdf6d60d602b558ac9a
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-07-18 07:16:00 +00:00
Maurice Kalinowski
5fe83f3fba Make QMqttClient::publish invokable
Even though there is no default QML binding available, it is pretty easy
to use QMqttClient directly exported like in the example. A user then
might want to publish messages in addition to receiving them.

Change-Id: I81e9ad61ffea7c833317986bbf5b5acf293a2ccd
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2017-07-05 13:41:00 +00:00
Maurice Kalinowski
9ea31d4948 Update module version to match Qt
Change-Id: I066d05c6bdee78ed25ed99b08402cd95a2940e76
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-07-05 07:21:19 +00:00