Diffstat (limited to 'noncore/settings/networksettings/interfaces.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/interfaces.cpp b/noncore/settings/networksettings/interfaces.cpp index eef42df..0927258 100644 --- a/noncore/settings/networksettings/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces.cpp @@ -164,12 +164,38 @@ bool Interfaces::addInterface(QString interface, QString family, QString method) interfaces.append(""); interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); return true; } /** + * Copies interface with name interface to name newInterface + * @param newInterface name of the new interface. + * @return bool true if successfull + */ +bool Interfaces::copyInterface(QString interface, QString newInterface){ + if(!setInterface(interface)) return false; + + QStringList::Iterator it = currentIface; + it++; + + bool error; + addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); + if(!setInterface(newInterface)) return false; + QStringList::Iterator newIface = currentIface; + newIface++; + + for ( it; it != interfaces.end(); ++it ){ + if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) + break; + newIface = interfaces.insert(newIface, *it); + } + + return true; +} + +/** * Remove the currently selected interface and all of its options. * @return bool if successfull or not. */ bool Interfaces::removeInterface(){ if(currentIface == interfaces.end()) return false; @@ -398,20 +424,34 @@ QString Interfaces::getScript(bool &error){ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ bool found = false; iterator = interfaces.end(); for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { QString line = (*it).simplifyWhiteSpace(); if(line.contains(stanza) && line.contains(option)){ + uint point = line.find(option); + bool valid = true; + if(point > 0){ + // There are more chars in the line. check +1 + if(line.at(point-1) != ' ') + valid = false; + } + point += option.length(); + if(point < line.length()-1){ + // There are more chars in the line. check -1 + if(line.at(point) != ' ') + valid = false; + } + if(valid){ if(found == true){ qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); } - qDebug("Found"); found = true; iterator = it; } } + } return found; } /** * Sets a value of an option in a stanza * @param start the start of the stanza |