summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--examples/nfc/poster/poster.qrc1
-rw-r--r--src/bluetooth/android/android.pri2
-rw-r--r--src/bluetooth/bluetooth.pro32
-rw-r--r--src/bluetooth/osx/osxbt.pri8
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp13
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp6
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.h6
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo_p.h2
-rw-r--r--src/bluetooth/qlowenergycontroller.cpp2
-rw-r--r--src/bluetooth/qlowenergycontroller_android.cpp4
-rw-r--r--src/bluetooth/qlowenergycontroller_dummy.cpp (renamed from src/bluetooth/qlowenergycontroller_p.cpp)2
-rw-r--r--src/bluetooth/qlowenergycontroller_dummy_p.h (renamed from src/bluetooth/qlowenergycontroller_p.h)0
-rw-r--r--src/bluetooth/qlowenergycontroller_win.cpp18
-rw-r--r--src/imports/bluetooth/plugins.qmltypes2
-rw-r--r--src/imports/nfc/nfc.pro2
-rw-r--r--src/imports/nfc/plugins.qmltypes2
-rw-r--r--src/imports/nfc/qdeclarativenearfieldsocket.cpp380
-rw-r--r--src/imports/nfc/qdeclarativenearfieldsocket_p.h123
-rw-r--r--src/nfc/nfc.pro14
-rw-r--r--src/nfc/qnearfieldtarget.cpp2
21 files changed, 55 insertions, 568 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 35dba548..b3c7403c 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -2,4 +2,4 @@ load(qt_build_config)
DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST
-MODULE_VERSION = 5.14.2
+MODULE_VERSION = 5.15.0
diff --git a/examples/nfc/poster/poster.qrc b/examples/nfc/poster/poster.qrc
index d8286e71..7bb30667 100644
--- a/examples/nfc/poster/poster.qrc
+++ b/examples/nfc/poster/poster.qrc
@@ -2,5 +2,4 @@
<qresource prefix="/">
<file>poster.qml</file>
</qresource>
- <qresource prefix="/icons"/>
</RCC>
diff --git a/src/bluetooth/android/android.pri b/src/bluetooth/android/android.pri
index c50a919a..af39a6d7 100644
--- a/src/bluetooth/android/android.pri
+++ b/src/bluetooth/android/android.pri
@@ -1,4 +1,4 @@
-PRIVATE_HEADERS += \
+HEADERS += \
android/inputstreamthread_p.h \
android/devicediscoverybroadcastreceiver_p.h \
android/servicediscoverybroadcastreceiver_p.h \
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index 4d181dfb..9f42b34e 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -5,7 +5,7 @@ DEFINES += QT_NO_FOREACH
QMAKE_DOCS = $$PWD/doc/qtbluetooth.qdocconf
OTHER_FILES += doc/src/*.qdoc # show .qdoc files in Qt Creator
-PUBLIC_HEADERS += \
+HEADERS += \
qtbluetoothglobal.h \
qbluetoothaddress.h\
qbluetoothhostinfo.h \
@@ -30,9 +30,7 @@ PUBLIC_HEADERS += \
qlowenergyadvertisingdata.h \
qlowenergyadvertisingparameters.h \
qlowenergyconnectionparameters.h \
- qlowenergycontroller.h
-
-PRIVATE_HEADERS += \
+ qlowenergycontroller.h \
qtbluetoothglobal_p.h \
qbluetoothaddress_p.h\
qbluetoothhostinfo_p.h \
@@ -94,7 +92,7 @@ qtConfig(bluez) {
include(bluez/bluez.pri)
- PRIVATE_HEADERS += \
+ HEADERS += \
qbluetoothtransferreply_bluez_p.h \
qbluetoothsocket_bluez_p.h \
qbluetoothsocket_bluezdbus_p.h
@@ -118,7 +116,7 @@ qtConfig(bluez) {
lecmaccalculator.cpp \
qlowenergycontroller_bluezdbus.cpp
- PRIVATE_HEADERS += qlowenergycontroller_bluezdbus_p.h \
+ HEADERS += qlowenergycontroller_bluezdbus_p.h \
qlowenergycontroller_bluez_p.h
qtConfig(linux_crypto_api): DEFINES += CONFIG_LINUX_CRYPTO_API
@@ -126,9 +124,9 @@ qtConfig(bluez) {
DEFINES += QT_BLUEZ_NO_BTLE
include(dummy/dummy.pri)
SOURCES += \
- qlowenergycontroller_p.cpp
+ qlowenergycontroller_dummy.cpp
- PRIVATE_HEADERS += qlowenergycontroller_p.h
+ HEADERS += qlowenergycontroller_dummy_p.h
}
} else:android:!android-embedded {
@@ -153,7 +151,7 @@ qtConfig(bluez) {
qbluetoothserver_android.cpp \
qlowenergycontroller_android.cpp
- PRIVATE_HEADERS += qlowenergycontroller_android_p.h \
+ HEADERS += qlowenergycontroller_android_p.h \
qbluetoothsocket_android_p.h
} else:osx {
QT_PRIVATE = concurrent
@@ -171,7 +169,7 @@ qtConfig(bluez) {
qbluetoothtransferreply_osx.mm \
qlowenergycontroller_darwin.mm
- PRIVATE_HEADERS += qbluetoothsocket_osx_p.h \
+ HEADERS += qbluetoothsocket_osx_p.h \
qbluetoothtransferreply_osx_p.h \
qlowenergycontroller_darwin_p.h
} else:ios|tvos {
@@ -182,7 +180,7 @@ qtConfig(bluez) {
qbluetoothdevicediscoveryagent_darwin.mm \
qlowenergycontroller_darwin.mm
- PRIVATE_HEADERS += \
+ HEADERS += \
qlowenergycontroller_darwin_p.h \
qbluetoothsocket_dummy_p.h
@@ -213,13 +211,13 @@ qtConfig(bluez) {
qbluetoothutils_winrt.cpp \
qlowenergycontroller_winrt.cpp
- PRIVATE_HEADERS += qlowenergycontroller_winrt_p.h \
+ HEADERS += qlowenergycontroller_winrt_p.h \
qbluetoothsocket_winrt_p.h \
qbluetoothutils_winrt_p.h
qtConfig(winrt_btle_no_pairing) {
SOURCES += qlowenergycontroller_winrt_new.cpp
- PRIVATE_HEADERS += qlowenergycontroller_winrt_new_p.h
+ HEADERS += qlowenergycontroller_winrt_new_p.h
}
lessThan(WINDOWS_SDK_VERSION, 14393) {
@@ -242,7 +240,7 @@ qtConfig(bluez) {
qbluetoothserver_win.cpp \
qlowenergycontroller_win.cpp
- PRIVATE_HEADERS += qlowenergycontroller_win_p.h \
+ HEADERS += qlowenergycontroller_win_p.h \
qbluetoothsocket_win_p.h
} else {
message("Unsupported Bluetooth platform, will not build a working QtBluetooth library.")
@@ -255,9 +253,9 @@ qtConfig(bluez) {
qbluetoothservicediscoveryagent_p.cpp \
qbluetoothsocket_dummy.cpp \
qbluetoothserver_p.cpp \
- qlowenergycontroller_p.cpp
+ qlowenergycontroller_dummy.cpp
- PRIVATE_HEADERS += qlowenergycontroller_p.h \
+ HEADERS += qlowenergycontroller_dummy_p.h \
qbluetoothsocket_dummy_p.h
}
@@ -269,6 +267,4 @@ winrt {
OTHER_FILES +=
-HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
-
load(qt_module)
diff --git a/src/bluetooth/osx/osxbt.pri b/src/bluetooth/osx/osxbt.pri
index 8f6ea0d1..edc1c751 100644
--- a/src/bluetooth/osx/osxbt.pri
+++ b/src/bluetooth/osx/osxbt.pri
@@ -2,7 +2,7 @@ SOURCES += osx/uistrings.cpp \
osx/osxbtnotifier.cpp \
osx/btdelegates.cpp
-PRIVATE_HEADERS += osx/uistrings_p.h \
+HEADERS += osx/uistrings_p.h \
osx/osxbtgcdtimer_p.h \
osx/btraii_p.h \
osx/btdelegates_p.h
@@ -13,7 +13,7 @@ OBJECTIVE_SOURCES += osx/osxbtgcdtimer.mm \
#QMAKE_CXXFLAGS_WARN_ON += -Wno-nullability-completeness
CONFIG(osx) {
- PRIVATE_HEADERS += osx/osxbtutility_p.h \
+ HEADERS += osx/osxbtutility_p.h \
osx/osxbtdevicepair_p.h \
osx/osxbtdeviceinquiry_p.h \
osx/osxbtconnectionmonitor_p.h \
@@ -43,13 +43,13 @@ CONFIG(osx) {
osx/osxbtcentralmanager.mm \
osx/osxbtperipheralmanager.mm
} else {
- PRIVATE_HEADERS += osx/osxbtutility_p.h \
+ HEADERS += osx/osxbtutility_p.h \
osx/osxbtledeviceinquiry_p.h \
osx/osxbluetooth_p.h \
osx/osxbtcentralmanager_p.h \
osx/osxbtnotifier_p.h
ios {
- PRIVATE_HEADERS += osx/osxbtperipheralmanager_p.h
+ HEADERS += osx/osxbtperipheralmanager_p.h
}
OBJECTIVE_SOURCES += osx/osxbtutility.mm \
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
index 159428d4..eec76173 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
@@ -51,6 +51,8 @@
#include <setupapi.h>
#include <bluetoothapis.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
@@ -541,11 +543,12 @@ void QBluetoothDeviceDiscoveryAgentPrivate::processDiscoveredDevice(
} else {
qCDebug(QT_BT_WINDOWS) << "Updating device:" << deviceIt->name() << deviceIt->address();
// merge service uuids
- QList<QBluetoothUuid> uuids = deviceIt->serviceUuids();
- uuids.append(foundDevice.serviceUuids());
- const QSet<QBluetoothUuid> uuidSet = uuids.toSet();
- if (deviceIt->serviceUuids().count() != uuidSet.count())
- deviceIt->setServiceUuids(uuidSet.toList().toVector());
+ auto uuids = deviceIt->serviceUuids().toVector();
+ uuids.append(foundDevice.serviceUuids().toVector());
+ std::sort(uuids.begin(), uuids.end());
+ uuids.erase(std::unique(uuids.begin(), uuids.end()), uuids.end());
+ if (deviceIt->serviceUuids().count() != uuids.count())
+ deviceIt->setServiceUuids(uuids);
if (deviceIt->coreConfigurations() != foundDevice.coreConfigurations())
deviceIt->setCoreConfigurations(
QBluetoothDeviceInfo::BaseRateAndLowEnergyCoreConfiguration);
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index a5bc7b81..fae7faa4 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -695,14 +695,14 @@ QByteArray QBluetoothDeviceInfo::manufacturerData(quint16 manufacturerId) const
bool QBluetoothDeviceInfo::setManufacturerData(quint16 manufacturerId, const QByteArray &data)
{
Q_D(QBluetoothDeviceInfo);
- QHash<quint16, QByteArray>::const_iterator it = d->manufacturerData.find(manufacturerId);
- while (it != d->manufacturerData.end() && it.key() == manufacturerId) {
+ auto it = d->manufacturerData.constFind(manufacturerId);
+ while (it != d->manufacturerData.cend() && it.key() == manufacturerId) {
if (*it == data)
return false;
it++;
}
- d->manufacturerData.insertMulti(manufacturerId, data);
+ d->manufacturerData.insert(manufacturerId, data);
return true;
}
diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h
index c4fa01ec..f9da3b4d 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.h
+++ b/src/bluetooth/qbluetoothdeviceinfo.h
@@ -262,10 +262,8 @@ public:
#endif
void setServiceUuids(const QVector<QBluetoothUuid> &uuids);
- // TODO Qt6 manufacturerData()
- // manufacturerData() and manufacturerData(quint16) return types should be modified to
- // cope with multiple data entires per manufacturer ID. QHash<quint16, QByteArray>
- // may stay though if it retains insertMulti() in Qt 6.
+ // TODO Qt6 manufacturerData() need to be changed to return
+ // QMultiHash<quint16, QByteArray>
QVector<quint16> manufacturerIds() const;
QByteArray manufacturerData(quint16 manufacturerId) const;
bool setManufacturerData(quint16 manufacturerId, const QByteArray &data);
diff --git a/src/bluetooth/qbluetoothdeviceinfo_p.h b/src/bluetooth/qbluetoothdeviceinfo_p.h
index 80fd1472..61295c10 100644
--- a/src/bluetooth/qbluetoothdeviceinfo_p.h
+++ b/src/bluetooth/qbluetoothdeviceinfo_p.h
@@ -81,7 +81,7 @@ public:
QBluetoothDeviceInfo::DataCompleteness serviceUuidsCompleteness;
#endif
QVector<QBluetoothUuid> serviceUuids;
- QHash<quint16, QByteArray> manufacturerData;
+ QMultiHash<quint16, QByteArray> manufacturerData;
QBluetoothDeviceInfo::CoreConfigurations deviceCoreConfiguration;
QBluetoothUuid deviceUuid;
diff --git a/src/bluetooth/qlowenergycontroller.cpp b/src/bluetooth/qlowenergycontroller.cpp
index ec140a85..06fa0369 100644
--- a/src/bluetooth/qlowenergycontroller.cpp
+++ b/src/bluetooth/qlowenergycontroller.cpp
@@ -65,7 +65,7 @@
#elif defined(Q_OS_DARWIN)
#include "qlowenergycontroller_darwin_p.h"
#else
-#include "qlowenergycontroller_p.h"
+#include "qlowenergycontroller_dummy_p.h"
#endif
#include <algorithm>
diff --git a/src/bluetooth/qlowenergycontroller_android.cpp b/src/bluetooth/qlowenergycontroller_android.cpp
index f7966023..e0a59ddd 100644
--- a/src/bluetooth/qlowenergycontroller_android.cpp
+++ b/src/bluetooth/qlowenergycontroller_android.cpp
@@ -502,7 +502,7 @@ void QLowEnergyControllerPrivateAndroid::servicesDiscovered(
if (errorCode == QLowEnergyController::NoError) {
//Android delivers all services in one go
- const QStringList list = foundServices.split(QStringLiteral(" "), QString::SkipEmptyParts);
+ const QStringList list = foundServices.split(QStringLiteral(" "), Qt::SkipEmptyParts);
for (const QString &entry : list) {
const QBluetoothUuid service(entry);
if (service.isNull())
@@ -551,7 +551,7 @@ void QLowEnergyControllerPrivateAndroid::serviceDetailsDiscoveryFinished(
if (javaIncludes.isValid()) {
const QStringList list = javaIncludes.toString()
.split(QStringLiteral(" "),
- QString::SkipEmptyParts);
+ Qt::SkipEmptyParts);
for (const QString &entry : list) {
const QBluetoothUuid service(entry);
if (service.isNull())
diff --git a/src/bluetooth/qlowenergycontroller_p.cpp b/src/bluetooth/qlowenergycontroller_dummy.cpp
index c3605f05..2542b355 100644
--- a/src/bluetooth/qlowenergycontroller_p.cpp
+++ b/src/bluetooth/qlowenergycontroller_dummy.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qlowenergycontroller_p.h"
+#include "qlowenergycontroller_dummy_p.h"
#include "dummy/dummy_helper_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/bluetooth/qlowenergycontroller_p.h b/src/bluetooth/qlowenergycontroller_dummy_p.h
index 54a49b53..54a49b53 100644
--- a/src/bluetooth/qlowenergycontroller_p.h
+++ b/src/bluetooth/qlowenergycontroller_dummy_p.h
diff --git a/src/bluetooth/qlowenergycontroller_win.cpp b/src/bluetooth/qlowenergycontroller_win.cpp
index 7a30be9a..5631b8cd 100644
--- a/src/bluetooth/qlowenergycontroller_win.cpp
+++ b/src/bluetooth/qlowenergycontroller_win.cpp
@@ -62,13 +62,13 @@ Q_GLOBAL_STATIC(QLibrary, bluetoothapis)
Q_GLOBAL_STATIC(QVector<QLowEnergyControllerPrivateWin32 *>, qControllers)
static QMutex controllersGuard(QMutex::NonRecursive);
-const QEvent::Type CharactericticValueEventType = static_cast<QEvent::Type>(QEvent::User + 1);
+const QEvent::Type CharacteristicValueEventType = static_cast<QEvent::Type>(QEvent::User + 1);
-class CharactericticValueEvent : public QEvent
+class CharacteristicValueEvent : public QEvent
{
public:
- explicit CharactericticValueEvent(const PBLUETOOTH_GATT_VALUE_CHANGED_EVENT gattValueChangedEvent)
- : QEvent(CharactericticValueEventType)
+ explicit CharacteristicValueEvent(const BLUETOOTH_GATT_VALUE_CHANGED_EVENT *gattValueChangedEvent)
+ : QEvent(CharacteristicValueEventType)
, m_handle(0)
{
if (!gattValueChangedEvent || gattValueChangedEvent->CharacteristicValueDataSize == 0)
@@ -517,8 +517,8 @@ static void WINAPI eventChangedCallbackEntry(
if (!qControllers->contains(target))
return;
- CharactericticValueEvent *e = new CharactericticValueEvent(
- reinterpret_cast<const PBLUETOOTH_GATT_VALUE_CHANGED_EVENT>(eventOutParameter));
+ CharacteristicValueEvent *e = new CharacteristicValueEvent(
+ reinterpret_cast<const BLUETOOTH_GATT_VALUE_CHANGED_EVENT *>(eventOutParameter));
QCoreApplication::postEvent(target, e);
}
@@ -668,11 +668,11 @@ static BTH_LE_GATT_DESCRIPTOR recoverNativeLeGattDescriptor(
void QLowEnergyControllerPrivateWin32::customEvent(QEvent *e)
{
- if (e->type() != CharactericticValueEventType)
+ if (e->type() != CharacteristicValueEventType)
return;
- const CharactericticValueEvent *characteristicEvent
- = static_cast<CharactericticValueEvent *>(e);
+ const CharacteristicValueEvent *characteristicEvent
+ = static_cast<CharacteristicValueEvent *>(e);
updateValueOfCharacteristic(characteristicEvent->m_handle,
characteristicEvent->m_value, false);
diff --git a/src/imports/bluetooth/plugins.qmltypes b/src/imports/bluetooth/plugins.qmltypes
index 2060b594..2aac2df5 100644
--- a/src/imports/bluetooth/plugins.qmltypes
+++ b/src/imports/bluetooth/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtBluetooth 5.14'
+// 'qmlplugindump -nonrelocatable QtBluetooth 5.15'
Module {
dependencies: ["QtQuick 2.0"]
diff --git a/src/imports/nfc/nfc.pro b/src/imports/nfc/nfc.pro
index d651e837..e7ce081b 100644
--- a/src/imports/nfc/nfc.pro
+++ b/src/imports/nfc/nfc.pro
@@ -4,7 +4,6 @@ QT = core qml nfc
# Input
HEADERS += \
- #qdeclarativenearfieldsocket_p.h \
qdeclarativenearfield_p.h \
qdeclarativendeffilter_p.h \
qdeclarativendeftextrecord_p.h \
@@ -12,7 +11,6 @@ HEADERS += \
qdeclarativendefmimerecord_p.h
SOURCES += plugin.cpp \
- #qdeclarativenearfieldsocket.cpp \
qdeclarativenearfield.cpp \
qdeclarativendeffilter.cpp \
qdeclarativendeftextrecord.cpp \
diff --git a/src/imports/nfc/plugins.qmltypes b/src/imports/nfc/plugins.qmltypes
index 2151ad7d..40cbe2cc 100644
--- a/src/imports/nfc/plugins.qmltypes
+++ b/src/imports/nfc/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtNfc 5.14'
+// 'qmlplugindump -nonrelocatable QtNfc 5.15'
Module {
dependencies: ["QtQuick 2.0"]
diff --git a/src/imports/nfc/qdeclarativenearfieldsocket.cpp b/src/imports/nfc/qdeclarativenearfieldsocket.cpp
deleted file mode 100644
index 0bf9abcd..00000000
--- a/src/imports/nfc/qdeclarativenearfieldsocket.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativenearfieldsocket_p.h"
-
-#include <qllcpserver.h>
-
-/*!
- \qmltype NearFieldSocket
- \instantiates QDeclarativeNearFieldSocket
- \since 5.2
- \brief Represents an LLCP socket.
-
- \ingroup nfc-qml
- \inqmlmodule QtNfc
-
- The NearFieldSocket type can be used to create a peer-to-peer connection over NFC LLCP
- sockets. NearfieldSocket can be used for both client and server side sockets.
-
- \internal
-*/
-
-/*!
- \qmlproperty string NearFieldSocket::uri
-
- This property hold the URI of the socket. The URI uniquely identifies a remote service (for
- client sockets) or to register a service (for server sockets).
-*/
-
-/*!
- \qmlproperty bool NearFieldSocket::connected
-
- This property holds the connected state of the socket.
-*/
-
-/*!
- \qmlproperty string NearFieldSocket::error
-
- This property holds the last error that occurred.
-*/
-
-/*!
- \qmlproperty string NearFieldSocket::state
-
- This property holds the state of the socket.
-*/
-
-/*!
- \qmlproperty bool NearFieldSocket::listening
-
- This property holds whether the socket is listening for incoming connections.
-*/
-
-/*!
- \qmlproperty string NearFieldSocket::stringData
-
- This property returns the available string data read from the socket. Seting this property
- sends the data to the remote socket.
-*/
-
-class QDeclarativeNearFieldSocketPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeNearFieldSocket)
-
-public:
- QDeclarativeNearFieldSocketPrivate(QDeclarativeNearFieldSocket *q)
- : q_ptr(q), m_socket(0), m_server(0),
- m_error(QLatin1String("No Error")),
- m_state(QLatin1String("No Service Set")),
- m_componentCompleted(false),
- m_connected(false), m_listen(false)
- {
- }
-
- ~QDeclarativeNearFieldSocketPrivate()
- {
- delete m_socket;
- }
-
- void connect()
- {
- Q_ASSERT(!uri.isEmpty());
-
- m_error = QLatin1String("No Error");
-
- if (m_socket)
- m_socket->deleteLater();
-
- m_socket = new QLlcpSocket;
-
- Q_Q(const QDeclarativeNearFieldSocket);
-
- QObject::connect(m_socket, SIGNAL(connected()), q, SLOT(socket_connected()));
- QObject::connect(m_socket, SIGNAL(disconnected()), q, SLOT(socket_disconnected()));
- QObject::connect(m_socket, SIGNAL(error(QLlcpSocket::SocketError)),
- q, SLOT(socket_error(QLlcpSocket::SocketError)));
- QObject::connect(m_socket, SIGNAL(stateChanged(QLlcpSocket::SocketState)),
- q, SLOT(socket_state(QLlcpSocket::SocketState)));
- QObject::connect(m_socket, SIGNAL(readyRead()), q, SLOT(socket_readyRead()));
-
- m_socket->connectToService(0, uri);
- }
-
- QDeclarativeNearFieldSocket *q_ptr;
- QString uri;
- QLlcpSocket *m_socket;
- QLlcpServer *m_server;
- QString m_error;
- QString m_state;
- bool m_componentCompleted;
- bool m_connected;
- bool m_listen;
-};
-
-QDeclarativeNearFieldSocket::QDeclarativeNearFieldSocket(QObject *parent)
-: QObject(parent), d_ptr(new QDeclarativeNearFieldSocketPrivate(this))
-{
-}
-
-QDeclarativeNearFieldSocket::~QDeclarativeNearFieldSocket()
-{
- delete d_ptr;
-}
-
-void QDeclarativeNearFieldSocket::componentComplete()
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- d->m_componentCompleted = true;
-
- if (d->m_connected && !d->uri.isEmpty())
- d->connect();
- else if (d->m_listen)
- setListening(true);
-}
-
-QString QDeclarativeNearFieldSocket::uri() const
-{
- Q_D(const QDeclarativeNearFieldSocket);
-
- return d->uri;
-}
-
-void QDeclarativeNearFieldSocket::setUri(const QString &uri)
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- d->uri = uri;
-
- if (!d->m_componentCompleted)
- return;
-
- if (d->m_connected)
- d->connect();
-
- emit uriChanged();
-}
-
-bool QDeclarativeNearFieldSocket::connected() const
-{
- Q_D(const QDeclarativeNearFieldSocket);
-
- if (!d->m_socket)
- return false;
-
- return d->m_socket->state() == QLlcpSocket::ConnectedState;
-}
-
-void QDeclarativeNearFieldSocket::setConnected(bool connected)
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- d->m_connected = connected;
- if (connected && d->m_componentCompleted) {
- if (!d->uri.isEmpty())
- d->connect();
- else
- qWarning() << "NearFieldSocket::setConnected called before a uri was set";
- }
-
- if (!connected && d->m_socket)
- d->m_socket->close();
-}
-
-QString QDeclarativeNearFieldSocket::error() const
-{
- Q_D(const QDeclarativeNearFieldSocket);
-
- return d->m_error;
-}
-
-void QDeclarativeNearFieldSocket::socket_connected()
-{
- emit connectedChanged();
-}
-
-void QDeclarativeNearFieldSocket::socket_disconnected()
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- d->m_socket->deleteLater();
- d->m_socket = 0;
- emit connectedChanged();
-}
-
-void QDeclarativeNearFieldSocket::socket_error(QLlcpSocket::SocketError err)
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- if (err == QLlcpSocket::RemoteHostClosedError)
- d->m_error = QLatin1String("Connection Closed by Remote Host");
- else
- d->m_error = QLatin1String("Unknown Error");
-
- emit errorChanged();
-}
-
-void QDeclarativeNearFieldSocket::socket_state(QLlcpSocket::SocketState state)
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- switch (state) {
- case QLlcpSocket::UnconnectedState:
- d->m_state = QLatin1String("Unconnected");
- break;
- case QLlcpSocket::ConnectingState:
- d->m_state = QLatin1String("Connecting");
- break;
- case QLlcpSocket::ConnectedState:
- d->m_state = QLatin1String("Connected");
- break;
- case QLlcpSocket::ClosingState:
- d->m_state = QLatin1String("Closing");
- break;
- case QLlcpSocket::ListeningState:
- d->m_state = QLatin1String("Listening");
- break;
- case QLlcpSocket::BoundState:
- d->m_state = QLatin1String("Bound");
- break;
- }
-
- emit stateChanged();
-}
-
-QString QDeclarativeNearFieldSocket::state() const
-{
- Q_D(const QDeclarativeNearFieldSocket);
-
- return d->m_state;
-}
-
-bool QDeclarativeNearFieldSocket::listening() const
-{
- Q_D(const QDeclarativeNearFieldSocket);
-
- if (d->m_server)
- return true;
-
- return false;
-}
-
-void QDeclarativeNearFieldSocket::setListening(bool listen)
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- if (listen == false && d->m_server) {
- qWarning() << "Once socket is in listening state, can not be returned to client socket";
- return;
- }
-
- if (!d->m_componentCompleted){
- d->m_listen = listen;
- return;
- }
-
- if (d->uri.isEmpty()) {
- qWarning() << "Can not put socket into listening state without an assigned uri";
- return;
- }
-
- d->m_server = new QLlcpServer;
-
- connect(d->m_server, SIGNAL(newConnection()), this, SLOT(llcp_connection()));
-
- d->m_server->listen(d->uri);
-
-
-
- emit listeningChanged();
-}
-
-void QDeclarativeNearFieldSocket::socket_readyRead()
-{
- emit dataAvailable();
-}
-
-QString QDeclarativeNearFieldSocket::stringData()
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- if (!d->m_socket|| !d->m_socket->bytesAvailable())
- return QString();
-
- const QByteArray data = d->m_socket->readAll();
- return QString::fromUtf8(data.constData(), data.size());
-}
-
-void QDeclarativeNearFieldSocket::sendStringData(const QString &data)
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- if (!d->m_connected || !d->m_socket) {
- qWarning() << "Writing data to unconnected socket";
- return;
- }
-
- d->m_socket->write(data.toUtf8());
-}
-
-void QDeclarativeNearFieldSocket::llcp_connection()
-{
- Q_D(QDeclarativeNearFieldSocket);
-
- QLlcpSocket *socket = d->m_server->nextPendingConnection();
- if (!socket)
- return;
-
- if (d->m_socket) {
- socket->close();
- return;
- }
-
- d->m_socket = socket;
-
- connect(socket, SIGNAL(disconnected()), this, SLOT(socket_disconnected()));
- connect(socket, SIGNAL(error(QLlcpSocket::SocketError)),
- this, SLOT(socket_error(QLlcpSocket::SocketError)));
- connect(socket, SIGNAL(stateChanged(QLlcpSocket::SocketState)),
- this, SLOT(socket_state(QLlcpSocket::SocketState)));
- connect(socket, SIGNAL(readyRead()), this, SLOT(socket_readyRead()));
-
- void connectedChanged();
-}
diff --git a/src/imports/nfc/qdeclarativenearfieldsocket_p.h b/src/imports/nfc/qdeclarativenearfieldsocket_p.h
deleted file mode 100644
index 09db52e0..00000000
--- a/src/imports/nfc/qdeclarativenearfieldsocket_p.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVENEARFIELDSOCKET_P_H
-#define QDECLARATIVENEARFIELDSOCKET_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QObject>
-#include <QtQml/qqml.h>
-#include <QtQml/QQmlParserStatus>
-#include <QtNfc/QLlcpSocket>
-
-QT_USE_NAMESPACE
-
-class QDeclarativeNearFieldSocketPrivate;
-
-class QDeclarativeNearFieldSocket : public QObject, public QQmlParserStatus
-{
- Q_OBJECT
-
- Q_PROPERTY(QString uri READ uri WRITE setUri NOTIFY uriChanged)
- Q_PROPERTY(bool connected READ connected WRITE setConnected NOTIFY connectedChanged)
- Q_PROPERTY(QString error READ error NOTIFY errorChanged)
- Q_PROPERTY(QString state READ state NOTIFY stateChanged)
- Q_PROPERTY(bool listening READ listening WRITE setListening NOTIFY listeningChanged)
- Q_PROPERTY(QString stringData READ stringData WRITE sendStringData NOTIFY dataAvailable)
-
- Q_INTERFACES(QQmlParserStatus)
-
- Q_DECLARE_PRIVATE(QDeclarativeNearFieldSocket)
-
-public:
- explicit QDeclarativeNearFieldSocket(QObject *parent = 0);
- ~QDeclarativeNearFieldSocket();
-
- QString uri() const;
- bool connected() const;
- QString error() const;
- QString state() const;
- bool listening() const;
-
- QString stringData();
-
- // From QDeclarativeParserStatus
- void classBegin() {}
- void componentComplete();
-
-signals:
- void uriChanged();
- void connectedChanged();
- void errorChanged();
- void stateChanged();
- void listeningChanged();
- void dataAvailable();
-
-public slots:
- void setUri(const QString &service);
- void setConnected(bool connected);
- void setListening(bool listen);
- void sendStringData(const QString &data);
-
-private slots:
- void socket_connected();
- void socket_disconnected();
- void socket_error(QLlcpSocket::SocketError);
- void socket_state(QLlcpSocket::SocketState);
- void socket_readyRead();
-
- void llcp_connection();
-
-private:
- QDeclarativeNearFieldSocketPrivate *d_ptr;
-};
-
-QML_DECLARE_TYPE(QDeclarativeNearFieldSocket)
-
-#endif // QDECLARATIVENEARFIELDSOCKET_P_H
diff --git a/src/nfc/nfc.pro b/src/nfc/nfc.pro
index ed88b79a..c6ae147d 100644
--- a/src/nfc/nfc.pro
+++ b/src/nfc/nfc.pro
@@ -5,7 +5,7 @@ DEFINES += QT_NO_FOREACH
QMAKE_DOCS = $$PWD/doc/qtnfc.qdocconf
OTHER_FILES += doc/src/*.qdoc # show .qdoc files in Qt Creator
-PUBLIC_HEADERS += \
+HEADERS += \
qtnfcglobal.h \
qnearfieldmanager.h \
qnearfieldtarget.h \
@@ -17,9 +17,7 @@ PUBLIC_HEADERS += \
qqmlndefrecord.h \
qndefnfcsmartposterrecord.h \
qnearfieldsharemanager.h \
- qnearfieldsharetarget.h
-
-PRIVATE_HEADERS += \
+ qnearfieldsharetarget.h \
qtnfcglobal_p.h \
qllcpsocket_p.h \
qllcpserver_p.h \
@@ -63,7 +61,7 @@ linux:!android:qtHaveModule(dbus) {
DEFINES += NEARD_NFC
- PRIVATE_HEADERS += \
+ HEADERS += \
qllcpsocket_p_p.h \
qllcpserver_p_p.h \
qnearfieldmanager_neard_p.h \
@@ -91,7 +89,7 @@ linux:!android:qtHaveModule(dbus) {
DEFINES += ANDROID_NFC
QT_PRIVATE += core-private gui androidextras
- PRIVATE_HEADERS += \
+ HEADERS += \
qllcpserver_android_p.h \
qllcpsocket_android_p.h \
android/androidjninfc_p.h \
@@ -117,7 +115,7 @@ linux:!android:qtHaveModule(dbus) {
isEmpty(NFC_BACKEND_AVAILABLE) {
message("Unsupported NFC platform, will not build a working QtNfc library.")
- PRIVATE_HEADERS += \
+ HEADERS += \
qllcpsocket_p_p.h \
qllcpserver_p_p.h \
qnearfieldmanagerimpl_p.h \
@@ -133,6 +131,4 @@ isEmpty(NFC_BACKEND_AVAILABLE) {
qnearfieldtarget_p.cpp
}
-HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS
-
load(qt_module)
diff --git a/src/nfc/qnearfieldtarget.cpp b/src/nfc/qnearfieldtarget.cpp
index 814747a4..850408fe 100644
--- a/src/nfc/qnearfieldtarget.cpp
+++ b/src/nfc/qnearfieldtarget.cpp
@@ -226,7 +226,7 @@ bool QNearFieldTarget::RequestId::isValid() const
int QNearFieldTarget::RequestId::refCount() const
{
if (d)
- return d->ref.load();
+ return d->ref.loadRelaxed();
return 0;
}