diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-05-09 15:26:01 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-23 08:46:13 +0200 |
commit | 82a11f8b742bb2e6e7b326296405618fb16933df (patch) | |
tree | 8e45b4669a6b8f96439141dc9ac6d6f49d54f0ea /src | |
parent | e6097f5be7450fd043f5b5c13d8c953e2e79fa39 (diff) | |
download | qtconnectivity-82a11f8b742bb2e6e7b326296405618fb16933df.tar.gz |
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')
-rw-r--r-- | src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 29 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothlocaldevice_p.h | 1 |
2 files changed, 8 insertions, 22 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); - - } } } diff --git a/src/bluetooth/qbluetoothlocaldevice_p.h b/src/bluetooth/qbluetoothlocaldevice_p.h index 33f813e1..8edac58c 100644 --- a/src/bluetooth/qbluetoothlocaldevice_p.h +++ b/src/bluetooth/qbluetoothlocaldevice_p.h @@ -146,7 +146,6 @@ public: QBluetoothLocalDevice::Pairing pairing; OrgBluezDevice1Interface *pairingTarget; QTimer *pairingDiscoveryTimer; - bool discoveryWasAlreadyActive; QBluetoothLocalDevice::HostMode currentMode; int pendingHostModeChange; |