From 1399fc2c3e2287de88ed3253476ea7f1b5d87937 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Apr 2014 10:05:45 +0200 Subject: Use extended SDP discovery in btchat example. Android's minimal service discovery is very limited and more often than not fails entirely. Using FulklDiscovery dramatically increases the chance to find the remote SPP chat server. Task-number: QTBUG-38140 Change-Id: I1df55f74a6896312236ef06485c4063c9e893e6c Reviewed-by: Nedim Hadzic Reviewed-by: Alex Blasche --- examples/bluetooth/btchat/remoteselector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bluetooth/btchat/remoteselector.cpp b/examples/bluetooth/btchat/remoteselector.cpp index e6fd728f..79dc0564 100644 --- a/examples/bluetooth/btchat/remoteselector.cpp +++ b/examples/bluetooth/btchat/remoteselector.cpp @@ -75,7 +75,7 @@ void RemoteSelector::startDiscovery(const QBluetoothUuid &uuid) ui->remoteDevices->clear(); m_discoveryAgent->setUuidFilter(uuid); - m_discoveryAgent->start(); + m_discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); } -- cgit v1.2.1 From 9615e7fbf439d0b2b9476ea7cb15ad145e675583 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Apr 2014 10:28:47 +0200 Subject: Build snippets during developer builds with examples only. This replaces an earlier Android specific solution against a more generic solution. Task-number: QTBUG-37638 Change-Id: I472ea48567e872c658094a5576b9260bf2d02c89 Reviewed-by: Oswald Buddenhagen --- src/src.pro | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/src.pro b/src/src.pro index 6ab12bda..cf918574 100644 --- a/src/src.pro +++ b/src/src.pro @@ -3,14 +3,19 @@ TEMPLATE = subdirs SUBDIRS += bluetooth nfc android: SUBDIRS += android -!android { +contains(QT_CONFIG, private_tests) { bluetooth_doc_snippets.subdir = bluetooth/doc/snippets bluetooth_doc_snippets.depends = bluetooth - SUBDIRS += bluetooth_doc_snippets nfc_doc_snippets.subdir = nfc/doc/snippets nfc_doc_snippets.depends = nfc - SUBDIRS += nfc_doc_snippets + + !contains(QT_BUILD_PARTS, examples) { + bluetooth_doc_snippets.CONFIG = no_default_target no_default_install + nfc_doc_snippets.CONFIG = no_default_target no_default_install + } + + SUBDIRS += bluetooth_doc_snippets nfc_doc_snippets } qtHaveModule(quick) { -- cgit v1.2.1 From 5c2f4d3472630be3a7b35c136434df5e8b50928f Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Apr 2014 14:58:52 +0200 Subject: Fix inconsistent behavior between BtDiscoveryModel & BtServiceDiscoveryAgent The model always resets the model content when starting a new service discovery. However QBluetoothServiceDiscovery doesn't do that. It adds newly discovered services and maintains the existing services. Since the model updates its content based on the serviceDiscovered signal, every second run created an empty list or only ever added services. Change-Id: I9c1d29562b9178678ab42bee98d5d1e3d0c4367f Reviewed-by: Fabian Bumberger --- src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp index 842d042d..d042bdfe 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp @@ -403,6 +403,7 @@ void QDeclarativeBluetoothDiscoveryModel::setRunning(bool running) } d->m_serviceAgent->setRemoteAddress(QBluetoothAddress(d->m_remoteAddress)); + d->m_serviceAgent->clear(); if (!d->m_uuid.isEmpty()) d->m_serviceAgent->setUuidFilter(QBluetoothUuid(d->m_uuid)); -- cgit v1.2.1 From d6f4ada86a20b1e25e61dae3d764fc4a35c3b3d9 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Fri, 11 Apr 2014 16:16:37 +0200 Subject: Doc: Improved example documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -include a section about running the example (from qtbase/doc/global) -added links to Qt Bluetooth or Qt NFC -updated copyright year -added markup to a string and other small corrections -added \brief Task-number: QTBUG-33597 Change-Id: Ia65821549a0e2e3fbf164188982114b4741be233 Reviewed-by: Alex Blasche Reviewed-by: Topi Reiniö --- examples/bluetooth/btchat/doc/src/btchat.qdoc | 7 ++-- .../btfiletransfer/doc/src/btfiletransfer.qdoc | 7 +++- .../bluetooth/btscanner/doc/src/btscanner.qdoc | 9 +++-- .../picturetransfer/doc/src/picturetransfer.qdoc | 40 +++++++++++++--------- examples/bluetooth/pingpong/doc/src/pingpong.qdoc | 6 ++-- examples/bluetooth/scanner/doc/src/scanner.qdoc | 5 +++ .../nfc/annotatedurl/doc/src/annotatedurl.qdoc | 14 +++++--- examples/nfc/corkboard/doc/src/corkboard.qdoc | 9 +++-- examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc | 12 +++++-- examples/nfc/poster/doc/src/poster.qdoc | 13 ++++--- 10 files changed, 86 insertions(+), 36 deletions(-) diff --git a/examples/bluetooth/btchat/doc/src/btchat.qdoc b/examples/bluetooth/btchat/doc/src/btchat.qdoc index 77f73fd1..a78b9ede 100644 --- a/examples/bluetooth/btchat/doc/src/btchat.qdoc +++ b/examples/bluetooth/btchat/doc/src/btchat.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt local connectivty modules. @@ -28,8 +28,9 @@ /*! \example btchat \title Bluetooth Chat Example + \brief An example showing communication through Bluetooth. - The Bluetooth Chat example shows how to use the Qt Connectivity Bluetooth API to communicate + The Bluetooth Chat example shows how to use the \l{Qt Bluetooth} API to communicate with another application on a remote device using Bluetooth. \image btchat-example.png @@ -38,6 +39,8 @@ application always acts as both a server and a client eliminating the need to determine who should connect to whom. + \include examples-run.qdocinc + \section1 Chat Server The chat server is implemented by the ChatServer class. The ChatServer class is declared as: diff --git a/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc b/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc index aeeffffb..53832725 100644 --- a/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc +++ b/examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt local connectivty modules. @@ -28,6 +28,7 @@ /*! \example btfiletransfer \title Bluetooth File Transfer Example + \brief An example showing the use of Bluetooth Object Push Profile (OPP). The Bluetooth File Transfer example is an application to transfer files via a bluetooth connection. This example does not work on Android due to @@ -35,4 +36,8 @@ \image btfiletransfer-example.png + \include examples-run.qdocinc + + \sa {Qt Bluetooth} + */ diff --git a/examples/bluetooth/btscanner/doc/src/btscanner.qdoc b/examples/bluetooth/btscanner/doc/src/btscanner.qdoc index e67b761a..e4d28ee2 100644 --- a/examples/bluetooth/btscanner/doc/src/btscanner.qdoc +++ b/examples/bluetooth/btscanner/doc/src/btscanner.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt local connectivty modules. @@ -28,9 +28,14 @@ /*! \example btscanner \title Bluetooth Scanner Example + \brief An example showing how to locate Bluetooth devices. - An example of how to locate Bluetooth devices. + An example showing how to locate Bluetooth devices. \image btscanner-example.png + \include examples-run.qdocinc + + \sa {Qt Bluetooth} + */ diff --git a/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc b/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc index 7a166121..3b0218d4 100644 --- a/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc +++ b/examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc @@ -28,18 +28,20 @@ a/**************************************************************************** /*! \example picturetransfer \title QML Bluetooth Picture Push Example +\brief An example showing the use Bluetooth Object Push Profile (OPP). -The Bluetooth Picture Push example shows how to use the \l QBluetoothTransferManager -API. The example transfers a local image to a remote device. Unfortunately this example cannot be used on -Android as Qt does not support the Object Push Profile on this platform. +The Bluetooth Picture Push example shows how to use the \l +QBluetoothTransferManager API. The example transfers a local image to a remote +device. Unfortunately this example cannot be used on Android as Qt does not +support the Object Push Profile (OPP) on this platform. -On the first user interface page the application scans for remote Bluetooth devices. The user must select -the appropriate device to continue: +On the first user interface page the application scans for remote Bluetooth +devices. The user must select the appropriate device to continue: \image opp-example-1.png -The next page presents a list of image files on the device. The files must be located under -\l QStandardPaths::PicturesLocation}: +The next page presents a list of image files on the device. The files must be +located under \l QStandardPaths::PicturesLocation}: \image opp-example-2.png @@ -47,29 +49,35 @@ Once the picture was selected the UI shows the progress of the file transfer: \image opp-example-3.png +\include examples-run.qdocinc + +\sa {Qt Bluetooth} + \section1 Device Discovery -The device discovery uses the \l BluetoothDiscoveryModel to detect the remote devices. Each discovery is displayed -as an entry in a list. Once a device was selected the device address is stored in the \c root element. More -details about the \c root element will follow further below. +The device discovery uses the \l BluetoothDiscoveryModel to detect the remote +devices. Each discovery is displayed as an entry in a list. Once a device was +selected the device address is stored in the \c root element. More details about +the \c root element will follow further below. \snippet picturetransfer/DeviceDiscovery.qml Discovery-1 \snippet picturetransfer/DeviceDiscovery.qml Discovery-2 \section1 File Selection -The file is selected with the help of \l FolderListModel. Once again the selected file is stored in the \c root -element: +The file is selected with the help of \l FolderListModel. Once again the +selected file is stored in the \c root element: \snippet picturetransfer/PictureSelector.qml FileSelect-1 \snippet picturetransfer/PictureSelector.qml FileSelect-2 \snippet picturetransfer/PictureSelector.qml FileSelect-3 \snippet picturetransfer/PictureSelector.qml FileSelect-4 -\section1 The root element +\section1 Root Element -The already mentioned \c root element collects the necessary pieces of data for the picture transfer. -Once the file name has been set it triggers the file transfer: +The already mentioned \c root element collects the necessary pieces of data for +the picture transfer. Once the file name has been set it triggers the file +transfer: \snippet picturetransfer/bttransfer.qml Root-1 @@ -77,7 +85,7 @@ Once the file name has been set it triggers the file transfer: \snippet picturetransfer/bttransfer.qml Root-3 \snippet picturetransfer/bttransfer.qml Root-3 -\section1 The File Transfer +\section1 File Transfer The file transfer is implemented in C++: diff --git a/examples/bluetooth/pingpong/doc/src/pingpong.qdoc b/examples/bluetooth/pingpong/doc/src/pingpong.qdoc index df7fcc34..0e82a71a 100644 --- a/examples/bluetooth/pingpong/doc/src/pingpong.qdoc +++ b/examples/bluetooth/pingpong/doc/src/pingpong.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt Toolkit. @@ -28,6 +28,7 @@ /*! \example pingpong \title Bluetooth QML Ping Pong example + \brief A QML example showing Bluetooth communication. The Bluetooth QML Ping Pong example presents the socket communication between two Bluetooth devices. The basic concept is the ping pong game where two players @@ -35,6 +36,8 @@ \image intro.png + \include examples-run.qdocinc + At the beginning, the user selects the role. One device acts as a server and the second one as a client. After selecting the role, adjustments to the screen size are done (two devices might have different screen sizes). The server side starts a service named @@ -77,4 +80,3 @@ \image intro1.png */ - diff --git a/examples/bluetooth/scanner/doc/src/scanner.qdoc b/examples/bluetooth/scanner/doc/src/scanner.qdoc index 62b9680c..f4e292a8 100644 --- a/examples/bluetooth/scanner/doc/src/scanner.qdoc +++ b/examples/bluetooth/scanner/doc/src/scanner.qdoc @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2013 Aaron McCarthy ** Contact: http://www.qt-project.org/legal ** @@ -28,6 +29,7 @@ /*! \example scanner \title QML Bluetooth Scanner Example +\brief A QML example about locating Bluetooth devices. This is an example on how to locate Bluetooth devices in QML. @@ -50,4 +52,7 @@ from local cache information and may not always be complete and accurate. The pr perform a minimal discovery are time constraints. A full service discovery can take up to two minutes. Note that not every platform supports a minimal discovery. In such cases the API performs a full discovery. +\include examples-run.qdocinc + +\sa {Qt Bluetooth} */ diff --git a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc index 2a84c8b3..08001fdf 100644 --- a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc +++ b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt local connectivty modules. @@ -28,10 +28,16 @@ /*! \example annotatedurl \title Annotated URL Example +\brief An example showing reading from formatted NFC Data Exchange Format (NDEF) messages. -The Annotated URL example displays the contents of specifically formatted NDEF messages read from -an NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record, and one -or more localized Text records. +The Annotated URL example displays the contents of specifically formatted NFC +Data Exchange Format (NDEF) messages read from an NFC Tag. The NDEF message +should contain a URI record, an optional \c image/* MIME record, and one or more +localized Text records. \image annotatedurl.png + +\include examples-run.qdocinc + +\sa {Qt NFC} */ diff --git a/examples/nfc/corkboard/doc/src/corkboard.qdoc b/examples/nfc/corkboard/doc/src/corkboard.qdoc index 4027fc26..db982d2e 100644 --- a/examples/nfc/corkboard/doc/src/corkboard.qdoc +++ b/examples/nfc/corkboard/doc/src/corkboard.qdoc @@ -28,12 +28,17 @@ /*! \example corkboard \title QML CorkBoard Example +\brief A QML example about displaying NFC Data Exchange Format (NDEF) messages. The QML CorkBoard example displays the contents of NDEF messages read from an NFC Tag. Each newly detected NDEF message is added to the corkboard and can be -dragged into an arbitrary position on the board. The corkboard has a "Personal" -and "Work" space. The workspace can be changed by sliding left or right. +dragged into an arbitrary position on the board. The corkboard has a \e Personal +and \e Work space. The workspace can be changed by sliding left or right. \image corkboard.png +\include examples-run.qdocinc + +\sa {Qt NFC} + */ diff --git a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc index 346feb8e..3ebc5525 100644 --- a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc +++ b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt local connectivty modules. @@ -28,9 +28,15 @@ /*! \example ndefeditor \title NDEF Editor Example +\brief An example about reading and writing NFC Data Exchange Format (NDEF) messages to NFC Forum Tags. -The NDEF Editor example reads and writes NDEF messages to NFC Forum Tags. NDEF messages can be -composed by adding records of supported types. +The NDEF Editor example reads and writes NFC Data Exchange Format (NDEF) +messages to NFC Forum Tags. NDEF messages can be composed by adding records of +supported types. \image ndefeditor.png + +\include examples-run.qdocinc + +\sa {Qt NFC} */ diff --git a/examples/nfc/poster/doc/src/poster.qdoc b/examples/nfc/poster/doc/src/poster.qdoc index 125afd95..05cfd6d3 100644 --- a/examples/nfc/poster/doc/src/poster.qdoc +++ b/examples/nfc/poster/doc/src/poster.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt local connectivty modules. @@ -28,11 +28,16 @@ /*! \example poster \title QML Poster Example +\brief A QML example about reading and displaying NFC Data Exchange Format (NDEF) messages. -The QML Poster example displays the contents of specifically formatted NDEF messages read from an -NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record, and one -or more localized Text records. +The QML Poster example displays the contents of specifically formatted NFC Data +Exchange Format (NDEF) messages read from an NFC Tag. The NDEF message should +contain a URI record, an optional \c image/* MIME record, and one or more +localized Text records. \image qml-poster-example.png +\include examples-run.qdocinc + +\sa {Qt NFC} */ -- cgit v1.2.1 From 5f00449d4b1492142ba23211258e2370bdfa5986 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Apr 2014 15:38:39 +0200 Subject: Don't double up the internal list of discovered services Convention is that calling QBluetoothServiceDiscoveryAgent maintains an internal list of discovered services. When start() is called already discovered services are kept unless clear() was called. The Bluez code never checked which services were already discovered by previous discovery runs. This patch fixes this problem. Change-Id: I3987d6ea65ea41aefc9726acc31f6abaa478c72c Reviewed-by: Fabian Bumberger --- .../qbluetoothservicediscoveryagent_bluez.cpp | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp index 0e782d5c..a842d3d9 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtBluetooth module of the Qt Toolkit. @@ -240,9 +240,24 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC Q_Q(QBluetoothServiceDiscoveryAgent); - discoveredServices.append(serviceInfo); - qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString(); - emit q->serviceDiscovered(serviceInfo); + //don't include the service if we already discovered it before + bool alreadyDiscovered = false; + for (int j = 0; j < discoveredServices.count(); j++) { + const QBluetoothServiceInfo &info = discoveredServices.at(j); + if (info.device() == serviceInfo.device() + && info.serviceClassUuids() == serviceInfo.serviceClassUuids() + && info.serviceUuid() == serviceInfo.serviceUuid()) { + alreadyDiscovered = true; + break; + } + } + + if (!alreadyDiscovered) { + discoveredServices.append(serviceInfo); + qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString(); + emit q->serviceDiscovered(serviceInfo); + } + // could stop discovery, check for state if(discoveryState() == Inactive){ qCDebug(QT_BT_BLUEZ) << "Exit discovery after stop"; -- cgit v1.2.1 From 14532147e29dd2337ee024eeb8e0af7ba9964841 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Apr 2014 13:14:51 +0200 Subject: Do not always filter Serial Port profiles out anymore on Android 1.) If we find a custom and SPP uuid we create only on service using custom uuid as service uuid and SPP as service class uuid. THis is the recommended way. Any remote service should really advertise a custom uuid. Unfortunately this is not always the case on some embedded devices. Hence we need to cover the cases below. 2.) If we find a custom uuid only we create a service which uses the custom uuid as service uuid but we do not set a service class. 3.) If we find a SPP uuid only, we create a service which uses SPP as service uuid and as service class uuid. This is no problem as Android's connectToRfcommService() call explicitly permits an SPP uuid as connection parameter. 4.) We find none of the above the problem doesn't exist in the first place and no service was found. Task-number: QTBUG-38140 Change-Id: I2e9080f65b98db23782264ef9e62a410ab9f91f1 Reviewed-by: Fabian Bumberger Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../qbluetoothservicediscoveryagent_android.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp index 2e55d40e..4a8b62e7 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp @@ -416,7 +416,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB } for (int i = 0; i < uuids.count(); i++) { - if (i == sppIndex) //skip SPP service class id + if (i == sppIndex && !customUuids.isEmpty()) continue; QBluetoothServiceInfo serviceInfo; @@ -444,6 +444,21 @@ void QBluetoothServiceDiscoveryAgentPrivate::populateDiscoveredServices(const QB serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Serial Port Profile")); serviceInfo.setServiceUuid(uuids.at(i)); + } else if (sppIndex == i && customUuids.isEmpty()) { + //set rfcomm protocol + QBluetoothServiceInfo::Sequence protocol; + protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm)) + << QVariant::fromValue(0); + protocolDescriptorList.append(QVariant::fromValue(protocol)); + + QBluetoothServiceInfo::Sequence classId; + classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); + serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, + classId); + + //also we need to set the custom uuid to the SPP uuid + //otherwise QBluetoothSocket::connectToService() would fail due to a missing service uuid + serviceInfo.setServiceUuid(uuids.at(i)); } else if (customUuids.contains(i)) { //custom uuid but no serial port serviceInfo.setServiceUuid(uuids.at(i)); -- cgit v1.2.1 From d755d1e76e8268f1de9c2006685df84e4e2728bf Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 14 Apr 2014 16:30:43 +0200 Subject: Add Qt 5.3.0 change log for QtNfc and QtBluetooth Change-Id: Id489adfe1cfb4c652907e67950b8a12bf1c18c8c Reviewed-by: Fabian Bumberger --- dist/changes-5.3.0 | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 dist/changes-5.3.0 diff --git a/dist/changes-5.3.0 b/dist/changes-5.3.0 new file mode 100644 index 00000000..97754515 --- /dev/null +++ b/dist/changes-5.3.0 @@ -0,0 +1,154 @@ +Qt 5.3 introduces many new features and improvements as well as bugfixes +over the 5.2.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://qt-project.org/doc/qt-5.3 + +The Qt version 5.3 series is binary compatible with the 5.2.x series. +Applications compiled for 5.2 will continue to run with 5.3. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt-project.org/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + +General Improvements +-------------------- + +**************************************************************************** +* Library * +**************************************************************************** + +QtBluetooth +----------- + + - Documentation: + * The documentation for the Bluetooth discovery classes has been + improved. + * QBluetoothSocket's local name, port and address property documentation + improved. + * Documentation of all examples improved. + + - General: + * Added a new Object-Push example. + * QML scanner example was optimized for high DPI displays and + error handling was improved. This ensures a better user interface + for Android and BlackBerry devices. + * Replaced tennis example against new QML based PingPong example. + * Test application added. This application enables easier testing + and debugging of the various API features. + + - BluetoothDiscoveryModel: + * Improved error handling of device discovery process. + * Fixed incorrect behavior when changing from device to service discovery + and vice versa. + + - QBluetoothDeviceDiscoveryAgent: + * Added checks and error enum value to avoid incorrect handling of + non-existing local Bluetooth adapter addresses. + + - QBluetoothHostInfo: + * Copy operator added. + + - QBluetoothLocalDevice: + * Added a new API elements to retrieve connected Bluetooth devices + and to receive notifications about connection changes. + + - QBluetoothServiceDiscoveryAgent: + * Fixed the fallback backend's initial state and error values. + * Duplicated code was removed. + * QBluetoothServiceDiscoveryAgent::clear() was improved to avoid + unpredictable class behavior. + + - QBluetoothServer: + * Checks added to avoid calls to listen() while the server socket is + already listening for incoming sockets. + * Fixed inconsistent state() of server object after failed service + registration attempt during listen() call. + * Fixed incorrect parameter type of error() signal. This fixed issues + whereby QObject::connect() could not find the signal. + * Added custom uuid to serial port service SDP data set. This enables + the discovery of such profiles on Android devices. + + - QBluetoothServiceInfo: + * Fixed broken implementation of serviceClassUuids(). + + - QBluetoothSocket: + * Fixed a crash in Bluez part of QBluetoothSocket() which was caused + triggered when calling the sequence connect() - abort() - connect(). + * Fixed missing initialization of the internal socket error state + variable. This caused incorrect QBluetoothSocket::error() right after + class instantiation. + * Synchronized handling of errors across all supported platforms. + + - QBluetoothUuid: + * Fixed wrong value of PnpInformation enum value. + * Added newly defined ServiceClassUuid's defined Bluetooth forum. + + +QtNfc +----- + + - Documentation: + * Added missing documentation to QQmlNdefRecord. + * General documentation fixes add. + + - General: + * Added a new corkboard example displaying the content of NDEF text + records. + * A new NFC share API was added. The API provides sharing of NDEF + messages and arbitrary files via NFC and may potentially use other + communication protocols such as wifi or Bluetooth as part of its + implementation. + + + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +Android +------- + + - [QTBUG-33792] QtBluetooth has been ported to Android. + +BlackBerry 10: + + - [QTBUG-36626] Fixed a memory leak in QBluetoothServer::listen(). + - Fixed incomplete implementation of QBluetoothServer::close(). + - Fixed wrong pairingStatus() returned by QBluetoothLocalDevice. + - Fixed accidental loss of remote device information in QBluetoothServer. + - Added incomplete implementation of QBluetooth::setMaxPendingConnections(). + - Fixed always failing call to QBluetoothServerInfo::unregisterService(). + - Fixed missing emission of ConnectedState by QBluetoothSocket. + - Fixed implementation of QBluetoothTransferManager::put() when using + together with a QFile. + +Bluez/Linux +------- + + - The handling of powered-off local Bluetooth adapters was improved. + - Fixed memory leaks in service and device discovery classes. + - Removed dead code from SDP discovery implementation. + - Fixed crash during service discovery. + - Fixed incorrect invocation of QBluetoothDiscoveryAgent where the + remote service address was incorrectly assumed to be the local Bt + adapter address. This prevented the detection of the remote service. + - Removed caching of QBluetoothSocket::localName() and peerName() values. Under + certain circumstances those functions returned wrong values. + - Fixed missing update of internal QBluetoothSocket::state during SDP discovery. + - Removed assertion during service discovery due to unknown SDP attribute. + - Prevented calls to QBluetoothSocket::connectToService() while the socket + is already in the ServiceLoockupState. + - Fixed failing call to QBluetoothServer::listen(QBluetoothAddress) if the passed + address was null. + + + -- cgit v1.2.1 From 99a53598a952f775f8ce8a3b1bf66cf81cb63761 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Mon, 14 Apr 2014 11:03:42 -0700 Subject: Refactor disconnection signals emittance in QBluetoothSocket This fixes duplicate switching to the unconnected state in case the disconnect() signal is used to reconnect. [ChangeLog][QtBluetooth][QBluetoothSocket] Fixed duplicate emission of unconnected state in the reconnection case. Change-Id: If449420d936c96e62518fc408e6a1e35b79988a8 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothsocket.cpp | 9 +++++++++ src/bluetooth/qbluetoothsocket_bluez.cpp | 16 +--------------- src/bluetooth/qbluetoothsocket_qnx.cpp | 2 -- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp index 6272ca1f..0c514887 100644 --- a/src/bluetooth/qbluetoothsocket.cpp +++ b/src/bluetooth/qbluetoothsocket.cpp @@ -600,7 +600,12 @@ void QBluetoothSocket::abort() Q_D(QBluetoothSocket); d->abort(); + +#ifndef QT_ANDROID_BLUETOOTH + //Android closes when the Java event loop comes around setSocketState(QBluetoothSocket::UnconnectedState); + emit disconnected(); +#endif } void QBluetoothSocket::disconnectFromService() @@ -666,7 +671,11 @@ void QBluetoothSocket::close() d->close(); +#ifndef QT_ANDROID_BLUETOOTH + //Android closes when the Java event loop comes around setSocketState(UnconnectedState); + emit disconnected(); +#endif } /*! diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index 6aad6603..459d9f5e 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -238,7 +238,6 @@ void QBluetoothSocketPrivate::_q_readNotify() q->setSocketError(QBluetoothSocket::UnknownSocketError); q->disconnectFromService(); - q->setSocketState(QBluetoothSocket::UnconnectedState); } else { buffer.chop(QPRIVATELINEARBUFFER_BUFFERSIZE - (readFromDevice < 0 ? 0 : readFromDevice)); @@ -259,9 +258,6 @@ void QBluetoothSocketPrivate::abort() // QBluetoothSocket::close QT_CLOSE(socket); socket = -1; - - Q_Q(QBluetoothSocket); - emit q->disconnected(); } QString QBluetoothSocketPrivate::localName() const @@ -508,17 +504,7 @@ void QBluetoothSocketPrivate::close() connectWriteNotifier->setEnabled(true); } else { - - delete readNotifier; - readNotifier = 0; - delete connectWriteNotifier; - connectWriteNotifier = 0; - - // We are disconnected now, so go to unconnected. - q->setSocketState(QBluetoothSocket::UnconnectedState); - emit q->disconnected(); - QT_CLOSE(socket); - socket = -1; + abort(); } } diff --git a/src/bluetooth/qbluetoothsocket_qnx.cpp b/src/bluetooth/qbluetoothsocket_qnx.cpp index ad4359e2..4deb4f84 100644 --- a/src/bluetooth/qbluetoothsocket_qnx.cpp +++ b/src/bluetooth/qbluetoothsocket_qnx.cpp @@ -176,8 +176,6 @@ void QBluetoothSocketPrivate::abort() ::close(socket); - q->setSocketState(QBluetoothSocket::UnconnectedState); - Q_EMIT q->disconnected(); isServerSocket = false; } -- cgit v1.2.1 From 7d04c97a566c3ec6b17101d7a511767ba09da9a6 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Fri, 11 Apr 2014 18:05:18 -0700 Subject: Fix internal buffer corruption in QBluetoothSocket (BlueZ) When _q_readNotify() is called and no data is available (e.g. in case of timeout), then the internal buffer grows indefinitely, causing a one time corruption of the following good data. Change-Id: I75929382db73953bbccdd86b9ae248329df879fa Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothsocket_bluez.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index 459d9f5e..7ff96dd9 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -226,6 +226,7 @@ void QBluetoothSocketPrivate::_q_readNotify() char *writePointer = buffer.reserve(QPRIVATELINEARBUFFER_BUFFERSIZE); // qint64 readFromDevice = q->readData(writePointer, QPRIVATELINEARBUFFER_BUFFERSIZE); int readFromDevice = ::read(socket, writePointer, QPRIVATELINEARBUFFER_BUFFERSIZE); + buffer.chop(QPRIVATELINEARBUFFER_BUFFERSIZE - (readFromDevice < 0 ? 0 : readFromDevice)); if(readFromDevice <= 0){ int errsv = errno; readNotifier->setEnabled(false); @@ -240,8 +241,6 @@ void QBluetoothSocketPrivate::_q_readNotify() q->disconnectFromService(); } else { - buffer.chop(QPRIVATELINEARBUFFER_BUFFERSIZE - (readFromDevice < 0 ? 0 : readFromDevice)); - emit q->readyRead(); } } -- cgit v1.2.1 From 6d9ab3981a1ae9e224b3c6a8cf107049a0ee5095 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Tue, 15 Apr 2014 17:25:36 -0700 Subject: Fix a crash in QBluetoothSocket on reconnection attempt (BlueZ) Ensure a native socket is obtained after QBluetoothSocket has been closed. [ChangeLog][QtBluetooth][QBluetoothSocket] Fixed a crash on reconnect. Change-Id: I9f470d23366250dc20ad3305ddec16300c1ad8ec Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothsocket_bluez.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index 7ff96dd9..b9ed73a6 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -134,6 +134,12 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, Q_UNUSED(openMode); int result = -1; + if (socket == -1 && !ensureNativeSocket(socketType)) { + errorString = QObject::tr("Unknown socket error"); + q->setSocketError(QBluetoothSocket::UnknownSocketError); + return; + } + if (socketType == QBluetoothServiceInfo::RfcommProtocol) { sockaddr_rc addr; -- cgit v1.2.1 From 9b11226f3d23dfb4c6b8457f2a839584666cda6a Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 15 Apr 2014 14:18:12 +0200 Subject: Fix discovery hanging in unrecoverable state due to incorrect error handling The discovery of services happens in a sequentiali per-device order. Once the first device's services were found, the results are processed and the discovery is started on the next device. Unfortunately if the search didn't create any results due to the remote device refusing the SDP discovery or because the given remote Bluetooth address was not valid, the discovery agent didn't continue with the next device. Now the error handling ensures that the discovery process is continued with the next device (if there is any). Task-number: QTBUG-38362 Change-Id: Ie27bbc5327eadc4bcc31b589227c51dc4fa2c7c1 Reviewed-by: Fabian Bumberger --- src/bluetooth/android/servicediscoverybroadcastreceiver.cpp | 6 +++++- src/bluetooth/qbluetoothservicediscoveryagent_android.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp b/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp index 0a3f97f9..87564ce6 100644 --- a/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp +++ b/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp @@ -76,8 +76,10 @@ void ServiceDiscoveryBroadcastReceiver::onReceive(JNIEnv *env, jobject context, "getParcelableArrayExtra", "(Ljava/lang/String;)[Landroid/os/Parcelable;", keyExtra.object()); - if (!parcelableUuids.isValid()) + if (!parcelableUuids.isValid()) { + emit uuidFetchFinished(QBluetoothAddress(), QList()); return; + } const QList result = ServiceDiscoveryBroadcastReceiver::convertParcelableArray(parcelableUuids); keyExtra = valueForStaticField(JavaNames::BluetoothDevice, JavaNames::ExtraDevice); @@ -89,6 +91,8 @@ void ServiceDiscoveryBroadcastReceiver::onReceive(JNIEnv *env, jobject context, if (bluetoothDevice.isValid()) { address = QBluetoothAddress(bluetoothDevice.callObjectMethod("getAddress").toString()); emit uuidFetchFinished(address, result); + } else { + emit uuidFetchFinished(QBluetoothAddress(), QList()); } } } diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp index 4a8b62e7..2643d7a9 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp @@ -246,6 +246,12 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids( if (discoveredDevices.count() == 0) return; + //could not find any service for the current address/device -> go to next one + if (address.isNull() || uuids.isEmpty()) { + _q_serviceDiscoveryFinished(); + return; + } + if (QT_BT_ANDROID().isDebugEnabled()) { qCDebug(QT_BT_ANDROID) << "Found UUID for" << address.toString() << "\ncount: " << uuids.count(); -- cgit v1.2.1 From 8a52d4bd4f2cf1d9a44cd1f95ad3e2d8da4c132b Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Wed, 16 Apr 2014 19:01:00 -0700 Subject: Provide correct code snippet for QBluetoothServiceDiscoveryAgent Change-Id: I8b975a2f55833c58479edac5d62809c1e83ea417 Reviewed-by: Alex Blasche --- src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp | 29 ++++++++++++++++++++-- src/bluetooth/qbluetoothdevicediscoveryagent.cpp | 2 +- src/bluetooth/qbluetoothservicediscoveryagent.cpp | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp index 88520c35..0975b966 100644 --- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp +++ b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,7 @@ public: public slots: void deviceDiscovered(const QBluetoothDeviceInfo &device); + void serviceDiscovered(const QBluetoothServiceInfo &service); void transferFinished(QBluetoothTransferReply* reply); }; @@ -94,7 +96,7 @@ if (localDevice.isValid()) { } -//! [discovery] +//! [device_discovery] void MyClass::startDiscovery() { @@ -114,7 +116,30 @@ void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device) { qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')'; } -//! [discovery] +//! [device_discovery] + +//! [service_discovery] +void MyClass::startDiscovery() +{ + + // Create a discovery agent and connect to its signals + QBluetoothServiceDiscoveryAgent *discoveryAgent = new QBluetoothServiceDiscoveryAgent(this); + connect(discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), + this, SLOT(serviceDiscovered(QBluetoothServiceInfo)); + + // Start a discovery + discoveryAgent->start(); + + //... +} + +// In your local slot, read information about the found devices +void MyClass::serviceDiscovered(const QBluetoothServiceInfo &service) +{ + qDebug() << "Found new service:" << service.serviceName() + << '(' << service.device().address().toString() << ')'; +} +//! [service_discovery] void MyClass::objectPush() { diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp index eeac8f11..fab8f965 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE \li and call start(). \endlist - \snippet doc_src_qtbluetooth.cpp discovery + \snippet doc_src_qtbluetooth.cpp device_discovery To retrieve results asynchronously, connect to the deviceDiscovered() signal. To get a list of all discovered devices, call discoveredDevices() after the finished() signal. diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp index 7e0e701d..36849eed 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE \li and call start(). \endlist - \snippet doc_src_qtbluetooth.cpp discovery + \snippet doc_src_qtbluetooth.cpp service_discovery By default a minimal service discovery is performed. In this mode, the QBluetotohServiceInfo objects returned are guaranteed to contain only device and service UUID information. Depending -- cgit v1.2.1 From c71404f34cc6a2fa6b52ab7adcfc72f8fa795b0e Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 16 Apr 2014 17:32:21 +0200 Subject: Bluez4: Fix incorrect list of connected devices in QBluetoothLocalDevice ConnectionChange signals were never emitted for remote devices which already existed at class instanciation time. At the same time this patch removes the delayed creation of the connectedDevices set. This simplifies the code and the caching did not save much effort. Task-number: QTBUG-38402 Change-Id: Ic871f919435c0d42ce2d79fd54f0da693816010a Reviewed-by: Oleg Shparber Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothlocaldevice_bluez.cpp | 41 ++++++++++++--------------- src/bluetooth/qbluetoothlocaldevice_p.h | 2 -- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp index 9f2e7fd3..ac694f34 100644 --- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp @@ -347,7 +347,7 @@ QBluetoothLocalDevice::Pairing QBluetoothLocalDevice::pairingStatus(const QBluet } QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice *q, QBluetoothAddress address) - : adapter(0), agent(0), localAddress(address), pendingHostModeChange(-1), msgConnection(0), q_ptr(q), connectedCached(false) + : adapter(0), agent(0), localAddress(address), pendingHostModeChange(-1), msgConnection(0), q_ptr(q) { initializeAdapter(); connectDeviceChanges(); @@ -356,6 +356,7 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice void QBluetoothLocalDevicePrivate::connectDeviceChanges() { if (adapter) { //invalid QBluetoothLocalDevice due to wrong local adapter address + createCache(); connect(adapter, SIGNAL(PropertyChanged(QString,QDBusVariant)), SLOT(PropertyChanged(QString,QDBusVariant))); connect(adapter, SIGNAL(DeviceCreated(QDBusObjectPath)), SLOT(_q_deviceCreated(QDBusObjectPath))); connect(adapter, SIGNAL(DeviceRemoved(QDBusObjectPath)), SLOT(_q_deviceRemoved(QDBusObjectPath))); @@ -438,7 +439,7 @@ void QBluetoothLocalDevicePrivate::RequestConfirmation(const QDBusObjectPath &in void QBluetoothLocalDevicePrivate::_q_deviceCreated(const QDBusObjectPath &device) { OrgBluezDeviceInterface *deviceInterface = - new OrgBluezDeviceInterface(QLatin1String("org.bluez"), device.path(), QDBusConnection::systemBus()); + new OrgBluezDeviceInterface(QLatin1String("org.bluez"), device.path(), QDBusConnection::systemBus(), this); connect(deviceInterface, SIGNAL(PropertyChanged(QString,QDBusVariant)), SLOT(_q_devicePropertyChanged(QString,QDBusVariant))); devices << deviceInterface; QDBusPendingReply properties = deviceInterface->asyncCall(QLatin1String("GetProperties")); @@ -451,16 +452,13 @@ void QBluetoothLocalDevicePrivate::_q_deviceCreated(const QDBusObjectPath &devic const QBluetoothAddress address = QBluetoothAddress(properties.value().value(QLatin1String("Address")).toString()); const bool connected = properties.value().value(QLatin1String("Connected")).toBool(); - if (connectedCached) { - if (connected) - connectedDevicesSet.insert(address); - else - connectedDevicesSet.remove(address); - } - if (connected) + if (connected) { + connectedDevicesSet.insert(address); emit q_ptr->deviceConnected(address); - else + } else { + connectedDevicesSet.remove(address); emit q_ptr->deviceDisconnected(address); + } } void QBluetoothLocalDevicePrivate::_q_deviceRemoved(const QDBusObjectPath &device) @@ -488,16 +486,13 @@ void QBluetoothLocalDevicePrivate::_q_devicePropertyChanged(const QString &prope const QBluetoothAddress address = QBluetoothAddress(properties.value(QLatin1String("Address")).toString()); const bool connected = value.variant().toBool(); - if (connectedCached) { - if (connected) - connectedDevicesSet.insert(address); - else - connectedDevicesSet.remove(address); - } - if (connected) + if (connected) { + connectedDevicesSet.insert(address); emit q_ptr->deviceConnected(address); - else + } else { + connectedDevicesSet.remove(address); emit q_ptr->deviceDisconnected(address); + } } } @@ -513,9 +508,12 @@ void QBluetoothLocalDevicePrivate::createCache() return; } foreach (const QDBusObjectPath &device, reply.value()) { - OrgBluezDeviceInterface deviceInterface(QLatin1String("org.bluez"), device.path(), QDBusConnection::systemBus()); + OrgBluezDeviceInterface *deviceInterface = + new OrgBluezDeviceInterface(QLatin1String("org.bluez"), device.path(), QDBusConnection::systemBus(), this); + connect(deviceInterface, SIGNAL(PropertyChanged(QString,QDBusVariant)), SLOT(_q_devicePropertyChanged(QString,QDBusVariant))); + devices << deviceInterface; - QDBusPendingReply properties = deviceInterface.asyncCall(QLatin1String("GetProperties")); + QDBusPendingReply properties = deviceInterface->asyncCall(QLatin1String("GetProperties")); properties.waitForFinished(); if (!properties.isValid()) { qCWarning(QT_BT_BLUEZ) << "Unable to get properties for device " << device.path(); @@ -525,13 +523,10 @@ void QBluetoothLocalDevicePrivate::createCache() if (properties.value().value(QLatin1String("Connected")).toBool()) connectedDevicesSet.insert(QBluetoothAddress(properties.value().value(QLatin1String("Address")).toString())); } - connectedCached = true; } QList QBluetoothLocalDevicePrivate::connectedDevices() const { - if (!connectedCached) - const_cast(this)->createCache(); return connectedDevicesSet.toList(); } diff --git a/src/bluetooth/qbluetoothlocaldevice_p.h b/src/bluetooth/qbluetoothlocaldevice_p.h index 61527d31..f00c33bf 100644 --- a/src/bluetooth/qbluetoothlocaldevice_p.h +++ b/src/bluetooth/qbluetoothlocaldevice_p.h @@ -168,8 +168,6 @@ private: QBluetoothLocalDevice *q_ptr; - bool connectedCached; - void initializeAdapter(); }; -- cgit v1.2.1 From fe0ced588437b575a6e443f8806269b044ff4f52 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Tue, 22 Apr 2014 03:00:51 -0700 Subject: Fix crash in QDeclarativeBluetoothService The crash was caused by the listen() always returning -1 because the condition m_service->socketProtocol() == UnknownProtocol was always true. Change-Id: I13725bb13db3e7000e01a80601fdcb3380710798 Reviewed-by: Alex Blasche --- .../bluetooth/qdeclarativebluetoothservice.cpp | 63 ++++++++-------------- .../bluetooth/qdeclarativebluetoothservice_p.h | 1 + 2 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp index adff13db..e246ca8d 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp @@ -102,8 +102,6 @@ public: delete m_service; } - int listen(); - bool m_componentComplete; QBluetoothServiceInfo *m_service; QDeclarativeBluetoothService::Protocol m_protocol; @@ -271,28 +269,6 @@ bool QDeclarativeBluetoothService::isRegistered() const return d->m_service->isRegistered(); } - -int QDeclarativeBluetoothServicePrivate::listen() { - - if (m_service->socketProtocol() == QBluetoothServiceInfo::UnknownProtocol) { - qCWarning(QT_BT_QML) << "Unknown protocol, can't make service" << m_protocol; - return -1; - } - QBluetoothServiceInfo::Protocol serverType = QBluetoothServiceInfo::UnknownProtocol; - if (m_service->socketProtocol() == QBluetoothServiceInfo::L2capProtocol) - serverType = QBluetoothServiceInfo::L2capProtocol; - else if (m_service->socketProtocol() == QBluetoothServiceInfo::RfcommProtocol) - serverType = QBluetoothServiceInfo::RfcommProtocol; - - QBluetoothServer *server = new QBluetoothServer(serverType); - server->setMaxPendingConnections(1); - server->listen(QBluetoothAddress()); - server->serverPort(); - m_server = server; - - return server->serverPort(); -} - void QDeclarativeBluetoothService::setRegistered(bool registered) { if (!d->m_componentComplete) { @@ -308,9 +284,21 @@ void QDeclarativeBluetoothService::setRegistered(bool registered) return; } - d->listen(); - connect(d->m_server, SIGNAL(newConnection()), this, SLOT(new_connection())); + if (d->m_protocol == UnknownProtocol) { + qCWarning(QT_BT_QML) << "Unknown protocol, can't make service" << d->m_protocol; + return; + } + + QBluetoothServer *server + = new QBluetoothServer(static_cast(d->m_protocol)); + server->setMaxPendingConnections(1); + if (!server->listen()) { + qCWarning(QT_BT_QML) << "Could not start server. Error:" << server->error(); + return; + } + d->m_server = server; + connect(d->m_server, SIGNAL(newConnection()), this, SLOT(new_connection())); d->m_service->setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010); @@ -321,7 +309,7 @@ void QDeclarativeBluetoothService::setRegistered(bool registered) //qDebug() << "name/uuid" << d->m_name << d->m_uuid << d->m_port; d->m_service->setAttribute(QBluetoothServiceInfo::BrowseGroupList, - QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup)); + QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup)); QBluetoothServiceInfo::Sequence protocolDescriptorList; QBluetoothServiceInfo::Sequence protocol; @@ -329,26 +317,19 @@ void QDeclarativeBluetoothService::setRegistered(bool registered) if (d->m_protocol == L2CapProtocol) { protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap)) << QVariant::fromValue(quint16(d->m_server->serverPort())); - protocolDescriptorList.append(QVariant::fromValue(protocol)); - } - else if (d->m_protocol == RfcommProtocol) { + } else if (d->m_protocol == RfcommProtocol) { protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm)) << QVariant::fromValue(quint8(d->m_server->serverPort())); - protocolDescriptorList.append(QVariant::fromValue(protocol)); - } - else { - qCWarning(QT_BT_QML) << "No protocol specified for bluetooth service"; } + protocolDescriptorList.append(QVariant::fromValue(protocol)); + d->m_service->setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, - protocolDescriptorList); + protocolDescriptorList); - if (d->m_service->registerService()) { + if (d->m_service->registerService()) emit registeredChanged(); - } - else { - qCWarning(QT_BT_QML) << "Register service failed"; - //TODO propaget this error to the user - } + else + qCWarning(QT_BT_QML) << "Register service failed"; // TODO: propagate this error to the user } QBluetoothServiceInfo *QDeclarativeBluetoothService::serviceInfo() const diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice_p.h b/src/imports/bluetooth/qdeclarativebluetoothservice_p.h index e7e861c7..644e8905 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothservice_p.h +++ b/src/imports/bluetooth/qdeclarativebluetoothservice_p.h @@ -68,6 +68,7 @@ class QDeclarativeBluetoothService : public QObject, public QQmlParserStatus Q_ENUMS(Protocol) public: + /// TODO: Merge/Replace with QBluetoothServiceInfo::Protocol in Qt 6 enum Protocol { RfcommProtocol = QBluetoothServiceInfo::RfcommProtocol, L2CapProtocol = QBluetoothServiceInfo::L2capProtocol, -- cgit v1.2.1 From 764780a8d30d375d21f033c7216e4c54b193a428 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Thu, 17 Apr 2014 17:04:48 +0200 Subject: Bump MODULE_VERSION to 5.3.1 Change-Id: I295b61c203f2bb43f0cc0e71da78cefb4b6ddc0c Reviewed-by: Oswald Buddenhagen --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index efd0e68f..ef45a002 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,4 +1,4 @@ load(qt_build_config) CONFIG += qt_example_installs -MODULE_VERSION = 5.3.0 +MODULE_VERSION = 5.3.1 -- cgit v1.2.1 From 8f97081dbdef48c5da61fefda104e150d7ebb25b Mon Sep 17 00:00:00 2001 From: Louai Al-Khanji Date: Thu, 24 Apr 2014 11:26:46 +0300 Subject: Remove duplicate function definition Change-Id: I1d76c50d84a0c33e56c2e197e5eb528b00082949 Reviewed-by: Alex Blasche --- src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp index 0975b966..c0c0f61a 100644 --- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp +++ b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp @@ -61,7 +61,8 @@ class MyClass : public QObject public: MyClass() : QObject() {} void localDevice(); - void startDiscovery(); + void startDeviceDiscovery(); + void startServiceDiscovery(); void objectPush(); public slots: @@ -97,7 +98,7 @@ if (localDevice.isValid()) { } //! [device_discovery] -void MyClass::startDiscovery() +void MyClass::startDeviceDiscovery() { // Create a discovery agent and connect to its signals @@ -119,13 +120,13 @@ void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device) //! [device_discovery] //! [service_discovery] -void MyClass::startDiscovery() +void MyClass::startServiceDiscovery() { // Create a discovery agent and connect to its signals QBluetoothServiceDiscoveryAgent *discoveryAgent = new QBluetoothServiceDiscoveryAgent(this); connect(discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), - this, SLOT(serviceDiscovered(QBluetoothServiceInfo)); + this, SLOT(serviceDiscovered(QBluetoothServiceInfo))); // Start a discovery discoveryAgent->start(); -- cgit v1.2.1 From 18a00cc7b236dd959cb6c2cb526c4a7b27a01de9 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 24 Apr 2014 13:20:12 +0200 Subject: Build snippet outside of example build configurations too. This is a partial revert of 9615e7fbf439d0b2b9476ea7cb15ad145e675583. The CI does not test a combined developer-build and example configuration. Ensuring the snippet compiles is mostly a private test. This patch drops the additional example condition to provide an increased chance of compiling the snippets on the CI. So far the condition never triggered and hence the CI couldn't ensure a compiling snippet. Task-number: QTBUG-37638 Change-Id: I8d815c6ddeaa2955c2824697a937d3b08729b979 Reviewed-by: Oswald Buddenhagen --- src/src.pro | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/src.pro b/src/src.pro index cf918574..e017d34b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -10,11 +10,6 @@ contains(QT_CONFIG, private_tests) { nfc_doc_snippets.subdir = nfc/doc/snippets nfc_doc_snippets.depends = nfc - !contains(QT_BUILD_PARTS, examples) { - bluetooth_doc_snippets.CONFIG = no_default_target no_default_install - nfc_doc_snippets.CONFIG = no_default_target no_default_install - } - SUBDIRS += bluetooth_doc_snippets nfc_doc_snippets } -- cgit v1.2.1 From 78022ee2e2ee417efa3fb593ea0fb0a3185caa3b Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 24 Apr 2014 14:30:50 +0200 Subject: Fix a renamed qdoc tag and improve grammar/spelling Change-Id: Iee11fdfe3b57fbe94d7e3362454851867d25e98a Reviewed-by: Leena Miettinen --- src/bluetooth/doc/src/bluetooth-overview.qdoc | 4 ++-- src/bluetooth/qbluetoothdevicediscoveryagent.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bluetooth/doc/src/bluetooth-overview.qdoc b/src/bluetooth/doc/src/bluetooth-overview.qdoc index 2afd2bd8..f8040fb8 100644 --- a/src/bluetooth/doc/src/bluetooth-overview.qdoc +++ b/src/bluetooth/doc/src/bluetooth-overview.qdoc @@ -51,7 +51,7 @@ \section1 Retrieving Local Device Information The Qt Bluetooth API has three main purposes. The first one is to - obtain local and remote device information. The first steps in retrieving device information is + obtain local and remote device information. The first steps in retrieving device information are to check if Bluetooth is available on the device and read the local device address and name. QBluetoothLocalDevice is the class that provides all of this information. Additionally you can use it to turn Bluetooth on/off, set the visibility of the device and determine the current connections. @@ -65,7 +65,7 @@ your own and fill them with data, the easier way is to use the QBluetoothDeviceDiscoveryAgent to start an automated search for visible Bluetooth devices within the connectable range. - \snippet doc_src_qtbluetooth.cpp discovery + \snippet doc_src_qtbluetooth.cpp device_discovery \section1 Pushing Files to Remote Devices diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp index fab8f965..6b959c5f 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp @@ -91,8 +91,8 @@ QT_BEGIN_NAMESPACE support it, GeneralUnlimitedInquiry will be used instead. Setting LimitedInquiry is useful for multi-player Bluetooth-based games that needs faster communication between the devices. The phone scans for devices in LimitedInquiry and Service Discovery is done on one or two devices - to speed up the service scan. After the game has connected to the device it intends to,the device - returns to GeneralUnilimitedInquiry. + to speed up the service scan. After the game has connected to the device it intended to, + the device returns to GeneralUnlimitedInquiry. */ /*! -- cgit v1.2.1 From 293af3174c5615978d842603f9a8a4a9b568236c Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Mon, 28 Apr 2014 02:09:06 -0700 Subject: Check for QT_NO_DEBUG_STREAM for QBluetoothUuid QDebug helper [ChangeLog][QtBluetooth] QDebug helper for QBluetoothUuid became aware of QT_NO_DEBUG_STREAM define. Change-Id: I20941c32560bfc6beaa8f4f465799af987d0b0cd Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothuuid.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h index 014b975a..f33d8c13 100644 --- a/src/bluetooth/qbluetoothuuid.h +++ b/src/bluetooth/qbluetoothuuid.h @@ -174,11 +174,14 @@ public: quint128 toUInt128() const; }; +#ifndef QT_NO_DEBUG_STREAM +/// TODO: Move implementation to .cpp, uninline and add Q_BLUETOOTH_EXPORT for Qt 6 inline QDebug operator<<(QDebug debug, const QBluetoothUuid &uuid) { debug << uuid.toString(); return debug; } +#endif QT_END_NAMESPACE -- cgit v1.2.1 From 4c301dfa6b4193115b6cf56ba0206a45d3a43977 Mon Sep 17 00:00:00 2001 From: Nedim Hadzic Date: Thu, 17 Apr 2014 17:39:34 +0200 Subject: 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 Reviewed-by: Fabian Bumberger --- src/bluetooth/qbluetoothserver_p.h | 6 +++ src/bluetooth/qbluetoothserver_qnx.cpp | 59 +++++++++++++++++++--- src/bluetooth/qbluetoothserviceinfo_qnx.cpp | 31 ++++++++++++ src/bluetooth/qbluetoothsocket_qnx.cpp | 77 ++++++++++++++++++++++++----- 4 files changed, 154 insertions(+), 19 deletions(-) diff --git a/src/bluetooth/qbluetoothserver_p.h b/src/bluetooth/qbluetoothserver_p.h index 4137986a..afd9d50f 100644 --- a/src/bluetooth/qbluetoothserver_p.h +++ b/src/bluetooth/qbluetoothserver_p.h @@ -97,6 +97,10 @@ public: QBluetoothServiceInfo::Protocol serverType; #ifdef QT_QNX_BLUETOOTH +#ifdef QT_QNX_BT_BLUETOOTH + static void btCallback(long param, int socket); + Q_INVOKABLE void setBtCallbackParameters(int receivedSocket); +#endif QList activeSockets; QString m_serviceName; #endif @@ -112,8 +116,10 @@ private: QString nextClientAddress; private Q_SLOTS: +#ifndef QT_QNX_BT_BLUETOOTH void controlReply(ppsResult result); void controlEvent(ppsResult result); +#endif #elif defined(QT_BLUEZ_BLUETOOTH) QSocketNotifier *socketNotifier; #elif defined(QT_ANDROID_BLUETOOTH) 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 #include - +#ifdef QT_QNX_BT_BLUETOOTH +#include +#endif QT_BEGIN_NAMESPACE extern QHash __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(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; } diff --git a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp index 30dac958..8767889b 100644 --- a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp +++ b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp @@ -45,6 +45,11 @@ #include "qbluetoothserver_p.h" #include "qbluetoothserver.h" +#ifdef QT_QNX_BT_BLUETOOTH +#include +#include +#endif + QT_BEGIN_NAMESPACE QBluetoothServiceInfoPrivate::QBluetoothServiceInfoPrivate() @@ -70,11 +75,19 @@ bool QBluetoothServiceInfoPrivate::unregisterService() if (serverChannel() == -1) return false; if ( __fakeServerPorts.key(serverChannel()) != 0) { +#ifdef QT_QNX_BT_BLUETOOTH + QByteArray b_uuid = attributes.value(QBluetoothServiceInfo::ServiceId). + value().toByteArray(); + b_uuid = b_uuid.mid(1, b_uuid.length() - 2); + if (bt_spp_close_server(b_uuid.data()) == -1) + return false; +#else if (!ppsSendControlMessage("deregister_server", 0x1101, attributes.value(QBluetoothServiceInfo::ServiceId).value(), QString(), attributes.value(QBluetoothServiceInfo::ServiceName).toString(), __fakeServerPorts.key(serverChannel()), BT_SPP_SERVER_SUBTYPE)) { return false; } +#endif else { __fakeServerPorts.remove(__fakeServerPorts.key(serverChannel())); registered = false; @@ -98,10 +111,28 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress& loca return false; if (__fakeServerPorts.key(serverChannel()) != 0) { +#ifdef QT_QNX_BT_BLUETOOTH + QByteArray b_uuid = attributes.value(QBluetoothServiceInfo::ServiceId) + .value().toByteArray(); + b_uuid = b_uuid.mid(1, b_uuid.length() - 2); + qCDebug(QT_BT_QNX) << "Registering server. " << b_uuid.data() + << attributes.value(QBluetoothServiceInfo::ServiceName) + .toString(); + if (bt_spp_open_server(attributes.value(QBluetoothServiceInfo::ServiceName) + .toString().toUtf8().data(), + b_uuid.data(), true, &QBluetoothServerPrivate::btCallback, + reinterpret_cast(__fakeServerPorts.key(serverChannel()))) == -1) { + qCDebug(QT_BT_QNX) << "Could not open the server. " + << qt_error_string(errno) << errno; + bt_spp_close_server(b_uuid.data()); + return false; + } +#else if (!ppsSendControlMessage("register_server", 0x1101, attributes.value(QBluetoothServiceInfo::ServiceId).value(), QString(), attributes.value(QBluetoothServiceInfo::ServiceName).toString(), __fakeServerPorts.key(serverChannel()), BT_SPP_SERVER_SUBTYPE)) return false; +#endif //The server needs to know the service name for the socket mount point path __fakeServerPorts.key(serverChannel())->m_serviceName = attributes.value(QBluetoothServiceInfo::ServiceName).toString(); } else { diff --git a/src/bluetooth/qbluetoothsocket_qnx.cpp b/src/bluetooth/qbluetoothsocket_qnx.cpp index 4deb4f84..c54a0937 100644 --- a/src/bluetooth/qbluetoothsocket_qnx.cpp +++ b/src/bluetooth/qbluetoothsocket_qnx.cpp @@ -43,8 +43,15 @@ #include "qbluetoothsocket_p.h" #include "qbluetoothlocaldevice.h" #include +#ifdef QT_QNX_BT_BLUETOOTH +#include +#include +#endif QT_BEGIN_NAMESPACE +#ifdef QT_QNX_BT_BLUETOOTH +static int initCounter = 0; +#endif QBluetoothSocketPrivate::QBluetoothSocketPrivate() : socket(-1), @@ -57,12 +64,28 @@ QBluetoothSocketPrivate::QBluetoothSocketPrivate() discoveryAgent(0), isServerSocket(false) { +#ifdef QT_QNX_BT_BLUETOOTH + if (!initCounter && (bt_spp_init() == -1)) + qCDebug(QT_BT_QNX) << "Could not initialize Bluetooth library. " + << qt_error_string(errno); + + initCounter++; +#else ppsRegisterControl(); +#endif } QBluetoothSocketPrivate::~QBluetoothSocketPrivate() { +#ifdef QT_QNX_BT_BLUETOOTH + if (initCounter == 1 && (bt_spp_deinit() == -1)) + qCDebug(QT_BT_QNX) << "Could not deinitialize Bluetooth library." + "SPP connection is still open."; + + initCounter--; +#else ppsUnregisterControl(this); +#endif close(); } @@ -79,27 +102,47 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid, QIODevice::OpenMode openMode) { + Q_Q(QBluetoothSocket); Q_UNUSED(openMode); qCDebug(QT_BT_QNX) << "Connecting socket"; - if (isServerSocket) { - m_peerAddress = address; - m_uuid = uuid; + + m_peerAddress = address; +#ifdef QT_QNX_BT_BLUETOOTH + QByteArray b_uuid = uuid.toByteArray(); + b_uuid = b_uuid.mid(1, b_uuid.length() - 2); + socket = bt_spp_open(address.toString().toUtf8().data(), b_uuid.data(), false); + if (socket == -1) { + qCWarning(QT_BT_QNX) << "Could not connect to" << address.toString() << b_uuid << qt_error_string(errno); + errorString = qt_error_string(errno); + q->setSocketError(QBluetoothSocket::NetworkError); return; } + delete readNotifier; + delete connectWriteNotifier; + + readNotifier = new QSocketNotifier(socket, QSocketNotifier::Read); + QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_readNotify())); + connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q); + QObject::connect(connectWriteNotifier, SIGNAL(activated(int)), q, SLOT(_q_writeNotify())); + + connecting = true; + q->setOpenMode(openMode); +#else + m_uuid = uuid; + if (isServerSocket) + return; + if (state != QBluetoothSocket::UnconnectedState) { qCDebug(QT_BT_QNX) << "Socket already connected"; return; } - state = QBluetoothSocket::ConnectingState; - - m_uuid = uuid; - m_peerAddress = address; ppsSendControlMessage("connect_service", 0x1101, uuid, address.toString(), QString(), this, BT_SPP_CLIENT_SUBTYPE); ppsRegisterForEvent(QStringLiteral("service_connected"),this); ppsRegisterForEvent(QStringLiteral("get_mount_point_path"),this); - socketType = QBluetoothServiceInfo::RfcommProtocol; +#endif + q->setSocketState(QBluetoothSocket::ConnectingState); } void QBluetoothSocketPrivate::_q_writeNotify() @@ -166,9 +209,16 @@ void QBluetoothSocketPrivate::abort() { Q_Q(QBluetoothSocket); qCDebug(QT_BT_QNX) << "Disconnecting service"; +#ifdef QT_QNX_BT_BLUETOOTH + if (isServerSocket) + bt_spp_close_server(m_uuid.toString().toUtf8().data()); + else + bt_spp_close(socket); +#else if (q->state() != QBluetoothSocket::ClosingState) ppsSendControlMessage("disconnect_service", 0x1101, m_uuid, m_peerAddress.toString(), QString(), 0, isServerSocket ? BT_SPP_SERVER_SUBTYPE : BT_SPP_CLIENT_SUBTYPE); +#endif delete readNotifier; readNotifier = 0; delete connectWriteNotifier; @@ -282,11 +332,6 @@ bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoo socket = socketDescriptor; socketType = socketType_; - // ensure that O_NONBLOCK is set on new connections. - int flags = fcntl(socket, F_GETFL, 0); - if (!(flags & O_NONBLOCK)) - fcntl(socket, F_SETFL, flags | O_NONBLOCK); - readNotifier = new QSocketNotifier(socket, QSocketNotifier::Read); QObject::connect(readNotifier, SIGNAL(activated(int)), q, SLOT(_q_readNotify())); connectWriteNotifier = new QSocketNotifier(socket, QSocketNotifier::Write, q); @@ -299,7 +344,9 @@ bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoo emit q->connected(); isServerSocket = true; +#ifndef QT_QNX_BT_BLUETOOTH ppsRegisterForEvent(QStringLiteral("service_disconnected"),this); +#endif return true; } @@ -311,6 +358,7 @@ qint64 QBluetoothSocketPrivate::bytesAvailable() const void QBluetoothSocketPrivate::controlReply(ppsResult result) { +#ifndef QT_QNX_BT_BLUETOOTH Q_Q(QBluetoothSocket); if (result.msg == QStringLiteral("connect_service")) { @@ -361,15 +409,18 @@ void QBluetoothSocketPrivate::controlReply(ppsResult result) ppsRegisterForEvent(QStringLiteral("service_disconnected"),this); } } +#endif } void QBluetoothSocketPrivate::controlEvent(ppsResult result) { +#ifndef QT_QNX_BT_BLUETOOTH Q_Q(QBluetoothSocket); if (result.msg == QStringLiteral("service_disconnected")) { q->setSocketState(QBluetoothSocket::ClosingState); close(); } +#endif } QT_END_NAMESPACE -- cgit v1.2.1 From ef7de5da3d4d2346ec7110413c8fb12db8c94013 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 5 May 2014 13:25:32 +0200 Subject: Add missing classname tag to Bluetooth and NFC qml module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is required for static builds. Change-Id: Ia6861685ff2845dc6c3998079cf10019ea9fbdd7 Reviewed-by: Tor Arne Vestbø --- src/imports/bluetooth/qmldir | 1 + src/imports/nfc/qmldir | 1 + 2 files changed, 2 insertions(+) diff --git a/src/imports/bluetooth/qmldir b/src/imports/bluetooth/qmldir index 159d2422..2f5b2fac 100644 --- a/src/imports/bluetooth/qmldir +++ b/src/imports/bluetooth/qmldir @@ -1,3 +1,4 @@ module QtBluetooth plugin declarative_bluetooth +classname QBluetoothQmlPlugin typeinfo plugins.qmltypes diff --git a/src/imports/nfc/qmldir b/src/imports/nfc/qmldir index 3afa926d..0025f3e6 100644 --- a/src/imports/nfc/qmldir +++ b/src/imports/nfc/qmldir @@ -1,3 +1,4 @@ module QtNfc plugin declarative_nfc +classname QNfcQmlPlugin typeinfo plugins.qmltypes -- cgit v1.2.1