Add a proper public property to QCoapClient class, and also add
the getter and setter to the QCoapConnection private class.
The code in QCoapConnection uses the new private APIs from QtNetwork
(added in qtbase/83fc4ff9c20eb922113e08ba8566e077ce44dea3) to bind
the UDP socket to a specific network interface.
Since the new private QtNetwork APIs are not fully functional on
macOS, this patch also implements additional filtering of the
incoming datagrams based on the specified network interface.
The QCoapConnection instance lives in a helper thread, so the
implementation stores the specified QNetworkInterface in both
QCoapConnection and QCoapClient, and uses invokeMethod() to transfer
the value from the client to the connection.
A different approach could be to store the network interface in the
connection only, and use a QMutex to synchronize access to it, but
due to the mentioned problem with macOS, we need to access the
QNetworkInterface instance in QCoapConnection when processing each
received datagram, so locking a mutex looks like too much overhead
in this case.
[ChangeLog][QCoapClient] Added a bindInterface property that can be
used to bind the communication to a specific network interface.
Done-with: Ivan Solovev <ivan.solovev@qt.io>
Fixes: QTBUG-139697
Change-Id: Ib64691d4f4787fcbc25240da31ff059c2bf326fe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
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>
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>
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>
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>
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>
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>
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>
... 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>
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>
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>
The are not part of the public API.
Addresses header review comment, and amends
41b71d6187
Task-number: QTBUG-132090
Pick-to: 6.9
Change-Id: Iff94177bbd10b4f74e957e362e5a0c3ba72cf11f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
And especially not built-in types.
The re-registration in the QCoapClient constructor with a name will
register the alias, by calling QMetaType::registerNormalizedTypedef()
eventually.
Pick-to: 6.8
Change-Id: I936b144f20b97f55c9f4fffd5988373ea84ba1de
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Include documentation testing steps in coin/module_config.yaml and
set the warning limit to zero.
Task-number: QTBUG-130559
Change-Id: I0e34102e936db08861f1afb6f6687cf89165e191
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Declare those used in multiple translation units in a central header,
and make those that are used in a single translation unit static.
Change-Id: I4cd440cf5b4520a3df2df2aa1d49d7a708ef1fdc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit organizes the articles, so they:
- have a reasonable tree structure
- can be navigated through the topic tree in the Qt Creator help viewer
Task-number: QTBUG-127042
Change-Id: I45ae86fa8fa8c899dec5725ee5ec209b2c335a6a
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
The behavior that argument was enabling is the default one now.
Pick-to: 6.8
Task-number: QTBUG-90492
Change-Id: Idefccdc3c6dcd5c3ed513a534f3933faeb79138d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Move assignment operators might be self-explanatory, but if
we document them, then we need to document the parameters.
Change-Id: I794ed7d023c3dde3f80ed7273889b7cf9a2113d6
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
All these TUs relied on transitive includes of qpointer.h, maybe to a
large extent via qevent.h, though, given that qevent.h is more or less
the only public QtBase header that includes qpointer.h, something else
seems to be at play here.
Said qevent.h actually needs QPointer in-name-only, so a forward
declaration would suffice. Prepare for qevent.h dropping the include.
The algorithm I used was:
If the TU mentions 'passiveGrabbers', the name of the QEvent function
that returns QPointers, and the TU doesn't have qpointer.h included
explicitly, include it. That may produce False Positives, but better
safe than sorry. Otherwise, in src/, add an include to all source and
header files which mention QPointer. Exception: if foo.h of a foo.cpp
already includes it, don't include again.
Task-number: QTBUG-117670
Change-Id: I49b637cc4ff478da510e52d999f3b76501ba6061
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The \generate list names are added for each categorized section with
some explanation. Here, calling the overviews as
explanations-(name of the section). The idea is to give general terms
instead of specific phrases like 'core' etc, for better understanding.
Task-number: QTBUG-115347
Pick-to: 6.5 6.6
Change-Id: Ifd8058f343fe6ffc4b45e443fb4ef0de17a4cb7a
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
This disables the 3-arg QObject::connect() overload:
QObject::connect(sender, signal, functor)
For details see:
https://lists.qt-project.org/pipermail/development/2023-July/044141.html
Change-Id: Ie9fe431feac6db6a8981b65fbc25bc8a1e352457
Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
The autogenerated list of overviews was adding the \group command which
included all the groups instead of overviews.
The idea here is to categorize the overviews later on once we have
the list of all overviews.
Task-number: QTBUG-114762
Change-Id: I3cf53886be277abc86b5ec54d399cd6933fbe882
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
* Do not use the "Example" word in the title
* Set the proper example category
* Add a note about running the example from QtCreator
* Add a note on how to terminate docker containers after usage
* Update the screenshot to reflect the changes in the UI, switch to
webp format
* Update the documentation about exposing C++ types to QML. Describe
the modern way of doing it.
* Introduce a section about changes to build files.
Task-number: QTBUG-113858
Pick-to: 6.6 6.5
Change-Id: I1ff3cdc4be673affa791a28d5f4641351060b13b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The example demonstrates a subset of features from Simple CoAP Client
example, but does not have any UI, and also provides only a basic
documentation page.
It can be safely removed, and other examples should be used instead.
Task-number: QTBUG-113858
Pick-to: 6.6 6.5
Change-Id: Iec63aa530d1bf35c403151341057ceb7dd2fac66
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
The QtCoap namespace clashes with the QtCoap module, when it comes to
linking in qdoc. Because of that it was not possible to link to the
namespace.
Add a
\keyword {QtCoap Namespace}
command to the QtCoap namespace, so that it could be
referenced using \l {QtCoap Namespace}.
Pick-to: 6.6 6.5
Change-Id: I066504dac6107a5bbc7f5d40a7f0c3924c2e8acb
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
To fix the AddressSanitizer error:
AddressSanitizer: new-delete-type-mismatch in thread T0:
object passed to delete has wrong type:
size of the allocated type: 104 bytes;
size of the deallocated type: 80 bytes.
QCoapMessage stores an instance of QCoapMessagePrivate in a
QSharedDataPointer. There is also a QCoapRequest class, which is
derived from QCoapMessage, and a QCoapRequestPrivate, which is derived
from QCoapMessagePrivate.
The QCoapRequest constructor creates an instance of QCoapRequestPrivate
and stores it in base class' d_ptr (which is
QSharedDataPointer<QCoapMessagePrivate>). This leads to an error shown
above.
Fix it by making QCoapMessagePrivate's d-tor virtual.
This revealed another issue - the non-const d_func() calls on
QCoapMessage were always calling QCoapMessagePrivate's copy c-tor,
which is incorrect if the d_ptr stores a QCoapRequestPrivate instance.
Fix it by introducing a virtual QCoapMessagePrivate::clone() function,
implementing it for both classes in the hierarchy, and providing a
specialization for QSharedDataPointer<QCoapMessagePrivate>, which uses
the clone() method.
This way we ensure that the detach goes via a virtual method, not via
a copy constructor.
Also make the copy constructors protected, to prevent future bugs.
Pick-to: 6.6 6.5 6.2
Change-Id: I865b8ce4733500120c12ac562a97e08b11c01c4c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.
Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.
Task-number: QTBUG-99313
Change-Id: I0483bd72018332f9a1d7c60537228ea6c85f7029
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
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: I227e49052f5f1a2a8abfc719112facb5c805d463
Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
qdoc's new clang backend does not use Cpp.ignoretokens anymore.
Task-number: QTBUG-104903
Change-Id: I120c231d476c0645917593fe8acbe6efcc1f6907
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
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: I53217bc6cf8a044937785533ec42ce22d6720a49
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
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: I2f390c365ce2d50aa79d317eafd63be19e530c1e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
qSwap() is a monster that looks for ADL overloads of swap() and also
detects the noexcept of the wrapped swap() function, so it should only
be used when the argument type is unknown. In the vast majority of
cases, the type is known to be efficiently std::swap()able or to have
a member-swap. Call either of these.
Task-number: QTBUG-97601
Pick-to: 6.3 6.2 5.15
Change-Id: Icaed67ff42bc148cb70e42d3377dea6b7eed908e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
See script in qtbase/util/includeprivate for the rules.
Since these files are being touched anyway, I also ran the
updatecopyright.pl script too.
Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This seems to be a leftover. It will now default to index.html
(as set in qtbase).
Pick-to: 6.3
Change-Id: Ica9ded9eddbf3f973a5eb4058e59ff22ae8e3f28
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
- Updated the overview documentation with details on how to link against
QtCoap with CMake
- Added \qtcmakepackage command, to include CMake instructions in
class/namespace docs
- Removed the note about the module being part of Qt for Automation
- Fixed an error in the license information
Fixes: QTBUG-99991
Pick-to: 6.3 6.2
Change-Id: Ie6f3f8cd5f797a5dc6702750eb6e1f12e10bdaf8
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
The d-pointer is not used in that scope.
Pick-to: 6.2
Task-number: QTBUG-91163
Change-Id: I8bdf97bafdc9cb66992f3a3cff1d58d4df922287
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Replace the hardcoded cpp exports with a generated one where it's
applicable.
Task-number: QTBUG-90492
Change-Id: I6218c27fcc34adf8ddcff255bbc9ad8b30c23ad4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Adrien Leravat <aleravat@witekio.com>
`src/coap/doc/src/external-resources.qdoc` defines a series of
`\externalpage` resources to some RFCs.
The links to `https://tools.ietf.org/search/*` resolve to an `Object
not found!` page.
To avoid the problem, they were replaced with an equivalent link on
the `datatracker.ietf.org` domain, which is one of the official ways
of reading published RFCs as per the IETF website.
The `tools.ietf.org/html/*` web pages containing RFCs now redirect
to `datatracker.ietf.org/doc/html/*`.
While the redirection work, our script to catch broken links on
dev-snapshots builds of the documentation doesn't handle redirection
correctly, reporting it as broken.
To appease the broken-links script, to avoid an unneccesary and to be
consistent in the domain that is linked to by the other pages, the
relevant `\externalpage` link were modified to point to the new domain.
Task-number: QTBUG-96127
Pick-to: 6.2
Change-Id: Idcaed482b1d54eefe33cb157fca425b2abd47962
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
customFilters defined in .qdocconf are not supported anymore by Qt
Assistant since Qt 5.13. Therefore remove them from all .qdocconf files,
also to avoid cargo-culting them to new help modules.
Task-number: QTBUG-95987
Change-Id: Iee20206a76c5f12866a30011a2f0023914b64e50
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
When sending Acknowledgment packets with code 0.00, the message should
be empty (RFC-7252 section 12.1). An empty message should have no token
(token length is 0), and no bytes should appear after the message ID
(RFC-7252 section 4.1, section 3). Since Reset packets have the same
structure (only the packet type differs), unified the packet creation
for both cases in one method.
Fixes: QTBUG-94763
Pick-to: 6.2 6.1 5.15
Change-Id: If2619ad6f4f5dba500e04ab10dbbbf08e4887aef
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
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: I034cce0921b65bf635c1d16a408bbd7141efe4a0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>