1/*
2 SPDX-FileCopyrightText: 2011 Lamarque V. Souza <lamarque@kde.org>
3 SPDX-FileCopyrightText: 2014 Jan Grulich <jgrulich@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#include "dhcp6config_p.h"
9#include "manager_p.h"
10#include "nmdebug.h"
11
12NetworkManager::Dhcp6ConfigPrivate::Dhcp6ConfigPrivate(const QString &path, Dhcp6Config *q)
13#ifdef NMQT_STATIC
14 : dhcp6Iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::sessionBus())
15#else
16 : dhcp6Iface(NetworkManagerPrivate::DBUS_SERVICE, path, QDBusConnection::systemBus())
17#endif
18 , path(path)
19 , q_ptr(q)
20{
21}
22
23NetworkManager::Dhcp6ConfigPrivate::~Dhcp6ConfigPrivate()
24{
25}
26
27NetworkManager::Dhcp6Config::Dhcp6Config(const QString &path, QObject *owner)
28 : d_ptr(new Dhcp6ConfigPrivate(path, this))
29{
30 Q_D(Dhcp6Config);
31 Q_UNUSED(owner);
32
33 QDBusConnection::systemBus().connect(service: NetworkManagerPrivate::DBUS_SERVICE,
34 path: d->path,
35 interface: NetworkManagerPrivate::FDO_DBUS_PROPERTIES,
36 name: QLatin1String("PropertiesChanged"),
37 receiver: d,
38 SLOT(dbusPropertiesChanged(QString, QVariantMap, QStringList)));
39
40 d->options = d->dhcp6Iface.options();
41}
42
43NetworkManager::Dhcp6Config::~Dhcp6Config()
44{
45 delete d_ptr;
46}
47
48QString NetworkManager::Dhcp6Config::path() const
49{
50 Q_D(const Dhcp6Config);
51 return d->path;
52}
53
54QVariantMap NetworkManager::Dhcp6Config::options() const
55{
56 Q_D(const Dhcp6Config);
57 return d->options;
58}
59
60QString NetworkManager::Dhcp6Config::optionValue(const QString &key) const
61{
62 Q_D(const Dhcp6Config);
63 QString value;
64 if (d->options.contains(key)) {
65 value = d->options.value(key).toString();
66 }
67 return value;
68}
69
70void NetworkManager::Dhcp6ConfigPrivate::dbusPropertiesChanged(const QString &interfaceName,
71 const QVariantMap &properties,
72 const QStringList &invalidatedProperties)
73{
74 Q_UNUSED(invalidatedProperties);
75 if (interfaceName == QLatin1String("org.freedesktop.NetworkManager.DHCP6Config")) {
76 dhcp6PropertiesChanged(properties);
77 }
78}
79
80void NetworkManager::Dhcp6ConfigPrivate::dhcp6PropertiesChanged(const QVariantMap &properties)
81{
82 Q_Q(Dhcp6Config);
83
84 QVariantMap::const_iterator it = properties.constBegin();
85 while (it != properties.constEnd()) {
86 const QString property = it.key();
87 if (property == QLatin1String("Options")) {
88 options = it.value().toMap();
89 Q_EMIT q->optionsChanged(options);
90 } else {
91 qCWarning(NMQT) << Q_FUNC_INFO << "Unhandled property" << property;
92 }
93 ++it;
94 }
95}
96
97#include "moc_dhcp6config.cpp"
98#include "moc_dhcp6config_p.cpp"
99

source code of networkmanager-qt/src/dhcp6config.cpp