7#include "adapter_interface.h"
8#include "properties_interface.h"
9#include "objectmanager_interface.h"
21 QDBusPendingReply<ManagedObjectList>
reply = m_neardHelper->dbusObjectManager()->GetManagedObjects();
22 reply.waitForFinished();
23 if (
reply.isError()) {
24 qCWarning(QT_NFC_NEARD) <<
"Error getting managed objects";
29 const QList<QDBusObjectPath>
paths =
reply.value().keys();
33 for (
const QString &iface : ifaces) {
36 m_adapterPath =
path.path();
37 qCDebug(QT_NFC_NEARD) <<
"org.neard.Adapter found for path" << m_adapterPath;
47 qCWarning(QT_NFC_NEARD) <<
"no adapter found, neard daemon running?";
50 this, &QNearFieldManagerPrivateImpl::handleTagFound);
52 this, &QNearFieldManagerPrivateImpl::handleTagRemoved);
64 qCWarning(QT_NFC_NEARD) <<
"dbus object manager invalid or adapter path invalid";
69 reply.waitForFinished();
70 if (
reply.isError()) {
71 qCWarning(QT_NFC_NEARD) <<
"error getting managed objects";
75 const QList<QDBusObjectPath>
paths =
reply.value().keys();
77 if (m_adapterPath ==
path.path())
87 qCWarning(QT_NFC_NEARD) <<
"no adapter found, neard daemon running?";
92 qCWarning(QT_NFC_NEARD) <<
"dbus object manager invalid or adapter path invalid";
101 qCDebug(QT_NFC_NEARD) <<
"starting target detection";
109 if (!dbusProperties.isValid()) {
110 qCWarning(QT_NFC_NEARD) <<
"dbus property interface invalid";
115 QDBusPendingReply<QDBusVariant> replyPolling = dbusProperties.Get(
QStringLiteral(
"org.neard.Adapter"),
117 replyPolling.waitForFinished();
118 if (!replyPolling.isError()) {
119 if (replyPolling.value().variant().toBool()) {
120 qCDebug(QT_NFC_NEARD) <<
"adapter is already polling";
124 qCWarning(QT_NFC_NEARD) <<
"error getting 'Polling' state from property interface";
129 QDBusPendingReply<QDBusVariant> replyPowered = dbusProperties.Get(
QStringLiteral(
"org.neard.Adapter"),
131 replyPowered.waitForFinished();
132 if (!replyPowered.isError()) {
133 if (replyPowered.value().variant().toBool()) {
134 qCDebug(QT_NFC_NEARD) <<
"adapter is already powered";
136 QDBusPendingReply<QDBusVariant> replyTryPowering = dbusProperties.Set(
QStringLiteral(
"org.neard.Adapter"),
139 replyTryPowering.waitForFinished();
140 if (!replyTryPowering.isError()) {
141 qCDebug(QT_NFC_NEARD) <<
"powering adapter";
145 qCWarning(QT_NFC_NEARD) <<
"error getting 'Powered' state from property interface";
150 OrgNeardAdapterInterface neardAdapter(
QStringLiteral(
"org.neard"),
157 if (replyPollLoop.isError()) {
158 qCWarning(QT_NFC_NEARD) <<
"error when starting polling";
161 qCDebug(QT_NFC_NEARD) <<
"successfully started polling";
169 qCDebug(QT_NFC_NEARD) <<
"stopping target detection";
177 if (!dbusProperties.isValid()) {
178 qCWarning(QT_NFC_NEARD) <<
"dbus property interface invalid";
183 QDBusPendingReply<QDBusVariant> replyPolling = dbusProperties.Get(
QStringLiteral(
"org.neard.Adapter"),
185 replyPolling.waitForFinished();
186 if (!replyPolling.isError()) {
187 if (replyPolling.value().variant().toBool()) {
189 OrgNeardAdapterInterface neardAdapter(
QStringLiteral(
"org.neard"),
195 if (replyStopPolling.isError())
196 qCWarning(QT_NFC_NEARD) <<
"error when stopping polling";
198 qCDebug(QT_NFC_NEARD) <<
"successfully stopped polling";
200 qCDebug(QT_NFC_NEARD) <<
"already stopped polling";
203 qCWarning(QT_NFC_NEARD) <<
"error getting 'Polling' state from property interface";
218 if (m_activeTags.
contains(adapterPath)) {
220 m_activeTags.
remove(adapterPath);
void tagRemoved(const QDBusObjectPath &)
OrgFreedesktopDBusObjectManagerInterface * dbusObjectManager()
void tagFound(const QDBusObjectPath &)
QDBusPendingReply< ManagedObjectList > GetManagedObjects()
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.
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
size_type remove(const Key &key)
bool isEnabled() const override
bool isSupported(QNearFieldTarget::AccessMethod accessMethod) const override
bool startTargetDetection(QNearFieldTarget::AccessMethod accessMethod) override
~QNearFieldManagerPrivateImpl() override
void stopTargetDetection(const QString &errorMessage) override
void targetDetected(QNearFieldTarget *target)
void targetLost(QNearFieldTarget *target)
The QNearFieldTarget class provides an interface for communicating with a target device.
AccessMethod
This enum describes the access methods a near field target supports.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
bool isNull() const
Returns true if this string is null; otherwise returns false.
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLsizei const GLuint * paths
GLsizei const GLchar *const * path
#define QStringLiteral(str)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)