diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2013-07-23 16:59:15 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-29 12:51:32 +0200 |
commit | a7f6e8cf3ed1fddce5fd8a8d0e3d9125e5d8431c (patch) | |
tree | 2741be5dcc07b00013dd34a74cb3a4b1aa8e467d /src/bluetooth/qbluetoothlocaldevice_bluez.cpp | |
parent | b0cca9bdd0acf0865a1a5fcb0c51944d902638b1 (diff) |
Don't hardcode the test device's Bt address in the unit test.
Ensure that all signals emitted during a pairing request
are queued via the event loop. The exact reason for doing
this is unknown however such a change was done on purpose
in QtMobility. We keep the behavior to be on the safe side.
Change-Id: I666c5b2c25a0c80df634f7b6643bd08126812b65
Reviewed-by: Michael Zanetti <michael.zanetti@canonical.com>
Reviewed-by: Alex <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/qbluetoothlocaldevice_bluez.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp index 6a520158..f7beb672 100644 --- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp @@ -197,13 +197,15 @@ static inline OrgBluezDeviceInterface *getDevice(const QBluetoothAddress &addres void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pairing pairing) { if (address.isNull()) { - emit error(PairingError); + QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, + Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; } const Pairing current_pairing = pairingStatus(address); if (current_pairing == pairing) { - emit pairingFinished(address, pairing); + QMetaObject::invokeMethod(this, "pairingFinished", Qt::QueuedConnection, Q_ARG(QBluetoothAddress, address), + Q_ARG(QBluetoothLocalDevice::Pairing, pairing)); return; } @@ -216,7 +218,8 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai d_ptr->agent = new OrgBluezAgentAdaptor(d_ptr); bool res = QDBusConnection::systemBus().registerObject(d_ptr->agent_path, d_ptr); if(!res){ - emit error(PairingError); + QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, + Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); qDebug() << "Failed to register agent"; return; } @@ -225,14 +228,16 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai if(current_pairing == Paired && pairing == AuthorizedPaired){ OrgBluezDeviceInterface *device = getDevice(address, d_ptr); if (!device) { - emit error(PairingError); + QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, + Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; } QDBusPendingReply<> deviceReply = device->SetProperty(QLatin1String("Trusted"), QDBusVariant(true)); deviceReply.waitForFinished(); if(deviceReply.isError()){ qDebug() << Q_FUNC_INFO << "reply failed" << deviceReply.error(); - emit error(PairingError); + QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, + Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; } delete device; @@ -242,14 +247,16 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai else if(current_pairing == AuthorizedPaired && pairing == Paired){ OrgBluezDeviceInterface *device = getDevice(address, d_ptr); if (!device) { - emit error(PairingError); + QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, + Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; } QDBusPendingReply<> deviceReply = device->SetProperty(QLatin1String("Trusted"), QDBusVariant(false)); deviceReply.waitForFinished(); if(deviceReply.isError()){ qDebug() << Q_FUNC_INFO << "reply failed" << deviceReply.error(); - emit error(PairingError); + QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, + Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; } delete device; @@ -274,14 +281,16 @@ void QBluetoothLocalDevice::requestPairing(const QBluetoothAddress &address, Pai reply.waitForFinished(); if(reply.isError()) { qDebug() << Q_FUNC_INFO << "failed to find device" << reply.error(); - emit error(QBluetoothLocalDevice::PairingError); + QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, + Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); return; } QDBusPendingReply<> removeReply = this->d_ptr->adapter->RemoveDevice(reply.value()); removeReply.waitForFinished(); if(removeReply.isError()){ qDebug() << Q_FUNC_INFO << "failed to remove device" << removeReply.error(); - emit error(QBluetoothLocalDevice::PairingError); + QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, + Q_ARG(QBluetoothLocalDevice::Error, QBluetoothLocalDevice::PairingError)); } else { QMetaObject::invokeMethod(this, "pairingFinished", Qt::QueuedConnection, Q_ARG(QBluetoothAddress, address), Q_ARG(QBluetoothLocalDevice::Pairing, QBluetoothLocalDevice::Unpaired)); |