Debian Codegraph @

autotests/fakebluez/object.cpp

raw
1 /*
2 * SPDX-FileCopyrightText: 2014-2015 David Rosca <[email protected]>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6
7 #include "object.h"
8
9 #include <QDBusConnection>
10 #include <QDBusMessage>
11
12 Object::Object()
13 : m_parent(nullptr)
14 {
15 }
16
17 QObject *Object::objectParent() const
18 {
19 return m_parent;
20 }
21
22 void Object::setObjectParent(QObject *parent)
23 {
24 m_parent = parent;
25 }
26
27 QDBusObjectPath Object::path() const
28 {
29 return m_path;
30 }
31
32 void Object::setPath(const QDBusObjectPath &path)
33 {
34 m_path = path;
35 }
36
37 QString Object::name() const
38 {
39 return m_name;
40 }
41
42 void Object::setName(const QString &name)
43 {
44 m_name = name;
45 }
46
47 bool Object::haveProperties() const
48 {
49 return !m_properties.isEmpty();
50 }
51
52 QVariantMap Object::properties() const
53 {
54 return m_properties;
55 }
56
57 void Object::setProperties(const QVariantMap &properties)
58 {
59 m_properties = properties;
60 }
61
62 QVariant Object::property(const QString &name) const
63 {
64 return m_properties.value(name);
65 }
66
67 void Object::changeProperty(const QString &name, const QVariant &value)
68 {
69 if (m_properties.value(name) == value) {
70 return;
71 }
72
73 QVariantMap updatedProperties;
74 updatedProperties[name] = value;
75
76 m_properties[name] = value;
77
78 QDBusMessage signal = QDBusMessage::createSignal(m_path.path(), QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"));
79 signal << m_name;
80 signal << updatedProperties;
81 signal << QStringList();
82 QDBusConnection::sessionBus().send(signal);
83 }