16 m_tagPath(interfacePath),
17 m_readRequested(
false)
19 m_readErrorTimer.setSingleShot(
true);
20 m_recordPathsCollectedTimer.setSingleShot(
true);
21 m_delayedWriteTimer.setSingleShot(
true);
23 qCDebug(QT_NFC_NEARD) <<
"tag found at path" << interfacePath.path();
26 if (!m_dbusProperties->isValid()) {
27 qCWarning(QT_NFC_NEARD) <<
"Could not connect to dbus property interface at path"
28 << interfacePath.path();
32 QDBusPendingReply<QVariantMap>
reply = m_dbusProperties->GetAll(
QStringLiteral(
"org.neard.Tag"));
33 reply.waitForFinished();
34 if (
reply.isError()) {
35 qCWarning(QT_NFC_NEARD) <<
"Could not get properties of org.neard.Tag dbus interface";
54 this, &QNearFieldTargetPrivateImpl::createNdefMessage);
56 this, &QNearFieldTargetPrivateImpl::handleReadError);
58 this, &QNearFieldTargetPrivateImpl::handleWriteRequest);
60 this, &QNearFieldTargetPrivateImpl::handleRecordFound);
90 return !m_recordPaths.
isEmpty();
98 if (m_currentReadRequestId.
isValid())
99 return m_currentReadRequestId;
108 m_readRequested =
true;
112 m_readErrorTimer.
start(1000);
129 qWarning(
"QNearFieldTarget::WriteNdefMessages() disabled. See QTBUG-43802\n");
134 if (m_currentWriteRequestId.
isValid())
135 return m_currentWriteRequestId;
137 qCDebug(QT_NFC_NEARD) <<
"writing messages";
138 if (messages.isEmpty() || messages.first().isEmpty()) {
139 qCWarning(QT_NFC_NEARD) <<
"No record specified";
142 if (messages.count() > 1 || messages.first().count() > 1) {
144 qCWarning(QT_NFC_NEARD) <<
"Writing of only one NDEF record and message is supported";
150 m_currentWriteRequestData.
clear();
169 qCWarning(QT_NFC_NEARD) <<
"Record type not supported for writing";
175 m_delayedWriteTimer.
start(100);
177 return m_currentWriteRequestId;
185 qCDebug(QT_NFC_NEARD) <<
"reading record for path" <<
path.path();
188 if (!recordInterface.isValid())
191 QDBusPendingReply<QVariantMap>
reply = recordInterface.GetAll(
QStringLiteral(
"org.neard.Record"));
192 reply.waitForFinished();
208 textRecord.setLocale(locale);
214 if (!
value.isEmpty()) {
221 spRecord.setUri(
QUrl(uri));
235 spRecord.setSize(
size);
265 m_recordPathsCollectedTimer.
start(100);
267 m_readErrorTimer.
stop();
270void QNearFieldTargetPrivateImpl::createNdefMessage()
272 if (m_readRequested) {
273 qCDebug(QT_NFC_NEARD) <<
"creating Ndef message, reading" << m_recordPaths.
length() <<
"record paths";
276 newNdefMessage.
append(readRecord(recordPath));
278 if (!newNdefMessage.isEmpty()) {
289 m_readRequested =
false;
295void QNearFieldTargetPrivateImpl::handleReadError()
301void QNearFieldTargetPrivateImpl::handleWriteRequest()
305 if (!tagInterface.isValid()) {
306 qCWarning(QT_NFC_NEARD) <<
"tag interface invalid";
309 reply = tagInterface.Write(m_currentWriteRequestData);
310 reply.waitForFinished();
311 if (
reply.isError()) {
static NeardHelper * instance()
void recordFound(const QDBusObjectPath &)
bool isValid() const
Returns true if this is a valid reference to a remote object.
static QDBusConnection systemBus()
Returns a QDBusConnection object opened with the system bus.
QString path() const
Returns this object path.
bool isEmpty() const noexcept
qsizetype length() const noexcept
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
The QNdefMessage class provides an NFC NDEF message.
The QNdefNfcSmartPosterRecord class provides an NFC RTD-SmartPoster.
bool addTitle(const QNdefNfcTextRecord &text)
Attempts to add a title record text to the smart poster.
The QNdefNfcTextRecord class provides an NFC RTD-Text.
void setText(const QString text)
Sets the contents of the text record to text.
The QNdefNfcUriRecord class provides an NFC RTD-URI.
void setUri(const QUrl &uri)
Sets the URI of this URI record to uri.
The QNdefRecord class provides an NFC NDEF record.
QNearFieldTarget::RequestId writeNdefMessages(const QList< QNdefMessage > &messages) override
QNearFieldTarget::RequestId readNdefMessages() override
~QNearFieldTargetPrivateImpl() override
QNearFieldTarget::Type type() const override
QNearFieldTarget::RequestId sendCommand(const QByteArray &command) override
QNearFieldTarget::AccessMethods accessMethods() const override
bool hasNdefMessage() override
QByteArray uid() const override
void requestCompleted(const QNearFieldTarget::RequestId &id)
void reportError(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id)
\inmodule QtNfc \inheaderfile QNearFieldTarget
bool isValid() const
Returns true if this is a valid request id; otherwise returns false.
Type
This enum describes the type of tag the target is detected as.
NetworkError error() const
Returns the error that was found during the processing of this request.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
void stop()
Stops the timer.
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
list append(new Employee("Blackpool", "Stephen"))
Q_QML_EXPORT QV4::ReturnedValue locale(QV4::ExecutionEngine *engine, const QString &localeName)
Provides locale specific properties and formatted data.
Combined button and popup list for selecting options.
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
QNearFieldTarget::RequestId requestId
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
#define Q_ARG(Type, data)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei const GLchar *const * path
#define QStringLiteral(str)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)