diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2021-08-23 12:31:57 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-08-27 15:29:10 +0000 |
commit | 81873ae564a78faa5c5fed099dbd43b82be48821 (patch) | |
tree | 3e277e1c6af1a88f095151dbda35a9127e8432e0 | |
parent | 6ff02cd468a67d8f781c7ddffdc5a2fa6396a7f3 (diff) |
Remove BlueZ4 implementation from BluetoothSocket
Task-number: QTBUG-75342
Change-Id: Iabaa559747de369571be64be87da8b0200470ead
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit fbaf177a6f71fbc79ab2670f4a27b9669285829d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/bluetooth/qbluetoothsocket_bluez.cpp | 71 |
1 files changed, 19 insertions, 52 deletions
diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index bcaf56f0..28f1c2a5 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -494,64 +494,31 @@ QString QBluetoothSocketPrivateBluez::peerName() const const QString peerAddress = QBluetoothAddress(bdaddr).toString(); const QString localAdapter = localAddress().toString(); - if (isBluez5()) { - OrgFreedesktopDBusObjectManagerInterface manager(QStringLiteral("org.bluez"), - QStringLiteral("/"), - QDBusConnection::systemBus()); - QDBusPendingReply<ManagedObjectList> reply = manager.GetManagedObjects(); - reply.waitForFinished(); - if (reply.isError()) - return QString(); - - ManagedObjectList managedObjectList = reply.value(); - for (ManagedObjectList::const_iterator it = managedObjectList.constBegin(); it != managedObjectList.constEnd(); ++it) { - const InterfaceList &ifaceList = it.value(); - - for (InterfaceList::const_iterator jt = ifaceList.constBegin(); jt != ifaceList.constEnd(); ++jt) { - const QString &iface = jt.key(); - const QVariantMap &ifaceValues = jt.value(); - - if (iface == QStringLiteral("org.bluez.Device1")) { - if (ifaceValues.value(QStringLiteral("Address")).toString() == peerAddress) - return ifaceValues.value(QStringLiteral("Alias")).toString(); - } - } - } + initializeBluez5(); + OrgFreedesktopDBusObjectManagerInterface manager( + QStringLiteral("org.bluez"), QStringLiteral("/"), QDBusConnection::systemBus()); + QDBusPendingReply<ManagedObjectList> reply = manager.GetManagedObjects(); + reply.waitForFinished(); + if (reply.isError()) return QString(); - } else { - OrgBluezManagerInterface manager(QStringLiteral("org.bluez"), QStringLiteral("/"), - QDBusConnection::systemBus()); - QDBusPendingReply<QDBusObjectPath> reply = manager.FindAdapter(localAdapter); - reply.waitForFinished(); - if (reply.isError()) - return QString(); - - OrgBluezAdapterInterface adapter(QStringLiteral("org.bluez"), reply.value().path(), - QDBusConnection::systemBus()); + ManagedObjectList managedObjectList = reply.value(); + for (ManagedObjectList::const_iterator it = managedObjectList.constBegin(); + it != managedObjectList.constEnd(); ++it) { + const InterfaceList &ifaceList = it.value(); - QDBusPendingReply<QDBusObjectPath> deviceObjectPath = adapter.FindDevice(peerAddress); - deviceObjectPath.waitForFinished(); - if (deviceObjectPath.isError()) { - if (deviceObjectPath.error().name() != QStringLiteral("org.bluez.Error.DoesNotExist")) - return QString(); + for (InterfaceList::const_iterator jt = ifaceList.constBegin(); jt != ifaceList.constEnd(); + ++jt) { + const QString &iface = jt.key(); + const QVariantMap &ifaceValues = jt.value(); - deviceObjectPath = adapter.CreateDevice(peerAddress); - deviceObjectPath.waitForFinished(); - if (deviceObjectPath.isError()) - return QString(); + if (iface == QStringLiteral("org.bluez.Device1")) { + if (ifaceValues.value(QStringLiteral("Address")).toString() == peerAddress) + return ifaceValues.value(QStringLiteral("Alias")).toString(); + } } - - OrgBluezDeviceInterface device(QStringLiteral("org.bluez"), deviceObjectPath.value().path(), - QDBusConnection::systemBus()); - - QDBusPendingReply<QVariantMap> properties = device.GetProperties(); - properties.waitForFinished(); - if (properties.isError()) - return QString(); - - return properties.value().value(QStringLiteral("Alias")).toString(); } + return QString(); } QBluetoothAddress QBluetoothSocketPrivateBluez::peerAddress() const |