Compare commits

...

50 Commits

Author SHA1 Message Date
Qt Submodule Update Bot fc48adb437 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Iff9cf0e6781e33507641f3112518f3df13abfd65
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-09-17 03:39:08 +00:00
Qt Submodule Update Bot ed64498884 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ie3e41f2cdd603a45857114db620d340751d02635
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-09-12 04:14:09 +00:00
Qt Submodule Update Bot feaab0d09e Update dependencies on 'dev' in qt/qtcoap
Change-Id: I559b155a73c774389acb2a214ebcabe3f7a6ed8c
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-09-09 09:32:04 +00:00
Volker Hilsheimer d1edf59e2e QCoapClient: remove documentation about custom transport
Neither QCoapConnection nor QCoapQUdpConnection are public classes, and
there is no QCoapClient constructor (or other API) that would accept a
connection-instance.

Task-number: QTBUG-139697
Pick-to: 6.10 6.9 6.8
Change-Id: I3024d886299175401557a0b30987e98ab80b956f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-09-05 17:18:53 +02:00
Qt Submodule Update Bot 66e3a99700 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ie70b254a66dfa5623742482ca278816f7214dcce
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-09-05 05:11:07 +00:00
Qt Submodule Update Bot 980443ff65 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I38b40d13eb15376d0558544a6724be1ae730ad7e
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-09-01 12:05:36 +00:00
Qt Submodule Update Bot ff41dfbbf4 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I1ce92a306515c500a12ae70376ae39076cfa0b5d
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-08-25 04:30:02 +00:00
Qt Submodule Update Bot 398b0ca080 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I690c48a47b6cbc50ae2602c684102b433be929e0
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-08-21 05:01:17 +00:00
Qt Submodule Update Bot 4e08b0e7c0 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I34d497178bacf4b60e11878f3d232065a40415b9
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-08-18 08:48:36 +00:00
Qt Submodule Update Bot f6509ba532 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I8c4b5c7cb4cff22f208753299061e1759a3fd305
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-08-14 08:54:01 +00:00
Qt Submodule Update Bot cd1fc74704 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ic7d41867484c671c7e96210b03704b8834382710
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-08-13 04:50:52 +00:00
Qt Submodule Update Bot f39277bf14 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ia50edc5612ad23f38b781526aa5ce863eab1f026
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-08-08 17:35:45 +00:00
Topi Reinio 241da3cf7c Doc: Fix incorrect usage of \generatelist
The \generatelist command takes an optional argument
that affect how the members are listed, for example,
`classesbymodule` which creates an annotated list of
the classes in a named C++ module.

`groupsbymodule` is not recognized or documented. QDoc
falls back to generating a list of all members of a
group in this case. While the end result is correct,
this relies on an undocumented feature that is likely
to change and break.

Replace these instances with an explicit \annotatedlist
command that produces the same output.

Pick-to: 6.10
Task-number: QTBUG-138901
Change-Id: I0c23dac38445e41940907cf32a6da6fe3b769f7f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-08-06 09:14:57 +00:00
Qt Submodule Update Bot d7928a43b0 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ibd0f980b81bbce15b38cfdaea84f649afb59615e
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-08-05 04:18:47 +00:00
Ivan Solovev de51e04450 Mark the rest of the files in QtCoAP as security-significant
The previous commits identified and marked all security-critical files.
This commit marks the rest of the module with the default security
level (i.e. significant).

Fixes: QTBUG-135752
Pick-to: 6.10 6.9 6.8
Change-Id: I5ca76189504a2dfa1143def36abaafcca14bbcf5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-08-01 15:18:07 +02:00
Ivan Solovev 27beb42a33 Mark qcoapresourcediscoveryreply.cpp as security-critical
The QCoapResourceDiscoveryReplyPrivate::resourcesFromCoreLinkList()
method parses the resource discovery reply according to the CoRE Link
Format.

