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 */
85 enum SettingType {
86 Adsl,
87 Cdma,
88 Gsm,
89 Infiniband,
90 Ipv4,
91 Ipv6,
92 Ppp,
93 Pppoe,
94 Security8021x,
95 Serial,
96 Vpn,
97 Wired,
98 Wireless,
99 WirelessSecurity,
100 Bluetooth,
101 OlpcMesh,
102 Vlan,
103 Wimax,
104 Bond,
105 Bridge,
106 BridgePort,
107 Team,
108 Generic,
109 Tun,
110 Vxlan,
111 IpTunnel,
112 Proxy,
113 User,
114 OvsBridge,
115 OvsInterface,
116 OvsPatch,
117 OvsPort,
118 Match,
119 Tc,
120 TeamPort,
121 Macsec,
122 Dcb,
123 WireGuard,
124 };
125
126 /*!
127 *
128 * \value None
129 * \value AgentOwned
130 * \value NotSaved
131 * \value NotRequired
132 */
133 enum SecretFlagType {
134 None = 0,
135 AgentOwned = 0x01,
136 NotSaved = 0x02,
137 NotRequired = 0x04,
138 };
139 Q_DECLARE_FLAGS(SecretFlags, SecretFlagType)
140
141 /*!
142 *
143 * \value MacAddressRandomizationDefault
144 * \value MacAddressRandomizationNever
145 * \value MacAddressRandomizationAlways
146 */
147 enum MacAddressRandomization {
148 MacAddressRandomizationDefault = 0,
149 MacAddressRandomizationNever,
150 MacAddressRandomizationAlways,
151 };
152
153 /*!
154 */
155 static QString typeAsString(SettingType type);
156 /*!
157 */
158 static SettingType typeFromString(const QString &type);
159
160 /*!
161 */
162 explicit Setting(SettingType type);
163 /*!
164 */
165 explicit Setting(const Ptr &setting);
166 /*!
167 */
168 virtual ~Setting();
169
170 /*!
171 * \brief Must be reimplemented, default implementation does nothing.
172 */
173 virtual void fromMap(const QVariantMap &map);
174
175 /*!
176 * \brief Must be reimplemented, default implementationd does nothing.
177 */
178 virtual QVariantMap toMap() const;
179
180 /*!
181 */
182 virtual void secretsFromMap(const QVariantMap &map);
183
184 /*!
185 * \brief secretsFromStringMap is a convenience function
186 * to set the secrets from a map of strings.
187 * \a map to extract secrets from
188 */
189 virtual void secretsFromStringMap(const NMStringMap &map);
190
191 /*!
192 */
193 virtual QVariantMap secretsToMap() const;
194
195 /*!
196 * \brief secretsToStringMap is a convenience function
197 * to get the secrets to map of strings.
198 * Returns string map with current secrets
199 */
200 virtual NMStringMap secretsToStringMap() const;
201
202 /*!
203 */
204 virtual QStringList needSecrets(bool requestNew = false) const;
205
206 /*!
207 * \brief Must be reimplemented, default implementationd does nothing.
208 */
209 virtual QString name() const;
210
211 /*!
212 */
213 void setInitialized(bool initialized);
214
215 /*!
216 */
217 bool isNull() const;
218
219 /*!
220 */
221 void setType(SettingType type);
222 /*!
223 */
224 SettingType type() const;
225
226protected:
227 SettingPrivate *d_ptr;
228
229private:
230 Q_DECLARE_PRIVATE(Setting)
231};
232Q_DECLARE_OPERATORS_FOR_FLAGS(Setting::SecretFlags)
233
234NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const Setting &setting);
235
236}
237
238#endif // NETWORKMANAGERQT_SETTING_H
239

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