summaryrefslogtreecommitdiffstats
path: root/src/imports
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 /src/imports
parent672413c65685883136f4572d34f7d08f7b952641 (diff)
parent782a09be7c89352b27083bca7ee5b032d9e56ca6 (diff)
Merge branch 'stable' into dev
Diffstat (limited to 'src/imports')
-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
21 files changed, 412 insertions, 373 deletions
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.