Task-number: QTBUG-135752
Pick-to: 6.10 6.9 6.8
Change-Id: I274c6ea467ccafe8d8bef1230a87d0c12d79dbc8
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-08-01 15:18:07 +02:00
Ivan Solovev d28ae1fef4 QCoapClient::post(): align the implementation with the docs
The docs clearly mention that a null device is treated as empty content.
However, the code was simply returning a nullptr in such case instead
of posting an actual request with an empty data.

As a drive-by, update the docs to actually mention that if the original
request has a payload, it will be used in such case. That is how the
QBA overload behaves.

[ChangeLog][Important Behavior Changes][QCoapClient] The post() overload
that takes a QIODevice* now behaves according to the documentation.
Specifically, if the provided QIODevice* is null, it will act as if an
empty QByteArray was provided instead of simply returning nullptr.

Change-Id: If8848515c71bd48f15e7672be6e184f903ce576d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-08-01 15:18:07 +02:00
Qt Submodule Update Bot 2dcc46856e Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ic54574353ee6d682e1df4111c98e1cc5ee44522b
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-08-01 11:07:31 +00:00
Ivan Solovev 95a161861b Explicitly mark qcoaprequest.cpp as significant
Various methods in this file parse and adjust the user-provided URL.
However, they do it by using the public QUrl APIs only. Since QUrl
itself is security-critical, this file can be marked with the default
security score.

Task-number: QTBUG-135752
Pick-to: 6.10 6.9 6.8
Change-Id: I556a5b171aa0b1944688d5d87ab2279c13277ec3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-08-01 10:46:13 +02:00
Ivan Solovev 19498bed65 Mark files that implement the CoAP protocol as security-critical
The QCoapInternalMessage::setFromDescriptiveBlockOption() method
implements a part of the CoAP protocol, so mark qcoapinternalmessage.cpp
as security-critical.

The QCoapInternalReply class has createFromFrame() and nextBlockToSend()
methods that implement parts of the CoAP protocol, so mark
qcoapinternalreply.cpp as security-critical.

The QCoapInternalRequest class contains multiple methods that
implement the CoAP protocol (e.g. toQByteArray() or blockOption()), so
mark qcoapinternalrequest.cpp as security-critical.

The QCoapProtocol class implements the high-level details of the CoAP
protocol. It does not directly parse the data or generate the frames,
but contains the logic to call the proper low-level implementation.
Therefor, mark it as security-critical as well.

Task-number: QTBUG-135752
Pick-to: 6.10 6.9 6.8
Change-Id: I84855b6c352356f6163f7310b2d7075fd86bc9d4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-08-01 10:46:07 +02:00
Ivan Solovev 163b5e619b Docs: clarify QCoapClient::put() QIODevice overload
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ib3c4f5b82803a83bafe10ba56a3d01b61287a0c5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-08-01 08:45:58 +00:00
Ivan Solovev b80c11bf00 QCoapResourceDiscoveryReply: do not copy QByteArrays when iterating
Take them by const ref instead.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Iaf24edcc63d7ff7f682ced01665753a6a94f95dd
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-07-30 09:33:00 +02:00
Ivan Solovev d85ded9e40 QCoapResourceDiscoveryReply: store QString's size in qsizetype
... instead of an int. The int variable had a risk of overflow, which
is technically an UB. However, in practice it would have silently
resulted in a negative value.
The only usage of the variable is a call to QString::mid(), which
handles the negative second parameter as "provide data until the end
of the string".

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ic95de0ceba09e02b726ab90407d637c449da2ccd
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-07-30 09:32:57 +02:00
Ivan Solovev f310b4a5a2 QCoapReply: add test for a chunked read
QCoapReply is a QIODevice, but it was not obvious if readData() is
implemented properly, or if it also needed to update pos().

