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 */
69 enum ConnectionType {
70 Unknown = 0,
71 Adsl,
72 Bluetooth,
73 Bond,
74 Bridge,
75 Cdma,
76 Gsm,
77 Infiniband,
78 OLPCMesh,
79 Pppoe,
80 Vlan,
81 Vpn,
82 Wimax,
83 Wired,
84 Wireless,
85 Team,
86 Generic,
87 Tun,
88 IpTunnel,
89 WireGuard,
90 Loopback,
91 };
92
93 /*!
94 *
95 * \value SlavesDefault
96 * \value DoNotConnectSlaves
97 * \value ConnectAllSlaves
98 */
99 enum AutoconnectSlaves {
100 SlavesDefault = -1,
101 DoNotConnectSlaves = 0,
102 ConnectAllSlaves = 1,
103 };
104
105 /*!
106 *
107 * \value LldpDefault
108 * \value LldpDisable
109 * \value LldpEnableRx
110 */
111 enum Lldp {
112 LldpDefault = -1,
113 LldpDisable = 0,
114 LldpEnableRx = 1,
115 };
116
117 /*!
118 *
119 * FIXME same enum as in device.h, unfortunately it's not possible to use that one
120 * maybe in future move all enums into one header so they can be used across all classes
121 *
122 * \value MeteredUnknown
123 * \value MeteredYes
124 * \value MeteredNo
125 * \value MeteredGuessYes
126 * \value MeteredGuessNo
127 */
128 enum Metered {
129 MeteredUnknown = 0,
130 MeteredYes = 1,
131 MeteredNo = 2,
132 MeteredGuessYes = 3,
133 MeteredGuessNo = 4,
134 };
135
136 /*!
137 *
138 * \value MdnsDefault
139 * \value MdnsNo
140 * \value MdnsResolve
141 * \value MdnsResolveAndRespond
142 */
143 enum Mdns {
144 MdnsDefault = -1,
145 MdnsNo = 0,
146 MdnsResolve = 1,
147 MdnsResolveAndRespond = 2
148 };
149
150 /*!
151 */
152 static ConnectionType typeFromString(const QString &typeString);
153 /*!
154 */
155 static QString typeAsString(const ConnectionType type);
156 /*!
157 */
158 static QString createNewUuid();
159
160 /*!
161 */
162 ConnectionSettings();
163 /*!
164 */
165 explicit ConnectionSettings(ConnectionType type, NMBluetoothCapabilities bt_cap = NM_BT_CAPABILITY_DUN);
166 /*!
167 */
168 explicit ConnectionSettings(const ConnectionSettings::Ptr &other);
169 /*!
170 */
171 explicit ConnectionSettings(const NMVariantMapMap &map);
172 /*!
173 */
174 virtual ~ConnectionSettings();
175
176 /*!
177 */
178 QString name() const;
179
180 /*!
181 */
182 void fromMap(const NMVariantMapMap &map);
183 /*!
184 */
185 void fromMeCard(const QVariantMap &map);
186
187 /*!
188 */
189 NMVariantMapMap toMap() const;
190
191 /*!
192 */
193 void setId(const QString &id);
194 /*!
195 */
196 QString id() const;
197
198 /*!
199 */
200 void setUuid(const QString &uuid);
201 /*!
202 */
203 QString uuid() const;
204
205 /*!
206 */
207 void setInterfaceName(const QString &interfaceName);
208 /*!
209 */
210 QString interfaceName() const;
211
212 /*!
213 */
214 void setConnectionType(ConnectionType type, NMBluetoothCapabilities bt_cap = NM_BT_CAPABILITY_DUN);
215 /*!
216 */
217 ConnectionType connectionType() const;
218
219 /*!
220 */
221 void addToPermissions(const QString &user, const QString &type);
222 /*!
223 */
224 void setPermissions(const QHash<QString, QString> &perm);
225 /*!
226 */
227 QHash<QString, QString> permissions() const;
228
229 /*!
230 */
231 void setAutoconnect(bool autoconnect);
232 /*!
233 */
234 bool autoconnect() const;
235
236 /*!
237 */
238 void setAutoconnectPriority(int priority);
239 /*!
240 */
241 int autoconnectPriority() const;
242
243 /*!
244 */
245 void setTimestamp(const QDateTime &timestamp);
246 /*!
247 */
248 QDateTime timestamp() const;
249
250 /*!
251 */
252 void setReadOnly(bool readonly);
253 /*!
254 */
255 bool readOnly() const;
256
257 /*!
258 */
259 void setZone(const QString &zone);
260 /*!
261 */
262 QString zone() const;
263
264 /*!
265 */
266 bool isSlave() const;
267
268 /*!
269 */
270 void setMaster(const QString &master);
271 /*!
272 */
273 QString master() const;
274
275 /*!
276 */
277 void setSlaveType(const QString &type);
278 /*!
279 */
280 QString slaveType() const;
281
282 /*!
283 */
284 void setSecondaries(const QStringList &secondaries);
285 /*!
286 */
287 QStringList secondaries() const;
288
289 /*!
290 */
291 void setGatewayPingTimeout(quint32 timeout);
292 /*!
293 */
294 quint32 gatewayPingTimeout() const;
295
296 /*!
297 */
298 void setAutoconnectRetries(int retries);
299 /*!
300 */
301 int autoconnectRetries() const;
302
303 /*!
304 */
305 void setAutoconnectSlaves(AutoconnectSlaves autoconnectSlaves);
306 /*!
307 */
308 AutoconnectSlaves autoconnectSlaves() const;
309
310 /*!
311 */
312 void setLldp(Lldp lldp);
313 /*!
314 */
315 Lldp lldp() const;
316
317 /*!
318 */
319 void setMetered(Metered metered);
320 /*!
321 */
322 Metered metered() const;
323
324 /*!
325 */
326 void setMdns(Mdns mdns);
327 /*!
328 */
329 Mdns mdns() const;
330
331 /*!
332 */
333 void setStableId(const QString &stableId);
334 /*!
335 */
336 QString stableId() const;
337
338 /*!
339 */
340 Setting::Ptr setting(Setting::SettingType type) const;
341 /*!
342 */
343 Setting::Ptr setting(const QString &type) const;
344
345 /*!
346 */
347 Setting::List settings() const;
348
349protected:
350 ConnectionSettingsPrivate *d_ptr;
351
352private:
353 Q_DECLARE_PRIVATE(ConnectionSettings)
354};
355
356NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const ConnectionSettings &setting);
357
358}
359
360#endif // NETWORKMANAGERQT_CONNECTION_SETTINGS_H
361

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