Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpcsccard_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 QPCSCCARD_P_H
5#define QPCSCCARD_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 "qpcsc_p.h"
19#include "qndefmessage.h"
21#include "ndef/qndefaccessfsm_p.h"
22
24
25class QTimer;
26
27class QPcscCard : public QObject
28{
30public:
32 ~QPcscCard();
33
34 bool isValid() const { return m_isValid; }
35 void invalidate();
36
37 bool checkCardPresent();
39
42
43 bool supportsNdef() const { return m_supportsNdef; }
44
45private:
46 SCARDHANDLE m_handle;
47 SCARD_IO_REQUEST m_ioPci;
48 bool m_isValid = true;
49 bool m_supportsNdef;
50 bool m_autodelete = false;
51 // Indicates that an _automatic_ transaction was started
52 bool m_inAutoTransaction = false;
53 QTimer *m_keepAliveTimer;
54
55 std::unique_ptr<QNdefAccessFsm> m_tagDetectionFsm;
56
57 enum AutoTransaction { NoAutoTransaction, StartAutoTransaction };
58
59 QPcsc::RawCommandResult sendCommand(const QByteArray &command, AutoTransaction autoTransaction);
60 void performNdefDetection();
61
62 class Transaction
63 {
64 public:
65 Transaction(QPcscCard *card);
66 ~Transaction();
67
68 private:
69 QPcscCard *m_card;
70 bool m_initiated = false;
71 };
72
73public Q_SLOTS:
75 void onTargetDestroyed();
76 void onSendCommandRequest(const QNearFieldTarget::RequestId &request,
77 const QByteArray &command);
78 void onReadNdefMessagesRequest(const QNearFieldTarget::RequestId &request);
79 void onWriteNdefMessagesRequest(const QNearFieldTarget::RequestId &request,
80 const QList<QNdefMessage> &messages);
81
82private Q_SLOTS:
83 void onKeepAliveTimeout();
84
88
89 void requestCompleted(const QNearFieldTarget::RequestId &request,
90 QNearFieldTarget::Error reason, const QVariant &result);
91 void ndefMessageRead(const QNdefMessage &message);
92};
93
94QT_END_NAMESPACE
95
96#endif // QPCSCCARD_P_H
void onReadNdefMessagesRequest(const QNearFieldTarget::RequestId &request)
void requestCompleted(const QNearFieldTarget::RequestId &request, QNearFieldTarget::Error reason, const QVariant &result)
bool supportsNdef() const
Definition qpcsccard_p.h:43
QByteArray readUid()
void invalidate()
bool isValid() const
Definition qpcsccard_p.h:34
void onTargetDestroyed()
bool checkCardPresent()
void onWriteNdefMessagesRequest(const QNearFieldTarget::RequestId &request, const QList< QNdefMessage > &messages)
void onSendCommandRequest(const QNearFieldTarget::RequestId &request, const QByteArray &command)
void ndefMessageRead(const QNdefMessage &message)
void invalidated()
int readMaxInputLength()
Q_INVOKABLE void enableAutodelete()