summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bluetooth/bluez/properties_p.h3
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp29
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_p.h1
-rw-r--r--src/bluetooth/qbluetoothserver_bluez.cpp2
-rw-r--r--src/bluetooth/qlowenergycontroller_bluezdbus.cpp17
-rw-r--r--tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp6
6 files changed, 36 insertions, 22 deletions
diff --git a/src/bluetooth/bluez/properties_p.h b/src/bluetooth/bluez/properties_p.h
index 16a43e80..d8a7b6cb 100644
--- a/src/bluetooth/bluez/properties_p.h
+++ b/src/bluetooth/bluez/properties_p.h
@@ -58,7 +58,8 @@ public Q_SLOTS: // METHODS
}
Q_SIGNALS: // SIGNALS
- void PropertiesChanged(const QString &interface, const QVariantMap &changed_properties, const QStringList &invalidated_properties);
+ void PropertiesChanged(const QString &interface, const QVariantMap &changed_properties, const QStringList &invalidated_properties,
+ const QDBusMessage &msg);
};
namespace org {
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
index 7dce9dae..243be3b2 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
@@ -292,6 +292,17 @@ void QBluetoothDeviceDiscoveryAgentPrivate::startBluez5(QBluetoothDeviceDiscover
q, [this](const QString &path){
this->_q_discoveryInterrupted(path);
});
+ OrgFreedesktopDBusPropertiesInterface *prop = new OrgFreedesktopDBusPropertiesInterface(
+ QStringLiteral("org.bluez"), QStringLiteral(""), QDBusConnection::systemBus());
+ QObject::connect(prop, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged,
+ q, [this](const QString &interface, const QVariantMap &changedProperties,
+ const QStringList &invalidatedProperties,
+ const QDBusMessage &signal) {
+ this->_q_PropertiesChanged(interface, signal.path(), changedProperties, invalidatedProperties);
+ });
+
+ // remember what we have to cleanup
+ propertyMonitors.append(prop);
// collect initial set of information
QDBusPendingReply<ManagedObjectList> reply = managerBluez5->GetManagedObjects();
@@ -476,17 +487,6 @@ void QBluetoothDeviceDiscoveryAgentPrivate::deviceFoundBluez5(const QString &dev
<< "RSSI" << deviceInfo.rssi()
<< "Num ManufacturerData" << deviceInfo.manufacturerData().size();
- OrgFreedesktopDBusPropertiesInterface *prop = new OrgFreedesktopDBusPropertiesInterface(
- QStringLiteral("org.bluez"), devicePath, QDBusConnection::systemBus(), q);
- QObject::connect(prop, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged,
- q, [this](const QString &interface, const QVariantMap &changedProperties,
- const QStringList &invalidatedProperties) {
- this->_q_PropertiesChanged(interface, changedProperties, invalidatedProperties);
- });
-
- // remember what we have to cleanup
- propertyMonitors.append(prop);
-
// Cache the properties so we do not have to access dbus every time to get a value
devicesProperties[devicePath] = properties;
@@ -641,6 +641,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_discoveryInterrupted(const QStrin
}
void QBluetoothDeviceDiscoveryAgentPrivate::_q_PropertiesChanged(const QString &interface,
+ const QString &path,
const QVariantMap &changed_properties,
const QStringList &invalidated_properties)
{
@@ -648,12 +649,6 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_PropertiesChanged(const QString &
if (interface != QStringLiteral("org.bluez.Device1"))
return;
- OrgFreedesktopDBusPropertiesInterface *props =
- qobject_cast<OrgFreedesktopDBusPropertiesInterface *>(q->sender());
- if (!props)
- return;
-
- const QString path = props->path();
if (!devicesProperties.contains(path))
return;
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
index 27220a09..c9a35c3d 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_p.h
@@ -142,6 +142,7 @@ public:
void _q_discoveryFinished();
void _q_discoveryInterrupted(const QString &path);
void _q_PropertiesChanged(const QString &interface,
+ const QString &path,
const QVariantMap &changed_properties,
const QStringList &invalidated_properties);
void _q_extendedDeviceDiscoveryTimeout();
diff --git a/src/bluetooth/qbluetoothserver_bluez.cpp b/src/bluetooth/qbluetoothserver_bluez.cpp
index a98f5398..0daae61f 100644
--- a/src/bluetooth/qbluetoothserver_bluez.cpp
+++ b/src/bluetooth/qbluetoothserver_bluez.cpp
@@ -69,7 +69,7 @@ QBluetoothSocket *QBluetoothServerPrivate::createSocketForServer(
QBluetoothServerPrivate::QBluetoothServerPrivate(QBluetoothServiceInfo::Protocol sType,
QBluetoothServer *parent)
: maxPendingConnections(1), securityFlags(QBluetooth::Authorization), serverType(sType),
- m_lastError(QBluetoothServer::NoError), q_ptr(parent)
+ q_ptr(parent), m_lastError(QBluetoothServer::NoError)
{
if (sType == QBluetoothServiceInfo::RfcommProtocol)
socket = createSocketForServer(QBluetoothServiceInfo::RfcommProtocol);
diff --git a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
index 2a0fafdf..5dde8774 100644
--- a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
@@ -112,6 +112,23 @@ void QLowEnergyControllerPrivateBluezDBus::devicePropertiesChanged(
}
}
}
+
+ if (changedProperties.contains(QStringLiteral("UUIDs"))) {
+ const QStringList newUuidStringList = changedProperties.value(QStringLiteral("UUIDs")).toStringList();
+ QVector<QBluetoothUuid> newUuidList;
+ for (const QString &uuidString : newUuidStringList)
+ newUuidList.append(QBluetoothUuid(uuidString));
+
+ for (const QBluetoothUuid &uuid : serviceList.keys()) {
+ if (!newUuidList.contains(uuid)) {
+ qCDebug(QT_BT_BLUEZ) << __func__ << "Service" << uuid << "has been removed";
+ QSharedPointer<QLowEnergyServicePrivate> service = serviceList.take(uuid);
+ service->setController(nullptr);
+ dbusServices.remove(uuid);
+ }
+ }
+ }
+
} else if (interface == QStringLiteral("org.bluez.Battery1")) {
qCDebug(QT_BT_BLUEZ) << "######" << interface << changedProperties;
if (changedProperties.contains(QStringLiteral("Percentage"))) {
diff --git a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
index 5ebb0b1d..b3caab44 100644
--- a/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
+++ b/tests/auto/qlowenergydescriptor/tst_qlowenergydescriptor.cpp
@@ -63,7 +63,7 @@ private:
};
tst_QLowEnergyDescriptor::tst_QLowEnergyDescriptor() :
- globalControl(0), globalService(0)
+ globalControl(nullptr), globalService(nullptr)
{
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
}
@@ -104,13 +104,13 @@ void tst_QLowEnergyDescriptor::initTestCase()
QTRY_VERIFY_WITH_TIMEOUT(spy.count() > 0, 50000);
// find first service with descriptor
- QLowEnergyController *controller = 0;
+ QLowEnergyController *controller = nullptr;
for (const QBluetoothDeviceInfo& remoteDeviceInfo : qAsConst(remoteLeDeviceInfos)) {
controller = QLowEnergyController::createCentral(remoteDeviceInfo, this);
qDebug() << "Connecting to" << remoteDeviceInfo.address();
controller->connectToDevice();
QTRY_IMPL(controller->state() != QLowEnergyController::ConnectingState,
- 20000);
+ 20000)
if (controller->state() != QLowEnergyController::ConnectedState) {
// any error and we skip
delete controller;