summaryrefslogtreecommitdiff
path: root/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-05-12 12:33:41 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-23 08:46:17 +0200
commit66cc81ed8df87103409140547b4e017647e80d61 (patch)
treef0dc0cae6419ad9b5af7721936a41719d202a05d /src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
parent82a11f8b742bb2e6e7b326296405618fb16933df (diff)
downloadqtconnectivity-66cc81ed8df87103409140547b4e017647e80d61.tar.gz
Code cleanup: Avoid repeated service info duplication check
Change-Id: I00701e9103a6acfdfc2697949280f8a7de8bcdfe Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Diffstat (limited to 'src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp')
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp43
1 files changed, 11 insertions, 32 deletions
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
index 89d93200..2f7dc726 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
@@ -355,13 +355,14 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
if (!serviceInfo.isValid())
continue;
- discoveredServices.append(serviceInfo);
- qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
- << serviceInfo.serviceName() << serviceInfo.serviceUuid()
- << ">>>" << serviceInfo.serviceClassUuids();
+ if (!isDuplicatedService(serviceInfo)) {
+ discoveredServices.append(serviceInfo);
+ qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+ << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+ << ">>>" << serviceInfo.serviceClassUuids();
- // TODO check for duplicates (wait until stable has merged due to related change)
- emit q->serviceDiscovered(serviceInfo);
+ emit q->serviceDiscovered(serviceInfo);
+ }
// could stop discovery, check for state
if (discoveryState() == Inactive)
@@ -492,19 +493,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC
Q_Q(QBluetoothServiceDiscoveryAgent);
- //don't include the service if we already discovered it before
- bool alreadyDiscovered = false;
- for (int j = 0; j < discoveredServices.count(); j++) {
- const QBluetoothServiceInfo &info = discoveredServices.at(j);
- if (info.device() == serviceInfo.device()
- && info.serviceClassUuids() == serviceInfo.serviceClassUuids()
- && info.serviceUuid() == serviceInfo.serviceUuid()) {
- alreadyDiscovered = true;
- break;
- }
- }
-
- if (!alreadyDiscovered) {
+ if (!isDuplicatedService(serviceInfo)) {
discoveredServices.append(serviceInfo);
qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
<< serviceInfo.serviceName();
@@ -624,20 +613,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::performMinimalServiceDiscovery(cons
}
//don't include the service if we already discovered it before
- bool alreadyDiscovered = false;
- for (int j = 0; j < discoveredServices.count(); j++) {
- const QBluetoothServiceInfo &info = discoveredServices.at(j);
- if (info.device() == serviceInfo.device()
- && info.serviceClassUuids() == serviceInfo.serviceClassUuids()
- && info.serviceUuid() == serviceInfo.serviceUuid()) {
- alreadyDiscovered = true;
- break;
- }
- }
-
- if (!alreadyDiscovered) {
+ if (!isDuplicatedService(serviceInfo)) {
discoveredServices << serviceInfo;
- //qCDebug(QT_BT_ANDROID) << serviceInfo;
+ qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+ << serviceInfo.serviceName();
emit q->serviceDiscovered(serviceInfo);
}
}