1/*
2 SPDX-FileCopyrightText: 2012-2019 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#ifndef NETWORKMANAGERQT_SETTING_H
8#define NETWORKMANAGERQT_SETTING_H
9
10#include <networkmanagerqt/networkmanagerqt_export.h>
11
12#include "generictypes.h"
13
14#undef signals
15#include <libnm/NetworkManager.h>
16#define signals Q_SIGNALS
17
18#include <QSharedPointer>
19#include <QStringList>
20#include <QVariantMap>
21
22namespace NetworkManager
23{
24class SettingPrivate;
25
26/**
27 * Base class for all kinds of setting
28 */
29class NETWORKMANAGERQT_EXPORT Setting
30{
31public:
32 typedef QSharedPointer<Setting> Ptr;
33 typedef QList<Ptr> List;
34 enum SettingType {
35 Adsl,
36 Cdma,
37 Gsm,
38 Infiniband,
39 Ipv4,
40 Ipv6,
41 Ppp,
42 Pppoe,
43 Security8021x,
44 Serial,
45 Vpn,
46 Wired,
47 Wireless,
48 WirelessSecurity,
49 Bluetooth,
50 OlpcMesh,
51 Vlan,
52 Wimax,
53 Bond,
54 Bridge,
55 BridgePort,
56 Team,
57 Generic,
58 Tun,
59 Vxlan,
60 IpTunnel,
61 Proxy,
62 User,
63 OvsBridge,
64 OvsInterface,
65 OvsPatch,
66 OvsPort,
67 Match,
68 Tc,
69 TeamPort,
70 Macsec,
71 Dcb,
72 WireGuard,
73 };
74
75 enum SecretFlagType {
76 None = 0,
77 AgentOwned = 0x01,
78 NotSaved = 0x02,
79 NotRequired = 0x04,
80 };
81 Q_DECLARE_FLAGS(SecretFlags, SecretFlagType)
82
83 enum MacAddressRandomization {
84 MacAddressRandomizationDefault = 0,
85 MacAddressRandomizationNever,
86 MacAddressRandomizationAlways,
87 };
88
89 static QString typeAsString(SettingType type);
90 static SettingType typeFromString(const QString &type);
91
92 explicit Setting(SettingType type);
93 explicit Setting(const Ptr &setting);
94 virtual ~Setting();
95
96 /**
97 * @brief Must be reimplemented, default implementation does nothing
98 */
99 virtual void fromMap(const QVariantMap &map);
100
101 /**
102 * @brief Must be reimplemented, default implementationd does nothing
103 */
104 virtual QVariantMap toMap() const;
105
106 virtual void secretsFromMap(const QVariantMap &map);
107
108 /**
109 * @brief secretsFromStringMap is a convenience function
110 * to set the secrets from a map of strings.
111 * @param map to extract secrets from
112 */
113 virtual void secretsFromStringMap(const NMStringMap &map);
114
115 virtual QVariantMap secretsToMap() const;
116
117 /**
118 * @brief secretsToStringMap is a convenience function
119 * to get the secrets to map of strings.
120 * @return string map with current secrets
121 */
122 virtual NMStringMap secretsToStringMap() const;
123
124 virtual QStringList needSecrets(bool requestNew = false) const;
125
126 /**
127 * @brief Must be reimplemented, default implementationd does nothing
128 */
129 virtual QString name() const;
130
131 void setInitialized(bool initialized);
132
133 bool isNull() const;
134
135 void setType(SettingType type);
136 SettingType type() const;
137
138protected:
139 SettingPrivate *d_ptr;
140
141private:
142 Q_DECLARE_PRIVATE(Setting)
143};
144Q_DECLARE_OPERATORS_FOR_FLAGS(Setting::SecretFlags)
145
146NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Setting &setting);
147
148}
149
150#endif // NETWORKMANAGERQT_SETTING_H
151

source code of networkmanager-qt/src/settings/setting.h