1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QNEARFIELDTARGET_P_H |
5 | #define QNEARFIELDTARGET_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include "qnearfieldtarget.h" |
19 | |
20 | #include <QtCore/QByteArray> |
21 | #include <QtCore/QList> |
22 | #include <QtCore/QObject> |
23 | #include <QtCore/QSharedData> |
24 | #include <QtCore/QVariant> |
25 | #include <QtCore/QMap> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | class QNearFieldTarget::RequestIdPrivate : public QSharedData |
30 | { |
31 | }; |
32 | |
33 | class Q_AUTOTEST_EXPORT QNearFieldTargetPrivate : public QObject |
34 | { |
35 | Q_OBJECT |
36 | |
37 | public: |
38 | QNearFieldTarget *q_ptr; |
39 | |
40 | explicit QNearFieldTargetPrivate(QObject *parent = nullptr); |
41 | virtual ~QNearFieldTargetPrivate() = default; |
42 | |
43 | virtual QByteArray uid() const; |
44 | virtual QNearFieldTarget::Type type() const; |
45 | virtual QNearFieldTarget::AccessMethods accessMethods() const; |
46 | |
47 | virtual bool disconnect(); |
48 | |
49 | // NdefAccess |
50 | virtual bool hasNdefMessage(); |
51 | virtual QNearFieldTarget::RequestId readNdefMessages(); |
52 | virtual QNearFieldTarget::RequestId writeNdefMessages(const QList<QNdefMessage> &messages); |
53 | |
54 | // TagTypeSpecificAccess |
55 | virtual int maxCommandLength() const; |
56 | virtual QNearFieldTarget::RequestId sendCommand(const QByteArray &command); |
57 | |
58 | bool waitForRequestCompleted(const QNearFieldTarget::RequestId &id, int msecs = 5000); |
59 | QVariant requestResponse(const QNearFieldTarget::RequestId &id) const; |
60 | |
61 | Q_SIGNALS: |
62 | void disconnected(); |
63 | |
64 | void ndefMessageRead(const QNdefMessage &message); |
65 | |
66 | void requestCompleted(const QNearFieldTarget::RequestId &id); |
67 | |
68 | void error(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id); |
69 | |
70 | protected: |
71 | QMap<QNearFieldTarget::RequestId, QVariant> m_decodedResponses; |
72 | |
73 | virtual void setResponseForRequest(const QNearFieldTarget::RequestId &id, |
74 | const QVariant &response, |
75 | bool emitRequestCompleted = true); |
76 | |
77 | void reportError(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id); |
78 | }; |
79 | |
80 | QT_END_NAMESPACE |
81 | |
82 | #endif // QNEARFIELDTARGET_P_H |
83 |