diff options
Diffstat (limited to 'src/imports/nfc')
-rw-r--r-- | src/imports/nfc/nfc.pro | 20 | ||||
-rw-r--r-- | src/imports/nfc/plugin.cpp | 101 | ||||
-rw-r--r-- | src/imports/nfc/plugins.qmltypes | 91 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativendeffilter.cpp | 167 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativendeffilter_p.h | 93 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativendefmimerecord.cpp | 97 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativendefmimerecord_p.h | 75 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativendeftextrecord.cpp | 180 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativendeftextrecord_p.h | 95 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativendefurirecord.cpp | 98 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativendefurirecord_p.h | 80 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativenearfield.cpp | 360 | ||||
-rw-r--r-- | src/imports/nfc/qdeclarativenearfield_p.h | 135 | ||||
-rw-r--r-- | src/imports/nfc/qmldir | 4 |
14 files changed, 0 insertions, 1596 deletions
diff --git a/src/imports/nfc/nfc.pro b/src/imports/nfc/nfc.pro deleted file mode 100644 index e7ce081b..00000000 --- a/src/imports/nfc/nfc.pro +++ /dev/null @@ -1,20 +0,0 @@ -TARGETPATH = QtNfc - -QT = core qml nfc - -# Input -HEADERS += \ - qdeclarativenearfield_p.h \ - qdeclarativendeffilter_p.h \ - qdeclarativendeftextrecord_p.h \ - qdeclarativendefurirecord_p.h \ - qdeclarativendefmimerecord_p.h - -SOURCES += plugin.cpp \ - qdeclarativenearfield.cpp \ - qdeclarativendeffilter.cpp \ - qdeclarativendeftextrecord.cpp \ - qdeclarativendefurirecord.cpp \ - qdeclarativendefmimerecord.cpp - -load(qml_plugin) diff --git a/src/imports/nfc/plugin.cpp b/src/imports/nfc/plugin.cpp deleted file mode 100644 index 3a6806fa..00000000 --- a/src/imports/nfc/plugin.cpp +++ /dev/null @@ -1,101 +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 <QtQml/QQmlEngine> -#include <QtQml/QQmlExtensionPlugin> - -#include "qqmlndefrecord.h" -#include "qdeclarativenearfield_p.h" -#include "qdeclarativendeffilter_p.h" -#include "qdeclarativendeftextrecord_p.h" -#include "qdeclarativendefurirecord_p.h" -#include "qdeclarativendefmimerecord_p.h" - -QT_USE_NAMESPACE - -class QNfcQmlPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) - -public: - QNfcQmlPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QStringLiteral("QtNfc")); - - // @uri QtNfc - - // Register the 5.0 types - int major = 5; - int minor = 0; - - qmlRegisterType<QDeclarativeNearField>(uri, major, minor, "NearField"); - qmlRegisterType<QDeclarativeNdefFilter>(uri, major, minor, "NdefFilter"); - qmlRegisterType<QQmlNdefRecord>(uri, major, minor, "NdefRecord"); - qmlRegisterType<QDeclarativeNdefTextRecord>(uri, major, minor, "NdefTextRecord"); - qmlRegisterType<QDeclarativeNdefUriRecord>(uri, major, minor, "NdefUriRecord"); - qmlRegisterType<QDeclarativeNdefMimeRecord>(uri, major, minor, "NdefMimeRecord"); - - // Register the 5.2 types - minor = 2; - qmlRegisterType<QDeclarativeNearField>(uri, major, minor, "NearField"); - qmlRegisterType<QDeclarativeNdefFilter>(uri, major, minor, "NdefFilter"); - qmlRegisterType<QQmlNdefRecord>(uri, major, minor, "NdefRecord"); - qmlRegisterType<QDeclarativeNdefTextRecord>(uri, major, minor, "NdefTextRecord"); - qmlRegisterType<QDeclarativeNdefUriRecord>(uri, major, minor, "NdefUriRecord"); - qmlRegisterType<QDeclarativeNdefMimeRecord>(uri, major, minor, "NdefMimeRecord"); - - // Register the 5.4 types - // introduces 5.4 version, other existing 5.2 exports become automatically available under 5.2-5.4l - minor = 4; - qmlRegisterType<QDeclarativeNearField>(uri, major, minor, "NearField"); - - // Register the 5.5 types - minor = 5; - qmlRegisterType<QDeclarativeNearField, 1>(uri, major, minor, "NearField"); - - - // Register the latest Qt version as QML type version - qmlRegisterModule(uri, QT_VERSION_MAJOR, QT_VERSION_MINOR); - } -}; - -#include "plugin.moc" - diff --git a/src/imports/nfc/plugins.qmltypes b/src/imports/nfc/plugins.qmltypes deleted file mode 100644 index 2151ad7d..00000000 --- a/src/imports/nfc/plugins.qmltypes +++ /dev/null @@ -1,91 +0,0 @@ -import QtQuick.tooling 1.2 - -// 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 -nonrelocatable QtNfc 5.14' - -Module { - dependencies: ["QtQuick 2.0"] - Component { - name: "QDeclarativeNdefFilter" - prototype: "QObject" - exports: ["QtNfc/NdefFilter 5.0", "QtNfc/NdefFilter 5.2"] - exportMetaObjectRevisions: [0, 0] - Property { name: "type"; type: "string" } - Property { name: "typeNameFormat"; type: "QQmlNdefRecord::TypeNameFormat" } - Property { name: "minimum"; type: "int" } - Property { name: "maximum"; type: "int" } - } - Component { - name: "QDeclarativeNdefMimeRecord" - prototype: "QQmlNdefRecord" - exports: ["QtNfc/NdefMimeRecord 5.0", "QtNfc/NdefMimeRecord 5.2"] - exportMetaObjectRevisions: [0, 0] - Property { name: "uri"; type: "string"; isReadonly: true } - } - Component { - name: "QDeclarativeNdefTextRecord" - prototype: "QQmlNdefRecord" - exports: ["QtNfc/NdefTextRecord 5.0", "QtNfc/NdefTextRecord 5.2"] - exportMetaObjectRevisions: [0, 0] - Enum { - name: "LocaleMatch" - values: { - "LocaleMatchedNone": 0, - "LocaleMatchedEnglish": 1, - "LocaleMatchedLanguage": 2, - "LocaleMatchedLanguageAndCountry": 3 - } - } - Property { name: "text"; type: "string" } - Property { name: "locale"; type: "string" } - Property { name: "localeMatch"; type: "LocaleMatch"; isReadonly: true } - } - Component { - name: "QDeclarativeNdefUriRecord" - prototype: "QQmlNdefRecord" - exports: ["QtNfc/NdefUriRecord 5.0", "QtNfc/NdefUriRecord 5.2"] - exportMetaObjectRevisions: [0, 0] - Property { name: "uri"; type: "string" } - } - Component { - name: "QDeclarativeNearField" - prototype: "QObject" - exports: [ - "QtNfc/NearField 5.0", - "QtNfc/NearField 5.2", - "QtNfc/NearField 5.4", - "QtNfc/NearField 5.5" - ] - exportMetaObjectRevisions: [0, 0, 0, 1] - Property { name: "messageRecords"; type: "QQmlNdefRecord"; isList: true; isReadonly: true } - Property { name: "filter"; type: "QDeclarativeNdefFilter"; isList: true; isReadonly: true } - Property { name: "orderMatch"; type: "bool" } - Property { name: "polling"; revision: 1; type: "bool" } - Signal { name: "pollingChanged"; revision: 1 } - Signal { name: "tagFound"; revision: 1 } - Signal { name: "tagRemoved"; revision: 1 } - } - Component { - name: "QQmlNdefRecord" - prototype: "QObject" - exports: ["QtNfc/NdefRecord 5.0", "QtNfc/NdefRecord 5.2"] - exportMetaObjectRevisions: [0, 0] - Enum { - name: "TypeNameFormat" - values: { - "Empty": 0, - "NfcRtd": 1, - "Mime": 2, - "Uri": 3, - "ExternalRtd": 4, - "Unknown": 5 - } - } - Property { name: "type"; type: "string" } - Property { name: "typeNameFormat"; type: "TypeNameFormat" } - Property { name: "record"; type: "QNdefRecord" } - } -} diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp deleted file mode 100644 index 96cf4f3a..00000000 --- a/src/imports/nfc/qdeclarativendeffilter.cpp +++ /dev/null @@ -1,167 +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 "qdeclarativendeffilter_p.h" - -#include <limits.h> - -/*! - \qmltype NdefFilter - \instantiates QDeclarativeNdefFilter - \since 5.2 - \brief Represents a filtering constraint for NDEF message records. - - \ingroup nfc-qml - \inqmlmodule QtNfc - - \sa NearField - \sa QNdefFilter - - The NdefFilter type is used with the NearField type to read NDEF messages from NFC Forum - tags that match a given structure. - - \code - NearField { - filter: [ - NdefFilter { - type: "urn:nfc:wkt:U" - minimum: 1 - maximum: 1 - } - ] - } - \endcode -*/ - -/*! - \qmlproperty string NdefFilter::type - - This property holds the NDEF record type that the filter matches. This property must be set to - the fully qualified record type, i.e. including the NIS and NSS prefixes. For example set to - \c {urn:nfc:wkt:U} to match NFC RTD-URI records. -*/ - -/*! - \qmlproperty QQmlNdefRecord::TypeNameFormat NdefFilter::typeNameFormat - - This property holds the NDEF record name format type \l QQmlNdefRecord::TypeNameFormat. -*/ - -/*! - \qmlproperty int NdefFilter::minimum - - This property holds the minimum number of records of the given type that must be in the NDEF - message for it match. - - The default minimum is 1. - - \sa maximum -*/ - -/*! - \qmlproperty int NdefFilter::maximum - - This property holds the maximum number of records of the given type that must be in the NDEF - message for it match. - - The default maximum is UINT_MAX. - - \sa minimum -*/ - -QDeclarativeNdefFilter::QDeclarativeNdefFilter(QObject *parent) -: QObject(parent), m_minimum(1), m_maximum(INT_MAX) -{ -} - -QString QDeclarativeNdefFilter::type() const -{ - return m_type; -} - -void QDeclarativeNdefFilter::setType(const QString &t) -{ - if (m_type == t) - return; - - m_type = t; - emit typeChanged(); -} - -QQmlNdefRecord::TypeNameFormat QDeclarativeNdefFilter::typeNameFormat() const -{ - return m_typeNameFormat; -} - -void QDeclarativeNdefFilter::setTypeNameFormat(QQmlNdefRecord::TypeNameFormat format) -{ - if (m_typeNameFormat == format) - return; - - m_typeNameFormat = format; - emit typeNameFormatChanged(); -} - -int QDeclarativeNdefFilter::minimum() const -{ - return m_minimum; -} - -void QDeclarativeNdefFilter::setMinimum(int value) -{ - if (m_minimum == value) - return; - - m_minimum = value; - emit minimumChanged(); -} - -int QDeclarativeNdefFilter::maximum() const -{ - return m_maximum; -} - -void QDeclarativeNdefFilter::setMaximum(int value) -{ - if (m_maximum == value) - return; - - m_maximum = value; - emit maximumChanged(); -} diff --git a/src/imports/nfc/qdeclarativendeffilter_p.h b/src/imports/nfc/qdeclarativendeffilter_p.h deleted file mode 100644 index 7ecc3093..00000000 --- a/src/imports/nfc/qdeclarativendeffilter_p.h +++ /dev/null @@ -1,93 +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 QDECLARATIVENDEFFILTER_P_H -#define QDECLARATIVENDEFFILTER_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 <qqmlndefrecord.h> - -class QDeclarativeNdefFilter : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) - Q_PROPERTY(QQmlNdefRecord::TypeNameFormat typeNameFormat READ typeNameFormat WRITE setTypeNameFormat NOTIFY typeNameFormatChanged) - Q_PROPERTY(int minimum READ minimum WRITE setMinimum NOTIFY minimumChanged) - Q_PROPERTY(int maximum READ maximum WRITE setMaximum NOTIFY maximumChanged) -public: - explicit QDeclarativeNdefFilter(QObject *parent = 0); - - QString type() const; - void setType(const QString &t); - - QQmlNdefRecord::TypeNameFormat typeNameFormat() const; - void setTypeNameFormat(QQmlNdefRecord::TypeNameFormat format); - - int minimum() const; - void setMinimum(int value); - - int maximum() const; - void setMaximum(int value); - -signals: - void typeChanged(); - void minimumChanged(); - void maximumChanged(); - void typeNameFormatChanged(); - -private: - QString m_type; - int m_minimum; - int m_maximum; - QQmlNdefRecord::TypeNameFormat m_typeNameFormat; -}; - -#endif // QDECLARATIVENDEFFILTER_P_H diff --git a/src/imports/nfc/qdeclarativendefmimerecord.cpp b/src/imports/nfc/qdeclarativendefmimerecord.cpp deleted file mode 100644 index ffeecfb1..00000000 --- a/src/imports/nfc/qdeclarativendefmimerecord.cpp +++ /dev/null @@ -1,97 +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 "qdeclarativendefmimerecord_p.h" - -/*! - \qmltype NdefMimeRecord - \since 5.2 - \brief Represents an NFC MIME record. - - \ingroup connectivity-nfc - \inqmlmodule QtNfc - - \inherits NdefRecord - - 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. -*/ - -/*! - \qmlproperty string NdefMimeRecord::uri - - This property hold the URI from which the MIME data can be fetched from. Currently this - property returns a data url. -*/ - -Q_DECLARE_NDEFRECORD(QDeclarativeNdefMimeRecord, QNdefRecord::Mime, ".*") - -static inline QNdefRecord createMimeRecord() -{ - QNdefRecord mimeRecord; - mimeRecord.setTypeNameFormat(QNdefRecord::Mime); - return mimeRecord; -} - -static inline QNdefRecord castToMimeRecord(const QNdefRecord &record) -{ - if (record.typeNameFormat() != QNdefRecord::Mime) - return createMimeRecord(); - return record; -} - -QDeclarativeNdefMimeRecord::QDeclarativeNdefMimeRecord(QObject *parent) -: QQmlNdefRecord(createMimeRecord(), parent) -{ -} - -QDeclarativeNdefMimeRecord::QDeclarativeNdefMimeRecord(const QNdefRecord &record, QObject *parent) -: QQmlNdefRecord(castToMimeRecord(record), parent) -{ -} - -QDeclarativeNdefMimeRecord::~QDeclarativeNdefMimeRecord() -{ -} - -QString QDeclarativeNdefMimeRecord::uri() const -{ - QByteArray dataUri = "data:" + record().type() + ";base64," + record().payload().toBase64(); - return QString::fromLatin1(dataUri.constData(), dataUri.length()); -} diff --git a/src/imports/nfc/qdeclarativendefmimerecord_p.h b/src/imports/nfc/qdeclarativendefmimerecord_p.h deleted file mode 100644 index a06f5218..00000000 --- a/src/imports/nfc/qdeclarativendefmimerecord_p.h +++ /dev/null @@ -1,75 +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 QDECLARATIVENDEFMIMERECORD_P_H -#define QDECLARATIVENDEFMIMERECORD_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 <qqmlndefrecord.h> - -QT_USE_NAMESPACE - -class QDeclarativeNdefMimeRecord : public QQmlNdefRecord -{ - Q_OBJECT - - Q_PROPERTY(QString uri READ uri NOTIFY uriChanged) - -public: - explicit QDeclarativeNdefMimeRecord(QObject *parent = 0); - Q_INVOKABLE QDeclarativeNdefMimeRecord(const QNdefRecord &record, QObject *parent = 0); - ~QDeclarativeNdefMimeRecord(); - - QString uri() const; - -signals: - void uriChanged(); -}; - -#endif // QDECLARATIVENDEFMIMERECORD_P_H diff --git a/src/imports/nfc/qdeclarativendeftextrecord.cpp b/src/imports/nfc/qdeclarativendeftextrecord.cpp deleted file mode 100644 index ff93a44b..00000000 --- a/src/imports/nfc/qdeclarativendeftextrecord.cpp +++ /dev/null @@ -1,180 +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 "qdeclarativendeftextrecord_p.h" - -#include <QtCore/QLocale> - -/*! - \qmltype NdefTextRecord - \since 5.2 - \brief Represents an NFC RTD-Text NDEF record. - - \ingroup nfc-qml - \inqmlmodule QtNfc - - \inherits NdefRecord - - \sa QNdefNfcTextRecord - - 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 - property can be used to determine if the text record has been matched. -*/ - -/*! - \qmlproperty string NdefTextRecord::text - - This property holds the text which should be displayed when the current locale matches - \l locale. -*/ - -/*! - \qmlproperty string NdefTextRecord::locale - - This property holds the locale that this text record is for. -*/ - -/*! - \qmlproperty enumeration NdefTextRecord::localeMatch - - This property holds an enum describing how closely the locale of the text record matches the - applications current locale. The application should display only the text record that most - closely matches the applications current locale. - - \table - \header - \li Value - \li Description - \row - \li LocaleMatchedNone - \li The text record does not match at all. - \row - \li LocaleMatchedEnglish - \li The language of the text record is English and the language of application's current - locale is \b {not} English. The English language text should be displayed if - there is not a more appropriate match. - \row - \li LocaleMatchedLanguage - \li The language of the text record and the language of the applications's current - locale are the same. - \row - \li LocaleMatchedLanguageAndCountry - \li The language and country of the text record matches that of the applicatin's current - locale. - \endtable -*/ - -Q_DECLARE_NDEFRECORD(QDeclarativeNdefTextRecord, QNdefRecord::NfcRtd, "T") - -QDeclarativeNdefTextRecord::QDeclarativeNdefTextRecord(QObject *parent) -: QQmlNdefRecord(QNdefNfcTextRecord(), parent) -{ -} - -QDeclarativeNdefTextRecord::QDeclarativeNdefTextRecord(const QNdefRecord &record, QObject *parent) -: QQmlNdefRecord(QNdefNfcTextRecord(record), parent) -{ -} - -QDeclarativeNdefTextRecord::~QDeclarativeNdefTextRecord() -{ -} - -QString QDeclarativeNdefTextRecord::text() const -{ - QNdefNfcTextRecord textRecord(record()); - - return textRecord.text(); -} - -void QDeclarativeNdefTextRecord::setText(const QString &text) -{ - QNdefNfcTextRecord textRecord(record()); - - if (textRecord.text() == text) - return; - - textRecord.setText(text); - setRecord(textRecord); - emit textChanged(); -} - -QString QDeclarativeNdefTextRecord::locale() const -{ - if (!record().isRecordType<QNdefNfcTextRecord>()) - return QString(); - - QNdefNfcTextRecord textRecord(record()); - - return textRecord.locale(); -} - -void QDeclarativeNdefTextRecord::setLocale(const QString &locale) -{ - QNdefNfcTextRecord textRecord(record()); - - if (textRecord.locale() == locale) - return; - - LocaleMatch previous = localeMatch(); - - textRecord.setLocale(locale); - setRecord(textRecord); - emit localeChanged(); - - if (previous != localeMatch()) - emit localeMatchChanged(); -} - -QDeclarativeNdefTextRecord::LocaleMatch QDeclarativeNdefTextRecord::localeMatch() const -{ - const QLocale recordLocale(locale()); - const QLocale defaultLocale; - - if (recordLocale == defaultLocale) - return LocaleMatchedLanguageAndCountry; - else if (recordLocale.language() == defaultLocale.language()) - return LocaleMatchedLanguage; - else if (recordLocale.language() == QLocale::English) - return LocaleMatchedEnglish; - else - return LocaleMatchedNone; -} diff --git a/src/imports/nfc/qdeclarativendeftextrecord_p.h b/src/imports/nfc/qdeclarativendeftextrecord_p.h deleted file mode 100644 index dc5ac1f5..00000000 --- a/src/imports/nfc/qdeclarativendeftextrecord_p.h +++ /dev/null @@ -1,95 +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 QDECLARATIVENDEFTEXTRECORD_P_H -#define QDECLARATIVENDEFTEXTRECORD_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 <qqmlndefrecord.h> - -#include <qndefnfctextrecord.h> - -QT_USE_NAMESPACE - -class QDeclarativeNdefTextRecord : public QQmlNdefRecord -{ - Q_OBJECT - - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QString locale READ locale WRITE setLocale NOTIFY localeChanged) - Q_PROPERTY(LocaleMatch localeMatch READ localeMatch NOTIFY localeMatchChanged) - -public: - enum LocaleMatch { - LocaleMatchedNone, - LocaleMatchedEnglish, - LocaleMatchedLanguage, - LocaleMatchedLanguageAndCountry - }; - Q_ENUM(LocaleMatch) - - explicit QDeclarativeNdefTextRecord(QObject *parent = 0); - Q_INVOKABLE QDeclarativeNdefTextRecord(const QNdefRecord &record, QObject *parent = 0); - ~QDeclarativeNdefTextRecord(); - - QString text() const; - void setText(const QString &text); - - QString locale() const; - void setLocale(const QString &locale); - - LocaleMatch localeMatch() const; - -signals: - void textChanged(); - void localeChanged(); - void localeMatchChanged(); -}; - -#endif // QDECLARATIVENDEFTEXTRECORD_P_H diff --git a/src/imports/nfc/qdeclarativendefurirecord.cpp b/src/imports/nfc/qdeclarativendefurirecord.cpp deleted file mode 100644 index b1f49712..00000000 --- a/src/imports/nfc/qdeclarativendefurirecord.cpp +++ /dev/null @@ -1,98 +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 "qdeclarativendefurirecord_p.h" - -#include <QtCore/QUrl> - -/*! - \qmltype NdefUriRecord - \since 5.2 - \brief Represents an NFC RTD-URI NDEF record. - - \ingroup nfc-qml - \inqmlmodule QtNfc - - \inherits NdefRecord - - \sa QNdefNfcUriRecord - - The NdefUriRecord type can contain a uniform resource identifier. -*/ - -/*! - \qmlproperty string NdefUriRecord::uri - - This property hold the URI stored in this URI record. -*/ - -Q_DECLARE_NDEFRECORD(QDeclarativeNdefUriRecord, QNdefRecord::NfcRtd, "U") - -QDeclarativeNdefUriRecord::QDeclarativeNdefUriRecord(QObject *parent) -: QQmlNdefRecord(QNdefNfcUriRecord(), parent) -{ -} - -QDeclarativeNdefUriRecord::QDeclarativeNdefUriRecord(const QNdefRecord &record, QObject *parent) -: QQmlNdefRecord(QNdefNfcUriRecord(record), parent) -{ -} - -QDeclarativeNdefUriRecord::~QDeclarativeNdefUriRecord() -{ -} - -QString QDeclarativeNdefUriRecord::uri() const -{ - QNdefNfcUriRecord uriRecord(record()); - - return uriRecord.uri().toString(); -} - -void QDeclarativeNdefUriRecord::setUri(const QString &uri) -{ - QNdefNfcUriRecord uriRecord(record()); - - if (uriRecord.uri() == uri) - return; - - uriRecord.setUri(uri); - setRecord(uriRecord); - emit uriChanged(); -} diff --git a/src/imports/nfc/qdeclarativendefurirecord_p.h b/src/imports/nfc/qdeclarativendefurirecord_p.h deleted file mode 100644 index 8f00567e..00000000 --- a/src/imports/nfc/qdeclarativendefurirecord_p.h +++ /dev/null @@ -1,80 +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 QDECLARATIVENDEFURIRECORD_P_H -#define QDECLARATIVENDEFURIRECORD_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 <qqmlndefrecord.h> - -#include <qndefnfcurirecord.h> - -#include <QtCore/QMetaType> - -QT_USE_NAMESPACE - -class QDeclarativeNdefUriRecord : public QQmlNdefRecord -{ - Q_OBJECT - - Q_PROPERTY(QString uri READ uri WRITE setUri NOTIFY uriChanged) - -public: - explicit QDeclarativeNdefUriRecord(QObject *parent = 0); - Q_INVOKABLE QDeclarativeNdefUriRecord(const QNdefRecord &record, QObject *parent = 0); - ~QDeclarativeNdefUriRecord(); - - QString uri() const; - void setUri(const QString &uri); - -signals: - void uriChanged(); -}; - -#endif // QDECLARATIVENDEFURIRECORD_P_H diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp deleted file mode 100644 index c6c53ba4..00000000 --- a/src/imports/nfc/qdeclarativenearfield.cpp +++ /dev/null @@ -1,360 +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 "qdeclarativenearfield_p.h" -#include "qdeclarativendeffilter_p.h" -#include "qdeclarativendeftextrecord_p.h" -#include "qdeclarativendefurirecord_p.h" -#include "qdeclarativendefmimerecord_p.h" - -#include <qndefmessage.h> -#include <qndefnfctextrecord.h> -#include <qndefnfcurirecord.h> - -#include <QtNfc/QNearFieldTarget> - -/*! - \qmltype NearField - \instantiates QDeclarativeNearField - \since 5.2 - \brief Provides access to NDEF messages stored on NFC Forum tags. - - \ingroup nfc-qml - \inqmlmodule QtNfc - - \sa NdefFilter - \sa NdefRecord - - \sa QNearFieldManager - \sa QNdefMessage - \sa QNdefRecord - - 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. - - \note For platforms using neard, filtering is currently not implemented. For more information - on neard see \l QNearFieldManager. - - \snippet doc_src_qtnfc.qml QML register for messages -*/ - -/*! - \qmlproperty list<NdefRecord> NearField::messageRecords - - This property contains the list of NDEF records in the last NDEF message read. -*/ - -/*! - \qmlproperty list<NdefFilter> NearField::filter - - This property holds the NDEF filter constraints. The \l messageRecords property will only be - set to NDEF messages which match the filter. If no filter is set, a message handler for - all NDEF messages will be registered. - - \note Filtering is not supported when using neard. - - \l QNearFieldManager::registerNdefMessageHandler() -*/ - -/*! - \qmlproperty bool NearField::orderMatch - - This property indicates whether the order of records should be taken into account when matching - messages. This is not supported when using neard. - - The default of orderMatch is false. -*/ - -/*! - \qmlproperty bool NearField::polling - \since 5.5 - - This property indicates if the underlying adapter is currently in polling state. If set to \c true - the adapter will start polling and stop polling if set to \c false. - - \note On platforms using neard, the adapter will stop polling as soon as a tag has been detected. - For more information see \l QNearFieldManager. -*/ - -/*! - \qmlsignal NearField::tagFound() - \since 5.5 - - This signal will be emitted when a tag has been detected. -*/ - -/*! - \qmlsignal NearField::tagRemoved() - \since 5.5 - - This signal will be emitted when a tag has been removed. -*/ - -QDeclarativeNearField::QDeclarativeNearField(QObject *parent) - : QObject(parent), - m_orderMatch(false), - m_componentCompleted(false), - m_messageUpdating(false), - m_manager(new QNearFieldManager(this)), - m_messageHandlerId(-1), - m_polling(false) -{ - connect(m_manager, SIGNAL(targetDetected(QNearFieldTarget*)), - this, SLOT(_q_handleTargetDetected(QNearFieldTarget*))); - connect(m_manager, SIGNAL(targetLost(QNearFieldTarget*)), - this, SLOT(_q_handleTargetLost(QNearFieldTarget*))); -} - -QQmlListProperty<QQmlNdefRecord> QDeclarativeNearField::messageRecords() -{ - return QQmlListProperty<QQmlNdefRecord>(this, 0, - &QDeclarativeNearField::append_messageRecord, - &QDeclarativeNearField::count_messageRecords, - &QDeclarativeNearField::at_messageRecord, - &QDeclarativeNearField::clear_messageRecords); - -} - -QQmlListProperty<QDeclarativeNdefFilter> QDeclarativeNearField::filter() -{ - return QQmlListProperty<QDeclarativeNdefFilter>(this, 0, - &QDeclarativeNearField::append_filter, - &QDeclarativeNearField::count_filters, - &QDeclarativeNearField::at_filter, - &QDeclarativeNearField::clear_filter); -} - -bool QDeclarativeNearField::orderMatch() const -{ - return m_orderMatch; -} - -void QDeclarativeNearField::setOrderMatch(bool on) -{ - if (m_orderMatch == on) - return; - - m_orderMatch = on; - emit orderMatchChanged(); -} - -void QDeclarativeNearField::componentComplete() -{ - m_componentCompleted = true; - - registerMessageHandler(); -} - -bool QDeclarativeNearField::polling() const -{ - return m_polling; -} - -void QDeclarativeNearField::setPolling(bool on) -{ - if (m_polling == on) - return; - - if (on) { - if (m_manager->startTargetDetection()) { - m_polling = true; - emit pollingChanged(); - } - } else { - m_manager->stopTargetDetection(); - m_polling = false; - emit pollingChanged(); - } -} - -void QDeclarativeNearField::registerMessageHandler() -{ - if (m_messageHandlerId != -1) - m_manager->unregisterNdefMessageHandler(m_messageHandlerId); - - QNdefFilter ndefFilter; - ndefFilter.setOrderMatch(m_orderMatch); - for (const QDeclarativeNdefFilter *filter : qAsConst(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<QNdefRecord::TypeNameFormat>(filter->typeNameFormat()), type.toUtf8(), min, max); - } - - m_messageHandlerId = m_manager->registerNdefMessageHandler(ndefFilter, this, SLOT(_q_handleNdefMessage(QNdefMessage))); - - // FIXME: if a message handler has been registered we just assume that constant polling is done - if (m_messageHandlerId >= 0) { - m_polling = true; - emit pollingChanged(); - } -} - -void QDeclarativeNearField::_q_handleNdefMessage(const QNdefMessage &message) -{ - m_messageUpdating = true; - - QQmlListReference listRef(this, "messageRecords"); - - listRef.clear(); - - for (const QNdefRecord &record : message) - listRef.append(qNewDeclarativeNdefRecordForNdefRecord(record)); - - m_messageUpdating = false; - - emit messageRecordsChanged(); -} - -void QDeclarativeNearField::_q_handleTargetLost(QNearFieldTarget *target) -{ - Q_UNUSED(target); - // FIXME: only notify that polling stopped when there is no registered message handler - if (m_messageHandlerId == -1) { - m_polling = false; - emit pollingChanged(); - } - - emit tagRemoved(); -} - -void QDeclarativeNearField::_q_handleTargetDetected(QNearFieldTarget *target) -{ - Q_UNUSED(target); - - if (m_messageHandlerId == -1) { - connect(target, SIGNAL(ndefMessageRead(QNdefMessage)), - this, SLOT(_q_handleNdefMessage(QNdefMessage))); - target->readNdefMessages(); - } - - emit tagFound(); -} - -void QDeclarativeNearField::append_messageRecord(QQmlListProperty<QQmlNdefRecord> *list, - QQmlNdefRecord *record) -{ - QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object); - if (!nearField) - return; - - record->setParent(nearField); - nearField->m_message.append(record); - if (!nearField->m_messageUpdating) - emit nearField->messageRecordsChanged(); -} - -int QDeclarativeNearField::count_messageRecords(QQmlListProperty<QQmlNdefRecord> *list) -{ - QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object); - if (!nearField) - return 0; - - return nearField->m_message.count(); -} - -QQmlNdefRecord *QDeclarativeNearField::at_messageRecord(QQmlListProperty<QQmlNdefRecord> *list, - int index) -{ - QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object); - if (!nearField) - return 0; - - return nearField->m_message.at(index); -} - -void QDeclarativeNearField::clear_messageRecords(QQmlListProperty<QQmlNdefRecord> *list) -{ - QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object); - if (nearField) { - qDeleteAll(nearField->m_message); - nearField->m_message.clear(); - if (!nearField->m_messageUpdating) - emit nearField->messageRecordsChanged(); - } -} - -void QDeclarativeNearField::append_filter(QQmlListProperty<QDeclarativeNdefFilter> *list, - QDeclarativeNdefFilter *filter) -{ - QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object); - if (!nearField) - return; - - filter->setParent(nearField); - nearField->m_filterList.append(filter); - emit nearField->filterChanged(); - - if (nearField->m_componentCompleted) - nearField->registerMessageHandler(); -} - -int QDeclarativeNearField::count_filters(QQmlListProperty<QDeclarativeNdefFilter> *list) -{ - QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object); - if (!nearField) - return 0; - - return nearField->m_filterList.count(); -} - -QDeclarativeNdefFilter *QDeclarativeNearField::at_filter(QQmlListProperty<QDeclarativeNdefFilter> *list, - int index) -{ - QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object); - if (!nearField) - return 0; - - return nearField->m_filterList.at(index); -} - -void QDeclarativeNearField::clear_filter(QQmlListProperty<QDeclarativeNdefFilter> *list) -{ - QDeclarativeNearField *nearField = qobject_cast<QDeclarativeNearField *>(list->object); - if (!nearField) - return; - - 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 deleted file mode 100644 index ad26da8d..00000000 --- a/src/imports/nfc/qdeclarativenearfield_p.h +++ /dev/null @@ -1,135 +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 QDECLARATIVENEARFIELD_P_H -#define QDECLARATIVENEARFIELD_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/QNearFieldManager> - -#include "qqmlndefrecord.h" - - -QT_USE_NAMESPACE - -class QDeclarativeNdefFilter; -class QDeclarativeNearField : public QObject, public QQmlParserStatus -{ - Q_OBJECT - - Q_PROPERTY(QQmlListProperty<QQmlNdefRecord> messageRecords READ messageRecords NOTIFY messageRecordsChanged) - Q_PROPERTY(QQmlListProperty<QDeclarativeNdefFilter> filter READ filter NOTIFY filterChanged) - Q_PROPERTY(bool orderMatch READ orderMatch WRITE setOrderMatch NOTIFY orderMatchChanged) - Q_PROPERTY(bool polling READ polling WRITE setPolling NOTIFY pollingChanged REVISION 1) - - Q_INTERFACES(QQmlParserStatus) - -public: - explicit QDeclarativeNearField(QObject *parent = 0); - - QQmlListProperty<QQmlNdefRecord> messageRecords(); - - QQmlListProperty<QDeclarativeNdefFilter> filter(); - - bool orderMatch() const; - void setOrderMatch(bool on); - - // From QDeclarativeParserStatus - void classBegin() { } - void componentComplete(); - - bool polling() const; - void setPolling(bool on); - -signals: - void messageRecordsChanged(); - void filterChanged(); - void orderMatchChanged(); - Q_REVISION(1) void pollingChanged(); - - Q_REVISION(1) void tagFound(); - Q_REVISION(1) void tagRemoved(); - -private slots: - void _q_handleNdefMessage(const QNdefMessage &message); - void _q_handleTargetLost(QNearFieldTarget*); - void _q_handleTargetDetected(QNearFieldTarget*); - -private: - QList<QQmlNdefRecord *> m_message; - QList<QDeclarativeNdefFilter *> m_filterList; - bool m_orderMatch; - bool m_componentCompleted; - bool m_messageUpdating; - - QNearFieldManager *m_manager; - int m_messageHandlerId; - bool m_polling; - - void registerMessageHandler(); - - static void append_messageRecord(QQmlListProperty<QQmlNdefRecord> *list, - QQmlNdefRecord *record); - static int count_messageRecords(QQmlListProperty<QQmlNdefRecord> *list); - static QQmlNdefRecord *at_messageRecord(QQmlListProperty<QQmlNdefRecord> *list, - int index); - static void clear_messageRecords(QQmlListProperty<QQmlNdefRecord> *list); - - static void append_filter(QQmlListProperty<QDeclarativeNdefFilter> *list, - QDeclarativeNdefFilter *filter); - static int count_filters(QQmlListProperty<QDeclarativeNdefFilter> *list); - static QDeclarativeNdefFilter *at_filter(QQmlListProperty<QDeclarativeNdefFilter> *list, - int index); - static void clear_filter(QQmlListProperty<QDeclarativeNdefFilter> *list); -}; - -#endif // QDECLARATIVENEARFIELD_P_H diff --git a/src/imports/nfc/qmldir b/src/imports/nfc/qmldir deleted file mode 100644 index 0025f3e6..00000000 --- a/src/imports/nfc/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -module QtNfc -plugin declarative_nfc -classname QNfcQmlPlugin -typeinfo plugins.qmltypes |