9#include "connectionsettings.h"
10#include "connectionsettings_p.h"
12#include "adslsetting.h"
13#include "bluetoothsetting.h"
14#include "bondsetting.h"
15#include "bridgeportsetting.h"
16#include "bridgesetting.h"
17#include "cdmasetting.h"
18#include "gsmsetting.h"
19#include "infinibandsetting.h"
20#include "iptunnelsetting.h"
21#include "ipv4setting.h"
22#include "ipv6setting.h"
23#include "olpcmeshsetting.h"
24#include "pppoesetting.h"
25#include "pppsetting.h"
26#include "security8021xsetting.h"
27#include "serialsetting.h"
28#include "tunsetting.h"
29#include "vlansetting.h"
30#include "vpnsetting.h"
31#include "wimaxsetting.h"
32#include "wiredsetting.h"
33#include "wireguardsetting.h"
34#include "wirelesssecuritysetting.h"
35#include "wirelesssetting.h"
39#if !NM_CHECK_VERSION(1, 6, 0)
40#define NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES "autoconnect-retries"
43#if !NM_CHECK_VERSION(1, 12, 0)
44#define NM_SETTING_CONNECTION_MDNS "mdns"
47#if !NM_CHECK_VERSION(1, 16, 0)
48#define NM_SETTING_WIREGUARD_SETTING_NAME "wireguard"
51#if !NM_CHECK_VERSION(1, 42, 0)
52#define NM_SETTING_LOOPBACK_SETTING_NAME "loopback"
55#include "genericsetting.h"
56#include "teamsetting.h"
62extern bool checkVersion(
const int x,
const int y,
const int z);
65NetworkManager::ConnectionSettingsPrivate::ConnectionSettingsPrivate(ConnectionSettings *q)
66 : name(NM_SETTING_CONNECTION_SETTING_NAME)
68 ,
type(ConnectionSettings::Wired)
71 , gatewayPingTimeout(0)
72 , autoconnectPriority(0)
73 , autoconnectRetries(-1)
74 , autoconnectSlaves(ConnectionSettings::SlavesDefault)
75 , lldp(ConnectionSettings::LldpDefault)
76 ,
metered(ConnectionSettings::MeteredUnknown)
77 , mdns(ConnectionSettings::MdnsDefault)
82void NetworkManager::ConnectionSettingsPrivate::addSetting(
const NetworkManager::Setting::Ptr &setting)
84 settings.push_back(setting);
87void NetworkManager::ConnectionSettingsPrivate::clearSettings()
92void NetworkManager::ConnectionSettingsPrivate::initSettings(NMBluetoothCapabilities bt_cap)
97 case ConnectionSettings::Adsl:
98 addSetting(Setting::Ptr(
new AdslSetting()));
99 addSetting(Setting::Ptr(
new Ipv4Setting()));
100 addSetting(Setting::Ptr(
new Ipv6Setting()));
102 case ConnectionSettings::Bond:
103 addSetting(Setting::Ptr(
new BondSetting()));
104 addSetting(Setting::Ptr(
new Ipv4Setting()));
105 addSetting(Setting::Ptr(
new Ipv6Setting()));
107 case ConnectionSettings::Bluetooth:
108 addSetting(Setting::Ptr(
new BluetoothSetting()));
109 addSetting(Setting::Ptr(
new Ipv4Setting()));
111 if (bt_cap == NM_BT_CAPABILITY_DUN) {
112 addSetting(Setting::Ptr(
new GsmSetting()));
113 addSetting(Setting::Ptr(
new PppSetting()));
114 addSetting(Setting::Ptr(
new SerialSetting()));
117 case ConnectionSettings::Bridge:
118 addSetting(Setting::Ptr(
new BridgeSetting()));
119 addSetting(Setting::Ptr(
new Ipv4Setting()));
120 addSetting(Setting::Ptr(
new Ipv6Setting()));
122 case ConnectionSettings::Cdma:
123 addSetting(Setting::Ptr(
new CdmaSetting()));
124 addSetting(Setting::Ptr(
new Ipv4Setting()));
126 addSetting(Setting::Ptr(
new Ipv6Setting()));
128 addSetting(Setting::Ptr(
new PppSetting()));
130 case ConnectionSettings::Gsm:
131 addSetting(Setting::Ptr(
new GsmSetting()));
132 addSetting(Setting::Ptr(
new Ipv4Setting()));
134 addSetting(Setting::Ptr(
new Ipv6Setting()));
136 addSetting(Setting::Ptr(
new PppSetting()));
138 case ConnectionSettings::Infiniband:
139 addSetting(Setting::Ptr(
new InfinibandSetting()));
140 addSetting(Setting::Ptr(
new Ipv4Setting()));
141 addSetting(Setting::Ptr(
new Ipv6Setting()));
143 case ConnectionSettings::OLPCMesh:
144 addSetting(Setting::Ptr(
new Ipv4Setting()));
145 addSetting(Setting::Ptr(
new Ipv6Setting()));
146 addSetting(Setting::Ptr(
new OlpcMeshSetting()));
148 case ConnectionSettings::Pppoe:
149 addSetting(Setting::Ptr(
new Ipv4Setting()));
151 addSetting(Setting::Ptr(
new PppSetting()));
152 addSetting(Setting::Ptr(
new PppoeSetting()));
153 addSetting(Setting::Ptr(
new WiredSetting()));
155 case ConnectionSettings::Vlan:
156 addSetting(Setting::Ptr(
new Ipv4Setting()));
157 addSetting(Setting::Ptr(
new Ipv6Setting()));
158 addSetting(Setting::Ptr(
new VlanSetting()));
160 case ConnectionSettings::Vpn:
161 addSetting(Setting::Ptr(
new Ipv4Setting()));
162 addSetting(Setting::Ptr(
new Ipv6Setting()));
163 addSetting(Setting::Ptr(
new VpnSetting()));
165 case ConnectionSettings::Wimax:
166 addSetting(Setting::Ptr(
new Ipv4Setting()));
167 addSetting(Setting::Ptr(
new Ipv6Setting()));
168 addSetting(Setting::Ptr(
new WimaxSetting()));
170 case ConnectionSettings::Wired:
171 addSetting(Setting::Ptr(
new Ipv4Setting()));
172 addSetting(Setting::Ptr(
new Ipv6Setting()));
173 addSetting(Setting::Ptr(
new Security8021xSetting()));
174 addSetting(Setting::Ptr(
new WiredSetting()));
176 case ConnectionSettings::Wireless:
177 addSetting(Setting::Ptr(
new Ipv4Setting()));
178 addSetting(Setting::Ptr(
new Ipv6Setting()));
179 addSetting(Setting::Ptr(
new Security8021xSetting()));
180 addSetting(Setting::Ptr(
new WirelessSetting()));
181 addSetting(Setting::Ptr(
new WirelessSecuritySetting()));
183 case ConnectionSettings::Team:
184 addSetting(Setting::Ptr(
new TeamSetting()));
185 addSetting(Setting::Ptr(
new Ipv4Setting()));
186 addSetting(Setting::Ptr(
new Ipv6Setting()));
188 case ConnectionSettings::Generic:
189 addSetting(Setting::Ptr(
new GenericSetting()));
190 addSetting(Setting::Ptr(
new Ipv4Setting()));
191 addSetting(Setting::Ptr(
new Ipv6Setting()));
193 case ConnectionSettings::Tun:
194 addSetting(Setting::Ptr(
new TunSetting()));
195 addSetting(Setting::Ptr(
new Ipv4Setting()));
196 addSetting(Setting::Ptr(
new Ipv6Setting()));
198 case ConnectionSettings::IpTunnel:
199 addSetting(Setting::Ptr(
new IpTunnelSetting()));
200 addSetting(Setting::Ptr(
new Ipv4Setting()));
201 addSetting(Setting::Ptr(
new Ipv6Setting()));
203 case ConnectionSettings::WireGuard:
204 addSetting(Setting::Ptr(
new WireGuardSetting()));
205 addSetting(Setting::Ptr(
new Ipv4Setting()));
206 addSetting(Setting::Ptr(
new Ipv6Setting()));
208 case ConnectionSettings::Loopback:
209 addSetting(Setting::Ptr(
new Ipv4Setting()));
210 addSetting(Setting::Ptr(
new Ipv6Setting()));
211 case ConnectionSettings::Unknown:
217void NetworkManager::ConnectionSettingsPrivate::initSettings(
const NetworkManager::ConnectionSettings::Ptr &connectionSettings)
219 Q_Q(ConnectionSettings);
224 case ConnectionSettings::Adsl:
225 addSetting(connectionSettings->setting(Setting::Adsl));
226 addSetting(connectionSettings->setting(Setting::Ipv4));
227 addSetting(connectionSettings->setting(Setting::Ipv6));
229 case ConnectionSettings::Bond:
230 addSetting(connectionSettings->setting(Setting::Bond));
231 addSetting(connectionSettings->setting(Setting::Ipv4));
232 addSetting(connectionSettings->setting(Setting::Ipv6));
234 case ConnectionSettings::Bluetooth:
235 addSetting(connectionSettings->setting(Setting::Bluetooth));
236 addSetting(connectionSettings->setting(Setting::Ipv4));
238 addSetting(connectionSettings->setting(Setting::Ipv6));
240 if (q->setting(Setting::Gsm) && q->setting(Setting::Ppp) && q->setting(Setting::Serial)) {
241 addSetting(connectionSettings->setting(Setting::Gsm));
242 addSetting(connectionSettings->setting(Setting::Ppp));
243 addSetting(connectionSettings->setting(Setting::Serial));
246 case ConnectionSettings::Bridge:
247 addSetting(connectionSettings->setting(Setting::Bridge));
248 addSetting(connectionSettings->setting(Setting::Ipv4));
249 addSetting(connectionSettings->setting(Setting::Ipv6));
251 case ConnectionSettings::Cdma:
252 addSetting(connectionSettings->setting(Setting::Cdma));
253 addSetting(connectionSettings->setting(Setting::Ipv4));
255 addSetting(connectionSettings->setting(Setting::Ipv6));
257 addSetting(connectionSettings->setting(Setting::Ppp));
259 case ConnectionSettings::Gsm:
260 addSetting(connectionSettings->setting(Setting::Gsm));
261 addSetting(connectionSettings->setting(Setting::Ipv4));
263 addSetting(connectionSettings->setting(Setting::Ipv6));
265 addSetting(connectionSettings->setting(Setting::Ppp));
267 case ConnectionSettings::Infiniband:
268 addSetting(connectionSettings->setting(Setting::Infiniband));
269 addSetting(connectionSettings->setting(Setting::Ipv4));
270 addSetting(connectionSettings->setting(Setting::Ipv6));
272 case ConnectionSettings::OLPCMesh:
273 addSetting(connectionSettings->setting(Setting::Ipv4));
274 addSetting(connectionSettings->setting(Setting::Ipv6));
275 addSetting(connectionSettings->setting(Setting::OlpcMesh));
277 case ConnectionSettings::Pppoe:
278 addSetting(connectionSettings->setting(Setting::Ipv4));
280 addSetting(connectionSettings->setting(Setting::Ppp));
281 addSetting(connectionSettings->setting(Setting::Pppoe));
282 addSetting(connectionSettings->setting(Setting::Wired));
284 case ConnectionSettings::Vlan:
285 addSetting(connectionSettings->setting(Setting::Ipv4));
286 addSetting(connectionSettings->setting(Setting::Ipv6));
287 addSetting(connectionSettings->setting(Setting::Vlan));
289 case ConnectionSettings::Vpn:
290 addSetting(connectionSettings->setting(Setting::Ipv4));
291 addSetting(connectionSettings->setting(Setting::Ipv6));
292 addSetting(connectionSettings->setting(Setting::Vpn));
294 case ConnectionSettings::Wimax:
295 addSetting(connectionSettings->setting(Setting::Ipv4));
296 addSetting(connectionSettings->setting(Setting::Ipv6));
297 addSetting(connectionSettings->setting(Setting::Wimax));
299 case ConnectionSettings::Wired:
300 addSetting(connectionSettings->setting(Setting::Ipv4));
301 addSetting(connectionSettings->setting(Setting::Ipv6));
302 addSetting(connectionSettings->setting(Setting::Security8021x));
303 addSetting(connectionSettings->setting(Setting::Wired));
305 case ConnectionSettings::Wireless:
306 addSetting(connectionSettings->setting(Setting::Ipv4));
307 addSetting(connectionSettings->setting(Setting::Ipv6));
308 addSetting(connectionSettings->setting(Setting::Security8021x));
309 addSetting(connectionSettings->setting(Setting::Wireless));
310 addSetting(connectionSettings->setting(Setting::WirelessSecurity));
312 case ConnectionSettings::Team:
313 addSetting(connectionSettings->setting(Setting::Team));
314 addSetting(connectionSettings->setting(Setting::Ipv4));
315 addSetting(connectionSettings->setting(Setting::Ipv6));
317 case ConnectionSettings::Generic:
318 addSetting(connectionSettings->setting(Setting::Generic));
319 addSetting(connectionSettings->setting(Setting::Ipv4));
320 addSetting(connectionSettings->setting(Setting::Ipv6));
322 case ConnectionSettings::Tun:
323 addSetting(connectionSettings->setting(Setting::Tun));
324 addSetting(connectionSettings->setting(Setting::Ipv4));
325 addSetting(connectionSettings->setting(Setting::Ipv6));
327 case ConnectionSettings::IpTunnel:
328 addSetting(connectionSettings->setting(Setting::IpTunnel));
329 addSetting(connectionSettings->setting(Setting::Ipv4));
330 addSetting(connectionSettings->setting(Setting::Ipv6));
332 case ConnectionSettings::WireGuard:
333 addSetting(connectionSettings->setting(Setting::WireGuard));
334 addSetting(connectionSettings->setting(Setting::Ipv4));
335 addSetting(connectionSettings->setting(Setting::Ipv6));
337 case ConnectionSettings::Loopback:
338 addSetting(connectionSettings->setting(Setting::Ipv4));
339 addSetting(connectionSettings->setting(Setting::Ipv6));
341 case ConnectionSettings::Unknown:
347NetworkManager::ConnectionSettings::ConnectionType NetworkManager::ConnectionSettings::typeFromString(
const QString &typeString)
349 ConnectionSettings::ConnectionType
type = Wired;
351 if (typeString == QLatin1String(NM_SETTING_ADSL_SETTING_NAME)) {
353 }
else if (typeString == QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME)) {
355 }
else if (typeString == QLatin1String(NM_SETTING_BOND_SETTING_NAME)) {
357 }
else if (typeString == QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME)) {
359 }
else if (typeString == QLatin1String(NM_SETTING_CDMA_SETTING_NAME)) {
361 }
else if (typeString == QLatin1String(NM_SETTING_GSM_SETTING_NAME)) {
363 }
else if (typeString == QLatin1String(NM_SETTING_INFINIBAND_SETTING_NAME)) {
365 }
else if (typeString == QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME)) {
367 }
else if (typeString == QLatin1String(NM_SETTING_PPPOE_SETTING_NAME)) {
369 }
else if (typeString == QLatin1String(NM_SETTING_VLAN_SETTING_NAME)) {
371 }
else if (typeString == QLatin1String(NM_SETTING_VPN_SETTING_NAME)) {
373 }
else if (typeString == QLatin1String(NM_SETTING_WIMAX_SETTING_NAME)) {
375 }
else if (typeString == QLatin1String(NM_SETTING_WIRED_SETTING_NAME)) {
377 }
else if (typeString == QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME)) {
379 }
else if (typeString == QLatin1String(NM_SETTING_TEAM_SETTING_NAME)) {
381 }
else if (typeString == QLatin1String(NM_SETTING_GENERIC_SETTING_NAME)) {
383 }
else if (typeString == QLatin1String(NM_SETTING_TUN_SETTING_NAME)) {
385 }
else if (typeString == QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME)) {
387 }
else if (typeString == QLatin1String(NM_SETTING_WIREGUARD_SETTING_NAME)) {
389 }
else if (typeString == QLatin1String(NM_SETTING_LOOPBACK_SETTING_NAME)) {
396QString NetworkManager::ConnectionSettings::typeAsString(NetworkManager::ConnectionSettings::ConnectionType type)
402 typeString = QLatin1String(NM_SETTING_ADSL_SETTING_NAME);
405 typeString = QLatin1String(NM_SETTING_BOND_SETTING_NAME);
408 typeString = QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME);
411 typeString = QLatin1String(NM_SETTING_BRIDGE_SETTING_NAME);
414 typeString = QLatin1String(NM_SETTING_CDMA_SETTING_NAME);
417 typeString = QLatin1String(NM_SETTING_GSM_SETTING_NAME);
420 typeString = QLatin1String(NM_SETTING_INFINIBAND_SETTING_NAME);
423 typeString = QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME);
426 typeString = QLatin1String(NM_SETTING_PPPOE_SETTING_NAME);
429 typeString = QLatin1String(NM_SETTING_VLAN_SETTING_NAME);
432 typeString = QLatin1String(NM_SETTING_VPN_SETTING_NAME);
435 typeString = QLatin1String(NM_SETTING_WIMAX_SETTING_NAME);
438 typeString = QLatin1String(NM_SETTING_WIRED_SETTING_NAME);
441 typeString = QLatin1String(NM_SETTING_WIRELESS_SETTING_NAME);
444 typeString = QLatin1String(NM_SETTING_TEAM_SETTING_NAME);
447 typeString = QLatin1String(NM_SETTING_GENERIC_SETTING_NAME);
450 typeString = QLatin1String(NM_SETTING_TUN_SETTING_NAME);
453 typeString = QLatin1String(NM_SETTING_IP_TUNNEL_SETTING_NAME);
456 typeString = QLatin1String(NM_SETTING_WIREGUARD_SETTING_NAME);
459 typeString = QLatin1String(NM_SETTING_LOOPBACK_SETTING_NAME);
468QString NetworkManager::ConnectionSettings::createNewUuid()
473NetworkManager::ConnectionSettings::ConnectionSettings()
474 : d_ptr(new ConnectionSettingsPrivate(this))
478NetworkManager::ConnectionSettings::ConnectionSettings(NetworkManager::ConnectionSettings::ConnectionType type, NMBluetoothCapabilities bt_cap)
479 : d_ptr(new ConnectionSettingsPrivate(this))
481 setConnectionType(type, bt_cap);
484NetworkManager::ConnectionSettings::ConnectionSettings(
const NetworkManager::ConnectionSettings::Ptr &other)
485 : d_ptr(new ConnectionSettingsPrivate(this))
487 Q_D(ConnectionSettings);
490 setUuid(other->uuid());
491 setInterfaceName(other->interfaceName());
492 setConnectionType(other->connectionType());
493 setPermissions(other->permissions());
494 setAutoconnect(other->autoconnect());
495 setAutoconnectPriority(other->autoconnectPriority());
496 setTimestamp(other->timestamp());
497 setReadOnly(other->readOnly());
498 setZone(other->zone());
499 setMaster(other->master());
500 setSlaveType(other->slaveType());
501 setGatewayPingTimeout(other->gatewayPingTimeout());
502 setAutoconnectRetries(other->autoconnectRetries());
503 setAutoconnectSlaves(other->autoconnectSlaves());
504 setLldp(other->lldp());
505 setMetered(other->metered());
506 setMdns(other->mdns());
507 setStableId(other->stableId());
509 d->initSettings(other);
512NetworkManager::ConnectionSettings::ConnectionSettings(
const NMVariantMapMap &map)
513 : d_ptr(new ConnectionSettingsPrivate(this))
518NetworkManager::ConnectionSettings::~ConnectionSettings()
520 d_ptr->clearSettings();
525void NetworkManager::ConnectionSettings::fromMap(
const NMVariantMapMap &map)
527 QVariantMap connectionSettings =
map.value(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME));
529 setId(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_ID)).
toString());
530 setUuid(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_UUID)).
toString());
531 setConnectionType(typeFromString(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_TYPE)).
toString()));
533 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_INTERFACE_NAME))) {
534 setInterfaceName(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_INTERFACE_NAME)).
toString());
536 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS))) {
537 const QStringList permissions = connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS)).toStringList();
538 for (
const QString &permission : permissions) {
540 addToPermissions(split.
at(1), split.
at(2));
544 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT))) {
545 setAutoconnect(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT)).toBool());
548 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY))) {
549 setAutoconnectPriority(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY)).toInt());
552 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_TIMESTAMP))) {
553 const int timestamp = connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_TIMESTAMP)).toInt();
557 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_READ_ONLY))) {
558 setReadOnly(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_READ_ONLY)).toBool());
561 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_ZONE))) {
562 setZone(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_ZONE)).
toString());
565 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_MASTER))) {
566 setMaster(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_MASTER)).
toString());
569 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_SLAVE_TYPE))) {
570 setSlaveType(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_SLAVE_TYPE)).
toString());
573 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_SECONDARIES))) {
574 setSecondaries(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_SECONDARIES)).toStringList());
577 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT))) {
578 setGatewayPingTimeout(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT)).toUInt());
581 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES))) {
582 setAutoconnectRetries(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES)).toInt());
585 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES))) {
586 setAutoconnectSlaves(
587 (NetworkManager::ConnectionSettings::AutoconnectSlaves)connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES)).toInt());
590 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_LLDP))) {
591 setLldp((NetworkManager::ConnectionSettings::Lldp)connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_LLDP)).toInt());
594 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_METERED))) {
595 setMetered((NetworkManager::ConnectionSettings::Metered)connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_METERED)).toInt());
598 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_MDNS))) {
599 setMdns((NetworkManager::ConnectionSettings::Mdns)connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_MDNS)).toInt());
602 if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_STABLE_ID))) {
603 setStableId(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_STABLE_ID)).
toString());
606 const auto settingsList = settings();
607 for (
const Setting::Ptr &setting : settingsList) {
608 if (
map.contains(setting->name())) {
609 setting->fromMap(
map.value(setting->name()));
610 setting->setInitialized(
true);
612 setting->setInitialized(
false);
619 NetworkManager::Security8021xSetting::EapMethod method;
620}
constexpr const eap_methods[] = {
621 {
"PEAP", NetworkManager::Security8021xSetting::EapMethodPeap},
622 {
"PWD", NetworkManager::Security8021xSetting::EapMethodPwd},
623 {
"TLS", NetworkManager::Security8021xSetting::EapMethodTls},
624 {
"TTLS", NetworkManager::Security8021xSetting::EapMethodTtls},
629 NetworkManager::Security8021xSetting::AuthMethod method;
630}
constexpr const auth_methods[] = {
631 {
"GTC", NetworkManager::Security8021xSetting::AuthMethodGtc},
632 {
"MSCHAP", NetworkManager::Security8021xSetting::AuthMethodMschap},
633 {
"MSCHAPV2", NetworkManager::Security8021xSetting::AuthMethodMschapv2},
634 {
"PAP", NetworkManager::Security8021xSetting::AuthMethodPap},
637void NetworkManager::ConnectionSettings::fromMeCard(
const QVariantMap &map)
639 const auto ssid =
map.value(QLatin1String(
"S")).toString();
643 wifiSetting->setInitialized(
true);
644 wifiSetting->setSsid(ssid.toUtf8());
647 const auto securityType =
map.value(QLatin1String(
"T")).toString();
649 if (!securityType.isEmpty() && securityType != QLatin1String(
"nopass")) {
650 wifiSecurity->setInitialized(
true);
653 if (securityType == QLatin1String(
"WPA") || securityType == QLatin1String(
"WEP")) {
654 wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
655 wifiSecurity->setPsk(
map.value(QLatin1String(
"P")).
toString());
656 wifiSecurity->setPskFlags(NetworkManager::Setting::AgentOwned);
657 }
else if (securityType == QLatin1String(
"SAE")) {
658 wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::SAE);
659 wifiSecurity->setPsk(
map.value(QLatin1String(
"P")).
toString());
660 wifiSecurity->setPskFlags(NetworkManager::Setting::AgentOwned);
661 }
else if (securityType == QLatin1String(
"WPA2-EAP")) {
662 wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
664 sec8021x->setAnonymousIdentity(
map.value(QLatin1String(
"A")).
toString());
665 sec8021x->setIdentity(
map.value(QLatin1String(
"I")).
toString());
666 sec8021x->setPassword(
map.value(QLatin1String(
"P")).
toString());
668 const auto eapMethod =
map.value(QLatin1String(
"E")).toString();
669 for (
const auto &method : eap_methods) {
670 if (eapMethod == QLatin1String(method.name)) {
671 sec8021x->setEapMethods({method.method});
675 const auto phase2AuthMethod =
map.value(QLatin1String(
"PH2")).toString();
676 for (
const auto &method : auth_methods) {
677 if (phase2AuthMethod == QLatin1String(method.name)) {
678 sec8021x->setPhase2AuthMethod(method.method);
685NMVariantMapMap NetworkManager::ConnectionSettings::toMap()
const
687 NMVariantMapMap result;
688 QVariantMap connectionSetting;
690 if (!
id().isEmpty()) {
691 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_ID),
id());
694 if (!uuid().isEmpty()) {
695 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_UUID), uuid());
698 if (connectionType()) {
699 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_TYPE), typeAsString(connectionType()));
702 if (!interfaceName().isEmpty()) {
703 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_INTERFACE_NAME), interfaceName());
706 if (!permissions().isEmpty()) {
708 QHash<QString, QString> perms = permissions();
709 QHash<QString, QString>::const_iterator it = perms.
constBegin();
711 const QString tmp =
"user:" + it.key() +
':' + it.value();
716 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS), perm);
719 if (!autoconnect()) {
720 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT), autoconnect());
723 if (autoconnectPriority()) {
724 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY), autoconnectPriority());
728 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_TIMESTAMP), timestamp().toSecsSinceEpoch());
732 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_READ_ONLY), readOnly());
735 if (!zone().isEmpty()) {
736 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_ZONE), zone());
739 if (!master().isEmpty()) {
740 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_MASTER), master());
743 if (!slaveType().isEmpty()) {
744 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_SLAVE_TYPE), slaveType());
747 if (!secondaries().isEmpty()) {
748 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_SECONDARIES), secondaries());
751 if (gatewayPingTimeout()) {
752 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT), gatewayPingTimeout());
755 if (autoconnectRetries() >= 0) {
756 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES), autoconnectRetries());
759 connectionSetting.
insert(QLatin1String(NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES), autoconnectSlaves());
760 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_LLDP), lldp());
761 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_METERED),
metered());
763 if (mdns() != MdnsDefault) {
764 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_MDNS), mdns());
767 if (!stableId().isEmpty()) {
768 connectionSetting.insert(QLatin1String(NM_SETTING_CONNECTION_STABLE_ID), stableId());
771 result.
insert(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME), connectionSetting);
773 const auto settingsList = settings();
774 for (
const Setting::Ptr &setting : settingsList) {
775 QVariantMap
map = setting->toMap();
776 if (!setting->isNull()) {
777 result.
insert(setting->name(), map);
783QString NetworkManager::ConnectionSettings::name()
const
790void NetworkManager::ConnectionSettings::setId(
const QString &
id)
797QString NetworkManager::ConnectionSettings::id()
const
804void NetworkManager::ConnectionSettings::setUuid(
const QString &uuid)
811QString NetworkManager::ConnectionSettings::uuid()
const
818void NetworkManager::ConnectionSettings::setInterfaceName(
const QString &interfaceName)
822 d->interfaceName = interfaceName;
825QString NetworkManager::ConnectionSettings::interfaceName()
const
829 return d->interfaceName;
832void NetworkManager::ConnectionSettings::setConnectionType(NetworkManager::ConnectionSettings::ConnectionType type, NMBluetoothCapabilities bt_cap)
837 d->initSettings(bt_cap);
840NetworkManager::ConnectionSettings::ConnectionType NetworkManager::ConnectionSettings::connectionType()
const
847void NetworkManager::ConnectionSettings::addToPermissions(
const QString &user,
const QString &type)
851 d->permissions.insert(user, type);
854void NetworkManager::ConnectionSettings::setPermissions(
const QHash<QString, QString> &perm)
858 d->permissions = perm;
861QHash<QString, QString> NetworkManager::ConnectionSettings::permissions()
const
865 return d->permissions;
868void NetworkManager::ConnectionSettings::setAutoconnect(
bool autoconnect)
872 d->autoconnect = autoconnect;
875bool NetworkManager::ConnectionSettings::autoconnect()
const
879 return d->autoconnect;
882void NetworkManager::ConnectionSettings::setAutoconnectPriority(
int priority)
886 d->autoconnectPriority = priority;
889int NetworkManager::ConnectionSettings::autoconnectPriority()
const
893 return d->autoconnectPriority;
896void NetworkManager::ConnectionSettings::setTimestamp(
const QDateTime ×tamp)
900 d->timestamp = timestamp;
903QDateTime NetworkManager::ConnectionSettings::timestamp()
const
910void NetworkManager::ConnectionSettings::setReadOnly(
bool readonly)
914 d->readOnly = readonly;
917bool NetworkManager::ConnectionSettings::readOnly()
const
924void NetworkManager::ConnectionSettings::setZone(
const QString &zone)
931QString NetworkManager::ConnectionSettings::zone()
const
938bool NetworkManager::ConnectionSettings::isSlave()
const
942 return !d->master.isEmpty() && !d->slaveType.isEmpty();
945void NetworkManager::ConnectionSettings::setMaster(
const QString &master)
952QString NetworkManager::ConnectionSettings::master()
const
959void NetworkManager::ConnectionSettings::setSlaveType(
const QString &type)
966QString NetworkManager::ConnectionSettings::slaveType()
const
973void NetworkManager::ConnectionSettings::setSecondaries(
const QStringList &secondaries)
977 d->secondaries = secondaries;
980QStringList NetworkManager::ConnectionSettings::secondaries()
const
984 return d->secondaries;
987void NetworkManager::ConnectionSettings::setGatewayPingTimeout(quint32 timeout)
991 d->gatewayPingTimeout = timeout;
994quint32 NetworkManager::ConnectionSettings::gatewayPingTimeout()
const
998 return d->gatewayPingTimeout;
1001int NetworkManager::ConnectionSettings::autoconnectRetries()
const
1005 return d->autoconnectRetries;
1008void NetworkManager::ConnectionSettings::setAutoconnectRetries(
int retries)
1012 d->autoconnectRetries = retries;
1015NetworkManager::ConnectionSettings::AutoconnectSlaves NetworkManager::ConnectionSettings::autoconnectSlaves()
const
1019 return d->autoconnectSlaves;
1022void NetworkManager::ConnectionSettings::setAutoconnectSlaves(NetworkManager::ConnectionSettings::AutoconnectSlaves autoconnectSlaves)
1026 d->autoconnectSlaves = autoconnectSlaves;
1029NetworkManager::ConnectionSettings::Lldp NetworkManager::ConnectionSettings::lldp()
const
1036void NetworkManager::ConnectionSettings::setLldp(NetworkManager::ConnectionSettings::Lldp lldp)
1043NetworkManager::ConnectionSettings::Metered NetworkManager::ConnectionSettings::metered()
const
1050void NetworkManager::ConnectionSettings::setMetered(NetworkManager::ConnectionSettings::Metered
metered)
1057NetworkManager::ConnectionSettings::Mdns NetworkManager::ConnectionSettings::mdns()
const
1064void NetworkManager::ConnectionSettings::setMdns(NetworkManager::ConnectionSettings::Mdns mdns)
1071QString NetworkManager::ConnectionSettings::stableId()
const
1078void NetworkManager::ConnectionSettings::setStableId(
const QString &stableId)
1082 d->stableId = stableId;
1085NetworkManager::Setting::Ptr NetworkManager::ConnectionSettings::setting(Setting::SettingType type)
const
1087 const auto settingsList = settings();
1088 for (
const Setting::Ptr &setting : settingsList) {
1089 if (setting->type() == type) {
1094 return Setting::Ptr();
1097NetworkManager::Setting::Ptr NetworkManager::ConnectionSettings::setting(
const QString &type)
const
1099 return setting(Setting::typeFromString(type));
1102NetworkManager::Setting::List NetworkManager::ConnectionSettings::settings()
const
1109QDebug NetworkManager::operator<<(QDebug dbg,
const NetworkManager::ConnectionSettings &setting)
1111 dbg.
nospace() <<
"CONNECTION SETTINGS\n";
1112 dbg.
nospace() <<
"===================\n";
1114 dbg.
nospace() << NM_SETTING_CONNECTION_ID <<
": " << setting.id() <<
'\n';
1115 dbg.
nospace() << NM_SETTING_CONNECTION_UUID <<
": " << setting.uuid() <<
'\n';
1116 dbg.
nospace() << NM_SETTING_CONNECTION_INTERFACE_NAME <<
": " << setting.interfaceName() <<
'\n';
1117 dbg.
nospace() << NM_SETTING_CONNECTION_TYPE <<
": " << setting.typeAsString(setting.connectionType()) <<
'\n';
1118 dbg.
nospace() << NM_SETTING_CONNECTION_PERMISSIONS <<
": " << setting.permissions() <<
'\n';
1119 dbg.
nospace() << NM_SETTING_CONNECTION_AUTOCONNECT <<
": " << setting.autoconnect() <<
'\n';
1120 dbg.
nospace() << NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY <<
": " << setting.autoconnectPriority() <<
'\n';
1122 dbg.
nospace() << NM_SETTING_CONNECTION_READ_ONLY <<
": " << setting.readOnly() <<
'\n';
1123 dbg.
nospace() << NM_SETTING_CONNECTION_ZONE <<
": " << setting.zone() <<
'\n';
1124 dbg.
nospace() << NM_SETTING_CONNECTION_MASTER <<
": " << setting.master() <<
'\n';
1125 dbg.
nospace() << NM_SETTING_CONNECTION_SLAVE_TYPE <<
": " << setting.slaveType() <<
'\n';
1126 dbg.
nospace() << NM_SETTING_CONNECTION_SECONDARIES <<
": " << setting.secondaries() <<
'\n';
1127 dbg.
nospace() << NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT <<
": " << setting.gatewayPingTimeout() <<
'\n';
1128 dbg.
nospace() << NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES <<
": " << setting.autoconnectRetries() <<
'\n';
1129 dbg.
nospace() << NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES <<
": " << setting.autoconnectSlaves() <<
'\n';
1130 dbg.
nospace() << NM_SETTING_CONNECTION_LLDP <<
": " << setting.lldp() <<
'\n';
1131 dbg.
nospace() << NM_SETTING_CONNECTION_METERED <<
": " << setting.metered() <<
'\n';
1132 dbg.
nospace() << NM_SETTING_CONNECTION_MDNS <<
": " << setting.mdns() <<
'\n';
1133 dbg.
nospace() << NM_SETTING_CONNECTION_STABLE_ID <<
": " << setting.stableId() <<
'\n';
1134 dbg.
nospace() <<
"===================\n";
1135 const auto settingsList = setting.settings();
1136 for (
const Setting::Ptr &settingPtr : settingsList) {
1137 dbg.
nospace() << settingPtr->typeAsString(settingPtr->type()).toUpper() <<
" SETTINGS\n";
1138 dbg.
nospace() <<
"---------------------------\n";
1139 switch (settingPtr->type()) {
1141 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::AdslSetting>().data());
1144 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::BondSetting>().data());
1146 case Setting::Bluetooth:
1147 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::BluetoothSetting>().data());
1149 case Setting::Bridge:
1150 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::BridgeSetting>().data());
1152 case Setting::BridgePort:
1153 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::BridgePortSetting>().data());
1156 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::CdmaSetting>().data());
1159 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::GsmSetting>().data());
1161 case Setting::Infiniband:
1162 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::InfinibandSetting>().data());
1165 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::Ipv4Setting>().data());
1168 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::Ipv6Setting>().data());
1170 case Setting::OlpcMesh:
1171 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::OlpcMeshSetting>().data());
1174 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::PppSetting>().data());
1176 case Setting::Pppoe:
1177 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::PppoeSetting>().data());
1179 case Setting::Security8021x:
1180 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::Security8021xSetting>().data());
1182 case Setting::Serial:
1183 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::SerialSetting>().data());
1186 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::VlanSetting>().data());
1189 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::VpnSetting>().data());
1191 case Setting::Wimax:
1192 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::WimaxSetting>().data());
1194 case Setting::Wired:
1195 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::WiredSetting>().data());
1197 case Setting::Wireless:
1198 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::WirelessSetting>().data());
1200 case Setting::WirelessSecurity:
1201 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::WirelessSecuritySetting>().data());
1204 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::TeamSetting>().data());
1207 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::TunSetting>().data());
1209 case Setting::IpTunnel:
1210 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::IpTunnelSetting>().data());
1212 case Setting::WireGuard:
1213 dbg.
nospace() << *(settingPtr.staticCast<NetworkManager::WireGuardSetting>().data());
1216 dbg.
nospace() << *settingPtr.data();
Represents collection of all connection settings.
Represents 802.1x wireless security setting.
Represents wireless security setting.
Represents wireless setting.
char * toString(const EngineQuery &query)
bool isValid(QStringView ifopt)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
This class allows querying the underlying system to discover the available network interfaces and rea...
NETWORKMANAGERQT_EXPORT NetworkManager::Device::MeteredStatus metered()
NETWORKMANAGERQT_EXPORT bool checkVersion(const int x, const int y, const int z)
Checks if NetworkManager version is at least x.y.z.
QDateTime fromSecsSinceEpoch(qint64 secs)
qint64 toSecsSinceEpoch() const const
const_iterator constBegin() const const
const_iterator constEnd() const const
const_reference at(qsizetype i) const const
iterator insert(const Key &key, const T &value)
QSharedPointer< X > dynamicCast() const const
QString mid(qsizetype position, qsizetype n) const const
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QString toString(StringFormat mode) const const