From 85de7d64e85aa058f1777bc9d1a778790b1d50a6 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 23 Sep 2013 13:52:35 +0200 Subject: Fix peer to peer communication using two local adapters. The code assumed to use the default adapter in a variety of places which caused wrong SDP registrations, device searches and peer names. The btchat examples was extended to cope with two local adapters. If there are more than two local adapters they will be ignored. Change-Id: I27d8bce65d943773e4e6cbd86982446fa79664a4 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothsocket_bluez.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/bluetooth/qbluetoothsocket_bluez.cpp') diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index bc7dc972..c6f332e3 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -362,12 +362,13 @@ QString QBluetoothSocketPrivate::peerName() const return QString(); } - const QString address = QBluetoothAddress(bdaddr).toString(); + const QString peerAddress = QBluetoothAddress(bdaddr).toString(); + const QString localAdapter = localAddress().toString(); OrgBluezManagerInterface manager(QLatin1String("org.bluez"), QLatin1String("/"), QDBusConnection::systemBus()); - QDBusPendingReply reply = manager.DefaultAdapter(); + QDBusPendingReply reply = manager.FindAdapter(localAdapter); reply.waitForFinished(); if (reply.isError()) return QString(); @@ -375,13 +376,13 @@ QString QBluetoothSocketPrivate::peerName() const OrgBluezAdapterInterface adapter(QLatin1String("org.bluez"), reply.value().path(), QDBusConnection::systemBus()); - QDBusPendingReply deviceObjectPath = adapter.CreateDevice(address); + QDBusPendingReply deviceObjectPath = adapter.CreateDevice(peerAddress); deviceObjectPath.waitForFinished(); if (deviceObjectPath.isError()) { if (deviceObjectPath.error().name() != QLatin1String("org.bluez.Error.AlreadyExists")) return QString(); - deviceObjectPath = adapter.FindDevice(address); + deviceObjectPath = adapter.FindDevice(peerAddress); deviceObjectPath.waitForFinished(); if (deviceObjectPath.isError()) return QString(); -- cgit v1.2.3