1/*
2 SPDX-FileCopyrightText: 2012-2013 Jan Grulich <jgrulich@redhat.com>
3 SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef NETWORKMANAGERQT_CONNECTION_SETTINGS_H
9#define NETWORKMANAGERQT_CONNECTION_SETTINGS_H
10
11#include "setting.h"
12#include <networkmanagerqt/networkmanagerqt_export.h>
13
14#undef signals
15#include <libnm/NetworkManager.h>
16#define signals Q_SIGNALS
17
18#include <QDateTime>
19#include <QHash>
20#include <QString>
21
22namespace NetworkManager
23{
24class ConnectionSettingsPrivate;
25
26/*!
27 * \class NetworkManager::ConnectionSettings
28 * \inheaderfile NetworkManagerQt/ConnectionSettings
29 * \inmodule NetworkManagerQt
30 *
31 * \brief Represents collection of all connection settings.
32 */
33class NETWORKMANAGERQT_EXPORT ConnectionSettings
34{
35 Q_ENUMS(ConnectionType)
36public:
37 /*!
38 * \typedef NetworkManager::ConnectionSettings::Ptr
39 */
40 typedef QSharedPointer<ConnectionSettings> Ptr;
41 /*!
42 * \typedef NetworkManager::ConnectionSettings::List
43 */
44 typedef QList<Ptr> List;
45 /*!
46 *
47 * \value Unknown
48 * \value Adsl
49 * \value Bluetooth
50 * \value Bond
51 * \value Bridge
52 * \value Cdma
53 * \value Gsm
54 * \value Infiniband
55 * \value OLPCMesh
56 * \value Pppoe
57 * \value Vlan
58 * \value Vpn
59 * \value Wimax
60 * \value Wired
61 * \value Wireless
62 * \value Team
63 * \value Generic
64 * \value Tun
65 * \value IpTunnel
66 * \value WireGuard
67 * \value Loopback
68 * \value[since 6.20] WifiP2P
69 */
70 enum ConnectionType {
71 Unknown = 0,
72 Adsl,
73 Bluetooth,
74 Bond,
75 Bridge,
76 Cdma,
77 Gsm,
78 Infiniband,
79 OLPCMesh,
80 Pppoe,
81 Vlan,
82 Vpn,
83 Wimax,
84 Wired,
85 Wireless,
86 Team,
87 Generic,
88 Tun,
89 IpTunnel,
90 WireGuard,
91 Loopback,
92 WifiP2P,
93 };
94
95 /*!
96 *
97 * \value SlavesDefault
98 * \value DoNotConnectSlaves
99 * \value ConnectAllSlaves
100 */
101 enum AutoconnectSlaves {
102 SlavesDefault = -1,
103 DoNotConnectSlaves = 0,
104 ConnectAllSlaves = 1,
105 };
106
107 /*!
108 *
109 * \value LldpDefault
110 * \value LldpDisable
111 * \value LldpEnableRx
112 */
113 enum Lldp {
114 LldpDefault = -1,
115 LldpDisable = 0,
116 LldpEnableRx = 1,
117 };
118
119 /*!
120 *
121 * FIXME same enum as in device.h, unfortunately it's not possible to use that one
122 * maybe in future move all enums into one header so they can be used across all classes
123 *
124 * \value MeteredUnknown
125 * \value MeteredYes
126 * \value MeteredNo
127 * \value MeteredGuessYes
128 * \value MeteredGuessNo
129 */
130 enum Metered {
131 MeteredUnknown = 0,
132 MeteredYes = 1,
133 MeteredNo = 2,
134 MeteredGuessYes = 3,
135 MeteredGuessNo = 4,
136 };
137
138 /*!
139 *
140 * \value MdnsDefault
141 * \value MdnsNo
142 * \value MdnsResolve
143 * \value MdnsResolveAndRespond
144 */
145 enum Mdns {
146 MdnsDefault = -1,
147 MdnsNo = 0,
148 MdnsResolve = 1,
149 MdnsResolveAndRespond = 2
150 };
151
152 /*!
153 */
154 static ConnectionType typeFromString(const QString &typeString);
155 /*!
156 */
157 static QString typeAsString(const ConnectionType type);
158 /*!
159 */
160 static QString createNewUuid();
161
162 /*!
163 */
164 ConnectionSettings();
165 /*!
166 */
167 explicit ConnectionSettings(ConnectionType type, NMBluetoothCapabilities bt_cap = NM_BT_CAPABILITY_DUN);
168 /*!
169 */
170 explicit ConnectionSettings(const ConnectionSettings::Ptr &other);
171 /*!
172 */
173 explicit ConnectionSettings(const NMVariantMapMap &map);
174 /*!
175 */
176 virtual ~ConnectionSettings();
177
178 /*!
179 */
180 QString name() const;
181
182 /*!
183 */
184 void fromMap(const NMVariantMapMap &map);
185 /*!
186 */
187 void fromMeCard(const QVariantMap &map);
188
189 /*!
190 */
191 NMVariantMapMap toMap() const;
192
193 /*!
194 */
195 void setId(const QString &id);
196 /*!
197 */
198 QString id() const;
199
200 /*!
201 */
202 void setUuid(const QString &uuid);
203 /*!
204 */
205 QString uuid() const;
206
207 /*!
208 */
209 void setInterfaceName(const QString &interfaceName);
210 /*!
211 */
212 QString interfaceName() const;
213
214 /*!
215 */
216 void setConnectionType(ConnectionType type, NMBluetoothCapabilities bt_cap = NM_BT_CAPABILITY_DUN);
217 /*!
218 */
219 ConnectionType connectionType() const;
220
221 /*!
222 */
223 void addToPermissions(const QString &user, const QString &type);
224 /*!
225 */
226 void setPermissions(const QHash<QString, QString> &perm);
227 /*!
228 */
229 QHash<QString, QString> permissions() const;
230
231 /*!
232 */
233 void setAutoconnect(bool autoconnect);
234 /*!
235 */
236 bool autoconnect() const;
237
238 /*!
239 */
240 void setAutoconnectPriority(int priority);
241 /*!
242 */
243 int autoconnectPriority() const;
244
245 /*!
246 */
247 void setTimestamp(const QDateTime &timestamp);
248 /*!
249 */
250 QDateTime timestamp() const;
251
252 /*!
253 */
254 void setReadOnly(bool readonly);
255 /*!
256 */
257 bool readOnly() const;
258
259 /*!
260 */
261 void setZone(const QString &zone);
262 /*!
263 */
264 QString zone() const;
265
266 /*!
267 */
268 bool isSlave() const;
269
270 /*!
271 */
272 void setMaster(const QString &master);
273 /*!
274 */
275 QString master() const;
276
277 /*!
278 */
279 void setSlaveType(const QString &type);
280 /*!
281 */
282 QString slaveType() const;
283
284 /*!
285 */
286 void setSecondaries(const QStringList &secondaries);
287 /*!
288 */
289 QStringList secondaries() const;
290
291 /*!
292 */
293 void setGatewayPingTimeout(quint32 timeout);
294 /*!
295 */
296 quint32 gatewayPingTimeout() const;
297
298 /*!
299 */
300 void setAutoconnectRetries(int retries);
301 /*!
302 */
303 int autoconnectRetries() const;
304
305 /*!
306 */
307 void setAutoconnectSlaves(AutoconnectSlaves autoconnectSlaves);
308 /*!
309 */
310 AutoconnectSlaves autoconnectSlaves() const;
311
312 /*!
313 */
314 void setLldp(Lldp lldp);
315 /*!
316 */
317 Lldp lldp() const;
318
319 /*!
320 */
321 void setMetered(Metered metered);
322 /*!
323 */
324 Metered metered() const;
325
326 /*!
327 */
328 void setMdns(Mdns mdns);
329 /*!
330 */
331 Mdns mdns() const;
332
333 /*!
334 */
335 void setStableId(const QString &stableId);
336 /*!
337 */
338 QString stableId() const;
339
340 /*!
341 */
342 Setting::Ptr setting(Setting::SettingType type) const;
343 /*!
344 */
345 Setting::Ptr setting(const QString &type) const;
346
347 /*!
348 */
349 Setting::List settings() const;
350
351protected:
352 ConnectionSettingsPrivate *d_ptr;
353
354private:
355 Q_DECLARE_PRIVATE(ConnectionSettings)
356};
357
358NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const ConnectionSettings &setting);
359
360}
361
362#endif // NETWORKMANAGERQT_CONNECTION_SETTINGS_H
363

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