diff options
Diffstat (limited to 'src/bluetooth')
-rw-r--r-- | src/bluetooth/bluez/properties_p.h | 3 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp | 29 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_p.h | 1 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothserver_bluez.cpp | 2 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluezdbus.cpp | 17 |
5 files changed, 33 insertions, 19 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 263ab9ca..0bff7138 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"))) { |