summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Bluetooth Windows: fix segfault in COM de-initIvan Solovev2023-12-151-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | While doing COM initialization/deinitialization, we always implicitly assumed that QCoreApplication instance is available. However, if the Bluetooth objects are re-parented to the main application, the QCoreApplication instance will already be removed by the time we want to delete the Bluetooth object (and call COM de-init). Fix it by caching the main application's thread, and using it instead of QCoreApplication::instance()->thread() in the mainThreadCoUninit() helper method. This commit still assumes that all Bluetooth objects are created *after* the main QCoreApplication instance. Amends 340b84a5578f78d7a399e369e900ac991d9e0da2. Fixes: QTBUG-119063 Pick-to: 6.5 6.2 Change-Id: I450e4e14039ca27fcfd1f3f131789b049e1edb03 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit f762e9b646e240d9e8d3d7de928ae1333227c8a0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 0e8bd451adef1ce67b1260fc0062c5a7e0c2ce3e)
* Windows Bluetooth: gracefully handle device disconnect during detailed ↵Ivan Solovev2023-12-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | service discovery Discovering service details in an asynchronous process, which means that the user may actually disconnect from the device while the discovery is still in progress. This means that we could end up in a situation when the discoverServiceDetailsHelper() is called with an empty serviceList. In this case, requesting for a specific service from the serviceList returns a nullptr, which may later lead to a crash. Add a nullptr check to gracefully handle such situations. Fixes: QTBUG-119060 Pick-to: 6.5 Change-Id: Iebdff67a12e6550979535ae5bac659ddae57b010 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 35f853837793b6d526815140021013cf03cc80b5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 3593b019e8c20d1fcae28d88448fc87fb99e7c3b)
* Silence expected java exceptionsJulian Greilich2023-11-151-2/+2
| | | | | | | | | | | | | | | Since we expect the calls to "connect" and "close" in checkIsTargetLost() to fail with IOException when the target was lost, we dont need to print the exceptions as log warning. This restores the behavior like it was before the port to the new Qt 6 Android APIs (7d2c6ae66fd61be56b35ae0c59354b695a02d6c7). Pick-to: 6.5 Change-Id: Ic9e14a58827f8b24865202012708644b903d5d70 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 0692168870463c7f32434b5ee1b0e6d762e078fa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* BlueZ: treat AuthenticationCanceled as a PairingErrorIvan Solovev2023-11-102-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... when it is not triggered from our side. The linked Jira ticket, as well as some searches over the internet, show that some devices report org.bluez.Error.AuthenticationCanceled error when the authentication fails, not when it is canceled. At the same time, it is also possible to get this error code by trying to pair with the device, and then immideately cancelling the pairing, like this: QBluetoothLocalDevice dev; dev.requestPairing(address, QBluetoothLocalDevice::Paired); dev.requestPairing(address, QBluetoothLocalDevice::Unpaired); The pre-existing code was only considering the latter usecase, and so was not reporting AuthenticationCanceled as a PairingError. This patch introduces an extra flag to check if the pairing was canceled from our side. If that's the case - the old behavior is preserved, and we do not report an error. In other cases, a PairingError is reported. Fixes: QTBUG-118895 Pick-to: 6.5 Change-Id: I1fe246eb8a0da6efb62eddc9a843de7be0f7b2c5 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> (cherry picked from commit 9815fa235e21321a2f4719a8f4b6f9837904d976) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Reset status of isSessionScheduled when starting a iOS NFC sessionJens Trillmann2023-11-071-0/+1
| | | | | | | | | | | | | If a user cancels the NFC popup and then starts a new session immediately after then isSessionScheduled gets set to true. This value has to be reset when the session gets started as isSessionScheduled==true leads to the QTimer always triggering a new NFC session. Pick-to: 6.5 Change-Id: I53d71d5c9b419d334ac6a229cff3e32aa81e9230 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 550e1c8ad5e8204c9942814bccc558c10faf197f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add thread protection to Android static string cacheJuha Vuolle2023-10-191-0/+2
| | | | | | | | | | | | | | | | | The string cache is accessed in the Qt Android main activity thread, as wells as in JNI callbacks which execute in arbitrary Java threads. For clarity: the usage in code looks like this: "valueForStaticField<QtJniTypes::XYZ" There is a small chance that the cache is accessed concurrently. Pick-to: 6.5 Change-Id: I34c26e22347f65614b18a000b5d61f0737e3b49e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 62045a447c688935091ce6b9fb0cc8a0ce03343c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Extend list of highlighted Connectivity examplesKai Köhne2023-09-262-2/+7
| | | | | | | | | Pick-to: 6.6.0 6.5 Task-number: QTBUG-117221 Change-Id: Idc1d7793c02bc1009f5cc43d30e3208b923ab0ee Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 4de43218466329a45cee1b588964ab811f4fedce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: All overviews list categorizationJaishree Vyas2023-09-211-1/+1
| | | | | | | | | | | | 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 Change-Id: Ie7ab2df16d61f672a27fb75bd7aea1782a5d59e6 (cherry picked from commit af7bbe8ac5d35340b70ef0751e42a3e551edf5ec) Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Clear any pendingJob of BT LE controller in case of disconnectJuha Vuolle2023-09-211-1/+11
| | | | | | | | | | | | | | | | | | | | | When using QLowEnergyController in Client role and the remote peripheral disconnects, we clear any current resources. However it seems we didn't clear the pendingJob variable. If the pendingJob variable remains non-null, then the next time we use the controller, the "performNextIO()" function will return early as it waits for the previous job to complete. However in this case, as it is a remnant from a previous run, it never completes, and the application's QLowEnergyService::discoverServiceDetails() will silently do nothing (the new job is put into job queue, but never attended, because of this pendingJob not completing). Pick-to: 6.5 Fixes: QTBUG-115370 Change-Id: Idd14efcc1469c155ac46c6a35336e04fc5bd6aa9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit cc337336fd51a13afc4ea09acf52c746fc747dbf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Allow to set user information after detection started for non NDEF tagsJan Moeller2023-09-121-3/+5
| | | | | | | | | | | | | | | | Prior to the NDEF implementation one could change the user information after the target detection started. The limitation seems to only effect NDEF tags, so all other tags should still be able to set the information at a later time. This allows to inform the user about the current progress of the process or inform about errors. Fixes: QTBUG-116563 Pick-to: 6.5 Change-Id: If82ea8c2056eb4c425626b06dac98462e3f0070c Reviewed-by: Lars Schmertmann <lars.schmertmann@governikus.de> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 76e0b4687ced7e3e54a60c674c9432a3161ce834) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Consider protocols that derive NFCNDEFTag in isNdefTag()Jan Moeller2023-08-301-1/+10
| | | | | | | | | | | | | NFCMiFareTag, NFCFeliCaTag, NFCISO15693Tag, NFCISO7816Tag all derive NFCNDEFTag. Therefor, the current implementation of isNdefTag() will return true for all of these, as they satisfy [conformsToProtocol:@protocol(NFCNDEFTag)]. Fixes: QTBUG-116563 Change-Id: I816cb84b2c06f1f9401fccb3867ab78d3ee075b7 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 7de85709d6828e7ee9dd4fffd683a8d67228311b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Bluetooth: remove custom implementations of qbswap(QUuid::Id128Bytes)Ivan Solovev2023-08-232-18/+0
| | | | | | | | | | | | | Starting from qtbase/470b2b8ad9f28eaf24518dfa3f48cc13fcdc421f qbswap() is provided as a hidden friend for this type, so the custom implementations for Windows and Android backends in Qt Bluetooth are no longer required. Fixes: QTBUG-116341 Change-Id: I451de4249a082331f75c1db93ad420cf96d0e3cc Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 98cddeeb4a9e0c8686e505e5e6b9165970ec3060) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix translation context of QBluetoothUuid::WeightScaleFeatureFriedemann Kleint2023-08-211-1/+1
| | | | | | | | | Amends 439e818f7843b6a117e1bfe755e313022e14aafa. Change-Id: If08fc84a495d493b463cc71de43237b1cc950a5b Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit a6bac31e41b71aeff6272cf8c34f02b237b21184) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: magic_numbers -= 50Marc Mutz2023-08-181-5/+5
| | | | | | | | | | | | | | | | | | | Prevent code readers from having to compare the long lists of magic numbers in the various bluetooth-specific UUID constructors; they're all the same as the ones used in the quint32 ctor, so use C++11 ctor delegation to make all ctors call the quint32 one. This calls into question the need of the quint16 ctor, seeing as the quint32 ctor could just do the former's job with an implicit conversion. But removing it would allow users to pass any integral type to the QBluetoothUuid ctor, which is not the case atm, because the two integral ctors make each other ambiguous unless the arguments match either parameter types exactly. So leave it in. Change-Id: I40ddc47149cbb0526ad6488f32cc7f203e70a6b3 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 08a0f404f60e5c02dfb3cf7b224feae7e93359b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: inherit all ctors from QUuidMarc Mutz2023-08-183-15/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QBluetoothUuid clearly is-a QUuid, so it should have the same constructors, though it may add its own on top. Three Qt releases (6.3-6.6) of QUuid changes have, however, not been properly reflected in QBluetoothUuid, so fix it once and for all by adding using QUuid::QUuid; to QBluetoothUuid, thereby inheriting all the QUuid ctors (except SMFs) that QBluethoothUuid doesn't supply itself. This fixes or simplifies: - The Id128Bytes ctor, which we don't need to supply at all now. - The QString ctor, which was replaced by a QAnyStringView overload in QUuid a long time ago (6.3). - Anything else that we have missed in the past (GUID, e.g.). The superfluous constructors still have to be retained in the ABI, because QBluetoothUuid is unfortunately exported wholesale. This affects only the QString ctor. The other one was not in 6.5, and we don't provide BC with pre-releases of Qt. Add some variance to the fromString() tests now that we have QAnyStringView instead of just QString. Found in API-review. [ChangeLog][QtBluetooth] QBluetoothUuid now provides all the constructors that QUuid also provides (incl. from GUID and QAnyStringView). Change-Id: I2cb76a9a9cbc47f2fd4e637bdb41233d1ffc6972 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit aff0acdeee12acf6a85f479f160a0d4776f79d7c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: inline the (quint128, Endian) ctorMarc Mutz2023-08-182-20/+4
| | | | | | | | | | | | | | | | | We can actually write a body that works for both unsigned __int128 as well as the legacy struct quint128, using QUuid::fromBytes(), so do that. This removes the need to keep a complex implementation behind the ABI boundary, and thus allows to remove the function from the ABI so we don't run into even more BiC problems once MSVC starts supporting __int128, possibly with just a newer /std flag which, as per current rules, isn't supposed to change the ABI. Change-Id: I1975cf68bc5f5421bf90f81a691ddf68bfa928dd Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 0f689ee079aa98b26efe097c8dc6652055f9010b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: inline converting ctor from QUuidMarc Mutz2023-08-172-5/+12
| | | | | | | | | | | | | | | | | It really shouldn't be out-of-line. We should allow the compiler to see it as the no-op that it is. As a drive-by, pre-program the signature to pass by value come Qt 7, fixing a Clazy warning. We could already do it now, but since T and const T& don't overload, we'd have to take out the QT6_NEW_OVERLOAD bazooka, and it's not really worth it. When the code is inline, the compiler can see through the pass-by-reference overhead and avoid allocating the argument on the stack. Change-Id: Ic708bb9b2cacd4df22313b704de557dbda4d28fa Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 6bbf186d135e731e3c7b84a0c3cf9e74c946d32d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: cut out the streamingOperator() middle-manMarc Mutz2023-08-153-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | The split into an inline friend op<< and an out-of-line streamingOperator() just causes the QDebug object to be copied once more than otherwise necessary. Relegate the streamingOperator() middle-man to QT_REMOVED_SINCE status and make op<< the real thing. We can't make the named function call op<<, because Thiago says there are situations in which the op<<(QDebug, QBluetoothUuid) call in removed_api.cpp, if we were to use it, would get resolved to an exported version of the old op<< in a user library compiled without -fvisibility-hidden, creating a cycle. Fortunately, the implementation is simple enough to make a DRY violation acceptable. Problem exists in 6.5, too, but let's get as many removed_api.cpp tasks done for 6.6, because the QT_NO_INT128 in removed_api.cpp will make a QT_REMOVED_SINCE(6, 7) in this header file that much harder. Change-Id: I10b42cfc1565db8d9a6924cee0af8fb6623c9000 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit a16133c959151892a386204aa54c8115992c1075) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: provide Endian overloads for quint128 functionsMarc Mutz2023-08-153-31/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mimicks the new APIs of the same name in QUuid. For QBluetoothUuid, this is wonderful news, because the old overloads that lack the Endian parameter are now _always_ referring to the old struct quint128, and are, as usual, defined in removed_api.cpp¹ ¹ with the caveat that QT_NO_INT128 is defined there globally, which may create problems for potential QT_REMOVED_SINCE(6, 7)s. A solution would be to move this stuff out into a compat/old_int128_api.cpp, but let's first get the 6.6 part done. The new overloads are now either `unsigned __int128` (#ifdef QT_SUPPORTS_INT128) or `struct quint128` (otherwise), never both, so we don't need a second TU to do the overloading at the ABI level. This leaves removed_api.cpp with its traditional role of dealing with QT_REMOVED_SINCE (with the caveat mentioned above) and the QT_SUPPORTS_INT128 handling is in qbluetoothuuid.{h,cpp}, where it belongs. This greatly simplifies the #ifdef'ery in all three files and allows to do away with the "normal" vs. "not typical" QT_REMOVED_SINCE(6, 6) section split. Amends 5d90296f312f72ffa6a5322df7b565c3e5521684. As a drive-by, fix missing Q_QDOC handling. Change-Id: I4ead4ee39533967a78c145ef222d9991fdf4cd98 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit bfa5d5f6581439216ccbff97e1c9af76fc461dc7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: remove default case labels and fix the falloutMarc Mutz2023-08-121-8/+4
| | | | | | | | | | | | | | | Learn to love -Wswitch and avoid default case labels even at the cost of having a few enumerator cases "too many". They help catch mistakes, like, in this case, the missing handling of QBluetoothUuid::CharacteristicType::WeightScaleFeature. [ChangeLog][QtBluethooth][QBluetoothUuid] Fixed missing result of characteristicToString(CharacteristicType::WeightScaleFeature). Change-Id: I04b7cf9ee058ef5a8d202fff01fb347d315562f6 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 439e818f7843b6a117e1bfe755e313022e14aafa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: remove unused equals() method declarationMarc Mutz2023-08-121-3/+0
| | | | | | | | | | | This was never used, nor even defined, ever since the declaration was added in 9c59558afc71f36a82a1cab9ca0841119892e26a, so it doesn't need QT_REMOVED_SINCE(). It just was whitespace. Change-Id: I6a56cbe346455818c13cefb66c65887edbfcb0e9 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 85e4b9f7c66bf653ec295a52305b5f1224eda3c6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: insulate against potentially-disappearing QUuid(quint128) ctorMarc Mutz2023-08-121-1/+1
| | | | | | | | | | | | | | | | | | | We're considering remove the QUuid(quint12*) ctor in favor of the "named" fromUInt128() ctor, so isolate the code against that by going via the Id128Bytes ctor, which always exists. This particular way of writing the code requires C++20/C99 designated initializer support enabled in the compiler. It just so happens that the only compiler that doesn't support __int128 (MSVC) also is the only compiler that doesn't allow the use of designated initializers in C++17 builds (because MSVC never implemented C99), only in C++20+ ones, so for the moment we're ok. If this becomes a problem, we can rewrite the code. Change-Id: Ic4424ddad1a8a703e00b2ff3d9b45b07bb321fd0 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 5fcb55cf2bd45408162d20fe5be407ce6494ba5f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: add missing Endian argument to Id128Bytes ctorMarc Mutz2023-08-112-4/+5
| | | | | | | | | | | | | | | | The base class has it, so QBluetoothUuid also has to have it, too, for API symmetry. Adapt the docs to be more like QUuid's for the same function, even though those may still be improved in qtbase (in which case we shouldn't forget to re-sync them here). Found in API-review. Change-Id: If13df1e7551235e2c9f57ba0e8729d7f2a6d494c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit a2944859ac2a6a13100b5a06c681fb477231e52a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: keep custom quint128 and related methods when 128-bit ints ↵Ivan Solovev2023-08-033-12/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | are not supported ... to retain SC with prior Qt versions. For QBluetoothUuid::toUInt128() this is done by introducing an extra condition to the method declaration and definition. If the 128-bit ints are not supported, we shouldn't hide the method under QT_BLUETOOTH_REMOVED_SINCE. The QBluetoothUuid(quint128) c-tor is a bit more tricky, because we need to provide a forwarding c-tor to be able to use QUuid(quint128) c-tor. And at the same time, we need to keep BC by keeping the constructor that takes custom struct quint128. This is achieved by having an unconstrained c-tor declaration and two implementations: * an implementation in qbluetoothuuid.cpp is only available when Qt supports 128-bit ints. It just forwards to the QUuid c-tor. * an implementation in removed_api.cpp serves as a backup implementation to keep BC for the case when Qt supports 128-bit ints. And at the same time it serves as a main implementation when 128-bit ints are not supported. Also extend the unit-tests to explicitly check that both APIs are available on all platforms. The test additionally makes sure that QUuid::toUInt128() and QBluetoothUuid::toUInt128() provide the result which is similar to QUuid::toBytes(). This guarantees compatibility between platforms. This commit amends 1e903be81f43da4e31385bb7866bb4d3f07e5eba. Change-Id: I6ba3ff6278e6db11a372b46f001429f4466520a0 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 5d90296f312f72ffa6a5322df7b565c3e5521684) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: List of all Qt overviews which are now termed as explanationJaishree Vyas2023-07-191-0/+1
| | | | | | | | | | | | | 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> (cherry picked from commit f7ae4d2aa8bfd37f5cf0a98afbe58328407784b5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Remove \ingroup all-examples command from the docsJaishree Vyas2023-07-122-2/+0
| | | | | | | | Task-number: QTBUG-115044 Change-Id: I83314f3b7955e1ef9c857bcc96c07f6f90b2f875 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> (cherry picked from commit 9cc12e95730c671eaaa669d131d031fc1453279f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothUuid: fix alignment of the custom quint128 structIvan Solovev2023-07-112-3/+6
| | | | | | | | | | | | | | Updating the struct to contain the Id128Bytes member instead of an array of chars changes the alignment of the struct. Revert the struct to its original state, and update the code in removed_api.cpp to adapt to the changes. This commit partially reverts 1e903be81f43da4e31385bb7866bb4d3f07e5eba Change-Id: I638622ffa5320f8de3f7866109fcc384b557392e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit b23456ca14ae203df3228c51db2df55cb1f67d70) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothAddress: restore missing move SMFsMarc Mutz2023-07-091-0/+2
| | | | | | | | | | | The user-defined copy SMFs were deleting the move SMFs. Restore them with a strategic =default. Change-Id: I461975ca422cb08c615e910643da2b932c5b45d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit a0495c038b8e187f8c48cbee3352b147eb81e462) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothAddress: inline most functionsMarc Mutz2023-07-093-42/+40
| | | | | | | | | | | | | | | | | | | | This class is supposed to be a _thin_ wrapper around a quint64. It's not extensible anymore, anyway, because inline functions (e.g. the relational operators) access m_address, so we might was well inline all the trivial functions. Do that. Since the class is exported, we need to us QT_INLINE_SINCE. As a drive-by, make all newly-inline functions noexcept. Drop the documentation of the copy SMFs and the destructor. They're trivial, we're not documenting the SMFs of e.g. QUuid, either. Change-Id: I7d5207cb24ea637d5b6eefe0ab8ce54a4b123305 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 7f248fed3d19ca73580d02f5b4ae3d009b90fadf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBluetoothAddress: add qHash() as a proper hidden friendMarc Mutz2023-07-094-6/+11
| | | | | | | | | | | | | | | | | | | | ... removing the ODR-endangered private overload. While the QBluetoothAddress constructors are constexpr, the dtor is not, so qHash() can only be constexpr come Qt 7. Pre-program accordingly. Even though GCC and Clang accept the constexpr as long as we pass by reference-to-const, the actual constexpr'ness of the function cannot be used. Partially reverts d44a46e2bcc9ff119128759262c0422aa91bcd69. [ChangeLog][QtBluetooth][QBluetoothAddress] Added qHash(). Change-Id: I6f98eb867b4691eee2629fa63107f6b954787243 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 4d5da3f5beb7bc8588057e9f5304504fb3d220e5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* [docs] QBluetoothAddress: fix a grammer mistakeMarc Mutz2023-07-081-1/+1
| | | | | | | Change-Id: I7e0a616aaf227c9cfa3147a3bd5c19fc85778f88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 2d4eac59f45807806372a32ccda40f0563f47aa1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Merge duplicate qHash(QBluetoohAddress) definitionsMarc Mutz2023-07-083-10/+6
| | | | | | | | | | | | | | | | | ODR violation, detected by -unity-build-batch-size 103. Fix by moving into a central header. Keep inline, so we don't export a new symbol and can pick back to 6.5. A follow-up commit will make make this a proper hidden friend of QBluetoothAddress. Task-number: QTBUG-109394 Change-Id: I6425e11bc4897ff9f41d25653e9e2ca8ac36631c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d44a46e2bcc9ff119128759262c0422aa91bcd69) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Windows: fix bluetooth pairing status requestIvan Solovev2023-06-071-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | When requesting for pairing status, we do not really know if the device is LE or Classic bluetooth device. Because of that, we try both options. The pre-existing code was trying to get an instance of BluetoothDevice first. In practice, the BluetoothDevice::FromBluetoothAddressAsync() method returned a correct BluetoothDevice even for LE devices, which was later leading to an incorrect pairing status, when accessing device.DeviceInformation().PairingStatus(). This patch re-orders the checks, trying to obtain an LE device first. My tests show that this approach works correctly for both LE and Classic devices, because the LE check fails for Classic devices. Note: Qt 6.2 is unaffected by this bug, because it already checks LE devices first. The bug was introduces during one of the later refactorings. Fixes: QTBUG-113318 Change-Id: I93ada1ca681ec2597809ecba117808d68c2dcb8c Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> (cherry picked from commit 3d234d3b182f1759ecf8e5c092948c15f5c3ea4c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Follow up on change to QUuid in qtbaseVolker Hilsheimer2023-05-233-1/+12
| | | | | | | | | | | | | | | The unit test fails to build without allowing a QBluetoothUuid to be created explicitly from an 128-bit integer. Since the constructor taking a quint128 has been removed from Qt 6.6, and since the constructor from QUuid is explicit, we need to add a constructor from the QUuid::Id128Bytes union type. To avoid that QtCore/qtypes.h declares the quint128 typedef we have to include all the headers that qtypes.h includes into removed_api.cpp before undefining the __SIZEOF_INT128__ symbol. Change-Id: If857faefc253dbbe6cf91bd13bdc31f31cdfb54e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtNfc: Remove dependency on QtNetworkFriedemann Kleint2023-05-121-1/+0
| | | | | | | | | | | It does not appear to use anything from QtNetwork. [ChangeLog][Potentially source-incompatible changes] QtNfc no longer depends on QtNetwork. Change-Id: I23a71684fee760b091579e2f57eaf62d90a4743a Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* BlueZ: remove unused variablesIvan Solovev2023-05-052-3/+0
| | | | | | | | | The localAdapter variable is a leftover from the BlueZ4 support. The remoteDevicePath variable was never used. Pick-to: 6.5 Change-Id: I93a691627467700cc01d2ee372a5d8e661083cd4 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QtBluetooth: use public QPermission API to check for permissions on AndroidIvan Solovev2023-05-0310-67/+30
| | | | | | | | | | | | | | Now when we have the fine-grained public QBluetoothPermission API, we can use it to check for permissions in the Android implementation. Adapt QtBluetooth examples to use only the minimal required set of permissions. As a drive-by: fix a couple of qCWarning() strings. Task-number: QTBUG-109964 Change-Id: I55c67bcae27926e76bf9c1a8a9367af2b58883ff Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove Unnecessary Q_DECLARE_METATYPE(QJniObject)Amir Masoud Abdol2023-04-242-6/+0
| | | | | | | | | | | This doesn't seem to be necessary anymore. Maybe it was at some point, Removing them, even without moving it to qtbase doesn't cause any problems either. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Id9a62f23aba355e2e37f70a374aa20c48ce4ef83 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QtBluetooth: do not request permissions on AndroidIvan Solovev2023-04-053-14/+17
| | | | | | | | | | Expect it to be done on the application side. The library only checks for the needed permissions. Task-number: QTBUG-109964 Change-Id: Ibb6b756ddea13c14a4c096d200418923e9ccd69c Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* [Darwin] Fix LE controller initializationJuha Vuolle2023-04-041-1/+1
| | | | | | | | | | | | | | | | | | | | | Peripheral applications don't work properly due to permission-related initialization changes. The underlying CBPeripheralManager was instantiated only when startAdvertising() was called, which can be too late; the peripheral manager is needed already earlier if the application calls addService(). Calling addService() before startAdvertising() is not mandatory though, and hence the lazy initialization needs to be attempted in both functions. Amends ae1a1f5efce291f613a13757ff6f744fcca2d2ce Task-number: QTBUG-112215 Change-Id: I7771a2e1bd951093e33030546e5da69538c8dcd1 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QBluetoothUuid - add platform-specific conversion functionsTimur Pocheptsov2023-04-033-0/+57
| | | | | | | | | | | | | Namely: fromCBUUID and toCBUUID, similar to fromNSUUID and toNSUUID that we already have. [ChangeLog][QtBluetooth] Add CoreBluetooth-specific conversion to QBluetoothUuid class, to get CBUUID out of QBluetoothUuid and convert CBUUID to QBluetoothUuid. Fixes: QTBUG-112303 Change-Id: I4ca0b13395b4346f7c830a0e042a16f976998a33 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove redundant checks on Darwin LE controllerJuha Vuolle2023-04-031-28/+2
| | | | | | | | Checks are already done at base or the public class Pick-to: 6.5 Change-Id: Idf5ae08cb34fa1293de8f270c8980799866a8b08 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Exclude source files from unity buildAmir Masoud Abdol2023-04-031-0/+4
| | | | | | | | | | | When building with Unity, Windows Bluetooth symbols from WIN32/COM and more modern WinRT APIs, e.g., AsyncStatus, start to confuse the compiler as related source files start to be pooled together. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I3d59f09caca3e56b6961fb6ffcdf8233369313d2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* HeartRate Game example: do not show duplicated devicesIvan Solovev2023-03-291-1/+4
| | | | | | | | | | | | The deviceDiscovered() signal can be emitted more than once for the same device, so implement a check before adding a device. This commit amends a1f43b9dcd722527d52ceb0c7a138bd2994c1a7b Task-number: QTBUG-111972 Pick-to: 6.5 Change-Id: Iff0a2b301d6d05090745ef97cedf5fab4532da7e Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* HeartRate Server: revamp the exampleIvan Solovev2023-03-281-1/+1
| | | | | | | | | | | | | | | | | Some code clean-ups: * Use qt_standard_project_setup() and PRIVATE linking in CMake * Port away from QScopedPointer and use std::unique_ptr instead Documentation updates: * Add Connectivity category * Mention the new BlueZ D-Bus backend in the documentation * Small wording improvements * Provide more links to Qt classes and enums Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Id2a0ef48d3ce82f1784dd4b51f94236731730432 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Windows: optimize BTLE device discoveryIvan Solovev2023-03-271-19/+22
| | | | | | | | | | | | | | | | | | | | | Previously we were doing full service discovery every time when the BluetoothLEAdvertisementWatcher reports a new advertisement. This results in a very high CPU usage during BTLE device discovery on some configurations. In practice such approach might not be needed, because most BTLE devices repeatedly advertise the same data. With this patch we do a detailed service discovery only when a new device is added, or when the list of advertised services has changed. Note that we still need to handle all the incoming advertisements, because we want to report changes in other parameters, such as RSSI. Fixes: QTBUG-111116 Pick-to: 6.5 6.5.0 6.2 Change-Id: I0863739a2fb21d04e9a728adc68e3f197f1966e3 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Remove PingPong exampleIvan Solovev2023-03-222-4/+0
| | | | | | | | | | | | The example contains a lot of rather complicated code, which is not directly related to the demonstrated Bluetooth features. Remove it in favor of BtChat example, which demonstrates the same Bluetooth features in a much more compact and understandable way. Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Iccb2598fa6e88816697286b2252858f35a635ee5 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* BtScanner example: move to manual testsIvan Solovev2023-03-212-4/+0
| | | | | | | | | | | | | | | | | | | | | | | The example mostly shows the usage of QBluetooth{Device,Service}DiscoveryAgent classes, which is also illustrated by other examples. Move it, because it's not fully functional on mobile platforms (because it's widget based). Do not remove it completely, because it might still be useful for doing Classic device scan. Also implement some improvements while on it: * fix CMakeLists.txt by using qt_standard_project_setup() and PRIVATE linking * fix memory leak in DeviceDiscoveryDialog * rework the code to use Qt parent-child model instead of manually deleting objects where possible * fix includes * fix forward declarations Task-number: QTBUG-111972 Pick-to: 6.5 6.5.0 Change-Id: Ie4bc9e25ccdda6d5f5de2f57528df349c71cdc12 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* QtBluetooth: port the code to the new permissions API (CoreBluetooth)Timur Pocheptsov2023-02-246-68/+48
| | | | | | | | | | | | | | | | | | | | | We only _check_ if permissions were granted, leaving it up to an application to _request_ permissions. If permission status is not 'Granted', we bail out ealy setting MissionPermissionsError. QLowEnergyController::init is now a no-op for Darwin, because it's OK to create a peripheral/central and no need to set any error yet. Autotests require minor adjustments - they were already passing if BT is off, as it is on CI (checking Bluetooth local device and its status), but if BT is somewhere on, tests can try to scan or connect not having permissions granted - for this we adjust the tests, using permission API. [ChangeLog][Important Behavior Changes][QtBluetooth][Darwin] Do not request permissions implicitly, only check them and leave it to applications to request permissions explicitly. Task-number: QTBUG-109964 Change-Id: I95c04744e979614ffb6d992da2e279e86b272679 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* SDP scanner: encode input URLs and escape XML-specific charactersIvan Solovev2023-02-231-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old implementation didn't take care of escaping the XML-specific characters and didn't handle non-printable characters. This patch makes use of QUrl class to properly %-encode the input data. The QUrl::toEncoded() method %-encodes all XML-specific characters except '&', so we need to manually replace it with "&amp;" before adding the url to the generated XML. Escaping special XML characters potentially allows Qt Bluetooth to handle more URLs received from sdpscanner, because QXmlStreamReader discards attributes with unescaped special characters, so previously part of the URLs could be silently skipped. For other potential sdpscanner users this change shouldn't make much difference, because they should anyway parse the returned XML documents according to XML standard. %-encoding of URLs potentially changes the way the URL looks for the user, but not for the software that should handle the URLs, so this change is also safe. [ChangeLog][Qt Bluetooth][sdpscanner] sdpscanner now %-encodes the URLs and escapes all XML-specific characters in them before adding the result to the generated XML output. Fixes: QTBUG-111369 Pick-to: 6.5 6.4 6.4.3 6.2 5.15 Change-Id: I6de080fef7689ef96fe5e5e26c62a3c48ebc45b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>