summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-05-08 09:51:40 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-05-08 09:51:40 +0200
commit94445dd4b9a6754a63736a05b9bccaaffc0a4038 (patch)
treefedeb79f2a583da4935fcd8fc5f70298812c056d
parent74449f1b0b2952dcbad9525c167b36fbf908696f (diff)
parentef7de5da3d4d2346ec7110413c8fb12db8c94013 (diff)
downloadqtconnectivity-94445dd4b9a6754a63736a05b9bccaaffc0a4038.tar.gz
Merge branch 'stable' into dev
Conflicts: .qmake.conf src/bluetooth/qbluetoothlocaldevice_bluez.cpp src/bluetooth/qbluetoothserver_p.h src/bluetooth/qbluetoothsocket_qnx.cpp Change-Id: I08792f10155f9b4e6af30066b70e24b48985ddd6
-rw-r--r--dist/changes-5.3.0154
-rw-r--r--examples/bluetooth/btchat/doc/src/btchat.qdoc7
-rw-r--r--examples/bluetooth/btchat/remoteselector.cpp2
-rw-r--r--examples/bluetooth/btfiletransfer/doc/src/btfiletransfer.qdoc7
-rw-r--r--examples/bluetooth/btscanner/doc/src/btscanner.qdoc9
-rw-r--r--examples/bluetooth/picturetransfer/doc/src/picturetransfer.qdoc40
-rw-r--r--examples/bluetooth/pingpong/doc/src/pingpong.qdoc6
-rw-r--r--examples/bluetooth/scanner/doc/src/scanner.qdoc5
-rw-r--r--examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc14
-rw-r--r--examples/nfc/corkboard/doc/src/corkboard.qdoc9
-rw-r--r--examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc12
-rw-r--r--examples/nfc/poster/doc/src/poster.qdoc13
-rw-r--r--src/bluetooth/android/servicediscoverybroadcastreceiver.cpp6
-rw-r--r--src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp34
-rw-r--r--src/bluetooth/doc/src/bluetooth-overview.qdoc4
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.cpp6
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp48
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_p.h2
-rw-r--r--src/bluetooth/qbluetoothserver_p.h6
-rw-r--r--src/bluetooth/qbluetoothserver_qnx.cpp59
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp2
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_android.cpp23
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp23
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_qnx.cpp31
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp9
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez.cpp25
-rw-r--r--src/bluetooth/qbluetoothsocket_qnx.cpp79
-rw-r--r--src/bluetooth/qbluetoothuuid.h3
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp1
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice.cpp63
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice_p.h1
-rw-r--r--src/imports/bluetooth/qmldir1
-rw-r--r--src/imports/nfc/qmldir1
-rw-r--r--src/src.pro6
34 files changed, 548 insertions, 163 deletions
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.
+
+
+
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/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);
}
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 <mccarthy.aaron@gmail.com>
** 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}
*/
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<jstring>());
- if (!parcelableUuids.isValid())
+ if (!parcelableUuids.isValid()) {
+ emit uuidFetchFinished(QBluetoothAddress(), QList<QBluetoothUuid>());
return;
+ }
const QList<QBluetoothUuid> 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<jstring>("getAddress").toString());
emit uuidFetchFinished(address, result);
+ } else {
+ emit uuidFetchFinished(QBluetoothAddress(), QList<QBluetoothUuid>());
}
}
}
diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
index 88520c35..c0c0f61a 100644
--- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
+++ b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
@@ -46,6 +46,7 @@
#include <QtCore/QFile>
#include <QtCore/QObject>
#include <QtBluetooth/QBluetoothDeviceDiscoveryAgent>
+#include <QtBluetooth/QBluetoothServiceDiscoveryAgent>
#include <QtBluetooth/QBluetoothTransferManager>
#include <QtBluetooth/QBluetoothTransferRequest>
#include <QtBluetooth/QBluetoothTransferReply>
@@ -60,11 +61,13 @@ class MyClass : public QObject
public:
MyClass() : QObject() {}
void localDevice();
- void startDiscovery();
+ void startDeviceDiscovery();
+ void startServiceDiscovery();
void objectPush();
public slots:
void deviceDiscovered(const QBluetoothDeviceInfo &device);
+ void serviceDiscovered(const QBluetoothServiceInfo &service);
void transferFinished(QBluetoothTransferReply* reply);
};
@@ -94,8 +97,8 @@ if (localDevice.isValid()) {
}
-//! [discovery]
-void MyClass::startDiscovery()
+//! [device_discovery]
+void MyClass::startDeviceDiscovery()
{
// Create a discovery agent and connect to its signals
@@ -114,7 +117,30 @@ void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device)
{
qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')';
}
-//! [discovery]
+//! [device_discovery]
+
+//! [service_discovery]
+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)));
+
+ // 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/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 2c2cba11..0afca649 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.
@@ -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.
*/
/*!
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
index b9117ac8..6abcb2f8 100644
--- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
@@ -648,8 +648,7 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate(QBluetoothLocalDevice
discoveryWasAlreadyActive(true),
pendingHostModeChange(-1),
msgConnection(0),
- q_ptr(q),
- connectedCached(false)
+ q_ptr(q)
{
if (isBluez5())
initializeAdapterBluez5();
@@ -662,6 +661,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)),
@@ -978,7 +978,8 @@ void QBluetoothLocalDevicePrivate::_q_deviceCreated(const QDBusObjectPath &devic
{
OrgBluezDeviceInterface *deviceInterface
= new OrgBluezDeviceInterface(QLatin1String("org.bluez"),
- device.path(), QDBusConnection::systemBus());
+ device.path(),
+ QDBusConnection::systemBus(), this);
connect(deviceInterface, SIGNAL(PropertyChanged(QString, QDBusVariant)),
SLOT(_q_devicePropertyChanged(QString, QDBusVariant)));
devices << deviceInterface;
@@ -994,16 +995,13 @@ void QBluetoothLocalDevicePrivate::_q_deviceCreated(const QDBusObjectPath &devic
= 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)
@@ -1033,16 +1031,13 @@ void QBluetoothLocalDevicePrivate::_q_devicePropertyChanged(const QString &prope
= 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);
+ }
}
}
@@ -1058,11 +1053,16 @@ 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<QVariantMap> properties
- = deviceInterface.asyncCall(QLatin1String("GetProperties"));
+ = deviceInterface->asyncCall(QLatin1String("GetProperties"));
properties.waitForFinished();
if (!properties.isValid()) {
qCWarning(QT_BT_BLUEZ) << "Unable to get properties for device " << device.path();
@@ -1074,14 +1074,10 @@ void QBluetoothLocalDevicePrivate::createCache()
QBluetoothAddress(properties.value().value(QLatin1String("Address")).toString()));
}
}
- connectedCached = true;
}
QList<QBluetoothAddress> QBluetoothLocalDevicePrivate::connectedDevices() const
{
- if (adapter && !connectedCached)
- const_cast<QBluetoothLocalDevicePrivate *>(this)->createCache();
-
return connectedDevicesSet.toList();
}
diff --git a/src/bluetooth/qbluetoothlocaldevice_p.h b/src/bluetooth/qbluetoothlocaldevice_p.h
index 7fc82e2f..33f813e1 100644
--- a/src/bluetooth/qbluetoothlocaldevice_p.h
+++ b/src/bluetooth/qbluetoothlocaldevice_p.h
@@ -193,8 +193,6 @@ private:
QBluetoothLocalDevice *q_ptr;
- bool connectedCached;
-
void initializeAdapter();
void initializeAdapterBluez5();
};
diff --git a/src/bluetooth/qbluetoothserver_p.h b/src/bluetooth/qbluetoothserver_p.h
index 1a620645..492ad489 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<QBluetoothSocket *> activeSockets;
QString m_serviceName;
#endif
@@ -112,8 +116,10 @@ private:
QString nextClientAddress;
private 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 <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;
}
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
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
index 2e55d40e..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();
@@ -416,7 +422,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 +450,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));
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";
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 <btapi/btspp.h>
+#include <errno.h>
+#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<QBluetoothUuid>().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<QBluetoothUuid>(), 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<QBluetoothUuid>().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<long>(__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<QBluetoothUuid>(), 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.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..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;
@@ -226,6 +232,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);
@@ -238,11 +245,8 @@ void QBluetoothSocketPrivate::_q_readNotify()
q->setSocketError(QBluetoothSocket::UnknownSocketError);
q->disconnectFromService();
- q->setSocketState(QBluetoothSocket::UnconnectedState);
}
else {
- buffer.chop(QPRIVATELINEARBUFFER_BUFFERSIZE - (readFromDevice < 0 ? 0 : readFromDevice));
-
emit q->readyRead();
}
}
@@ -259,9 +263,6 @@ void QBluetoothSocketPrivate::abort()
// QBluetoothSocket::close
QT_CLOSE(socket);
socket = -1;
-
- Q_Q(QBluetoothSocket);
- emit q->disconnected();
}
QString QBluetoothSocketPrivate::localName() const
@@ -508,17 +509,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 6e5c26ec..10f08aa5 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 <sys/stat.h>
+#ifdef QT_QNX_BT_BLUETOOTH
+#include <errno.h>
+#include <btapi/btspp.h>
+#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;
@@ -176,8 +226,6 @@ void QBluetoothSocketPrivate::abort()
::close(socket);
- q->setSocketState(QBluetoothSocket::UnconnectedState);
- emit q->disconnected();
isServerSocket = false;
}
@@ -284,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);
@@ -301,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;
}
@@ -313,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")) {
@@ -363,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
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
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
index bb1d327c..d4974967 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));
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<QBluetoothServiceInfo::Protocol>(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,
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
diff --git a/src/src.pro b/src/src.pro
index 6ab12bda..e017d34b 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -3,14 +3,14 @@ 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
+
+ SUBDIRS += bluetooth_doc_snippets nfc_doc_snippets
}
qtHaveModule(quick) {