summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-10-22 11:37:08 +0200
committerAlex Blasche <alexander.blasche@digia.com>2013-10-22 11:39:44 +0200
commitb00388ea1448cfd977c54f53d038d1a270562d53 (patch)
treec6097a3d9ce61d0da5e2a5a4e977250aa5e376ed
parent672413c65685883136f4572d34f7d08f7b952641 (diff)
parent782a09be7c89352b27083bca7ee5b032d9e56ca6 (diff)
Merge branch 'stable' into dev
-rw-r--r--.gitattributes7
-rw-r--r--examples/bluetooth/btchat/chat.cpp50
-rw-r--r--examples/bluetooth/btchat/chat.h6
-rw-r--r--examples/bluetooth/btchat/chat.ui26
-rw-r--r--examples/bluetooth/btchat/chatclient.cpp2
-rw-r--r--examples/bluetooth/btchat/chatserver.cpp23
-rw-r--r--examples/bluetooth/btchat/chatserver.h3
-rw-r--r--examples/bluetooth/btchat/doc/src/btchat.qdoc82
-rw-r--r--examples/bluetooth/btchat/remoteselector.cpp20
-rw-r--r--examples/bluetooth/btchat/remoteselector.h2
-rw-r--r--examples/bluetooth/scanner/scanner.qml9
-rw-r--r--examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc4
-rw-r--r--examples/nfc/poster/doc/src/poster.qdoc4
-rw-r--r--examples/nfc/poster/poster.qml6
-rw-r--r--src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml2
-rw-r--r--src/bluetooth/doc/src/bluetooth-cpp.qdoc4
-rw-r--r--src/bluetooth/doc/src/bluetooth-overview.qdoc8
-rw-r--r--src/bluetooth/doc/src/bluetooth-qml.qdoc8
-rw-r--r--src/bluetooth/doc/src/examples.qdoc13
-rw-r--r--src/bluetooth/qbluetoothserver.cpp3
-rw-r--r--src/bluetooth/qbluetoothserver_bluez.cpp1
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp26
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.h1
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_p.h1
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp25
-rw-r--r--src/bluetooth/qbluetoothserviceinfo.cpp49
-rw-r--r--src/bluetooth/qbluetoothserviceinfo.h5
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_bluez.cpp43
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_p.cpp17
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_p.h14
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_qnx.cpp20
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp4
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez.cpp9
-rw-r--r--src/bluetooth/qbluetoothsocket_qnx.cpp2
-rw-r--r--src/bluetooth/qbluetoothtransferreply_bluez.cpp10
-rw-r--r--src/bluetooth/qbluetoothtransferreply_qnx.cpp23
-rw-r--r--src/bluetooth/qbluetoothtransferrequest.h2
-rw-r--r--src/bluetooth/qbluetoothuuid.cpp4
-rw-r--r--src/bluetooth/qprivatelinearbuffer_p.h2
-rw-r--r--src/imports/bluetooth/plugin.cpp20
-rw-r--r--src/imports/bluetooth/plugins.qmltypes124
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp58
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h4
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice.cpp222
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice_p.h30
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothsocket.cpp53
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothsocket_p.h7
-rw-r--r--src/imports/nfc/plugin.cpp17
-rw-r--r--src/imports/nfc/plugins.qmltypes81
-rw-r--r--src/imports/nfc/qdeclarativendeffilter.cpp21
-rw-r--r--src/imports/nfc/qdeclarativendeffilter_p.h8
-rw-r--r--src/imports/nfc/qdeclarativendefmimerecord.cpp11
-rw-r--r--src/imports/nfc/qdeclarativendefmimerecord_p.h4
-rw-r--r--src/imports/nfc/qdeclarativendeftextrecord.cpp11
-rw-r--r--src/imports/nfc/qdeclarativendeftextrecord_p.h4
-rw-r--r--src/imports/nfc/qdeclarativendefurirecord.cpp11
-rw-r--r--src/imports/nfc/qdeclarativendefurirecord_p.h4
-rw-r--r--src/imports/nfc/qdeclarativenearfield.cpp68
-rw-r--r--src/imports/nfc/qdeclarativenearfield_p.h20
-rw-r--r--src/imports/nfc/qdeclarativenearfieldsocket.cpp7
-rw-r--r--src/nfc/doc/snippets/doc_src_qtnfc.qml2
-rw-r--r--src/nfc/doc/snippets/foorecord.cpp16
-rw-r--r--src/nfc/doc/snippets/foorecord.h10
-rw-r--r--src/nfc/doc/src/examples.qdoc6
-rw-r--r--src/nfc/doc/src/nfc-cpp.qdoc2
-rw-r--r--src/nfc/doc/src/nfc-index.qdoc4
-rw-r--r--src/nfc/doc/src/nfc-overview.qdoc8
-rw-r--r--src/nfc/doc/src/nfc-qml.qdoc6
-rw-r--r--src/nfc/nfc.pro4
-rw-r--r--src/nfc/qndefrecord.cpp2
-rw-r--r--src/nfc/qndefrecord_p.h7
-rw-r--r--src/nfc/qnearfieldmanager.cpp15
-rw-r--r--src/nfc/qnearfieldmanager.h11
-rw-r--r--src/nfc/qnx/qnxnfcmanager.cpp9
-rw-r--r--src/nfc/qqmlndefrecord.cpp (renamed from src/nfc/qdeclarativendefrecord.cpp)167
-rw-r--r--src/nfc/qqmlndefrecord.h (renamed from src/nfc/qdeclarativendefrecord.h)43
-rw-r--r--sync.profile1
-rw-r--r--tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp81
-rw-r--r--tests/auto/qndefrecord/tst_qndefrecord.cpp109
79 files changed, 1019 insertions, 809 deletions
diff --git a/.gitattributes b/.gitattributes
index a96f8f54..1a045fa1 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,4 @@
-.tag export-subst
-.gitignore export-ignore
-.gitattributes export-ignore
+.tag export-subst
+.gitignore export-ignore
+.gitattributes export-ignore
+.commit-template export-ignore
diff --git a/examples/bluetooth/btchat/chat.cpp b/examples/bluetooth/btchat/chat.cpp
index 37bfb85c..f3df7aa1 100644
--- a/examples/bluetooth/btchat/chat.cpp
+++ b/examples/bluetooth/btchat/chat.cpp
@@ -56,7 +56,7 @@
static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8");
Chat::Chat(QWidget *parent)
-: QDialog(parent), ui(new Ui_Chat)
+ : QDialog(parent), currentAdapterIndex(0), ui(new Ui_Chat)
{
//! [Construct UI]
ui->setupUi(this);
@@ -66,6 +66,22 @@ Chat::Chat(QWidget *parent)
connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendClicked()));
//! [Construct UI]
+ localAdapters = QBluetoothLocalDevice::allDevices();
+ if (localAdapters.count() < 2) {
+ ui->localAdapterBox->setVisible(false);
+ } else {
+ //we ignore more than two adapters
+ ui->localAdapterBox->setVisible(true);
+ ui->firstAdapter->setText(tr("Default (%1)", "%1 = Bluetooth address").
+ arg(localAdapters.at(0).address().toString()));
+ ui->secondAdapter->setText(localAdapters.at(1).address().toString());
+ ui->firstAdapter->setChecked(true);
+ connect(ui->firstAdapter, SIGNAL(clicked()), this, SLOT(newAdapterSelected()));
+ connect(ui->secondAdapter, SIGNAL(clicked()), this, SLOT(newAdapterSelected()));
+ QBluetoothLocalDevice adapter(localAdapters.at(0).address());
+ adapter.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
+ }
+
//! [Create Chat Server]
server = new ChatServer(this);
connect(server, SIGNAL(clientConnected(QString)), this, SLOT(clientConnected(QString)));
@@ -104,6 +120,32 @@ void Chat::connected(const QString &name)
{
ui->chat->insertPlainText(QString::fromLatin1("Joined chat with %1.\n").arg(name));
}
+
+void Chat::newAdapterSelected()
+{
+ const int newAdapterIndex = adapterFromUserSelection();
+ if (currentAdapterIndex != newAdapterIndex) {
+ server->stopServer();
+ currentAdapterIndex = newAdapterIndex;
+ const QBluetoothHostInfo info = localAdapters.at(currentAdapterIndex);
+ QBluetoothLocalDevice adapter(info.address());
+ adapter.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
+ server->startServer(info.address());
+ localName = info.name();
+ }
+}
+
+int Chat::adapterFromUserSelection() const
+{
+ int result = 0;
+ QBluetoothAddress newAdapter = localAdapters.at(0).address();
+
+ if (ui->secondAdapter->isChecked()) {
+ newAdapter = localAdapters.at(1).address();
+ result = 1;
+ }
+ return result;
+}
//! [connected]
//! [clientDisconnected]
@@ -123,7 +165,11 @@ void Chat::connectClicked()
ui->connectButton->setEnabled(false);
// scan for services
- RemoteSelector remoteSelector;
+ const QBluetoothAddress adapter = localAdapters.isEmpty() ?
+ QBluetoothAddress() :
+ localAdapters.at(currentAdapterIndex).address();
+
+ RemoteSelector remoteSelector(adapter);
remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid));
if (remoteSelector.exec() == QDialog::Accepted) {
QBluetoothServiceInfo service = remoteSelector.service();
diff --git a/examples/bluetooth/btchat/chat.h b/examples/bluetooth/btchat/chat.h
index fed850f1..75d7669f 100644
--- a/examples/bluetooth/btchat/chat.h
+++ b/examples/bluetooth/btchat/chat.h
@@ -44,6 +44,7 @@
#include <qbluetoothserviceinfo.h>
#include <qbluetoothsocket.h>
+#include <qbluetoothhostinfo.h>
#include <QDebug>
@@ -75,11 +76,16 @@ private slots:
void clientDisconnected();
void connected(const QString &name);
+ void newAdapterSelected();
+
private:
+ int adapterFromUserSelection() const;
+ int currentAdapterIndex;
Ui_Chat *ui;
ChatServer *server;
QList<ChatClient *> clients;
+ QList<QBluetoothHostInfo> localAdapters;
QString localName;
};
diff --git a/examples/bluetooth/btchat/chat.ui b/examples/bluetooth/btchat/chat.ui
index acebc937..d7829294 100644
--- a/examples/bluetooth/btchat/chat.ui
+++ b/examples/bluetooth/btchat/chat.ui
@@ -15,6 +15,32 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
+ <widget class="QGroupBox" name="localAdapterBox">
+ <property name="title">
+ <string>Local Bluetooth Adapter</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QRadioButton" name="firstAdapter">
+ <property name="text">
+ <string>Default</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="secondAdapter">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QTextEdit" name="chat">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
diff --git a/examples/bluetooth/btchat/chatclient.cpp b/examples/bluetooth/btchat/chatclient.cpp
index b6ba7c52..06930145 100644
--- a/examples/bluetooth/btchat/chatclient.cpp
+++ b/examples/bluetooth/btchat/chatclient.cpp
@@ -62,7 +62,7 @@ void ChatClient::startClient(const QBluetoothServiceInfo &remoteService)
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
qDebug() << "Create socket";
socket->connectToService(remoteService);
- qDebug() << "ConnecttoService done";
+ qDebug() << "ConnectToService done";
connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
connect(socket, SIGNAL(connected()), this, SLOT(connected()));
diff --git a/examples/bluetooth/btchat/chatserver.cpp b/examples/bluetooth/btchat/chatserver.cpp
index 863078fc..0b29b87b 100644
--- a/examples/bluetooth/btchat/chatserver.cpp
+++ b/examples/bluetooth/btchat/chatserver.cpp
@@ -42,6 +42,7 @@
#include <qbluetoothserver.h>
#include <qbluetoothsocket.h>
+#include <qbluetoothlocaldevice.h>
//! [Service UUID]
static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8");
@@ -57,7 +58,7 @@ ChatServer::~ChatServer()
stopServer();
}
-void ChatServer::startServer()
+void ChatServer::startServer(const QBluetoothAddress& localAdapter)
{
if (rfcommServer)
return;
@@ -65,14 +66,23 @@ void ChatServer::startServer()
//! [Create the server]
rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
- rfcommServer->listen();
+ bool result = rfcommServer->listen(localAdapter);
+ if (!result) {
+ qWarning() << "Cannot bind chat server to" << localAdapter.toString();
+ return;
+ }
//! [Create the server]
- serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
+ //serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
//! [Class Uuuid must contain at least 1 entry]
QBluetoothServiceInfo::Sequence classId;
- classId << QVariant::fromValue(QBluetoothUuid(serviceUuid));
+
+ classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList,
+ classId);
+
+ classId.prepend(QVariant::fromValue(QBluetoothUuid(serviceUuid)));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
//! [Class Uuuid must contain at least 1 entry]
@@ -81,7 +91,7 @@ void ChatServer::startServer()
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Bt Chat Server"));
serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,
tr("Example bluetooth chat server"));
- serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("Nokia, QtDF"));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("qt-project.org"));
//! [Service name, description and provider]
//! [Service UUID set]
@@ -107,7 +117,7 @@ void ChatServer::startServer()
//! [Protocol descriptor list]
//! [Register service]
- serviceInfo.registerService();
+ serviceInfo.registerService(localAdapter);
//! [Register service]
}
@@ -146,7 +156,6 @@ void ChatServer::clientConnected()
connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
clientSockets.append(socket);
-
emit clientConnected(socket->peerName());
}
//! [clientConnected]
diff --git a/examples/bluetooth/btchat/chatserver.h b/examples/bluetooth/btchat/chatserver.h
index 2a3c3503..8af21f55 100644
--- a/examples/bluetooth/btchat/chatserver.h
+++ b/examples/bluetooth/btchat/chatserver.h
@@ -42,6 +42,7 @@
#define CHATSERVER_H
#include <qbluetoothserviceinfo.h>
+#include <qbluetoothaddress.h>
#include <QtCore/QObject>
#include <QtCore/QList>
@@ -60,7 +61,7 @@ public:
explicit ChatServer(QObject *parent = 0);
~ChatServer();
- void startServer();
+ void startServer(const QBluetoothAddress &localAdapter = QBluetoothAddress());
void stopServer();
public slots:
diff --git a/examples/bluetooth/btchat/doc/src/btchat.qdoc b/examples/bluetooth/btchat/doc/src/btchat.qdoc
index 6f1f040d..77f73fd1 100644
--- a/examples/bluetooth/btchat/doc/src/btchat.qdoc
+++ b/examples/bluetooth/btchat/doc/src/btchat.qdoc
@@ -34,36 +34,36 @@
\image btchat-example.png
- The Bluetooth Chat example implements a simple chat program between multiple parties. The
+ The Bluetooth Chat example implements a simple chat program between multiple parties. The
application always acts as both a server and a client eliminating the need to determine who
should connect to whom.
\section1 Chat Server
- The chat server is implemented by the ChatServer class. The ChatServer class is declared as:
+ The chat server is implemented by the ChatServer class. The ChatServer class is declared as:
\snippet btchat/chatserver.h declaration
The first thing the chat server needs to do is create an instance of QRfcommServer to listen
- for incoming Bluetooth connections. Our clientConnected() slot will be called whenever a new
+ for incoming Bluetooth connections. Our clientConnected() slot will be called whenever a new
connection is created.
\snippet btchat/chatserver.cpp Create the server
- The chat server is only useful if others know that it is there. To enable other devices to
- discover it a record describing the service needs to be published in the systems SDP (Service
- Discovery Protocol) database. The QBluetoothServiceInfo class encapsulates a service record.
+ The chat server is only useful if others know that it is there. To enable other devices to
+ discover it, a record describing the service needs to be published in the systems SDP (Service
+ Discovery Protocol) database. The QBluetoothServiceInfo class encapsulates a service record.
We will publish a service record that contains some textural descriptions of the services, a
- UUID that uniquely identifies the service, the discoverability attribute and connection
+ UUID that uniquely identifies the service, the discoverability attribute, and connection
parameters.
- The textural description of the service is stored in the ServiceName, ServiceDescription and
+ The textural description of the service is stored in the ServiceName, ServiceDescription, and
ServiceProvider attributes.
\snippet btchat/chatserver.cpp Service name, description and provider
- Bluetooth uses UUIDs as unique identifiers. Our chat service is uses a randomly generated
+ Bluetooth uses UUIDs as unique identifiers. The chat service uses a randomly generated
UUID.
\snippet btchat/chatserver.cpp Service UUID
@@ -74,78 +74,78 @@
\snippet btchat/chatserver.cpp Service Discoverability
The ProtocolDescriptorList attribute is used to publish the connection parameters that the
- remote device requires to connect to our service. Here we specify that the Rfcomm protocol is
- used and set the port number to port that our rfcommServer instance is listening to.
+ remote device requires to connect to our service. Here we specify that the Rfcomm protocol is
+ used and set the port number to the port that our rfcommServer instance is listening to.
\snippet btchat/chatserver.cpp Protocol descriptor list
- Finally we register the service record with the system.
+ Finally, we register the service record with the system.
\snippet btchat/chatserver.cpp Register service
- As mentioned earlier incoming connections are handled in the clientConnected() slot. In this
- slot we get a pointer a QBluetoothSocket representing the next pending connection connect up
- slots to the readyRead() and disconnected() signals and emit a signal to notify others that a
- new client has connected.
+
+ As mentioned earlier, incoming connections are handled in the clientConnected() slot where
+ pending connections are connected to the readyRead() and disconnected() signals. The signals
+ notify others that a new client has connected.
\snippet btchat/chatserver.cpp clientConnected
- The readSocket() slot is called whenever data is ready to be read from a client socket. The
- slot reads individual lines from the socket converts them from UTF-8 and emits the
+ The readSocket() slot is called whenever data is ready to be read from a client socket. The
+ slot reads individual lines from the socket, converts them from UTF-8, and emits the
messageReceived() signal.
\snippet btchat/chatserver.cpp readSocket
- The clientDisconnected() slot is called whenever a client disconnects from the service. The
- slot emits a signal to notify others that a client has disconnected and deletes the socket.
+ The clientDisconnected() slot is called whenever a client disconnects from the service. The
+ slot emits a signal to notify others that a client has disconnected, and deletes the socket.
\snippet btchat/chatserver.cpp clientDisconnected
- The sendMessage() slot is used to send a message to all connected clients. The message is
+ The sendMessage() slot is used to send a message to all connected clients. The message is
converted into UTF-8 and appended with a newline before being sent to all clients.
\snippet btchat/chatserver.cpp sendMessage
- When the chat server is stop the service record is removed from the system SDP database, all
- connected client sockets are deleted and the QRfcommServer instance is deleted.
+ When the chat server is stopped the service record is removed from the system SDP database, all
+ connected client sockets are deleted, and the QRfcommServer instance is deleted.
\snippet btchat/chatserver.cpp stopServer
\section1 Chat Client
- The chat client is implemented by the ChatClient class. The ChatClient class is declared as:
+ The chat client is implemented by the ChatClient class. The ChatClient class is declared as:
\snippet btchat/chatclient.h declaration
The client creates a new QBluetoothSocket and connects to the remote service described by the
- \e remoteService parameter. Slots are connected to the sockets readyRead(), connected() and
+ \e remoteService parameter. Slots are connected to the sockets readyRead(), connected() and
disconnected() signals.
\snippet btchat/chatclient.cpp startClient
- On sucessfull socket connection we emit a signal to notify other.
+ On successful socket connection we emit a signal to notify others.
\snippet btchat/chatclient.cpp connected
- Similarily to the chat server the readSocket() slot is called when data is available from the
- socket. Lines are read individually and converted from UTF-8. The messageReceived() signal
+ Similarly to the chat server, the readSocket() slot is called when data is available from the
+ socket. Lines are read individually and converted from UTF-8. The messageReceived() signal
is emitted.
\snippet btchat/chatclient.cpp readSocket
- The sendMessage() slot is used to send a message to the remote device. The message is
- converted to UTF-8 and a newline appended.
+ The sendMessage() slot is used to send a message to the remote device. The message is
+ converted to UTF-8 and a newline is appended.
\snippet btchat/chatclient.cpp sendMessage
- To disconnect from the remote chat service the QBluetoothSocket instance is deleted.
+ To disconnect from the remote chat service, the QBluetoothSocket instance is deleted.
\snippet btchat/chatclient.cpp stopClient
\section1 Chat Dialog
- The main window of this example is the chat dialog, implemented in the Chat class. This class
- displays a chat session between a single ChatServer and zero or more ChatClients. The Chat
+ The main window of this example is the chat dialog, implemented in the Chat class. This class
+ displays a chat session between a single ChatServer and zero or more ChatClients. The Chat
class is declared as:
\snippet btchat/chat.h declaration
@@ -155,27 +155,27 @@
\snippet btchat/chat.cpp Construct UI
We create an instance of the ChatServer and respond to its clientConnected(),
- clientDiconnected() and messageReceived() signals.
+ clientDiconnected(), and messageReceived() signals.
\snippet btchat/chat.cpp Create Chat Server
- In response to the clientConnected() and clientDisconnected() signals of the ChatServer we
- display the typical "foo has joined chat." and "foo has left." messages in the chat session.
+ In response to the clientConnected() and clientDisconnected() signals of the ChatServer, we
+ display the typical "X has joined chat." and "Y has left." messages in the chat session.
\snippet btchat/chat.cpp clientConnected clientDisconnected
Incoming messages from clients connected to the ChatServer are handled in the showMessage()
- slot. The message text tagged with the remote device name is displayed in the chat session.
+ slot. The message text tagged with the remote device name is displayed in the chat session.
\snippet btchat/chat.cpp showMessage
- In response to the connect button being clicked the application starts service discovery and
- presents a list of discovered chat services on remote devices. A ChatClient for the service
- selected by the user.
+ In response to the connect button being clicked, the application starts service discovery and
+ presents a list of discovered chat services on remote devices. A ChatClient for the service
+ is selected by the user.
\snippet btchat/chat.cpp Connect to remote service
- In reponse to connected() signals from ChatClient we display the a "Joined chat with foo."
+ In reponse to the connected() signals from ChatClient, we display the a "Joined chat with X."
message in the chat session.
\snippet btchat/chat.cpp connected
diff --git a/examples/bluetooth/btchat/remoteselector.cpp b/examples/bluetooth/btchat/remoteselector.cpp
index f660a815..e6fd728f 100644
--- a/examples/bluetooth/btchat/remoteselector.cpp
+++ b/examples/bluetooth/btchat/remoteselector.cpp
@@ -47,29 +47,17 @@
QT_USE_NAMESPACE
-RemoteSelector::RemoteSelector(QWidget *parent)
+RemoteSelector::RemoteSelector(const QBluetoothAddress &localAdapter, QWidget *parent)
: QDialog(parent), ui(new Ui::RemoteSelector)
{
ui->setupUi(this);
- //Using default Bluetooth adapter
- QBluetoothLocalDevice localDevice;
- QBluetoothAddress adapterAddress = localDevice.address();
-
- /*
- * In case of multiple Bluetooth adapters it is possible to
- * set which adapter will be used by providing MAC Address.
- * Example code:
- *
- * QBluetoothAddress adapterAddress("XX:XX:XX:XX:XX:XX");
- * m_discoveryAgent = new QBluetoothServiceDiscoveryAgent(adapterAddress);
- */
-
- m_discoveryAgent = new QBluetoothServiceDiscoveryAgent(adapterAddress);
+ m_discoveryAgent = new QBluetoothServiceDiscoveryAgent(localAdapter);
connect(m_discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
connect(m_discoveryAgent, SIGNAL(finished()), this, SLOT(discoveryFinished()));
+ connect(m_discoveryAgent, SIGNAL(canceled()), this, SLOT(discoveryFinished()));
}
RemoteSelector::~RemoteSelector()
@@ -80,6 +68,7 @@ RemoteSelector::~RemoteSelector()
void RemoteSelector::startDiscovery(const QBluetoothUuid &uuid)
{
+ ui->status->setText(tr("Scanning..."));
if (m_discoveryAgent->isActive())
m_discoveryAgent->stop();
@@ -88,7 +77,6 @@ void RemoteSelector::startDiscovery(const QBluetoothUuid &uuid)
m_discoveryAgent->setUuidFilter(uuid);
m_discoveryAgent->start();
- ui->status->setText(tr("Scanning..."));
}
void RemoteSelector::stopDiscovery()
diff --git a/examples/bluetooth/btchat/remoteselector.h b/examples/bluetooth/btchat/remoteselector.h
index 3f6e15c9..5b123127 100644
--- a/examples/bluetooth/btchat/remoteselector.h
+++ b/examples/bluetooth/btchat/remoteselector.h
@@ -63,7 +63,7 @@ class RemoteSelector : public QDialog
Q_OBJECT
public:
- explicit RemoteSelector(QWidget *parent = 0);
+ explicit RemoteSelector(const QBluetoothAddress &localAdapter, QWidget *parent = 0);
~RemoteSelector();
void startDiscovery(const QBluetoothUuid &uuid);
diff --git a/examples/bluetooth/scanner/scanner.qml b/examples/bluetooth/scanner/scanner.qml
index 52182362..48b2ee53 100644
--- a/examples/bluetooth/scanner/scanner.qml
+++ b/examples/bluetooth/scanner/scanner.qml
@@ -40,7 +40,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtBluetooth 5.0
+import QtBluetooth 5.2
Item {
id: top
@@ -52,7 +52,8 @@ Item {
running: true
discoveryMode: BluetoothDiscoveryModel.DeviceDiscovery
onDiscoveryModeChanged: console.log("Discovery mode: " + discoveryMode)
- onNewServiceDiscovered: console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName);
+ onServiceDiscovered: console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName);
+ onDeviceDiscovered: console.log("New device: " + device)
}
Rectangle {
@@ -86,6 +87,9 @@ Item {
width: top.width
anchors.top: busy.bottom
anchors.bottom: buttonGroup.top
+ anchors.bottomMargin: 10
+ anchors.topMargin: 10
+ clip: true
model: btModel
delegate: Rectangle {
@@ -128,7 +132,6 @@ Item {
if (s.serviceName) { str += "<br>Service: " + s.serviceName; }
if (s.serviceDescription) { str += "<br>Description: " + s.serviceDescription; }
if (s.serviceProtocol) { str += "<br>Protocol: " + s.serviceProtocol; }
- if (s.servicePort) { str += "<br>Port: " + s.servicePort; }
return str;
}
}
diff --git a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
index 157b3e17..2a84c8b3 100644
--- a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
+++ b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
@@ -29,8 +29,8 @@
\example annotatedurl
\title Annotated URL Example
-The Annotated URL example displays the contents of specifically formated NDEF messages read from
-an NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record and one
+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.
\image annotatedurl.png
diff --git a/examples/nfc/poster/doc/src/poster.qdoc b/examples/nfc/poster/doc/src/poster.qdoc
index 8d0317c9..125afd95 100644
--- a/examples/nfc/poster/doc/src/poster.qdoc
+++ b/examples/nfc/poster/doc/src/poster.qdoc
@@ -29,8 +29,8 @@
\example poster
\title QML Poster Example
-The QML Poster example displays the contents of specifically formated NDEF messages read from an
-NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record and one
+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.
\image qml-poster-example.png
diff --git a/examples/nfc/poster/poster.qml b/examples/nfc/poster/poster.qml
index 058f8e4f..c50c702b 100644
--- a/examples/nfc/poster/poster.qml
+++ b/examples/nfc/poster/poster.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtNfc 5.0
+import QtNfc 5.2
Rectangle {
id: root
@@ -50,8 +50,8 @@ Rectangle {
id: nearfield
filter: [
- NdefFilter { type: "urn:nfc:wkt:U"; minimum: 1; maximum: 1 },
- NdefFilter { type: "urn:nfc:wkt:T"; minimum: 1 }
+ NdefFilter { type: "U"; typeNameFormat: NearFiledRecord.NfcRtd; minimum: 1; maximum: 1 },
+ NdefFilter { type: "T"; typeNameFormat: NearFiledRecord.NfcRtd; minimum: 1 }
]
onMessageRecordsChanged: {
diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml
index 2d4280c3..eac7c144 100644
--- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml
+++ b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml
@@ -39,7 +39,7 @@
****************************************************************************/
//! [import]
-import QtBluetooth 5.0
+import QtBluetooth 5.2
//! [import]
//! [service]
diff --git a/src/bluetooth/doc/src/bluetooth-cpp.qdoc b/src/bluetooth/doc/src/bluetooth-cpp.qdoc
index 7bd28c70..9bef246b 100644
--- a/src/bluetooth/doc/src/bluetooth-cpp.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-cpp.qdoc
@@ -29,10 +29,10 @@
\module QtBluetooth
\title Qt Bluetooth C++ Classes
-\brief An API enabling basic Bluetooth operations like scanning for devices
-and connecting them.
+\brief Enables basic Bluetooth operations like scanning for devices and connecting them.
\ingroup modules
\qtvariable bluetooth
+\since 5.2
The \l{Qt Bluetooth} C++ API enables an application to scan for devices and
diff --git a/src/bluetooth/doc/src/bluetooth-overview.qdoc b/src/bluetooth/doc/src/bluetooth-overview.qdoc
index c101ac34..347ab2cf 100644
--- a/src/bluetooth/doc/src/bluetooth-overview.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-overview.qdoc
@@ -59,7 +59,7 @@
\section1 Scanning for Bluetooth Devices
Similar to the QBluetoothLocalDevice, the API offers QBluetoothDeviceInfo which provides
- that information for remote devices. While you can just create QBluetoothDeviceInfo objects on
+ that information for remote devices. Although you can just create QBluetoothDeviceInfo objects on
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.
@@ -69,7 +69,7 @@
Once the desired device is found, there are two main use cases provided by Qt Bluetooth. The
simpler is to send files via the Obex Object Push Profile (OPP). As the name describes, this
- profile can only push files from one device to another but not pull files or browse the remote
+ profile can only push files from one device to another, but not pull files or browse the remote
file system. Because of this limitation, this profile does not require the two devices to be
paired before exchanging data. To push files to remote devices, create a
QBluetoothTransferRequest and ask the QBluetoothTransferManager to push the file contained in
@@ -79,7 +79,7 @@
\section1 Exchanging Data Between Devices
- The more flexible approach to do communication between two Bluetooth enabled devices, is to
+ The more flexible approach for communication between two Bluetooth enabled devices, is to
create a virtual serial port connection and freely exchange data over that connection. This can
be done by the Serial Port Profile (SPP). The Serial Port Profile emulates a serial connection
over the Bluetooth transport protocol RFCOMM.
@@ -95,7 +95,7 @@
\snippet btchat/chatclient.cpp startClient
Using such a connection allows to exchange any form of data in both directions.
- It is perfectly suited for use cases like gaming or syncing the state between two instances of
+ It is perfectly suited for gaming or for syncing the state between two instances of
an application on two devices. For more detailed descriptions on how to configure the server
and client, please refer to the detailed description sections in the QRfcommServer and
QBluetoothSocket classes. A good example to start with SPP is the \l{btchat}{Bluetooth Chat}
diff --git a/src/bluetooth/doc/src/bluetooth-qml.qdoc b/src/bluetooth/doc/src/bluetooth-qml.qdoc
index 912f2153..9c9fe0aa 100644
--- a/src/bluetooth/doc/src/bluetooth-qml.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-qml.qdoc
@@ -28,13 +28,13 @@
/*!
-\qmlmodule QtBluetooth 5.0
+\qmlmodule QtBluetooth 5.2
\title Qt Bluetooth QML Types
\ingroup qmlmodules
-\brief Provides QML types for basic Bluetooth operations on devices
+\brief Provides QML types for basic Bluetooth operations on devices.
-The Qt Bluetooth QML Types enable an application to scan for devices and connect and
-interact with them in an easier way than the C++ Classes. However, it is a bit
+The Qt Bluetooth QML Types enable an application to scan for devices and connect
+and interact with them in an easier way than the C++ Classes. However, it is a bit
more limited than the C++ API. You can always use the C++ API to create QML
plugins with the flexibility you need.
diff --git a/src/bluetooth/doc/src/examples.qdoc b/src/bluetooth/doc/src/examples.qdoc
index ec98dbc5..441b303d 100644
--- a/src/bluetooth/doc/src/examples.qdoc
+++ b/src/bluetooth/doc/src/examples.qdoc
@@ -29,12 +29,15 @@
\ingroup all-examples
\page bluetooth-examples.html
\title Qt Bluetooth Examples
- \brief Examples for the QtBluetooth module
+ \brief Examples for the Qt Bluetooth module.
- This is a variety of examples that cover the entire range of the the Qt Bluetooth API. You will find them in their own documentation but are also accessible from here.
+ This is a variety of examples that cover the entire range of the the Qt
+ Bluetooth API. You will find them in their own documentation but they are also
+ accessible from here.
\section2 C++ Tutorial
- The \l{btchat}{Bluetooth Chat} example contains a tutorial on how to use the C++ API to create a RFCOMM server and client and exchange data between them.
+ The \l{btchat}{Bluetooth Chat} example contains a tutorial on how to use the
+ C++ API to create a RFCOMM server and client, and exchange data between them.
\section2 C++ Examples
\table 80%
@@ -60,8 +63,8 @@
\li Description
\row
\li \l{bttennis}{QML Bluetooth Tennis}
- \li The tennis game using a QML interface to the Bluetooth API. It must connect to an
- instance of the C++ \l{bttennis}{Bluetooth Tennis} game to play.
+ \li The tennis game using a QML interface to the Bluetooth API. It
+ must connect to an instance of the C++ \l{bttennis}{Bluetooth Tennis} game to play.
\row
\li \l{btscanner}{QML Bluetooth Scanner}
\li A QML implementation of the Bluetooth device scanner.
diff --git a/src/bluetooth/qbluetoothserver.cpp b/src/bluetooth/qbluetoothserver.cpp
index 6cb9ba01..967d4e71 100644
--- a/src/bluetooth/qbluetoothserver.cpp
+++ b/src/bluetooth/qbluetoothserver.cpp
@@ -175,7 +175,8 @@ QBluetoothServer::~QBluetoothServer()
which is returned can not be changed any more.
Returns a registered QBluetoothServiceInfo instance if sucessful otherwise an
- invalid QBluetoothServiceInfo.
+ invalid QBluetoothServiceInfo. This function always assumes that the default Bluetooth adapter
+ should be used.
For an RFCOMM server this function is equivalent to following code snippet.
diff --git a/src/bluetooth/qbluetoothserver_bluez.cpp b/src/bluetooth/qbluetoothserver_bluez.cpp
index 83d0b073..e8457183 100644
--- a/src/bluetooth/qbluetoothserver_bluez.cpp
+++ b/src/bluetooth/qbluetoothserver_bluez.cpp
@@ -107,6 +107,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
int sock = d->socket->socketDescriptor();
if (sock < 0) {
d->m_lastError = InputOutputError;
+ emit error(d->m_lastError);
return false;
}
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index 023ffb80..1bf31245 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -99,7 +99,8 @@ QT_BEGIN_NAMESPACE
/*!
\fn QBluetoothServiceDiscoveryAgent::finished()
- This signal is emitted when Bluetooth service discovery completes.
+ This signal is emitted when Bluetooth service discovery completes. This signal will even
+ be emitted when an error occurred during the service discovery.
*/
/*!
@@ -329,11 +330,17 @@ void QBluetoothServiceDiscoveryAgentPrivate::startDeviceDiscovery()
Q_Q(QBluetoothServiceDiscoveryAgent);
if (!deviceDiscoveryAgent) {
- deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent;
+#ifdef QT_BLUEZ_BLUETOOTH
+ deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(m_deviceAdapterAddress, q);
+#else
+ deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(q);
+#endif
QObject::connect(deviceDiscoveryAgent, SIGNAL(finished()),
q, SLOT(_q_deviceDiscoveryFinished()));
QObject::connect(deviceDiscoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
q, SLOT(_q_deviceDiscovered(QBluetoothDeviceInfo)));
+ QObject::connect(deviceDiscoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)),
+ q, SLOT(_q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error)));
}
@@ -368,6 +375,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryFinished()
setDiscoveryState(Inactive);
Q_Q(QBluetoothServiceDiscoveryAgent);
+ emit q->error(error);
emit q->finished();
return;
}
@@ -401,6 +409,20 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscovered(const QBluetoot
}
}
+void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error newError)
+{
+ error = static_cast<QBluetoothServiceDiscoveryAgent::Error>(newError);
+
+ deviceDiscoveryAgent->stop();
+ delete deviceDiscoveryAgent;
+ deviceDiscoveryAgent = 0;
+
+ setDiscoveryState(Inactive);
+ Q_Q(QBluetoothServiceDiscoveryAgent);
+ emit q->error(error);
+ emit q->finished();
+}
+
/*!
Starts service discovery for the next device.
*/
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.h b/src/bluetooth/qbluetoothservicediscoveryagent.h
index f4786f7e..f923c2d0 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.h
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.h
@@ -108,6 +108,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscovered(const QBluetoothDeviceInfo &info))
Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscoveryFinished())
+ Q_PRIVATE_SLOT(d_func(), void _q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error))
Q_PRIVATE_SLOT(d_func(), void _q_serviceDiscoveryFinished())
#ifdef QT_BLUEZ_BLUETOOTH
Q_PRIVATE_SLOT(d_func(), void _q_discoveredServices(QDBusPendingCallWatcher*))
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_p.h b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
index 2b396786..0691b490 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_p.h
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.h
@@ -106,6 +106,7 @@ public:
void _q_deviceDiscoveryFinished();
void _q_deviceDiscovered(const QBluetoothDeviceInfo &info);
void _q_serviceDiscoveryFinished();
+ void _q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error);
#ifdef QT_BLUEZ_BLUETOOTH
void _q_discoveredServices(QDBusPendingCallWatcher *watcher);
void _q_createdDevice(QDBusPendingCallWatcher *watcher);
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
index 16b471da..319e631f 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp
@@ -54,6 +54,8 @@
#include <QPointer>
#endif
+#include <QFile>
+
#include <QtCore/private/qcore_unix_p.h>
QT_BEGIN_NAMESPACE
@@ -195,10 +197,15 @@ void QBluetoothServiceDiscoveryAgentPrivate::start(const QBluetoothAddress &addr
qBBBluetoothDebug() << "Starting Service discovery for" << address.toString();
const char *filePath = QByteArray("/pps/services/bluetooth/remote_devices/").append(address.toString().toUtf8().constData()).constData();
if ((m_rdfd = qt_safe_open(filePath, O_RDONLY)) == -1) {
- qWarning() << "Failed to open " << filePath;
- error = QBluetoothServiceDiscoveryAgent::InputOutputError;
- errorString = QStringLiteral("Failed to open remote device file");
- q->error(error);
+ if (QFile::exists(QLatin1String(filePath) + QLatin1String("-00")) ||
+ QFile::exists(QLatin1String(filePath) + QLatin1String("-01"))) {
+ qBBBluetoothDebug() << "LE device discovered...skipping";
+ } else {
+ qWarning() << "Failed to open " << filePath;
+ error = QBluetoothServiceDiscoveryAgent::InputOutputError;
+ errorString = QStringLiteral("Failed to open remote device file");
+ q->error(error);
+ }
_q_serviceDiscoveryFinished();
return;
} else {
@@ -274,8 +281,12 @@ void QBluetoothServiceDiscoveryAgentPrivate::remoteDevicesChanged(int fd)
if (serviceName.size() == 2) {
serviceInfo.setServiceUuid(QBluetoothUuid(QLatin1String(serviceName.last())));
suuid = QBluetoothUuid((quint16)(serviceName.first().toUInt(&ok,16)));
- if (suuid == QBluetoothUuid::SerialPort)
- protocolDescriptorList << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm));
+ if (suuid == QBluetoothUuid::SerialPort) {
+ QBluetoothServiceInfo::Sequence protocol;
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
+ << QVariant::fromValue(0);
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ }
}
} else {
//We do not have anything better, so we set the service class UUID as service UUID
@@ -283,7 +294,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::remoteDevicesChanged(int fd)
}
//Check if the UUID is in the uuidFilter
- if (!uuidFilter.isEmpty() && !uuidFilter.contains(suuid))
+ if (!uuidFilter.isEmpty() && !uuidFilter.contains(serviceInfo.serviceUuid()))
continue;
serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp
index 4e2c0499..3a864b3c 100644
--- a/src/bluetooth/qbluetoothserviceinfo.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo.cpp
@@ -110,10 +110,12 @@ QT_BEGIN_NAMESPACE
Bluetooth service attributes. Please check the Bluetooth Core Specification for a more detailed description of these attributes.
\value ServiceRecordHandle Specifies a service record from which attributes can be retrieved.
- \value ServiceClassIds UUIDs of service classes that the service conforms to.
+ \value ServiceClassIds UUIDs of service classes that the service conforms to. The
+ most common service classes are defined in (\l QBluetoothUuid::ServiceClassUuid)
\value ServiceRecordState Attibute changes when any other service attribute is added, deleted or modified.
\value ServiceId UUID that uniquely identifies the service.
- \value ProtocolDescriptorList List of protocols used by the service.
+ \value ProtocolDescriptorList List of protocols used by the service. The most common protocol Uuids are defined
+ in \l QBluetoothUuid::ProtocolUuid
\value BrowseGroupList List of browse groups the service is in.
\value LanguageBaseAttributeIdList List of language base attribute IDs to support human-readable attributes.
\value ServiceInfoTimeToLive Number of seconds for which the service record is expected to remain valid and unchanged.
@@ -122,7 +124,7 @@ QT_BEGIN_NAMESPACE
\value DocumentationUrl URL that points to the documentation on the service..
\value ClientExecutableUrl URL that refers to the location of an application that can be used to utilize the service.
\value IconUrl URL to the location of the icon representing the service.
- \value AdditionalProtocolDescriptorList Additional protocols used by the service. This attribute extends the \l QBluetoothServiceInfo::ProtocolDescriptorList.
+ \value AdditionalProtocolDescriptorList Additional protocols used by the service. This attribute extends \c ProtocolDescriptorList.
\value PrimaryLanguageBase Base index for primary language text descriptors.
\value ServiceName Name of the Bluetooth service in the primary language.
\value ServiceDescription Description of the Bluetooth service in the primary language.
@@ -152,21 +154,27 @@ bool QBluetoothServiceInfo::isRegistered() const
}
/*!
- \fn bool QBluetoothServiceInfo::registerService() const
+ \fn bool QBluetoothServiceInfo::registerService(const QBluetoothAddress &localAdapter)
Registers this service with the platform's Service Discovery Protocol (SDP) implementation,
making it findable by other devices when they perform service discovery. Returns true if the
service is successfully registered, otherwise returns false. Once registered changes to the record
cannot be made. The service must be unregistered and registered again with the changes.
+
+ The \a localAdapter parameter determines the local Bluetooth adapter under which
+ the service should be registered. If \a localAdapter is \c null the default Bluetooth adapter
+ will be used. If this service info object is already registered via a local adapter
+ and this is function is called using a different local adapter, the previous registration
+ is removed and the service reregistered using the new adapter.
*/
-bool QBluetoothServiceInfo::registerService() const
+bool QBluetoothServiceInfo::registerService(const QBluetoothAddress &localAdapter)
{
- return d_ptr->registerService();
+ return d_ptr->registerService(localAdapter);
}
/*!
- \fn bool QBluetoothServiceInfo::unregisterService() const
+ \fn bool QBluetoothServiceInfo::unregisterService()
Unregisters this service with the platform's Service Discovery Protocol (SDP) implementation.
After this, the service will no longer be findable by other devices through service discovery.
@@ -174,7 +182,7 @@ bool QBluetoothServiceInfo::registerService() const
Returns true if the service is successfully unregistered, otherwise returns false.
*/
-bool QBluetoothServiceInfo::unregisterService() const
+bool QBluetoothServiceInfo::unregisterService()
{
return d_ptr->unregisterService();
}
@@ -186,6 +194,9 @@ bool QBluetoothServiceInfo::unregisterService() const
This is a convenience function.
Sets the attribute identified by \a attributeId to \a value.
+
+ If the service information is already registered with the platform's SDP database,
+ the database entry will not be updated until \l registerService() was called again.
*/
/*!
@@ -194,6 +205,9 @@ bool QBluetoothServiceInfo::unregisterService() const
This is a convenience function.
Sets the attribute identified by \a attributeId to \a value.
+
+ If the service information is already registered with the platform's SDP database,
+ the database entry will not be updated until \l registerService() was called again.
*/
/*!
@@ -202,6 +216,9 @@ bool QBluetoothServiceInfo::unregisterService() const
This is a convenience function.
Sets the attribute identified by \a attributeId to \a value.
+
+ If the service information is already registered with the platform's SDP database,
+ the database entry will not be updated until \l registerService() was called again.
*/
/*!
@@ -391,20 +408,14 @@ void QBluetoothServiceInfo::setDevice(const QBluetoothDeviceInfo &device)
/*!
Sets the attribute identified by \a attributeId to \a value.
- If the service information is registered with the platforms SDP database, the database entry is also
- updated.
+ If the service information is already registered with the platform's SDP database,
+ the database entry will not be updated until \l registerService() was called again.
\sa isRegistered(), registerService()
*/
void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QVariant &value)
{
-// if (value.type() == QVariant::List)
-// qDebug() << "tried attribute with type QVariantList" << value;
-
d_ptr->attributes[attributeId] = value;
-
- if (isRegistered())
- d_ptr->setRegisteredAttribute(attributeId, value);
}
/*!
@@ -434,13 +445,13 @@ bool QBluetoothServiceInfo::contains(quint16 attributeId) const
/*!
Removes the attribute \a attributeId from the QBluetoothServiceInfo object.
+
+ If the service information is already registered with the platforms SDP database,
+ the database entry will not be updated until \l registerService() was called again.
*/
void QBluetoothServiceInfo::removeAttribute(quint16 attributeId)
{
d_ptr->attributes.remove(attributeId);
-
- if (isRegistered())
- d_ptr->removeRegisteredAttribute(attributeId);
}
/*!
diff --git a/src/bluetooth/qbluetoothserviceinfo.h b/src/bluetooth/qbluetoothserviceinfo.h
index 507c7c1d..0e6555c0 100644
--- a/src/bluetooth/qbluetoothserviceinfo.h
+++ b/src/bluetooth/qbluetoothserviceinfo.h
@@ -45,6 +45,7 @@
#include <QtBluetooth/qbluetoothglobal.h>
#include <QtBluetooth/QBluetoothUuid>
+#include <QtBluetooth/QBluetoothAddress>
#include <QtCore/QMetaType>
#include <QtCore/QList>
@@ -145,8 +146,8 @@ public:
QBluetoothServiceInfo &operator=(const QBluetoothServiceInfo &other);
bool isRegistered() const;
- bool registerService() const;
- bool unregisterService() const;
+ bool registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress());
+ bool unregisterService();
protected:
friend Q_BLUETOOTH_EXPORT QDebug operator<<(QDebug, const QBluetoothServiceInfo &);
diff --git a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
index a98b4a46..d8344589 100644
--- a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
@@ -181,12 +181,12 @@ bool QBluetoothServiceInfoPrivate::isRegistered() const
return registered;
}
-bool QBluetoothServiceInfoPrivate::unregisterService() const
+bool QBluetoothServiceInfoPrivate::unregisterService()
{
if (!registered)
return false;
- if (!ensureSdpConnection())
+ if (!ensureSdpConnection(currentLocalAdapter))
return false;
QDBusPendingReply<> reply = service->RemoveRecord(serviceRecord);
@@ -200,43 +200,40 @@ bool QBluetoothServiceInfoPrivate::unregisterService() const
return true;
}
-void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) const
+bool QBluetoothServiceInfoPrivate::ensureSdpConnection(const QBluetoothAddress &localAdapter)
{
- Q_UNUSED(attributeId);
- Q_UNUSED(value);
-
- registerService();
-}
-
-void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) const
-{
- Q_UNUSED(attributeId);
-
- registerService();
-}
-
-bool QBluetoothServiceInfoPrivate::ensureSdpConnection() const
-{
- if (service)
+ if (service && currentLocalAdapter == localAdapter)
return true;
+ delete service;
+
OrgBluezManagerInterface manager(QLatin1String("org.bluez"), QLatin1String("/"),
QDBusConnection::systemBus());
- QDBusPendingReply<QDBusObjectPath> reply = manager.FindAdapter(QLatin1String("any"));
+
+ QDBusPendingReply<QDBusObjectPath> reply;
+ if (localAdapter.isNull())
+ reply = manager.DefaultAdapter();
+ else
+ reply = manager.FindAdapter(localAdapter.toString());
reply.waitForFinished();
if (reply.isError())
return false;
+ currentLocalAdapter = localAdapter;
service = new OrgBluezServiceInterface(QLatin1String("org.bluez"), reply.value().path(),
- QDBusConnection::systemBus());
+ QDBusConnection::systemBus(), this);
return true;
}
-bool QBluetoothServiceInfoPrivate::registerService() const
+bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &localAdapter)
{
- if (!ensureSdpConnection()) {
+ //if new adapter unregister previous one first
+ if (registered && localAdapter != currentLocalAdapter)
+ unregisterService();
+
+ if (!ensureSdpConnection(localAdapter)) {
qWarning() << "SDP not connected. Cannot register";
return false;
}
diff --git a/src/bluetooth/qbluetoothserviceinfo_p.cpp b/src/bluetooth/qbluetoothserviceinfo_p.cpp
index 13bc8fd5..e5f2f4e5 100644
--- a/src/bluetooth/qbluetoothserviceinfo_p.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_p.cpp
@@ -57,26 +57,15 @@ bool QBluetoothServiceInfoPrivate::isRegistered() const
return false;
}
-bool QBluetoothServiceInfoPrivate::registerService() const
+bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &localAdapter)
{
+ Q_UNUSED(localAdapter);
return false;
}
-bool QBluetoothServiceInfoPrivate::unregisterService() const
+bool QBluetoothServiceInfoPrivate::unregisterService()
{
return false;
}
-
-void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) const
-{
- Q_UNUSED(attributeId);
- Q_UNUSED(value);
-}
-
-void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) const
-{
- Q_UNUSED(attributeId);
-}
-
QT_END_NAMESPACE
diff --git a/src/bluetooth/qbluetoothserviceinfo_p.h b/src/bluetooth/qbluetoothserviceinfo_p.h
index 0e263fe6..46ae84d4 100644
--- a/src/bluetooth/qbluetoothserviceinfo_p.h
+++ b/src/bluetooth/qbluetoothserviceinfo_p.h
@@ -43,6 +43,7 @@
#define QBLUETOOTHSERVICEINFO_P_H
#include "qbluetoothuuid.h"
+#include "qbluetoothaddress.h"
#include "qbluetoothdeviceinfo.h"
#include "qbluetoothserviceinfo.h"
@@ -63,14 +64,12 @@ public:
QBluetoothServiceInfoPrivate();
~QBluetoothServiceInfoPrivate();
- bool registerService() const;
+ bool registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress());
bool isRegistered() const;
- bool unregisterService() const;
+ bool unregisterService();
- void setRegisteredAttribute(quint16 attributeId, const QVariant &value) const;
- void removeRegisteredAttribute(quint16 attributeId) const;
QBluetoothDeviceInfo deviceInfo;
QMap<quint16, QVariant> attributes;
@@ -78,10 +77,11 @@ public:
int serverChannel() const;
private:
#ifdef QT_BLUEZ_BLUETOOTH
- bool ensureSdpConnection() const;
+ bool ensureSdpConnection(const QBluetoothAddress &localAdapter = QBluetoothAddress());
- mutable OrgBluezServiceInterface *service;
- mutable quint32 serviceRecord;
+ OrgBluezServiceInterface *service;
+ quint32 serviceRecord;
+ QBluetoothAddress currentLocalAdapter;
#endif
mutable bool registered;
diff --git a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp
index cb82851c..b744feff 100644
--- a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp
@@ -61,7 +61,7 @@ bool QBluetoothServiceInfoPrivate::isRegistered() const
return registered;
}
-bool QBluetoothServiceInfoPrivate::unregisterService() const
+bool QBluetoothServiceInfoPrivate::unregisterService()
{
if (!registered)
return false;
@@ -69,25 +69,11 @@ bool QBluetoothServiceInfoPrivate::unregisterService() const
return false;
}
-
-void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) const
-{
- Q_UNUSED(attributeId);
- Q_UNUSED(value);
-
- registerService();
-}
-
-void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) const
-{
- Q_UNUSED(attributeId);
- registered = false;
-}
-
extern QHash<QBluetoothServerPrivate*, int> __fakeServerPorts;
-bool QBluetoothServiceInfoPrivate::registerService() const
+bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress& localAdapter)
{
+ Q_UNUSED(localAdapter); //QNX always uses default local adapter
if (protocolDescriptor(QBluetoothUuid::Rfcomm).isEmpty()) {
qWarning() << Q_FUNC_INFO << "Only SPP services can be registered on QNX";
return false;
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index 38697756..96ed9dae 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -481,6 +481,7 @@ void QBluetoothSocket::doDeviceDiscovery(const QBluetoothServiceInfo &service, O
{
Q_D(QBluetoothSocket);
+ setSocketState(QBluetoothSocket::ServiceLookupState);
//qDebug() << "Starting discovery";
if(d->discoveryAgent) {
@@ -675,6 +676,9 @@ QDebug operator<<(QDebug debug, QBluetoothSocket::SocketState state)
case QBluetoothSocket::ListeningState:
debug << "QBluetoothSocket::ListeningState";
break;
+ case QBluetoothSocket::ServiceLookupState:
+ debug << "QBluetoothSocket::ServiceLookupState";
+ break;
default:
debug << "QBluetoothSocket::SocketState(" << (int)state << ")";
}
diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp
index bc7dc972..c6f332e3 100644
--- a/src/bluetooth/qbluetoothsocket_bluez.cpp
+++ b/src/bluetooth/qbluetoothsocket_bluez.cpp
@@ -362,12 +362,13 @@ QString QBluetoothSocketPrivate::peerName() const
return QString();
}
- const QString address = QBluetoothAddress(bdaddr).toString();
+ const QString peerAddress = QBluetoothAddress(bdaddr).toString();
+ const QString localAdapter = localAddress().toString();
OrgBluezManagerInterface manager(QLatin1String("org.bluez"), QLatin1String("/"),
QDBusConnection::systemBus());
- QDBusPendingReply<QDBusObjectPath> reply = manager.DefaultAdapter();
+ QDBusPendingReply<QDBusObjectPath> reply = manager.FindAdapter(localAdapter);
reply.waitForFinished();
if (reply.isError())
return QString();
@@ -375,13 +376,13 @@ QString QBluetoothSocketPrivate::peerName() const
OrgBluezAdapterInterface adapter(QLatin1String("org.bluez"), reply.value().path(),
QDBusConnection::systemBus());
- QDBusPendingReply<QDBusObjectPath> deviceObjectPath = adapter.CreateDevice(address);
+ QDBusPendingReply<QDBusObjectPath> deviceObjectPath = adapter.CreateDevice(peerAddress);
deviceObjectPath.waitForFinished();
if (deviceObjectPath.isError()) {
if (deviceObjectPath.error().name() != QLatin1String("org.bluez.Error.AlreadyExists"))
return QString();
- deviceObjectPath = adapter.FindDevice(address);
+ deviceObjectPath = adapter.FindDevice(peerAddress);
deviceObjectPath.waitForFinished();
if (deviceObjectPath.isError())
return QString();
diff --git a/src/bluetooth/qbluetoothsocket_qnx.cpp b/src/bluetooth/qbluetoothsocket_qnx.cpp
index 1f3f1ed4..6e14ae13 100644
--- a/src/bluetooth/qbluetoothsocket_qnx.cpp
+++ b/src/bluetooth/qbluetoothsocket_qnx.cpp
@@ -67,7 +67,7 @@ QBluetoothSocketPrivate::~QBluetoothSocketPrivate()
bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol type)
{
- Q_UNUSED(type);
+ socketType = type;
return false;
}
diff --git a/src/bluetooth/qbluetoothtransferreply_bluez.cpp b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
index 3c63adeb..0634f080 100644
--- a/src/bluetooth/qbluetoothtransferreply_bluez.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_bluez.cpp
@@ -110,13 +110,21 @@ bool QBluetoothTransferReplyBluez::start()
}
else {
if (!file->exists()) {
- m_errorStr = tr("File does not exist");
+ m_errorStr = QBluetoothTransferReply::tr("File does not exist");
m_error = QBluetoothTransferReply::FileNotFoundError;
m_finished = true;
m_running = false;
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
+ if (request().address().isNull()) {
+ m_errorStr = QBluetoothTransferReply::tr("Invalid target address");
+ m_error = QBluetoothTransferReply::HostNotFoundError;
+ m_finished = true;
+ m_running = false;
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
+ return false;
+ }
m_size = file->size();
startOPP(file->fileName());
}
diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
index 56e2c3e3..b3425300 100644
--- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp
+++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp
@@ -1,6 +1,7 @@
/***************************************************************************
**
** Copyright (C) 2013 Research In Motion
+** Copyright (C) 2013 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.
@@ -113,13 +114,21 @@ bool QBluetoothTransferReplyQnx::start()
} else {
if (!file->exists()) {
- m_errorStr = tr("File does not exist");
+ m_errorStr = QBluetoothTransferReply::tr("File does not exist");
m_error = QBluetoothTransferReply::FileNotFoundError;
m_finished = true;
m_running = false;
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
return false;
}
+ if (request().address().isNull()) {
+ m_errorStr = QBluetoothTransferReply::tr("Invalid target address");
+ m_error = QBluetoothTransferReply::HostNotFoundError;
+ m_finished = true;
+ m_running = false;
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection, Q_ARG(QBluetoothTransferReply*, this));
+ return false;
+ }
startOPP(file->fileName());
}
return true;
@@ -192,12 +201,16 @@ void QBluetoothTransferReplyQnx::controlEvent(ppsResult result)
Q_EMIT finished(this);
} else if (result.msg == QStringLiteral("opp_update")) {
bool ok;
- int sentBytes = result.dat.at(result.dat.indexOf(QStringLiteral("sent")) + 1).toInt(&ok);
- if (!ok)
+ qint64 sentBytes = result.dat.at(result.dat.indexOf(QStringLiteral("sent")) + 1).toDouble(&ok);
+ if (!ok) {
+ qWarning() << "Could not convert sent bytes";
return;
- int totalBytes = result.dat.at(result.dat.indexOf(QStringLiteral("total")) + 1).toInt(&ok);
- if (!ok)
+ }
+ qint64 totalBytes = result.dat.at(result.dat.indexOf(QStringLiteral("total")) + 1).toDouble(&ok);
+ if (!ok) {
+ qWarning() << "Could not convert total bytes";
return;
+ }
qBBBluetoothDebug() << "opp update" << sentBytes << totalBytes;
Q_EMIT transferProgress(sentBytes, totalBytes);
} else if (result.msg == QStringLiteral("opp_complete")) {
diff --git a/src/bluetooth/qbluetoothtransferrequest.h b/src/bluetooth/qbluetoothtransferrequest.h
index 45a3bc76..072d330f 100644
--- a/src/bluetooth/qbluetoothtransferrequest.h
+++ b/src/bluetooth/qbluetoothtransferrequest.h
@@ -64,7 +64,7 @@ public:
NameAttribute
};
- QBluetoothTransferRequest(const QBluetoothAddress &address = QBluetoothAddress());
+ explicit QBluetoothTransferRequest(const QBluetoothAddress &address = QBluetoothAddress());
QBluetoothTransferRequest(const QBluetoothTransferRequest &other);
~QBluetoothTransferRequest();
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp
index 5426e943..fcf5a5f7 100644
--- a/src/bluetooth/qbluetoothuuid.cpp
+++ b/src/bluetooth/qbluetoothuuid.cpp
@@ -96,6 +96,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value McapControlChannel Multi-Channel Adaptation Protocol UUID
\value McapDataChannel Multi-Channel Adaptation Protocol UUID
\value L2cap L2CAP protocol UUID
+
+ \sa QBluetoothServiceInfo::ProtocolDescriptorList
*/
/*!
@@ -161,6 +163,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value HDP Health Device Profile
\value HDPSource Health Device Profile
\value HDPSink Health Device Profile
+
+ \sa QBluetoothServiceInfo::ServiceClassIds
*/
/*!
diff --git a/src/bluetooth/qprivatelinearbuffer_p.h b/src/bluetooth/qprivatelinearbuffer_p.h
index 5413bd28..2eb38cd6 100644
--- a/src/bluetooth/qprivatelinearbuffer_p.h
+++ b/src/bluetooth/qprivatelinearbuffer_p.h
@@ -141,7 +141,7 @@ private:
size_t newCapacity = qMax(capacity, size_t(QPRIVATELINEARBUFFER_BUFFERSIZE));
while (newCapacity < required)
newCapacity *= 2;
- int moveOffset = (where == freeSpaceAtEnd) ? 0 : newCapacity - len;
+ const int moveOffset = (where == freeSpaceAtEnd) ? 0 : int(newCapacity) - len;
if (newCapacity > capacity) {
// allocate more space
char* newBuf = new char[newCapacity];
diff --git a/src/imports/bluetooth/plugin.cpp b/src/imports/bluetooth/plugin.cpp
index 9d3b816f..2311d6b8 100644
--- a/src/imports/bluetooth/plugin.cpp
+++ b/src/imports/bluetooth/plugin.cpp
@@ -56,13 +56,25 @@ class QBluetoothQmlPlugin : public QQmlExtensionPlugin
public:
void registerTypes(const char *uri)
{
- Q_ASSERT(uri == QLatin1String("QtBluetooth"));
+ // @uri QtBluetooth
+
+ Q_ASSERT(uri == QStringLiteral("QtBluetooth"));
int major = 5;
int minor = 0;
- qmlRegisterType<QDeclarativeBluetoothDiscoveryModel>(uri, major, minor, "BluetoothDiscoveryModel");
- qmlRegisterType<QDeclarativeBluetoothService>(uri, major, minor, "BluetoothService");
- qmlRegisterType<QDeclarativeBluetoothSocket>(uri, major, minor, "BluetoothSocket");
+
+ // Register the 5.0 types
+ //5.0 is silent and not advertised
+ qmlRegisterType<QDeclarativeBluetoothDiscoveryModel >(uri, major, minor, "BluetoothDiscoveryModel");
+ qmlRegisterType<QDeclarativeBluetoothService >(uri, major, minor, "BluetoothService");
+ qmlRegisterType<QDeclarativeBluetoothSocket >(uri, major, minor, "BluetoothSocket");
+
+ // Register the 5.2 types
+ minor = 2;
+ qmlRegisterType<QDeclarativeBluetoothDiscoveryModel >(uri, major, minor, "BluetoothDiscoveryModel");
+ qmlRegisterType<QDeclarativeBluetoothService >(uri, major, minor, "BluetoothService");
+ qmlRegisterType<QDeclarativeBluetoothSocket >(uri, major, minor, "BluetoothSocket");
+
}
};
diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes
index 578cd711..20d57574 100644
--- a/src/imports/bluetooth/plugins.qmltypes
+++ b/src/imports/bluetooth/plugins.qmltypes
@@ -3,70 +3,74 @@ import QtQuick.tooling 1.1
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
-// This file was auto-generated with the command 'qmlplugindump -notrelocatable QtBluetooth 5.0'.
+// This file was auto-generated by:
+// 'qmlplugindump -notrelocatable QtBluetooth 5.2'
Module {
Component {
name: "QDeclarativeBluetoothDiscoveryModel"
prototype: "QAbstractListModel"
- exports: ["QtBluetooth/BluetoothDiscoveryModel 5.0"]
- exportMetaObjectRevisions: [0]
- Property { name: "error"; type: "string"; isReadonly: true }
- Property { name: "minimalDiscovery"; type: "bool" }
- Property { name: "discovery"; type: "bool" }
+ exports: [
+ "QtBluetooth/BluetoothDiscoveryModel 5.0",
+ "QtBluetooth/BluetoothDiscoveryModel 5.2"
+ ]
+ exportMetaObjectRevisions: [0, 0]
+ Enum {
+ name: "DiscoveryMode"
+ values: {
+ "MinimalServiceDiscovery": 0,
+ "FullServiceDiscovery": 1,
+ "DeviceDiscovery": 2
+ }
+ }
+ Enum {
+ name: "Error"
+ values: {
+ "NoError": 0,
+ "InputOutputError": 1,
+ "PoweredOffError": 2,
+ "UnknownError": 3
+ }
+ }
+ Property { name: "error"; type: "Error"; isReadonly: true }
+ Property { name: "discoveryMode"; type: "DiscoveryMode" }
+ Property { name: "running"; type: "bool" }
Property { name: "uuidFilter"; type: "string" }
+ Property { name: "remoteAddress"; type: "string" }
Signal {
- name: "newServiceDiscovered"
+ name: "serviceDiscovered"
Parameter { name: "service"; type: "QDeclarativeBluetoothService"; isPointer: true }
}
- Method {
- name: "setDiscovery"
- Parameter { name: "discovery_"; type: "bool" }
+ Signal {
+ name: "deviceDiscovered"
+ Parameter { name: "device"; type: "string" }
}
}
Component {
name: "QDeclarativeBluetoothService"
prototype: "QObject"
- exports: ["QtBluetooth/BluetoothService 5.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtBluetooth/BluetoothService 5.0",
+ "QtBluetooth/BluetoothService 5.2"
+ ]
+ exportMetaObjectRevisions: [0, 0]
+ Enum {
+ name: "Protocol"
+ values: {
+ "RfcommProtocol": 2,
+ "L2CapProtocol": 1,
+ "UnknownProtocol": 0
+ }
+ }
Property { name: "deviceName"; type: "string"; isReadonly: true }
Property { name: "deviceAddress"; type: "string" }
Property { name: "serviceName"; type: "string" }
Property { name: "serviceDescription"; type: "string" }
Property { name: "serviceUuid"; type: "string" }
- Property { name: "serviceProtocol"; type: "string" }
- Property { name: "servicePort"; type: "int" }
+ Property { name: "serviceProtocol"; type: "Protocol" }
Property { name: "registered"; type: "bool" }
Signal { name: "detailsChanged" }
Signal { name: "newClient" }
- Method {
- name: "setServiceName"
- Parameter { name: "name"; type: "string" }
- }
- Method {
- name: "setDeviceAddress"
- Parameter { name: "address"; type: "string" }
- }
- Method {
- name: "setServiceDescription"
- Parameter { name: "description"; type: "string" }
- }
- Method {
- name: "setServiceUuid"
- Parameter { name: "uuid"; type: "string" }
- }
- Method {
- name: "setServiceProtocol"
- Parameter { name: "protocol"; type: "string" }
- }
- Method {
- name: "setServicePort"
- Parameter { name: "port"; type: "int" }
- }
- Method {
- name: "setRegistered"
- Parameter { name: "registered"; type: "bool" }
- }
Method { name: "nextClient"; type: "QDeclarativeBluetoothSocket*" }
Method {
name: "assignNextClient"
@@ -76,13 +80,41 @@ Module {
Component {
name: "QDeclarativeBluetoothSocket"
prototype: "QObject"
- exports: ["QtBluetooth/BluetoothSocket 5.0"]
- exportMetaObjectRevisions: [0]
+ exports: [
+ "QtBluetooth/BluetoothSocket 5.0",
+ "QtBluetooth/BluetoothSocket 5.2"
+ ]
+ exportMetaObjectRevisions: [0, 0]
+ Enum {
+ name: "Error"
+ values: {
+ "NoError": -2,
+ "UnknownSocketError": -1,
+ "HostNotFoundError": 2,
+ "ServiceNotFoundError": 9,
+ "NetworkError": 7,
+ "UnsupportedProtocolError": 8
+ }
+ }
+ Enum {
+ name: "SocketState"
+ values: {
+ "Unconnected": 0,
+ "ServiceLookup": 1,
+ "Connecting": 2,
+ "Connected": 3,
+ "Bound": 4,
+ "Closing": 6,
+ "Listening": 5,
+ "NoServiceSet": 100
+ }
+ }
Property { name: "service"; type: "QDeclarativeBluetoothService"; isPointer: true }
Property { name: "connected"; type: "bool" }
- Property { name: "error"; type: "string"; isReadonly: true }
- Property { name: "state"; type: "string"; isReadonly: true }
+ Property { name: "error"; type: "Error"; isReadonly: true }
+ Property { name: "socketState"; type: "SocketState"; isReadonly: true }
Property { name: "stringData"; type: "string" }
+ Signal { name: "stateChanged" }
Signal { name: "dataAvailable" }
Method {
name: "setService"
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
index 97265b4f..67b71902 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
@@ -52,22 +52,43 @@
/*!
\qmltype BluetoothDiscoveryModel
\instantiates QDeclarativeBluetoothDiscoveryModel
- \inqmlmodule QtBluetooth 5.0
- \brief Enables you to search for the Bluetooth devices and services in
+ \inqmlmodule QtBluetooth
+ \since 5.2
+ \brief Enables searching for the Bluetooth devices and services in
range.
- The BluetoothDiscoveryModel type was introduced in \b{QtBluetooth 5.0}.
-
BluetoothDiscoveryModel provides a model of connectable services. The
contents of the model can be filtered by UUID allowing discovery to be
limited to a single service such as a game.
The model roles provided by BluetoothDiscoveryModel are
- \c service, \c name, \c remoteAddress and \c deviceName.
- Through the \c service role the BluetoothService can be accessed for more details.
+ \c service, \c name, \c remoteAddress and \c deviceName. The meaning of the roles
+ changes based on the current \l discoveryMode.
- \sa QBluetoothServiceDiscoveryAgent
+ \table
+ \header
+ \li Model role
+ \li Device Discovery
+ \li Service Discovery
+ \row
+ \li \c name
+ \li The device's name and address.
+ \li The service name and the name of the device offering the service. If the device name is empty the devices address will be used.
+ \row
+ \li \c deviceName
+ \li The name of the device.
+ \li The name of the device offering the service.
+ \row
+ \li \c service
+ \li The role is undefined in this mode.
+ \li The \l BluetoothService object describing the discovered service.
+ \row
+ \li \c remoteAddress
+ \li The address of the found device.
+ \li The address of the device offering the service.
+ \endtable
+ \sa QBluetoothServiceDiscoveryAgent
*/
class QDeclarativeBluetoothDiscoveryModelPrivate
@@ -239,9 +260,12 @@ QVariant QDeclarativeBluetoothDiscoveryModel::data(const QModelIndex &index, int
}
/*!
- \qmlsignal BluetoothDiscoveryModel::newServiceDiscovered()
+ \qmlsignal BluetoothDiscoveryModel::serviceDiscovered(BluetoothService service)
- This handler is called when a new service is discovered.
+ This handler is called when a new service is discovered. The \a service
+ parameter contains the service details.
+
+ \sa BluetoothService
*/
void QDeclarativeBluetoothDiscoveryModel::serviceDiscovered(const QBluetoothServiceInfo &service)
@@ -262,13 +286,14 @@ void QDeclarativeBluetoothDiscoveryModel::serviceDiscovered(const QBluetoothServ
beginInsertRows(QModelIndex(),d->m_services.count(), d->m_services.count());
d->m_services.append(bs);
endInsertRows();
- emit newServiceDiscovered(bs);
+ emit serviceDiscovered(bs);
}
/*!
- \qmlsignal BluetoothDiscoveryModel::newDeviceDiscovered()
+ \qmlsignal BluetoothDiscoveryModel::deviceDiscovered(string device)
- This handler is called when a new device is discovered.
+ This handler is called when a new device is discovered. \a device contains
+ the Bluetooth address of the discovred device.
*/
void QDeclarativeBluetoothDiscoveryModel::deviceDiscovered(const QBluetoothDeviceInfo &device)
@@ -278,16 +303,9 @@ void QDeclarativeBluetoothDiscoveryModel::deviceDiscovered(const QBluetoothDevic
beginInsertRows(QModelIndex(),d->m_devices.count(), d->m_devices.count());
d->m_devices.append(device);
endInsertRows();
- emit newDeviceDiscovered();
+ emit deviceDiscovered(device.address().toString());
}
-/*!
- \qmlsignal BluetoothDiscoveryModel::discoveryChanged()
-
- This handler is called when discovery has completed and no
- further results will be generated.
-*/
-
void QDeclarativeBluetoothDiscoveryModel::finishedDiscovery()
{
setRunning(false);
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
index feb1a5e1..63f232e0 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
@@ -119,8 +119,8 @@ public:
signals:
void errorChanged();
void discoveryModeChanged();
- void newServiceDiscovered(QDeclarativeBluetoothService *service);
- void newDeviceDiscovered();
+ void serviceDiscovered(QDeclarativeBluetoothService *service);
+ void deviceDiscovered(const QString& device);
void runningChanged();
void uuidFilterChanged();
void remoteAddressChanged();
diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
index 7180be7b..be8f90c0 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
@@ -53,14 +53,13 @@
/*!
\qmltype BluetoothService
\instantiates QDeclarativeBluetoothService
- \inqmlmodule QtBluetooth 5.0
+ \inqmlmodule QtBluetooth
+ \since 5.2
\brief Provides information about a particular Bluetooth service.
\sa QBluetoothAddress
\sa QBluetoothSocket
- The BluetoothService type was introduced in \b{QtBluetooth 5.0}.
-
It allows a QML project to get information about a remote service, or describe a service
for a BluetoothSocket to connect to.
*/
@@ -86,9 +85,8 @@ class QDeclarativeBluetoothServicePrivate
public:
QDeclarativeBluetoothServicePrivate()
: m_componentComplete(false),
- m_service(0), m_port(0),
- m_needsRegistration(false),
- m_listen(0)
+ m_service(0),
+ m_server(0)
{
}
@@ -102,20 +100,15 @@ public:
bool m_componentComplete;
QBluetoothServiceInfo *m_service;
- QString m_protocol;
- qint32 m_port;
- QString m_description;
- QString m_name;
- QString m_uuid;
- bool m_needsRegistration;
- QObject *m_listen;
-
+ QDeclarativeBluetoothService::Protocol m_protocol;
+ QBluetoothServer *m_server;
};
QDeclarativeBluetoothService::QDeclarativeBluetoothService(QObject *parent) :
QObject(parent)
{
d = new QDeclarativeBluetoothServicePrivate;
+ d->m_service = new QBluetoothServiceInfo();
}
QDeclarativeBluetoothService::QDeclarativeBluetoothService(const QBluetoothServiceInfo &service, QObject *parent)
@@ -134,7 +127,7 @@ void QDeclarativeBluetoothService::componentComplete()
{
d->m_componentComplete = true;
- if (d->m_needsRegistration)
+ if (!d->m_service->isRegistered())
setRegistered(true);
}
@@ -148,8 +141,6 @@ void QDeclarativeBluetoothService::componentComplete()
QString QDeclarativeBluetoothService::deviceName() const
{
- if (!d->m_service)
- return QString();
return d->m_service->device().name();
}
@@ -165,19 +156,13 @@ QString QDeclarativeBluetoothService::deviceName() const
QString QDeclarativeBluetoothService::deviceAddress() const
{
- if (!d->m_service)
- return QString();
-
return d->m_service->device().address().toString();
}
-void QDeclarativeBluetoothService::setDeviceAddress(QString address)
+void QDeclarativeBluetoothService::setDeviceAddress(const QString &newAddress)
{
- if (!d->m_service)
- d->m_service = new QBluetoothServiceInfo();
-
- QBluetoothAddress a(address);
- QBluetoothDeviceInfo device(a, QString(), QBluetoothDeviceInfo::ComputerDevice);
+ QBluetoothAddress address(newAddress);
+ QBluetoothDeviceInfo device(address, QString(), QBluetoothDeviceInfo::ComputerDevice);
d->m_service->setDevice(device);
}
@@ -190,18 +175,12 @@ void QDeclarativeBluetoothService::setDeviceAddress(QString address)
QString QDeclarativeBluetoothService::serviceName() const
{
- if (!d->m_service)
- return QString();
-
- if (!d->m_name.isEmpty())
- return d->m_name;
-
return d->m_service->serviceName();
}
-void QDeclarativeBluetoothService::setServiceName(QString name)
+void QDeclarativeBluetoothService::setServiceName(const QString &name)
{
- d->m_name = name;
+ d->m_service->setServiceName(name);
}
@@ -213,51 +192,43 @@ void QDeclarativeBluetoothService::setServiceName(QString name)
*/
QString QDeclarativeBluetoothService::serviceDescription() const
{
- if (!d->m_service)
- return QString();
-
- if (!d->m_description.isEmpty())
- return d->m_name;
-
return d->m_service->serviceDescription();
}
-void QDeclarativeBluetoothService::setServiceDescription(QString description)
+void QDeclarativeBluetoothService::setServiceDescription(const QString &description)
{
- d->m_description = description;
+ d->m_service->setServiceDescription(description);
emit detailsChanged();
}
/*!
- \qmlproperty string BluetoothService::serviceProtocol
+ \qmlproperty enumeration BluetoothService::serviceProtocol
- This property holds the protocol used for the service. Can be the string,
- "l2cap" or "rfcomm". Changing this property emits the
+ This property holds the protocol used for the service. Changing this property emits the
detailsChanged signal.
- */
-
-QString QDeclarativeBluetoothService::serviceProtocol() const
-{
- if (!d->m_protocol.isEmpty())
- return d->m_protocol;
+ Possible values for this property are:
+ \table
+ \header \li Property \li Description
+ \row \li \c BluetoothService.RfcommProtocol
+ \li The Rfcomm protocol is used.
+ \row \li \c BluetoothService.L2capProtocol
+ \li The L2cap protocol is used.
+ \row \li \c BluetoothService.UnknownProtocol
+ \li The protocol is unknown.
+ \endtable
- if (!d->m_service)
- return QString();
+ \sa QBluetoothServiceInfo::Protocol
- if (d->m_service->socketProtocol() == QBluetoothServiceInfo::L2capProtocol)
- return QLatin1String("l2cap");
- if (d->m_service->socketProtocol() == QBluetoothServiceInfo::RfcommProtocol)
- return QLatin1String("rfcomm");
+ */
- return QLatin1String("unknown");
+QDeclarativeBluetoothService::Protocol QDeclarativeBluetoothService::serviceProtocol() const
+{
+ return d->m_protocol;
}
-void QDeclarativeBluetoothService::setServiceProtocol(QString protocol)
+void QDeclarativeBluetoothService::setServiceProtocol(QDeclarativeBluetoothService::Protocol protocol)
{
- if (protocol != "rfcomm" && protocol != "l2cap")
- qWarning() << "Invalid protocol" << protocol;
-
d->m_protocol = protocol;
emit detailsChanged();
}
@@ -265,70 +236,24 @@ void QDeclarativeBluetoothService::setServiceProtocol(QString protocol)
/*!
\qmlproperty string BluetoothService::serviceUuid
- This property holds the UUID of the remote service. Service UUID or port,
- and the address must be set to connect to a remote service. If UUID and
- port are set, the port is used. The UUID takes longer to connect as
- service discovery must be initiated to discover the port value. Changing
+ This property holds the UUID of the remote service. Service UUID,
+ and the address must be set to connect to a remote service. Changing
this property emits the detailsChanged signal.
*/
QString QDeclarativeBluetoothService::serviceUuid() const
{
- if (!d->m_uuid.isEmpty())
- return d->m_uuid;
-
- if (!d->m_service)
- return QString();
-
- return d->m_service->attribute(QBluetoothServiceInfo::ServiceId).toString();
+ return d->m_service->serviceUuid().toString();
}
-void QDeclarativeBluetoothService::setServiceUuid(QString uuid)
+void QDeclarativeBluetoothService::setServiceUuid(const QString &uuid)
{
- d->m_uuid = uuid;
- if (!d->m_service)
- d->m_service = new QBluetoothServiceInfo();
- d->m_service->setAttribute(QBluetoothServiceInfo::ServiceId, QBluetoothUuid(uuid));
-
+ d->m_service->setServiceUuid(QBluetoothUuid(uuid));
emit detailsChanged();
}
/*!
- \qmlproperty int BluetoothService::servicePort
-
- This property holds the port value for the remote service. Bluetooth does not
- use well defined port values, so port values should not be stored and used
- later. Connecting using UUID is much more consistent. Changing this property emits the
- detailsChanged signal.
-*/
-qint32 QDeclarativeBluetoothService::servicePort() const
-{
- if (d->m_port > 0)
- return d->m_port;
-
- if (!d->m_service)
- return -1;
-
- if (d->m_service->serverChannel() > 0)
- return d->m_service->serverChannel();
- if (d->m_service->protocolServiceMultiplexer() > 0)
- return d->m_service->protocolServiceMultiplexer();
-
- return -1;
-}
-
-void QDeclarativeBluetoothService::setServicePort(qint32 port)
-{
- if (d->m_port != port){
- d->m_port = port;
- if (isRegistered())
- setRegistered(true);
- emit detailsChanged();
- }
-}
-
-/*!
\qmlproperty string BluetoothService::registered
This property holds the registration/publication status of the service. If true, the service
@@ -337,77 +262,57 @@ void QDeclarativeBluetoothService::setServicePort(qint32 port)
bool QDeclarativeBluetoothService::isRegistered() const
{
- if (!d->m_service)
- return false;
-
return d->m_service->isRegistered();
}
int QDeclarativeBluetoothServicePrivate::listen() {
- if (m_protocol != "l2cap" && m_protocol != "rfcomm") {
+ if (m_service->socketProtocol() == QBluetoothServiceInfo::UnknownProtocol) {
qWarning() << "Unknown protocol, can't make service" << m_protocol;
return -1;
}
QBluetoothServiceInfo::Protocol serverType;
- if (m_protocol == "l2cap") {
+ if (m_service->socketProtocol() == QBluetoothServiceInfo::L2capProtocol) {
serverType = QBluetoothServiceInfo::L2capProtocol;
}
- else if (m_protocol == "rfcomm") {
+ else if (m_service->socketProtocol() == QBluetoothServiceInfo::RfcommProtocol) {
serverType = QBluetoothServiceInfo::RfcommProtocol;
}
QBluetoothServer *server = new QBluetoothServer(serverType);
server->setMaxPendingConnections(1);
- server->listen(QBluetoothAddress(), m_port);
- m_port = server->serverPort();
- m_listen = server;
-
- return m_port;
+ server->listen(QBluetoothAddress());
+ server->serverPort();
+ m_server = server;
+ return server->serverPort();
}
void QDeclarativeBluetoothService::setRegistered(bool registered)
{
-
- d->m_needsRegistration = registered;
-
if (!d->m_componentComplete) {
return;
}
+ delete d->m_server;
+ d->m_server = 0;
+
if (!registered) {
- if (!d->m_service)
- return;
d->m_service->unregisterService();
emit registeredChanged();
+ return;
}
- if (!d->m_service) {
- d->m_service = new QBluetoothServiceInfo();
- }
-
-
- delete d->m_listen;
- d->m_listen = 0;
-
d->listen();
- connect(d->m_listen, SIGNAL(newConnection()), this, SLOT(new_connection()));
+ connect(d->m_server, SIGNAL(newConnection()), this, SLOT(new_connection()));
d->m_service->setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
-// QBluetoothServiceInfo::Sequence classId;
-//// classId << QVariant::fromVhttp://theunderstatement.com/alue(QBluetoothUuid(serviceUuid));
-// classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
-// d->m_service->setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
-
- d->m_service->setAttribute(QBluetoothServiceInfo::ServiceName, d->m_name);
- d->m_service->setAttribute(QBluetoothServiceInfo::ServiceDescription,
- d->m_description);
-
- d->m_service->setServiceUuid(QBluetoothUuid(d->m_uuid));
+ QBluetoothServiceInfo::Sequence classId;
+ classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
+ d->m_service->setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
//qDebug() << "name/uuid" << d->m_name << d->m_uuid << d->m_port;
@@ -417,16 +322,14 @@ void QDeclarativeBluetoothService::setRegistered(bool registered)
QBluetoothServiceInfo::Sequence protocolDescriptorList;
QBluetoothServiceInfo::Sequence protocol;
- //qDebug() << "Port" << d->m_port;
-
- if (d->m_protocol == "l2cap") {
+ if (d->m_protocol == L2CapProtocol) {
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap))
- << QVariant::fromValue(quint16(d->m_port));
+ << QVariant::fromValue(quint16(d->m_server->serverPort()));
protocolDescriptorList.append(QVariant::fromValue(protocol));
}
- else if (d->m_protocol == "rfcomm") {
+ else if (d->m_protocol == RfcommProtocol) {
protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
- << QVariant::fromValue(quint8(d->m_port));
+ << QVariant::fromValue(quint8(d->m_server->serverPort()));
protocolDescriptorList.append(QVariant::fromValue(protocol));
}
else {
@@ -436,7 +339,6 @@ void QDeclarativeBluetoothService::setRegistered(bool registered)
protocolDescriptorList);
if (d->m_service->registerService()) {
- //qDebug() << "registered";
emit registeredChanged();
}
else {
@@ -457,23 +359,23 @@ void QDeclarativeBluetoothService::new_connection()
QDeclarativeBluetoothSocket *QDeclarativeBluetoothService::nextClient()
{
- QBluetoothServer *server = qobject_cast<QBluetoothServer *>(d->m_listen);
+ QBluetoothServer *server = qobject_cast<QBluetoothServer *>(d->m_server);
if (server) {
if (server->hasPendingConnections()) {
QBluetoothSocket *socket = server->nextPendingConnection();
- return new QDeclarativeBluetoothSocket(socket, this, 0x0);
+ return new QDeclarativeBluetoothSocket(socket, this, 0);
}
else {
qWarning() << "Socket has no pending connection, failing";
- return 0x0;
+ return 0;
}
}
- return 0x0;
+ return 0;
}
void QDeclarativeBluetoothService::assignNextClient(QDeclarativeBluetoothSocket *dbs)
{
- QBluetoothServer *server = qobject_cast<QBluetoothServer *>(d->m_listen);
+ QBluetoothServer *server = qobject_cast<QBluetoothServer *>(d->m_server);
if (server) {
if (server->hasPendingConnections()) {
QBluetoothSocket *socket = server->nextPendingConnection();
diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice_p.h b/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
index a4b300a1..e7e861c7 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothservice_p.h
@@ -61,13 +61,19 @@ class QDeclarativeBluetoothService : public QObject, public QQmlParserStatus
Q_PROPERTY(QString serviceName READ serviceName WRITE setServiceName NOTIFY detailsChanged)
Q_PROPERTY(QString serviceDescription READ serviceDescription WRITE setServiceDescription NOTIFY detailsChanged)
Q_PROPERTY(QString serviceUuid READ serviceUuid WRITE setServiceUuid NOTIFY detailsChanged)
- Q_PROPERTY(QString serviceProtocol READ serviceProtocol WRITE setServiceProtocol NOTIFY detailsChanged)
- Q_PROPERTY(qint32 servicePort READ servicePort WRITE setServicePort NOTIFY detailsChanged)
+ Q_PROPERTY(Protocol serviceProtocol READ serviceProtocol WRITE setServiceProtocol NOTIFY detailsChanged)
Q_PROPERTY(bool registered READ isRegistered WRITE setRegistered NOTIFY registeredChanged)
Q_INTERFACES(QQmlParserStatus)
+ Q_ENUMS(Protocol)
public:
+ enum Protocol {
+ RfcommProtocol = QBluetoothServiceInfo::RfcommProtocol,
+ L2CapProtocol = QBluetoothServiceInfo::L2capProtocol,
+ UnknownProtocol = QBluetoothServiceInfo::UnknownProtocol
+ };
+
explicit QDeclarativeBluetoothService(QObject *parent = 0);
explicit QDeclarativeBluetoothService(const QBluetoothServiceInfo &service,
QObject *parent = 0);
@@ -78,8 +84,7 @@ public:
QString serviceName() const;
QString serviceDescription() const;
QString serviceUuid() const;
- QString serviceProtocol() const;
- qint32 servicePort() const;
+ Protocol serviceProtocol() const;
bool isRegistered() const;
QBluetoothServiceInfo *serviceInfo() const;
@@ -91,21 +96,18 @@ public:
void classBegin() {}
void componentComplete();
+ void setServiceName(const QString &name);
+ void setDeviceAddress(const QString &address);
+ void setServiceDescription(const QString &description);
+ void setServiceUuid(const QString &uuid);
+ void setServiceProtocol(QDeclarativeBluetoothService::Protocol protocol);
+ void setRegistered(bool registered);
+
signals:
void detailsChanged();
void registeredChanged();
void newClient();
-public slots:
- void setServiceName(QString name);
- void setDeviceAddress(QString address);
- void setServiceDescription(QString description);
- void setServiceUuid(QString uuid);
- void setServiceProtocol(QString protocol);
- void setServicePort(qint32 port);
- void setRegistered(bool registered);
-
-
private slots:
void new_connection();
diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
index 02c6d308..a1329182 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
@@ -54,15 +54,14 @@
/*!
\qmltype BluetoothSocket
\instantiates QDeclarativeBluetoothSocket
- \inqmlmodule QtBluetooth 5.0
- \brief Enables you to connect and communicate with a Bluetooth service or
+ \inqmlmodule QtBluetooth
+ \since 5.2
+ \brief Enables connecting and communicating with a Bluetooth service or
device.
\sa QBluetoothSocket
\sa QDataStream
- The BluetoothSocket type was introduced in \b{QtBluetooth 5.0}.
-
It allows a QML class connect to another Bluetooth device and exchange strings
with it. Data is sent and received using a QDataStream object allowing type
safe transfers of QStrings. QDataStream is a well known format and can be
@@ -118,8 +117,6 @@ public:
QObject::connect(m_socket, SIGNAL(error(QBluetoothSocket::SocketError)), m_dbs, SLOT(socket_error(QBluetoothSocket::SocketError)));
QObject::connect(m_socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), m_dbs, SLOT(socket_state(QBluetoothSocket::SocketState)));
QObject::connect(m_socket, SIGNAL(readyRead()), m_dbs, SLOT(socket_readyRead()));
-
- m_stream = new QDataStream(m_socket);
}
QDeclarativeBluetoothSocket *m_dbs;
@@ -129,8 +126,6 @@ public:
QDeclarativeBluetoothSocket::SocketState m_state;
bool m_componentCompleted;
bool m_connected;
- QDataStream *m_stream;
-
};
QDeclarativeBluetoothSocket::QDeclarativeBluetoothSocket(QObject *parent) :
@@ -160,9 +155,6 @@ QDeclarativeBluetoothSocket::QDeclarativeBluetoothSocket(QBluetoothSocket *socke
QObject::connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socket_error(QBluetoothSocket::SocketError)));
QObject::connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socket_state(QBluetoothSocket::SocketState)));
QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(socket_readyRead()));
-
- d->m_stream = new QDataStream(socket);
-
}
@@ -312,15 +304,6 @@ QDeclarativeBluetoothSocket::SocketState QDeclarativeBluetoothSocket::state() co
return d->m_state;
}
-/*!
- \qmlsignal BluetoothSocket::dataAvailable()
-
- This signal indicates the arrival of new data. It is emitted each time the socket has new
- data available. The data can be read from the property stringData.
- \sa stringData
- \sa sendStringData
- */
-
void QDeclarativeBluetoothSocket::socket_readyRead()
{
emit dataAvailable();
@@ -329,13 +312,11 @@ void QDeclarativeBluetoothSocket::socket_readyRead()
/*!
\qmlproperty string BluetoothSocket::stringData
- This property receives or sends data to remote Bluetooth device. Arrival of
- data is signaled by the dataAvailable signal and can be read by
- stringData. Calling sendStringData will transmit the string.
+ This property receives or sends data to a remote Bluetooth device. Arrival of
+ data can be detected by connecting to this properties changed signal and can be read via
+ stringData. Setting stringData will transmit the string.
If excessive amounts of data are sent, the function may block sending. Reading will
never block.
- \sa dataAvailable
- \sa sendStringData
*/
QString QDeclarativeBluetoothSocket::stringData()
@@ -344,30 +325,28 @@ QString QDeclarativeBluetoothSocket::stringData()
return QString();
QString data;
- *d->m_stream >> data;
+ while (d->m_socket->canReadLine()) {
+ QByteArray line = d->m_socket->readLine();
+ data += QString::fromUtf8(line.constData(), line.length());
+ }
+
return data;
}
/*!
- \qmlmethod BluetoothSocket::sendStringData(data)
-
This method transmits the string data passed with "data" to the remote device.
If excessive amounts of data are sent, the function may block sending.
- \sa dataAvailable
- \sa stringData
*/
-void QDeclarativeBluetoothSocket::sendStringData(QString data)
+void QDeclarativeBluetoothSocket::sendStringData(const QString &data)
{
if (!d->m_connected || !d->m_socket){
qWarning() << "Writing data to unconnected socket";
return;
}
- QByteArray b;
- QDataStream s(&b, QIODevice::WriteOnly);
- s << data;
- d->m_socket->write(b);
+ QByteArray text = data.toUtf8() + '\n';
+ d->m_socket->write(text);
}
void QDeclarativeBluetoothSocket::newSocket(QBluetoothSocket *socket, QDeclarativeBluetoothService *service)
@@ -380,7 +359,7 @@ void QDeclarativeBluetoothSocket::newSocket(QBluetoothSocket *socket, QDeclarati
d->m_socket = socket;
d->m_connected = true;
d->m_componentCompleted = true;
- d->m_error = NoSocketerror;
+ d->m_error = NoError;
QObject::connect(socket, SIGNAL(connected()), this, SLOT(socket_connected()));
QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(socket_disconnected()));
@@ -388,8 +367,6 @@ void QDeclarativeBluetoothSocket::newSocket(QBluetoothSocket *socket, QDeclarati
QObject::connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socket_state(QBluetoothSocket::SocketState)));
QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(socket_readyRead()));
- d->m_stream = new QDataStream(socket);
-
socket_state(socket->state());
emit connectedChanged();
diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h b/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h
index ec63a829..4b83dfb0 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h
@@ -75,8 +75,7 @@ public:
HostNotFoundError = QBluetoothSocket::HostNotFoundError,
ServiceNotFoundError = QBluetoothSocket::ServiceNotFoundError,
NetworkError = QBluetoothSocket::NetworkError,
- UnsupportedProtocolError = QBluetoothSocket::UnsupportedProtocolError,
- NoSocketerror
+ UnsupportedProtocolError = QBluetoothSocket::UnsupportedProtocolError
};
enum SocketState {
@@ -87,7 +86,7 @@ public:
Bound = QBluetoothSocket::BoundState,
Closing = QBluetoothSocket::ClosingState,
Listening = QBluetoothSocket::ListeningState,
- NoServiceSet
+ NoServiceSet = 100 //Leave gap for future enums and to avoid collision with QBluetoothSocket enums
};
explicit QDeclarativeBluetoothSocket(QObject *parent = 0);
@@ -120,7 +119,7 @@ signals:
public slots:
void setService(QDeclarativeBluetoothService *service);
void setConnected(bool connected);
- void sendStringData(QString data);
+ void sendStringData(const QString& data);
private slots:
void socket_connected();
diff --git a/src/imports/nfc/plugin.cpp b/src/imports/nfc/plugin.cpp
index dd97e296..0a423495 100644
--- a/src/imports/nfc/plugin.cpp
+++ b/src/imports/nfc/plugin.cpp
@@ -42,7 +42,7 @@
#include <QtQml/QQmlEngine>
#include <QtQml/QQmlExtensionPlugin>
-#include "qdeclarativendefrecord.h"
+#include "qqmlndefrecord.h"
//#include "qdeclarativenearfieldsocket_p.h"
#include "qdeclarativenearfield_p.h"
#include "qdeclarativendeffilter_p.h"
@@ -55,23 +55,32 @@ QT_USE_NAMESPACE
class QNfcQmlPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
-
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri)
{
- Q_ASSERT(uri == QLatin1String("QtNfc"));
+ Q_ASSERT(uri == QStringLiteral("QtNfc"));
// @uri QtNfc
+ // Register the 5.0 types
int major = 5;
int minor = 0;
//qmlRegisterType<QDeclarativeNearFieldSocket>(uri, major, minor, "NearFieldSocket");
qmlRegisterType<QDeclarativeNearField>(uri, major, minor, "NearField");
qmlRegisterType<QDeclarativeNdefFilter>(uri, major, minor, "NdefFilter");
- qmlRegisterType<QDeclarativeNdefRecord>(uri, major, minor, "NdefRecord");
+ qmlRegisterType<QQmlNdefRecord>(uri, major, minor, "NdefRecord");
+ qmlRegisterType<QDeclarativeNdefTextRecord>(uri, major, minor, "NdefTextRecord");
+ qmlRegisterType<QDeclarativeNdefUriRecord>(uri, major, minor, "NdefUriRecord");
+ qmlRegisterType<QDeclarativeNdefMimeRecord>(uri, major, minor, "NdefMimeRecord");
+
+ // Register the 5.2 types
+ minor = 2;
+ qmlRegisterType<QDeclarativeNearField>(uri, major, minor, "NearField");
+ qmlRegisterType<QDeclarativeNdefFilter>(uri, major, minor, "NdefFilter");
+ qmlRegisterType<QQmlNdefRecord>(uri, major, minor, "NdefRecord");
qmlRegisterType<QDeclarativeNdefTextRecord>(uri, major, minor, "NdefTextRecord");
qmlRegisterType<QDeclarativeNdefUriRecord>(uri, major, minor, "NdefUriRecord");
qmlRegisterType<QDeclarativeNdefMimeRecord>(uri, major, minor, "NdefMimeRecord");
diff --git a/src/imports/nfc/plugins.qmltypes b/src/imports/nfc/plugins.qmltypes
new file mode 100644
index 00000000..346c0bfa
--- /dev/null
+++ b/src/imports/nfc/plugins.qmltypes
@@ -0,0 +1,81 @@
+import QtQuick.tooling 1.1
+
+// This file describes the plugin-supplied types contained in the library.
+// It is used for QML tooling purposes only.
+//
+// This file was auto-generated by:
+// 'qmlplugindump -notrelocatable QtNfc 5.2'
+
+Module {
+ Component {
+ name: "QDeclarativeNdefFilter"
+ prototype: "QObject"
+ exports: ["QtNfc/NdefFilter 5.0", "QtNfc/NdefFilter 5.2"]
+ exportMetaObjectRevisions: [0, 0]
+ Property { name: "type"; type: "string" }
+ Property { name: "typeNameFormat"; type: "QQmlNdefRecord::TypeNameFormat" }
+ Property { name: "minimum"; type: "int" }
+ Property { name: "maximum"; type: "int" }
+ }
+ Component {
+ name: "QDeclarativeNdefMimeRecord"
+ prototype: "QQmlNdefRecord"
+ exports: ["QtNfc/NdefMimeRecord 5.0", "QtNfc/NdefMimeRecord 5.2"]
+ exportMetaObjectRevisions: [0, 0]
+ Property { name: "uri"; type: "string"; isReadonly: true }
+ }
+ Component {
+ name: "QDeclarativeNdefTextRecord"
+ prototype: "QQmlNdefRecord"
+ exports: ["QtNfc/NdefTextRecord 5.0", "QtNfc/NdefTextRecord 5.2"]
+ exportMetaObjectRevisions: [0, 0]
+ Enum {
+ name: "LocaleMatch"
+ values: {
+ "LocaleMatchedNone": 0,
+ "LocaleMatchedEnglish": 1,
+ "LocaleMatchedLanguage": 2,
+ "LocaleMatchedLanguageAndCountry": 3
+ }
+ }
+ Property { name: "text"; type: "string" }
+ Property { name: "locale"; type: "string" }
+ Property { name: "localeMatch"; type: "LocaleMatch"; isReadonly: true }
+ }
+ Component {
+ name: "QDeclarativeNdefUriRecord"
+ prototype: "QQmlNdefRecord"
+ exports: ["QtNfc/NdefUriRecord 5.0", "QtNfc/NdefUriRecord 5.2"]
+ exportMetaObjectRevisions: [0, 0]
+ Property { name: "uri"; type: "string" }
+ }
+ Component {
+ name: "QDeclarativeNearField"
+ prototype: "QObject"
+ exports: ["QtNfc/NearField 5.0", "QtNfc/NearField 5.2"]
+ exportMetaObjectRevisions: [0, 0]
+ Property { name: "messageRecords"; type: "QQmlNdefRecord"; isList: true; isReadonly: true }
+ Property { name: "filter"; type: "QDeclarativeNdefFilter"; isList: true; isReadonly: true }
+ Property { name: "orderMatch"; type: "bool" }
+ }
+ Component {
+ name: "QQmlNdefRecord"
+ prototype: "QObject"
+ exports: ["QtNfc/NdefRecord 5.0", "QtNfc/NdefRecord 5.2"]
+ exportMetaObjectRevisions: [0, 0]
+ Enum {
+ name: "TypeNameFormat"
+ values: {
+ "Empty": 0,
+ "NfcRtd": 1,
+ "Mime": 2,
+ "Uri": 3,
+ "ExternalRtd": 4,
+ "Unknown": 5
+ }
+ }
+ Property { name: "type"; type: "string" }
+ Property { name: "typeNameFormat"; type: "TypeNameFormat" }
+ Property { name: "record"; type: "QNdefRecord" }
+ }
+}
diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp
index 3e0bcef2..5d1dd43f 100644
--- a/src/imports/nfc/qdeclarativendeffilter.cpp
+++ b/src/imports/nfc/qdeclarativendeffilter.cpp
@@ -44,16 +44,15 @@
/*!
\qmltype NdefFilter
\instantiates QDeclarativeNdefFilter
- \brief The NdefFilter type represents a filtering constraint for NDEF message records.
+ \since 5.2
+ \brief Represents a filtering constraint for NDEF message records.
\ingroup nfc-qml
- \inqmlmodule QtNfc 5.0
+ \inqmlmodule QtNfc
\sa NearField
\sa QNdefFilter
- The NdefFilter type was introduced in \b {QtNfc 5.0}.
-
The NdefFilter type is used with the NearField type to read NDEF messages from NFC Forum
tags that match a given structure.
@@ -119,6 +118,20 @@ void QDeclarativeNdefFilter::setType(const QString &t)
emit typeChanged();
}
+QQmlNdefRecord::TypeNameFormat QDeclarativeNdefFilter::typeNameFormat() const
+{
+ return m_typeNameFormat;
+}
+
+void QDeclarativeNdefFilter::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat format)
+{
+ if (m_typeNameFormat == format)
+ return;
+
+ m_typeNameFormat = format;
+ Q_EMIT(typeNameFormatChanged());
+}
+
int QDeclarativeNdefFilter::minimum() const
{
return m_minimum;
diff --git a/src/imports/nfc/qdeclarativendeffilter_p.h b/src/imports/nfc/qdeclarativendeffilter_p.h
index d64db531..2ff8e8e2 100644
--- a/src/imports/nfc/qdeclarativendeffilter_p.h
+++ b/src/imports/nfc/qdeclarativendeffilter_p.h
@@ -43,21 +43,25 @@
#define QDECLARATIVENDEFFILTER_P_H
#include <QtCore/QObject>
+#include <qqmlndefrecord.h>
class QDeclarativeNdefFilter : public QObject
{
Q_OBJECT
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
+ Q_PROPERTY(QQmlNdefRecord::TypeNameFormat typeNameFormat READ typeNameFormat WRITE setTypeNameFormat NOTIFY typeNameFormatChanged)
Q_PROPERTY(int minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
Q_PROPERTY(int maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
-
public:
explicit QDeclarativeNdefFilter(QObject *parent = 0);
QString type() const;
void setType(const QString &t);
+ QQmlNdefRecord::TypeNameFormat typeNameFormat() const;
+ void setTypeNameFormat(QQmlNdefRecord::TypeNameFormat format);
+
int minimum() const;
void setMinimum(int value);
@@ -68,11 +72,13 @@ signals:
void typeChanged();
void minimumChanged();
void maximumChanged();
+ void typeNameFormatChanged();
private:
QString m_type;
int m_minimum;
int m_maximum;
+ QQmlNdefRecord::TypeNameFormat m_typeNameFormat;
};
#endif // QDECLARATIVENDEFFILTER_P_H
diff --git a/src/imports/nfc/qdeclarativendefmimerecord.cpp b/src/imports/nfc/qdeclarativendefmimerecord.cpp
index 46ba975d..3141c94f 100644
--- a/src/imports/nfc/qdeclarativendefmimerecord.cpp
+++ b/src/imports/nfc/qdeclarativendefmimerecord.cpp
@@ -43,15 +43,14 @@
/*!
\qmltype NdefMimeRecord
- \brief The NdefMimeRecord type represents an NFC MIME record.
+ \since 5.2
+ \brief Represents an NFC MIME record.
\ingroup connectivity-nfc
- \inqmlmodule QtNfc 5.0
+ \inqmlmodule QtNfc
\inherits NdefRecord
- The NdefMimeRecord type was introduced in \b {QtNfc 5.0}.
-
The NdefMimeRecord type can contain data with an associated MIME type. The data is
accessible from the uri in the \l {NdefMimeRecord::uri}{uri} property.
*/
@@ -80,12 +79,12 @@ static inline QNdefRecord castToMimeRecord(const QNdefRecord &record)
}
QDeclarativeNdefMimeRecord::QDeclarativeNdefMimeRecord(QObject *parent)
-: QDeclarativeNdefRecord(createMimeRecord(), parent)
+: QQmlNdefRecord(createMimeRecord(), parent)
{
}
QDeclarativeNdefMimeRecord::QDeclarativeNdefMimeRecord(const QNdefRecord &record, QObject *parent)
-: QDeclarativeNdefRecord(castToMimeRecord(record), parent)
+: QQmlNdefRecord(castToMimeRecord(record), parent)
{
}
diff --git a/src/imports/nfc/qdeclarativendefmimerecord_p.h b/src/imports/nfc/qdeclarativendefmimerecord_p.h
index bad83235..3338fcc6 100644
--- a/src/imports/nfc/qdeclarativendefmimerecord_p.h
+++ b/src/imports/nfc/qdeclarativendefmimerecord_p.h
@@ -42,11 +42,11 @@
#ifndef QDECLARATIVENDEFMIMERECORD_P_H
#define QDECLARATIVENDEFMIMERECORD_P_H
-#include <qdeclarativendefrecord.h>
+#include <qqmlndefrecord.h>
QT_USE_NAMESPACE
-class QDeclarativeNdefMimeRecord : public QDeclarativeNdefRecord
+class QDeclarativeNdefMimeRecord : public QQmlNdefRecord
{
Q_OBJECT
diff --git a/src/imports/nfc/qdeclarativendeftextrecord.cpp b/src/imports/nfc/qdeclarativendeftextrecord.cpp
index 7542edf0..bd63aa2b 100644
--- a/src/imports/nfc/qdeclarativendeftextrecord.cpp
+++ b/src/imports/nfc/qdeclarativendeftextrecord.cpp
@@ -45,17 +45,16 @@
/*!
\qmltype NdefTextRecord
- \brief The NdefTextRecord type represents an NFC RTD-Text NDEF record.
+ \since 5.2
+ \brief Represents an NFC RTD-Text NDEF record.
\ingroup nfc-qml
- \inqmlmodule QtNfc 5.0
+ \inqmlmodule QtNfc
\inherits NdefRecord
\sa QNdefNfcTextRecord
- The NdefTextRecord type was introduced in \b {QtNfc 5.0}.
-
The NdefTextRecord type contains a localized piece of text that can be display to the user.
An NDEF message may contain many text records for different locales, it is up to the
application to select the most appropriate one to display to the user. The localeMatch
@@ -108,12 +107,12 @@
Q_DECLARE_NDEFRECORD(QDeclarativeNdefTextRecord, QNdefRecord::NfcRtd, "T")
QDeclarativeNdefTextRecord::QDeclarativeNdefTextRecord(QObject *parent)
-: QDeclarativeNdefRecord(QNdefNfcTextRecord(), parent)
+: QQmlNdefRecord(QNdefNfcTextRecord(), parent)
{
}
QDeclarativeNdefTextRecord::QDeclarativeNdefTextRecord(const QNdefRecord &record, QObject *parent)
-: QDeclarativeNdefRecord(QNdefNfcTextRecord(record), parent)
+: QQmlNdefRecord(QNdefNfcTextRecord(record), parent)
{
}
diff --git a/src/imports/nfc/qdeclarativendeftextrecord_p.h b/src/imports/nfc/qdeclarativendeftextrecord_p.h
index 8701ab17..946e1fb4 100644
--- a/src/imports/nfc/qdeclarativendeftextrecord_p.h
+++ b/src/imports/nfc/qdeclarativendeftextrecord_p.h
@@ -42,13 +42,13 @@
#ifndef QDECLARATIVENDEFTEXTRECORD_P_H
#define QDECLARATIVENDEFTEXTRECORD_P_H
-#include <qdeclarativendefrecord.h>
+#include <qqmlndefrecord.h>
#include <qndefnfctextrecord.h>
QT_USE_NAMESPACE
-class QDeclarativeNdefTextRecord : public QDeclarativeNdefRecord
+class QDeclarativeNdefTextRecord : public QQmlNdefRecord
{
Q_OBJECT
diff --git a/src/imports/nfc/qdeclarativendefurirecord.cpp b/src/imports/nfc/qdeclarativendefurirecord.cpp
index 00dcd031..a1f4824f 100644
--- a/src/imports/nfc/qdeclarativendefurirecord.cpp
+++ b/src/imports/nfc/qdeclarativendefurirecord.cpp
@@ -45,16 +45,17 @@
/*!
\qmltype NdefUriRecord
- \brief The NdefUriRecord type represents an NFC RTD-URI NDEF record.
+ \since 5.2
+ \brief Represents an NFC RTD-URI NDEF record.
\ingroup nfc-qml
- \inqmlmodule QtNfc 5.0
+ \inqmlmodule QtNfc
\inherits NdefRecord
\sa QNdefNfcUriRecord
- The NdefUriRecord type was introduced in \b {QtNfc 5.0}.
+ The NdefUriRecord type can contain a uniform resource identifier.
*/
/*!
@@ -66,12 +67,12 @@
Q_DECLARE_NDEFRECORD(QDeclarativeNdefUriRecord, QNdefRecord::NfcRtd, "U")
QDeclarativeNdefUriRecord::QDeclarativeNdefUriRecord(QObject *parent)
-: QDeclarativeNdefRecord(QNdefNfcUriRecord(), parent)
+: QQmlNdefRecord(QNdefNfcUriRecord(), parent)
{
}
QDeclarativeNdefUriRecord::QDeclarativeNdefUriRecord(const QNdefRecord &record, QObject *parent)
-: QDeclarativeNdefRecord(QNdefNfcUriRecord(record), parent)
+: QQmlNdefRecord(QNdefNfcUriRecord(record), parent)
{
}
diff --git a/src/imports/nfc/qdeclarativendefurirecord_p.h b/src/imports/nfc/qdeclarativendefurirecord_p.h
index b935a55b..67718c7f 100644
--- a/src/imports/nfc/qdeclarativendefurirecord_p.h
+++ b/src/imports/nfc/qdeclarativendefurirecord_p.h
@@ -42,7 +42,7 @@
#ifndef QDECLARATIVENDEFURIRECORD_P_H
#define QDECLARATIVENDEFURIRECORD_P_H
-#include <qdeclarativendefrecord.h>
+#include <qqmlndefrecord.h>
#include <qndefnfcurirecord.h>
@@ -50,7 +50,7 @@
QT_USE_NAMESPACE
-class QDeclarativeNdefUriRecord : public QDeclarativeNdefRecord
+class QDeclarativeNdefUriRecord : public QQmlNdefRecord
{
Q_OBJECT
diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp
index 7e7e188a..673c9a0d 100644
--- a/src/imports/nfc/qdeclarativenearfield.cpp
+++ b/src/imports/nfc/qdeclarativenearfield.cpp
@@ -52,10 +52,11 @@
/*!
\qmltype NearField
\instantiates QDeclarativeNearField
- \brief The NearField type provides access to NDEF messages stored on NFC Forum tags.
+ \since 5.2
+ \brief Provides access to NDEF messages stored on NFC Forum tags.
\ingroup nfc-qml
- \inqmlmodule QtNfc 5.0
+ \inqmlmodule QtNfc
\sa NdefFilter
\sa NdefRecord
@@ -64,15 +65,13 @@
\sa QNdefMessage
\sa QNdefRecord
- The NearField type was introduced in \b {QtNfc 5.0}.
-
The NearField type can be used to read NDEF messages from NFC Forum tags. Set the \l filter
and \l orderMatch properties to match the required NDEF messages. Once an NDEF message is
successfully read from a tag the \l messageRecords property is updated.
\code
NearField {
- filter: [ NdefFilter { type: "urn:nfc:wkt:U"; minimum: 1; maximum: 1 } ]
+ filter: [ NdefFilter { type: "U"; typeNameFormat: NdefRecord.NfcRtd; minimum: 1; maximum: 1 } ]
orderMatch: false
onMessageRecordsChanged: displayMessage()
@@ -90,7 +89,10 @@
\qmlproperty list<NdefFilter> NearField::filter
This property holds the NDEF filter constraints. The \l messageRecords property will only be
- set to NDEF messages which match the filter.
+ set to NDEF messages which match the filter. If no filter is set, a message handler for
+ all NDEF messages will be registered.
+
+ \l QNearFieldManager::registerNdefMessageHandler()
*/
/*!
@@ -106,9 +108,9 @@ QDeclarativeNearField::QDeclarativeNearField(QObject *parent)
{
}
-QQmlListProperty<QDeclarativeNdefRecord> QDeclarativeNearField::messageRecords()
+QQmlListProperty<QQmlNdefRecord> QDeclarativeNearField::messageRecords()
{
- return QQmlListProperty<QDeclarativeNdefRecord>(this, 0,
+ return QQmlListProperty<QQmlNdefRecord>(this, 0,
&QDeclarativeNearField::append_messageRecord,
&QDeclarativeNearField::count_messageRecords,
&QDeclarativeNearField::at_messageRecord,
@@ -143,8 +145,7 @@ void QDeclarativeNearField::componentComplete()
{
m_componentCompleted = true;
- if (!m_filter.isEmpty())
- registerMessageHandler();
+ registerMessageHandler();
}
void QDeclarativeNearField::registerMessageHandler()
@@ -155,28 +156,17 @@ void QDeclarativeNearField::registerMessageHandler()
if (m_messageHandlerId != -1)
m_manager->unregisterNdefMessageHandler(m_messageHandlerId);
- // no filter abort
- if (m_filter.isEmpty())
- return;
+ QNdefFilter ndefFilter;
+ ndefFilter.setOrderMatch(m_orderMatch);
+ foreach (const QDeclarativeNdefFilter *filter, m_filterList) {
+ const QString type = filter->type();
+ uint min = filter->minimum() < 0 ? UINT_MAX : filter->minimum();
+ uint max = filter->maximum() < 0 ? UINT_MAX : filter->maximum();
- QNdefFilter filter;
- filter.setOrderMatch(m_orderMatch);
- foreach (QDeclarativeNdefFilter *f, m_filter) {
- const QString type = f->type();
- uint min = f->minimum() < 0 ? UINT_MAX : f->minimum();
- uint max = f->maximum() < 0 ? UINT_MAX : f->maximum();
-
- if (type.startsWith(QLatin1String("urn:nfc:wkt:")))
- filter.appendRecord(QNdefRecord::NfcRtd, type.mid(12).toUtf8(), min, max);
- else if (type.startsWith(QLatin1String("urn:nfc:ext:")))
- filter.appendRecord(QNdefRecord::ExternalRtd, type.mid(12).toUtf8(), min, max);
- else if (type.startsWith(QLatin1String("urn:nfc:mime")))
- filter.appendRecord(QNdefRecord::Mime, type.mid(13).toUtf8(), min, max);
- else
- qWarning("Unknown NDEF record type %s", qPrintable(type));
+ ndefFilter.appendRecord(static_cast<QNdefRecord::TypeNameFormat>(filter->typeNameFormat()), type.toUtf8(), min, max);
}
- m_messageHandlerId = m_manager->registerNdefMessageHandler(filter, this, SLOT(_q_handleNdefMessage(QNdefMessage)));
+ m_messageHandlerId = m_manager->registerNdefMessageHandler(ndefFilter, this, SLOT(_q_handleNdefMessage(QNdefMessage)));
}
void QDeclarativeNearField::_q_handleNdefMessage(const QNdefMessage &message)
@@ -195,8 +185,8 @@ void QDeclarativeNearField::_q_handleNdefMessage(const QNdefMessage &message)
emit messageRecordsChanged();
}
-void QDeclarativeNearField::append_messageRecord(QQmlListProperty<QDeclarativeNdefRecord> *list,
- QDeclarativeNdefRecord *record)
+void QDeclarativeNearField::append_messageRecord(QQmlListProperty<QQmlNdefRecord> *list,
+ QQmlNdefRecord *record)
{
QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object);
if (!nearField)
@@ -208,7 +198,7 @@ void QDeclarativeNearField::append_messageRecord(QQmlListProperty<QDeclarativeNd
emit nearField->messageRecordsChanged();
}
-int QDeclarativeNearField::count_messageRecords(QQmlListProperty<QDeclarativeNdefRecord> *list)
+int QDeclarativeNearField::count_messageRecords(QQmlListProperty<QQmlNdefRecord> *list)
{
QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object);
if (!nearField)
@@ -217,7 +207,7 @@ int QDeclarativeNearField::count_messageRecords(QQmlListProperty<QDeclarativeNde
return nearField->m_message.count();
}
-QDeclarativeNdefRecord *QDeclarativeNearField::at_messageRecord(QQmlListProperty<QDeclarativeNdefRecord> *list,
+QQmlNdefRecord *QDeclarativeNearField::at_messageRecord(QQmlListProperty<QQmlNdefRecord> *list,
int index)
{
QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object);
@@ -227,7 +217,7 @@ QDeclarativeNdefRecord *QDeclarativeNearField::at_messageRecord(QQmlListProperty
return nearField->m_message.at(index);
}
-void QDeclarativeNearField::clear_messageRecords(QQmlListProperty<QDeclarativeNdefRecord> *list)
+void QDeclarativeNearField::clear_messageRecords(QQmlListProperty<QQmlNdefRecord> *list)
{
QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object);
if (nearField) {
@@ -246,7 +236,7 @@ void QDeclarativeNearField::append_filter(QQmlListProperty<QDeclarativeNdefFilte
return;
filter->setParent(nearField);
- nearField->m_filter.append(filter);
+ nearField->m_filterList.append(filter);
emit nearField->filterChanged();
if (nearField->m_componentCompleted)
@@ -259,7 +249,7 @@ int QDeclarativeNearField::count_filters(QQmlListProperty<QDeclarativeNdefFilter
if (!nearField)
return 0;
- return nearField->m_filter.count();
+ return nearField->m_filterList.count();
}
QDeclarativeNdefFilter *QDeclarativeNearField::at_filter(QQmlListProperty<QDeclarativeNdefFilter> *list,
@@ -269,7 +259,7 @@ QDeclarativeNdefFilter *QDeclarativeNearField::at_filter(QQmlListProperty<QDecla
if (!nearField)
return 0;
- return nearField->m_filter.at(index);
+ return nearField->m_filterList.at(index);
}
void QDeclarativeNearField::clear_filter(QQmlListProperty<QDeclarativeNdefFilter> *list)
@@ -278,8 +268,8 @@ void QDeclarativeNearField::clear_filter(QQmlListProperty<QDeclarativeNdefFilter
if (!nearField)
return;
- qDeleteAll(nearField->m_filter);
- nearField->m_filter.clear();
+ qDeleteAll(nearField->m_filterList);
+ nearField->m_filterList.clear();
emit nearField->filterChanged();
if (nearField->m_componentCompleted)
nearField->registerMessageHandler();
diff --git a/src/imports/nfc/qdeclarativenearfield_p.h b/src/imports/nfc/qdeclarativenearfield_p.h
index d3f4b50f..14a6d986 100644
--- a/src/imports/nfc/qdeclarativenearfield_p.h
+++ b/src/imports/nfc/qdeclarativenearfield_p.h
@@ -47,7 +47,7 @@
#include <QtQml/QQmlParserStatus>
#include <QtNfc/QNearFieldManager>
-#include "qdeclarativendefrecord.h"
+#include "qqmlndefrecord.h"
QT_USE_NAMESPACE
@@ -57,7 +57,7 @@ class QDeclarativeNearField : public QObject, public QQmlParserStatus
{
Q_OBJECT
- Q_PROPERTY(QQmlListProperty<QDeclarativeNdefRecord> messageRecords READ messageRecords NOTIFY messageRecordsChanged)
+ Q_PROPERTY(QQmlListProperty<QQmlNdefRecord> messageRecords READ messageRecords NOTIFY messageRecordsChanged)
Q_PROPERTY(QQmlListProperty<QDeclarativeNdefFilter> filter READ filter NOTIFY filterChanged)
Q_PROPERTY(bool orderMatch READ orderMatch WRITE setOrderMatch NOTIFY orderMatchChanged)
@@ -66,7 +66,7 @@ class QDeclarativeNearField : public QObject, public QQmlParserStatus
public:
explicit QDeclarativeNearField(QObject *parent = 0);
- QQmlListProperty<QDeclarativeNdefRecord> messageRecords();
+ QQmlListProperty<QQmlNdefRecord> messageRecords();
QQmlListProperty<QDeclarativeNdefFilter> filter();
@@ -86,8 +86,8 @@ private slots:
void _q_handleNdefMessage(const QNdefMessage &message);
private:
- QList<QDeclarativeNdefRecord *> m_message;
- QList<QDeclarativeNdefFilter *> m_filter;
+ QList<QQmlNdefRecord *> m_message;
+ QList<QDeclarativeNdefFilter *> m_filterList;
bool m_orderMatch;
bool m_componentCompleted;
bool m_messageUpdating;
@@ -97,12 +97,12 @@ private:
void registerMessageHandler();
- static void append_messageRecord(QQmlListProperty<QDeclarativeNdefRecord> *list,
- QDeclarativeNdefRecord *record);
- static int count_messageRecords(QQmlListProperty<QDeclarativeNdefRecord> *list);
- static QDeclarativeNdefRecord *at_messageRecord(QQmlListProperty<QDeclarativeNdefRecord> *list,
+ static void append_messageRecord(QQmlListProperty<QQmlNdefRecord> *list,
+ QQmlNdefRecord *record);
+ static int count_messageRecords(QQmlListProperty<QQmlNdefRecord> *list);
+ static QQmlNdefRecord *at_messageRecord(QQmlListProperty<QQmlNdefRecord> *list,
int index);
- static void clear_messageRecords(QQmlListProperty<QDeclarativeNdefRecord> *list);
+ static void clear_messageRecords(QQmlListProperty<QQmlNdefRecord> *list);
static void append_filter(QQmlListProperty<QDeclarativeNdefFilter> *list,
QDeclarativeNdefFilter *filter);
diff --git a/src/imports/nfc/qdeclarativenearfieldsocket.cpp b/src/imports/nfc/qdeclarativenearfieldsocket.cpp
index 15e59f9b..062970b7 100644
--- a/src/imports/nfc/qdeclarativenearfieldsocket.cpp
+++ b/src/imports/nfc/qdeclarativenearfieldsocket.cpp
@@ -46,12 +46,11 @@
/*!
\qmltype NearFieldSocket
\instantiates QDeclarativeNearFieldSocket
- \brief The NearFieldSocket type represents an LLCP socket.
+ \since 5.2
+ \brief Represents an LLCP socket.
\ingroup nfc-qml
- \inqmlmodule QtNfc 5.0
-
- The NearFieldSocket type was introduced in \b {QtNfc 5.0}.
+ \inqmlmodule QtNfc
The NearFieldSocket type can be used to create a peer-to-peer connection over NFC LLCP
sockets. NearfieldSocket can be used for both client and server side sockets.
diff --git a/src/nfc/doc/snippets/doc_src_qtnfc.qml b/src/nfc/doc/snippets/doc_src_qtnfc.qml
index 867004f6..6c4d892d 100644
--- a/src/nfc/doc/snippets/doc_src_qtnfc.qml
+++ b/src/nfc/doc/snippets/doc_src_qtnfc.qml
@@ -39,7 +39,7 @@
****************************************************************************/
//! [import]
-import QtNfc 5.0
+import QtNfc 5.2
//! [import]
Item { }
diff --git a/src/nfc/doc/snippets/foorecord.cpp b/src/nfc/doc/snippets/foorecord.cpp
index be0a6f89..2c4daeb1 100644
--- a/src/nfc/doc/snippets/foorecord.cpp
+++ b/src/nfc/doc/snippets/foorecord.cpp
@@ -42,7 +42,7 @@
#include <qndefrecord.h>
//! [Declare foo record]
-Q_DECLARE_NDEFRECORD(QDeclarativeNdefFooRecord, QNdefRecord::ExternalRtd, "com.example:f")
+Q_DECLARE_NDEFRECORD(QQmlNdefFooRecord, QNdefRecord::ExternalRtd, "com.example:f")
//! [Declare foo record]
//! [createFooRecord]
@@ -69,22 +69,22 @@ static inline QNdefRecord copyFooRecord(const QNdefRecord &record)
//! [copyFooRecord]
//! [Constructors]
-QDeclarativeNdefFooRecord::QDeclarativeNdefFooRecord(QObject *parent)
-: QDeclarativeNdefRecord(createFooRecord(), parent)
+QQmlNdefFooRecord::QQmlNdefFooRecord(QObject *parent)
+: QQmlNdefRecord(createFooRecord(), parent)
{
}
-QDeclarativeNdefFooRecord::QDeclarativeNdefFooRecord(const QNdefRecord &record, QObject *parent)
-: QDeclarativeNdefRecord(copyFooRecord(record), parent)
+QQmlNdefFooRecord::QQmlNdefFooRecord(const QNdefRecord &record, QObject *parent)
+: QQmlNdefRecord(copyFooRecord(record), parent)
{
}
//! [Constructors]
-QDeclarativeNdefFooRecord::~QDeclarativeNdefFooRecord()
+QQmlNdefFooRecord::~QQmlNdefFooRecord()
{
}
-int QDeclarativeNdefFooRecord::foo() const
+int QQmlNdefFooRecord::foo() const
{
QByteArray payload = record().payload();
@@ -96,7 +96,7 @@ int QDeclarativeNdefFooRecord::foo() const
return value;
}
-void QDeclarativeNdefFooRecord::setFoo(int value)
+void QQmlNdefFooRecord::setFoo(int value)
{
if (foo() == value)
return;
diff --git a/src/nfc/doc/snippets/foorecord.h b/src/nfc/doc/snippets/foorecord.h
index c6432361..59d13df9 100644
--- a/src/nfc/doc/snippets/foorecord.h
+++ b/src/nfc/doc/snippets/foorecord.h
@@ -41,21 +41,21 @@
#ifndef FOORECORD_H
#define FOORECORD_H
-#include <qdeclarativendefrecord.h>
+#include <qqmlndefrecord.h>
QT_USE_NAMESPACE
//! [Foo declaration]
-class QDeclarativeNdefFooRecord : public QDeclarativeNdefRecord
+class QQmlNdefFooRecord : public QQmlNdefRecord
{
Q_OBJECT
Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged)
public:
- explicit QDeclarativeNdefFooRecord(QObject *parent = 0);
- Q_INVOKABLE QDeclarativeNdefFooRecord(const QNdefRecord &record, QObject *parent = 0);
- ~QDeclarativeNdefFooRecord();
+ explicit QQmlNdefFooRecord(QObject *parent = 0);
+ Q_INVOKABLE QQmlNdefFooRecord(const QNdefRecord &record, QObject *parent = 0);
+ ~QQmlNdefFooRecord();
int foo() const;
void setFoo(int value);
diff --git a/src/nfc/doc/src/examples.qdoc b/src/nfc/doc/src/examples.qdoc
index f49c0d8f..64cc0982 100644
--- a/src/nfc/doc/src/examples.qdoc
+++ b/src/nfc/doc/src/examples.qdoc
@@ -29,10 +29,10 @@
\ingroup all-examples
\page nfc-examples.html
\title Qt NFC Examples
-\brief Examples for the QtNfc module
+\brief Examples for the Qt NFC module.
-This is a variety of examples that cover the entire range of the the Qt NFC API. You will find them
-in their own documentation but are also accessible from here.
+This is a variety of examples that cover the entire range of the Qt NFC API. You will find them
+in their own documentation, but they are also accessible from here.
\section2 C++ Tutorial
diff --git a/src/nfc/doc/src/nfc-cpp.qdoc b/src/nfc/doc/src/nfc-cpp.qdoc
index b52db05b..4df93e69 100644
--- a/src/nfc/doc/src/nfc-cpp.qdoc
+++ b/src/nfc/doc/src/nfc-cpp.qdoc
@@ -33,7 +33,7 @@
\title Qt NFC C++ Classes
\brief An API for accessing NFC Forum Tags.
-The \l{Qt NFC} C++ API enables an application to access NFC Forum Tagss.
+The \l{Qt NFC} C++ API enables an application to access NFC Forum Tags.
To use the C++ library in your application, add the following configuration
option to your \c .pro file:
diff --git a/src/nfc/doc/src/nfc-index.qdoc b/src/nfc/doc/src/nfc-index.qdoc
index a353a759..7309e4cc 100644
--- a/src/nfc/doc/src/nfc-index.qdoc
+++ b/src/nfc/doc/src/nfc-index.qdoc
@@ -28,10 +28,10 @@
/*!
\page qtnfc-index.html
\title Qt NFC
-\brief Qt NFC enables connectivity between NFC enabled devices.
+\brief Enables connectivity between NFC enabled devices.
NFC is an extremely short-range (less than 20 centimeters) wireless technology and has a
-maximum transfer rate of 424 kbit/s. NFC is ideal for transferring small packets of data when two
+maximum transfer rate of 424 kbit/s. NFC is ideal for transferring small packets of data when two
devices are touched together.
The NFC API provides APIs for interacting with NFC Forum Tags and NFC Forum Devices, including
diff --git a/src/nfc/doc/src/nfc-overview.qdoc b/src/nfc/doc/src/nfc-overview.qdoc
index 6c479c62..b7d029bb 100644
--- a/src/nfc/doc/src/nfc-overview.qdoc
+++ b/src/nfc/doc/src/nfc-overview.qdoc
@@ -29,21 +29,21 @@
\ingroup technology-apis
\title Qt NFC Overview
\page qtnfc-overview.html
-\brief The Qt NFC classes provides access to NFC enabled devices.
+\brief Provides access to NFC enabled devices.
\tableofcontents
With the Qt NFC API typical use cases are:
\list
- \li Detect NFC tags entering and leaving communication range.
+ \li Detect NFC tags entering and leaving the communication range.
\li Read and write NDEF message on NFC Forum Tags.
\li Register an NDEF message handler for a particular content type.
\endlist
-The following sections describe how to use QtNfc C++ classes for the above use cases.
+The following sections describe how to use Qt NFC C++ classes for the above use cases.
\section1 Detect NFC tags entering and leaving communication range.
-\section1 Read and write NDEF message on NFC Forum Tags.
+\section1 Read and write an NDEF message on NFC Forum Tags.
\section1 Register an NDEF message handler for a particular content type.
*/
diff --git a/src/nfc/doc/src/nfc-qml.qdoc b/src/nfc/doc/src/nfc-qml.qdoc
index 54902112..42e57159 100644
--- a/src/nfc/doc/src/nfc-qml.qdoc
+++ b/src/nfc/doc/src/nfc-qml.qdoc
@@ -28,12 +28,12 @@
/*!
-\qmlmodule QtNfc 5.0
+\qmlmodule QtNfc 5.2
\title Qt NFC QML Types
\ingroup qmlmodules
-\brief Provides QML types for accessing NFC Forum Tags
+\brief Provides QML types for accessing NFC Forum Tags.
-To use the classes of the module in your application you need the following
+To use the classes of the module in your application, you need the following
import statement in your \c .qml file:
\snippet doc_src_qtnfc.qml import
diff --git a/src/nfc/nfc.pro b/src/nfc/nfc.pro
index 1b4d6e24..dfa1d3ef 100644
--- a/src/nfc/nfc.pro
+++ b/src/nfc/nfc.pro
@@ -15,7 +15,7 @@ PUBLIC_HEADERS += \
qndefmessage.h \
qndeffilter.h \
qndefnfcurirecord.h \
- qdeclarativendefrecord.h \
+ qqmlndefrecord.h \
qndefnfcsmartposterrecord.h
PRIVATE_HEADERS += \
@@ -46,7 +46,7 @@ SOURCES += \
qnearfieldtagtype4.cpp \
qtlv.cpp \
qllcpserver.cpp \
- qdeclarativendefrecord.cpp \
+ qqmlndefrecord.cpp \
qndefnfcsmartposterrecord.cpp
qnx {
diff --git a/src/nfc/qndefrecord.cpp b/src/nfc/qndefrecord.cpp
index 1790187c..a1673def 100644
--- a/src/nfc/qndefrecord.cpp
+++ b/src/nfc/qndefrecord.cpp
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
QNdefRecord and derived classes are used to parse the contents of
\l {QNdefMessage}{NDEF messages} and create new NDEF messages.
- Use typeNameFormat(), userTypeNameFormat(), setTypeNameFormat() and setUserTypeNameFormat() to
+ Use typeNameFormat() and setTypeNameFormat() to
get and set the type name format of the NDEF record.
Use type() and setType() to get and set the type of the NDEF record.
diff --git a/src/nfc/qndefrecord_p.h b/src/nfc/qndefrecord_p.h
index d55c1724..0dfe583a 100644
--- a/src/nfc/qndefrecord_p.h
+++ b/src/nfc/qndefrecord_p.h
@@ -53,8 +53,11 @@ QT_BEGIN_NAMESPACE
class QNdefRecordPrivate : public QSharedData
{
public:
- //bool messageBegin : 1;
- //bool messageEnd : 1;
+ QNdefRecordPrivate() : QSharedData()
+ {
+ typeNameFormat = 0; //TypeNameFormat::Empty
+ }
+
unsigned int typeNameFormat : 3;
QByteArray type;
diff --git a/src/nfc/qnearfieldmanager.cpp b/src/nfc/qnearfieldmanager.cpp
index 5e483343..f2fafdce 100644
--- a/src/nfc/qnearfieldmanager.cpp
+++ b/src/nfc/qnearfieldmanager.cpp
@@ -108,6 +108,21 @@ QT_BEGIN_NAMESPACE
manager->registerNdefMessageHandler(this,
SLOT(handleNdefMessage(QNdefMessage,QNearFieldTarget)));
\endcode
+
+ On BlackBerry the registration for NDEF message handlers is done over the
+ \l{https://developer.blackberry.com/native/documentation/core/invocation_framework.html}{Invocation Framework}.
+ This means that the application has to set an invoke target in the bar descriptor xml file when using
+ \l registerNdefMessageHandler().
+
+ \code
+ <invoke-target id="com.myapp.id">
+ <type>APPLICATION</type>
+ <filter>
+ <action>bb.action.OPEN</action>
+ <mime-type>application/vnd.rim.nfc.ndef</mime-type>
+ </filter>
+ </invoke-target>
+ \endcode
*/
/*!
diff --git a/src/nfc/qnearfieldmanager.h b/src/nfc/qnearfieldmanager.h
index b690c2e2..0e91abcc 100644
--- a/src/nfc/qnearfieldmanager.h
+++ b/src/nfc/qnearfieldmanager.h
@@ -78,8 +78,6 @@ public:
bool startTargetDetection();
void stopTargetDetection();
- template<typename T>
- int registerNdefMessageHandler(QObject *object, const char *method);
int registerNdefMessageHandler(QObject *object, const char *method);
int registerNdefMessageHandler(QNdefRecord::TypeNameFormat typeNameFormat,
const QByteArray &type,
@@ -97,15 +95,6 @@ private:
QNearFieldManagerPrivate *d_ptr;
};
-template<typename T>
-int QNearFieldManager::registerNdefMessageHandler(QObject *object, const char *method)
-{
- T record;
-
- return registerNdefMessageHandler(record.userTypeNameFormat(), record.type(),
- object, method);
-}
-
Q_DECLARE_OPERATORS_FOR_FLAGS(QNearFieldManager::TargetAccessModes)
QT_END_NAMESPACE
diff --git a/src/nfc/qnx/qnxnfcmanager.cpp b/src/nfc/qnx/qnxnfcmanager.cpp
index bd072c7b..be23838e 100644
--- a/src/nfc/qnx/qnxnfcmanager.cpp
+++ b/src/nfc/qnx/qnxnfcmanager.cpp
@@ -43,6 +43,7 @@
#include <QMetaMethod>
#include <QMetaObject>
#include "../qllcpsocket_qnx_p.h"
+#include <QCoreApplication>
QT_BEGIN_NAMESPACE
@@ -360,10 +361,14 @@ void QNXNFCManager::setupInvokeTarget() {
QByteArray filter = "actions=bb.action.OPEN;types=application/vnd.rim.nfc.ndef;" + uriFilter;
filters[0] = filter.constData();
- if (BPS_SUCCESS != navigator_invoke_set_filters("20", "org.qtm.NFCTest", filters, 1)) {
+ //Get the correct target-id
+ QString targetId = QCoreApplication::instance()->arguments().first();
+ targetId = targetId.left(targetId.lastIndexOf("."));
+
+ if (BPS_SUCCESS != navigator_invoke_set_filters("20", targetId.toLatin1().constData(), filters, 1)) {
qWarning() << "NFC Error setting share target filter";
} else {
- qQNXNFCDebug() << "NFC share target filter set" << filters[0];
+ qQNXNFCDebug() << "NFC share target filter set" << filters[0] << " Target:" << targetId;
}
}
diff --git a/src/nfc/qdeclarativendefrecord.cpp b/src/nfc/qqmlndefrecord.cpp
index e9e741c5..8a3f24d7 100644
--- a/src/nfc/qdeclarativendefrecord.cpp
+++ b/src/nfc/qqmlndefrecord.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include "qdeclarativendefrecord.h"
+#include "qqmlndefrecord.h"
#include <QtCore/QMap>
#include <QtCore/QRegExp>
@@ -47,15 +47,15 @@
QT_BEGIN_NAMESPACE
/*!
- \class QDeclarativeNdefRecord
- \brief The QDeclarativeNdefRecord class implements the NdefRecord type in QML.
+ \class QQmlNdefRecord
+ \brief The QQmlNdefRecord class implements the NdefRecord type in QML.
\ingroup connectivity-nfc
\inmodule QtNfc
\sa NdefRecord
- The QDeclarativeNdefRecord class is the base class for all NdefRecord types in QML. To
+ The QQmlNdefRecord class is the base class for all NdefRecord types in QML. To
support a new NDEF record type in QML subclass this class and expose new properties, member
functions and signals appropriate for the new record type. The following must be done to
create a new NDEF record type in QML:
@@ -80,17 +80,17 @@ QT_BEGIN_NAMESPACE
Finially the application or plugin code calls qmlRegisterType():
\code
- qmlRegisterType<QDeclarativeNdefFooRecord>(uri, 1, 0, "NdefFooRecord");
+ qmlRegisterType<QQmlNdefFooRecord>(uri, 1, 0, "NdefFooRecord");
\endcode
*/
/*!
\qmltype NdefRecord
- \instantiates QDeclarativeNdefRecord
+ \instantiates QQmlNdefRecord
\brief The NdefRecord type represents a record in an NDEF message.
\ingroup nfc-qml
- \inqmlmodule QtNfc 5.0
+ \inqmlmodule QtNfc
\sa NdefFilter
\sa NearField
@@ -102,14 +102,36 @@ QT_BEGIN_NAMESPACE
This class is not intended to be used directly, but extended from C++.
- \sa QDeclarativeNdefRecord
+ \sa QQmlNdefRecord
*/
/*!
- \qmlproperty string NdefRecord::recordType
+ \qmlproperty string NdefRecord::type
- This property holds the fully qualified record type of the NDEF record. The fully qualified
- record type includes the NIS and NSS prefixes.
+ This property holds the type of the NDEF record.
+*/
+
+/*!
+ \qmlproperty enumeration NdefRecord::typeNameFormat
+
+ This property holds the TNF of the NDEF record.
+
+ \table
+ \header \li Property \li Description
+ \row \li \c NdefRecord.Empty
+ \li An empty NDEF record, the record does not contain a payload.
+ \row \li \c NdefRecord.NfcRtd
+ \li The NDEF record type is defined by an NFC RTD Specification.
+ \row \li \c NdefRecord.Mime
+ \li The NDEF record type follows the construct described in RFC 2046.
+ \row \li \c NdefRecord.Uri
+ \li The NDEF record type follows the construct described in RFC 3986.
+ \row \li \c NdefRecord.ExternalRtd
+ \li The NDEF record type follows the construct for external type names
+ described the NFC RTD Specification.
+ \endtable
+
+ \sa QNdefRecord::typeNameFormat()
*/
/*!
@@ -119,26 +141,32 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QDeclarativeNdefRecord::recordTypeChanged()
+ \fn void QQmlNdefRecord::typeChanged()
This signal is emitted when the record type changes.
*/
/*!
- \property QDeclarativeNdefRecord::record
+ \property QQmlNdefRecord::record
This property hold the NDEF record that this class represents.
*/
/*!
- \property QDeclarativeNdefRecord::recordType
+ \property QQmlNdefRecord::type
+
+ This property hold the type of the NDEF record.
+*/
+
+/*!
+ \property QQmlNdefRecord::typeNameFormat
- This property hold the record type of the NDEF record that this class represents.
+ This property hold the TNF of the NDEF record.
*/
/*!
\macro Q_DECLARE_NDEFRECORD(className, typeNameFormat, type)
- \relates QDeclarativeNdefRecord
+ \relates QQmlNdefRecord
This macro ensures that \a className is declared as the class implementing the NDEF record
identified by \a typeNameFormat and \a type.
@@ -148,7 +176,7 @@ QT_BEGIN_NAMESPACE
static QMap<QString, const QMetaObject *> registeredNdefRecordTypes;
-class QDeclarativeNdefRecordPrivate
+class QQmlNdefRecordPrivate
{
public:
QNdefRecord record;
@@ -181,7 +209,7 @@ void qRegisterNdefRecordTypeHelper(const QMetaObject *metaObject,
/*!
\internal
*/
-QDeclarativeNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord &record)
+QQmlNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord &record)
{
const QString urn = urnForRecordType(record.typeNameFormat(), record.type());
@@ -197,78 +225,105 @@ QDeclarativeNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord
if (!metaObject)
continue;
- return static_cast<QDeclarativeNdefRecord *>(metaObject->newInstance(
+ return static_cast<QQmlNdefRecord *>(metaObject->newInstance(
Q_ARG(QNdefRecord, record), Q_ARG(QObject *, 0)));
}
- return new QDeclarativeNdefRecord(record);
+ return new QQmlNdefRecord(record);
}
/*!
- Constructs a new empty QDeclarativeNdefRecord with \a parent.
+ Constructs a new empty QQmlNdefRecord with \a parent.
*/
-QDeclarativeNdefRecord::QDeclarativeNdefRecord(QObject *parent)
-: QObject(parent), d_ptr(new QDeclarativeNdefRecordPrivate)
+QQmlNdefRecord::QQmlNdefRecord(QObject *parent)
+: QObject(parent), d_ptr(new QQmlNdefRecordPrivate)
{
}
/*!
- Constructs a new QDeclarativeNdefRecord representing \a record. The parent of the newly
+ Constructs a new QQmlNdefRecord representing \a record. The parent of the newly
constructed object will be set to \a parent.
*/
-QDeclarativeNdefRecord::QDeclarativeNdefRecord(const QNdefRecord &record, QObject *parent)
-: QObject(parent), d_ptr(new QDeclarativeNdefRecordPrivate)
+QQmlNdefRecord::QQmlNdefRecord(const QNdefRecord &record, QObject *parent)
+: QObject(parent), d_ptr(new QQmlNdefRecordPrivate)
{
d_ptr->record = record;
}
/*!
- Returns the fully qualified record type of the record. The fully qualified record type
- includes both the NIS and NSS prefixes.
+ \enum QQmlNdefRecord::TypeNameFormat
+
+ This enum describes the type name format of an NDEF record. The values of this enum are according to
+ \l QNdefRecord::TypeNameFormat
+
+ \value Empty An empty NDEF record, the record does not contain a payload.
+ \value NfcRtd The NDEF record type is defined by an NFC RTD Specification.
+ \value Mime The NDEF record type follows the construct described in RFC 2046.
+ \value Uri The NDEF record type follows the construct described in RFC 3986.
+ \value ExternalRtd The NDEF record type follows the construct for external type names
+ described the NFC RTD Specification.
+*/
+
+/*!
+ Returns the type of the record.
+
+ \sa QNdefRecord::setType(), QNdefRecord::type()
*/
-QString QDeclarativeNdefRecord::recordType() const
+QString QQmlNdefRecord::type() const
{
- Q_D(const QDeclarativeNdefRecord);
-
- if (d->record.typeNameFormat() == QNdefRecord::Empty)
- return QString();
+ Q_D(const QQmlNdefRecord);
- return urnForRecordType(d->record.typeNameFormat(), d->record.type());
+ return QLatin1String(d->record.type());
}
/*!
Sets the record type to \a type if it is not currently equal to \a type; otherwise does
- nothing. If the record type is set the recordTypeChanged() signal will be emitted.
+ nothing. If the record type is set the typeChanged() signal will be emitted.
+
+ \sa QNdefRecord::setType(), QNdefRecord::type()
*/
-void QDeclarativeNdefRecord::setRecordType(const QString &type)
+void QQmlNdefRecord::setType(const QString &newtype)
{
- if (type == recordType())
+ if (newtype == type())
return;
- Q_D(QDeclarativeNdefRecord);
-
- if (type.startsWith(QLatin1String("urn:nfc:wkt:"))) {
- d->record.setTypeNameFormat(QNdefRecord::NfcRtd);
- d->record.setType(type.mid(12).toUtf8());
- } else if (type.startsWith(QLatin1String("urn:nfc:ext:"))) {
- d->record.setTypeNameFormat(QNdefRecord::ExternalRtd);
- d->record.setType(type.mid(12).toUtf8());
- } else if (type.startsWith(QLatin1String("urn:nfc:mime:"))) {
- d->record.setTypeNameFormat(QNdefRecord::Mime);
- d->record.setType(type.mid(13).toUtf8());
- } else {
- qWarning("Don't know how to decode NDEF type %s\n", qPrintable(type));
- }
+ Q_D(QQmlNdefRecord);
+ d->record.setType(newtype.toUtf8());
+
+ emit typeChanged();
+}
+
+/*!
+ Sets the type name format of the NDEF record to \a newTypeNameFormat.
+*/
+void QQmlNdefRecord::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat newTypeNameFormat)
+{
+ if (newTypeNameFormat == typeNameFormat())
+ return;
- emit recordTypeChanged();
+ Q_D(QQmlNdefRecord);
+ d->record.setTypeNameFormat(static_cast<QNdefRecord::TypeNameFormat>(newTypeNameFormat));
+
+ emit typeNameFormatChanged();
+}
+
+/*!
+ \fn QQmlNdefRecord::TypeNameFormat QQmlNdefRecord::typeNameFormat() const
+
+ Returns the type name format of the NDEF record.
+*/
+QQmlNdefRecord::TypeNameFormat QQmlNdefRecord::typeNameFormat() const
+{
+ Q_D(const QQmlNdefRecord);
+ return static_cast<QQmlNdefRecord::TypeNameFormat>(d->record.typeNameFormat());
}
/*!
Returns a copy of the record.
*/
-QNdefRecord QDeclarativeNdefRecord::record() const
+QNdefRecord QQmlNdefRecord::record() const
{
- Q_D(const QDeclarativeNdefRecord);
+ Q_D(const QQmlNdefRecord);
return d->record;
}
@@ -277,9 +332,9 @@ QNdefRecord QDeclarativeNdefRecord::record() const
Sets the record to \a record. If the record is set the recordChanged() signal will
be emitted.
*/
-void QDeclarativeNdefRecord::setRecord(const QNdefRecord &record)
+void QQmlNdefRecord::setRecord(const QNdefRecord &record)
{
- Q_D(QDeclarativeNdefRecord);
+ Q_D(QQmlNdefRecord);
if (d->record == record)
return;
diff --git a/src/nfc/qdeclarativendefrecord.h b/src/nfc/qqmlndefrecord.h
index ab7031f4..76ba8bf2 100644
--- a/src/nfc/qdeclarativendefrecord.h
+++ b/src/nfc/qqmlndefrecord.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QDECLARATIVENDEFRECORD_P_H
-#define QDECLARATIVENDEFRECORD_P_H
+#ifndef QQMLNDEFRECORD_H
+#define QQMLNDEFRECORD_H
#include <QtCore/QObject>
#include <QtCore/QMetaType>
@@ -48,40 +48,55 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeNdefRecordPrivate;
+class QQmlNdefRecordPrivate;
-class Q_NFC_EXPORT QDeclarativeNdefRecord : public QObject
+class Q_NFC_EXPORT QQmlNdefRecord : public QObject
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeNdefRecord)
+ Q_DECLARE_PRIVATE(QQmlNdefRecord)
- Q_PROPERTY(QString recordType READ recordType WRITE setRecordType NOTIFY recordTypeChanged)
+ Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
+ Q_PROPERTY(TypeNameFormat typeNameFormat READ typeNameFormat WRITE setTypeNameFormat NOTIFY typeNameFormatChanged)
Q_PROPERTY(QNdefRecord record READ record WRITE setRecord NOTIFY recordChanged)
+ Q_ENUMS(TypeNameFormat)
public:
- explicit QDeclarativeNdefRecord(QObject *parent = 0);
- explicit QDeclarativeNdefRecord(const QNdefRecord &record, QObject *parent = 0);
+ enum TypeNameFormat {
+ Empty = QNdefRecord::Empty,
+ NfcRtd = QNdefRecord::NfcRtd,
+ Mime = QNdefRecord::Mime,
+ Uri = QNdefRecord::Uri,
+ ExternalRtd = QNdefRecord::ExternalRtd,
+ Unknown = QNdefRecord::Unknown
+ };
- QString recordType() const;
- void setRecordType(const QString &t);
+ explicit QQmlNdefRecord(QObject *parent = 0);
+ explicit QQmlNdefRecord(const QNdefRecord &record, QObject *parent = 0);
+
+ QString type() const;
+ void setType(const QString &t);
+
+ void setTypeNameFormat(TypeNameFormat typeNameFormat);
+ TypeNameFormat typeNameFormat() const;
QNdefRecord record() const;
void setRecord(const QNdefRecord &record);
Q_SIGNALS:
- void recordTypeChanged();
+ void typeChanged();
+ void typeNameFormatChanged();
void recordChanged();
private:
- QDeclarativeNdefRecordPrivate *d_ptr;
+ QQmlNdefRecordPrivate *d_ptr;
};
void Q_NFC_EXPORT qRegisterNdefRecordTypeHelper(const QMetaObject *metaObject,
QNdefRecord::TypeNameFormat typeNameFormat,
const QByteArray &type);
-Q_NFC_EXPORT QDeclarativeNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord &record);
+Q_NFC_EXPORT QQmlNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord &record);
template<typename T>
bool qRegisterNdefRecordType(QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray &type)
@@ -95,4 +110,4 @@ static bool _q_##className##_registered = qRegisterNdefRecordType<className>(typ
QT_END_NAMESPACE
-#endif // QDECLARATIVENDEFRECORD_P_H
+#endif // QQMLNDEFRECORD_H
diff --git a/sync.profile b/sync.profile
index d7d8e10e..34518c9a 100644
--- a/sync.profile
+++ b/sync.profile
@@ -14,6 +14,5 @@
%dependencies = (
"qtbase" => "",
"qtdeclarative" => "",
- "qtsystems" => "",
"qtxmlpatterns" => "",
);
diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
index 5c9ea9f0..fb2c1ad3 100644
--- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
+++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp
@@ -93,15 +93,8 @@ private slots:
void tst_sendBuffer_data();
void tst_sendBuffer();
-
-public slots:
- void serviceDiscovered(const QBluetoothServiceInfo &info);
- void finished();
- void error(QBluetoothServiceDiscoveryAgent::Error error);
private:
- bool done_discovery;
QBluetoothAddress remoteAddress;
- QBluetoothAddress foundAddress;
};
tst_QBluetoothTransferManager::tst_QBluetoothTransferManager()
@@ -122,62 +115,16 @@ void tst_QBluetoothTransferManager::initTestCase()
qWarning() << "Using remote device " << remote << " for testing. Ensure that the device is discoverable for pairing requests";
} else {
qWarning() << "Not using any remote device for testing. Set BT_TEST_DEVICE env to run manual tests involving a remote device";
+ QSKIP("Remote upload test not possible. Set BT_TEST_DEVICE");
}
-
-
if (!QBluetoothLocalDevice::allDevices().count())
QSKIP("Skipping test due to missing Bluetooth device");
- if (remoteAddress.isNull())
- QSKIP("Remote upload test not possible. Set BT_TEST_DEVICE");
-
// start Bluetooth if not started
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
device->powerOn();
delete device;
-
- // Go find an echo server for BTADDRESS
- QBluetoothServiceDiscoveryAgent *sda = new QBluetoothServiceDiscoveryAgent(this);
- connect(sda, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
- connect(sda, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(error(QBluetoothServiceDiscoveryAgent::Error)));
- connect(sda, SIGNAL(finished()), this, SLOT(finished()));
-
- qDebug() << "Starting discovery";
- done_discovery = false;
-
- sda->setUuidFilter(QBluetoothUuid(QBluetoothUuid::ObexObjectPush));
- sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
-
- for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
- QTest::qWait(1000);
-
- sda->stop();
-
- if (foundAddress.isNull())
- QFAIL("Unable to find test service/device");
-
- delete sda;
-}
-void tst_QBluetoothTransferManager::error(QBluetoothServiceDiscoveryAgent::Error error)
-{
- qDebug() << "Received error" << error;
- done_discovery = true;
-}
-
-void tst_QBluetoothTransferManager::finished()
-{
- qDebug() << "Finished";
- done_discovery = true;
-}
-
-void tst_QBluetoothTransferManager::serviceDiscovered(const QBluetoothServiceInfo &info)
-{
- qDebug() << "Found: " << info.device().name() << info.device().address().toString() << info.serviceName();
- if (info.device().address() == remoteAddress) {
- foundAddress = remoteAddress;
- done_discovery = true;
- }
}
void tst_QBluetoothTransferManager::tst_construction()
@@ -256,12 +203,8 @@ void tst_QBluetoothTransferManager::tst_sendFile_data()
QTest::addColumn<bool>("expectSuccess");
QTest::addColumn<bool>("isInvalidFile");
- if (foundAddress.isNull()) {
- qDebug("Skipping send file test due to not finding remote device");
- } else {
- QTest::newRow("Push to remote test device") << foundAddress << true << false;
- QTest::newRow("Push of non-existing file") << foundAddress << false << true;
- }
+ QTest::newRow("Push to remote test device") << remoteAddress << true << false;
+ QTest::newRow("Push of non-existing file") << remoteAddress << false << true;
QTest::newRow("Push to invalid address") << QBluetoothAddress() << false << false;
QTest::newRow("Push to non-existend device") << QBluetoothAddress("11:22:33:44:55:66") << false << false;
@@ -276,7 +219,7 @@ void tst_QBluetoothTransferManager::tst_sendFile()
QBluetoothLocalDevice dev;
if (expectSuccess) {
dev.requestPairing(deviceAddress, QBluetoothLocalDevice::Paired);
- QTest::qWait(2000);
+ QTest::qWait(5000);
QCOMPARE(dev.pairingStatus(deviceAddress), QBluetoothLocalDevice::Paired);
}
@@ -289,8 +232,7 @@ void tst_QBluetoothTransferManager::tst_sendFile()
fileHandle = QFINDTESTDATA("testfile.txt");
QVERIFY(!fileHandle.isEmpty());
} else {
- fileHandle = QFINDTESTDATA("arbitraryFileName.txt"); //file doesn't exist
- QVERIFY(fileHandle.isEmpty());
+ fileHandle = ("arbitraryFileName.txt"); //file doesn't exist
}
QFile f(fileHandle);
QCOMPARE(f.exists(), !isInvalidFile);
@@ -311,8 +253,8 @@ void tst_QBluetoothTransferManager::tst_sendFile()
const int maxWaitTime = 20 * 1000; //20s
for (int time = 0;
time<maxWaitTime && (finishedSpy.count()==0);
- time+=10000) {
- QTest::qWait(10000); //if interval
+ time+=1000) {
+ QTest::qWait(1000); //if interval
}
QVERIFY(finishedSpy.count()>0);
@@ -340,13 +282,10 @@ void tst_QBluetoothTransferManager::tst_sendBuffer_data()
QTest::addColumn<bool>("expectSuccess");
QTest::addColumn<QByteArray>("data");
- if (foundAddress.isNull())
- qDebug("Skipping send file test due to not finding remote device");
- else
- QTest::newRow("Push to remote test device") << foundAddress << true <<
+ QTest::newRow("Push to remote test device") << remoteAddress << true <<
QByteArray("This is a very long byte arry which we are going to access via a QBuffer"); ;
- //QTest::newRow("Push to invalid address") << QBluetoothAddress() << false;
- //QTest::newRow("Push to non-existend device") << QBluetoothAddress("11:22:33:44:55:66") << false;
+ QTest::newRow("Push to invalid address") << QBluetoothAddress() << false << QByteArray("test");
+ QTest::newRow("Push to non-existend device") << QBluetoothAddress("11:22:33:44:55:66") << false << QByteArray("test");
}
diff --git a/tests/auto/qndefrecord/tst_qndefrecord.cpp b/tests/auto/qndefrecord/tst_qndefrecord.cpp
index cccd1c61..000ff017 100644
--- a/tests/auto/qndefrecord/tst_qndefrecord.cpp
+++ b/tests/auto/qndefrecord/tst_qndefrecord.cpp
@@ -44,7 +44,7 @@
#include <qndefrecord.h>
#include <qndefnfctextrecord.h>
#include <qndefnfcurirecord.h>
-#include <qdeclarativendefrecord.h>
+#include <qqmlndefrecord.h>
QT_USE_NAMESPACE
@@ -99,9 +99,10 @@ void tst_QNdefRecord::tst_record()
QCOMPARE(record, QNdefRecord());
QVERIFY(!(record != QNdefRecord()));
- QDeclarativeNdefRecord declRecord;
+ QQmlNdefRecord declRecord;
QCOMPARE(declRecord.record(), record);
- QCOMPARE(declRecord.recordType(), QString());
+ QCOMPARE(declRecord.type(), QString());
+ QCOMPARE(declRecord.typeNameFormat(), QQmlNdefRecord::Empty);
}
// test type name format
@@ -255,9 +256,10 @@ void tst_QNdefRecord::tst_textRecord()
QVERIFY(record != QNdefRecord());
- QDeclarativeNdefRecord declRecord(record);
+ QQmlNdefRecord declRecord(record);
QCOMPARE(declRecord.record(), QNdefRecord(record));
- QCOMPARE(declRecord.recordType(), QString("urn:nfc:wkt:T"));
+ QCOMPARE(declRecord.type(), QString("T"));
+ QCOMPARE(declRecord.typeNameFormat(), QQmlNdefRecord::NfcRtd);
}
// test getters
@@ -323,9 +325,10 @@ void tst_QNdefRecord::tst_uriRecord()
QVERIFY(record != QNdefRecord());
- QDeclarativeNdefRecord declRecord(record);
+ QQmlNdefRecord declRecord(record);
QCOMPARE(declRecord.record(), QNdefRecord(record));
- QCOMPARE(declRecord.recordType(), QString("urn:nfc:wkt:U"));
+ QCOMPARE(declRecord.type(), QString("U"));
+ QCOMPARE(declRecord.typeNameFormat(), QQmlNdefRecord::NfcRtd);
}
// test getters
@@ -360,27 +363,21 @@ void tst_QNdefRecord::tst_uriRecord()
void tst_QNdefRecord::tst_declarative_record_data()
{
QTest::addColumn<QNdefRecord::TypeNameFormat>("typeNameFormat");
- QTest::addColumn<QNdefRecord::TypeNameFormat>("typeNameFormatOut");
QTest::addColumn<QByteArray>("type");
- QTest::addColumn<QByteArray>("typeOut");
- QTest::addColumn<QString>("recordType");
-
- QTest::newRow("NfcRtd:U") << QNdefRecord::NfcRtd << QNdefRecord::NfcRtd << QByteArray("U") << QByteArray("U") << QString("urn:nfc:wkt:U");
- QTest::newRow("NfcRtd:T") << QNdefRecord::NfcRtd << QNdefRecord::NfcRtd << QByteArray("T") << QByteArray("T") << QString("urn:nfc:wkt:T");
- QTest::newRow("Empty:BLAH") << QNdefRecord::Empty << QNdefRecord::Empty << QByteArray("BLAH") << QByteArray("") << QString("");
- QTest::newRow("Empty") << QNdefRecord::Empty << QNdefRecord::Empty << QByteArray("") << QByteArray("") << QString("");
- QTest::newRow("Unknown") << QNdefRecord::Unknown << QNdefRecord::Empty << QByteArray("BLAHfoo") << QByteArray("") << QString("");
- QTest::newRow("Mime") << QNdefRecord::Mime << QNdefRecord::Mime << QByteArray("foobar") << QByteArray("foobar") << QString("urn:nfc:mime:foobar");
- QTest::newRow("ExternalRtd") << QNdefRecord::ExternalRtd << QNdefRecord::ExternalRtd << QByteArray("") << QByteArray("") << QString("urn:nfc:ext:");
+
+ QTest::newRow("NfcRtd:U") << QNdefRecord::NfcRtd << QByteArray("U");
+ QTest::newRow("NfcRtd:T") << QNdefRecord::NfcRtd << QByteArray("T");
+ QTest::newRow("Empty:BLAH") << QNdefRecord::Empty << QByteArray("BLAH");
+ QTest::newRow("Empty") << QNdefRecord::Empty << QByteArray("");
+ QTest::newRow("Unknown") << QNdefRecord::Unknown << QByteArray("BLAHfoo");
+ QTest::newRow("Mime") << QNdefRecord::Mime << QByteArray("foobar");
+ QTest::newRow("ExternalRtd") << QNdefRecord::ExternalRtd << QByteArray("");
}
void tst_QNdefRecord::tst_declarative_record()
{
QFETCH(QNdefRecord::TypeNameFormat, typeNameFormat);
- QFETCH(QNdefRecord::TypeNameFormat, typeNameFormatOut);
QFETCH(QByteArray, type);
- QFETCH(QByteArray, typeOut);
- QFETCH(QString, recordType);
{
QNdefRecord record;
@@ -389,78 +386,98 @@ void tst_QNdefRecord::tst_declarative_record()
QCOMPARE(record.typeNameFormat(), typeNameFormat);
QCOMPARE(record.type(), type);
- QDeclarativeNdefRecord declRecord(record);
+ QQmlNdefRecord declRecord(record);
QCOMPARE(declRecord.record(), record);
QCOMPARE(declRecord.record().typeNameFormat(), typeNameFormat);
QCOMPARE(declRecord.record().type(), type);
- QCOMPARE(declRecord.recordType(), recordType);
+ QCOMPARE(declRecord.type(), QString(type));
+ QCOMPARE(declRecord.typeNameFormat(), static_cast<QQmlNdefRecord::TypeNameFormat>(typeNameFormat));
- QDeclarativeNdefRecord declRecord2;
+ QQmlNdefRecord declRecord2;
declRecord2.setRecord(record);
QCOMPARE(declRecord2.record(), record);
QCOMPARE(declRecord2.record().typeNameFormat(), typeNameFormat);
QCOMPARE(declRecord2.record().type(), type);
- QCOMPARE(declRecord2.recordType(), recordType);
-
- QDeclarativeNdefRecord declRecord3;
- declRecord3.setRecordType(recordType);
- QCOMPARE(declRecord3.recordType(), recordType);
- QCOMPARE(declRecord3.record().typeNameFormat(), typeNameFormatOut);
- QCOMPARE(declRecord3.record().type(), typeOut);
+ QCOMPARE(declRecord2.type(), QString(type));
+ QCOMPARE(declRecord2.typeNameFormat(), static_cast<QQmlNdefRecord::TypeNameFormat>(typeNameFormat));
+
+ QQmlNdefRecord declRecord3;
+ declRecord3.setTypeNameFormat((QQmlNdefRecord::TypeNameFormat)typeNameFormat);
+ declRecord3.setType(type);
+ QCOMPARE(declRecord3.type(), QString(type));
+ QCOMPARE(declRecord3.record().typeNameFormat(), typeNameFormat);
+ QCOMPARE(declRecord3.record().type(), type);
+ QCOMPARE(declRecord3.typeNameFormat(), static_cast<QQmlNdefRecord::TypeNameFormat>(typeNameFormat));
}
}
void tst_QNdefRecord::tst_declarativeChangedSignals()
{
- QDeclarativeNdefRecord record;
- QSignalSpy typeSpy(&record, SIGNAL(recordTypeChanged()));
+ QQmlNdefRecord record;
+ QSignalSpy typeSpy(&record, SIGNAL(typeChanged()));
+ QSignalSpy tnfSpy(&record, SIGNAL(typeNameFormatChanged()));
QSignalSpy recordSpy(&record, SIGNAL(recordChanged()));
QCOMPARE(typeSpy.count(), 0);
QCOMPARE(recordSpy.count(), 0);
- record.setRecordType("urn:nfc:wkt:U");
+ record.setType("U");
+ record.setTypeNameFormat(QQmlNdefRecord::NfcRtd);
QCOMPARE(typeSpy.count(), 1);
+ QCOMPARE(tnfSpy.count(), 1);
QCOMPARE(recordSpy.count(), 0);
- QCOMPARE(record.recordType(), QString("urn:nfc:wkt:U"));
+ QCOMPARE(record.type(), QString("U"));
QCOMPARE(record.record().type(), QByteArray("U"));
QCOMPARE(record.record().typeNameFormat(), QNdefRecord::NfcRtd);
+ QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::NfcRtd);
- record.setRecordType("urn:nfc:wkt:U"); //same value, no signal
+ record.setType("U"); //same value, no signal
QCOMPARE(typeSpy.count(), 1);
+ QCOMPARE(tnfSpy.count(), 1);
QCOMPARE(recordSpy.count(), 0);
- QCOMPARE(record.recordType(), QString("urn:nfc:wkt:U"));
+ QCOMPARE(record.type(), QString("U"));
QCOMPARE(record.record().type(), QByteArray("U"));
QCOMPARE(record.record().typeNameFormat(), QNdefRecord::NfcRtd);
+ QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::NfcRtd);
- record.setRecordType("urn:nfc:ext:blah");
- record.setRecordType("urn:nfc:ext:blah2");
+ record.setType("blah");
+ record.setType("blah2");
+ record.setTypeNameFormat(QQmlNdefRecord::ExternalRtd);
QCOMPARE(typeSpy.count(), 3);
+ QCOMPARE(tnfSpy.count(), 2);
QCOMPARE(recordSpy.count(), 0);
- QCOMPARE(record.recordType(), QString("urn:nfc:ext:blah2"));
+ QCOMPARE(record.type(), QString("blah2"));
QCOMPARE(record.record().type(), QByteArray("blah2"));
QCOMPARE(record.record().typeNameFormat(), QNdefRecord::ExternalRtd);
+ QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::ExternalRtd);
- record.setRecordType("Rubbish");
+ record.setType("Rubbish");
QCOMPARE(typeSpy.count(), 4);
+ QCOMPARE(tnfSpy.count(), 2);
QCOMPARE(recordSpy.count(), 0);
- QCOMPARE(record.recordType(), QString("urn:nfc:ext:blah2"));
- QCOMPARE(record.record().type(), QByteArray("blah2"));
+ QCOMPARE(record.type(), QString("Rubbish"));
+ QCOMPARE(record.record().type(), QByteArray("Rubbish"));
QCOMPARE(record.record().typeNameFormat(), QNdefRecord::ExternalRtd);
+ QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::ExternalRtd);
- record.setRecordType("urn:nfc:mime:QQQQ");
+ record.setType("QQQQ");
+ record.setTypeNameFormat(QQmlNdefRecord::Mime);
QCOMPARE(typeSpy.count(), 5);
+ QCOMPARE(tnfSpy.count(), 3);
QCOMPARE(recordSpy.count(), 0);
- QCOMPARE(record.recordType(), QString("urn:nfc:mime:QQQQ"));
+ QCOMPARE(record.type(), QString("QQQQ"));
QCOMPARE(record.record().type(), QByteArray("QQQQ"));
QCOMPARE(record.record().typeNameFormat(), QNdefRecord::Mime);
+ QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::Mime);
record.setRecord(QNdefRecord());
QCOMPARE(typeSpy.count(), 5); //setting record -> no recordChanged signal
+ QCOMPARE(tnfSpy.count(), 3);
QCOMPARE(recordSpy.count(), 1);
- QCOMPARE(record.recordType(), QString(""));
+ QCOMPARE(record.type(), QString(""));
QCOMPARE(record.record().type(), QByteArray());
QCOMPARE(record.record().typeNameFormat(), QNdefRecord::Empty);
+ QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::Empty);
}
QTEST_MAIN(tst_QNdefRecord)