summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothservicediscoveryagent.cpp
diff options
context:
space:
mode:
authorNedim Hadzic <nhadzic@blackberry.com>2013-08-29 12:46:56 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-05 10:23:47 +0200
commitecb93e0f63f317039c0bba2c6c754c67b80a9d5e (patch)
treeb98cc16f8d5416e4dabc9dce101ab068136cecf5 /src/bluetooth/qbluetoothservicediscoveryagent.cpp
parentfcb5d4d992b660305c764d54ee70d977c0833602 (diff)
Make Bluetooth adapter choosable for device and service search
In case there are more Bluetooth adapter, device and service search might give different results. Addition to Change-Id: Ideddb39460985c18547baec986b15e43946c85de - added option for setting the device adapter for service search. QBluetoothLocalDevice was used in both classes (device and service search) for passing an argument for setting adapter. The reason for this to keep the same approach, because in QBluetoothServiceDiscoveryAgent class there is already a constructor with QBluetoothAddress argument. Auto tests and examples updated. Change-Id: Ib5d7ff23e4846d9d42dae68d8d424031748811e5 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/qbluetoothservicediscoveryagent.cpp')
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index 136ec8e5..89149941 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -119,18 +119,14 @@ QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(QObject *parent
}
/*!
- Constructs a new QBluetoothServiceDiscoveryAgent for \a remoteAddress and with \a parent.
+ Constructs a new QBluetoothServiceDiscoveryAgent for \a deviceAdapter and with \a parent.
- If \a remoteAddress is null, services will be discovred on all contactable Bluetooth
- devices.
+ If \a deviceAdapter is null, the default adapter will be used.
*/
-QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(const QBluetoothAddress &remoteAddress, QObject *parent)
-: QObject(parent), d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(remoteAddress))
+QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(const QBluetoothAddress &deviceAdapter, QObject *parent)
+: QObject(parent), d_ptr(new QBluetoothServiceDiscoveryAgentPrivate(deviceAdapter))
{
d_ptr->q_ptr = this;
- if (!remoteAddress.isNull()) {
- d_ptr->singleDevice = true;
- }
}
/*!
@@ -196,6 +192,36 @@ QList<QBluetoothUuid> QBluetoothServiceDiscoveryAgent::uuidFilter() const
}
/*!
+ Sets remote device address to \a address. If \a address is null, services will be discovered
+ on all contactable Bluetooth devices. A new remote address can only be set while there is
+ no service discovery in progress; otherwise this function returns false.
+
+*/
+bool QBluetoothServiceDiscoveryAgent::setRemoteAddress(const QBluetoothAddress &address)
+{
+ if (isActive())
+ return false;
+ if (!address.isNull())
+ d_ptr->singleDevice = true;
+ d_ptr->deviceAddress = address;
+
+ return true;
+}
+
+/*!
+ Returns the remote device address. If setRemoteAddress is not called, the function
+ will return default QBluetoothAddress.
+
+*/
+QBluetoothAddress QBluetoothServiceDiscoveryAgent::remoteAddress() const
+{
+ if (d_ptr->singleDevice == true)
+ return d_ptr->deviceAddress;
+ else
+ return QBluetoothAddress();
+}
+
+/*!
Starts service discovery. \a mode specifies the type of service discovery to perform.
On Blackberry devices device discovery may lead to pairing requests.