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 @@ -169,2 +169,28 @@ bool Interfaces::addInterface(QString interface, QString family, QString method) /** + * 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. @@ -403,2 +429,16 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator 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){ @@ -406,3 +446,2 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator } - qDebug("Found"); found = true; @@ -411,2 +450,3 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator } + } return found; |