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
neard_helper.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 BasysKom GmbH.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include <QDBusMetaType>
6#include "neard_helper_p.h"
7#include "objectmanager_interface.h"
8
10
12Q_GLOBAL_STATIC(NeardHelper, neardHelper)
13
15 QObject(parent)
16{
17 qDBusRegisterMetaType<InterfaceList>();
18 qDBusRegisterMetaType<ManagedObjectList>();
19
20 m_dbusObjectManager = new OrgFreedesktopDBusObjectManagerInterface(QStringLiteral("org.neard"),
21 QStringLiteral("/"),
23 this);
24 if (!m_dbusObjectManager->isValid()) {
25 qCCritical(QT_NFC_NEARD) << "dbus object manager invalid";
26 return;
27 }
28
30 this, &NeardHelper::interfacesAdded);
32 this, &NeardHelper::interfacesRemoved);
33}
34
36{
37 return neardHelper();
38}
39
44
45void NeardHelper::interfacesAdded(const QDBusObjectPath &path, InterfaceList interfaceList)
46{
47 const QList<QString> keys = interfaceList.keys();
48 for (const QString &key : keys) {
49 if (key == QStringLiteral("org.neard.Tag")) {
51 break;
52 }
53 if (key == QStringLiteral("org.neard.Record")) {
55 break;
56 }
57 }
58}
59
60void NeardHelper::interfacesRemoved(const QDBusObjectPath &path, const QStringList &list)
61{
62 if (list.contains(QStringLiteral("org.neard.Record"))) {
63 qCDebug(QT_NFC_NEARD) << "record removed" << path.path();
65 } else if (list.contains(QStringLiteral("org.neard.Tag"))) {
66 qCDebug(QT_NFC_NEARD) << "tag removed" << path.path();
68 }
69}
70
void tagRemoved(const QDBusObjectPath &)
static NeardHelper * instance()
OrgFreedesktopDBusObjectManagerInterface * dbusObjectManager()
void recordFound(const QDBusObjectPath &)
void tagFound(const QDBusObjectPath &)
void recordRemoved(const QDBusObjectPath &)
void InterfacesAdded(const QDBusObjectPath &object_path, InterfaceList interfaces_and_properties)
void InterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces)
static QDBusConnection systemBus()
Returns a QDBusConnection object opened with the system bus.
\inmodule QtDBus
Definition qmap.h:187
QList< Key > keys() const
Definition qmap.h:383
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qCCritical(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLuint64 key
GLsizei const GLchar *const * path
#define QStringLiteral(str)
#define emit
QList< int > list
[14]
QStringList keys
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
bool contains(const AT &t) const noexcept
Definition qlist.h:45