Make it possible to remove manually configured IPv4 addresses

main
Aaron Rainbolt 1 year ago
parent 4e07bf46e2
commit 807b01d5d2

@ -428,6 +428,7 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
{
// Contains adapted code from plasma-nm
bool wipeClonedMacAddress = false;
bool wipeIpv4AddressConfig = false;
bool ensure802_1xSettings = false;
NetworkManager::Connection::Ptr conn = NetworkManager::findConnectionByUuid(connUuidStr);
NetworkManager::ConnectionSettings::Ptr connSettings = conn->settings();
@ -528,6 +529,8 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
QList<NetworkManager::IpAddress> ipv4AddrList = settings["ipv4AddressList"].value<QList<NetworkManager::IpAddress>>();
if (!ipv4AddrList.isEmpty()) {
connIpv4Setting->setAddresses(ipv4AddrList);
} else {
wipeIpv4AddressConfig = true;
}
}
@ -817,6 +820,16 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
if (ensure802_1xSettings) {
connSettingsMap.insert("802-1x", secSetting.toMap());
}
if (wipeIpv4AddressConfig) {
QVariantMap ipv4SettingsMap = connSettingsMap.value("ipv4");
if (!ipv4SettingsMap.isEmpty()) {
ipv4SettingsMap.remove("address-data");
ipv4SettingsMap.remove("addresses");
ipv4SettingsMap.remove("gateway");
connSettingsMap.remove("ipv4");
connSettingsMap.insert("ipv4", ipv4SettingsMap);
}
}
if (wipeClonedMacAddress) {
QVariantMap ethSettingsMap = connSettingsMap.value("802-3-ethernet");
if (!ethSettingsMap.isEmpty()) {

Loading…
Cancel
Save