7#include "teamportsetting.h"
8#include "teamportsetting_p.h"
12#if !NM_CHECK_VERSION(1, 10, 0)
13#define NM_SETTING_TEAM_PORT_SETTING_NAME "team-port"
15#define NM_SETTING_TEAM_PORT_CONFIG "config"
16#define NM_SETTING_TEAM_PORT_QUEUE_ID "queue-id"
17#define NM_SETTING_TEAM_PORT_PRIO "prio"
18#define NM_SETTING_TEAM_PORT_STICKY "sticky"
19#define NM_SETTING_TEAM_PORT_LACP_PRIO "lacp-prio"
20#define NM_SETTING_TEAM_PORT_LACP_KEY "lacp-key"
21#define NM_SETTING_TEAM_PORT_LINK_WATCHERS "link-watchers"
24NetworkManager::TeamPortSettingPrivate::TeamPortSettingPrivate()
25 : name(NM_SETTING_TEAM_PORT_SETTING_NAME)
34NetworkManager::TeamPortSetting::TeamPortSetting()
35 : Setting(Setting::TeamPort)
36 , d_ptr(new TeamPortSettingPrivate())
40NetworkManager::TeamPortSetting::TeamPortSetting(
const Ptr &other)
42 , d_ptr(new TeamPortSettingPrivate())
44 config(other->config());
45 lacpKey(other->lacpKey());
46 lacpPrio(other->lacpPrio());
48 queueId(other->queueId());
49 sticky(other->sticky());
50 setLinkWatchers(other->linkWatchers());
53NetworkManager::TeamPortSetting::~TeamPortSetting()
65void NetworkManager::TeamPortSetting::config(
const QString &config)
72QString NetworkManager::TeamPortSetting::config()
const
74 Q_D(
const TeamPortSetting);
79void NetworkManager::TeamPortSetting::lacpKey(qint32 key)
86qint32 NetworkManager::TeamPortSetting::lacpKey()
const
88 Q_D(
const TeamPortSetting);
93void NetworkManager::TeamPortSetting::lacpPrio(qint32 priority)
97 d->lacpPrio = priority;
100qint32 NetworkManager::TeamPortSetting::lacpPrio()
const
102 Q_D(
const TeamPortSetting);
107void NetworkManager::TeamPortSetting::prio(qint32 prio)
109 Q_D(TeamPortSetting);
114qint32 NetworkManager::TeamPortSetting::prio()
const
116 Q_D(
const TeamPortSetting);
121void NetworkManager::TeamPortSetting::queueId(qint32
id)
123 Q_D(TeamPortSetting);
128qint32 NetworkManager::TeamPortSetting::queueId()
const
130 Q_D(
const TeamPortSetting);
135void NetworkManager::TeamPortSetting::sticky(
bool sticky)
137 Q_D(TeamPortSetting);
142bool NetworkManager::TeamPortSetting::sticky()
const
144 Q_D(
const TeamPortSetting);
149void NetworkManager::TeamPortSetting::setLinkWatchers(
const NMVariantMapList &linkWatchers)
151 Q_D(TeamPortSetting);
153 d->linkWatchers = linkWatchers;
158 Q_D(
const TeamPortSetting);
160 return d->linkWatchers;
165 if (setting.contains(
QLatin1String(NM_SETTING_TEAM_PORT_CONFIG))) {
166 config(setting.value(
QLatin1String(NM_SETTING_TEAM_PORT_CONFIG)).toString());
169 if (setting.contains(
QLatin1String(NM_SETTING_TEAM_PORT_LACP_KEY))) {
170 lacpKey(setting.value(
QLatin1String(NM_SETTING_TEAM_PORT_LACP_KEY)).toUInt());
173 if (setting.contains(
QLatin1String(NM_SETTING_TEAM_PORT_LACP_PRIO))) {
174 lacpPrio(setting.value(
QLatin1String(NM_SETTING_TEAM_PORT_LACP_PRIO)).toUInt());
177 if (setting.contains(
QLatin1String(NM_SETTING_TEAM_PORT_PRIO))) {
178 prio(setting.value(
QLatin1String(NM_SETTING_TEAM_PORT_PRIO)).toUInt());
181 if (setting.contains(
QLatin1String(NM_SETTING_TEAM_PORT_QUEUE_ID))) {
182 queueId(setting.value(
QLatin1String(NM_SETTING_TEAM_PORT_QUEUE_ID)).toUInt());
185 if (setting.contains(
QLatin1String(NM_SETTING_TEAM_PORT_STICKY))) {
186 sticky(setting.value(
QLatin1String(NM_SETTING_TEAM_PORT_STICKY)).toBool());
189 if (setting.contains(
QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS))) {
190 setLinkWatchers(qdbus_cast<NMVariantMapList>(setting.value(
QLatin1String(NM_SETTING_TEAM_PORT_LINK_WATCHERS))));
198 if (!config().isEmpty()) {
199 setting.insert(
QLatin1String(NM_SETTING_TEAM_PORT_CONFIG), config());
202 if (lacpKey() != 0) {
203 setting.insert(
QLatin1String(NM_SETTING_TEAM_PORT_LACP_KEY), lacpKey());
206 if (lacpPrio() != 255) {
207 setting.insert(
QLatin1String(NM_SETTING_TEAM_PORT_LACP_PRIO), lacpPrio());
211 setting.insert(
QLatin1String(NM_SETTING_TEAM_PORT_PRIO), prio());
214 if (queueId() != -1) {
215 setting.insert(
QLatin1String(NM_SETTING_TEAM_PORT_QUEUE_ID), queueId());
219 setting.insert(
QLatin1String(NM_SETTING_TEAM_PORT_STICKY), sticky());
222 if (!linkWatchers().empty()) {
231 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
232 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
234 dbg.
nospace() << NM_SETTING_TEAM_PORT_CONFIG <<
": " << setting.config() <<
'\n';
235 dbg.
nospace() << NM_SETTING_TEAM_PORT_LACP_KEY <<
": " << setting.lacpKey() <<
'\n';
236 dbg.
nospace() << NM_SETTING_TEAM_PORT_LACP_PRIO <<
": " << setting.lacpPrio() <<
'\n';
237 dbg.
nospace() << NM_SETTING_TEAM_PORT_PRIO <<
": " << setting.prio() <<
'\n';
238 dbg.
nospace() << NM_SETTING_TEAM_PORT_QUEUE_ID <<
": " << setting.queueId() <<
'\n';
239 dbg.
nospace() << NM_SETTING_TEAM_PORT_STICKY <<
": " << setting.sticky() <<
'\n';
241 dbg.
nospace() << NM_SETTING_TEAM_PORT_LINK_WATCHERS <<
": " <<
'\n';
243 for (
const QVariantMap &linkWatcher : variantMapList) {
244 QVariantMap::const_iterator i = linkWatcher.constBegin();
245 while (i != linkWatcher.constEnd()) {
246 dbg.
nospace() << i.key() <<
": " << i.value() <<
'\n';
Represents TeamPort setting.
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QVariant fromValue(T &&value)