NetworkManagerQt

vlansetting.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 "vlansetting.h"
8#include "vlansetting_p.h"
9
10// define the deprecated&dropped values
11#define NM_SETTING_VLAN_INTERFACE_NAME "interface-name"
12
13#include <QDebug>
14
15NetworkManager::VlanSettingPrivate::VlanSettingPrivate()
16 : name(NM_SETTING_VLAN_SETTING_NAME)
17 , id(0)
18 , flags(VlanSetting::None)
19{
20}
21
22NetworkManager::VlanSetting::VlanSetting()
23 : Setting(Setting::Vlan)
24 , d_ptr(new VlanSettingPrivate())
25{
26}
27
28NetworkManager::VlanSetting::VlanSetting(const Ptr &other)
29 : Setting(other)
30 , d_ptr(new VlanSettingPrivate())
31{
32 setInterfaceName(other->interfaceName());
33 setParent(other->parent());
34 setId(other->id());
35 setFlags(other->flags());
36 setIngressPriorityMap(other->ingressPriorityMap());
37 setEgressPriorityMap(other->egressPriorityMap());
38}
39
40NetworkManager::VlanSetting::~VlanSetting()
41{
42 delete d_ptr;
43}
44
46{
47 Q_D(const VlanSetting);
48
49 return d->name;
50}
51
53{
55
56 d->interfaceName = name;
57}
58
59QString NetworkManager::VlanSetting::interfaceName() const
60{
61 Q_D(const VlanSetting);
62
63 return d->interfaceName;
64}
65
66void NetworkManager::VlanSetting::setParent(const QString &parent)
67{
68 Q_D(VlanSetting);
69
70 d->parent = parent;
71}
72
73QString NetworkManager::VlanSetting::parent() const
74{
75 Q_D(const VlanSetting);
76
77 return d->parent;
78}
79
80void NetworkManager::VlanSetting::setId(quint32 id)
81{
82 Q_D(VlanSetting);
83
84 d->id = id;
85}
86
87quint32 NetworkManager::VlanSetting::id() const
88{
89 Q_D(const VlanSetting);
90
91 return d->id;
92}
93
94void NetworkManager::VlanSetting::setFlags(NetworkManager::VlanSetting::Flags flags)
95{
96 Q_D(VlanSetting);
97
98 d->flags = flags;
99}
100
101NetworkManager::VlanSetting::Flags NetworkManager::VlanSetting::flags() const
102{
103 Q_D(const VlanSetting);
104
105 return d->flags;
106}
107
108void NetworkManager::VlanSetting::setIngressPriorityMap(const QStringList &map)
109{
110 Q_D(VlanSetting);
111
112 d->ingressPriorityMap = map;
113}
114
115QStringList NetworkManager::VlanSetting::ingressPriorityMap() const
116{
117 Q_D(const VlanSetting);
118
119 return d->ingressPriorityMap;
120}
121
122void NetworkManager::VlanSetting::setEgressPriorityMap(const QStringList &map)
123{
124 Q_D(VlanSetting);
125
126 d->egressPriorityMap = map;
127}
128
129QStringList NetworkManager::VlanSetting::egressPriorityMap() const
130{
131 Q_D(const VlanSetting);
132
133 return d->egressPriorityMap;
134}
135
136void NetworkManager::VlanSetting::fromMap(const QVariantMap &setting)
137{
138 if (setting.contains(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME))) {
139 setInterfaceName(setting.value(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME)).toString());
140 }
141
142 if (setting.contains(QLatin1String(NM_SETTING_VLAN_PARENT))) {
143 setParent(setting.value(QLatin1String(NM_SETTING_VLAN_PARENT)).toString());
144 }
145
146 if (setting.contains(QLatin1String(NM_SETTING_VLAN_ID))) {
147 setId(setting.value(QLatin1String(NM_SETTING_VLAN_ID)).toUInt());
148 }
149
150 if (setting.contains(QLatin1String(NM_SETTING_VLAN_FLAGS))) {
151 setFlags((Flag)setting.value(QLatin1String(NM_SETTING_VLAN_FLAGS)).toUInt());
152 }
153
154 if (setting.contains(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP))) {
155 setIngressPriorityMap(setting.value(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP)).toStringList());
156 }
157
158 if (setting.contains(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP))) {
159 setEgressPriorityMap(setting.value(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP)).toStringList());
160 }
161}
162
164{
165 QVariantMap setting;
166
167 if (!interfaceName().isEmpty()) {
168 setting.insert(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME), interfaceName());
169 }
170
171 if (!parent().isEmpty()) {
172 setting.insert(QLatin1String(NM_SETTING_VLAN_PARENT), parent());
173 }
174
175 if (id()) {
176 setting.insert(QLatin1String(NM_SETTING_VLAN_ID), id());
177 }
178
179 if (flags() != None) {
180 setting.insert(QLatin1String(NM_SETTING_VLAN_FLAGS), (int)flags());
181 }
182
183 if (!ingressPriorityMap().isEmpty()) {
184 setting.insert(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP), ingressPriorityMap());
185 }
186
187 if (!egressPriorityMap().isEmpty()) {
188 setting.insert(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP), egressPriorityMap());
189 }
190
191 return setting;
192}
193
194QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::VlanSetting &setting)
195{
196 dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
197 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
198
199 dbg.nospace() << NM_SETTING_VLAN_INTERFACE_NAME << ": " << setting.interfaceName() << '\n';
200 dbg.nospace() << NM_SETTING_VLAN_PARENT << ": " << setting.parent() << '\n';
201 dbg.nospace() << NM_SETTING_VLAN_ID << ": " << setting.id() << '\n';
202 dbg.nospace() << NM_SETTING_VLAN_FLAGS << ": " << setting.flags() << '\n';
203 dbg.nospace() << NM_SETTING_VLAN_INGRESS_PRIORITY_MAP << ": " << setting.ingressPriorityMap() << '\n';
204 dbg.nospace() << NM_SETTING_VLAN_EGRESS_PRIORITY_MAP << ": " << setting.egressPriorityMap() << '\n';
205
206 return dbg.maybeSpace();
207}
Represents vlan setting.
Definition vlansetting.h:23
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
void setInterfaceName(const QString &name)
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
KCRASH_EXPORT void setFlags(KCrash::CrashFlags flags)
QDebug & maybeSpace()
QDebug & nospace()
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:01:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.