This patch adds a unit test that checks a chunked read from the reply.
The test passes, so nothing needs to be fixed in the implementation.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I0642718f21a31cf978a733bc3bc742ad1eb47b3a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-07-30 09:32:54 +02:00
Ivan Solovev a292490ba6 QCoapOption: use qt_ptr_swap() instead of qSwap()
It's faster when we know that we operate on pointers.

Change-Id: I1366c96159ff65186f2aa67d397772b5a4d4c5bd
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-07-30 09:32:50 +02:00
Ivan Solovev 11df2d4c33 Optimize QCoapClient::observe()
There's no need to call get() once the request was created. It will
simply result in unnecessary copy of the request.
We can call sendRequest() directly instead.

Change-Id: I313a186478b4f2e9701c46e83d80c091f5a64a5f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-07-30 09:32:47 +02:00
Qt Submodule Update Bot db77da4802 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I056102f02bf884b3d43b73e61968162e67963572
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-07-30 04:33:59 +00:00
Qt Submodule Update Bot 8df5be74a0 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I2a924e1934fe4943ba4b4ca623edbadea6ad2c9e
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-07-18 03:23:22 +00:00
Lucie Gérard 72953e45c4 Remove year from Qt Copyright in REUSE.toml
Change-Id: If05e5a7c1a0c68b022360e680b8b43e086a4e724
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-07-14 09:46:45 +02:00
Qt Submodule Update Bot 10ae4b6665 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I7d007931a33d1ff69fb4391f4afa24d51917f0cd
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-07-10 14:05:22 +00:00
Qt Submodule Update Bot fc4eda33f1 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I705c9c4264d79717cc328bb68eb8665ecbd9de40
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-07-09 06:46:15 +00:00
Qt Submodule Update Bot 533c0d18f9 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I95b6adb52d709d3daa60c204bf7230946bc2e757
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-07-06 21:54:55 +00:00
Qt Submodule Update Bot c7da497512 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ia7fe8c6bd1dd1ddc371626c4d19f51d7db765adf
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-07-03 05:06:44 +00:00
Qt Submodule Update Bot ad485a7171 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I16ae1607fb4197b55316ad93913cfa8a7d1b686b
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-07-01 13:37:29 +00:00
Qt Submodule Update Bot 9b58df71a8 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I3b2dcc80edc3ffb589c1952495f8ffe7c004375c
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-30 06:00:59 +00:00
Qt Submodule Update Bot 8540256517 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ic8018404b44611813eb31ebd8f10f8804041ded9
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-27 07:32:32 +00:00
Qt Submodule Update Bot f38eff095e Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ieadf27ef705ca882b88c99d208a37fa6ed33a781
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-25 10:51:06 +00:00
Qt Submodule Update Bot e26601dac4 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ied131ddbd2854d9bf5128e00e0d5f4f62b1a6329
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-22 18:16:46 +00:00
Cristian Le 6f5de771d9 Move `qt_internal_project_setup` as early as possible
The earliest we can move this is right after `BuildInternals`. This
allows us to add function calls before navigating the `find_package`
tree of the dependents.

