From e269d5d894e60dfa5e954eb75ae19754d08f3353 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 24 Sep 2013 15:00:57 +0200 Subject: sync.profile: Point to qtsystems#dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qtconnectivity doesn't really depend on qtsystems, so this is a temporary solution until qt5.git#qt.pro is updated. Change-Id: I89811ccc82d5cc46503ab270f4d50423b3313c60 Reviewed-by: Tony Sarajärvi Reviewed-by: Sergio Ahumada --- sync.profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sync.profile b/sync.profile index d7d8e10e..3e08d775 100644 --- a/sync.profile +++ b/sync.profile @@ -14,6 +14,6 @@ %dependencies = ( "qtbase" => "", "qtdeclarative" => "", - "qtsystems" => "", + "qtsystems" => "refs/heads/dev", "qtxmlpatterns" => "", ); -- cgit v1.2.3 From 97ad2ffecf6f5c18b71c52c5a7f4a5f8b679c0a6 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 24 Sep 2013 10:36:48 +0200 Subject: Fixing small QBluetoothServer issues -extending documentation -emit error signal when setting a new error Task-number: QTBUG-32669 Change-Id: I16b8a149792ed5068a7bd76af874477084802aea Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothserver.cpp | 3 ++- src/bluetooth/qbluetoothserver_bluez.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3 From 85eac47703aa40df76e5102eb04291d8f029bfa3 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 24 Sep 2013 11:12:32 +0200 Subject: Emit ServiceLookup signal in QBluetoothSocket/Bluez when required. Change-Id: Ide9d2cf7fd469e28c584c557ad9e1307aec37f1d Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothsocket.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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 << ")"; } -- cgit v1.2.3 From 85de7d64e85aa058f1777bc9d1a778790b1d50a6 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 23 Sep 2013 13:52:35 +0200 Subject: Fix peer to peer communication using two local adapters. The code assumed to use the default adapter in a variety of places which caused wrong SDP registrations, device searches and peer names. The btchat examples was extended to cope with two local adapters. If there are more than two local adapters they will be ignored. Change-Id: I27d8bce65d943773e4e6cbd86982446fa79664a4 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- examples/bluetooth/btchat/chat.cpp | 50 ++++++++++++++++++++++- examples/bluetooth/btchat/chat.h | 6 +++ examples/bluetooth/btchat/chat.ui | 26 ++++++++++++ examples/bluetooth/btchat/chatclient.cpp | 2 +- examples/bluetooth/btchat/chatserver.cpp | 14 ++++--- examples/bluetooth/btchat/chatserver.h | 3 +- examples/bluetooth/btchat/remoteselector.cpp | 17 +------- examples/bluetooth/btchat/remoteselector.h | 2 +- src/bluetooth/qbluetoothservicediscoveryagent.cpp | 6 ++- src/bluetooth/qbluetoothserviceinfo.cpp | 16 +++++--- src/bluetooth/qbluetoothserviceinfo.h | 5 ++- src/bluetooth/qbluetoothserviceinfo_bluez.cpp | 32 ++++++++++----- src/bluetooth/qbluetoothserviceinfo_p.cpp | 9 ++-- src/bluetooth/qbluetoothserviceinfo_p.h | 16 ++++---- src/bluetooth/qbluetoothserviceinfo_qnx.cpp | 9 ++-- src/bluetooth/qbluetoothsocket_bluez.cpp | 9 ++-- 16 files changed, 160 insertions(+), 62 deletions(-) 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 #include +#include #include @@ -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 clients; + QList 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 @@ -14,6 +14,32 @@ Bluetooth Chat + + + + Local Bluetooth Adapter + + + false + + + + + + Default + + + + + + + + + + + + + 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..8b1bf6f0 100644 --- a/examples/bluetooth/btchat/chatserver.cpp +++ b/examples/bluetooth/btchat/chatserver.cpp @@ -42,6 +42,7 @@ #include #include +#include //! [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,7 +66,11 @@ 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); @@ -81,7 +86,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 +112,7 @@ void ChatServer::startServer() //! [Protocol descriptor list] //! [Register service] - serviceInfo.registerService(); + serviceInfo.registerService(localAdapter); //! [Register service] } @@ -146,7 +151,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 +#include #include #include @@ -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/remoteselector.cpp b/examples/bluetooth/btchat/remoteselector.cpp index f660a815..73f56a54 100644 --- a/examples/bluetooth/btchat/remoteselector.cpp +++ b/examples/bluetooth/btchat/remoteselector.cpp @@ -47,25 +47,12 @@ 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))); 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/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp index 023ffb80..b613642c 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp @@ -329,7 +329,11 @@ 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)), diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp index 4e2c0499..0a1d9ee5 100644 --- a/src/bluetooth/qbluetoothserviceinfo.cpp +++ b/src/bluetooth/qbluetoothserviceinfo.cpp @@ -152,21 +152,27 @@ bool QBluetoothServiceInfo::isRegistered() const } /*! - \fn bool QBluetoothServiceInfo::registerService() const + \fn bool QBluetoothServiceInfo::registerService() 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 \l 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 +180,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(); } 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 #include +#include #include #include @@ -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..a24e8cea 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,7 +200,7 @@ bool QBluetoothServiceInfoPrivate::unregisterService() const return true; } -void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) const +void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) { Q_UNUSED(attributeId); Q_UNUSED(value); @@ -208,35 +208,47 @@ void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, c registerService(); } -void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) const +void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) { Q_UNUSED(attributeId); registerService(); } -bool QBluetoothServiceInfoPrivate::ensureSdpConnection() const +bool QBluetoothServiceInfoPrivate::ensureSdpConnection(const QBluetoothAddress &localAdapter) { - if (service) + if (service && currentLocalAdapter == localAdapter) return true; + delete service; + OrgBluezManagerInterface manager(QLatin1String("org.bluez"), QLatin1String("/"), QDBusConnection::systemBus()); - QDBusPendingReply reply = manager.FindAdapter(QLatin1String("any")); + + QDBusPendingReply 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..51aeb75b 100644 --- a/src/bluetooth/qbluetoothserviceinfo_p.cpp +++ b/src/bluetooth/qbluetoothserviceinfo_p.cpp @@ -57,24 +57,25 @@ 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 +void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) { Q_UNUSED(attributeId); Q_UNUSED(value); } -void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) const +void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) { Q_UNUSED(attributeId); } diff --git a/src/bluetooth/qbluetoothserviceinfo_p.h b/src/bluetooth/qbluetoothserviceinfo_p.h index 0e263fe6..a98cf0e9 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,14 @@ 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; + void setRegisteredAttribute(quint16 attributeId, const QVariant &value); + void removeRegisteredAttribute(quint16 attributeId); QBluetoothDeviceInfo deviceInfo; QMap attributes; @@ -78,10 +79,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..cd1ecfef 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; @@ -70,7 +70,7 @@ bool QBluetoothServiceInfoPrivate::unregisterService() const } -void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) const +void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) { Q_UNUSED(attributeId); Q_UNUSED(value); @@ -78,7 +78,7 @@ void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, c registerService(); } -void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) const +void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) { Q_UNUSED(attributeId); registered = false; @@ -86,8 +86,9 @@ void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId extern QHash __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_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 reply = manager.DefaultAdapter(); + QDBusPendingReply 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 deviceObjectPath = adapter.CreateDevice(address); + QDBusPendingReply 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(); -- cgit v1.2.3 From 176d5208a3301ade9fea2b0681474dbff253b6a8 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Mon, 23 Sep 2013 14:55:35 +0200 Subject: Emit service discovery error during internal device discovery This was discovered when starting a service discovery while no Bluetooth device is connected. Change-Id: Ibb970ee6cb95ff50bca635813cce23c4d7f8e3c6 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- examples/bluetooth/btchat/remoteselector.cpp | 3 ++- src/bluetooth/qbluetoothservicediscoveryagent.cpp | 20 +++++++++++++++++++- src/bluetooth/qbluetoothservicediscoveryagent.h | 1 + src/bluetooth/qbluetoothservicediscoveryagent_p.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/examples/bluetooth/btchat/remoteselector.cpp b/examples/bluetooth/btchat/remoteselector.cpp index 73f56a54..e6fd728f 100644 --- a/examples/bluetooth/btchat/remoteselector.cpp +++ b/examples/bluetooth/btchat/remoteselector.cpp @@ -57,6 +57,7 @@ RemoteSelector::RemoteSelector(const QBluetoothAddress &localAdapter, QWidget *p 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() @@ -67,6 +68,7 @@ RemoteSelector::~RemoteSelector() void RemoteSelector::startDiscovery(const QBluetoothUuid &uuid) { + ui->status->setText(tr("Scanning...")); if (m_discoveryAgent->isActive()) m_discoveryAgent->stop(); @@ -75,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/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp index b613642c..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. */ /*! @@ -338,6 +339,8 @@ void QBluetoothServiceDiscoveryAgentPrivate::startDeviceDiscovery() 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))); } @@ -372,6 +375,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryFinished() setDiscoveryState(Inactive); Q_Q(QBluetoothServiceDiscoveryAgent); + emit q->error(error); emit q->finished(); return; } @@ -405,6 +409,20 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscovered(const QBluetoot } } +void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscoveryError(QBluetoothDeviceDiscoveryAgent::Error newError) +{ + error = static_cast(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 697fe662..517f6a98 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_p.h +++ b/src/bluetooth/qbluetoothservicediscoveryagent_p.h @@ -105,6 +105,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); -- cgit v1.2.3 From 905987ab1d9014289f7719099f1dcc01dd865fd5 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 24 Sep 2013 12:06:10 +0200 Subject: Remove private and unused API from QBluetoothServiceInfoPrivate Presumably this API was intended to update attributes while the service info object is already registered. It was not implemented anywhere. No reason to keep it. Some minor documentation fixes Change-Id: If6b4b7c37d99027d49a7af48c282725228e9a6c7 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothserviceinfo.cpp | 29 +++++++++++++++------------ src/bluetooth/qbluetoothserviceinfo_bluez.cpp | 15 -------------- src/bluetooth/qbluetoothserviceinfo_p.cpp | 12 ----------- src/bluetooth/qbluetoothserviceinfo_p.h | 2 -- src/bluetooth/qbluetoothserviceinfo_qnx.cpp | 15 -------------- 5 files changed, 16 insertions(+), 57 deletions(-) diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp index 0a1d9ee5..5ff48b4e 100644 --- a/src/bluetooth/qbluetoothserviceinfo.cpp +++ b/src/bluetooth/qbluetoothserviceinfo.cpp @@ -152,14 +152,14 @@ bool QBluetoothServiceInfo::isRegistered() const } /*! - \fn bool QBluetoothServiceInfo::registerService() + \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 \l localAdapter parameter determines the local Bluetooth adapter under which + 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 @@ -192,6 +192,9 @@ bool QBluetoothServiceInfo::unregisterService() 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. */ /*! @@ -200,6 +203,9 @@ bool QBluetoothServiceInfo::unregisterService() 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. */ /*! @@ -208,6 +214,9 @@ bool QBluetoothServiceInfo::unregisterService() 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. */ /*! @@ -397,20 +406,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); } /*! @@ -440,13 +443,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_bluez.cpp b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp index a24e8cea..d8344589 100644 --- a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp +++ b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp @@ -200,21 +200,6 @@ bool QBluetoothServiceInfoPrivate::unregisterService() return true; } -void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) -{ - Q_UNUSED(attributeId); - Q_UNUSED(value); - - registerService(); -} - -void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) -{ - Q_UNUSED(attributeId); - - registerService(); -} - bool QBluetoothServiceInfoPrivate::ensureSdpConnection(const QBluetoothAddress &localAdapter) { if (service && currentLocalAdapter == localAdapter) diff --git a/src/bluetooth/qbluetoothserviceinfo_p.cpp b/src/bluetooth/qbluetoothserviceinfo_p.cpp index 51aeb75b..e5f2f4e5 100644 --- a/src/bluetooth/qbluetoothserviceinfo_p.cpp +++ b/src/bluetooth/qbluetoothserviceinfo_p.cpp @@ -68,16 +68,4 @@ bool QBluetoothServiceInfoPrivate::unregisterService() return false; } - -void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) -{ - Q_UNUSED(attributeId); - Q_UNUSED(value); -} - -void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) -{ - Q_UNUSED(attributeId); -} - QT_END_NAMESPACE diff --git a/src/bluetooth/qbluetoothserviceinfo_p.h b/src/bluetooth/qbluetoothserviceinfo_p.h index a98cf0e9..46ae84d4 100644 --- a/src/bluetooth/qbluetoothserviceinfo_p.h +++ b/src/bluetooth/qbluetoothserviceinfo_p.h @@ -70,8 +70,6 @@ public: bool unregisterService(); - void setRegisteredAttribute(quint16 attributeId, const QVariant &value); - void removeRegisteredAttribute(quint16 attributeId); QBluetoothDeviceInfo deviceInfo; QMap attributes; diff --git a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp index cd1ecfef..b744feff 100644 --- a/src/bluetooth/qbluetoothserviceinfo_qnx.cpp +++ b/src/bluetooth/qbluetoothserviceinfo_qnx.cpp @@ -69,21 +69,6 @@ bool QBluetoothServiceInfoPrivate::unregisterService() return false; } - -void QBluetoothServiceInfoPrivate::setRegisteredAttribute(quint16 attributeId, const QVariant &value) -{ - Q_UNUSED(attributeId); - Q_UNUSED(value); - - registerService(); -} - -void QBluetoothServiceInfoPrivate::removeRegisteredAttribute(quint16 attributeId) -{ - Q_UNUSED(attributeId); - registered = false; -} - extern QHash __fakeServerPorts; bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress& localAdapter) -- cgit v1.2.3 From 218ab9347ce1f48b5002f11ad3e4ba7d1856982a Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Tue, 24 Sep 2013 18:23:51 +0200 Subject: Doc: Removed version from \inqmlmodule. -QDoc ignores the version in \inqmlmodule but it is good to remove it to avoid confusion. -QDoc uses \qmlmodule for the import statement Task-number: QTBUG-32172 Change-Id: If5a3ec8a16aabcf5abec6d1794717ea2c54f0c9f Reviewed-by: Alex Blasche --- src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp | 2 +- src/imports/bluetooth/qdeclarativebluetoothservice.cpp | 2 +- src/imports/bluetooth/qdeclarativebluetoothsocket.cpp | 2 +- src/imports/nfc/qdeclarativendeffilter.cpp | 2 +- src/imports/nfc/qdeclarativendefmimerecord.cpp | 2 +- src/imports/nfc/qdeclarativendeftextrecord.cpp | 2 +- src/imports/nfc/qdeclarativendefurirecord.cpp | 2 +- src/imports/nfc/qdeclarativenearfield.cpp | 2 +- src/imports/nfc/qdeclarativenearfieldsocket.cpp | 2 +- src/nfc/qdeclarativendefrecord.cpp | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp index 97265b4f..04d08e48 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp @@ -52,7 +52,7 @@ /*! \qmltype BluetoothDiscoveryModel \instantiates QDeclarativeBluetoothDiscoveryModel - \inqmlmodule QtBluetooth 5.0 + \inqmlmodule QtBluetooth \brief Enables you to search for the Bluetooth devices and services in range. diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp index 7180be7b..e64876d8 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp @@ -53,7 +53,7 @@ /*! \qmltype BluetoothService \instantiates QDeclarativeBluetoothService - \inqmlmodule QtBluetooth 5.0 + \inqmlmodule QtBluetooth \brief Provides information about a particular Bluetooth service. \sa QBluetoothAddress diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp index 02c6d308..54a4ef8e 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp @@ -54,7 +54,7 @@ /*! \qmltype BluetoothSocket \instantiates QDeclarativeBluetoothSocket - \inqmlmodule QtBluetooth 5.0 + \inqmlmodule QtBluetooth \brief Enables you to connect and communicate with a Bluetooth service or device. diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp index 3e0bcef2..cdb99461 100644 --- a/src/imports/nfc/qdeclarativendeffilter.cpp +++ b/src/imports/nfc/qdeclarativendeffilter.cpp @@ -47,7 +47,7 @@ \brief The NdefFilter type represents a filtering constraint for NDEF message records. \ingroup nfc-qml - \inqmlmodule QtNfc 5.0 + \inqmlmodule QtNfc \sa NearField \sa QNdefFilter diff --git a/src/imports/nfc/qdeclarativendefmimerecord.cpp b/src/imports/nfc/qdeclarativendefmimerecord.cpp index 46ba975d..b1c49bde 100644 --- a/src/imports/nfc/qdeclarativendefmimerecord.cpp +++ b/src/imports/nfc/qdeclarativendefmimerecord.cpp @@ -46,7 +46,7 @@ \brief The NdefMimeRecord type represents an NFC MIME record. \ingroup connectivity-nfc - \inqmlmodule QtNfc 5.0 + \inqmlmodule QtNfc \inherits NdefRecord diff --git a/src/imports/nfc/qdeclarativendeftextrecord.cpp b/src/imports/nfc/qdeclarativendeftextrecord.cpp index 7542edf0..ad3cda6a 100644 --- a/src/imports/nfc/qdeclarativendeftextrecord.cpp +++ b/src/imports/nfc/qdeclarativendeftextrecord.cpp @@ -48,7 +48,7 @@ \brief The NdefTextRecord type represents an NFC RTD-Text NDEF record. \ingroup nfc-qml - \inqmlmodule QtNfc 5.0 + \inqmlmodule QtNfc \inherits NdefRecord diff --git a/src/imports/nfc/qdeclarativendefurirecord.cpp b/src/imports/nfc/qdeclarativendefurirecord.cpp index 00dcd031..47a65cfa 100644 --- a/src/imports/nfc/qdeclarativendefurirecord.cpp +++ b/src/imports/nfc/qdeclarativendefurirecord.cpp @@ -48,7 +48,7 @@ \brief The NdefUriRecord type represents an NFC RTD-URI NDEF record. \ingroup nfc-qml - \inqmlmodule QtNfc 5.0 + \inqmlmodule QtNfc \inherits NdefRecord diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp index 7e7e188a..681e2e9e 100644 --- a/src/imports/nfc/qdeclarativenearfield.cpp +++ b/src/imports/nfc/qdeclarativenearfield.cpp @@ -55,7 +55,7 @@ \brief The NearField type provides access to NDEF messages stored on NFC Forum tags. \ingroup nfc-qml - \inqmlmodule QtNfc 5.0 + \inqmlmodule QtNfc \sa NdefFilter \sa NdefRecord diff --git a/src/imports/nfc/qdeclarativenearfieldsocket.cpp b/src/imports/nfc/qdeclarativenearfieldsocket.cpp index 15e59f9b..b297ccdf 100644 --- a/src/imports/nfc/qdeclarativenearfieldsocket.cpp +++ b/src/imports/nfc/qdeclarativenearfieldsocket.cpp @@ -49,7 +49,7 @@ \brief The NearFieldSocket type represents an LLCP socket. \ingroup nfc-qml - \inqmlmodule QtNfc 5.0 + \inqmlmodule QtNfc The NearFieldSocket type was introduced in \b {QtNfc 5.0}. diff --git a/src/nfc/qdeclarativendefrecord.cpp b/src/nfc/qdeclarativendefrecord.cpp index e9e741c5..4d560500 100644 --- a/src/nfc/qdeclarativendefrecord.cpp +++ b/src/nfc/qdeclarativendefrecord.cpp @@ -90,7 +90,7 @@ QT_BEGIN_NAMESPACE \brief The NdefRecord type represents a record in an NDEF message. \ingroup nfc-qml - \inqmlmodule QtNfc 5.0 + \inqmlmodule QtNfc \sa NdefFilter \sa NearField -- cgit v1.2.3 From c08bd2c68b32d44269374753d66fe3cb934f16e0 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Wed, 25 Sep 2013 11:30:28 +0200 Subject: QNX: Set the correct target id for the invoke filter Change-Id: I328703f2578ffef10e9b475d0015a30ec6671b5b Reviewed-by: Alex Blasche --- src/nfc/qnx/qnxnfcmanager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 #include #include "../qllcpsocket_qnx_p.h" +#include 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; } } -- cgit v1.2.3 From efb67941585a82c190302af18d5b6350386ed7da Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Wed, 25 Sep 2013 11:44:33 +0200 Subject: QNX: Extend documentation for NDEF message handlers Change-Id: If96b4fc9aacc3c16e9e8eb88ab4849ec15e280b5 Reviewed-by: Alex Blasche --- src/nfc/qnearfieldmanager.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 + + APPLICATION + + bb.action.OPEN + application/vnd.rim.nfc.ndef + + + \endcode */ /*! -- cgit v1.2.3 From da9a3a88efbc60df892fdf6ede2ba82e3c04ba85 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 25 Sep 2013 18:14:43 +0200 Subject: Update QML plugin meta data for Qt Creator Change-Id: Ie5a9f5f0844adbd1e27753f3f6970b9431d5d741 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/imports/bluetooth/plugins.qmltypes | 62 ++++++++++++++++++++++++----- src/imports/nfc/plugins.qmltypes | 73 ++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 src/imports/nfc/plugins.qmltypes diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes index 578cd711..ba4b1bc7 100644 --- a/src/imports/bluetooth/plugins.qmltypes +++ b/src/imports/bluetooth/plugins.qmltypes @@ -3,7 +3,8 @@ 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.0' Module { Component { @@ -11,18 +12,33 @@ Module { 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" } + 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" Parameter { name: "service"; type: "QDeclarativeBluetoothService"; isPointer: true } } - Method { - name: "setDiscovery" - Parameter { name: "discovery_"; type: "bool" } - } + Signal { name: "newDeviceDiscovered" } } Component { name: "QDeclarativeBluetoothService" @@ -78,11 +94,37 @@ Module { prototype: "QObject" exports: ["QtBluetooth/BluetoothSocket 5.0"] exportMetaObjectRevisions: [0] + Enum { + name: "Error" + values: { + "NoError": -2, + "UnknownSocketError": -1, + "HostNotFoundError": 2, + "ServiceNotFoundError": 9, + "NetworkError": 7, + "UnsupportedProtocolError": 8, + "NoSocketerror": 9 + } + } + Enum { + name: "SocketState" + values: { + "Unconnected": 0, + "ServiceLookup": 1, + "Connecting": 2, + "Connected": 3, + "Bound": 4, + "Closing": 6, + "Listening": 5, + "NoServiceSet": 6 + } + } 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/nfc/plugins.qmltypes b/src/imports/nfc/plugins.qmltypes new file mode 100644 index 00000000..2d8eef8e --- /dev/null +++ b/src/imports/nfc/plugins.qmltypes @@ -0,0 +1,73 @@ +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.0' + +Module { + Component { + name: "QDeclarativeNdefFilter" + prototype: "QObject" + exports: ["QtNfc/NdefFilter 5.0"] + exportMetaObjectRevisions: [0] + Property { name: "type"; type: "string" } + Property { name: "minimum"; type: "int" } + Property { name: "maximum"; type: "int" } + } + Component { + name: "QDeclarativeNdefMimeRecord" + prototype: "QDeclarativeNdefRecord" + exports: ["QtNfc/NdefMimeRecord 5.0"] + exportMetaObjectRevisions: [0] + Property { name: "uri"; type: "string"; isReadonly: true } + } + Component { + name: "QDeclarativeNdefRecord" + prototype: "QObject" + exports: ["QtNfc/NdefRecord 5.0"] + exportMetaObjectRevisions: [0] + Property { name: "recordType"; type: "string" } + Property { name: "record"; type: "QNdefRecord" } + } + Component { + name: "QDeclarativeNdefTextRecord" + prototype: "QDeclarativeNdefRecord" + exports: ["QtNfc/NdefTextRecord 5.0"] + exportMetaObjectRevisions: [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: "QDeclarativeNdefRecord" + exports: ["QtNfc/NdefUriRecord 5.0"] + exportMetaObjectRevisions: [0] + Property { name: "uri"; type: "string" } + } + Component { + name: "QDeclarativeNearField" + prototype: "QObject" + exports: ["QtNfc/NearField 5.0"] + exportMetaObjectRevisions: [0] + Property { + name: "messageRecords" + type: "QDeclarativeNdefRecord" + isList: true + isReadonly: true + } + Property { name: "filter"; type: "QDeclarativeNdefFilter"; isList: true; isReadonly: true } + Property { name: "orderMatch"; type: "bool" } + } +} -- cgit v1.2.3 From 6349b26b26c475e9f38baf1b4551f1c0b3635c1d Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Fri, 27 Sep 2013 16:23:41 +0200 Subject: Update the git-archive export options The .gitattributes, .gitignore, .commit-template files do not need to be present in packaged sources, as they are for people using the Git repository. People who download tarballs usually don't reimport into Git -- they should just download the actual repositories. Change-Id: I8d3eb36583d0fb6a3622f34427819fbc39b1b9ff Reviewed-by: Alex Blasche Reviewed-by: Sergio Ahumada --- .gitattributes | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 -- cgit v1.2.3 From 2ef02cb4d0474dce51658d381743de96204dce72 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Fri, 27 Sep 2013 18:17:59 +0200 Subject: Refactor QDeclarativeBluetoothServiceInfo Change-Id: I8a8197a5e10ee0d087dea2b55eb9577ba8c7d3c9 Reviewed-by: Alex Blasche --- .../bluetooth/qdeclarativebluetoothservice.cpp | 217 ++++++--------------- .../bluetooth/qdeclarativebluetoothservice_p.h | 30 +-- 2 files changed, 76 insertions(+), 171 deletions(-) diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp index e64876d8..c4234933 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp @@ -86,9 +86,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 +101,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 +128,7 @@ void QDeclarativeBluetoothService::componentComplete() { d->m_componentComplete = true; - if (d->m_needsRegistration) + if (!d->m_service->isRegistered()) setRegistered(true); } @@ -148,8 +142,6 @@ void QDeclarativeBluetoothService::componentComplete() QString QDeclarativeBluetoothService::deviceName() const { - if (!d->m_service) - return QString(); return d->m_service->device().name(); } @@ -165,19 +157,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 +176,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 +193,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,69 +237,23 @@ 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 @@ -337,77 +263,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 +323,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 +340,6 @@ void QDeclarativeBluetoothService::setRegistered(bool registered) protocolDescriptorList); if (d->m_service->registerService()) { - //qDebug() << "registered"; emit registeredChanged(); } else { @@ -457,23 +360,23 @@ void QDeclarativeBluetoothService::new_connection() QDeclarativeBluetoothSocket *QDeclarativeBluetoothService::nextClient() { - QBluetoothServer *server = qobject_cast(d->m_listen); + QBluetoothServer *server = qobject_cast(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(d->m_listen); + QBluetoothServer *server = qobject_cast(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(); -- cgit v1.2.3 From 171a0e2568c639ac40329a9d2ace01344eb395b0 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Wed, 25 Sep 2013 18:07:20 +0200 Subject: Alter the way type and TNF are treated in the qml API Change-Id: Iff972e1645447a57eb72e3006318a9dd5b2d5c9b Reviewed-by: Alex Blasche --- examples/nfc/poster/poster.qml | 4 +- src/imports/nfc/qdeclarativendeffilter.cpp | 14 ++++ src/imports/nfc/qdeclarativendeffilter_p.h | 8 +- src/imports/nfc/qdeclarativenearfield.cpp | 41 +++++----- src/imports/nfc/qdeclarativenearfield_p.h | 2 +- src/nfc/qdeclarativendefrecord.cpp | 116 ++++++++++++++++++++++------- src/nfc/qdeclarativendefrecord.h | 23 +++++- tests/auto/qndefrecord/tst_qndefrecord.cpp | 91 +++++++++++++--------- 8 files changed, 202 insertions(+), 97 deletions(-) diff --git a/examples/nfc/poster/poster.qml b/examples/nfc/poster/poster.qml index 058f8e4f..7dcd0db5 100644 --- a/examples/nfc/poster/poster.qml +++ b/examples/nfc/poster/poster.qml @@ -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/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp index cdb99461..ae551774 100644 --- a/src/imports/nfc/qdeclarativendeffilter.cpp +++ b/src/imports/nfc/qdeclarativendeffilter.cpp @@ -119,6 +119,20 @@ void QDeclarativeNdefFilter::setType(const QString &t) emit typeChanged(); } +QDeclarativeNdefRecord::TypeNameFormat QDeclarativeNdefFilter::typeNameFormat() const +{ + return m_typeNameFormat; +} + +void QDeclarativeNdefFilter::setTypeNameFormat(QDeclarativeNdefRecord::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..8622aece 100644 --- a/src/imports/nfc/qdeclarativendeffilter_p.h +++ b/src/imports/nfc/qdeclarativendeffilter_p.h @@ -43,21 +43,25 @@ #define QDECLARATIVENDEFFILTER_P_H #include +#include class QDeclarativeNdefFilter : public QObject { Q_OBJECT Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) + Q_PROPERTY(QDeclarativeNdefRecord::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); + QDeclarativeNdefRecord::TypeNameFormat typeNameFormat() const; + void setTypeNameFormat(QDeclarativeNdefRecord::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; + QDeclarativeNdefRecord::TypeNameFormat m_typeNameFormat; }; #endif // QDECLARATIVENDEFFILTER_P_H diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp index 681e2e9e..81a27730 100644 --- a/src/imports/nfc/qdeclarativenearfield.cpp +++ b/src/imports/nfc/qdeclarativenearfield.cpp @@ -72,7 +72,7 @@ \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() @@ -143,7 +143,7 @@ void QDeclarativeNearField::componentComplete() { m_componentCompleted = true; - if (!m_filter.isEmpty()) + if (!m_filterList.isEmpty()) registerMessageHandler(); } @@ -156,27 +156,20 @@ void QDeclarativeNearField::registerMessageHandler() m_manager->unregisterNdefMessageHandler(m_messageHandlerId); // no filter abort - if (m_filter.isEmpty()) + if (m_filterList.isEmpty()) return; - 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)); + 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(); + + ndefFilter.appendRecord(static_cast(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) @@ -246,7 +239,7 @@ void QDeclarativeNearField::append_filter(QQmlListPropertysetParent(nearField); - nearField->m_filter.append(filter); + nearField->m_filterList.append(filter); emit nearField->filterChanged(); if (nearField->m_componentCompleted) @@ -259,7 +252,7 @@ int QDeclarativeNearField::count_filters(QQmlListPropertym_filter.count(); + return nearField->m_filterList.count(); } QDeclarativeNdefFilter *QDeclarativeNearField::at_filter(QQmlListProperty *list, @@ -269,7 +262,7 @@ QDeclarativeNdefFilter *QDeclarativeNearField::at_filter(QQmlListPropertym_filter.at(index); + return nearField->m_filterList.at(index); } void QDeclarativeNearField::clear_filter(QQmlListProperty *list) @@ -278,8 +271,8 @@ void QDeclarativeNearField::clear_filter(QQmlListPropertym_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..ad551308 100644 --- a/src/imports/nfc/qdeclarativenearfield_p.h +++ b/src/imports/nfc/qdeclarativenearfield_p.h @@ -87,7 +87,7 @@ private slots: private: QList m_message; - QList m_filter; + QList m_filterList; bool m_orderMatch; bool m_componentCompleted; bool m_messageUpdating; diff --git a/src/nfc/qdeclarativendefrecord.cpp b/src/nfc/qdeclarativendefrecord.cpp index 4d560500..edec632e 100644 --- a/src/nfc/qdeclarativendefrecord.cpp +++ b/src/nfc/qdeclarativendefrecord.cpp @@ -106,10 +106,32 @@ QT_BEGIN_NAMESPACE */ /*! - \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,7 +141,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QDeclarativeNdefRecord::recordTypeChanged() + \fn void QDeclarativeNdefRecord::typeChanged() This signal is emitted when the record type changes. */ @@ -131,9 +153,15 @@ QT_BEGIN_NAMESPACE */ /*! - \property QDeclarativeNdefRecord::recordType + \property QDeclarativeNdefRecord::type + + This property hold the type of the NDEF record. +*/ + +/*! + \property QDeclarativeNdefRecord::typeNameFormat - This property hold the record type of the NDEF record that this class represents. + This property hold the TNF of the NDEF record. */ /*! @@ -223,44 +251,76 @@ QDeclarativeNdefRecord::QDeclarativeNdefRecord(const QNdefRecord &record, QObjec } /*! - Returns the fully qualified record type of the record. The fully qualified record type - includes both the NIS and NSS prefixes. + \enum QDeclarativeNdefRecord::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. */ -QString QDeclarativeNdefRecord::recordType() const + +/*! + Returns the type of the record. + + \sa QNdefRecord::setType(), QNdefRecord::type() +*/ +QString QDeclarativeNdefRecord::type() const { Q_D(const QDeclarativeNdefRecord); - if (d->record.typeNameFormat() == QNdefRecord::Empty) - return QString(); - - 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 QDeclarativeNdefRecord::setType(const QString &newtype) { - if (type == recordType()) + if (newtype == type()) return; Q_D(QDeclarativeNdefRecord); + d->record.setType(newtype.toUtf8()); + + emit typeChanged(); +} - 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)); +/*! + Sets the type name format of the NDEF record to \a typeNameFormat. +*/ +void QDeclarativeNdefRecord::setTypeNameFormat(QDeclarativeNdefRecord::TypeNameFormat typeNameFormat) +{ + Q_D(QDeclarativeNdefRecord); + bool emitChanged = true; + if (static_cast(d->record.typeNameFormat()) == typeNameFormat) { + emitChanged = false; } - emit recordTypeChanged(); + //We always have to set the tnf, otherwise we run into problems when tnf is empty. Then + //the QNdefRecordPrivate is not created + d->record.setTypeNameFormat(static_cast(typeNameFormat)); + + if (emitChanged) + Q_EMIT(typeNameFormatChanged()); +} + +/*! + \fn QDeclarativeNdefRecord::TypeNameFormat QDeclarativeNdefRecord::typeNameFormat() const + + Returns the type name format of the NDEF record. +*/ +QDeclarativeNdefRecord::TypeNameFormat QDeclarativeNdefRecord::typeNameFormat() const +{ + Q_D(const QDeclarativeNdefRecord); + return static_cast(d->record.typeNameFormat()); } /*! diff --git a/src/nfc/qdeclarativendefrecord.h b/src/nfc/qdeclarativendefrecord.h index ab7031f4..52c436fe 100644 --- a/src/nfc/qdeclarativendefrecord.h +++ b/src/nfc/qdeclarativendefrecord.h @@ -56,21 +56,36 @@ class Q_NFC_EXPORT QDeclarativeNdefRecord : public QObject Q_DECLARE_PRIVATE(QDeclarativeNdefRecord) - 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: + enum TypeNameFormat { + Empty = QNdefRecord::Empty, + NfcRtd = QNdefRecord::NfcRtd, + Mime = QNdefRecord::Mime, + Uri = QNdefRecord::Uri, + ExternalRtd = QNdefRecord::ExternalRtd, + Unknown = QNdefRecord::Unknown + }; + explicit QDeclarativeNdefRecord(QObject *parent = 0); explicit QDeclarativeNdefRecord(const QNdefRecord &record, QObject *parent = 0); - QString recordType() const; - void setRecordType(const QString &t); + 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: diff --git a/tests/auto/qndefrecord/tst_qndefrecord.cpp b/tests/auto/qndefrecord/tst_qndefrecord.cpp index cccd1c61..6ccb9566 100644 --- a/tests/auto/qndefrecord/tst_qndefrecord.cpp +++ b/tests/auto/qndefrecord/tst_qndefrecord.cpp @@ -101,7 +101,8 @@ void tst_QNdefRecord::tst_record() QDeclarativeNdefRecord declRecord; QCOMPARE(declRecord.record(), record); - QCOMPARE(declRecord.recordType(), QString()); + QCOMPARE(declRecord.type(), QString()); + QCOMPARE(declRecord.typeNameFormat(), QDeclarativeNdefRecord::Empty); } // test type name format @@ -257,7 +258,8 @@ void tst_QNdefRecord::tst_textRecord() QDeclarativeNdefRecord declRecord(record); QCOMPARE(declRecord.record(), QNdefRecord(record)); - QCOMPARE(declRecord.recordType(), QString("urn:nfc:wkt:T")); + QCOMPARE(declRecord.type(), QString("T")); + QCOMPARE(declRecord.typeNameFormat(), QDeclarativeNdefRecord::NfcRtd); } // test getters @@ -325,7 +327,8 @@ void tst_QNdefRecord::tst_uriRecord() QDeclarativeNdefRecord declRecord(record); QCOMPARE(declRecord.record(), QNdefRecord(record)); - QCOMPARE(declRecord.recordType(), QString("urn:nfc:wkt:U")); + QCOMPARE(declRecord.type(), QString("U")); + QCOMPARE(declRecord.typeNameFormat(), QDeclarativeNdefRecord::NfcRtd); } // test getters @@ -360,27 +363,21 @@ void tst_QNdefRecord::tst_uriRecord() void tst_QNdefRecord::tst_declarative_record_data() { QTest::addColumn("typeNameFormat"); - QTest::addColumn("typeNameFormatOut"); QTest::addColumn("type"); - QTest::addColumn("typeOut"); - QTest::addColumn("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; @@ -393,74 +390,94 @@ void tst_QNdefRecord::tst_declarative_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(typeNameFormat)); QDeclarativeNdefRecord declRecord2; declRecord2.setRecord(record); QCOMPARE(declRecord2.record(), record); QCOMPARE(declRecord2.record().typeNameFormat(), typeNameFormat); QCOMPARE(declRecord2.record().type(), type); - QCOMPARE(declRecord2.recordType(), recordType); + QCOMPARE(declRecord2.type(), QString(type)); + QCOMPARE(declRecord2.typeNameFormat(), static_cast(typeNameFormat)); QDeclarativeNdefRecord declRecord3; - declRecord3.setRecordType(recordType); - QCOMPARE(declRecord3.recordType(), recordType); - QCOMPARE(declRecord3.record().typeNameFormat(), typeNameFormatOut); - QCOMPARE(declRecord3.record().type(), typeOut); + declRecord3.setTypeNameFormat((QDeclarativeNdefRecord::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(typeNameFormat)); } } void tst_QNdefRecord::tst_declarativeChangedSignals() { QDeclarativeNdefRecord record; - QSignalSpy typeSpy(&record, SIGNAL(recordTypeChanged())); + 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(QDeclarativeNdefRecord::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(), QDeclarativeNdefRecord::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(), QDeclarativeNdefRecord::NfcRtd); - record.setRecordType("urn:nfc:ext:blah"); - record.setRecordType("urn:nfc:ext:blah2"); + record.setType("blah"); + record.setType("blah2"); + record.setTypeNameFormat(QDeclarativeNdefRecord::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(), QDeclarativeNdefRecord::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(), QDeclarativeNdefRecord::ExternalRtd); - record.setRecordType("urn:nfc:mime:QQQQ"); + record.setType("QQQQ"); + record.setTypeNameFormat(QDeclarativeNdefRecord::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(), QDeclarativeNdefRecord::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(), QDeclarativeNdefRecord::Empty); } QTEST_MAIN(tst_QNdefRecord) -- cgit v1.2.3 From ea413e54839872770d1f10e65cab4670b470063c Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Mon, 30 Sep 2013 12:24:34 +0200 Subject: QML Near Field: Allow detecting NDEF messages without setting a filter Change-Id: Ifb85ddb23df8e5302aac1b70b893f71e0fe8462d Reviewed-by: Alex Blasche --- src/imports/nfc/qdeclarativenearfield.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp index 81a27730..ed907292 100644 --- a/src/imports/nfc/qdeclarativenearfield.cpp +++ b/src/imports/nfc/qdeclarativenearfield.cpp @@ -90,7 +90,10 @@ \qmlproperty list 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() */ /*! @@ -143,8 +146,7 @@ void QDeclarativeNearField::componentComplete() { m_componentCompleted = true; - if (!m_filterList.isEmpty()) - registerMessageHandler(); + registerMessageHandler(); } void QDeclarativeNearField::registerMessageHandler() @@ -155,10 +157,6 @@ void QDeclarativeNearField::registerMessageHandler() if (m_messageHandlerId != -1) m_manager->unregisterNdefMessageHandler(m_messageHandlerId); - // no filter abort - if (m_filterList.isEmpty()) - return; - QNdefFilter ndefFilter; ndefFilter.setOrderMatch(m_orderMatch); foreach (const QDeclarativeNdefFilter *filter, m_filterList) { -- cgit v1.2.3 From e2c75b1ecb52b60879c6316a8bea838c23d24b0f Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Mon, 30 Sep 2013 16:24:18 +0200 Subject: Don't throw an error when a low energy device is discovered Just ignore it Change-Id: I7d8139f8c10cee0df4e2ebdc13bb76ee6bb8dda3 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp index c271a47f..d5feb3eb 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp @@ -50,6 +50,8 @@ #include +#include + #include QT_BEGIN_NAMESPACE @@ -75,10 +77,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 { -- cgit v1.2.3 From 9e30601991c36878d62ac168365ce85130b6863f Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Mon, 30 Sep 2013 16:25:27 +0200 Subject: QNX: Fix uuid filter in service discovery Change-Id: I5493be50f66cf8df8fac1177b885c395a6d697b6 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp index d5feb3eb..acc2a4dd 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp @@ -169,7 +169,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); -- cgit v1.2.3 From 80884c9842899094574635e872fc717aaaa8814c Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Mon, 30 Sep 2013 18:28:45 +0200 Subject: QNX: Fix socket connection with a service info object Change-Id: Ib33787c849ba4370bb9e99a6cc50ce30ce216f0c Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp | 8 ++++++-- src/bluetooth/qbluetoothsocket_qnx.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp index acc2a4dd..2ea847e6 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_qnx.cpp @@ -160,8 +160,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 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; } -- cgit v1.2.3 From eefe516bd08771d037afafc833764ebaa6ff213e Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Tue, 1 Oct 2013 14:20:26 +0200 Subject: Change the service properties in btchat example And adding some links to the documentation. Change-Id: I7f9baf6a648547ef028f9521b0d88b88267fa301 Reviewed-by: Alex Blasche --- examples/bluetooth/btchat/chatserver.cpp | 9 +++++++-- src/bluetooth/qbluetoothserviceinfo.cpp | 6 ++++-- src/bluetooth/qbluetoothuuid.cpp | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/bluetooth/btchat/chatserver.cpp b/examples/bluetooth/btchat/chatserver.cpp index 8b1bf6f0..0b29b87b 100644 --- a/examples/bluetooth/btchat/chatserver.cpp +++ b/examples/bluetooth/btchat/chatserver.cpp @@ -73,11 +73,16 @@ void ChatServer::startServer(const QBluetoothAddress& localAdapter) } //! [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] diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp index 5ff48b4e..c38d5bbc 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. 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 */ /*! -- cgit v1.2.3 From 590fa9441c01ec1acf987091929a4d07d744b72b Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Fri, 4 Oct 2013 21:53:07 +0800 Subject: Rename QDeclarativeNdefRecord -> QQmlNdefRecord The QDeclarative* class prefix is associated with the now-deprecated Qt Declarative module (a.k.a. Qt Quick 1). In Qt Quick 2, all QDeclarative* classes have been renamed to QQml* or QQuick* Also rename the example, QDeclarativeNdefFooRecord -> QQmlNdefFooRecord Change-Id: Ie81a9ea2fdda145ad749afb07ef758f791b278d0 Reviewed-by: Alex Blasche --- src/imports/nfc/plugin.cpp | 4 +- src/imports/nfc/plugins.qmltypes | 10 +- src/imports/nfc/qdeclarativendeffilter.cpp | 4 +- src/imports/nfc/qdeclarativendeffilter_p.h | 10 +- src/imports/nfc/qdeclarativendefmimerecord.cpp | 4 +- src/imports/nfc/qdeclarativendefmimerecord_p.h | 4 +- src/imports/nfc/qdeclarativendeftextrecord.cpp | 4 +- src/imports/nfc/qdeclarativendeftextrecord_p.h | 4 +- src/imports/nfc/qdeclarativendefurirecord.cpp | 4 +- src/imports/nfc/qdeclarativendefurirecord_p.h | 4 +- src/imports/nfc/qdeclarativenearfield.cpp | 14 +- src/imports/nfc/qdeclarativenearfield_p.h | 18 +- src/nfc/doc/snippets/foorecord.cpp | 16 +- src/nfc/doc/snippets/foorecord.h | 10 +- src/nfc/nfc.pro | 4 +- src/nfc/qdeclarativendefrecord.cpp | 351 ------------------------- src/nfc/qdeclarativendefrecord.h | 113 -------- src/nfc/qqmlndefrecord.cpp | 351 +++++++++++++++++++++++++ src/nfc/qqmlndefrecord.h | 113 ++++++++ tests/auto/qndefrecord/tst_qndefrecord.cpp | 48 ++-- 20 files changed, 545 insertions(+), 545 deletions(-) delete mode 100644 src/nfc/qdeclarativendefrecord.cpp delete mode 100644 src/nfc/qdeclarativendefrecord.h create mode 100644 src/nfc/qqmlndefrecord.cpp create mode 100644 src/nfc/qqmlndefrecord.h diff --git a/src/imports/nfc/plugin.cpp b/src/imports/nfc/plugin.cpp index dd97e296..6be71c73 100644 --- a/src/imports/nfc/plugin.cpp +++ b/src/imports/nfc/plugin.cpp @@ -42,7 +42,7 @@ #include #include -#include "qdeclarativendefrecord.h" +#include "qqmlndefrecord.h" //#include "qdeclarativenearfieldsocket_p.h" #include "qdeclarativenearfield_p.h" #include "qdeclarativendeffilter_p.h" @@ -71,7 +71,7 @@ public: qmlRegisterType(uri, major, minor, "NearField"); qmlRegisterType(uri, major, minor, "NdefFilter"); - qmlRegisterType(uri, major, minor, "NdefRecord"); + qmlRegisterType(uri, major, minor, "NdefRecord"); qmlRegisterType(uri, major, minor, "NdefTextRecord"); qmlRegisterType(uri, major, minor, "NdefUriRecord"); qmlRegisterType(uri, major, minor, "NdefMimeRecord"); diff --git a/src/imports/nfc/plugins.qmltypes b/src/imports/nfc/plugins.qmltypes index 2d8eef8e..3e7cb4e4 100644 --- a/src/imports/nfc/plugins.qmltypes +++ b/src/imports/nfc/plugins.qmltypes @@ -18,13 +18,13 @@ Module { } Component { name: "QDeclarativeNdefMimeRecord" - prototype: "QDeclarativeNdefRecord" + prototype: "QQmlNdefRecord" exports: ["QtNfc/NdefMimeRecord 5.0"] exportMetaObjectRevisions: [0] Property { name: "uri"; type: "string"; isReadonly: true } } Component { - name: "QDeclarativeNdefRecord" + name: "QQmlNdefRecord" prototype: "QObject" exports: ["QtNfc/NdefRecord 5.0"] exportMetaObjectRevisions: [0] @@ -33,7 +33,7 @@ Module { } Component { name: "QDeclarativeNdefTextRecord" - prototype: "QDeclarativeNdefRecord" + prototype: "QQmlNdefRecord" exports: ["QtNfc/NdefTextRecord 5.0"] exportMetaObjectRevisions: [0] Enum { @@ -51,7 +51,7 @@ Module { } Component { name: "QDeclarativeNdefUriRecord" - prototype: "QDeclarativeNdefRecord" + prototype: "QQmlNdefRecord" exports: ["QtNfc/NdefUriRecord 5.0"] exportMetaObjectRevisions: [0] Property { name: "uri"; type: "string" } @@ -63,7 +63,7 @@ Module { exportMetaObjectRevisions: [0] Property { name: "messageRecords" - type: "QDeclarativeNdefRecord" + type: "QQmlNdefRecord" isList: true isReadonly: true } diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp index ae551774..b1c2f74c 100644 --- a/src/imports/nfc/qdeclarativendeffilter.cpp +++ b/src/imports/nfc/qdeclarativendeffilter.cpp @@ -119,12 +119,12 @@ void QDeclarativeNdefFilter::setType(const QString &t) emit typeChanged(); } -QDeclarativeNdefRecord::TypeNameFormat QDeclarativeNdefFilter::typeNameFormat() const +QQmlNdefRecord::TypeNameFormat QDeclarativeNdefFilter::typeNameFormat() const { return m_typeNameFormat; } -void QDeclarativeNdefFilter::setTypeNameFormat(QDeclarativeNdefRecord::TypeNameFormat format) +void QDeclarativeNdefFilter::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat format) { if (m_typeNameFormat == format) return; diff --git a/src/imports/nfc/qdeclarativendeffilter_p.h b/src/imports/nfc/qdeclarativendeffilter_p.h index 8622aece..2ff8e8e2 100644 --- a/src/imports/nfc/qdeclarativendeffilter_p.h +++ b/src/imports/nfc/qdeclarativendeffilter_p.h @@ -43,14 +43,14 @@ #define QDECLARATIVENDEFFILTER_P_H #include -#include +#include class QDeclarativeNdefFilter : public QObject { Q_OBJECT Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) - Q_PROPERTY(QDeclarativeNdefRecord::TypeNameFormat typeNameFormat READ typeNameFormat WRITE setTypeNameFormat NOTIFY typeNameFormatChanged) + 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: @@ -59,8 +59,8 @@ public: QString type() const; void setType(const QString &t); - QDeclarativeNdefRecord::TypeNameFormat typeNameFormat() const; - void setTypeNameFormat(QDeclarativeNdefRecord::TypeNameFormat format); + QQmlNdefRecord::TypeNameFormat typeNameFormat() const; + void setTypeNameFormat(QQmlNdefRecord::TypeNameFormat format); int minimum() const; void setMinimum(int value); @@ -78,7 +78,7 @@ private: QString m_type; int m_minimum; int m_maximum; - QDeclarativeNdefRecord::TypeNameFormat m_typeNameFormat; + QQmlNdefRecord::TypeNameFormat m_typeNameFormat; }; #endif // QDECLARATIVENDEFFILTER_P_H diff --git a/src/imports/nfc/qdeclarativendefmimerecord.cpp b/src/imports/nfc/qdeclarativendefmimerecord.cpp index b1c49bde..9468c01a 100644 --- a/src/imports/nfc/qdeclarativendefmimerecord.cpp +++ b/src/imports/nfc/qdeclarativendefmimerecord.cpp @@ -80,12 +80,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 +#include 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 ad3cda6a..d487c351 100644 --- a/src/imports/nfc/qdeclarativendeftextrecord.cpp +++ b/src/imports/nfc/qdeclarativendeftextrecord.cpp @@ -108,12 +108,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 +#include #include 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 47a65cfa..069472e5 100644 --- a/src/imports/nfc/qdeclarativendefurirecord.cpp +++ b/src/imports/nfc/qdeclarativendefurirecord.cpp @@ -66,12 +66,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 +#include #include @@ -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 ed907292..9c871319 100644 --- a/src/imports/nfc/qdeclarativenearfield.cpp +++ b/src/imports/nfc/qdeclarativenearfield.cpp @@ -109,9 +109,9 @@ QDeclarativeNearField::QDeclarativeNearField(QObject *parent) { } -QQmlListProperty QDeclarativeNearField::messageRecords() +QQmlListProperty QDeclarativeNearField::messageRecords() { - return QQmlListProperty(this, 0, + return QQmlListProperty(this, 0, &QDeclarativeNearField::append_messageRecord, &QDeclarativeNearField::count_messageRecords, &QDeclarativeNearField::at_messageRecord, @@ -186,8 +186,8 @@ void QDeclarativeNearField::_q_handleNdefMessage(const QNdefMessage &message) emit messageRecordsChanged(); } -void QDeclarativeNearField::append_messageRecord(QQmlListProperty *list, - QDeclarativeNdefRecord *record) +void QDeclarativeNearField::append_messageRecord(QQmlListProperty *list, + QQmlNdefRecord *record) { QDeclarativeNearField *nearField = qobject_cast(list->object); if (!nearField) @@ -199,7 +199,7 @@ void QDeclarativeNearField::append_messageRecord(QQmlListPropertymessageRecordsChanged(); } -int QDeclarativeNearField::count_messageRecords(QQmlListProperty *list) +int QDeclarativeNearField::count_messageRecords(QQmlListProperty *list) { QDeclarativeNearField *nearField = qobject_cast(list->object); if (!nearField) @@ -208,7 +208,7 @@ int QDeclarativeNearField::count_messageRecords(QQmlListPropertym_message.count(); } -QDeclarativeNdefRecord *QDeclarativeNearField::at_messageRecord(QQmlListProperty *list, +QQmlNdefRecord *QDeclarativeNearField::at_messageRecord(QQmlListProperty *list, int index) { QDeclarativeNearField *nearField = qobject_cast(list->object); @@ -218,7 +218,7 @@ QDeclarativeNdefRecord *QDeclarativeNearField::at_messageRecord(QQmlListProperty return nearField->m_message.at(index); } -void QDeclarativeNearField::clear_messageRecords(QQmlListProperty *list) +void QDeclarativeNearField::clear_messageRecords(QQmlListProperty *list) { QDeclarativeNearField *nearField = qobject_cast(list->object); if (nearField) { diff --git a/src/imports/nfc/qdeclarativenearfield_p.h b/src/imports/nfc/qdeclarativenearfield_p.h index ad551308..14a6d986 100644 --- a/src/imports/nfc/qdeclarativenearfield_p.h +++ b/src/imports/nfc/qdeclarativenearfield_p.h @@ -47,7 +47,7 @@ #include #include -#include "qdeclarativendefrecord.h" +#include "qqmlndefrecord.h" QT_USE_NAMESPACE @@ -57,7 +57,7 @@ class QDeclarativeNearField : public QObject, public QQmlParserStatus { Q_OBJECT - Q_PROPERTY(QQmlListProperty messageRecords READ messageRecords NOTIFY messageRecordsChanged) + Q_PROPERTY(QQmlListProperty messageRecords READ messageRecords NOTIFY messageRecordsChanged) Q_PROPERTY(QQmlListProperty 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 messageRecords(); + QQmlListProperty messageRecords(); QQmlListProperty filter(); @@ -86,7 +86,7 @@ private slots: void _q_handleNdefMessage(const QNdefMessage &message); private: - QList m_message; + QList m_message; QList m_filterList; bool m_orderMatch; bool m_componentCompleted; @@ -97,12 +97,12 @@ private: void registerMessageHandler(); - static void append_messageRecord(QQmlListProperty *list, - QDeclarativeNdefRecord *record); - static int count_messageRecords(QQmlListProperty *list); - static QDeclarativeNdefRecord *at_messageRecord(QQmlListProperty *list, + static void append_messageRecord(QQmlListProperty *list, + QQmlNdefRecord *record); + static int count_messageRecords(QQmlListProperty *list); + static QQmlNdefRecord *at_messageRecord(QQmlListProperty *list, int index); - static void clear_messageRecords(QQmlListProperty *list); + static void clear_messageRecords(QQmlListProperty *list); static void append_filter(QQmlListProperty *list, QDeclarativeNdefFilter *filter); 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 //! [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 +#include 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/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/qdeclarativendefrecord.cpp b/src/nfc/qdeclarativendefrecord.cpp deleted file mode 100644 index edec632e..00000000 --- a/src/nfc/qdeclarativendefrecord.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativendefrecord.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \class QDeclarativeNdefRecord - \brief The QDeclarativeNdefRecord 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 - 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: - - \list - \li The subclass must have a Q_OBJECT macro in its declaration. - \li The subclass must have an \l {Q_INVOKABLE}{invokable} constructor that takes a - QNdefRecord and a QObject pointer. - \li The subclass must be declared as an NDEF record by expanding the Q_DECLARE_NDEFRECORD() - macro in the implementation file of the subclass. - \li The subclass must be registered with QML. - \endlist - - For example the declaration of such a class may look like the following. - - \snippet foorecord.h Foo declaration - - Within the implementation file the Q_DECLARE_NDEFRECORD() macro is expanded: - - \snippet foorecord.cpp Declare foo record - - Finially the application or plugin code calls qmlRegisterType(): - - \code - qmlRegisterType(uri, 1, 0, "NdefFooRecord"); - \endcode -*/ - -/*! - \qmltype NdefRecord - \instantiates QDeclarativeNdefRecord - \brief The NdefRecord type represents a record in an NDEF message. - - \ingroup nfc-qml - \inqmlmodule QtNfc - - \sa NdefFilter - \sa NearField - - \sa QNdefRecord - - The NdefRecord type is the base type for all NDEF record types in QML. It contains - a single property holding the type of record. - - This class is not intended to be used directly, but extended from C++. - - \sa QDeclarativeNdefRecord -*/ - -/*! - \qmlproperty string NdefRecord::type - - 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() -*/ - -/*! - \qmlproperty string NdefRecord::record - - This property holds the NDEF record. -*/ - -/*! - \fn void QDeclarativeNdefRecord::typeChanged() - - This signal is emitted when the record type changes. -*/ - -/*! - \property QDeclarativeNdefRecord::record - - This property hold the NDEF record that this class represents. -*/ - -/*! - \property QDeclarativeNdefRecord::type - - This property hold the type of the NDEF record. -*/ - -/*! - \property QDeclarativeNdefRecord::typeNameFormat - - This property hold the TNF of the NDEF record. -*/ - -/*! - \macro Q_DECLARE_NDEFRECORD(className, typeNameFormat, type) - \relates QDeclarativeNdefRecord - - This macro ensures that \a className is declared as the class implementing the NDEF record - identified by \a typeNameFormat and \a type. - - This macro should be expanded in the implementation file for \a className. -*/ - -static QMap registeredNdefRecordTypes; - -class QDeclarativeNdefRecordPrivate -{ -public: - QNdefRecord record; -}; - -static QString urnForRecordType(QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray &type) -{ - switch (typeNameFormat) { - case QNdefRecord::NfcRtd: - return QLatin1String("urn:nfc:wkt:") + QString::fromLatin1(type); - case QNdefRecord::ExternalRtd: - return QLatin1String("urn:nfc:ext:") + QString::fromLatin1(type); - case QNdefRecord::Mime: - return QLatin1String("urn:nfc:mime:") + QString::fromLatin1(type); - default: - return QString(); - } -} - -/*! - \internal -*/ -void qRegisterNdefRecordTypeHelper(const QMetaObject *metaObject, - QNdefRecord::TypeNameFormat typeNameFormat, - const QByteArray &type) -{ - registeredNdefRecordTypes.insert(urnForRecordType(typeNameFormat, type), metaObject); -} - -/*! - \internal -*/ -QDeclarativeNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord &record) -{ - const QString urn = urnForRecordType(record.typeNameFormat(), record.type()); - - QMapIterator i(registeredNdefRecordTypes); - while (i.hasNext()) { - i.next(); - - QRegExp ex(i.key()); - if (!ex.exactMatch(urn)) - continue; - - const QMetaObject *metaObject = i.value(); - if (!metaObject) - continue; - - return static_cast(metaObject->newInstance( - Q_ARG(QNdefRecord, record), Q_ARG(QObject *, 0))); - } - - return new QDeclarativeNdefRecord(record); -} - -/*! - Constructs a new empty QDeclarativeNdefRecord with \a parent. -*/ -QDeclarativeNdefRecord::QDeclarativeNdefRecord(QObject *parent) -: QObject(parent), d_ptr(new QDeclarativeNdefRecordPrivate) -{ -} - -/*! - Constructs a new QDeclarativeNdefRecord 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) -{ - d_ptr->record = record; -} - -/*! - \enum QDeclarativeNdefRecord::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::type() const -{ - Q_D(const QDeclarativeNdefRecord); - - 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 typeChanged() signal will be emitted. - - \sa QNdefRecord::setType(), QNdefRecord::type() -*/ -void QDeclarativeNdefRecord::setType(const QString &newtype) -{ - if (newtype == type()) - return; - - Q_D(QDeclarativeNdefRecord); - d->record.setType(newtype.toUtf8()); - - emit typeChanged(); -} - -/*! - Sets the type name format of the NDEF record to \a typeNameFormat. -*/ -void QDeclarativeNdefRecord::setTypeNameFormat(QDeclarativeNdefRecord::TypeNameFormat typeNameFormat) -{ - Q_D(QDeclarativeNdefRecord); - bool emitChanged = true; - if (static_cast(d->record.typeNameFormat()) == typeNameFormat) { - emitChanged = false; - } - - //We always have to set the tnf, otherwise we run into problems when tnf is empty. Then - //the QNdefRecordPrivate is not created - d->record.setTypeNameFormat(static_cast(typeNameFormat)); - - if (emitChanged) - Q_EMIT(typeNameFormatChanged()); -} - -/*! - \fn QDeclarativeNdefRecord::TypeNameFormat QDeclarativeNdefRecord::typeNameFormat() const - - Returns the type name format of the NDEF record. -*/ -QDeclarativeNdefRecord::TypeNameFormat QDeclarativeNdefRecord::typeNameFormat() const -{ - Q_D(const QDeclarativeNdefRecord); - return static_cast(d->record.typeNameFormat()); -} - -/*! - Returns a copy of the record. -*/ -QNdefRecord QDeclarativeNdefRecord::record() const -{ - Q_D(const QDeclarativeNdefRecord); - - return d->record; -} - -/*! - Sets the record to \a record. If the record is set the recordChanged() signal will - be emitted. -*/ -void QDeclarativeNdefRecord::setRecord(const QNdefRecord &record) -{ - Q_D(QDeclarativeNdefRecord); - - if (d->record == record) - return; - - d->record = record; - emit recordChanged(); -} - -QT_END_NAMESPACE diff --git a/src/nfc/qdeclarativendefrecord.h b/src/nfc/qdeclarativendefrecord.h deleted file mode 100644 index 52c436fe..00000000 --- a/src/nfc/qdeclarativendefrecord.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVENDEFRECORD_P_H -#define QDECLARATIVENDEFRECORD_P_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeNdefRecordPrivate; - -class Q_NFC_EXPORT QDeclarativeNdefRecord : public QObject -{ - Q_OBJECT - - Q_DECLARE_PRIVATE(QDeclarativeNdefRecord) - - 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: - enum TypeNameFormat { - Empty = QNdefRecord::Empty, - NfcRtd = QNdefRecord::NfcRtd, - Mime = QNdefRecord::Mime, - Uri = QNdefRecord::Uri, - ExternalRtd = QNdefRecord::ExternalRtd, - Unknown = QNdefRecord::Unknown - }; - - explicit QDeclarativeNdefRecord(QObject *parent = 0); - explicit QDeclarativeNdefRecord(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 typeChanged(); - void typeNameFormatChanged(); - void recordChanged(); - -private: - QDeclarativeNdefRecordPrivate *d_ptr; -}; - -void Q_NFC_EXPORT qRegisterNdefRecordTypeHelper(const QMetaObject *metaObject, - QNdefRecord::TypeNameFormat typeNameFormat, - const QByteArray &type); - -Q_NFC_EXPORT QDeclarativeNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord &record); - -template -bool qRegisterNdefRecordType(QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray &type) -{ - qRegisterNdefRecordTypeHelper(&T::staticMetaObject, typeNameFormat, type); - return true; -} - -#define Q_DECLARE_NDEFRECORD(className, typeNameFormat, type) \ -static bool _q_##className##_registered = qRegisterNdefRecordType(typeNameFormat, type); - -QT_END_NAMESPACE - -#endif // QDECLARATIVENDEFRECORD_P_H diff --git a/src/nfc/qqmlndefrecord.cpp b/src/nfc/qqmlndefrecord.cpp new file mode 100644 index 00000000..fd154d74 --- /dev/null +++ b/src/nfc/qqmlndefrecord.cpp @@ -0,0 +1,351 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtNfc module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlndefrecord.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QQmlNdefRecord + \brief The QQmlNdefRecord class implements the NdefRecord type in QML. + + \ingroup connectivity-nfc + \inmodule QtNfc + + \sa NdefRecord + + 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: + + \list + \li The subclass must have a Q_OBJECT macro in its declaration. + \li The subclass must have an \l {Q_INVOKABLE}{invokable} constructor that takes a + QNdefRecord and a QObject pointer. + \li The subclass must be declared as an NDEF record by expanding the Q_DECLARE_NDEFRECORD() + macro in the implementation file of the subclass. + \li The subclass must be registered with QML. + \endlist + + For example the declaration of such a class may look like the following. + + \snippet foorecord.h Foo declaration + + Within the implementation file the Q_DECLARE_NDEFRECORD() macro is expanded: + + \snippet foorecord.cpp Declare foo record + + Finially the application or plugin code calls qmlRegisterType(): + + \code + qmlRegisterType(uri, 1, 0, "NdefFooRecord"); + \endcode +*/ + +/*! + \qmltype NdefRecord + \instantiates QQmlNdefRecord + \brief The NdefRecord type represents a record in an NDEF message. + + \ingroup nfc-qml + \inqmlmodule QtNfc + + \sa NdefFilter + \sa NearField + + \sa QNdefRecord + + The NdefRecord type is the base type for all NDEF record types in QML. It contains + a single property holding the type of record. + + This class is not intended to be used directly, but extended from C++. + + \sa QQmlNdefRecord +*/ + +/*! + \qmlproperty string NdefRecord::type + + 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() +*/ + +/*! + \qmlproperty string NdefRecord::record + + This property holds the NDEF record. +*/ + +/*! + \fn void QQmlNdefRecord::typeChanged() + + This signal is emitted when the record type changes. +*/ + +/*! + \property QQmlNdefRecord::record + + This property hold the NDEF record that this class represents. +*/ + +/*! + \property QQmlNdefRecord::type + + This property hold the type of the NDEF record. +*/ + +/*! + \property QQmlNdefRecord::typeNameFormat + + This property hold the TNF of the NDEF record. +*/ + +/*! + \macro Q_DECLARE_NDEFRECORD(className, typeNameFormat, type) + \relates QQmlNdefRecord + + This macro ensures that \a className is declared as the class implementing the NDEF record + identified by \a typeNameFormat and \a type. + + This macro should be expanded in the implementation file for \a className. +*/ + +static QMap registeredNdefRecordTypes; + +class QQmlNdefRecordPrivate +{ +public: + QNdefRecord record; +}; + +static QString urnForRecordType(QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray &type) +{ + switch (typeNameFormat) { + case QNdefRecord::NfcRtd: + return QLatin1String("urn:nfc:wkt:") + QString::fromLatin1(type); + case QNdefRecord::ExternalRtd: + return QLatin1String("urn:nfc:ext:") + QString::fromLatin1(type); + case QNdefRecord::Mime: + return QLatin1String("urn:nfc:mime:") + QString::fromLatin1(type); + default: + return QString(); + } +} + +/*! + \internal +*/ +void qRegisterNdefRecordTypeHelper(const QMetaObject *metaObject, + QNdefRecord::TypeNameFormat typeNameFormat, + const QByteArray &type) +{ + registeredNdefRecordTypes.insert(urnForRecordType(typeNameFormat, type), metaObject); +} + +/*! + \internal +*/ +QQmlNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord &record) +{ + const QString urn = urnForRecordType(record.typeNameFormat(), record.type()); + + QMapIterator i(registeredNdefRecordTypes); + while (i.hasNext()) { + i.next(); + + QRegExp ex(i.key()); + if (!ex.exactMatch(urn)) + continue; + + const QMetaObject *metaObject = i.value(); + if (!metaObject) + continue; + + return static_cast(metaObject->newInstance( + Q_ARG(QNdefRecord, record), Q_ARG(QObject *, 0))); + } + + return new QQmlNdefRecord(record); +} + +/*! + Constructs a new empty QQmlNdefRecord with \a parent. +*/ +QQmlNdefRecord::QQmlNdefRecord(QObject *parent) +: QObject(parent), d_ptr(new QQmlNdefRecordPrivate) +{ +} + +/*! + Constructs a new QQmlNdefRecord representing \a record. The parent of the newly + constructed object will be set to \a parent. +*/ +QQmlNdefRecord::QQmlNdefRecord(const QNdefRecord &record, QObject *parent) +: QObject(parent), d_ptr(new QQmlNdefRecordPrivate) +{ + d_ptr->record = record; +} + +/*! + \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 QQmlNdefRecord::type() const +{ + Q_D(const QQmlNdefRecord); + + 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 typeChanged() signal will be emitted. + + \sa QNdefRecord::setType(), QNdefRecord::type() +*/ +void QQmlNdefRecord::setType(const QString &newtype) +{ + if (newtype == type()) + return; + + Q_D(QQmlNdefRecord); + d->record.setType(newtype.toUtf8()); + + emit typeChanged(); +} + +/*! + Sets the type name format of the NDEF record to \a typeNameFormat. +*/ +void QQmlNdefRecord::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat typeNameFormat) +{ + Q_D(QQmlNdefRecord); + bool emitChanged = true; + if (static_cast(d->record.typeNameFormat()) == typeNameFormat) { + emitChanged = false; + } + + //We always have to set the tnf, otherwise we run into problems when tnf is empty. Then + //the QNdefRecordPrivate is not created + d->record.setTypeNameFormat(static_cast(typeNameFormat)); + + if (emitChanged) + Q_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(d->record.typeNameFormat()); +} + +/*! + Returns a copy of the record. +*/ +QNdefRecord QQmlNdefRecord::record() const +{ + Q_D(const QQmlNdefRecord); + + return d->record; +} + +/*! + Sets the record to \a record. If the record is set the recordChanged() signal will + be emitted. +*/ +void QQmlNdefRecord::setRecord(const QNdefRecord &record) +{ + Q_D(QQmlNdefRecord); + + if (d->record == record) + return; + + d->record = record; + emit recordChanged(); +} + +QT_END_NAMESPACE diff --git a/src/nfc/qqmlndefrecord.h b/src/nfc/qqmlndefrecord.h new file mode 100644 index 00000000..76ba8bf2 --- /dev/null +++ b/src/nfc/qqmlndefrecord.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtNfc module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLNDEFRECORD_H +#define QQMLNDEFRECORD_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQmlNdefRecordPrivate; + +class Q_NFC_EXPORT QQmlNdefRecord : public QObject +{ + Q_OBJECT + + Q_DECLARE_PRIVATE(QQmlNdefRecord) + + 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: + enum TypeNameFormat { + Empty = QNdefRecord::Empty, + NfcRtd = QNdefRecord::NfcRtd, + Mime = QNdefRecord::Mime, + Uri = QNdefRecord::Uri, + ExternalRtd = QNdefRecord::ExternalRtd, + Unknown = QNdefRecord::Unknown + }; + + 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 typeChanged(); + void typeNameFormatChanged(); + void recordChanged(); + +private: + QQmlNdefRecordPrivate *d_ptr; +}; + +void Q_NFC_EXPORT qRegisterNdefRecordTypeHelper(const QMetaObject *metaObject, + QNdefRecord::TypeNameFormat typeNameFormat, + const QByteArray &type); + +Q_NFC_EXPORT QQmlNdefRecord *qNewDeclarativeNdefRecordForNdefRecord(const QNdefRecord &record); + +template +bool qRegisterNdefRecordType(QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray &type) +{ + qRegisterNdefRecordTypeHelper(&T::staticMetaObject, typeNameFormat, type); + return true; +} + +#define Q_DECLARE_NDEFRECORD(className, typeNameFormat, type) \ +static bool _q_##className##_registered = qRegisterNdefRecordType(typeNameFormat, type); + +QT_END_NAMESPACE + +#endif // QQMLNDEFRECORD_H diff --git a/tests/auto/qndefrecord/tst_qndefrecord.cpp b/tests/auto/qndefrecord/tst_qndefrecord.cpp index 6ccb9566..000ff017 100644 --- a/tests/auto/qndefrecord/tst_qndefrecord.cpp +++ b/tests/auto/qndefrecord/tst_qndefrecord.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include QT_USE_NAMESPACE @@ -99,10 +99,10 @@ void tst_QNdefRecord::tst_record() QCOMPARE(record, QNdefRecord()); QVERIFY(!(record != QNdefRecord())); - QDeclarativeNdefRecord declRecord; + QQmlNdefRecord declRecord; QCOMPARE(declRecord.record(), record); QCOMPARE(declRecord.type(), QString()); - QCOMPARE(declRecord.typeNameFormat(), QDeclarativeNdefRecord::Empty); + QCOMPARE(declRecord.typeNameFormat(), QQmlNdefRecord::Empty); } // test type name format @@ -256,10 +256,10 @@ void tst_QNdefRecord::tst_textRecord() QVERIFY(record != QNdefRecord()); - QDeclarativeNdefRecord declRecord(record); + QQmlNdefRecord declRecord(record); QCOMPARE(declRecord.record(), QNdefRecord(record)); QCOMPARE(declRecord.type(), QString("T")); - QCOMPARE(declRecord.typeNameFormat(), QDeclarativeNdefRecord::NfcRtd); + QCOMPARE(declRecord.typeNameFormat(), QQmlNdefRecord::NfcRtd); } // test getters @@ -325,10 +325,10 @@ void tst_QNdefRecord::tst_uriRecord() QVERIFY(record != QNdefRecord()); - QDeclarativeNdefRecord declRecord(record); + QQmlNdefRecord declRecord(record); QCOMPARE(declRecord.record(), QNdefRecord(record)); QCOMPARE(declRecord.type(), QString("U")); - QCOMPARE(declRecord.typeNameFormat(), QDeclarativeNdefRecord::NfcRtd); + QCOMPARE(declRecord.typeNameFormat(), QQmlNdefRecord::NfcRtd); } // test getters @@ -386,34 +386,34 @@ 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.type(), QString(type)); - QCOMPARE(declRecord.typeNameFormat(), static_cast(typeNameFormat)); + QCOMPARE(declRecord.typeNameFormat(), static_cast(typeNameFormat)); - QDeclarativeNdefRecord declRecord2; + QQmlNdefRecord declRecord2; declRecord2.setRecord(record); QCOMPARE(declRecord2.record(), record); QCOMPARE(declRecord2.record().typeNameFormat(), typeNameFormat); QCOMPARE(declRecord2.record().type(), type); QCOMPARE(declRecord2.type(), QString(type)); - QCOMPARE(declRecord2.typeNameFormat(), static_cast(typeNameFormat)); + QCOMPARE(declRecord2.typeNameFormat(), static_cast(typeNameFormat)); - QDeclarativeNdefRecord declRecord3; - declRecord3.setTypeNameFormat((QDeclarativeNdefRecord::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(typeNameFormat)); + QCOMPARE(declRecord3.typeNameFormat(), static_cast(typeNameFormat)); } } void tst_QNdefRecord::tst_declarativeChangedSignals() { - QDeclarativeNdefRecord record; + QQmlNdefRecord record; QSignalSpy typeSpy(&record, SIGNAL(typeChanged())); QSignalSpy tnfSpy(&record, SIGNAL(typeNameFormatChanged())); QSignalSpy recordSpy(&record, SIGNAL(recordChanged())); @@ -422,14 +422,14 @@ void tst_QNdefRecord::tst_declarativeChangedSignals() QCOMPARE(recordSpy.count(), 0); record.setType("U"); - record.setTypeNameFormat(QDeclarativeNdefRecord::NfcRtd); + record.setTypeNameFormat(QQmlNdefRecord::NfcRtd); QCOMPARE(typeSpy.count(), 1); QCOMPARE(tnfSpy.count(), 1); QCOMPARE(recordSpy.count(), 0); QCOMPARE(record.type(), QString("U")); QCOMPARE(record.record().type(), QByteArray("U")); QCOMPARE(record.record().typeNameFormat(), QNdefRecord::NfcRtd); - QCOMPARE(record.typeNameFormat(), QDeclarativeNdefRecord::NfcRtd); + QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::NfcRtd); record.setType("U"); //same value, no signal QCOMPARE(typeSpy.count(), 1); @@ -438,18 +438,18 @@ void tst_QNdefRecord::tst_declarativeChangedSignals() QCOMPARE(record.type(), QString("U")); QCOMPARE(record.record().type(), QByteArray("U")); QCOMPARE(record.record().typeNameFormat(), QNdefRecord::NfcRtd); - QCOMPARE(record.typeNameFormat(), QDeclarativeNdefRecord::NfcRtd); + QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::NfcRtd); record.setType("blah"); record.setType("blah2"); - record.setTypeNameFormat(QDeclarativeNdefRecord::ExternalRtd); + record.setTypeNameFormat(QQmlNdefRecord::ExternalRtd); QCOMPARE(typeSpy.count(), 3); QCOMPARE(tnfSpy.count(), 2); QCOMPARE(recordSpy.count(), 0); QCOMPARE(record.type(), QString("blah2")); QCOMPARE(record.record().type(), QByteArray("blah2")); QCOMPARE(record.record().typeNameFormat(), QNdefRecord::ExternalRtd); - QCOMPARE(record.typeNameFormat(), QDeclarativeNdefRecord::ExternalRtd); + QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::ExternalRtd); record.setType("Rubbish"); QCOMPARE(typeSpy.count(), 4); @@ -458,17 +458,17 @@ void tst_QNdefRecord::tst_declarativeChangedSignals() QCOMPARE(record.type(), QString("Rubbish")); QCOMPARE(record.record().type(), QByteArray("Rubbish")); QCOMPARE(record.record().typeNameFormat(), QNdefRecord::ExternalRtd); - QCOMPARE(record.typeNameFormat(), QDeclarativeNdefRecord::ExternalRtd); + QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::ExternalRtd); record.setType("QQQQ"); - record.setTypeNameFormat(QDeclarativeNdefRecord::Mime); + record.setTypeNameFormat(QQmlNdefRecord::Mime); QCOMPARE(typeSpy.count(), 5); QCOMPARE(tnfSpy.count(), 3); QCOMPARE(recordSpy.count(), 0); QCOMPARE(record.type(), QString("QQQQ")); QCOMPARE(record.record().type(), QByteArray("QQQQ")); QCOMPARE(record.record().typeNameFormat(), QNdefRecord::Mime); - QCOMPARE(record.typeNameFormat(), QDeclarativeNdefRecord::Mime); + QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::Mime); record.setRecord(QNdefRecord()); QCOMPARE(typeSpy.count(), 5); //setting record -> no recordChanged signal @@ -477,7 +477,7 @@ void tst_QNdefRecord::tst_declarativeChangedSignals() QCOMPARE(record.type(), QString("")); QCOMPARE(record.record().type(), QByteArray()); QCOMPARE(record.record().typeNameFormat(), QNdefRecord::Empty); - QCOMPARE(record.typeNameFormat(), QDeclarativeNdefRecord::Empty); + QCOMPARE(record.typeNameFormat(), QQmlNdefRecord::Empty); } QTEST_MAIN(tst_QNdefRecord) -- cgit v1.2.3 From c14977cc806227bc546043c0d16ede21b856e830 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 25 Sep 2013 18:15:33 +0200 Subject: Fix QDeclarativeBluetoothSocket stringData property Task-number: QTBUG-31729 Change-Id: Idd820e57b72c2293c999bdc0a578d1e8f8e5471b Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- .../bluetooth/qdeclarativebluetoothsocket.cpp | 34 +++++----------------- .../bluetooth/qdeclarativebluetoothsocket_p.h | 2 +- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp index 54a4ef8e..c94807a4 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp @@ -118,8 +118,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 +127,6 @@ public: QDeclarativeBluetoothSocket::SocketState m_state; bool m_componentCompleted; bool m_connected; - QDataStream *m_stream; - }; QDeclarativeBluetoothSocket::QDeclarativeBluetoothSocket(QObject *parent) : @@ -160,9 +156,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 +305,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(); @@ -344,30 +328,30 @@ 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) @@ -388,8 +372,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..cb6255b6 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h +++ b/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h @@ -120,7 +120,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(); -- cgit v1.2.3 From d78fcc4fda3282c3a465ea4b30294aa856dd0147 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Mon, 7 Oct 2013 22:59:24 +0200 Subject: QNX: Fix update progress The string format can only be converted to a double for very high numbers. Change-Id: I20e284eb24761dcb11a4777baf37782752b95bb6 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothtransferreply_qnx.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bluetooth/qbluetoothtransferreply_qnx.cpp b/src/bluetooth/qbluetoothtransferreply_qnx.cpp index 56e2c3e3..e37852cd 100644 --- a/src/bluetooth/qbluetoothtransferreply_qnx.cpp +++ b/src/bluetooth/qbluetoothtransferreply_qnx.cpp @@ -192,12 +192,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")) { -- cgit v1.2.3 From 527cb367ba745a7f675ca7ef314cd3d28934c5b9 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 8 Oct 2013 20:15:08 +0200 Subject: sync.profile: Remove dependency on qtsystems#dev Change-Id: Ice4b9d2bf163aab7ac4d17387e11cf09b2a68790 Reviewed-by: Alex Blasche --- sync.profile | 1 - 1 file changed, 1 deletion(-) diff --git a/sync.profile b/sync.profile index 3e08d775..34518c9a 100644 --- a/sync.profile +++ b/sync.profile @@ -14,6 +14,5 @@ %dependencies = ( "qtbase" => "", "qtdeclarative" => "", - "qtsystems" => "refs/heads/dev", "qtxmlpatterns" => "", ); -- cgit v1.2.3 From d5c1f2564d1623d67a79d7bc990043bc1d55cf76 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 10 Oct 2013 10:21:48 +0200 Subject: Fix MSVC64-warning about truncation from size_t to int. Change-Id: I592a6bf4396ff2fc587527fe4faf1093d9ea4f57 Reviewed-by: Alex Blasche --- src/bluetooth/qprivatelinearbuffer_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]; -- cgit v1.2.3 From 5514cae34d9b3ed8a374778e00ffe3b5682e0a0c Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 10 Oct 2013 12:25:55 +0200 Subject: Fix Bluetooth doc errors. Change-Id: I2ed67e0989eb8fe2c2c63def2654c6db2805c94a Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothserviceinfo.cpp | 2 +- src/imports/bluetooth/qdeclarativebluetoothsocket.cpp | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp index c38d5bbc..3a864b3c 100644 --- a/src/bluetooth/qbluetoothserviceinfo.cpp +++ b/src/bluetooth/qbluetoothserviceinfo.cpp @@ -124,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. diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp index c94807a4..449e578a 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp @@ -313,13 +313,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() @@ -339,8 +337,6 @@ QString QDeclarativeBluetoothSocket::stringData() /*! 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(const QString &data) -- cgit v1.2.3 From 42bd6c83b19f789821c4fde414f1ef457dce120d Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Thu, 10 Oct 2013 20:03:49 +0200 Subject: Make the QBluetoothTransferRequest constructor explicit Change-Id: I973ffedf6dc0c5b7215c9e99f5fb4bcb96ea6084 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothtransferrequest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); -- cgit v1.2.3 From 8155679b01ec523d877bcb1d6d019b3b555befaa Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 10 Oct 2013 12:09:55 +0200 Subject: Improve handling of invalid Bt address by QBluetoothTransferManager Some minor unit test improvements Task-number: QTBUG-33801 Change-Id: Idc98bf8928ced0f9e01b24668edf7c32172d2fd1 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothtransferreply_bluez.cpp | 10 +++++++++- src/bluetooth/qbluetoothtransferreply_qnx.cpp | 11 ++++++++++- .../tst_qbluetoothtransfermanager.cpp | 9 ++++----- 3 files changed, 23 insertions(+), 7 deletions(-) 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 e37852cd..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; diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp index 5c9ea9f0..885b7f1e 100644 --- a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp +++ b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp @@ -276,7 +276,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 +289,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 +310,8 @@ void tst_QBluetoothTransferManager::tst_sendFile() const int maxWaitTime = 20 * 1000; //20s for (int time = 0; time0); -- cgit v1.2.3 From d899ab782c2cb3f73a48d4b5bce072c27996f573 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 10 Oct 2013 15:17:47 +0200 Subject: Remove the "registerNdefMessageHandler" template function and doc fixes Too much syntactic sugar and qdoc has problems recognising it as well. Change-Id: I99f482426f537a8d3c0099edc3c393676424afec Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/nfc/qndefrecord.cpp | 2 +- src/nfc/qnearfieldmanager.h | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) 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/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 - 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 -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 -- cgit v1.2.3 From aa5f17bda3c6c958563c75bf74553c20cd18d6df Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 10 Oct 2013 13:38:14 +0200 Subject: BluetoothDiscoveryModel API fixes - rename signal: newServiceDiscovered -> serviceDiscovered - rename signal: newDeviceDiscovered -> deviceDisovered - add parameter to deviceDiscovered signal - improve documentation for above signals - minor example fixes Task-number: QTBUG-33678 Change-Id: I2f9223250ef844564c3e76a85adc25322867fd6e Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- examples/bluetooth/scanner/scanner.qml | 7 +++++-- .../qdeclarativebluetoothdiscoverymodel.cpp | 23 ++++++++++------------ .../qdeclarativebluetoothdiscoverymodel_p.h | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/bluetooth/scanner/scanner.qml b/examples/bluetooth/scanner/scanner.qml index 52182362..7ae0e28e 100644 --- a/examples/bluetooth/scanner/scanner.qml +++ b/examples/bluetooth/scanner/scanner.qml @@ -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 += "
Service: " + s.serviceName; } if (s.serviceDescription) { str += "
Description: " + s.serviceDescription; } if (s.serviceProtocol) { str += "
Protocol: " + s.serviceProtocol; } - if (s.servicePort) { str += "
Port: " + s.servicePort; } return str; } } diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp index 04d08e48..8ec78f85 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp @@ -239,9 +239,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 +265,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 +282,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(); -- cgit v1.2.3 From 07520e4b650e0a6b4c5039bc0fdc7687df009d15 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 10 Oct 2013 13:53:04 +0200 Subject: Document the data roles offered by the BluetoothDiscoveryModel. Change-Id: Ifba68d1980f6eedd030db38836be5a2d62a224b2 Reviewed-by: Jerome Pasion Reviewed-by: Fabian Bumberger --- .../qdeclarativebluetoothdiscoverymodel.cpp | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp index 8ec78f85..c2623ba0 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp @@ -63,11 +63,33 @@ 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 -- cgit v1.2.3 From a575626bd20223f7a906162dcfb74963291a1330 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 10 Oct 2013 13:55:28 +0200 Subject: Update QML type description for Bluetooth QML API due to API changes. Change-Id: I30ae8567823e9d48a51654f18048bf66babc6e5a Reviewed-by: Jerome Pasion Reviewed-by: Fabian Bumberger --- src/imports/bluetooth/plugins.qmltypes | 46 +++++++++++----------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes index ba4b1bc7..89db5407 100644 --- a/src/imports/bluetooth/plugins.qmltypes +++ b/src/imports/bluetooth/plugins.qmltypes @@ -35,54 +35,36 @@ Module { Property { name: "uuidFilter"; type: "string" } Property { name: "remoteAddress"; type: "string" } Signal { - name: "newServiceDiscovered" + name: "serviceDiscovered" Parameter { name: "service"; type: "QDeclarativeBluetoothService"; isPointer: true } } - Signal { name: "newDeviceDiscovered" } + Signal { + name: "deviceDiscovered" + Parameter { name: "device"; type: "string" } + } } Component { name: "QDeclarativeBluetoothService" prototype: "QObject" exports: ["QtBluetooth/BluetoothService 5.0"] exportMetaObjectRevisions: [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" -- cgit v1.2.3 From 686b36a13ca3984879adbe712e86c20c9b4214e3 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 10 Oct 2013 10:35:40 +0200 Subject: Fix unit test error in qndefrecord. The typenameformat signal was not always emitted due to insufficient logic associated with first time initialization of QQmlNdefRecord. This error only happened when the compiler didn't initialize QNdefRecordPrivate::typeNameFormat to 0. Change-Id: Ieba0a1d7c940c40980ff455ca5c1665c298c0527 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/nfc/qndefrecord_p.h | 7 +++++-- src/nfc/qqmlndefrecord.cpp | 19 +++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) 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/qqmlndefrecord.cpp b/src/nfc/qqmlndefrecord.cpp index fd154d74..8a3f24d7 100644 --- a/src/nfc/qqmlndefrecord.cpp +++ b/src/nfc/qqmlndefrecord.cpp @@ -294,22 +294,17 @@ void QQmlNdefRecord::setType(const QString &newtype) } /*! - Sets the type name format of the NDEF record to \a typeNameFormat. + Sets the type name format of the NDEF record to \a newTypeNameFormat. */ -void QQmlNdefRecord::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat typeNameFormat) +void QQmlNdefRecord::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat newTypeNameFormat) { - Q_D(QQmlNdefRecord); - bool emitChanged = true; - if (static_cast(d->record.typeNameFormat()) == typeNameFormat) { - emitChanged = false; - } + if (newTypeNameFormat == typeNameFormat()) + return; - //We always have to set the tnf, otherwise we run into problems when tnf is empty. Then - //the QNdefRecordPrivate is not created - d->record.setTypeNameFormat(static_cast(typeNameFormat)); + Q_D(QQmlNdefRecord); + d->record.setTypeNameFormat(static_cast(newTypeNameFormat)); - if (emitChanged) - Q_EMIT(typeNameFormatChanged()); + emit typeNameFormatChanged(); } /*! -- cgit v1.2.3 From 87debe438c3655081f2b56bceea1ca7b045e28a5 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Thu, 10 Oct 2013 17:22:00 +0200 Subject: Simplify QBluetoothTransferManager autotest I don't think the service discovery in there does anything valuable. Basically every device has a OPP service running. Like this it is just time consuming and error-prone. It would also be good to have a tool that automatically accepts the transfer on the testserver so that we can actually execute the test automatically. Change-Id: I93b3bab32cecb8a3005cecb95a69a40813663e4d Reviewed-by: Alex Blasche --- .../tst_qbluetoothtransfermanager.cpp | 72 ++-------------------- 1 file changed, 6 insertions(+), 66 deletions(-) diff --git a/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp b/tests/auto/qbluetoothtransfermanager/tst_qbluetoothtransfermanager.cpp index 885b7f1e..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("expectSuccess"); QTest::addColumn("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; @@ -339,13 +282,10 @@ void tst_QBluetoothTransferManager::tst_sendBuffer_data() QTest::addColumn("expectSuccess"); QTest::addColumn("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"); } -- cgit v1.2.3 From f50cf1de802b42bf632ed85b2da5072786a56fcb Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Oct 2013 14:48:42 +0200 Subject: QtBluetooth QML API starts with 5.2. 5.0 remains as silent import though. Change-Id: I06c839a1224dc0d8b019bd99e354245f829ae750 Reviewed-by: Jerome Pasion Reviewed-by: Fabian Bumberger --- examples/bluetooth/scanner/scanner.qml | 2 +- src/bluetooth/doc/snippets/doc_src_qtbluetooth.qml | 2 +- src/bluetooth/doc/src/bluetooth-qml.qdoc | 2 +- src/imports/bluetooth/plugin.cpp | 20 ++++++++++++++++---- .../qdeclarativebluetoothdiscoverymodel.cpp | 3 +-- .../bluetooth/qdeclarativebluetoothservice.cpp | 3 +-- .../bluetooth/qdeclarativebluetoothsocket.cpp | 3 +-- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/examples/bluetooth/scanner/scanner.qml b/examples/bluetooth/scanner/scanner.qml index 7ae0e28e..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 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-qml.qdoc b/src/bluetooth/doc/src/bluetooth-qml.qdoc index 912f2153..f9ff3d30 100644 --- a/src/bluetooth/doc/src/bluetooth-qml.qdoc +++ b/src/bluetooth/doc/src/bluetooth-qml.qdoc @@ -28,7 +28,7 @@ /*! -\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 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(uri, major, minor, "BluetoothDiscoveryModel"); - qmlRegisterType(uri, major, minor, "BluetoothService"); - qmlRegisterType(uri, major, minor, "BluetoothSocket"); + + // Register the 5.0 types + //5.0 is silent and not advertised + qmlRegisterType(uri, major, minor, "BluetoothDiscoveryModel"); + qmlRegisterType(uri, major, minor, "BluetoothService"); + qmlRegisterType(uri, major, minor, "BluetoothSocket"); + + // Register the 5.2 types + minor = 2; + qmlRegisterType(uri, major, minor, "BluetoothDiscoveryModel"); + qmlRegisterType(uri, major, minor, "BluetoothService"); + qmlRegisterType(uri, major, minor, "BluetoothSocket"); + } }; diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp index c2623ba0..8fc93e48 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp @@ -53,11 +53,10 @@ \qmltype BluetoothDiscoveryModel \instantiates QDeclarativeBluetoothDiscoveryModel \inqmlmodule QtBluetooth + \since 5.2 \brief Enables you to search 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. diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp index c4234933..be8f90c0 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp @@ -54,13 +54,12 @@ \qmltype BluetoothService \instantiates QDeclarativeBluetoothService \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. */ diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp index 449e578a..ea9d9e6e 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp @@ -55,14 +55,13 @@ \qmltype BluetoothSocket \instantiates QDeclarativeBluetoothSocket \inqmlmodule QtBluetooth + \since 5.2 \brief Enables you to connect and communicate 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 -- cgit v1.2.3 From 44562a5f8733949582a8b42557b5bc9d6bc85420 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Oct 2013 15:23:15 +0200 Subject: QtNfc QML Api starts with version 5.2 5.0 remains silent version Change-Id: Id1665120f8e694b21b59168db5f1168a7d3ce1d6 Reviewed-by: Jerome Pasion Reviewed-by: Fabian Bumberger --- examples/nfc/poster/poster.qml | 2 +- src/imports/nfc/plugin.cpp | 13 +++++++++++-- src/imports/nfc/qdeclarativendeffilter.cpp | 3 +-- src/imports/nfc/qdeclarativendefmimerecord.cpp | 3 +-- src/imports/nfc/qdeclarativendeftextrecord.cpp | 3 +-- src/imports/nfc/qdeclarativendefurirecord.cpp | 3 ++- src/imports/nfc/qdeclarativenearfield.cpp | 3 +-- src/imports/nfc/qdeclarativenearfieldsocket.cpp | 3 +-- src/nfc/doc/snippets/doc_src_qtnfc.qml | 2 +- src/nfc/doc/src/nfc-qml.qdoc | 2 +- 10 files changed, 21 insertions(+), 16 deletions(-) diff --git a/examples/nfc/poster/poster.qml b/examples/nfc/poster/poster.qml index 7dcd0db5..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 diff --git a/src/imports/nfc/plugin.cpp b/src/imports/nfc/plugin.cpp index 6be71c73..0a423495 100644 --- a/src/imports/nfc/plugin.cpp +++ b/src/imports/nfc/plugin.cpp @@ -55,16 +55,16 @@ 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(uri, major, minor, "NearFieldSocket"); @@ -75,6 +75,15 @@ public: qmlRegisterType(uri, major, minor, "NdefTextRecord"); qmlRegisterType(uri, major, minor, "NdefUriRecord"); qmlRegisterType(uri, major, minor, "NdefMimeRecord"); + + // Register the 5.2 types + minor = 2; + qmlRegisterType(uri, major, minor, "NearField"); + qmlRegisterType(uri, major, minor, "NdefFilter"); + qmlRegisterType(uri, major, minor, "NdefRecord"); + qmlRegisterType(uri, major, minor, "NdefTextRecord"); + qmlRegisterType(uri, major, minor, "NdefUriRecord"); + qmlRegisterType(uri, major, minor, "NdefMimeRecord"); } }; diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp index b1c2f74c..37a19c45 100644 --- a/src/imports/nfc/qdeclarativendeffilter.cpp +++ b/src/imports/nfc/qdeclarativendeffilter.cpp @@ -44,6 +44,7 @@ /*! \qmltype NdefFilter \instantiates QDeclarativeNdefFilter + \since 5.2 \brief The NdefFilter type represents a filtering constraint for NDEF message records. \ingroup nfc-qml @@ -52,8 +53,6 @@ \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. diff --git a/src/imports/nfc/qdeclarativendefmimerecord.cpp b/src/imports/nfc/qdeclarativendefmimerecord.cpp index 9468c01a..086cd8c2 100644 --- a/src/imports/nfc/qdeclarativendefmimerecord.cpp +++ b/src/imports/nfc/qdeclarativendefmimerecord.cpp @@ -43,6 +43,7 @@ /*! \qmltype NdefMimeRecord + \since 5.2 \brief The NdefMimeRecord type represents an NFC MIME record. \ingroup connectivity-nfc @@ -50,8 +51,6 @@ \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. */ diff --git a/src/imports/nfc/qdeclarativendeftextrecord.cpp b/src/imports/nfc/qdeclarativendeftextrecord.cpp index d487c351..a163fc6b 100644 --- a/src/imports/nfc/qdeclarativendeftextrecord.cpp +++ b/src/imports/nfc/qdeclarativendeftextrecord.cpp @@ -45,6 +45,7 @@ /*! \qmltype NdefTextRecord + \since 5.2 \brief The NdefTextRecord type represents an NFC RTD-Text NDEF record. \ingroup nfc-qml @@ -54,8 +55,6 @@ \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 diff --git a/src/imports/nfc/qdeclarativendefurirecord.cpp b/src/imports/nfc/qdeclarativendefurirecord.cpp index 069472e5..85463cd7 100644 --- a/src/imports/nfc/qdeclarativendefurirecord.cpp +++ b/src/imports/nfc/qdeclarativendefurirecord.cpp @@ -45,6 +45,7 @@ /*! \qmltype NdefUriRecord + \since 5.2 \brief The NdefUriRecord type represents an NFC RTD-URI NDEF record. \ingroup nfc-qml @@ -54,7 +55,7 @@ \sa QNdefNfcUriRecord - The NdefUriRecord type was introduced in \b {QtNfc 5.0}. + The NdefUriRecord type can contain a uniform resource identifier. */ /*! diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp index 9c871319..4f026775 100644 --- a/src/imports/nfc/qdeclarativenearfield.cpp +++ b/src/imports/nfc/qdeclarativenearfield.cpp @@ -52,6 +52,7 @@ /*! \qmltype NearField \instantiates QDeclarativeNearField + \since 5.2 \brief The NearField type provides access to NDEF messages stored on NFC Forum tags. \ingroup nfc-qml @@ -64,8 +65,6 @@ \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. diff --git a/src/imports/nfc/qdeclarativenearfieldsocket.cpp b/src/imports/nfc/qdeclarativenearfieldsocket.cpp index b297ccdf..4e2019e9 100644 --- a/src/imports/nfc/qdeclarativenearfieldsocket.cpp +++ b/src/imports/nfc/qdeclarativenearfieldsocket.cpp @@ -46,13 +46,12 @@ /*! \qmltype NearFieldSocket \instantiates QDeclarativeNearFieldSocket + \since 5.2 \brief The NearFieldSocket type represents an LLCP socket. \ingroup nfc-qml \inqmlmodule QtNfc - The NearFieldSocket type was introduced in \b {QtNfc 5.0}. - 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/src/nfc-qml.qdoc b/src/nfc/doc/src/nfc-qml.qdoc index 54902112..a8151bba 100644 --- a/src/nfc/doc/src/nfc-qml.qdoc +++ b/src/nfc/doc/src/nfc-qml.qdoc @@ -28,7 +28,7 @@ /*! -\qmlmodule QtNfc 5.0 +\qmlmodule QtNfc 5.2 \title Qt NFC QML Types \ingroup qmlmodules \brief Provides QML types for accessing NFC Forum Tags -- cgit v1.2.3 From cd9bbb44957fad833960a764d712d42456857aba Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Oct 2013 15:26:08 +0200 Subject: Update Nfc QML meta data for Qt Creator Change-Id: Ibb2651b948bf39e9a56a5351d5c69d5848c7a7bd Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/imports/nfc/plugins.qmltypes | 58 +++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/src/imports/nfc/plugins.qmltypes b/src/imports/nfc/plugins.qmltypes index 3e7cb4e4..346c0bfa 100644 --- a/src/imports/nfc/plugins.qmltypes +++ b/src/imports/nfc/plugins.qmltypes @@ -4,38 +4,31 @@ import QtQuick.tooling 1.1 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -notrelocatable QtNfc 5.0' +// 'qmlplugindump -notrelocatable QtNfc 5.2' Module { Component { name: "QDeclarativeNdefFilter" prototype: "QObject" - exports: ["QtNfc/NdefFilter 5.0"] - exportMetaObjectRevisions: [0] + 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"] - exportMetaObjectRevisions: [0] + exports: ["QtNfc/NdefMimeRecord 5.0", "QtNfc/NdefMimeRecord 5.2"] + exportMetaObjectRevisions: [0, 0] Property { name: "uri"; type: "string"; isReadonly: true } } - Component { - name: "QQmlNdefRecord" - prototype: "QObject" - exports: ["QtNfc/NdefRecord 5.0"] - exportMetaObjectRevisions: [0] - Property { name: "recordType"; type: "string" } - Property { name: "record"; type: "QNdefRecord" } - } Component { name: "QDeclarativeNdefTextRecord" prototype: "QQmlNdefRecord" - exports: ["QtNfc/NdefTextRecord 5.0"] - exportMetaObjectRevisions: [0] + exports: ["QtNfc/NdefTextRecord 5.0", "QtNfc/NdefTextRecord 5.2"] + exportMetaObjectRevisions: [0, 0] Enum { name: "LocaleMatch" values: { @@ -52,22 +45,37 @@ Module { Component { name: "QDeclarativeNdefUriRecord" prototype: "QQmlNdefRecord" - exports: ["QtNfc/NdefUriRecord 5.0"] - exportMetaObjectRevisions: [0] + 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"] - exportMetaObjectRevisions: [0] - Property { - name: "messageRecords" - type: "QQmlNdefRecord" - isList: true - isReadonly: true - } + 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" } + } } -- cgit v1.2.3 From f4474f93b9e0a7df48e94f3fec34a0de64b482bd Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Oct 2013 15:37:12 +0200 Subject: Use recommended way of using \brief statements in QML Types. Change-Id: Id8f57b69dcb80056b53bfee538a2f65c9662bb55 Reviewed-by: Jerome Pasion Reviewed-by: Fabian Bumberger --- src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp | 2 +- src/imports/bluetooth/qdeclarativebluetoothsocket.cpp | 2 +- src/imports/nfc/qdeclarativendeffilter.cpp | 2 +- src/imports/nfc/qdeclarativendefmimerecord.cpp | 2 +- src/imports/nfc/qdeclarativendeftextrecord.cpp | 2 +- src/imports/nfc/qdeclarativendefurirecord.cpp | 2 +- src/imports/nfc/qdeclarativenearfield.cpp | 2 +- src/imports/nfc/qdeclarativenearfieldsocket.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp index 8fc93e48..67b71902 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp @@ -54,7 +54,7 @@ \instantiates QDeclarativeBluetoothDiscoveryModel \inqmlmodule QtBluetooth \since 5.2 - \brief Enables you to search for the Bluetooth devices and services in + \brief Enables searching for the Bluetooth devices and services in range. BluetoothDiscoveryModel provides a model of connectable services. The diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp index ea9d9e6e..d71e5dd6 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp @@ -56,7 +56,7 @@ \instantiates QDeclarativeBluetoothSocket \inqmlmodule QtBluetooth \since 5.2 - \brief Enables you to connect and communicate with a Bluetooth service or + \brief Enables connecting and communicating with a Bluetooth service or device. \sa QBluetoothSocket diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp index 37a19c45..5d1dd43f 100644 --- a/src/imports/nfc/qdeclarativendeffilter.cpp +++ b/src/imports/nfc/qdeclarativendeffilter.cpp @@ -45,7 +45,7 @@ \qmltype NdefFilter \instantiates QDeclarativeNdefFilter \since 5.2 - \brief The NdefFilter type represents a filtering constraint for NDEF message records. + \brief Represents a filtering constraint for NDEF message records. \ingroup nfc-qml \inqmlmodule QtNfc diff --git a/src/imports/nfc/qdeclarativendefmimerecord.cpp b/src/imports/nfc/qdeclarativendefmimerecord.cpp index 086cd8c2..3141c94f 100644 --- a/src/imports/nfc/qdeclarativendefmimerecord.cpp +++ b/src/imports/nfc/qdeclarativendefmimerecord.cpp @@ -44,7 +44,7 @@ /*! \qmltype NdefMimeRecord \since 5.2 - \brief The NdefMimeRecord type represents an NFC MIME record. + \brief Represents an NFC MIME record. \ingroup connectivity-nfc \inqmlmodule QtNfc diff --git a/src/imports/nfc/qdeclarativendeftextrecord.cpp b/src/imports/nfc/qdeclarativendeftextrecord.cpp index a163fc6b..bd63aa2b 100644 --- a/src/imports/nfc/qdeclarativendeftextrecord.cpp +++ b/src/imports/nfc/qdeclarativendeftextrecord.cpp @@ -46,7 +46,7 @@ /*! \qmltype NdefTextRecord \since 5.2 - \brief The NdefTextRecord type represents an NFC RTD-Text NDEF record. + \brief Represents an NFC RTD-Text NDEF record. \ingroup nfc-qml \inqmlmodule QtNfc diff --git a/src/imports/nfc/qdeclarativendefurirecord.cpp b/src/imports/nfc/qdeclarativendefurirecord.cpp index 85463cd7..a1f4824f 100644 --- a/src/imports/nfc/qdeclarativendefurirecord.cpp +++ b/src/imports/nfc/qdeclarativendefurirecord.cpp @@ -46,7 +46,7 @@ /*! \qmltype NdefUriRecord \since 5.2 - \brief The NdefUriRecord type represents an NFC RTD-URI NDEF record. + \brief Represents an NFC RTD-URI NDEF record. \ingroup nfc-qml \inqmlmodule QtNfc diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp index 4f026775..673c9a0d 100644 --- a/src/imports/nfc/qdeclarativenearfield.cpp +++ b/src/imports/nfc/qdeclarativenearfield.cpp @@ -53,7 +53,7 @@ \qmltype NearField \instantiates QDeclarativeNearField \since 5.2 - \brief The NearField type provides access to NDEF messages stored on NFC Forum tags. + \brief Provides access to NDEF messages stored on NFC Forum tags. \ingroup nfc-qml \inqmlmodule QtNfc diff --git a/src/imports/nfc/qdeclarativenearfieldsocket.cpp b/src/imports/nfc/qdeclarativenearfieldsocket.cpp index 4e2019e9..062970b7 100644 --- a/src/imports/nfc/qdeclarativenearfieldsocket.cpp +++ b/src/imports/nfc/qdeclarativenearfieldsocket.cpp @@ -47,7 +47,7 @@ \qmltype NearFieldSocket \instantiates QDeclarativeNearFieldSocket \since 5.2 - \brief The NearFieldSocket type represents an LLCP socket. + \brief Represents an LLCP socket. \ingroup nfc-qml \inqmlmodule QtNfc -- cgit v1.2.3 From f674d4a5ade8b24dcb36c3c219c0fd5a842c1bfe Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 1 Oct 2013 13:51:33 +0200 Subject: Doc: language and style review doc qtconnectivity Reviewed doc Bluetooth and NFC Task-number: QTBUG-32173 Change-Id: I80f81c2123c3ee4fc269f471123f332dc39ee958 Reviewed-by: Jerome Pasion --- examples/bluetooth/btchat/doc/src/btchat.qdoc | 82 +++++++++++----------- .../nfc/annotatedurl/doc/src/annotatedurl.qdoc | 4 +- examples/nfc/poster/doc/src/poster.qdoc | 4 +- src/bluetooth/doc/src/bluetooth-cpp.qdoc | 4 +- src/bluetooth/doc/src/bluetooth-overview.qdoc | 8 +-- src/bluetooth/doc/src/bluetooth-qml.qdoc | 6 +- src/bluetooth/doc/src/examples.qdoc | 13 ++-- src/nfc/doc/src/examples.qdoc | 6 +- src/nfc/doc/src/nfc-cpp.qdoc | 2 +- src/nfc/doc/src/nfc-index.qdoc | 4 +- src/nfc/doc/src/nfc-overview.qdoc | 6 +- src/nfc/doc/src/nfc-qml.qdoc | 4 +- 12 files changed, 73 insertions(+), 70 deletions(-) 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/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/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 f9ff3d30..9c9fe0aa 100644 --- a/src/bluetooth/doc/src/bluetooth-qml.qdoc +++ b/src/bluetooth/doc/src/bluetooth-qml.qdoc @@ -31,10 +31,10 @@ \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..8884b3c8 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 QtBluetooth 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/nfc/doc/src/examples.qdoc b/src/nfc/doc/src/examples.qdoc index f49c0d8f..1f473991 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 QtNfc 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..25e193a6 100644 --- a/src/nfc/doc/src/nfc-overview.qdoc +++ b/src/nfc/doc/src/nfc-overview.qdoc @@ -29,14 +29,14 @@ \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 @@ -44,6 +44,6 @@ With the Qt NFC API typical use cases are: The following sections describe how to use QtNfc 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 a8151bba..42e57159 100644 --- a/src/nfc/doc/src/nfc-qml.qdoc +++ b/src/nfc/doc/src/nfc-qml.qdoc @@ -31,9 +31,9 @@ \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 -- cgit v1.2.3 From 90e953fca860f04e82c6451a8dbe5649e882677e Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 11 Oct 2013 14:51:28 +0200 Subject: Update Bluetooth QML meta data for Qt Creator Change-Id: I50ae4f34e1d737c59ff0e15e940e0e6484412271 Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/imports/bluetooth/plugins.qmltypes | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes index 89db5407..15182df5 100644 --- a/src/imports/bluetooth/plugins.qmltypes +++ b/src/imports/bluetooth/plugins.qmltypes @@ -4,14 +4,17 @@ import QtQuick.tooling 1.1 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -notrelocatable QtBluetooth 5.0' +// 'qmlplugindump -notrelocatable QtBluetooth 5.2' Module { Component { name: "QDeclarativeBluetoothDiscoveryModel" prototype: "QAbstractListModel" - exports: ["QtBluetooth/BluetoothDiscoveryModel 5.0"] - exportMetaObjectRevisions: [0] + exports: [ + "QtBluetooth/BluetoothDiscoveryModel 5.0", + "QtBluetooth/BluetoothDiscoveryModel 5.2" + ] + exportMetaObjectRevisions: [0, 0] Enum { name: "DiscoveryMode" values: { @@ -46,8 +49,11 @@ Module { 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: { @@ -74,8 +80,11 @@ 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: { -- cgit v1.2.3 From d5aa60fd33be47dd9ae1ad49c71d3edf059229bd Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 15 Oct 2013 13:19:17 +0200 Subject: Remove not needed error enum and avoid future enum value collisions Change-Id: Ieb40958b689914db3b9b5303757426d7348d3fbe Reviewed-by: Fabian Bumberger Reviewed-by: Alex Blasche --- src/imports/bluetooth/plugins.qmltypes | 5 ++--- src/imports/bluetooth/qdeclarativebluetoothsocket.cpp | 2 +- src/imports/bluetooth/qdeclarativebluetoothsocket_p.h | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes index 15182df5..20d57574 100644 --- a/src/imports/bluetooth/plugins.qmltypes +++ b/src/imports/bluetooth/plugins.qmltypes @@ -93,8 +93,7 @@ Module { "HostNotFoundError": 2, "ServiceNotFoundError": 9, "NetworkError": 7, - "UnsupportedProtocolError": 8, - "NoSocketerror": 9 + "UnsupportedProtocolError": 8 } } Enum { @@ -107,7 +106,7 @@ Module { "Bound": 4, "Closing": 6, "Listening": 5, - "NoServiceSet": 6 + "NoServiceSet": 100 } } Property { name: "service"; type: "QDeclarativeBluetoothService"; isPointer: true } diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp index d71e5dd6..a1329182 100644 --- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp +++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp @@ -359,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())); diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h b/src/imports/bluetooth/qdeclarativebluetoothsocket_p.h index cb6255b6..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); -- cgit v1.2.3 From 782a09be7c89352b27083bca7ee5b032d9e56ca6 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Mon, 14 Oct 2013 20:01:14 +0800 Subject: Doc: Fix module name format Follow the conventions at http://qt-project.org/wiki/Spelling_Module_Names_in_Qt_Documentation Task-number: QTBUG-33360 Change-Id: I51f23e4b3ac0dffe8fef674f2cb431776d5829ab Reviewed-by: Alex Blasche Reviewed-by: Jerome Pasion --- src/bluetooth/doc/src/examples.qdoc | 2 +- src/nfc/doc/src/examples.qdoc | 2 +- src/nfc/doc/src/nfc-overview.qdoc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bluetooth/doc/src/examples.qdoc b/src/bluetooth/doc/src/examples.qdoc index 8884b3c8..441b303d 100644 --- a/src/bluetooth/doc/src/examples.qdoc +++ b/src/bluetooth/doc/src/examples.qdoc @@ -29,7 +29,7 @@ \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 they are also diff --git a/src/nfc/doc/src/examples.qdoc b/src/nfc/doc/src/examples.qdoc index 1f473991..64cc0982 100644 --- a/src/nfc/doc/src/examples.qdoc +++ b/src/nfc/doc/src/examples.qdoc @@ -29,7 +29,7 @@ \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 Qt NFC API. You will find them in their own documentation, but they are also accessible from here. diff --git a/src/nfc/doc/src/nfc-overview.qdoc b/src/nfc/doc/src/nfc-overview.qdoc index 25e193a6..b7d029bb 100644 --- a/src/nfc/doc/src/nfc-overview.qdoc +++ b/src/nfc/doc/src/nfc-overview.qdoc @@ -41,7 +41,7 @@ With the Qt NFC API typical use cases are: \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 an NDEF message on NFC Forum Tags. -- cgit v1.2.3