summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket_bluez.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Code cleanup: Use nullptr wherever possibleAlex Blasche2018-08-241-4/+4
| | | | | Change-Id: I7dd2d055c8d667f049d7cb2c371619137bf76030 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* QBluetoothSocket: Move (dis-)connected logic into setSocketStateOliver Wolff2018-08-161-1/+0
| | | | | | | | | | | | Instead of duplicating that logic everywhere, it can be handled in one place. Additionally setOpenMode should be called before setSocketState so that every member variable is changed, before signals are emitted. Change-Id: Ic1d4317ba31046d78d97874ec00c59481a67bb50 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Bluez: Fix missing signalling for QBluetoothSocket::abortAlex Blasche2018-08-151-0/+7
| | | | | | | | This is a bug introduced by 45c843ceca9fac1aa1246043730eaeeb3ed23235 where this backend was simply forgotten. Change-Id: I11c9eb1476a3ded7d0c12aaf1d203ff61194f3c4 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-07-311-1/+1
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf src/bluetooth/qbluetoothsocket.cpp Change-Id: If622e4915a9c5f6711978ef8c0fa88f4c5084270
| * Cleanup meaningless code in QBluetoothSocketAlex Blasche2018-07-261-1/+1
| | | | | | | | | | Change-Id: I0407e6c1d2074e7102763002d94fc7170f5926d4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* | Move QBluetoothSocket::connectToService() to private implementationsAlex Blasche2018-07-251-0/+105
| | | | | | | | | | | | | | | | | | | | | | This permits each platform to customize the implementations without the need for ifdefs. Upcoming changes such as the BLuez DBuS addition will increase the platform differences. Task-number: QTBUG-68550 Change-Id: I8fc9a74d3ce704466f0bf2c16287e32f222c4376 Reviewed-by: Lubomir I. Ivanov <neolit123@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* | Rename QBluetoothSocketBasePrivate::connectToService()Alex Blasche2018-07-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to move the various QBluetoothSocket::connectoService() implementations into the private classes. Common parts can be split into QBluetoothSocketBasePrivate and the platform specific code. The code becomes cleaner and has less ifdefs. However this creates a symbol clash with the currently existing private implementation as it has a function with the same signature but different purpose. This rename provides the foundation for future changes. Task-number: QTBUG-68550 Change-Id: I121f08d93e00790c1619c0449629f47bca8a964d Reviewed-by: Lubomir I. Ivanov <neolit123@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* | Add separate interfaces for QBluetoothSocketPrivate on LinuxAlex Blasche2018-07-251-26/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Uses the new QBluetoothSocketBasePrivate interface to separate the Linux implementations from other platforms. On Linux, there will be the existing raw socket implementation and a BlueZ5 DBus implementation. The DBus implementation is required for very recent Bluez5 deployments (v5.4x+) which restrict access to traditional SDP discovery means like sdptool. For now the DBus implementation is non-existing/dysfunctional. Task-number: QTBUG-68550 Change-Id: Idd248ecdb2a443a95cde521ced929218d40df3fe Reviewed-by: Lubomir I. Ivanov <neolit123@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* | Add runtime polymorphism for QBluetoothSocketPrivateAlex Blasche2018-07-251-10/+2
|/ | | | | | | | | | | | | | | | | | | | | | This patch introduces a generic interface towards QBluetoothSocketPrivate. Later on, the QBluetoothSocketPrivate class will be split into platform specific overloads/interfaces. Ultimately, this will be needed to support runtime selection of the QBluetootSocket d-pointer on Linux. The Linux Bluez5 implementation is significantly different from the Bluez4 (raw socket) implementation. Since recent Bluez5 releases the raw socket implementation is no longer functional and/or the user has to have root permission and enable bluetooth --compat mode. Therefore a second QBluetoothSocket for the dbus socket API is needed. QBLuetoothSocket has to choose at runtime (during its instanciation) which implementation to use. Task-number: QTBUG-68550 Change-Id: I5d0b8e24b8acd1b149b897f52f0d82eade7f3823 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Lubomir I. Ivanov <neolit123@gmail.com>
* Add support for QBluetoothSocket::RemoteHostClosedError on BlueZAlex Blasche2017-07-121-1/+3
| | | | | | Change-Id: I88ff16001280dea4967887ae711c463304c7ec7d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Add indirection for QBluetoothSocket::bytesToWrite()Alex Blasche2017-06-291-0/+5
| | | | | | | | | | | | | | | | | | Not all platforms use txbuffer for writes. Fortunately those platforms who do not use it do not use any buffering at all. Hence bytesToWrite() returned the correct value as txbuffer always had size zero. Therefore this patch is effectively a NOP. Nevertheless this patch encourages the right implementation across the platform. This does not affect macOS as it has a separate implementation for QBluetoothSocket::bytesToWrite(). Task-number: QTBUG-58190 Change-Id: Ic05f4358b079f612ee7e0e4dbb7fb9aa78fd6556 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Fix concurrent access to QBluetoothSocket::canReadLine() on AndroidAlex Blasche2017-06-291-0/+5
| | | | | | | | | | | | | | | | | | | | | On Android, the socket's read buffer is managed in the Java thread. QBluetoothSocket::canReadLine() is public API (most likely) being called by in the main Qt thread though. The function directly called into the Java buffer instance without proper locking. This can create race conditions. Starting with this patch canReadLine() calls another QBluetoothSocketPrivate indirection to allow a platform specific implementation. This affects WinRT, BlueZ and the dummy backend too. This is not an issue on macOS as its implementation of QBluetoothSocket is separate and does not have to deal with multiple QBluetoothSocketPrivate implementations. Task-number: QTBUG-58190 Task-number: QTBUG-60830 Change-Id: Idae19f1aee6f809699d36519b01a3c68ad9c563d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Merge remote-tracking branch 'origin/5.8' into 5.9v5.9.0-beta3Liang Qi2017-04-181-4/+2
|\ | | | | | | | | | | | | Conflicts: src/bluetooth/qbluetoothsocket_bluez.cpp Change-Id: I37e21b3c636a241a357bc81fc23da51303b94623
| * QBluetoothSocket/bluez: fix QString::arg() usageMarc Mutz2017-03-241-4/+2
| | | | | | | | | | | | | | | | | | QString::arg() returns the new value but leaves *this unchanged. Found by GCC 7 (-Wunused-result). Change-Id: I8a0ddb801ded94365f0e9a7ae13a37a96c7f437a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Replace custom QT_BLUEZ_BLUETOOTH against the related feature defineAlex Blasche2017-04-061-1/+1
| | | | | | | | | | Change-Id: I4fbb948841a610640acaf87364e2157e31782836 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* | Correct the use of QString::argThiago Macieira2017-04-031-4/+4
|/ | | | | | | | | | It returns an updated QString, without modifying the variable it was called on. Found by Clang when building: qbluetoothsocket_bluez.cpp:255:17: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result] Change-Id: I27b55fdf514247549455fffd14b1795de236d488 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Improve failed ::write() handling in QBluetoothSocketAlex Blasche2016-07-191-13/+37
| | | | | | | | | | | | | | | | | | | | | When the Bluetooth connection is flooded with information, EAGAIN is returned. So far this was considered an unrecoverable error which is not consistent with the meaning of EAGAIN. In buffered mode we'll put the data back into the buffer and in unbuffered mode the QIODevice::write() call returns 0 which leaves the developer the option to retry. At the same time this patch ensures that write() calls always return the actual number of written bytes and not the amount of bytes the caller asked for to be written. Partial writes in buffered mode are returned to the buffer too. Task-number: QTBUG-54475 Change-Id: Iffc7980d2477e1fc0b45808431af6b7fecd38ded Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
* Merge remote-tracking branch 'gerrit/dev' into neardAlex Blasche2016-01-261-14/+20
|\ | | | | | | Change-Id: If9cf6718cbd619dd7ce38db2da274fe9d0a41fb7
| * 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>
* | QBluetoothSocket: Do not report an error when the connection closes.Christian Kandeler2015-11-171-2/+2
|/ | | | | | | | Higher-level code should decide whether a remote device disconnecting constitutes an error or not. Change-Id: I50d7524d2684dbbbfc8df5667e227748fb31cee4 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Bluetooth socket: Simplify address conversion.Christian Kandeler2015-10-151-22/+10
| | | | | | | | In most cases, callers of convertAddress() feed the result into a QBluetoothAddress, so they have no need for the output parameter. Change-Id: I23b2e8d5d49ac300c35d141b75ffa8e398e22f19 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* [Bluetooth] Optimize loopsKonstantin Ritt2015-09-161-6/+10
| | | | | | | | | | | | 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: peername: find a device before creating it.Robin Burchell2015-08-201-3/+3
| | | | | | | | | | | | | | | | To enable reading peername 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: I4a86840487a8b4c90759044b7c995815c77a7609 Task-number: MER#1225 Done-by: Hannu Mallat <hannu.mallat@jollamobile.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Bluez: Apply QBluetoothSocket::preferredSecurityFlags during connectAlex Blasche2015-07-071-0/+21
| | | | | | | | | | | | | This permits Bluez clients to determine the security level before connecting to the server. Note that the server may change the sec level at runtime without the user noticing. If the user wants to detect such cases socketDescriptor() in compination with getsockopt() should be used. Task-number: QTBUG-46377 Change-Id: I3bc4fcd62dc44d9e2e14e5a6e7416e3bb8e0d50b Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
* Add preferredSecurityFlags to QBluetoothSocketAlex Blasche2015-07-031-0/+1
| | | | | | | | | This permits the API user to determine the security parameters for the connect attempt to the remote SPP service. Task-number: QTBUG-46377 Change-Id: I1ed5ea0f5a32aa08dcedc46a34b0377654e420b2 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
* Merge branch '5.4' into 5.5Alex Blasche2015-04-011-12/+2
|\ | | | | | | Change-Id: I177affc6c60fd3cc55e914a7ea2a9aeba260906f
| * Minor code optimizationAlex Blasche2015-03-191-12/+2
| | | | | | | | | | | | | | | | | | QBluetoothSocketPrivate::close() was always called when the internal socket state has been set to ClosingState. The removed checks were meaningless. Change-Id: Ia36808a21de7dd1076cdd47bca8fd6855ec957c3 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.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>
* Fix QBluetoothSocket::isReadable()/isOpen()/isWritable()Alex Blasche2014-10-131-1/+1
| | | | | | | Change-Id: Ifd6b5ed8176aa7959ed8da0edc762266aa2bd6fa Task-number: QTBUG-32704 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Add support for random vs public remote address connectionsAlex Blasche2014-09-021-3/+3
| | | | | | | | | | | | | | | | This is required to be able to connect to devices which use random device addresses. Some platforms can determine this flag based on their last device scan. The flag is likely to be provided as part of QBluetoothDeviceInfo once the information is available. Unfortunately non-le scan on BLuez doesn't inform about the flag. The LE device scan is currently not implemented and, even worse, requires root privileges on Linux. The new API element permits the selection of the correct type when the scan doesn't detect the type properly. Change-Id: I8e7118658a7c927e0ea07b0d639d57f9483cb33c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix failing L2CP socket's on high-endian systemsAlex Blasche2014-09-021-2/+2
| | | | | | | | Bluetooth byte order is little endian. htbos ensures the psm is converted to the required byte order. Change-Id: I22362d1f1fe3978df7855eab14154644a1d60a0d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Make QBluetoothSocket's _q_writeNotify & _q_readNotify privateAlex Blasche2014-08-251-7/+5
| | | | | | | | | These two functions are really only needed by Linux style socket code. There is no need for other platforms to implement them as dummy too. It simplifies the code somewhat. Change-Id: I3e0aced8d9f7b590d1c6aaa60f97bd060ee8f4b4 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
* Update license headers and add new licensesJani Heikkinen2014-08-241-19/+11
| | | | | | | | | - 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-4/+1
|\ | | | | | | Change-Id: I1e79c96602d0da2c2d36d6217bdfe7ff183e6df9
| * Merge branch '5.3' into devAlex Blasche2014-07-171-4/+1
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: src/bluetooth/bluez/bluez.pri src/bluetooth/qbluetoothsocket_bluez.cpp Change-Id: Ieca8f2a327bf54b42403ddab88f8b9c3ff6b4a95
| | * Reduce system header dependenciesAlex Blasche2014-07-161-3/+1
| | | | | | | | | | | | | | | Change-Id: I52ac33b4864d6bfca248ff3fad5a069154a9c756 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* | | Bind the BTLE socket to the local Bt deviceAlex Blasche2014-07-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This seems to be optional for Bluez4 but mandatory for Bluez5 to establish a connection at all. Change-Id: Ia99b6e6623fc63f3d0abe37a87808a59cbd889f1 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* | | Merge branch 'dev' into btleAlex Blasche2014-07-031-1/+1
|\| | | | | | | | | | | | | | | | | | | | Conflicts: src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp Change-Id: Ib960b9e8d8800af84d2094bdf26c2652d4c81dba
| * | Remove usage of QObject::tr() in qbluetoothsocket_bluez.cpp.Friedemann Kleint2014-06-301-1/+1
| | | | | | | | | | | | | | | Change-Id: I72703aac0676e6474f2c40ac37b8ee8b00830690 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | | Provide guarding against non-BTLE enabled versions of BluezAlex Blasche2014-06-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This disables the gatttool based controller as well. While it might compile on older systems they are likely to not have a gatttool and why would a Bluez version without BTLE symbols ever work anyway. Change-Id: I761e482d3dd1e99008c5d170053e19a1a3a51e6c Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* | | Discover all Bluetooth services and their handlesAlex Blasche2014-06-161-1/+3
| | | | | | | | | | | | | | | Change-Id: I83d88412319c34cf6c8cf0c6e841458226c9d073 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
* | | Connect to BTLE deviceAlex Blasche2014-06-161-2/+11
|/ / | | | | | | | | | | Change-Id: Iaae61b6a872124d17855d80d106f2b10996501de Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Port QBluetoothSocket/QBluetoothServer to Bluez 5Alex Blasche2014-05-261-40/+50
| | | | | | | | | | | | Task-number: QTBUG-32085 Change-Id: I9fe63f3291a10a195d460720cd1821913a63b25b Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
* | Utilize QStringLiteral where possibleAlex Blasche2014-05-151-8/+8
|/ | | | | | | | 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>
* Fix a crash in QBluetoothSocket on reconnection attempt (BlueZ)Oleg Shparber2014-04-161-0/+6
| | | | | | | | | Ensure a native socket is obtained after QBluetoothSocket has been closed. [ChangeLog][QtBluetooth][QBluetoothSocket] Fixed a crash on reconnect. Change-Id: I9f470d23366250dc20ad3305ddec16300c1ad8ec Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Fix internal buffer corruption in QBluetoothSocket (BlueZ)Oleg Shparber2014-04-161-2/+1
| | | | | | | | | When _q_readNotify() is called and no data is available (e.g. in case of timeout), then the internal buffer grows indefinitely, causing a one time corruption of the following good data. Change-Id: I75929382db73953bbccdd86b9ae248329df879fa Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Refactor disconnection signals emittance in QBluetoothSocketOleg Shparber2014-04-151-15/+1
| | | | | | | | | | | This fixes duplicate switching to the unconnected state in case the disconnect() signal is used to reconnect. [ChangeLog][QtBluetooth][QBluetoothSocket] Fixed duplicate emission of unconnected state in the reconnection case. Change-Id: If449420d936c96e62518fc408e6a1e35b79988a8 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Fix a few TODOs around the source code and remove obsolete onesAlex Blasche2014-03-131-1/+2
| | | | | | Change-Id: I01e867cb5efb231e7c85b0d106897b2f31448977 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Utilize new QBluetoothSocket::OperationError on QNX and BluezAlex Blasche2014-02-271-2/+17
| | | | | | | | Task-number: QTBUG-36817 Change-Id: I17f7d57537f7f1a5cedd01ce6043cfd6aac26db4 Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Remove QBluetoothSocketPrivate::socketDescriptor()Alex Blasche2014-02-261-5/+0
| | | | | | | | | The function is not required as the public accessor function directly returns the socket descriptor. Change-Id: I6d64bec7b4f0542ce213dc90dcfe30c3885ed21d Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>