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)
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:
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)
408 typeString =
QLatin1String(NM_SETTING_BLUETOOTH_SETTING_NAME);
420 typeString =
QLatin1String(NM_SETTING_INFINIBAND_SETTING_NAME);
423 typeString =
QLatin1String(NM_SETTING_OLPC_MESH_SETTING_NAME);
441 typeString =
QLatin1String(NM_SETTING_WIRELESS_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);
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));
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))) {
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))) {
565 if (connectionSettings.contains(
QLatin1String(NM_SETTING_CONNECTION_MASTER))) {
569 if (connectionSettings.contains(
QLatin1String(NM_SETTING_CONNECTION_SLAVE_TYPE))) {
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))) {
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)
642 auto wifiSetting = setting(Setting::Wireless).
dynamicCast<WirelessSetting>();
643 wifiSetting->setInitialized(
true);
644 wifiSetting->setSsid(ssid.toUtf8());
646 auto wifiSecurity = setting(Setting::WirelessSecurity).
dynamicCast<WirelessSecuritySetting>();
649 if (!securityType.isEmpty() && securityType !=
QLatin1String(
"nopass")) {
650 wifiSecurity->setInitialized(
true);
654 wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
656 wifiSecurity->setPskFlags(NetworkManager::Setting::AgentOwned);
658 wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::SAE);
660 wifiSecurity->setPskFlags(NetworkManager::Setting::AgentOwned);
662 wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
663 auto sec8021x = setting(Setting::Security8021x).
dynamicCast<Security8021xSetting>();
669 for (
const auto &method : eap_methods) {
671 sec8021x->setEapMethods({method.method});
676 for (
const auto &method : auth_methods) {
678 sec8021x->setPhase2AuthMethod(method.method);
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()) {
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());
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());
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
785 Q_D(
const ConnectionSettings);
790void NetworkManager::ConnectionSettings::setId(
const QString &
id)
792 Q_D(ConnectionSettings);
797QString NetworkManager::ConnectionSettings::id()
const
799 Q_D(
const ConnectionSettings);
804void NetworkManager::ConnectionSettings::setUuid(
const QString &uuid)
806 Q_D(ConnectionSettings);
811QString NetworkManager::ConnectionSettings::uuid()
const
813 Q_D(
const ConnectionSettings);
818void NetworkManager::ConnectionSettings::setInterfaceName(
const QString &interfaceName)
820 Q_D(ConnectionSettings);
822 d->interfaceName = interfaceName;
825QString NetworkManager::ConnectionSettings::interfaceName()
const
827 Q_D(
const ConnectionSettings);
829 return d->interfaceName;
832void NetworkManager::ConnectionSettings::setConnectionType(NetworkManager::ConnectionSettings::ConnectionType type, NMBluetoothCapabilities bt_cap)
834 Q_D(ConnectionSettings);
837 d->initSettings(bt_cap);
840NetworkManager::ConnectionSettings::ConnectionType NetworkManager::ConnectionSettings::connectionType()
const
842 Q_D(
const ConnectionSettings);
847void NetworkManager::ConnectionSettings::addToPermissions(
const QString &user,
const QString &type)
849 Q_D(ConnectionSettings);
851 d->permissions.insert(user, type);
856 Q_D(ConnectionSettings);
858 d->permissions = perm;
863 Q_D(
const ConnectionSettings);
865 return d->permissions;
868void NetworkManager::ConnectionSettings::setAutoconnect(
bool autoconnect)
870 Q_D(ConnectionSettings);
872 d->autoconnect = autoconnect;
875bool NetworkManager::ConnectionSettings::autoconnect()
const
877 Q_D(
const ConnectionSettings);
879 return d->autoconnect;
882void NetworkManager::ConnectionSettings::setAutoconnectPriority(
int priority)
884 Q_D(ConnectionSettings);
886 d->autoconnectPriority = priority;
889int NetworkManager::ConnectionSettings::autoconnectPriority()
const
891 Q_D(
const ConnectionSettings);
893 return d->autoconnectPriority;
896void NetworkManager::ConnectionSettings::setTimestamp(
const QDateTime ×tamp)
898 Q_D(ConnectionSettings);
900 d->timestamp = timestamp;
903QDateTime NetworkManager::ConnectionSettings::timestamp()
const
905 Q_D(
const ConnectionSettings);
910void NetworkManager::ConnectionSettings::setReadOnly(
bool readonly)
912 Q_D(ConnectionSettings);
914 d->readOnly = readonly;
917bool NetworkManager::ConnectionSettings::readOnly()
const
919 Q_D(
const ConnectionSettings);
924void NetworkManager::ConnectionSettings::setZone(
const QString &zone)
926 Q_D(ConnectionSettings);
931QString NetworkManager::ConnectionSettings::zone()
const
933 Q_D(
const ConnectionSettings);
938bool NetworkManager::ConnectionSettings::isSlave()
const
940 Q_D(
const ConnectionSettings);
942 return !d->master.isEmpty() && !d->slaveType.isEmpty();
945void NetworkManager::ConnectionSettings::setMaster(
const QString &master)
947 Q_D(ConnectionSettings);
952QString NetworkManager::ConnectionSettings::master()
const
954 Q_D(
const ConnectionSettings);
959void NetworkManager::ConnectionSettings::setSlaveType(
const QString &type)
961 Q_D(ConnectionSettings);
966QString NetworkManager::ConnectionSettings::slaveType()
const
968 Q_D(
const ConnectionSettings);
973void NetworkManager::ConnectionSettings::setSecondaries(
const QStringList &secondaries)
975 Q_D(ConnectionSettings);
977 d->secondaries = secondaries;
980QStringList NetworkManager::ConnectionSettings::secondaries()
const
982 Q_D(
const ConnectionSettings);
984 return d->secondaries;
987void NetworkManager::ConnectionSettings::setGatewayPingTimeout(quint32 timeout)
989 Q_D(ConnectionSettings);
991 d->gatewayPingTimeout = timeout;
994quint32 NetworkManager::ConnectionSettings::gatewayPingTimeout()
const
996 Q_D(
const ConnectionSettings);
998 return d->gatewayPingTimeout;
1001int NetworkManager::ConnectionSettings::autoconnectRetries()
const
1003 Q_D(
const ConnectionSettings);
1005 return d->autoconnectRetries;
1008void NetworkManager::ConnectionSettings::setAutoconnectRetries(
int retries)
1010 Q_D(ConnectionSettings);
1012 d->autoconnectRetries = retries;
1015NetworkManager::ConnectionSettings::AutoconnectSlaves NetworkManager::ConnectionSettings::autoconnectSlaves()
const
1017 Q_D(
const ConnectionSettings);
1019 return d->autoconnectSlaves;
1022void NetworkManager::ConnectionSettings::setAutoconnectSlaves(NetworkManager::ConnectionSettings::AutoconnectSlaves autoconnectSlaves)
1024 Q_D(ConnectionSettings);
1026 d->autoconnectSlaves = autoconnectSlaves;
1029NetworkManager::ConnectionSettings::Lldp NetworkManager::ConnectionSettings::lldp()
const
1031 Q_D(
const ConnectionSettings);
1036void NetworkManager::ConnectionSettings::setLldp(NetworkManager::ConnectionSettings::Lldp lldp)
1038 Q_D(ConnectionSettings);
1043NetworkManager::ConnectionSettings::Metered NetworkManager::ConnectionSettings::metered()
const
1045 Q_D(
const ConnectionSettings);
1050void NetworkManager::ConnectionSettings::setMetered(NetworkManager::ConnectionSettings::Metered
metered)
1052 Q_D(ConnectionSettings);
1057NetworkManager::ConnectionSettings::Mdns NetworkManager::ConnectionSettings::mdns()
const
1059 Q_D(
const ConnectionSettings);
1064void NetworkManager::ConnectionSettings::setMdns(NetworkManager::ConnectionSettings::Mdns mdns)
1066 Q_D(ConnectionSettings);
1071QString NetworkManager::ConnectionSettings::stableId()
const
1073 Q_D(
const ConnectionSettings);
1078void NetworkManager::ConnectionSettings::setStableId(
const QString &stableId)
1080 Q_D(ConnectionSettings);
1082 d->stableId = stableId;
1087 const auto settingsList = settings();
1088 for (
const Setting::Ptr &setting : settingsList) {
1089 if (setting->type() == type) {
1094 return Setting::Ptr();
1099 return setting(Setting::typeFromString(type));
1104 Q_D(
const ConnectionSettings);
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()) {
1146 case Setting::Bluetooth:
1149 case Setting::Bridge:
1152 case Setting::BridgePort:
1161 case Setting::Infiniband:
1170 case Setting::OlpcMesh:
1176 case Setting::Pppoe:
1179 case Setting::Security8021x:
1182 case Setting::Serial:
1191 case Setting::Wimax:
1194 case Setting::Wired:
1197 case Setting::Wireless:
1200 case Setting::WirelessSecurity:
1209 case Setting::IpTunnel:
1212 case Setting::WireGuard:
1216 dbg.
nospace() << *settingPtr.data();
Represents bluetooth setting.
Represents bridge port setting.
Represents bridge setting.
Represents collection of all connection settings.
Represents infiniband setting.
Represents IpTunnel setting.
Represents olpc mesh setting.
Represents pppoe setting.
Represents 802.1x wireless security setting.
Represents serial setting.
Represents generic setting.
Represents wimax setting.
Represents generic setting.
Represents wired 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)
T value(const Key &key, const T &defaultValue) const const
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