NetworkManagerQt

olpcmeshsetting.cpp
1/*
2 SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "olpcmeshsetting.h"
8#include "olpcmeshsetting_p.h"
9
10#include <QDebug>
11
12NetworkManager::OlpcMeshSettingPrivate::OlpcMeshSettingPrivate()
13 : name(NM_SETTING_OLPC_MESH_SETTING_NAME)
14 , channel(0)
15{
16}
17
18NetworkManager::OlpcMeshSetting::OlpcMeshSetting()
19 : Setting(Setting::Bond)
20 , d_ptr(new OlpcMeshSettingPrivate())
21{
22}
23
24NetworkManager::OlpcMeshSetting::OlpcMeshSetting(const Ptr &other)
25 : Setting(other)
26 , d_ptr(new OlpcMeshSettingPrivate())
27{
28 setSsid(other->ssid());
29 setChannel(other->channel());
30 setDhcpAnycastAddress(other->dhcpAnycastAddress());
31}
32
33NetworkManager::OlpcMeshSetting::~OlpcMeshSetting()
34{
35 delete d_ptr;
36}
37
39{
40 Q_D(const OlpcMeshSetting);
41
42 return d->name;
43}
44
45void NetworkManager::OlpcMeshSetting::setSsid(const QByteArray &ssid)
46{
48
49 d->ssid = ssid;
50}
51
52QByteArray NetworkManager::OlpcMeshSetting::ssid() const
53{
54 Q_D(const OlpcMeshSetting);
55
56 return d->ssid;
57}
58
59void NetworkManager::OlpcMeshSetting::setChannel(quint32 channel)
60{
61 Q_D(OlpcMeshSetting);
62
63 d->channel = channel;
64}
65
66quint32 NetworkManager::OlpcMeshSetting::channel() const
67{
68 Q_D(const OlpcMeshSetting);
69
70 return d->channel;
71}
72
73void NetworkManager::OlpcMeshSetting::setDhcpAnycastAddress(const QByteArray &address)
74{
75 Q_D(OlpcMeshSetting);
76
77 d->dhcpAnycastAddress = address;
78}
79
80QByteArray NetworkManager::OlpcMeshSetting::dhcpAnycastAddress() const
81{
82 Q_D(const OlpcMeshSetting);
83
84 return d->dhcpAnycastAddress;
85}
86
87void NetworkManager::OlpcMeshSetting::fromMap(const QVariantMap &setting)
88{
89 if (setting.contains(QLatin1String(NM_SETTING_OLPC_MESH_SSID))) {
90 setSsid(setting.value(QLatin1String(NM_SETTING_OLPC_MESH_SSID)).toByteArray());
91 }
92
93 if (setting.contains(QLatin1String(NM_SETTING_OLPC_MESH_CHANNEL))) {
94 setChannel(setting.value(QLatin1String(NM_SETTING_OLPC_MESH_CHANNEL)).toUInt());
95 }
96
97 if (setting.contains(QLatin1String(NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS))) {
98 setDhcpAnycastAddress(setting.value(QLatin1String(NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS)).toByteArray());
99 }
100}
101
103{
104 QVariantMap setting;
105
106 if (!ssid().isEmpty()) {
107 setting.insert(QLatin1String(NM_SETTING_OLPC_MESH_SSID), ssid());
108 }
109
110 if (channel()) {
111 setting.insert(QLatin1String(NM_SETTING_OLPC_MESH_CHANNEL), channel());
112 }
113
114 if (!dhcpAnycastAddress().isEmpty()) {
115 setting.insert(QLatin1String(NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS), dhcpAnycastAddress());
116 }
117
118 return setting;
119}
120
121QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::OlpcMeshSetting &setting)
122{
123 dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
124 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
125
126 dbg.nospace() << NM_SETTING_OLPC_MESH_SSID << ": " << setting.ssid() << '\n';
127 dbg.nospace() << NM_SETTING_OLPC_MESH_CHANNEL << ": " << setting.channel() << '\n';
128 dbg.nospace() << NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS << ": " << setting.dhcpAnycastAddress() << '\n';
129
130 return dbg.maybeSpace();
131}
Represents olpc mesh setting.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
PostalAddress address(const QVariant &location)
QDebug & maybeSpace()
QDebug & nospace()
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:00:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.