summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Ensure custom uuids are returned by QBluetoothServiceInfo::serviceUuid()Alex Blasche2019-01-091-1/+17
| | | | | | | | | | | | | | | | | | QBluetoothServiceDiscoveryAgent::start(FullDiscovery) uses an external tool called sdpscanner to perform the SDP inquiry. The tool uses Bluez's own API to perform the task and is GPL. In case a remote device offers a custom service the service uuid is returned as serviceClassUuid. QBluetoothServiceInfo::serviceUuid() remains empty although it should be populated as per API contract. This patch ensures that the first custom uuid is shifted from the serviceClassUuid list to serviceUuid(). The fix is limited because it picks the first custom uuid and does not consider a secondary custom uuid. Such a case is extremely unlikely though and I have not come across it. Fixes: QTBUG-72800 Change-Id: I7256440bcb1c9b0b2fb75249f977c43fecf1d910 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Ensure QObject context is retained to avoid crashesv5.12.0-beta4Alex Blasche2018-10-311-4/+4
| | | | | | | | | | | If the public class is deleted pending lambda invocation can cause crashes unless QObject context is provided. This fixes a regression introduced by 819bb06c2cb3372cb1bb9ddd7f3a504f78d3452d. This was discovered while investigating QTBUG-71479. Change-Id: I3a49916ce6d9425c684863bb0b04a10bd3e652b9 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Normalize QObject::connect() statementsAlex Blasche2018-08-291-10/+20
| | | | | | | | | | | | | | Some cases use the Q_PRIVATE_SLOT logic which does not require QObject inheritance. Those cases were converted to lambda logic to avoid need for QObject inheritance. The Q_PRIVATE_SLOT macro was removed from qbluetoothdevicediscoveryagent.h. This is not a BC problem because the macro expands to nothing. Only moc recognizes the pattern. Change-Id: Ic7cb4cde397f9b230b6fd0b4046e59e504583e58 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Code cleanup: Use nullptr wherever possibleAlex Blasche2018-08-241-17/+16
| | | | | Change-Id: I7dd2d055c8d667f049d7cb2c371619137bf76030 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Replace foreach with for loop and set QT_NO_FOREACHOliver Wolff2018-08-151-7/+10
| | | | | | | | To avoid unnecessary copies, const is used wherever possible. Change-Id: Ic743716512751cfd24fad5bd37c244b115dd26fe Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Remove unused function convertAddressThiago Macieira2017-04-031-10/+0
| | | | | | | | Found by Clang: qbluetoothservicediscoveryagent_bluez.cpp:61:20: warning: unused function 'convertAddress' [-Wunused-function] Change-Id: I27b55fdf514247549455fffd14b1793f89f60f92 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Merge remote-tracking branch 'gerrit/5.6' into 5.7Alex Blasche2016-06-091-3/+13
|\ | | | | | | Change-Id: Id8dffff9bb75db396aabf6da2a3acb78505a6476
| * Bluez5: Run SDP on target devices which do not support public scansAlex Blasche2016-06-081-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PUBLIC_BROWSE_GROUP scans are not always supported. In such cases more targeted service scans are to be used. This patch modifies QBluetoothServiceDiscoveryAgent such that when a uuid filter is set targeted service scans are used rather than generic PUBLIC_BROWSE_GROUP ones. QBluetoothSocket always scans with an applied uuid filter and therefore directly benefits from the patch. Change-Id: I94997d2cf8f70fa7db5422d78c8bfdbe2aa1dbbc Task-number: QTBUG-53041 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
| * QBluetoothServiceDiscoveryAgent: set q_ptr in d_ptr's constructor.Edward Welbourne2016-06-021-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | The agent class constructors were initializing the q_ptr member of their d_ptr; it is cleaner to pass this down to the d_ptr's constructor and let it do this itself. This also lets Coverity know that initialization actually does happen (CID 22330). In particular, it makes sure we can't leave it uninitialized, if an agent implementation happens to neglect to do so. Change-Id: Ie01046a5a113b5669e8e63c6a22f692cd3943ac0 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Updated license headersAntti Kokko2016-01-201-14/+20
| | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I856c13e2a6d4d12c46e1286b0ca1c092ee4608f8 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | QBluetoothServiceDiscoveryAgentPrivate: use const reference forAnton Kudryavtsev2015-12-071-2/+2
|/ | | | | | | parameters to avoid unnecessary data copying. Change-Id: Iaca94a2af27d5d756deb9751c6bc9630f5fbc8bf Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* [Bluetooth] Optimize loopsKonstantin Ritt2015-09-161-7/+11
| | | | | | | | | | | | Decrease complexity from O(N+N*logN) to just O(N) for cases like foreach (Key key, map.keys()) Value value = map.value(key); , by rewriting with use of iterators. Change-Id: I81f1334797f16b624293fcebdee885b2be3c89f1 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* bluez: SDP: find a device before creating it.Robin Burchell2015-09-151-13/+51
| | | | | | | | | | | | | | | | To enable service discovery for known devices even if org.bluez.Adapter.CreateDevice has security restrictions, call org.bluez.Adapter.FindDevice first and CreateDevice only if the device isn't already known. The change is needed due to runtime security checks on Jolla devices, but reordering the calls does no harm when used with upstream bluetoothd. Change-Id: I8ad09808cec648f5b5949044c60173ff1ad46332 Task-number: MER#1225 Done-by: Hannu Mallat <hannu.mallat@jollamobile.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* bluez: Fix some memory leaks on device discovery.Robin Burchell2015-08-201-2/+7
| | | | | | | QDBusPendingCallWatcher will leak if it isn't deleted. Change-Id: I5571dfbc087f54308193dc89127e974e6d2e9275 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Merge branch '5.4' into 5.5Alex Blasche2015-04-011-1/+3
|\ | | | | | | Change-Id: I177affc6c60fd3cc55e914a7ea2a9aeba260906f
| * Fix crash in QBluetoothServiceDiscoveryAgent on Bluez 5.xAlex Blasche2015-03-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The list of internally discovered devices was already cleared. It should not be referenced anymore. Furthermore the QBluetoothSocket is killed while its internal QBluetoothServiceDiscoveryAgent is still running. This change stops the agent as well and thereby prevents more QBluetoothSocket slots froms being invoked and a more controlled termination of QBluetoothServiceDiscoveryAgent. [ChangeLog][QtBluetooth][Android] Fixed crash in QBluetoothServiceDiscoveryAgent on Bluez 5 when using single device discovery. Single device discovery is used during QBluetoothSocket::connectToService(). Task-number: QTBUG-44930 Change-Id: Ib3129c492151a3fe12b0c451cf5ffdddc62d001c Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Update copyright headersJani Heikkinen2015-02-161-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I3822a6484e8f7a420330de1cb1aeb0c3d1cf41b7 Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
* | Merge remote-tracking branch 'gerrit/5.4' into devAlex Blasche2015-02-111-57/+50
|\| | | | | | | Change-Id: Ia70c3fe64e2ffcb27181bf912b06e6af59d2bc92
| * Fix crashing btchat example when selecting remote devicev5.4.1Alex Blasche2015-01-291-57/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The example immidiately destroys the QBluetoothServiceDiscoveryAgent when the user selects a remote chat service from the remote selector dialog. This may happen even when the scheduled QtConcurrent call to runSdpScan() was still pending. The subsequent signal callback into the deleted parent caused a crash. Unfortunately QtConcurrent::run() returns a QFuture which does not permit stopping the pending thread execution. Therefore the runSdpScan() had to be rewritten using QProcess to properly destruct pending calls. Change-Id: I1ed5e147feb94a26240901a02d836056eddabbf6 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Convert qRegisterMetaType<T>(const char*) to qRegisterMetaType<T>()Alex Blasche2015-01-281-2/+2
|/ | | | | | | | | | | | | | | This is much safer and cleaner. [ChangeLog][QtBluetooth][Important Behavior Changes] Q_DECLARE_METATYPE added for QBluetoothServiceDiscoveryAgent::Error, QBluetoothSocket::SocketState, QBluetoothSocket::SocketError and QBluetoothDeviceInfo. This breaks source compatibility if application code has defined the above metatypes already. The applications Q_DECLARE_METATYPE must be removed to fix the compile error. Change-Id: I1c7cb1ee25832b7e5337c9aca6f36b21e8caf22e Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Set ATT as protocol descriptor for BTLE SDP recordsAlex Blasche2014-09-031-2/+20
| | | | | | | | At the same time we fix up some cases where the ProtocolDescriptorList was not a list within a list. Change-Id: If0ec6cf6374902a47a905edd08523906be9fd86b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove QLowEnergyServiceInfoAlex Blasche2014-09-031-39/+27
| | | | | | | | There is no need for this class anymore as QBluetoothServiceInfo covers the same information. Change-Id: I411a8abb68b34a3a4893a67ee9fac096f44bbd62 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix Bluez5 FullDiscovery SDP scanAlex Blasche2014-08-251-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | Several bugs prevented QBLuetoothServiceDiscoveryAgent from properly working on Bluez5 1.) If parseSDPRecord returned an empty QByteArray we continued the parse loop without further advancing the sdpResult list. 2.) Each sdp result was individually base64 encoded but the library side decoded the entire list of items in one go. The item separation gets lost during the transfer. As a result only every second item was properly decoded. Therefore only every second sdp record was properly recognized. Now we encode the entire result and transfer it in one go. 3.) Don't separate the xml items based on their size anymore. Although this is possibly slower it is a lot simpler to understand and debug. In combination with the above two problems the previous pointer based logic was leading to crashes too. 4.) QProcess::readAll() seems to loose data when the process finished and the output was very large. After this patch we start reading right after the start of the sdpscanner. Change-Id: I84a0be9d68e86c851945751c576a3ccf755db883 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
* Update license headers and add new licensesJani Heikkinen2014-08-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I7a8b8b787fcae9a178794364efdefe1021d10b1b Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Merge remote-tracking branch 'gerrit/5.4' into btleAlex Blasche2014-08-131-63/+36
|\ | | | | | | Change-Id: I1e79c96602d0da2c2d36d6217bdfe7ff183e6df9
| * Remove Bluez as link and include dependency from QtBluetoothAlex Blasche2014-08-121-63/+36
| | | | | | | | | | Change-Id: Ieecf341918ffdc51c359fed4969ef6c3998d83b8 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
* | Complete the removal of the Bluez's DBus Characteristic APIAlex Blasche2014-07-231-1/+0
| | | | | | | | | | | | | | | | It never worked and was not used. In the future there might be a new GATT DBUS API offered by Bluez. Change-Id: If4c05d37e330ff3cdcda3ef3458938e2bce30725 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* | Remove old GATT APIAlex Blasche2014-07-231-125/+0
| | | | | | | | | | | | | | | | | | The subsequent patches will rename QLowEnergyControllerNew to QLowEnergyController and fix up the documentation fragments which still point to the old API. Change-Id: I084e6b1a85a17f424702018f3ad7047bda35d46a Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* | Ensure Bluez5 device discovery sets the new core configuration flagAlex Blasche2014-07-171-0/+1
| | | | | | | | | | Change-Id: Idc04620c3941ec92c7ea81e1ba4ec521cf000720 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* | Merge branch 'dev' into btleAlex Blasche2014-07-031-27/+20
|\| | | | | | | | | | | | | Conflicts: src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp Change-Id: Ib960b9e8d8800af84d2094bdf26c2652d4c81dba
| * Merge branch '5.3' into devAlex Blasche2014-06-271-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/bluetooth/qbluetoothlocaldevice_bluez.cpp src/bluetooth/qbluetoothlocaldevice_p.h src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp Change-Id: Ifb0c01eb8bffbffcd2416ea8d7bf1d36eb1c70f2
| | * Process Bluez5 URLs during SDP scanAlex Blasche2014-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bluez5 advertises the following SDP attributes - QBluetoothServiceInfo::DocumentationUrl - QBluetoothServiceInfo::ClientExecutableUrl - QBluetoothServiceInfo::IconUrl They come as <url> xml tag but otherwise follow the <text> syntax. So far this type of xml tag was unknown, a warning was printed and the service info didn't contain the relevant info. Although Bluez5 seems to be the first to advertise this attribute, Bluez4 has to be able to deal with it too. Hence this patch goes to Qt 5.3/stable. Change-Id: I216fdaee23c75b1ed86702086be2d95a0efe109e Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
| * | Avoid empty service namesAlex Blasche2014-06-031-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bluez doesn't seem to know the service class uuid 0x1200 which seems common on BB10 devices. Ensure that we set a name if Bluez did not provide a name. This was made possible by the recent addition of QBluetoothUuid::serviceClassToString(..). [ChangeLog][QtBluetooth][QBluetoothServiceDiscoveryAgent] Fixed cases where Bluez doesn't provide service names for given Bluetooth service class uuid. Change-Id: Ife56ab878f70ca6226e907f59972368c79318bec Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
| * | Bluez5: Simplify lookup of default adapterAlex Blasche2014-06-021-25/+4
| | | | | | | | | | | | | | | | | | Change-Id: I59aa5241d33191a8ca8cc167263b63b024f52754 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
| * | Don't stop processing of Bluez services if one service is invalidAlex Blasche2014-05-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a regression introduced during the Bluez5 port. During the service xml parsing we may encounter an invalid service info. This does not mean the next one is invalid too. This bug caused the service discovery to abort. Change-Id: If51e0f898d83e99ba0a279c13ccaa3e5947bb6bf Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
* | | Merge branch 'dev' into btleAlex Blasche2014-05-261-49/+425
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/bluetooth/bluetooth.pro src/bluetooth/bluez/bluez.pri src/bluetooth/doc/src/bluetooth-index.qdoc src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp src/bluetooth/qbluetoothdeviceinfo.cpp src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp src/bluetooth/qbluetoothservicediscoveryagent_p.h src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp Change-Id: I88b22c51a4ee95b067ef8d2b2fddb5cbff4566f8
| * | Use proper include syntax for system headersAlex Blasche2014-05-231-3/+3
| | | | | | | | | | | | | | | | | | | | | They can be found in /usr/include Change-Id: I734fd72c52d2b78aca6388d79e59c973e8d99a73 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
| * | Fix crash during call to QBluetoothServiceDiscoveryAgent::stop()Alex Blasche2014-05-231-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | This was triggered when the stop() call was made while the SDP thread was talking to the SDP server. Change-Id: If6624dce21ca4a099d5beae064685b6b3a907989 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
| * | Code cleanup: Avoid repeated service info duplication checkAlex Blasche2014-05-231-32/+11
| | | | | | | | | | | | | | | Change-Id: I00701e9103a6acfdfc2697949280f8a7de8bcdfe Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
| * | Simplify detection of Bluetooth Base UUID derived uuidsAlex Blasche2014-05-221-13/+1
| | | | | | | | | | | | | | | | | | | | | This avoids unnecessary code duplication. Change-Id: I9e49cf3c5e524cf7b3ef811b4640d5248c2ba1b0 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
| * | Service discovery via Bluez5Alex Blasche2014-05-221-31/+416
| | | | | | | | | | | | | | | | | | | | | | | | | | | At the same time we shift the ServiceClassUUID to service name mapping to QBluetoothUuid. It was used by Android and now Bluez 5 uses it too. Task-number: QTBUG-32085 Change-Id: I9f2d4dc4e2997683485f2ba7aaefb646cb72fb75 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
| * | Utilize QStringLiteral where possibleAlex Blasche2014-05-151-15/+15
| |/ | | | | | | | | | | | | | | The only exception are generated files and cases where QLatin1String based overloads are used (e.g. during QString comparisons) Change-Id: I6f36789fb8acb3b30c1dc1f8a920b118a979d74f Reviewed-by: Kai Koehne <kai.koehne@digia.com>
| * Don't double up the internal list of discovered servicesAlex Blasche2014-04-151-4/+19
| | | | | | | | | | | | | | | | | | | | | | Convention is that calling QBluetoothServiceDiscoveryAgent maintains an internal list of discovered services. When start() is called already discovered services are kept unless clear() was called. The Bluez code never checked which services were already discovered by previous discovery runs. This patch fixes this problem. Change-Id: I3987d6ea65ea41aefc9726acc31f6abaa478c72c Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* | Bind QLowEnergyController to a particular local adapter.Alex Blasche2014-03-151-1/+0
| | | | | | | | | | | | | | | | | | This simplifies the internal LEServiceInfo logic and let's us later deal with multiple adapters. Change-Id: I7d3e991207cd6571b5d644ae99c6bf1a2c99ec68 Reviewed-by: Nedim Hadzic <nhadzic@blackberry.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Merge branch 'dev' into btleAlex Blasche2014-03-141-1/+0
|\| | | | | | | | | | | | | | | Conflicts: src/bluetooth/qbluetoothuuid.cpp tests/bttestui/btlocaldevice.cpp Change-Id: Id16ab93ec61361950669da7eb232769c5dc4644f
| * Don't assert when we discover a new SDP property.Alex Blasche2014-02-201-1/+0
| | | | | | | | | | Change-Id: I4beb72aac294511b87ef95c459c52daa85c62499 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* | Don't create invalid LEServices on Bluez due to default adapter usageAlex Blasche2014-02-271-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | A valid LEServiceInfo on Bluez requires an adapter address. If the service discorvery was initialized with a default adapter, the internal service discovery never actually determines the adapter address. Subsequently every LEServiceInfo object got an invalid adapter address. Change-Id: I3d95ee5b2169f8a049121fe6cc4591d3b79262d9 Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | UUID filter for LE service implementedNedim Hadzic2014-02-241-36/+51
| | | | | | | | | | Change-Id: I7c79a7ca1f29ca428509847a7e32a4b0d157c018 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Fix some BTLE service discovery issuesAlex Blasche2014-02-201-18/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | 1.) In Bluez avoid incomplete and/or premature finish of service discovery process. 2.) Add Testcode for QBluetoothServiceInfo::serviceDiscovered(QLowEnergyServiceInfo) to bttestui application Change-Id: I037a6303862dcf2e29aef4b761731b13c85b29aa Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Merge branch 'dev' into btleAlex Blasche2014-02-171-64/+71
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/bluetooth/bluetooth.pro src/bluetooth/doc/src/examples.qdoc src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp src/bluetooth/qbluetoothservicediscoveryagent_p.h src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp Change-Id: Ie1577e4b0f469cd5a6b05a61cbe94f180a64448d