Task-number: QTBUG-135233
Change-Id: I6330c79688c3b5fe566165ffb90658092a8c96b1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-20 15:26:54 +02:00
Qt Submodule Update Bot cc2d8bb958 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I5fed922989fe6ba190f0705f4998e1a4a2bdcf0e
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-20 11:41:10 +00:00
Qt Submodule Update Bot 4aa77ed0db Update dependencies on 'dev' in qt/qtcoap
Change-Id: I956d4e3465875f0a67ab09f83788af254f63a0b5
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-17 17:00:39 +00:00
Qt Submodule Update Bot b37714a28e Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ic3632e320a8c2cdca215ab15a39bec6eea0e1c40
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-16 13:03:22 +00:00
Qt Submodule Update Bot b73c764d25 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ied96e0d54ce7a99161fb57b60ea7ecfc4590105d
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-14 14:55:25 +00:00
Qt Submodule Update Bot 39c77b56d3 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I4b7b076093949a722cf421c7cd4c2e18d946995e
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-11 09:09:08 +00:00
Qt Submodule Update Bot 0c050f2182 Update dependencies on 'dev' in qt/qtcoap
Change-Id: Ib71b7babab386260ae5cac14b3129cdef72f8f14
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-07 18:33:05 +00:00
Jani Heikkinen 2f67264d54 Bump version to 6.11.0
Change-Id: I128777056c484d0398b712f39751ee04a140eef8
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-05 16:29:28 +01:00
Qt Submodule Update Bot e1a1fa96bc Update dependencies on 'dev' in qt/qtcoap
Change-Id: I427a7b13c456060dbb57c452834cf23e33e214fd
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-05 15:29:27 +00:00
Qt Submodule Update Bot 14ff760873 Update dependencies on 'dev' in qt/qtcoap
Change-Id: If7e6aaedae8a6007c90379e1458c5a826f3e79e4
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-04 18:51:14 +00:00
Marc Mutz 0ea08d303c Normalize signal/slot signatures 2025
This is the result of running util/normalize on the code base. The
following manual edits were needed:

(none)

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ia18b3968bc164a8dce5e7cca7653c759646cc4da
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-06-04 15:00:33 +02:00
Qt Submodule Update Bot 5bd6c49990 Update dependencies on 'dev' in qt/qtcoap
Change-Id: I842f695002a01a63634bcd7af72cd231996303dd
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-03 13:15:27 +00:00
47 changed files with 100 additions and 28 deletions

View File

@ -1,4 +1,4 @@
set(QT_REPO_MODULE_VERSION "6.10.0")
set(QT_REPO_MODULE_VERSION "6.11.0")
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1")
list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_FOREACH=1")

View File

@ -11,7 +11,13 @@ project(QtCoap
LANGUAGES CXX
)
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core Network)
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals)
# This should be called as early as possible, just after find_package(BuildInternals) where it is
# defined.
qt_internal_project_setup()
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core Network)
find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS Gui Widgets Quick Qml)
if(NOT QT_FEATURE_udpsocket)
@ -19,6 +25,4 @@ if(NOT QT_FEATURE_udpsocket)
return()
endif()
qt_internal_project_setup()
qt_build_repo()

View File

@ -3,34 +3,34 @@ version = 1
[[annotations]]
path = ["**/.gitattributes", "**.gitignore", "**.gitreview"]
precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = [".tag", ".cmake.conf", "**.yaml", "**.yml", "**ci_config_linux.json"]
precedence = "closest"
comment = "build system"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
SPDX-License-Identifier = "BSD-3-Clause"
[[annotations]]
path = ["examples/**"]
comment = "this must be after the build system table because example and snippets take precedence over build system"
precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = ["**/README*", "**.qdocconf", "src/coap/doc/style/style.css"]
comment = "documentation"
precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"
[[annotations]]
path = ["**.toml", "licenseRule.json"]
precedence = "override"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]

View File

@ -1,4 +1,4 @@
dependencies:
../qtbase:
ref: 71842cfb89da0bed1efd6cf7a567550d9e8119f6
ref: 6db355c6cd1c668ee79bcdccfdc4d5cbc379833f
required: true

2
dist/REUSE.toml vendored
View File

@ -4,5 +4,5 @@ version = 1
path = ["*"]
precedence = "override"
comment = "Licensed as documentation."
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-FileCopyrightText = "Copyright (C) The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"

View File

