summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket_p.h
Commit message (Collapse)AuthorAgeFilesLines
* winrt: Fix build using -no-pchOliver Wolff2017-10-251-0/+2
| | | | | | Task-number: QTBUG-63210 Change-Id: I98637337d8a77c8847bd0f2c567fec5e6a4ace31 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Windows: Fix namespaced buildOliver Wolff2017-07-261-2/+4
| | | | | Change-Id: I9f6a7c3884c2d7c9b0856a0e9a689ad88cca59fe Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Add indirection for QBluetoothSocket::bytesToWrite()Alex Blasche2017-06-291-0/+1
| | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | | | | | | | | | | | | 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>
* Obtain random bt address flag via Bluetooth Mgmt APIAlex Blasche2017-06-161-2/+2
| | | | | | | | | | | | | | | DBus does not expose this information. The Bluetooth Management API advertises the information but requires CAP_NET_ADMIN. The Management class monitors DEVICE FOUND events and records the random bit flag of each new device. QBluetoothDeviceDiscoveryAgent can subsequently add this information to the internal data set. Ultimately this makes QLowEnergyController::setRemoteAddressType obsolete. This function was only ever required on Linux. Task-number: QTBUG-46776 Change-Id: If10df86d332dfc7cc98b7c783eb28487c3fa9045 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Workaround for Android SDP discovery bugAlex Blasche2017-06-161-1/+12
| | | | | | | | | | | | | | | | | | | | | Due to an Android platform bug, SDP discovery may return the wrong uuid for the remote service. This bug was introduced by Android 6.0.1 and tracked by https://issuetracker.google.com/issues/37076498. The returned UUID is byte swapped. To increase the QBluetoothSocket::connectToService() convenience QBluetoothSocket uses a fallback which attempts to connect to the remote service assuming the uuid was byte swapped. This will only happen if the uuid is not derived from the official Bluetooth base UUID (aka the given UUID is truly custom). There is the slight chance that the reversed UUID is a different service but that chance is very marginal when considering the amount of possible custom UUIDs. Task-number: QTBUG-61392 Change-Id: Ia41d670ab8d0666628f067e174965b698d0f26b0 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
* Replace custom QT_BLUEZ_BLUETOOTH against the related feature defineAlex Blasche2017-04-061-2/+2
| | | | | Change-Id: I4fbb948841a610640acaf87364e2157e31782836 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* winrt: Use custom setSocketDescriptor functionOliver Wolff2017-02-031-0/+5
| | | | | | | | We have to use a similar approach to the one that is used on android as the ComPtr cannot reliably passed as an int. Change-Id: Ia52c78d4725fb3240eafa62fcb55531a282c0cd3 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* winrt: Add bluetooth socket supportOliver Wolff2017-01-201-0/+42
| | | | | | | Task-number: QTBUG-37779 Change-Id: I7fb49a6870768da956793b0d0681c371da939df9 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* 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>
* Bluetooth socket: Simplify address conversion.Christian Kandeler2015-10-151-2/+5
| | | | | | | | 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>
* 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>
* Remove QNX/BlackBerry implementation for QtBluetoothAlex Blasche2015-06-171-15/+3
| | | | | | | | | [ChangeLog][QtBluetooth][Platform Specific Changes] Removed support for Blackberry 10. Change-Id: I431c4f34bb10aa3668542df7a8b3403b61bf4705 Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Merge branch '5.4' into 5.5Alex Blasche2015-04-011-8/+15
|\ | | | | | | Change-Id: I177affc6c60fd3cc55e914a7ea2a9aeba260906f
| * Android: Fix crash when destructing socket during active connectAlex Blasche2015-03-301-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling BluetoothSocket.connect in Java blocks for a certain amount of time. Previously, QtConcurrent::run() was used to separate the Java connect() call out into a different thread. Since the function executed by QtConcurrent and the user facing class shared data fields, a crash occurred if the user deleted QBluetoothSocket while QtConcurrent hadn't executed its service connect call yet. The problem is solved by using QThread and Standard signal/slots which separates the shared data members. The only remaining shared data member is Java's BluetoothSocket instance which is shared via QAndroidJniObject references. This is no problem as deleting one reference retains the other reference. Calling close() on an Android BluetoothSocket while a connect() is ongoing seems to be buggy. Sometimes the close() returns, the pending connect() throws an exception but the physical connection still gets established. To avoid this the patch queues the close() call up until after the connect() statement has returned. It is accepted behavior that the connection might still get enabled for a very brief moment despite a close() being issues before the connect() actually finished. The SocketConnectThread cleans itself up once the thread finished(). Task-number: QTBUG-44930 Change-Id: I8324497a7395de390529ecd0b97b1a326cd78f63 Reviewed-by: Ulf Hermann <ulf.hermann@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>
* | QBluetoothSocket - bugfix and mods for OS X.Timur Pocheptsov2014-10-011-1/+15
| | | | | | | | | | | | | | | | | | | | | | - Emit disconnected if a channel was closed by IOBluetooth (== closed externally, not by Qt). - Trick to enable invokeMethod to work with a private class (not parseable by moc). - Fix inclusion guards _OSX_P_H, not _P_H (already in use). - QBluetoothServer - update include + reset a port to 0 in 'close'. Change-Id: Iaa35d6ca3ae1e8013b74d93a238d1afa4292a583 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Port QBluetoothSocket to OS X.Timur Pocheptsov2014-09-261-0/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement QBluetoothSocket using IOBluetooth framework on OS X (will implement Qt's API as close as possible with a given Apple's API). Update 0: add (empty for now) delegate classes (L2CAP/RFCOMM). Update 1: add service discovery (called doDeviceDiscovery though). Update 2: implement the public class' logic (QBluetoothSocket, connectToService). Update 3: more public logic implemented (since it's easy :) ) Update 4: L2CAP delegate - initial logic. Update 5: connectToService - L2CAP "socket". Update 6: fix pivate header files. Update 7: fix dependency after the previous patch was merged. Update 8: writeData - initial version for L2CAP. Update 9: since RFCOM/L2CAP delegates have the same interface, no need in duplicating the same class - add a "generic" ChannelDelegate instead. Update 10: more RFCOMM logic. Update 11: function to build a service description from QBluetoothServiceInfo (to be registered on SDP server). Update 12: QBluetoothSocket::close/abort. Update 13: Create a dictioinary out of QBluetoothServiceInfo to register a service. Update 14: Add service registration. Update 15: Convert attributes (sequences and 'scalars') from QBluetoothServiceInfor into NSDictionary. Update 16: Update QBluetoothServiceInfo with a real PSM/ChannelID after a service was registered. Update 17: Move a private class (bluetooth socket) into the separate private header file (to make it visible for bluetooth_server_osx) Update 18: Add an interface to create a bluetooth socket (private class) from a channel, reported by a notification (found by a listening server). Update 19: Fix an invalid assert - any state (Inactive/ServiceDiscovery/DeviceDiscovery) is possible, not only Inactive. Implement the missing 'readData' and 'writeData' for RFCOMM. Set SDP query as non-active after query finished. Temporary (!) workaround - can not invokeMethod on a private socket (d_ptr). Update 20: When creating a socket wrapper from an incoming notification/channel, set: socket type + channel's delegate. Change-Id: Idd6d5478597206ed759f49e282baed948d105ddf Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Add support for random vs public remote address connectionsAlex Blasche2014-09-021-1/+1
| | | | | | | | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.3' into 5.4Frederik Gladhorn2014-08-281-2/+18
|\ | | | | | | | | | | | | Conflicts: src/bluetooth/qbluetoothdevicediscoveryagent_p.cpp Change-Id: Ie8bf1903f9c7c1ccd5b05a3f97049ae0882b88b8
| * Add missing private headers warningSamuel Gaist2014-08-181-0/+11
| | | | | | | | | | Change-Id: I0f079a9b1b45bd2d2e946e06d7688f299a9c3fc3 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
| * Move socket workaround into own fctn and fix possible channel mismatchAlex Blasche2014-07-241-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the remote rfcomm channel was fixed to 1 which may not always match the correct rfcomm port. At the end of the day this is still a workaround for failure to connect when socket creation via UUID fails. We assume that the remote rfcomm service can be reached via the channel number. There is the remote chance that we connect to the wrong remote channel because getServiceChannel() fails and we attempt to connect to the hardcoded channel 1. However the workaround significantly reduces the chance of failure as a few devices (especially on the low end margin) cannot successfully connect via the UUID. The patch improves code readability and formatting too. Task-number: QTBUG-40172 Change-Id: Iae90252c877ca13953a81ea1ed83cc2c73abdf2a Reviewed-by: firatagdas <firatagdas@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
| * Fixed QTBUG-40172 Android Bluetooth Socket Connection fails in some cases.Firat Agdas2014-07-241-2/+4
| | | | | | | | | | Change-Id: Ibc4c835a9778bfa220ad6553f2c0140a7727d75d Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Make QBluetoothSocket's _q_writeNotify & _q_readNotify privateAlex Blasche2014-08-251-12/+7
| | | | | | | | | | | | | | | | | | 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>
* | Connect to BTLE deviceAlex Blasche2014-06-161-0/+5
| | | | | | | | | | | | Change-Id: Iaae61b6a872124d17855d80d106f2b10996501de Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* | Replace Q_SIGNALS/Q_SLOTS with signals/slots in private headersOleg Shparber2014-04-291-2/+2
|/ | | | | | | This patch fixes private headers accordingly to coding guidelines Change-Id: Id428e162207a7ae70ccfbcb172d28cab79739818 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Convert internal function parameter to const &Alex Blasche2014-03-131-1/+1
| | | | | | | | Performance improvement Change-Id: I9565771ab6ed15dccc67d5d7e7d5c02759a40367 Reviewed-by: Nedim Hadzic <nhadzic@blackberry.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Fix crash when interrupting QBluetoothSocket's input stream threadAlex Blasche2014-02-271-1/+1
| | | | | | | | | | | | The previous QThread did not always properly resume when InputStream.read() was interrupted by BluetoothSocket.close(). This patch converts the QThread to a Java thread which works as the Android API docs suggested. Task-number: QTBUG-37061 Change-Id: Id6ac9b57a28f3b532cbe49ff1dfdc9d1e6432aaa Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Remove QBluetoothSocketPrivate::socketDescriptor()Alex Blasche2014-02-261-1/+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>
* QNX QBluetoothSocket state fixNedim Hadzic2014-02-261-0/+2
| | | | | | | | Wrong socket state order fix. Due to this, the socket was not keeping remote device info. Change-Id: I860f15af9de4eb2e1238989d33bc59d62536f7aa Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Port QtBluetooth to AndroidAlex Blasche2014-02-131-3/+30
| | | | | | | | | | | | | | | | | | | | | | This is a feature merge to dev targeting Qt 5.3. Known issues: -QTBUG-36754: QBluetoothServer::close() crashes -QTBUG-36763: QBluetothTransferManager port to Android not possible -QTBUG-36764: Improve QBluetoothLocalDevice::connectedDevices() -QTBUG-36810: Remove direct use of Android action strings The above issues and some other minor TODO's will be addressed until final release time. Task-number: QTBUG-33792 [ChangeLog][QtBluetooth][Android] QtBluetooth has been ported to Android. Change-Id: I31ba83e3b7d6aa68e7258b7e43235de7d1a6e68a Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Don't cache the QBluetoothSocket::localName() & peerName()Alex Blasche2014-01-291-2/+0
| | | | | | | | | | | | This affects Bluez only. The other platforms don't use this feature. The problem was triggered when connecting, disconnecting and connecting again to another device. localName() might change due to a different local Bluetooth adapter being used and peerName() is different anyway in such cases. Change-Id: I8983a355832cf4f4d9a654971c54f5624be288e6 Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Unify QBluetoothSoket, QBluetoothServer and QBluetoothServiceInfo protocol enumFabian Bumberger2013-09-201-3/+3
| | | | | Change-Id: I6e66196a599e2cceabc7d93d728ba97361d8999f Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Remove QtBluetooth and QtNfc namespace.Alex Blasche2013-09-091-2/+2
| | | | | | | | This is based on namespace discussions on the Qt project dev mailing list. We continue to use the Qt namespace. Change-Id: I6119d06662f7682c11f42d759f3218be1f5a7d6c Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* QNX: Change name of platform define to QT_QNX_BLUETOOTHFabian Bumberger2013-08-231-4/+4
| | | | | | | To be aligned with the bluez implementation Change-Id: I8d3fbd0c23298f984e2c99cbf4131cf8fc0a0a64 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
* Update Copyright headersAlex Blasche2013-06-251-1/+1
| | | | | | | | | - Update Digia's copyright year - Add copyright to files without it - Convert old BSD to new LGPL license for auto test code Change-Id: I47f5c871c436f9c2731b235026434448719cc671 Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Rename NFC and Bluetooth namespace macros.Aaron McCarthy2013-02-141-2/+2
| | | | | | | | Renamed to the namespace macros to follow what syncqt expects. This fixes missing namespace macro warnings printed by syncqt. Change-Id: I7be5a700e8435a559cb4c2e74938851233095887 Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
* Remove use of QT_{BEGIN,END}_HEADER macros.Aaron McCarthy2013-02-031-4/+0
| | | | | | | | These macros were removed from Qt Core and they are no longer defined causing qtconnectivity to fail to build. Change-Id: I7971cca9d51e7eb1e395e348efb471982e355527 Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
* QNX: Adding SPP supportFabian Bumberger2012-11-231-0/+24
| | | | | | | This commit adds the SPP server and socket to the QNX Bluetooth port Change-Id: I0868f4cbc32fc84f0688eafdd2c3350dc8506b65 Reviewed-by: Alex <ablasche@gmail.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-231-24/+24
| | | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: I4f07028d0bf0b3ba4c4649897b80687ea5e51abc Reviewed-by: Janne Anttila <janne.anttila@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* removed Nokia specific stuff not needed any moreMichael Zanetti2012-06-261-9/+0
| | | | | Change-Id: I0b2c41f3c971221c65f77f847129ab38b094c31c Reviewed-by: Alex <alex.blasche@nokia.com>
* Extend SPP profile to be used with NOKIA_BT_SERVICESMichael Zanetti2012-04-261-0/+9
| | | | | Change-Id: Ide681b442f50d7b126d93b891b58aba75832b881 Reviewed-by: Alex <alex.blasche@nokia.com>
* Move qprivatelinearbuffer_p.h into bluetooth projectalex2012-02-281-1/+1
| | | | | | | | In general we don't have any code in MODULE_SRC/src Change-Id: I412e5de3708a036df8e5a76fcd7870faea90fb5d Reviewed-by: Michael Zanetti <michael.zanetti@nokia.com> Reviewed-by: Alex <alex.blasche@nokia.com>
* No more Bluetooth on Symbianalex2012-02-081-44/+0
| | | | | | | | This change cleans the code base significantly. Change-Id: I668d05d72cf5aa896818139e2daba51909c0b9dd Reviewed-by: Michael Zanetti <michael.zanetti@nokia.com> Reviewed-by: Alex <alex.blasche@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I84f8c423bd7748bbae495fedae696990414cee83 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update obsolete contact address.Jason McDonald2012-01-201-1/+1
| | | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I1c6ba5c87f0eca30b6f01f4245a032262d30f8ce Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | | Change-Id: I76920b22a5b386a0f85ec28076da20505c022b6f Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* added Connectivity namespaces (QtBluetooth and QtNfc)Michael Zanetti2011-11-111-1/+5
| | | | | | Change-Id: I5f3062c857e657a6d05ab29edfa2f1b48cb173f8 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Alex <alex.blasche@nokia.com>
* Initial commit.Michael Zanetti2011-08-241-0/+209
From qt5connectivity.tar.gz, md5 317c149d6f8c07d09632353188582834