summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-09-18 13:53:24 +0200
committerAlex Blasche <alexander.blasche@qt.io>2018-10-09 07:47:56 +0000
commitfac56a229b45395488f3e41bf178361c72b3ee1e (patch)
treeae99681642099d2bd3cb42fc66804f61c6f65aab
parent7ef3dfbd4354367ad78040010aa851943b7b9e75 (diff)
Deprecate QBluetoothDeviceInfo::DataCompleteness with Qt 6 in mind
The patch deprecates the mentioned enum and all users of it. In addition, QList usage is replaced by QVector (which is a design pattern in Qt). Task-number: QTBUG-62425 Change-Id: I63e8dceb03ed231d0d06709896a1aad2b6bb31a3 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/bluetooth/osx/osxbtledeviceinquiry.mm8
-rw-r--r--src/bluetooth/osx/osxbtsdpinquiry.mm4
-rw-r--r--src/bluetooth/osx/osxbtsdpinquiry_p.h3
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp8
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm4
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp10
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp36
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.h18
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo_p.h2
-rw-r--r--tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp5
10 files changed, 73 insertions, 25 deletions
diff --git a/src/bluetooth/osx/osxbtledeviceinquiry.mm b/src/bluetooth/osx/osxbtledeviceinquiry.mm
index e61968ed..677a4660 100644
--- a/src/bluetooth/osx/osxbtledeviceinquiry.mm
+++ b/src/bluetooth/osx/osxbtledeviceinquiry.mm
@@ -81,7 +81,7 @@ struct AdvertisementData {
// For now, we "parse":
QString localName;
- QList<QBluetoothUuid> serviceUuids;
+ QVector<QBluetoothUuid> serviceUuids;
QHash<quint16, QByteArray> manufacturerData;
// TODO: other keys probably?
AdvertisementData(NSDictionary *AdvertisementData);
@@ -324,10 +324,8 @@ QT_USE_NAMESPACE
if (RSSI)
newDeviceInfo.setRssi([RSSI shortValue]);
- if (qtAdvData.serviceUuids.size()) {
- newDeviceInfo.setServiceUuids(qtAdvData.serviceUuids,
- QBluetoothDeviceInfo::DataIncomplete);
- }
+ if (qtAdvData.serviceUuids.size())
+ newDeviceInfo.setServiceUuids(qtAdvData.serviceUuids);
const QList<quint16> keys = qtAdvData.manufacturerData.keys();
for (quint16 key : keys)
diff --git a/src/bluetooth/osx/osxbtsdpinquiry.mm b/src/bluetooth/osx/osxbtsdpinquiry.mm
index 6df2d16e..88849872 100644
--- a/src/bluetooth/osx/osxbtsdpinquiry.mm
+++ b/src/bluetooth/osx/osxbtsdpinquiry.mm
@@ -112,9 +112,9 @@ void extract_service_record(IOBluetoothSDPServiceRecord *record, QBluetoothServi
}
}
-QList<QBluetoothUuid> extract_services_uuids(IOBluetoothDevice *device)
+QVector<QBluetoothUuid> extract_services_uuids(IOBluetoothDevice *device)
{
- QList<QBluetoothUuid> uuids;
+ QVector<QBluetoothUuid> uuids;
// All "temporary" obj-c objects are autoreleased.
QT_BT_MAC_AUTORELEASEPOOL;
diff --git a/src/bluetooth/osx/osxbtsdpinquiry_p.h b/src/bluetooth/osx/osxbtsdpinquiry_p.h
index 6b39634e..f8eaf735 100644
--- a/src/bluetooth/osx/osxbtsdpinquiry_p.h
+++ b/src/bluetooth/osx/osxbtsdpinquiry_p.h
@@ -57,6 +57,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/qlist.h>
+#include <QtCore/qvector.h>
#include <Foundation/Foundation.h>
@@ -81,7 +82,7 @@ public:
void extract_service_record(IOBluetoothSDPServiceRecord *record, QBluetoothServiceInfo &serviceInfo);
QVariant extract_attribute_value(IOBluetoothSDPDataElement *dataElement);
-QList<QBluetoothUuid> extract_services_uuids(IOBluetoothDevice *device);
+QVector<QBluetoothUuid> extract_services_uuids(IOBluetoothDevice *device);
}
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
index 86b7a5e7..53a7ca09 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
@@ -364,12 +364,12 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres
QBluetoothDeviceInfo device(btAddress, btName, btClass);
if (dict.value(QStringLiteral("RSSI")).isValid())
device.setRssi(dict.value(QStringLiteral("RSSI")).toInt());
- QList<QBluetoothUuid> uuids;
+ QVector<QBluetoothUuid> uuids;
const QStringList uuidStrings
= dict.value(QLatin1String("UUIDs")).toStringList();
for (const QString &u : uuidStrings)
uuids.append(QBluetoothUuid(u));
- device.setServiceUuids(uuids, QBluetoothDeviceInfo::DataIncomplete);
+ device.setServiceUuids(uuids);
device.setCached(dict.value(QStringLiteral("Cached")).toBool());
@@ -443,7 +443,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::deviceFoundBluez5(const QString& dev
QBluetoothDeviceInfo deviceInfo(btAddress, btName, btClass);
deviceInfo.setRssi(device.rSSI());
- QList<QBluetoothUuid> uuids;
+ QVector<QBluetoothUuid> uuids;
bool foundLikelyLowEnergyUuid = false;
for (const auto &u: device.uUIDs()) {
const QBluetoothUuid id(u);
@@ -459,7 +459,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::deviceFoundBluez5(const QString& dev
}
uuids.append(id);
}
- deviceInfo.setServiceUuids(uuids, QBluetoothDeviceInfo::DataIncomplete);
+ deviceInfo.setServiceUuids(uuids);
if (!btClass) {
deviceInfo.setCoreConfigurations(QBluetoothDeviceInfo::LowEnergyCoreConfiguration);
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
index 4657da82..3cf3b08d 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
@@ -423,8 +423,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::deviceFound(IOBluetoothDeviceInquiry
deviceInfo.setCoreConfigurations(QBluetoothDeviceInfo::BaseRateCoreConfiguration);
deviceInfo.setRssi(device.RSSI);
- const QList<QBluetoothUuid> uuids(OSXBluetooth::extract_services_uuids(device));
- deviceInfo.setServiceUuids(uuids, QBluetoothDeviceInfo::DataIncomplete);
+ const QVector<QBluetoothUuid> uuids(OSXBluetooth::extract_services_uuids(device));
+ deviceInfo.setServiceUuids(uuids);
deviceFound(deviceInfo);
}
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index c64063c6..a353f5e3 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -466,7 +466,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onPairedClassicBluetoothDeviceFoun
uint serviceCount;
hr = deviceServices->get_Size(&serviceCount);
Q_ASSERT_SUCCEEDED(hr);
- QList<QBluetoothUuid> uuids;
+ QVector<QBluetoothUuid> uuids;
for (uint i = 0; i < serviceCount; ++i) {
ComPtr<Rfcomm::IRfcommDeviceService> service;
hr = deviceServices->GetAt(i, &service);
@@ -485,7 +485,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onPairedClassicBluetoothDeviceFoun
QBluetoothDeviceInfo info(QBluetoothAddress(address), btName, classOfDeviceInt);
info.setCoreConfigurations(QBluetoothDeviceInfo::BaseRateCoreConfiguration);
- info.setServiceUuids(uuids, QBluetoothDeviceInfo::DataIncomplete);
+ info.setServiceUuids(uuids);
info.setCached(true);
QMetaObject::invokeMethod(this, "deviceFound", Qt::AutoConnection,
@@ -605,7 +605,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
uint serviceCount;
hr = deviceServices->get_Size(&serviceCount);
Q_ASSERT_SUCCEEDED(hr);
- QList<QBluetoothUuid> uuids;
+ QVector<QBluetoothUuid> uuids;
for (uint i = 0; i < serviceCount; ++i) {
ComPtr<GenericAttributeProfile::IGattDeviceService> service;
hr = deviceServices->GetAt(i, &service);
@@ -622,7 +622,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
QBluetoothDeviceInfo info(QBluetoothAddress(address), btName, 0);
info.setCoreConfigurations(QBluetoothDeviceInfo::LowEnergyCoreConfiguration);
- info.setServiceUuids(uuids, QBluetoothDeviceInfo::DataIncomplete);
+ info.setServiceUuids(uuids);
info.setCached(true);
QMetaObject::invokeMethod(this, "deviceFound", Qt::AutoConnection,
@@ -782,7 +782,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::registerDevice(const QBluetoothDevic
uuids.append(info.serviceUuids());
const QSet<QBluetoothUuid> uuidSet = uuids.toSet();
if (iter->serviceUuids().count() != uuidSet.count())
- iter->setServiceUuids(uuidSet.toList(), QBluetoothDeviceInfo::DataIncomplete);
+ iter->setServiceUuids(uuidSet.toList().toVector());
if (iter->coreConfigurations() != info.coreConfigurations())
iter->setCoreConfigurations(QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration);
return;
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index bde8655e..5e26dea5 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -536,6 +536,8 @@ quint8 QBluetoothDeviceInfo::minorDeviceClass() const
}
/*!
+ \deprecated
+
Sets the list of service UUIDs to \a uuids and the completeness of the data to \a completeness.
*/
void QBluetoothDeviceInfo::setServiceUuids(const QList<QBluetoothUuid> &uuids,
@@ -543,11 +545,38 @@ void QBluetoothDeviceInfo::setServiceUuids(const QList<QBluetoothUuid> &uuids,
{
Q_D(QBluetoothDeviceInfo);
- d->serviceUuids = uuids;
+ d->serviceUuids = uuids.toVector();
d->serviceUuidsCompleteness = completeness;
}
/*!
+ Sets the list of service UUIDs to \a uuids.
+ \since 5.13
+ */
+void QBluetoothDeviceInfo::setServiceUuids(const QVector<QBluetoothUuid> &uuids)
+{
+ Q_D(QBluetoothDeviceInfo);
+ d->serviceUuids = uuids;
+}
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+/*!
+ Returns the list of service UUIDS supported by the device. Most commonly this
+ list of uuids represents custom uuids or a uuid value specified by
+ \l QBluetoothUuid::ServiceClassUuid.
+
+ \sa serviceUuids()
+ \since 6.0
+*/
+QVector<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids() const
+{
+ Q_D(const QBluetoothDeviceInfo);
+ return d->serviceUuids;
+}
+
+#else
+
+/*!
Returns the list of service UUIDS supported by the device. If \a completeness is not 0 it will
be set to DataComplete and the complete list of UUIDs supported by the device is returned.
DataIncomplete if additional service UUIDs are supported by the device and DataUnavailable if
@@ -562,10 +591,13 @@ QList<QBluetoothUuid> QBluetoothDeviceInfo::serviceUuids(DataCompleteness *compl
if (completeness)
*completeness = d->serviceUuidsCompleteness;
- return d->serviceUuids;
+ return d->serviceUuids.toList();
}
+#endif //QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
/*!
+ \deprecated
+
Returns the completeness of the service UUID list. If DataComplete is returned,
serviceUuids() returns the complete list of service UUIDs supported by the device, otherwise
only the partial or empty list of service UUIDs. To get a list
diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h
index d59eb27d..72072f58 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.h
+++ b/src/bluetooth/qbluetoothdeviceinfo.h
@@ -191,12 +191,14 @@ public:
};
Q_DECLARE_FLAGS(ServiceClasses, ServiceClass)
- //TODO Qt6 Remove DataCompleteness -> it serves no purpose
+#if QT_DEPRECATED_SINCE(5, 13)
+ // adding QT_DEPRECATED causes compile failure with gcc 7
enum DataCompleteness {
DataComplete,
DataIncomplete,
DataUnavailable
};
+#endif
enum class Field {
None = 0x0000,
@@ -241,9 +243,19 @@ public:
qint16 rssi() const;
void setRssi(qint16 signal);
- void setServiceUuids(const QList<QBluetoothUuid> &uuids, DataCompleteness completeness);
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED void setServiceUuids(const QList<QBluetoothUuid> &uuids, DataCompleteness completeness);
+ QT_DEPRECATED DataCompleteness serviceUuidsCompleteness() const;
+#endif
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+#ifndef Q_QDOC //suppress qdoc warnings
+ QVector<QBluetoothUuid> serviceUuids() const;
+#endif // Q_QDOC
+#else
QList<QBluetoothUuid> serviceUuids(DataCompleteness *completeness = nullptr) const;
- DataCompleteness serviceUuidsCompleteness() const;
+#endif
+ void setServiceUuids(const QVector<QBluetoothUuid> &uuids);
QVector<quint16> manufacturerIds() const;
QByteArray manufacturerData(quint16 manufacturerId) const;
diff --git a/src/bluetooth/qbluetoothdeviceinfo_p.h b/src/bluetooth/qbluetoothdeviceinfo_p.h
index 15c9e21c..3c19b10f 100644
--- a/src/bluetooth/qbluetoothdeviceinfo_p.h
+++ b/src/bluetooth/qbluetoothdeviceinfo_p.h
@@ -78,7 +78,7 @@ public:
quint8 minorDeviceClass;
QBluetoothDeviceInfo::DataCompleteness serviceUuidsCompleteness;
- QList<QBluetoothUuid> serviceUuids;
+ QVector<QBluetoothUuid> serviceUuids;
QHash<quint16, QByteArray> manufacturerData;
QBluetoothDeviceInfo::CoreConfigurations deviceCoreConfiguration;
diff --git a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
index fd2ed46f..6636f0cd 100644
--- a/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
+++ b/tests/auto/qbluetoothdeviceinfo/tst_qbluetoothdeviceinfo.cpp
@@ -452,6 +452,11 @@ void tst_QBluetoothDeviceInfo::tst_serviceUuids()
servicesList.append(QBluetoothUuid::Rfcomm);
QVERIFY(servicesList.count() > 0);
+ deviceInfo.setServiceUuids(servicesList.toVector());
+ QVERIFY(deviceInfo.serviceUuids().count() > 0);
+ deviceInfo.setServiceUuids(QVector<QBluetoothUuid>());
+ QCOMPARE(deviceInfo.serviceUuids().count(), 0);
+
deviceInfo.setServiceUuids(servicesList, QBluetoothDeviceInfo::DataComplete);
QVERIFY(deviceInfo.serviceUuids().count() > 0);
QVERIFY(deviceInfo != copyInfo);