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 * Represents collection of all connection settings
28 */
29class NETWORKMANAGERQT_EXPORT ConnectionSettings
30{
31 Q_ENUMS(ConnectionType)
32public:
33 typedef QSharedPointer<ConnectionSettings> Ptr;
34 typedef QList<Ptr> List;
35 enum ConnectionType {
36 Unknown = 0,
37 Adsl,
38 Bluetooth,
39 Bond,
40 Bridge,
41 Cdma,
42 Gsm,
43 Infiniband,
44 OLPCMesh,
45 Pppoe,
46 Vlan,
47 Vpn,
48 Wimax,
49 Wired,
50 Wireless,
51 Team,
52 Generic,
53 Tun,
54 IpTunnel,
55 WireGuard,
56 };
57
58 enum AutoconnectSlaves {
59 SlavesDefault = -1,
60 DoNotConnectSlaves = 0,
61 ConnectAllSlaves = 1,
62 };
63
64 enum Lldp {
65 LldpDefault = -1,
66 LldpDisable = 0,
67 LldpEnableRx = 1,
68 };
69
70 // FIXME same enum as in device.h, unfortunately it's not possible to use that one
71 // maybe in future move all enums into one header so they can be used across all classes
72 enum Metered {
73 MeteredUnknown = 0,
74 MeteredYes = 1,
75 MeteredNo = 2,
76 MeteredGuessYes = 3,
77 MeteredGuessNo = 4,
78 };
79
80 enum Mdns {
81 MdnsDefault = -1,
82 MdnsNo = 0,
83 MdnsResolve = 1,
84 MdnsResolveAndRespond = 2
85 };
86
87 static ConnectionType typeFromString(const QString &typeString);
88 static QString typeAsString(const ConnectionType type);
89 static QString createNewUuid();
90
91 ConnectionSettings();
92 explicit ConnectionSettings(ConnectionType type, NMBluetoothCapabilities bt_cap = NM_BT_CAPABILITY_DUN);
93 explicit ConnectionSettings(const ConnectionSettings::Ptr &other);
94 explicit ConnectionSettings(const NMVariantMapMap &map);
95 virtual ~ConnectionSettings();
96
97 QString name() const;
98
99 void fromMap(const NMVariantMapMap &map);
100 void fromMeCard(const QVariantMap &map);
101
102 NMVariantMapMap toMap() const;
103
104 void setId(const QString &id);
105 QString id() const;
106
107 void setUuid(const QString &uuid);
108 QString uuid() const;
109
110 void setInterfaceName(const QString &interfaceName);
111 QString interfaceName() const;
112
113 void setConnectionType(ConnectionType type, NMBluetoothCapabilities bt_cap = NM_BT_CAPABILITY_DUN);
114 ConnectionType connectionType() const;
115
116 void addToPermissions(const QString &user, const QString &type);
117 void setPermissions(const QHash<QString, QString> &perm);
118 QHash<QString, QString> permissions() const;
119
120 void setAutoconnect(bool autoconnect);
121 bool autoconnect() const;
122
123 void setAutoconnectPriority(int priority);
124 int autoconnectPriority() const;
125
126 void setTimestamp(const QDateTime &timestamp);
127 QDateTime timestamp() const;
128
129 void setReadOnly(bool readonly);
130 bool readOnly() const;
131
132 void setZone(const QString &zone);
133 QString zone() const;
134
135 bool isSlave() const;
136
137 void setMaster(const QString &master);
138 QString master() const;
139
140 void setSlaveType(const QString &type);
141 QString slaveType() const;
142
143 void setSecondaries(const QStringList &secondaries);
144 QStringList secondaries() const;
145
146 void setGatewayPingTimeout(quint32 timeout);
147 quint32 gatewayPingTimeout() const;
148
149 void setAutoconnectRetries(int retries);
150 int autoconnectRetries() const;
151
152 void setAutoconnectSlaves(AutoconnectSlaves autoconnectSlaves);
153 AutoconnectSlaves autoconnectSlaves() const;
154
155 void setLldp(Lldp lldp);
156 Lldp lldp() const;
157
158 void setMetered(Metered metered);
159 Metered metered() const;
160
161 void setMdns(Mdns mdns);
162 Mdns mdns() const;
163
164 void setStableId(const QString &stableId);
165 QString stableId() const;
166
167 Setting::Ptr setting(Setting::SettingType type) const;
168 Setting::Ptr setting(const QString &type) const;
169
170 Setting::List settings() const;
171
172protected:
173 ConnectionSettingsPrivate *d_ptr;
174
175private:
176 Q_DECLARE_PRIVATE(ConnectionSettings)
177};
178
179NETWORKMANAGERQT_EXPORT QDebug operator<<(QDebug dbg, const ConnectionSettings &setting);
180
181}
182
183#endif // NETWORKMANAGERQT_CONNECTION_SETTINGS_H
184

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