Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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_p.h"
8
9
QT_BEGIN_NAMESPACE
10
11
Q_DECLARE_LOGGING_CATEGORY(QT_NFC_NEARD)
12
Q_GLOBAL_STATIC(NeardHelper, neardHelper)
13
14
using
namespace
QtNfcPrivate;
// for D-Bus wrappers
15
16
NeardHelper::NeardHelper(QObject *parent) :
17
QObject(parent)
18
{
19
qDBusRegisterMetaType<InterfaceList>();
20
qDBusRegisterMetaType<
ManagedObjectList
>();
21
22
m_dbusObjectManager =
new
OrgFreedesktopDBusObjectManagerInterface(QStringLiteral(
"org.neard"
),
23
QStringLiteral(
"/"
),
24
QDBusConnection::systemBus(),
25
this
);
26
if
(!m_dbusObjectManager->isValid()) {
27
qCCritical(QT_NFC_NEARD) <<
"dbus object manager invalid"
;
28
return
;
29
}
30
31
connect(m_dbusObjectManager, &OrgFreedesktopDBusObjectManagerInterface::InterfacesAdded,
32
this
, &NeardHelper::interfacesAdded);
33
connect(m_dbusObjectManager, &OrgFreedesktopDBusObjectManagerInterface::InterfacesRemoved,
34
this
, &NeardHelper::interfacesRemoved);
35
}
36
37
NeardHelper *NeardHelper::instance()
38
{
39
return
neardHelper();
40
}
41
42
OrgFreedesktopDBusObjectManagerInterface *NeardHelper::dbusObjectManager()
43
{
44
return
m_dbusObjectManager;
45
}
46
47
void
NeardHelper::interfacesAdded(
const
QDBusObjectPath &path, InterfaceList interfaceList)
48
{
49
const
QList<QString> keys = interfaceList.keys();
50
for
(
const
QString &key : keys) {
51
if
(key == QStringLiteral(
"org.neard.Tag"
)) {
52
emit tagFound(path);
53
break
;
54
}
55
if
(key == QStringLiteral(
"org.neard.Record"
)) {
56
emit recordFound(path);
57
break
;
58
}
59
}
60
}
61
62
void
NeardHelper::interfacesRemoved(
const
QDBusObjectPath &path,
const
QStringList &list)
63
{
64
if
(list.contains(QStringLiteral(
"org.neard.Record"
))) {
65
qCDebug(QT_NFC_NEARD) <<
"record removed"
<< path.path();
66
emit recordRemoved(path);
67
}
else
if
(list.contains(QStringLiteral(
"org.neard.Tag"
))) {
68
qCDebug(QT_NFC_NEARD) <<
"tag removed"
<< path.path();
69
emit tagRemoved(path);
70
}
71
}
72
73
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
ManagedObjectList
QMap< QDBusObjectPath, InterfaceList > ManagedObjectList
Definition
neard_dbus_types_p.h:23
qtconnectivity
src
nfc
neard
neard_helper.cpp
Generated on
for Qt by
1.18.0