summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-05-09 15:26:01 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-23 08:46:13 +0200
commit82a11f8b742bb2e6e7b326296405618fb16933df (patch)
tree8e45b4669a6b8f96439141dc9ac6d6f49d54f0ea /src/bluetooth/qbluetoothlocaldevice_bluez.cpp
parente6097f5be7450fd043f5b5c13d8c953e2e79fa39 (diff)
Utilize Qt global discovery mode session in QBluetootLocalDevice.
QtBluezDiscoveryManager manges the global discovery session for all Qt classes. This was introduced when implementing the device discovery. QBluetoothLocalDevice was not using this mechanism yet which could lead to discovery sessions being killed while still required. Change-Id: I4229cb2aa34df35cf4d0650c828c8cfa11040d4a Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/qbluetoothlocaldevice_bluez.cpp')
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
index 7b4f6ad6..665f9096 100644
--- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
@@ -433,8 +433,8 @@ void QBluetoothLocalDevicePrivate::requestPairingBluez5(const QBluetoothAddress
//are we already discovering something? -> abort those attempts
if (pairingDiscoveryTimer && pairingDiscoveryTimer->isActive()) {
pairingDiscoveryTimer->stop();
- if (!discoveryWasAlreadyActive)
- adapterBluez5->StopDiscovery();
+ QtBluezDiscoveryManager::instance()->unregisterDiscoveryInterest(
+ adapterBluez5->path());
}
if (pairingTarget) {
@@ -474,13 +474,7 @@ void QBluetoothLocalDevicePrivate::requestPairingBluez5(const QBluetoothAddress
}
//no device matching -> turn on discovery
-
- //remember whether we were discovering already
- //if it was on don't modify it
- discoveryWasAlreadyActive = adapterBluez5->discovering();
-
- if (!discoveryWasAlreadyActive)
- adapterBluez5->StartDiscovery();
+ QtBluezDiscoveryManager::instance()->registerDiscoveryInterest(adapterBluez5->path());
address = targetAddress;
pairing = targetPairing;
@@ -513,8 +507,8 @@ void QBluetoothLocalDevicePrivate::processPairingBluez5(const QString &objectPat
if (pairingDiscoveryTimer && pairingDiscoveryTimer->isActive()) {
pairingDiscoveryTimer->stop();
- if (!discoveryWasAlreadyActive)
- adapterBluez5->StopDiscovery();
+ QtBluezDiscoveryManager::instance()->unregisterDiscoveryInterest(
+ adapterBluez5->path());
}
pairingTarget = new OrgBluezDevice1Interface(QStringLiteral("org.bluez"), objectPath,
@@ -573,8 +567,8 @@ void QBluetoothLocalDevicePrivate::pairingDiscoveryTimedOut()
{
qCWarning(QT_BT_BLUEZ) << "Discovery for pairing purposes failed. Cannot find parable device.";
- if (!discoveryWasAlreadyActive)
- adapterBluez5->StopDiscovery();
+ QtBluezDiscoveryManager::instance()->unregisterDiscoveryInterest(
+ adapterBluez5->path());
emit q_ptr->error(QBluetoothLocalDevice::PairingError);
}
@@ -645,7 +639,6 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice
localAddress(address),
pairingTarget(0),
pairingDiscoveryTimer(0),
- discoveryWasAlreadyActive(true),
pendingHostModeChange(-1),
msgConnection(0),
q_ptr(q)
@@ -929,14 +922,8 @@ void QBluetoothLocalDevicePrivate::InterfacesAdded(const QDBusObjectPath &object
//device discovery for pairing found new remote device
OrgBluezDevice1Interface device(QStringLiteral("org.bluez"),
object_path.path(), QDBusConnection::systemBus());
- if (!address.isNull() && address == QBluetoothAddress(device.address())) {
- pairingDiscoveryTimer->stop();
- if (!discoveryWasAlreadyActive)
- adapterBluez5->StopDiscovery();
-
+ if (!address.isNull() && address == QBluetoothAddress(device.address()))
processPairingBluez5(object_path.path(), pairing);
-
- }
}
}