@ -67,5 +67,5 @@
In addition, it is available under the
\l{GNU General Public License, version 3}.
\generatelist{groupsbymodule attributions-qtcoap}
\annotatedlist attributions-qtcoap
*/

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapclient_p.h"
#include "qcoapprotocol_p.h"
@ -130,10 +131,6 @@ QCoapClientPrivate::~QCoapClientPrivate()
The default for \a securityMode is QtCoap::NoSecurity, which
disables security.
This connects using a QCoapQUdpConnection; to use a custom transport,
sub-class QCoapConnection and pass an instance to one of the other
constructors.
*/
QCoapClient::QCoapClient(QtCoap::SecurityMode securityMode, QObject *parent) :
QObject(*new QCoapClientPrivate(new QCoapProtocol, new QCoapQUdpConnection(securityMode)),
@ -258,7 +255,8 @@ QCoapReply *QCoapClient::put(const QCoapRequest &request, const QByteArray &data
Sends the \a request using the PUT method and returns a new QCoapReply
object. Uses \a device content as the payload for this request.
A null device is treated as empty content.
A null device is treated as empty content, in which case the payload of the
\a request will be used.
\note The device has to be open and readable before calling this function.
@ -305,7 +303,8 @@ QCoapReply *QCoapClient::post(const QCoapRequest &request, const QByteArray &dat
Sends the \a request using the POST method and returns a new QCoapReply
object. Uses \a device content as the payload for this request.
A null device is treated as empty content.
A null device is treated as empty content, in which case the payload of the
\a request will be used.
\note The device has to be open and readable before calling this function.
@ -313,10 +312,7 @@ QCoapReply *QCoapClient::post(const QCoapRequest &request, const QByteArray &dat
*/
QCoapReply *QCoapClient::post(const QCoapRequest &request, QIODevice *device)
{
if (!device)
return nullptr;
return post(request, device->readAll());
return post(request, device ? device->readAll() : QByteArray());
}
/*!
@ -444,7 +440,7 @@ QCoapReply *QCoapClient::observe(const QCoapRequest &request)
d->connection->isSecure());
copyRequest.enableObserve();
return get(copyRequest);
return d->sendRequest(copyRequest);
}
/*!

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPCLIENT_H
#define QCOAPCLIENT_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPCLIENT_P_H
#define QCOAPCLIENT_P_H

View File

@ -1,5 +1,6 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapconnection_p.h"

View File

@ -1,5 +1,6 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPCONNECTION_P_H
#define QCOAPCONNECTION_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPGLOBAL_H
#define QCOAPGLOBAL_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:critical reason:network-protocol
#include "qcoapinternalmessage_p.h"
#include "qcoaprequest_p.h"

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPINTERNALMESSAGE_P_H
#define QCOAPINTERNALMESSAGE_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:critical reason:network-protocol
#include "qcoapinternalreply_p.h"
#include <QtCore/qmath.h>

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPINTERNALREPLY_H
#define QCOAPINTERNALREPLY_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:critical reason:network-protocol
#include "qcoaprequest.h"
#include "qcoapinternalrequest_p.h"

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPINTERNALREQUEST_H
#define QCOAPINTERNALREQUEST_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapmessage_p.h"

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPMESSAGE_H
#define QCOAPMESSAGE_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPMESSAGE_P_H
#define QCOAPMESSAGE_P_H

View File

@ -1,5 +1,6 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapnamespace_p.h"

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include <QtCoap/qcoapglobal.h>
#include <QtCore/qobject.h>

View File

@ -1,5 +1,6 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPNAMESPACE_P_H
#define QCOAPNAMESPACE_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapoption_p.h"
@ -157,7 +158,7 @@ QCoapOption &QCoapOption::operator=(QCoapOption &&other) noexcept
*/
void QCoapOption::swap(QCoapOption &other) noexcept
{
qSwap(d_ptr, other.d_ptr);
qt_ptr_swap(d_ptr, other.d_ptr);
}
/*!

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPOPTION_H
#define QCOAPOPTION_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPOPTION_P_H
#define QCOAPOPTION_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:critical reason:network-protocol
#include "qcoapprotocol_p.h"
#include "qcoapinternalrequest_p.h"

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPPROTOCOL_P_H
#define QCOAPPROTOCOL_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapqudpconnection_p.h"
#include <private/qcoapnamespace_p.h>

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPQUDPCONNECTION_P_H
#define QCOAPQUDPCONNECTION_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapreply_p.h"
#include "qcoapinternalreply_p.h"

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPREPLY_H
#define QCOAPREPLY_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPREPLY_P_H
#define QCOAPREPLY_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoaprequest_p.h"

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPREQUEST_H
#define QCOAPREQUEST_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPREQUEST_P_H
#define QCOAPREQUEST_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapresource_p.h"

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPRESOURCE_H
#define QCOAPRESOURCE_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPRESOURCE_P_H
#define QCOAPRESOURCE_P_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:critical reason:data-parser
#include "qcoapresourcediscoveryreply_p.h"
#include "qcoapinternalreply_p.h"
@ -108,14 +109,14 @@ QCoapResourceDiscoveryReplyPrivate::resourcesFromCoreLinkList(const QHostAddress
QLatin1String quote = QLatin1String("\"");
const QList<QByteArray> links = data.split(',');
for (QByteArray link : links) {
for (const QByteArray &link : links) {
QCoapResource resource;
resource.setHost(sender);
const QList<QByteArray> parameterList = link.split(';');
for (QByteArray parameter : parameterList) {
for (const QByteArray &parameter : parameterList) {
QString parameterString = QString::fromUtf8(parameter);
int length = parameterString.size();
const qsizetype length = parameterString.size();
if (parameter.startsWith('<'))
resource.setPath(parameterString.mid(1, length - 2));
else if (parameter.startsWith("title="))

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPRESOURCEDISCOVERYREPLY_H
#define QCOAPRESOURCEDISCOVERYREPLY_H

View File

@ -1,6 +1,7 @@
// Copyright (C) 2017 Witekio.
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPRESOURCEDISCOVERYREPLY_P_H
#define QCOAPRESOURCEDISCOVERYREPLY_P_H

View File

@ -1,5 +1,6 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#include "qcoapsecurityconfiguration.h"

View File

@ -1,5 +1,6 @@
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt-Security score:significant reason:default
#ifndef QCOAPSECURITYCONFIGURATION_H
#define QCOAPSECURITYCONFIGURATION_H

View File

@ -18,6 +18,7 @@ private Q_SLOTS:
void updateReply();
void requestData();
void abortRequest();
void readReplyChunked();
};
void tst_QCoapReply::updateReply_data()
@ -117,6 +118,39 @@ void tst_QCoapReply::abortRequest()
QVERIFY(arguments.at(0).toByteArray() == "token");
}
void tst_QCoapReply::readReplyChunked()
{
const QByteArray token = "\xAF\x01\xC2";
const quint16 id = 645;
const QByteArray payload = "this is some payload";
QScopedPointer<QCoapReply> reply(QCoapReplyPrivate::createCoapReply(QCoapRequest()));
QCoapMessage message;
message.setToken(token);
message.setMessageId(id);
message.setPayload(payload);
QMetaObject::invokeMethod(reply.data(), "_q_setContent",
Q_ARG(QHostAddress, QHostAddress()),
Q_ARG(QCoapMessage, message),
Q_ARG(QtCoap::ResponseCode, QtCoap::ResponseCode::Content));
QMetaObject::invokeMethod(reply.data(), "_q_setFinished",
Q_ARG(QtCoap::Error, QtCoap::Error::Ok));
QCOMPARE_EQ(reply->pos(), 0);
const qsizetype startBytes = 7;
const QByteArray start = reply->read(startBytes);
QCOMPARE_EQ(start, payload.first(startBytes));
QCOMPARE_EQ(reply->pos(), startBytes);
QByteArray last(100, Qt::Uninitialized);
const qint64 read = reply->read(last.data(), last.size());
QCOMPARE_EQ(read, payload.size() - startBytes);
QCOMPARE_EQ(reply->pos(), payload.size());
last.resize(read);
QCOMPARE_EQ(start + last, payload);
}
QTEST_MAIN(tst_QCoapReply)
#include "tst_qcoapreply.moc"