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
qnearfieldtarget.cpp
Go to the documentation of this file.
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#include "qnearfieldtarget.h"
6#include "qndefmessage.h"
7
8#include <QtCore/QString>
9#include <QtCore/QUrl>
10
11#include <QtCore/QDebug>
12
13#include <QCoreApplication>
14
16
18
19
137
145
153
160
165{
166 return d;
167}
168
173{
174 if (d)
175 return d->ref.loadRelaxed();
176
177 return 0;
178}
179
184{
185 return std::less<const RequestIdPrivate*>()(d.constData(), other.d.constData());
186}
187
192{
193 return d == other.d;
194}
195
200{
201 return d != other.d;
202}
203
212
220
225{
226 Q_D(QNearFieldTarget);
227
228 d->disconnect();
229}
230
240{
241 Q_D(const QNearFieldTarget);
242
243 return d->uid();
244}
245
250{
251 Q_D(const QNearFieldTarget);
252
253 return d->type();
254}
255
259QNearFieldTarget::AccessMethods QNearFieldTarget::accessMethods() const
260{
261 Q_D(const QNearFieldTarget);
262
263 return d->accessMethods();
264}
265
278{
279 Q_D(QNearFieldTarget);
280
281 return d->disconnect();
282}
283
289{
290 Q_D(QNearFieldTarget);
291
292 return d->hasNdefMessage();
293}
294
309{
310 Q_D(QNearFieldTarget);
311
312 return d->readNdefMessages();
313}
314
324{
325 Q_D(QNearFieldTarget);
326
327 return d->writeNdefMessages(messages);
328}
329
339{
340 Q_D(const QNearFieldTarget);
341
342 return d->maxCommandLength();
343}
344
359{
360 Q_D(QNearFieldTarget);
361
362 return d->sendCommand(command);
363}
364
371{
372 Q_D(QNearFieldTarget);
373
374 return d->waitForRequestCompleted(id, msecs);
375}
376
382{
383 Q_D(const QNearFieldTarget);
384
385 return d->requestResponse(id);
386}
387
392: QObject(parent), d_ptr(backend)
393{
394 Q_D(QNearFieldTarget);
395
396 d->q_ptr = this;
397 d->setParent(this);
398
399 qRegisterMetaType<QNearFieldTarget::RequestId>();
400 qRegisterMetaType<QNearFieldTarget::Error>();
401 qRegisterMetaType<QNdefMessage>();
402
411}
412
414
415#include "moc_qnearfieldtarget.cpp"
\inmodule QtCore
Definition qbytearray.h:57
void error(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id)
void ndefMessageRead(const QNdefMessage &message)
void requestCompleted(const QNearFieldTarget::RequestId &id)
\inmodule QtNfc \inheaderfile QNearFieldTarget
bool operator==(const RequestId &other) const
RequestId & operator=(const RequestId &other)
Assigns a copy of other to this request id and returns a reference to this request id.
bool isValid() const
Returns true if this is a valid request id; otherwise returns false.
~RequestId()
Destroys the request id handle.
int refCount() const
Returns the current reference count of the request id.
bool operator<(const RequestId &other) const
RequestId()
Constructs a new invalid request id handle.
bool operator!=(const RequestId &other) const
The QNearFieldTarget class provides an interface for communicating with a target device.
Type type() const
Returns the type of tag type of this near field target.
void error(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id)
This signal is emitted when an error occurs while processing request id.
bool waitForRequestCompleted(const RequestId &id, int msecs=5000)
Waits up to msecs milliseconds for the request id to complete.
bool hasNdefMessage()
Returns true if at least one NDEF message is stored on the near field target; otherwise returns false...
RequestId readNdefMessages()
Starts reading NDEF messages stored on the near field target.
Type
This enum describes the type of tag the target is detected as.
AccessMethods accessMethods() const
Returns the access methods supported by this near field target.
RequestId sendCommand(const QByteArray &command)
Sends command to the near field target.
QByteArray uid() const
Returns the UID of the near field target.
void requestCompleted(const QNearFieldTarget::RequestId &id)
This signal is emitted when a request id completes.
void disconnected()
This signal is emitted when the near field target moves out of proximity.
void ndefMessageRead(const QNdefMessage &message)
This signal is emitted when a complete NDEF message has been read from the target.
RequestId writeNdefMessages(const QList< QNdefMessage > &messages)
Writes the NDEF messages in messages to the target.
~QNearFieldTarget()
Destroys the near field target.
QNearFieldTarget(QObject *parent=nullptr)
Constructs a new near field target with parent.
QVariant requestResponse(const RequestId &id) const
Returns the decoded response for request id.
int maxCommandLength() const
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
\inmodule QtCore
Definition qvariant.h:65
#define this
Definition dialogs.cpp:9
Combined button and popup list for selecting options.
#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
Definition qmetatype.h:1384
GLfloat GLfloat p
[1]
QSharedPointer< T > other(t)
[5]