diff options
author | Javier <dev.git@javispedro.com> | 2014-11-23 19:53:30 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2014-11-23 19:53:30 +0100 |
commit | 9949c02b0f814ad94a27864a5c39689f090299b6 (patch) | |
tree | 90e2893d5aafc14a020754eaf72a2df99e373efb /sapbtlistener.cc | |
parent | 5244f7909e04b23fbd5706dc6bcadafba21f7600 (diff) | |
download | sapd-9949c02b0f814ad94a27864a5c39689f090299b6.tar.gz sapd-9949c02b0f814ad94a27864a5c39689f090299b6.zip |
port to sailfish with qt 5.2
Diffstat (limited to 'sapbtlistener.cc')
-rw-r--r-- | sapbtlistener.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/sapbtlistener.cc b/sapbtlistener.cc index 1b4550a..76ecb94 100644 --- a/sapbtlistener.cc +++ b/sapbtlistener.cc @@ -1,6 +1,9 @@ #include <QtCore/QDebug> + +#ifdef MANUAL_SDP #include <bluetooth/sdp.h> #include <bluetooth/sdp_lib.h> +#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 |