summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothserver_qnx.cpp
diff options
context:
space:
mode:
authorNedim Hadzic <nhadzic@blackberry.com>2014-04-17 17:39:34 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-29 10:00:09 +0200
commit4c301dfa6b4193115b6cf56ba0206a45d3a43977 (patch)
tree89946af06a4e53bb324fb4899a151fdb7ad4e738 /src/bluetooth/qbluetoothserver_qnx.cpp
parent293af3174c5615978d842603f9a8a4a9b568236c (diff)
BlackBerry C API added for OS>10.2.1
With new OS 10.3 some PPS object paths are changed. Therefore BB C API was used intead of PPS communication in some parts of QtConnectivity. The BB C API is introduced for OS 10.2.1 and newer. Change-Id: I94a21ed61a49a94dd2101990df4801a6925a3ce6 Reviewed-by: Alex Blasche <alexander.blasche@digia.com> Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
Diffstat (limited to 'src/bluetooth/qbluetoothserver_qnx.cpp')
-rw-r--r--src/bluetooth/qbluetoothserver_qnx.cpp59
1 files changed, 53 insertions, 6 deletions
diff --git a/src/bluetooth/qbluetoothserver_qnx.cpp b/src/bluetooth/qbluetoothserver_qnx.cpp
index cc28296c..2aefa041 100644
--- a/src/bluetooth/qbluetoothserver_qnx.cpp
+++ b/src/bluetooth/qbluetoothserver_qnx.cpp
@@ -48,7 +48,9 @@
#include <QSocketNotifier>
#include <QCoreApplication>
-
+#ifdef QT_QNX_BT_BLUETOOTH
+#include <btapi/btspp.h>
+#endif
QT_BEGIN_NAMESPACE
extern QHash<QBluetoothServerPrivate*, int> __fakeServerPorts;
@@ -70,6 +72,42 @@ QBluetoothServerPrivate::~QBluetoothServerPrivate()
activeSockets.clear();
}
+#ifdef QT_QNX_BT_BLUETOOTH
+void QBluetoothServerPrivate::btCallback(long param, int socket)
+{
+ QBluetoothServerPrivate *impl = reinterpret_cast<QBluetoothServerPrivate*>(param);
+ QMetaObject::invokeMethod(impl, "setBtCallbackParameters",
+ Qt::BlockingQueuedConnection,
+ Q_ARG(int, socket));
+}
+
+void QBluetoothServerPrivate::setBtCallbackParameters(int receivedSocket)
+{
+ Q_Q(QBluetoothServer);
+ if (receivedSocket == -1) {
+ qCDebug(QT_BT_QNX) << "Socket error: " << qt_error_string(errno);
+ m_lastError = QBluetoothServer::InputOutputError;
+ emit q->error(m_lastError);
+ return;
+ }
+ socket->setSocketDescriptor(receivedSocket, QBluetoothServiceInfo::RfcommProtocol,
+ QBluetoothSocket::ConnectedState,
+ QBluetoothSocket::ReadWrite);
+ char addr[18];
+ if (bt_spp_get_address(receivedSocket, addr) == -1) {
+ qCDebug(QT_BT_QNX) << "Could not obtain the remote address. "
+ << qt_error_string(errno);
+ m_lastError = QBluetoothServer::InputOutputError;
+ emit q->error(m_lastError);
+ return;
+ }
+ socket->d_ptr->m_peerAddress = QBluetoothAddress(addr);
+ activeSockets.append(socket);
+ socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this);
+ socket->setSocketState(QBluetoothSocket::ListeningState);
+ emit q->newConnection();
+}
+#else
void QBluetoothServerPrivate::controlReply(ppsResult result)
{
Q_Q(QBluetoothServer);
@@ -130,6 +168,7 @@ void QBluetoothServerPrivate::controlEvent(ppsResult result)
}
}
}
+#endif
void QBluetoothServer::close()
{
@@ -142,12 +181,19 @@ void QBluetoothServer::close()
}
if (d->socket) {
d->socket->close();
- delete d->socket;
- d->socket = 0;
if (__fakeServerPorts.contains(d)) {
- ppsSendControlMessage("deregister_server", 0x1101, d->m_uuid, QString(), QString(), 0);
+#ifdef QT_QNX_BT_BLUETOOTH
+ QByteArray b_uuid = d->m_uuid.toByteArray();
+ b_uuid = b_uuid.mid(1, b_uuid.length()-2);
+ bt_spp_close_server(b_uuid.data());
+#else
+ ppsSendControlMessage("deregister_server", 0x1101, d->m_uuid,
+ QString(), QString(), 0);
+#endif
__fakeServerPorts.remove(d);
}
+ delete d->socket;
+ d->socket = 0;
}
}
@@ -206,9 +252,10 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
return false;
}
- d->socket->setSocketState(QBluetoothSocket::ListeningState);
-
+#ifndef QT_QNX_BT_BLUETOOTH
ppsRegisterForEvent(QStringLiteral("service_connected"),d);
+#endif
+ d->socket->setSocketState(QBluetoothSocket::ListeningState);
return true;
}