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 "ovsinterfacesetting.h" |
8 | #include "ovsinterfacesetting_p.h" |
9 | |
10 | #include <QDebug> |
11 | |
12 | #if !NM_CHECK_VERSION(1, 10, 0) |
13 | #define NM_SETTING_OVS_INTERFACE_SETTING_NAME "ovs-interface" |
14 | #define NM_SETTING_OVS_INTERFACE_TYPE "type" |
15 | #endif |
16 | |
17 | NetworkManager::OvsInterfaceSettingPrivate::OvsInterfaceSettingPrivate() |
18 | : name(NM_SETTING_OVS_INTERFACE_SETTING_NAME) |
19 | { |
20 | } |
21 | |
22 | NetworkManager::OvsInterfaceSetting::OvsInterfaceSetting() |
23 | : Setting(Setting::OvsInterface) |
24 | , d_ptr(new OvsInterfaceSettingPrivate()) |
25 | { |
26 | } |
27 | |
28 | NetworkManager::OvsInterfaceSetting::OvsInterfaceSetting(const Ptr &other) |
29 | : Setting(other) |
30 | , d_ptr(new OvsInterfaceSettingPrivate()) |
31 | { |
32 | setInterfaceType(other->interfaceType()); |
33 | } |
34 | |
35 | NetworkManager::OvsInterfaceSetting::~OvsInterfaceSetting() |
36 | { |
37 | delete d_ptr; |
38 | } |
39 | |
40 | QString NetworkManager::OvsInterfaceSetting::name() const |
41 | { |
42 | Q_D(const OvsInterfaceSetting); |
43 | |
44 | return d->name; |
45 | } |
46 | |
47 | void NetworkManager::OvsInterfaceSetting::setInterfaceType(const QString &type) |
48 | { |
49 | Q_D(OvsInterfaceSetting); |
50 | |
51 | d->type = type; |
52 | } |
53 | |
54 | QString NetworkManager::OvsInterfaceSetting::interfaceType() const |
55 | { |
56 | Q_D(const OvsInterfaceSetting); |
57 | |
58 | return d->type; |
59 | } |
60 | |
61 | void NetworkManager::OvsInterfaceSetting::fromMap(const QVariantMap &setting) |
62 | { |
63 | if (setting.contains(key: QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE))) { |
64 | setInterfaceType(setting.value(key: QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE)).toString()); |
65 | } |
66 | } |
67 | |
68 | QVariantMap NetworkManager::OvsInterfaceSetting::toMap() const |
69 | { |
70 | QVariantMap setting; |
71 | |
72 | if (!interfaceType().isEmpty()) { |
73 | setting.insert(key: QLatin1String(NM_SETTING_OVS_INTERFACE_TYPE), value: interfaceType()); |
74 | } |
75 | |
76 | return setting; |
77 | } |
78 | |
79 | QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::OvsInterfaceSetting &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_INTERFACE_TYPE << ": "<< setting.type() << '\n'; |
85 | |
86 | return dbg.maybeSpace(); |
87 | } |
88 |