summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket_winrt.cpp
Commit message (Collapse)AuthorAgeFilesLines
* qbluetoothsocket_winrt: Fix clang warningsOliver Wolff2019-06-181-18/+46
| | | | | | | Change-Id: I71eafba9e7ff47dbfd89e3a650b83b55d1196693 Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* qbluetoothsocket_winrt: Use recommended service connection approach if possibleOliver Wolff2019-05-271-17/+47
| | | | | | | | | | | | | | | | MSDN documentation states that the recommended way of RFCOMM service connection is via connectionHostName and connectionServiceName (see https://docs.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.rfcomm.rfcommdeviceservice). So whenever possible, we should use this information from the native device service when connecting directly to the discovered service. As QBluetoothServiceInfo is basically just a wrapper for the attributes map this information is stored in its private pendant and extracted when a connection attempt is being made. Task-number: QTBUG-62520 Change-Id: I95be5df89a722531393b45fd136d37f302393ca8 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Fix clang-cl errors about narrowing conversionsKai Koehne2019-04-081-1/+1
| | | | | | | | | | | | | Force value to be a DWORD (unsigned long) instead of HRESULT (signed long). Fixes bluetoothsocket_winrt.cpp(770,10): error: case value evaluates to 2147952460, which cannot be narrowed to type 'long' [-Wc++11-narrowing] Change-Id: I4f1eb75807d4783b835094ad1b33e56f601ffb39 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* winrt: Add missing error handling in connectToServiceHelperOliver Wolff2018-08-161-1/+2
| | | | | | | | | QBluetoothSocketPrivateWinRT::connectToServiceHelper was missing one hr check. Change-Id: Iae357df99881874b2d672dde6625e36d6221de0f Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QBluetoothSocket: Move (dis-)connected logic into setSocketStateOliver Wolff2018-08-161-3/+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>
* Shift close/abort signaling from QBluetoothSocket to private implementationsAlex Blasche2018-08-091-1/+15
| | | | | | | | | | | | | | | | The private implementation can much more easily determine whether the socket closure is already done or not. On Bluez DBus, this avoids disconnected() being emitted twice. Another platform that is still delayed is Android. The patch permits the removal of Android specific ifdefs. Last but not least the patch cleans up missing signals in WinRT. Task-number: QTBUG-68550 Change-Id: I189e1dbc9f6d410522da1a82113fdf4fe79a4cbd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Move QBluetoothSocket::connectToService() to private implementationsAlex Blasche2018-07-251-0/+99
| | | | | | | | | | | 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 QBluetoothSocketPrivate interface for WinRTAlex Blasche2018-07-251-32/+31
| | | | | | Task-number: QTBUG-68550 Change-Id: I14fe43fcbbbdd6950f05feda900643f6899daa24 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Add runtime polymorphism for QBluetoothSocketPrivateAlex Blasche2018-07-251-7/+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>
* winrt: Properly close the bluetooth socketOliver Wolff2018-02-271-0/+9
| | | | | | | | | | | | | If I understand the documentation correctly, the socket's onCompleted callback should be called manually (with a proper status) before calling Close on its read operation (see https://docs.microsoft.com/en-us/uwp/api/windows.foundation.iasyncoperationwithprogress_tresult_tprogress_). Additionally all logic could be cut from the callback as soon as shutdown is initiated as we might run into dangling pointers otherwise. Change-Id: I3b7969f1aae16c453bc450b652746c8e21b2ef8f Reviewed-by: Andre de la Rocha <andre.rocha@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.105.10Liang Qi2018-02-021-0/+5
|\ | | | | | | Change-Id: Ia3172f663412eb9df0b1c41fc114699813039c43
| * Windows: Cancel and close the operation before deleting the SocketWorkerAndy Shaw2018-01-261-0/+4
| | | | | | | | | | | | | | | | | | | | Since it is possible that after calling Cancel() on the IAsyncInfo that it will still call the Completed() callback, we need to ensure that it has a chance to process the pending events before it is deleted. Change-Id: I7d6fbb5bf6344098048b147c9d361c1fe7923b55 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
| * Initialize the discoveryAgent variable to 0Andy Shaw2018-01-241-0/+1
| | | | | | | | | | Change-Id: Ief783e899cde02ae033be8cd3af61ab5572d81a5 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* | Add configure test to detect presence of winrt APIOliver Wolff2017-08-301-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of checking for a certain Windows version, we should check whether the API is actually available [ChangeLog][QtBluetooth][Windows] Enabled UWP backend for desktop Windows versions that support the API Task-number: QTBUG-61566 Change-Id: I8384119c70cc2c4bdcdbe6b297cfcf5fb3e3f534 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* | Merge remote-tracking branch 'gerrit/5.9' into devAlex Blasche2017-08-071-0/+15
|\| | | | | | | Change-Id: I0ed4afd881f483a166a7e1400043f116c491f30c
| * winrt: Check for valid m_socketObject before accessing socket informationOliver Wolff2017-08-021-0/+15
| | | | | | | | | | | | | | | | | | | | If the socket was created without giving the socket type, ensureNativeSocket was not called and thus m_socketObject is 0. Calling localName and friends caused a crash because they accesses the object unconditionally. Change-Id: I442e3d1492458161fb8660f1b2f17d52b37a2935 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Add support for QBluetoothSocket::RemoteHostClosedError on Win UWPAlex Blasche2017-07-101-1/+4
|/ | | | | Change-Id: I6503377cd99d403ff31a2eae8109476294cbebac Reviewed-by: Oliver Wolff <oliver.wolff@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>
* winrt: Set proper socket state in setSocketDescriptorOliver Wolff2017-02-031-0/+1
| | | | | Change-Id: I5469f696d0f20d563a67cdcc94af16faf6cac8ea Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* winrt: Use custom setSocketDescriptor functionOliver Wolff2017-02-031-7/+13
| | | | | | | | 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: Register callbacks in Xaml threadOliver Wolff2017-02-031-9/+15
| | | | | Change-Id: Ib32af0803e95229a1671055da4d5608f3fd3e0f6 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* winrt: Add bluetooth server supportOliver Wolff2017-01-311-5/+16
| | | | | | Task-numer: QTBUG-37779 Change-Id: Ieb3ed5dfea7d60b3875cbe97bb26f8060bebcc17 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* winrt: Fix wrong function name in invokeMethod in bluetooth socketOliver Wolff2017-01-301-1/+1
| | | | | Change-Id: I9fd9131c031328afa936a52e42371409e3fbac48 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* winrt: Add bluetooth socket supportOliver Wolff2017-01-201-0/+644
Task-number: QTBUG-37779 Change-Id: I7fb49a6870768da956793b0d0681c371da939df9 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>