10#include <nm-version.h>
11#define signals Q_SIGNALS
15#if !NM_CHECK_VERSION(1, 16, 0)
16#define NM_SETTING_WIREGUARD_SETTING_NAME "wireguard"
19#if !NM_CHECK_VERSION(1, 14, 0)
20#define NM_SETTING_MATCH_SETTING_NAME "match"
23#if !NM_CHECK_VERSION(1, 10, 0)
24#define NM_SETTING_OVS_BRIDGE_SETTING_NAME "ovs-bridge"
25#define NM_SETTING_OVS_INTERFACE_SETTING_NAME "ovs-interface"
26#define NM_SETTING_OVS_PATCH_SETTING_NAME "ovs-patch"
27#define NM_SETTING_OVS_PORT_SETTING_NAME "ovs-port"
28#define NM_SETTING_TC_CONFIG_SETTING_NAME "tc"
29#define NM_SETTING_TEAM_PORT_SETTING_NAME "team-port"
32#if !NM_CHECK_VERSION(1, 8, 0)
33#define NM_SETTING_USER_SETTING_NAME "user"
36#if !NM_CHECK_VERSION(1, 6, 0)
37#define NM_SETTING_MACSEC_SETTING_NAME "macsec"
38#define NM_SETTING_PROXY_SETTING_NAME "proxy"
48 Setting::SettingType type;
54 dbg.
nospace() <<
"type: " << setting.typeAsString(setting.type()) <<
'\n';
55 dbg.
nospace() <<
"initialized: " << !setting.isNull() <<
'\n';
61NetworkManager::SettingPrivate::SettingPrivate()
62 :
type(Setting::Wired)
67QString NetworkManager::Setting::typeAsString(NetworkManager::Setting::SettingType type)
79 typeString =
QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME);
82 typeString =
QLatin1String(NM_SETTING_IP4_CONFIG_SETTING_NAME);
85 typeString =
QLatin1String(NM_SETTING_IP6_CONFIG_SETTING_NAME);
106 typeString =
QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME);
108 case WirelessSecurity:
109 typeString =
QLatin1String(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
112 typeString =
QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME);
133 typeString =
QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME);
142 typeString =
QLatin1String(NM_SETTING_OVS_INTERFACE_SETTING_NAME);
145 typeString =
QLatin1String(NM_SETTING_OVS_BRIDGE_SETTING_NAME);
148 typeString =
QLatin1String(NM_SETTING_OVS_PATCH_SETTING_NAME);
151 typeString =
QLatin1String(NM_SETTING_OVS_PORT_SETTING_NAME);
157 typeString =
QLatin1String(NM_SETTING_TC_CONFIG_SETTING_NAME);
160 typeString =
QLatin1String(NM_SETTING_TEAM_PORT_SETTING_NAME);
168 case NetworkManager::Setting::WireGuard:
169 typeString =
QLatin1String(NM_SETTING_WIREGUARD_SETTING_NAME);
171 case NetworkManager::Setting::Generic:
181NetworkManager::Setting::SettingType NetworkManager::Setting::typeFromString(
const QString &typeString)
183 SettingType
type = Wired;
185 if (typeString ==
QLatin1String(NM_SETTING_CDMA_SETTING_NAME)) {
187 }
else if (typeString ==
QLatin1String(NM_SETTING_GSM_SETTING_NAME)) {
189 }
else if (typeString ==
QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME)) {
191 }
else if (typeString ==
QLatin1String(NM_SETTING_IP4_CONFIG_SETTING_NAME)) {
193 }
else if (typeString ==
QLatin1String(NM_SETTING_IP6_CONFIG_SETTING_NAME)) {
195 }
else if (typeString ==
QLatin1String(NM_SETTING_PPP_SETTING_NAME)) {
197 }
else if (typeString ==
QLatin1String(NM_SETTING_PPPOE_SETTING_NAME)) {
199 }
else if (typeString ==
QLatin1String(NM_SETTING_SERIAL_SETTING_NAME)) {
201 }
else if (typeString ==
QLatin1String(NM_SETTING_802_1X_SETTING_NAME)) {
202 type = Security8021x;
203 }
else if (typeString ==
QLatin1String(NM_SETTING_VPN_SETTING_NAME)) {
205 }
else if (typeString ==
QLatin1String(NM_SETTING_WIRED_SETTING_NAME)) {
207 }
else if (typeString ==
QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME)) {
209 }
else if (typeString ==
QLatin1String(NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)) {
210 type = WirelessSecurity;
211 }
else if (typeString ==
QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME)) {
213 }
else if (typeString ==
QLatin1String(NM_SETTING_VLAN_SETTING_NAME)) {
215 }
else if (typeString ==
QLatin1String(NM_SETTING_WIMAX_SETTING_NAME)) {
217 }
else if (typeString ==
QLatin1String(NM_SETTING_BOND_SETTING_NAME)) {
219 }
else if (typeString ==
QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME)) {
221 }
else if (typeString ==
QLatin1String(NM_SETTING_TEAM_SETTING_NAME)) {
223 }
else if (typeString ==
QLatin1String(NM_SETTING_VXLAN_SETTING_NAME)) {
225 }
else if (typeString ==
QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME)) {
227 }
else if (typeString ==
QLatin1String(NM_SETTING_GENERIC_SETTING_NAME)) {
229 }
else if (typeString ==
QLatin1String(NM_SETTING_USER_SETTING_NAME)) {
231 }
else if (typeString ==
QLatin1String(NM_SETTING_PROXY_SETTING_NAME)) {
233 }
else if (typeString ==
QLatin1String(NM_SETTING_OVS_INTERFACE_SETTING_NAME)) {
235 }
else if (typeString ==
QLatin1String(NM_SETTING_OVS_BRIDGE_SETTING_NAME)) {
237 }
else if (typeString ==
QLatin1String(NM_SETTING_OVS_PATCH_SETTING_NAME)) {
239 }
else if (typeString ==
QLatin1String(NM_SETTING_OVS_PORT_SETTING_NAME)) {
241 }
else if (typeString ==
QLatin1String(NM_SETTING_MATCH_SETTING_NAME)) {
243 }
else if (typeString ==
QLatin1String(NM_SETTING_TC_CONFIG_SETTING_NAME)) {
245 }
else if (typeString ==
QLatin1String(NM_SETTING_TEAM_PORT_SETTING_NAME)) {
247 }
else if (typeString ==
QLatin1String(NM_SETTING_MACSEC_SETTING_NAME)) {
249 }
else if (typeString ==
QLatin1String(NM_SETTING_DCB_SETTING_NAME)) {
251 }
else if (typeString ==
QLatin1String(NM_SETTING_WIREGUARD_SETTING_NAME)) {
258NetworkManager::Setting::Setting(SettingType type)
259 : d_ptr(new SettingPrivate())
265 : d_ptr(new SettingPrivate())
267 setInitialized(!setting->isNull());
268 setType(setting->type());
271NetworkManager::Setting::~Setting()
283 return QVariantMap();
286QStringList NetworkManager::Setting::needSecrets(
bool requestNew)
const
288 Q_UNUSED(requestNew);
297void NetworkManager::Setting::secretsFromMap(
const QVariantMap &map)
304 QVariantMap secretsMap;
306 while (i != map.constEnd()) {
307 secretsMap.insert(i.key(), i.value());
310 secretsFromMap(secretsMap);
313QVariantMap NetworkManager::Setting::secretsToMap()
const
315 return QVariantMap();
321 const QVariantMap secretsMap = secretsToMap();
322 for (
auto it = secretsMap.begin(); it != secretsMap.end(); ++it) {
323 ret.
insert(it.key(), it.value().toString());
329void NetworkManager::Setting::setInitialized(
bool initialized)
333 d->initialized = initialized;
336bool NetworkManager::Setting::isNull()
const
340 return !d->initialized;
343void NetworkManager::Setting::setType(NetworkManager::Setting::SettingType type)
350NetworkManager::Setting::SettingType NetworkManager::Setting::type()
const
Base class for all kinds of setting.
virtual NMStringMap secretsToStringMap() const
secretsToStringMap is a convenience function to get the secrets to map of strings.
virtual void secretsFromStringMap(const NMStringMap &map)
secretsFromStringMap is a convenience function to set the secrets from a map of strings.
virtual void fromMap(const QVariantMap &map)
Must be reimplemented, default implementation does nothing.
virtual QString name() const
Must be reimplemented, default implementationd does nothing.
virtual QVariantMap toMap() const
Must be reimplemented, default implementationd does nothing.
Type type(const QSqlDatabase &db)
QDebug operator<<(QDebug dbg, const DcrawInfoContainer &c)
This class allows querying the underlying system to discover the available network interfaces and rea...
iterator insert(const Key &key, const T &value)