NetworkManagerQt

bridgeportsetting.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 "bridgeportsetting.h"
8#include "bridgeportsetting_p.h"
9
10#include <QDebug>
11
12NetworkManager::BridgePortSettingPrivate::BridgePortSettingPrivate()
13 : name(NM_SETTING_BRIDGE_PORT_SETTING_NAME)
14 , priority(32)
15 , pathCost(100)
16 , hairpinMode(false)
17{
18}
19
20NetworkManager::BridgePortSetting::BridgePortSetting()
21 : Setting(Setting::BridgePort)
22 , d_ptr(new BridgePortSettingPrivate())
23{
24}
25
26NetworkManager::BridgePortSetting::BridgePortSetting(const NetworkManager::BridgePortSetting::Ptr &other)
27 : Setting(other)
28 , d_ptr(new BridgePortSettingPrivate())
29{
30 setPriority(other->priority());
31 setPathCost(other->pathCost());
32 setHairpinMode(other->hairpinMode());
33}
34
35NetworkManager::BridgePortSetting::~BridgePortSetting()
36{
37 delete d_ptr;
38}
39
41{
43
44 return d->name;
45}
46
47void NetworkManager::BridgePortSetting::setPriority(quint32 priority)
48{
50
51 d->priority = priority;
52}
53
54quint32 NetworkManager::BridgePortSetting::priority() const
55{
56 Q_D(const BridgePortSetting);
57
58 return d->priority;
59}
60
61void NetworkManager::BridgePortSetting::setPathCost(quint32 cost)
62{
63 Q_D(BridgePortSetting);
64
65 d->pathCost = cost;
66}
67
68quint32 NetworkManager::BridgePortSetting::pathCost() const
69{
70 Q_D(const BridgePortSetting);
71
72 return d->pathCost;
73}
74
75void NetworkManager::BridgePortSetting::setHairpinMode(bool enable)
76{
77 Q_D(BridgePortSetting);
78
79 d->hairpinMode = enable;
80}
81
82bool NetworkManager::BridgePortSetting::hairpinMode() const
83{
84 Q_D(const BridgePortSetting);
85
86 return d->hairpinMode;
87}
88
89void NetworkManager::BridgePortSetting::fromMap(const QVariantMap &setting)
90{
91 if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_PORT_PRIORITY))) {
92 setPriority(setting.value(QLatin1String(NM_SETTING_BRIDGE_PORT_PRIORITY)).toUInt());
93 }
94
95 if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST))) {
96 setPathCost(setting.value(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST)).toUInt());
97 }
98
99 if (setting.contains(QLatin1String(NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE))) {
100 setHairpinMode(setting.value(QLatin1String(NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE)).toBool());
101 }
102}
103
105{
106 QVariantMap setting;
107
108 if (priority() != 32) {
109 setting.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PRIORITY), priority());
110 }
111
112 if (pathCost() != 100) {
113 setting.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST), pathCost());
114 }
115
116 if (hairpinMode()) {
117 setting.insert(QLatin1String(NM_SETTING_BRIDGE_PORT_PATH_COST), hairpinMode());
118 }
119
120 return setting;
121}
122
123QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::BridgePortSetting &setting)
124{
125 dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
126 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
127
128 dbg.nospace() << NM_SETTING_BRIDGE_PORT_PRIORITY << ": " << setting.priority() << '\n';
129 dbg.nospace() << NM_SETTING_BRIDGE_PORT_PATH_COST << ": " << setting.pathCost() << '\n';
130 dbg.nospace() << NM_SETTING_BRIDGE_PORT_PATH_COST << ": " << setting.hairpinMode() << '\n';
131
132 return dbg.maybeSpace();
133}
Represents bridge port setting.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
QDebug & maybeSpace()
QDebug & nospace()
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:21 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.