summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothserver_bluez.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-02-28 15:15:03 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-01 20:09:28 +0100
commit17d38319d205fd186ffbb638e53e43fde011c753 (patch)
tree7aac0462c81781547e797060e002c72f43f72537 /src/bluetooth/qbluetoothserver_bluez.cpp
parent6c90b603cff92834ac7f58610fc6982ec801f2fd (diff)
Fix qrfcomm unit test
The patch also aligns the error behavior of QBluetoothServer::listen() across the various platforms. Task-number: QTBUG-22017 Change-Id: Ic81808c94d060ca07bd125afa842452e53efaec7 Reviewed-by: Nedim Hadzic <nedimhadzija@gmail.com> Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src/bluetooth/qbluetoothserver_bluez.cpp')
-rw-r--r--src/bluetooth/qbluetoothserver_bluez.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothserver_bluez.cpp b/src/bluetooth/qbluetoothserver_bluez.cpp
index b78fb526..1ee055de 100644
--- a/src/bluetooth/qbluetoothserver_bluez.cpp
+++ b/src/bluetooth/qbluetoothserver_bluez.cpp
@@ -42,6 +42,7 @@
#include "qbluetoothserver.h"
#include "qbluetoothserver_p.h"
#include "qbluetoothsocket.h"
+#include "qbluetoothlocaldevice.h"
#include <QtCore/QLoggingCategory>
#include <QtCore/QSocketNotifier>
@@ -110,6 +111,23 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
return false; //already listening, nothing to do
}
+ QBluetoothLocalDevice device(address);
+ if (!device.isValid()) {
+ qCWarning(QT_BT_BLUEZ) << "Device does not support Bluetooth or"
+ << address.toString() << "is not a valid local adapter";
+ d->m_lastError = QBluetoothServer::UnknownError;
+ emit error(d->m_lastError);
+ return false;
+ }
+
+ QBluetoothLocalDevice::HostMode hostMode = device.hostMode();
+ if (hostMode == QBluetoothLocalDevice::HostPoweredOff) {
+ d->m_lastError = QBluetoothServer::PoweredOffError;
+ emit error(d->m_lastError);
+ qCWarning(QT_BT_BLUEZ) << "Bluetooth device is powered off";
+ return false;
+ }
+
int sock = d->socket->socketDescriptor();
if (sock < 0) {
/* Negative socket descriptor is not always an error case