From 9949c02b0f814ad94a27864a5c39689f090299b6 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 23 Nov 2014 19:53:30 +0100 Subject: port to sailfish with qt 5.2 --- sapbtlistener.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'sapbtlistener.cc') diff --git a/sapbtlistener.cc b/sapbtlistener.cc index 1b4550a..76ecb94 100644 --- a/sapbtlistener.cc +++ b/sapbtlistener.cc @@ -1,6 +1,9 @@ #include + +#ifdef MANUAL_SDP #include #include +#endif #include "saprotocol.h" #include "sapbtlistener.h" @@ -12,6 +15,10 @@ namespace { + +#ifdef MANUAL_SDP +// Basically, QBluetoothServiceInfo is not yet compatible with Bluez5, +// so we hack around it by doing our own SDP connection. void add_sdp_record(sdp_session_t *session, const QBluetoothUuid &btuuid, quint16 port) { sdp_list_t *svclass_id, *apseq, *root; @@ -63,6 +70,7 @@ void add_sdp_records(quint16 port) add_sdp_record(sess, SAProtocol::dataServiceUuid, port); } +#endif } @@ -82,7 +90,11 @@ void SAPBTListener::start() return; } +#if QT_VERSION >= QT_VERSION_CHECK(5,2,0) + _server = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this); +#else _server = new QRfcommServer(this); +#endif connect(_server, SIGNAL(newConnection()), this, SLOT(acceptConnection())); if (!_server->listen(QBluetoothAddress(), 0)) { qWarning() << "Failed to start Bluetooth listener socket"; @@ -92,7 +104,7 @@ void SAPBTListener::start() quint8 serverPort = _server->serverPort(); -#if 1 +#if MANUAL_SDP // Basically, QBluetoothServiceInfo is not yet compatible with Bluez5, // so we hack around it by doing our own SDP connection. add_sdp_records(serverPort); @@ -123,7 +135,7 @@ void SAPBTListener::start() _service.setServiceProvider("gearbtteest"); QBluetoothServiceInfo::Sequence classIds; - classIds.append(QVariant::fromValue(SAPProtocol::dataServiceUuid)); + classIds.append(QVariant::fromValue(SAProtocol::dataServiceUuid)); _service.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classIds); QBluetoothServiceInfo::Sequence browseGroupList; @@ -167,7 +179,11 @@ void SAPBTListener::stop() void SAPBTListener::nudge(const QBluetoothAddress &address) { +#if QT_VERSION >= QT_VERSION_CHECK(5,2,0) + QBluetoothSocket *socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this); +#else QBluetoothSocket *socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket, this); +#endif connect(socket, SIGNAL(connected()), socket, SLOT(deleteLater())); connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), @@ -177,7 +193,7 @@ void SAPBTListener::nudge(const QBluetoothAddress &address) socket->connectToService(address, 2); //SAPProtocol::nudgeServiceUuid); -#if 1 +#if DESKTOP // At the same time set up and HFP connection to the watch. new HfpAg(address, this); #endif -- cgit v1.2.3