Diffstat (limited to 'noncore/settings/networksettings/interfaces.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces.cpp | 50 |
1 files changed, 45 insertions, 5 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 | |||
@@ -168,4 +168,30 @@ bool Interfaces::addInterface(QString interface, QString family, QString method) | |||
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Copies interface with name interface to name newInterface | ||
171 | * @param newInterface name of the new interface. | ||
172 | * @return bool true if successfull | ||
173 | */ | ||
174 | bool Interfaces::copyInterface(QString interface, QString newInterface){ | ||
175 | if(!setInterface(interface)) return false; | ||
176 | |||
177 | QStringList::Iterator it = currentIface; | ||
178 | it++; | ||
179 | |||
180 | bool error; | ||
181 | addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); | ||
182 | if(!setInterface(newInterface)) return false; | ||
183 | QStringList::Iterator newIface = currentIface; | ||
184 | newIface++; | ||
185 | |||
186 | for ( it; it != interfaces.end(); ++it ){ | ||
187 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) | ||
188 | break; | ||
189 | newIface = interfaces.insert(newIface, *it); | ||
190 | } | ||
191 | |||
192 | return true; | ||
193 | } | ||
194 | |||
195 | /** | ||
170 | * Remove the currently selected interface and all of its options. | 196 | * Remove the currently selected interface and all of its options. |
171 | * @return bool if successfull or not. | 197 | * @return bool if successfull or not. |
@@ -402,10 +428,24 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator | |||
402 | QString line = (*it).simplifyWhiteSpace(); | 428 | QString line = (*it).simplifyWhiteSpace(); |
403 | if(line.contains(stanza) && line.contains(option)){ | 429 | if(line.contains(stanza) && line.contains(option)){ |
404 | if(found == true){ | 430 | uint point = line.find(option); |
405 | qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); | 431 | bool valid = true; |
432 | if(point > 0){ | ||
433 | // There are more chars in the line. check +1 | ||
434 | if(line.at(point-1) != ' ') | ||
435 | valid = false; | ||
436 | } | ||
437 | point += option.length(); | ||
438 | if(point < line.length()-1){ | ||
439 | // There are more chars in the line. check -1 | ||
440 | if(line.at(point) != ' ') | ||
441 | valid = false; | ||
442 | } | ||
443 | if(valid){ | ||
444 | if(found == true){ | ||
445 | qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); | ||
446 | } | ||
447 | found = true; | ||
448 | iterator = it; | ||
406 | } | 449 | } |
407 | qDebug("Found"); | ||
408 | found = true; | ||
409 | iterator = it; | ||
410 | } | 450 | } |
411 | } | 451 | } |