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 * \class NetworkManager::Setting
28 * \inheaderfile NetworkManagerQt/Setting
29 * \inmodule NetworkManagerQt
30 *
31 * \brief Base class for all kinds of setting.
32 */
33class NETWORKMANAGERQT_EXPORT Setting
34{
35public:
36 /*!
37 * \typedef NetworkManager::SerialSetting::Ptr
38 */
39 typedef QSharedPointer<Setting> Ptr;
40 /*!
41 * \typedef NetworkManager::SerialSetting::List
42 */
43 typedef QList<Ptr> List;
44 /*!
45 *
46 * \value Adsl
47 * \value Cdma
48 * \value Gsm
49 * \value Infiniband
50 * \value Ipv4
51 * \value Ipv6
52 * \value Ppp
53 * \value Pppoe
54 * \value Security8021x
55 * \value Serial
56 * \value Vpn
57 * \value Wired
58 * \value Wireless
59 * \value WirelessSecurity
60 * \value Bluetooth
61 * \value OlpcMesh
62 * \value Vlan
63 * \value Wimax
64 * \value Bond
65 * \value Bridge
66 * \value BridgePort
67 * \value Team
68 * \value Generic
69 * \value Tun
70 * \value Vxlan
71 * \value IpTunnel
72 * \value Proxy
73 * \value User
74 * \value OvsBridge
75 * \value OvsInterface
76 * \value OvsPatch
77 * \value OvsPort
78 * \value Match
79 * \value Tc
80 * \value TeamPort
81 * \value Macsec
82 * \value Dcb
83 * \value WireGuard
84 * \value[since 6.20] WifiP2P
85 */
86 enum SettingType {
87 Adsl,
88 Cdma,
89 Gsm,
90 Infiniband,
91 Ipv4,
92 Ipv6,
93 Ppp,
94 Pppoe,
95 Security8021x,
96 Serial,
97 Vpn,
98 Wired,
99 Wireless,
100 WirelessSecurity,
101 Bluetooth,
102 OlpcMesh,
103 Vlan,
104 Wimax,
105 Bond,
106 Bridge,
107 BridgePort,
108 Team,
109 Generic,
110 Tun,
111 Vxlan,
112 IpTunnel,
113 Proxy,
114 User,
115 OvsBridge,
116 OvsInterface,
117 OvsPatch,
118 OvsPort,
119 Match,
120 Tc,
121 TeamPort,
122 Macsec,
123 Dcb,
124 WireGuard,
125 WifiP2P,
126 };
127
128 /*!
129 *
130 * \value None
131 * \value AgentOwned
132 * \value NotSaved
133 * \value NotRequired
134 */
135 enum SecretFlagType {
136 None = 0,
137 AgentOwned = 0x01,
138 NotSaved = 0x02,
139 NotRequired = 0x04,
140 };
141 Q_DECLARE_FLAGS(SecretFlags, SecretFlagType)
142
143 /*!
144 *
145 * \value MacAddressRandomizationDefault
146 * \value MacAddressRandomizationNever
147 * \value MacAddressRandomizationAlways
148 */
149 enum MacAddressRandomization {
150 MacAddressRandomizationDefault = 0,
151 MacAddressRandomizationNever,
152 MacAddressRandomizationAlways,
153 };
154
155 /*!
156 */
157 static QString typeAsString(SettingType type);
158 /*!
159 */
160 static SettingType typeFromString(const QString &type);
161
162 /*!
163 */
164 explicit Setting(SettingType type);
165 /*!
166 */
167 explicit Setting(const Ptr &setting);
168 /*!
169 */
170 virtual ~Setting();
171
172 /*!
173 * \brief Must be reimplemented, default implementation does nothing.
174 */
175 virtual void fromMap(const QVariantMap &map);
176
177 /*!
178 * \brief Must be reimplemented, default implementationd does nothing.
179 */
180 virtual QVariantMap toMap() const;
181
182 /*!
183 */
184 virtual void secretsFromMap(const QVariantMap &map);
185
186 /*!
187 * \brief secretsFromStringMap is a convenience function
188 * to set the secrets from a map of strings.
189 * \a map to extract secrets from
190 */
191 virtual void secretsFromStringMap(const NMStringMap &map);
192
193 /*!
194 */
195 virtual QVariantMap secretsToMap() const;
196
197 /*!
198 * \brief secretsToStringMap is a convenience function
199 * to get the secrets to map of strings.
200 * Returns string map with current secrets
201 */
202 virtual NMStringMap secretsToStringMap() const;
203
204 /*!
205 */
206 virtual QStringList needSecrets(bool requestNew = false) const;
207
208 /*!
209 * \brief Must be reimplemented, default implementationd does nothing.
210 */
211 virtual QString name() const;
212
213 /*!
214 */
215 void setInitialized(bool initialized);
216
217 /*!
218 */
219 bool isNull() const;
220
221 /*!
222 */
223 void setType(SettingType type);
224 /*!
225 */
226 SettingType type() const;
227
228protected:
229 SettingPrivate *d_ptr;
230
231private:
232 Q_DECLARE_PRIVATE(Setting)
233};
234Q_DECLARE_OPERATORS_FOR_FLAGS(Setting::SecretFlags)
235
236NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Setting &setting);
237
238}
239
240#endif // NETWORKMANAGERQT_SETTING_H
241

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