summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp75
1 files changed, 39 insertions, 36 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp
index 390faf50..f562486b 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_qnx.cpp
@@ -46,12 +46,16 @@
#include <QtCore/private/qcore_unix_p.h>
-
QT_BEGIN_NAMESPACE
-QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(const QBluetoothAddress &deviceAdapter):
- QObject(0), lastError(QBluetoothDeviceDiscoveryAgent::NoError),
- m_rdfd(-1), m_active(false), m_nextOp(None), m_currentOp(None)
+QBluetoothDeviceDiscoveryAgentPrivate::QBluetoothDeviceDiscoveryAgentPrivate(
+ const QBluetoothAddress &deviceAdapter) :
+ QObject(0),
+ lastError(QBluetoothDeviceDiscoveryAgent::NoError),
+ m_rdfd(-1),
+ m_active(false),
+ m_nextOp(None),
+ m_currentOp(None)
{
Q_UNUSED(deviceAdapter);
inquiryType = QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry;
@@ -86,16 +90,18 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
m_nextOp = Start;
return;
}
- if (m_nextOp == Cancel) {
+ if (m_nextOp == Cancel)
m_nextOp = None;
- }
m_currentOp = Start;
if (m_rdfd != -1) {
qCDebug(QT_BT_QNX) << "RDev FD still open";
- } else if ((m_rdfd = qt_safe_open("/pps/services/bluetooth/remote_devices/.all", O_RDONLY)) == -1) {
- qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "rdfd - failed to open /pps/services/bluetooth/remote_devices/.all"
- << m_rdfd;
+ } else if ((m_rdfd
+ = qt_safe_open("/pps/services/bluetooth/remote_devices/.all",
+ O_RDONLY)) == -1) {
+ qCWarning(QT_BT_QNX) << Q_FUNC_INFO
+ << "rdfd - failed to open /pps/services/bluetooth/remote_devices/.all"
+ << m_rdfd;
lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError;
errorString = QBluetoothDeviceDiscoveryAgent::tr("Cannot open remote device socket");
emit q->error(lastError);
@@ -106,7 +112,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
if (!m_rdNotifier) {
qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "failed to connect to m_rdNotifier";
lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError;
- errorString = QBluetoothDeviceDiscoveryAgent::tr("Cannot connect to Bluetooth socket notifier");
+ errorString = QBluetoothDeviceDiscoveryAgent::tr(
+ "Cannot connect to Bluetooth socket notifier");
emit q->error(lastError);
stop();
return;
@@ -114,7 +121,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start()
}
if (ppsSendControlMessage("device_search", this)) {
- //If there is no new results after 7 seconds, the device inquire will be stopped
+ // If there is no new results after 7 seconds, the device inquire will be stopped
m_finishedTimer.start(10000);
connect(m_rdNotifier, SIGNAL(activated(int)), this, SLOT(remoteDevicesChanged(int)));
} else {
@@ -138,7 +145,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::stop()
m_currentOp = Cancel;
qCDebug(QT_BT_QNX) << "Stopping device search";
- ppsSendControlMessage("cancel_device_search",this);
+ ppsSendControlMessage("cancel_device_search", this);
if (m_rdNotifier) {
delete m_rdNotifier;
@@ -160,9 +167,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::remoteDevicesChanged(int fd)
QBluetoothAddress deviceAddr;
QString deviceName;
- if (!ppsReadRemoteDevice(fd, &ppsDecoder, &deviceAddr, &deviceName)) {
+ if (!ppsReadRemoteDevice(fd, &ppsDecoder, &deviceAddr, &deviceName))
return;
- }
bool paired = false;
int cod = 0;
@@ -179,8 +185,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::remoteDevicesChanged(int fd)
deviceInfo.setRssi(rssi);
bool updated = false;
- //Prevent a device from being listed twice
- for (int i=0; i < discoveredDevices.size(); i++) {
+ // Prevent a device from being listed twice
+ for (int i = 0; i < discoveredDevices.size(); i++) {
if (discoveredDevices.at(i).address() == deviceInfo.address()) {
updated = true;
if (discoveredDevices.at(i) == deviceInfo) {
@@ -191,12 +197,12 @@ void QBluetoothDeviceDiscoveryAgentPrivate::remoteDevicesChanged(int fd)
}
}
}
- //Starts the timer again
+ // Starts the timer again
m_finishedTimer.start(7000);
if (!deviceAddr.isNull()) {
qCDebug(QT_BT_QNX) << "Device discovered: " << deviceName << deviceAddr.toString();
discoveredDevices.append(deviceInfo);
- if (!updated)//We are not allowed to emit a signal with the updated version
+ if (!updated) // We are not allowed to emit a signal with the updated version
emit q_ptr->deviceDiscovered(discoveredDevices.last());
}
}
@@ -206,11 +212,11 @@ void QBluetoothDeviceDiscoveryAgentPrivate::controlReply(ppsResult result)
Q_Q(QBluetoothDeviceDiscoveryAgent);
if (result.msg == QStringLiteral("device_search") && m_currentOp == Start) {
if (result.dat.size() > 0 && result.dat.first() == QStringLiteral("EOK")) {
- //Do nothing. We can not be certain, that the device search is over yet
+ // Do nothing. We can not be certain, that the device search is over yet
} else if (result.error == 16) {
qCDebug(QT_BT_QNX) << "Could not start device inquire bc resource is busy";
- if (m_nextOp == None) { //We try again
- ppsSendControlMessage("cancel_device_search",this);
+ if (m_nextOp == None) { // We try again
+ ppsSendControlMessage("cancel_device_search", this);
QTimer::singleShot(5000, this, SLOT(startDeviceSearch()));
m_finishedTimer.start(20000);
}
@@ -223,13 +229,14 @@ void QBluetoothDeviceDiscoveryAgentPrivate::controlReply(ppsResult result)
stop();
}
processNextOp();
- } else if (result.msg == QStringLiteral("cancel_device_search") && m_currentOp == Cancel && !isFinished) {
+ } else if (result.msg == QStringLiteral("cancel_device_search") && m_currentOp == Cancel
+ && !isFinished) {
qCDebug(QT_BT_QNX) << "Cancel device search";
-// if (!result.errorMsg.isEmpty()) {
-// lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError;
-// errorString = result.errorMsg;
-// q_ptr->error(QBluetoothDeviceDiscoveryAgent::InputOutputError);
-// }
+// if (!result.errorMsg.isEmpty()) {
+// lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError;
+// errorString = result.errorMsg;
+// q_ptr->error(QBluetoothDeviceDiscoveryAgent::InputOutputError);
+// }
emit q->canceled();
processNextOp();
}
@@ -237,9 +244,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::controlReply(ppsResult result)
void QBluetoothDeviceDiscoveryAgentPrivate::controlEvent(ppsResult result)
{
- if (result.msg == QStringLiteral("device_added")) {
+ if (result.msg == QStringLiteral("device_added"))
qCDebug(QT_BT_QNX) << "Device was added" << result.dat.first();
- }
}
void QBluetoothDeviceDiscoveryAgentPrivate::finished()
@@ -254,9 +260,8 @@ void QBluetoothDeviceDiscoveryAgentPrivate::finished()
void QBluetoothDeviceDiscoveryAgentPrivate::startDeviceSearch()
{
- if (m_currentOp == Start) {
- ppsSendControlMessage("device_search", this); //Try again
- }
+ if (m_currentOp == Start)
+ ppsSendControlMessage("device_search", this); // Try again
}
void QBluetoothDeviceDiscoveryAgentPrivate::processNextOp()
@@ -268,12 +273,10 @@ void QBluetoothDeviceDiscoveryAgentPrivate::processNextOp()
m_currentOp = m_nextOp;
m_nextOp = None;
- if (m_currentOp == Start) {
+ if (m_currentOp == Start)
start();
- } else if (m_currentOp == Cancel) {
+ else if (m_currentOp == Cancel)
stop();
- }
}
QT_END_NAMESPACE
-