Commit Graph

20 Commits

Author SHA1 Message Date
Marc Mutz 4d975c3ffc Port simple cases of count() to size()
The count() methods on QByteArray and QString are deprecated. The ones
on other Qt containers will likely follow soon, so port them all to
size().

The changes which also require int -> qsizetype will come in a
follow-up patch.

Pick-to: 6.3
Change-Id: I23e364019b9cfc457d93f4a3bb4660fe8d790da8
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-11 15:21:46 +02:00
Marc Mutz 330efe20f7 Replace count() comparisons against 0 with isEmpty()
Pick-to: 6.3
Change-Id: I0a14c1737cda87fa30d207bdf5b2a697214b7e70
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-08 07:11:30 +02:00
Juha Vuolle bdc2b067d4 Add support for QBluetoothServer::serverAddress() on Windows
Since Qt 6.3 Windows has a QBluetoothLocalDevice support which can be
used to provide the address.

Fixes: QTBUG-102007
Pick-to: 6.3
Change-Id: I214c43983bfcc323fcd6b01436ed82577c0c4450
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-03-25 15:15:11 +02:00
Juha Vuolle 71a8f966f0 Remove unnecessary variable inits in bluetooth servers
Since 6.2 there are in-class initializations for many of the
variables. In addition the Windows backend does not use
the socket that is created.

Pick-to: 6.2 6.3
Change-Id: I371b9b23aee54c49aa8fc71f86c2e8ecbbbfc407
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-03-25 15:15:08 +02:00
Juha Vuolle 340b84a557 Add Windows COM initializations on Bluetooth
The COM apartment model needs to be initialized before use, but
the existing CoInitialize/CoUninitialize pairs don't cover all COM
usage in bluetooth. This may be a problem for non-gui applications
whose main thread's apartment model may not be implicitly initialized
by Qt baseclasses.

This commit adds initialization calls to the classes that use COM.

Fixes: QTBUG-101953
Pick-to: 6.2 6.3
Change-Id: I07a8a5dc38cdbd150794056cb91074f478765e53
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2022-03-24 16:07:18 +02:00
Andreas Buhr e6f7e7b756 Unify Windows logging categories
There were two logging categories on Windows:
qt.bluetooth.winrt and qt.bluetooth.windows. As there is now only
one Windows backend, multiple logging categories are not required.
This patch removes qt.bluetooth.winrt and changes all usages
to qt.bluetooth.windows.

Change-Id: I3f42774e77326fa30f3f7bff6cac8160bf4e644f
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-04-12 18:45:23 +02:00
Andreas Buhr 1617f94cfc Change QBluetooth::Security and AttAcc. to be a scoped enums
This patch changes QBluetooth::Security and
QBluetooth::AttAccessConstraint to be scoped
enums for improved type safety.

Fixes: QTBUG-91906
Change-Id: Ife4797aa8e106690a10e4fcb7f623877023fbb3c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-03-30 14:38:51 +02:00
Andreas Buhr 75c3a3ee9f rename error signals to errorOccurred
Currently, there is a name clash between the error getter and
the error signal. This leads to extensive use of qOverload or
similar. This patch renames all error signals to errorOccurred
to resolve this.

Task-number: QTBUG-62877
Change-Id: I615e2405f855433b6e142d820072c4d3f35ae28f
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-03-22 13:51:28 +01:00
Oliver Wolff ef259f86a3 Remove winrt
Task-number: QTBUG-84434
Change-Id: Ib63031a7984a2d70456c1dc171dc88b90f998b74
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-07-02 19:59:33 +02:00
Oliver Wolff 0bb394194a winrt: Avoid possible hang in QBluetoothServer::hasPendingConnections
We have to unlock the mutex locker after the pending connection is
handled in QBluetoothServerPrivate::handleClientConnection. Otherwise
the application will hang, if the slot that is connected to
QBluetoothServer::newConnection calls
QBluetoothServer::hasPendingConnections as this functions also tries to
lock the mutex.

Fixes: QTBUG-81827
Change-Id: I40632d0c1e4a6cf4436f6471e5a0933c53dda9f1
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-02-11 14:29:41 +01:00
Andre de la Rocha 8b7b52d66f Enable the use of the Win32 Bluetooth backend
This change enables the optional use of the Win32-based Bluetooth
backend on Windows. By default, the WinRT backend is used, if
supported by the platform. The use of the Win32 backend must be
selected by the -native-win32-bluetooth configuration option.

Task-number: QTBUG-40698
Change-Id: I6904bf077467d826e3ff5ad026ebae5f955f2e37
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2019-08-05 09:16:09 +02:00
Alex Blasche fcf1f30d5f Code cleanup: Use nullptr wherever possible
Change-Id: I7dd2d055c8d667f049d7cb2c371619137bf76030
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-08-24 05:44:21 +00:00
Alex Blasche 4aa3093447 Add QBluetoothSocketPrivate interface for WinRT
Task-number: QTBUG-68550
Change-Id: I14fe43fcbbbdd6950f05feda900643f6899daa24
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-07-25 11:16:21 +00:00
Oliver Wolff 8f1bd6c6c0 windows: Make sure everything is properly CoInitialized on desktop use
Task-number: QTBUG-61566
Change-Id: I5f8ff2c3e8a841ab8c5a3fb465d0be4b003d7a2b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-08-30 13:33:10 +00:00
Oliver Wolff dbd70341ea Add configure test to detect presence of winrt API
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>
2017-08-30 13:33:08 +00:00
Oliver Wolff d1d06bf7ad winrt: Fix crash in QBluetoothServer::nextPendingConnection
If there are no pending connections, the call should not make
the application crash but just return nullptr.

Change-Id: I33c2ec9b47bbb72abc99ad22035f794724b295ef
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-08-04 07:58:16 +00:00
Oliver Wolff bcf6ef95b8 winrt: Use custom setSocketDescriptor function
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>
2017-02-03 11:06:26 +00:00
Oliver Wolff f07c94c003 winrt: Register callbacks in Xaml thread
Change-Id: Ib32af0803e95229a1671055da4d5608f3fd3e0f6
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-02-03 11:06:23 +00:00
Oliver Wolff 69c8d41f90 winrt: maxPendingConnections must be lower than currently pending connections
Change-Id: Ie14506c0ad648413019c511d4d39dc8bd43d7405
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2017-02-03 09:55:42 +00:00
Oliver Wolff c9218dbb84 winrt: Add bluetooth server support
Task-numer: QTBUG-37779
Change-Id: Ieb3ed5dfea7d60b3875cbe97bb26f8060bebcc17
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2017-01-31 08:43:34 +00:00