Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qndefaccessfsm_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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 QNDEFACCESSFSM_P_H
5#define QNDEFACCESSFSM_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 "qndefmessage.h"
19
21
22/*
23 Base class for FSMs that can be used to exchange NDEF messages with cards.
24
25 The user may call one of these methods to start a task:
26
27 - detectNdefSupport()
28 - readMessages()
29 - writeMessages()
30
31 The user is then expected to perform actions indicated by Action type.
32*/
34{
35 Q_DISABLE_COPY_MOVE(QNdefAccessFsm)
36public:
37 QNdefAccessFsm() = default;
38 virtual ~QNdefAccessFsm() = default;
39
40 enum Action {
41 // The requested task has successfully completed. New tasks can be started.
43 // The requested task has failed. New tasks can be started.
45 // An NDEF message was successfully read. The user must call getMessage().
47 // The user's call was unexpected. The FSM may be in an invalid state.
49 // The user must call getCommand() and then send the returned command to the card.
51 // The user must call provideResponse() with the result of the last sent command.
53 };
54
55 /*
56 Returns a command to send to the card.
57
58 This method must be called if the FMS has requested SendCommand action.
59
60 Next action will be ProvideResponse or Unexpected.
61 */
62 virtual QByteArray getCommand(Action &nextAction) = 0;
63
64 /*
65 This method must be called by the user to provide response for
66 a completed command.
67
68 An empty QByteArray can be provided to indicate that the command
69 has failed.
70 */
71 virtual Action provideResponse(const QByteArray &response) = 0;
72
73 /*
74 Returns an NDEF message that was read from the card.
75
76 This method must be called if the FSM has requested GetMessage action.
77 */
78 virtual QNdefMessage getMessage(Action &nextAction) = 0;
79
80 /*
81 Start NDEF support detection.
82 */
84
85 /*
86 Start reading NDEF messages.
87
88 This call also performs NDEF support detection if it was not performed
89 earlier.
90 */
91 virtual Action readMessages() = 0;
92
93 /*
94 Start writing the given messages to the card.
95
96 This call also performs NDEF detection if is was not performed earlier.
97 */
98 virtual Action writeMessages(const QList<QNdefMessage> &messages) = 0;
99};
100
102
103#endif // QNDEFACCESSFSM_P_H
\inmodule QtCore
Definition qbytearray.h:57
QNdefAccessFsm()=default
virtual ~QNdefAccessFsm()=default
virtual QNdefMessage getMessage(Action &nextAction)=0
virtual Action readMessages()=0
virtual QByteArray getCommand(Action &nextAction)=0
virtual Action detectNdefSupport()=0
virtual Action provideResponse(const QByteArray &response)=0
virtual Action writeMessages(const QList< QNdefMessage > &messages)=0
The QNdefMessage class provides an NFC NDEF message.
Combined button and popup list for selecting options.