1/*
2 SPDX-FileCopyrightText: Pranav Gade <pranavgade20@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "ovspatchsetting.h"
8#include "ovspatchsetting_p.h"
9
10#include <QDebug>
11
12#if !NM_CHECK_VERSION(1, 10, 0)
13#define NM_SETTING_OVS_PATCH_SETTING_NAME "ovs-patch"
14#define NM_SETTING_OVS_PATCH_PEER "peer"
15#endif
16
17NetworkManager::OvsPatchSettingPrivate::OvsPatchSettingPrivate()
18 : name(NM_SETTING_OVS_PATCH_SETTING_NAME)
19{
20}
21
22NetworkManager::OvsPatchSetting::OvsPatchSetting()
23 : Setting(Setting::OvsPatch)
24 , d_ptr(new OvsPatchSettingPrivate())
25{
26}
27
28NetworkManager::OvsPatchSetting::OvsPatchSetting(const Ptr &other)
29 : Setting(other)
30 , d_ptr(new OvsPatchSettingPrivate())
31{
32 setPeer(other->peer());
33}
34
35NetworkManager::OvsPatchSetting::~OvsPatchSetting()
36{
37 delete d_ptr;
38}
39
40QString NetworkManager::OvsPatchSetting::name() const
41{
42 Q_D(const OvsPatchSetting);
43
44 return d->name;
45}
46
47void NetworkManager::OvsPatchSetting::setPeer(const QString &peer)
48{
49 Q_D(OvsPatchSetting);
50
51 d->peer = peer;
52}
53
54QString NetworkManager::OvsPatchSetting::peer() const
55{
56 Q_D(const OvsPatchSetting);
57
58 return d->peer;
59}
60
61void NetworkManager::OvsPatchSetting::fromMap(const QVariantMap &setting)
62{
63 if (setting.contains(key: QLatin1String(NM_SETTING_OVS_PATCH_PEER))) {
64 setPeer(setting.value(key: QLatin1String(NM_SETTING_OVS_PATCH_PEER)).toString());
65 }
66}
67
68QVariantMap NetworkManager::OvsPatchSetting::toMap() const
69{
70 QVariantMap setting;
71
72 if (!peer().isEmpty()) {
73 setting.insert(key: QLatin1String(NM_SETTING_OVS_PATCH_PEER), value: peer());
74 }
75
76 return setting;
77}
78
79QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::OvsPatchSetting &setting)
80{
81 dbg.nospace() << "type: " << setting.typeAsString(type: setting.type()) << '\n';
82 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
83
84 dbg.nospace() << NM_SETTING_OVS_PATCH_PEER << ": " << setting.peer() << '\n';
85
86 return dbg.maybeSpace();
87}
88

source code of networkmanager-qt/src/settings/ovspatchsetting.cpp