summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/interfaces/interfaces.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfaces.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp60
1 files changed, 47 insertions, 13 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index 71d0cf5..436e449 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -1,26 +1,27 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qcheckbox.h>
3#include <qfile.h> 4#include <qfile.h>
4#include <qtextstream.h> 5#include <qtextstream.h>
5#include <qregexp.h> 6#include <qregexp.h>
6 7
7// The three stanza's 8// The three stanza's
8#define AUTO "auto" 9#define AUTO "auto"
9#define IFACE "iface" 10#define IFACE "iface"
10#define MAPPING "mapping" 11#define MAPPING "mapping"
11 12
12/** 13/**
13 * Constructor. Reads in the interfaces file and then split the file up by 14 * Constructor. Reads in the interfaces file and then split the file up by
14 * the \n for interfaces variable. 15 * the \n for interfaces variable.
15 * @param useInterfacesFile if an interface file other then the default is 16 * @param useInterfacesFile if an interface file other then the default is
16 * desired to be used it should be passed in. 17 * desired to be used it should be passed in.
17 */ 18 */
18Interfaces::Interfaces(QString useInterfacesFile){ 19Interfaces::Interfaces(QString useInterfacesFile){
19 acceptedFamily.append(INTERFACES_FAMILY_INET); 20 acceptedFamily.append(INTERFACES_FAMILY_INET);
20 acceptedFamily.append(INTERFACES_FAMILY_IPX); 21 acceptedFamily.append(INTERFACES_FAMILY_IPX);
21 acceptedFamily.append(INTERFACES_FAMILY_INET6); 22 acceptedFamily.append(INTERFACES_FAMILY_INET6);
22 23
23 interfacesFile = useInterfacesFile; 24 interfacesFile = useInterfacesFile;
24 QFile file(interfacesFile); 25 QFile file(interfacesFile);
25 if (!file.open(IO_ReadOnly)){ 26 if (!file.open(IO_ReadOnly)){
26 qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); 27 qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() );
@@ -130,63 +131,65 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){
130bool Interfaces::setInterface(QString interface){ 131bool Interfaces::setInterface(QString interface){
131 interface = interface.simplifyWhiteSpace(); 132 interface = interface.simplifyWhiteSpace();
132 interface = interface.replace(QRegExp(" "), ""); 133 interface = interface.replace(QRegExp(" "), "");
133 return setStanza(IFACE, interface, currentIface); 134 return setStanza(IFACE, interface, currentIface);
134} 135}
135 136
136/** 137/**
137 * A quick helper funtion to see if the current interface is set. 138 * A quick helper funtion to see if the current interface is set.
138 * @return bool true if set, false otherwise. 139 * @return bool true if set, false otherwise.
139 */ 140 */
140bool Interfaces::isInterfaceSet() const { 141bool Interfaces::isInterfaceSet() const {
141 return (interfaces.end() != currentIface); 142 return (interfaces.end() != currentIface);
142} 143}
143 144
144/** 145/**
145 * Add a new interface of with the settings - family and method 146 * Add a new interface of with the settings - family and method
146 * @param interface the name of the interface to set. All whitespace is 147 * @param interface the name of the interface to set. All whitespace is
147 * removed from the interface name. 148 * removed from the interface name.
148 * @param family the family of this interface inet or inet, ipx or inet6 149 * @param family the family of this interface inet or inet, ipx or inet6
149 * Must of one of the families defined in interfaces.h 150 * Must of one of the families defined in interfaces.h
150 * @param method for the family. see interfaces man page for family methods. 151 * @param method for the family. see interfaces man page for family methods.
151 * @return true if successfull. 152 * @return true if successfull.
152 */ 153 */
153bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ 154bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
155 qDebug("Interfaces::addInterface(%s)",interface.latin1());
154 if(0 == acceptedFamily.contains(family)) 156 if(0 == acceptedFamily.contains(family))
155 return false; 157 return false;
156 QString newInterface = interface.simplifyWhiteSpace(); 158 QString newInterface = interface.simplifyWhiteSpace();
157 newInterface = newInterface.replace(QRegExp(" "), ""); 159 newInterface = newInterface.replace(QRegExp(" "), "");
158 interfaces.append(""); 160 interfaces.append("");
159 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); 161 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
160 return true; 162 return true;
161} 163}
162 164
163/** 165/**
164 * Copies interface with name interface to name newInterface 166 * Copies interface with name interface to name newInterface
165 * @param newInterface name of the new interface. 167 * @param newInterface name of the new interface.
166 * @return bool true if successfull 168 * @return bool true if successfull
167 */ 169 */
168bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ 170bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
171 qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1());
169 if(!setInterface(interface)) 172 if(!setInterface(interface))
170 return false; 173 return false;
171 174
172 // Store the old interface and bump past the stanza line. 175 // Store the old interface and bump past the stanza line.
173 QStringList::Iterator it = currentIface; 176 QStringList::Iterator it = currentIface;
174 it++; 177 it++;
175 178
176 // Add the new interface 179 // Add the new interface
177 bool error; 180 bool error;
178 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); 181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
179 if(!setInterface(newInterface)) 182 if(!setInterface(newInterface))
180 return false; 183 return false;
181 184
182 QStringList::Iterator newIface = currentIface; 185 QStringList::Iterator newIface = currentIface;
183 newIface++; 186 newIface++;
184 187
185 // Copy all of the lines 188 // Copy all of the lines
186 for ( ; it != interfaces.end(); ++it ){ 189 for ( ; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) 190 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break; 191 break;
189 newIface = interfaces.insert(newIface, *it); 192 newIface = interfaces.insert(newIface, *it);
190 } 193 }
191 194
192 return true; 195 return true;
@@ -251,54 +254,58 @@ QString Interfaces::getInterfaceFamily(bool &error){
251 * @param error set to true if any error occurs, false otherwise. 254 * @param error set to true if any error occurs, false otherwise.
252 */ 255 */
253QString Interfaces::getInterfaceMethod(bool &error){ 256QString Interfaces::getInterfaceMethod(bool &error){
254 QString name = getInterfaceName(error); 257 QString name = getInterfaceName(error);
255 if(error) 258 if(error)
256 return QString(); 259 return QString();
257 QString family = getInterfaceFamily(error); 260 QString family = getInterfaceFamily(error);
258 if(error) 261 if(error)
259 return QString(); 262 return QString();
260 QString line = (*currentIface); 263 QString line = (*currentIface);
261 line = line.mid(QString(IFACE).length()+1, line.length()); 264 line = line.mid(QString(IFACE).length()+1, line.length());
262 line = line.mid(name.length()+1, line.length()); 265 line = line.mid(name.length()+1, line.length());
263 line = line.mid(family.length()+1, line.length()); 266 line = line.mid(family.length()+1, line.length());
264 line = line.simplifyWhiteSpace(); 267 line = line.simplifyWhiteSpace();
265 error = false; 268 error = false;
266 return line; 269 return line;
267} 270}
268 271
269/** 272/**
270 * Sets the interface name to newName. 273 * Sets the interface name to newName.
271 * @param newName the new name of the interface. All whitespace is removed. 274 * @param newName the new name of the interface. All whitespace is removed.
272 * @return bool true if successfull. 275 * @return bool true if successfull.
273 */ 276 */
274bool Interfaces::setInterfaceName(const QString &newName){ 277bool Interfaces::setInterfaceName(const QString &newName){
278 qDebug("setInterfaceName %s", newName.latin1());
275 if(currentIface == interfaces.end()) 279 if(currentIface == interfaces.end())
276 return false; 280 return false;
277 QString name = newName.simplifyWhiteSpace(); 281 QString name = newName.simplifyWhiteSpace();
278 name = name.replace(QRegExp(" "), ""); 282 name = name.replace(QRegExp(" "), "");
279 bool returnValue = false; 283 bool returnValue = false;
280 (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); 284 QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
285 qDebug("setting %s",tmp.latin1());
286
287 (*currentIface) = tmp;
281 return !returnValue; 288 return !returnValue;
282} 289}
283 290
284/** 291/**
285 * Sets the interface family to newName. 292 * Sets the interface family to newName.
286 * @param newName the new name of the interface. Must be one of the families 293 * @param newName the new name of the interface. Must be one of the families
287 * defined in the interfaces.h file. 294 * defined in the interfaces.h file.
288 * @return bool true if successfull. 295 * @return bool true if successfull.
289 */ 296 */
290bool Interfaces::setInterfaceFamily(const QString &newName){ 297bool Interfaces::setInterfaceFamily(const QString &newName){
291 if(currentIface == interfaces.end()) 298 if(currentIface == interfaces.end())
292 return false; 299 return false;
293 if(acceptedFamily.contains(newName)==0) 300 if(acceptedFamily.contains(newName)==0)
294 return false; 301 return false;
295 bool returnValue = false; 302 bool returnValue = false;
296 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); 303 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
297 return !returnValue; 304 return !returnValue;
298} 305}
299 306
300/** 307/**
301 * Sets the interface method to newName 308 * Sets the interface method to newName
302 * @param newName the new name of the interface 309 * @param newName the new name of the interface
303 * @return bool true if successfull. 310 * @return bool true if successfull.
304 */ 311 */
@@ -306,55 +313,61 @@ bool Interfaces::setInterfaceMethod(const QString &newName){
306 if(currentIface == interfaces.end()) 313 if(currentIface == interfaces.end())
307 return false; 314 return false;
308 bool returnValue = false; 315 bool returnValue = false;
309 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); 316 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
310 return !returnValue; 317 return !returnValue;
311} 318}
312 319
313/** 320/**
314 * Get a value for an option in the currently selected interface. For example 321 * Get a value for an option in the currently selected interface. For example
315 * calling getInterfaceOption("address") on the following stanza would 322 * calling getInterfaceOption("address") on the following stanza would
316 * return 192.168.1.1. 323 * return 192.168.1.1.
317 * iface eth0 static 324 * iface eth0 static
318 * address 192.168.1.1 325 * address 192.168.1.1
319 * @param option the options to get the value. 326 * @param option the options to get the value.
320 * @param error set to true if any error occurs, false otherwise. 327 * @param error set to true if any error occurs, false otherwise.
321 * @return QString the options value. QString::null if error == true 328 * @return QString the options value. QString::null if error == true
322 */ 329 */
323QString Interfaces::getInterfaceOption(const QString &option, bool &error){ 330QString Interfaces::getInterfaceOption(const QString &option, bool &error){
324 return getOption(currentIface, option, error); 331 return getOption(currentIface, option, error);
325} 332}
326 333
327/** 334/**
328 * Set a value for an option in the currently selected interface. If option 335 * Set a value for an option in the currently selected interface. If option
329 * doesn't exist then it is added along with the value. 336 * doesn't exist then it is added along with the value.
337 * If value isEmpty() then we will remove the option
338 *
330 * @param option the options to set the value. 339 * @param option the options to set the value.
331 * @param value the value that option should be set to. 340 * @param value the value that option should be set to.
332 * @param error set to true if any error occurs, false otherwise. 341 * @param error set to true if any error occurs, false otherwise.
333 * @return QString the options value. QString::null if error == true 342 * @return QString the options value. QString::null if error == true
334 */ 343 */
335bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ 344bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
336 return setOption(currentIface, option, value); 345 if( value.stripWhiteSpace().isEmpty() )
346 return removeInterfaceOption( option );
347
348 qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1());
349 return setOption(currentIface, option, value);
337} 350}
338 351
339/** 352/**
340 * Removes a value for an option in the currently selected interface. 353 * Removes a value for an option in the currently selected interface.
341 * @param option the options to set the value. 354 * @param option the options to set the value.
342 * @param error set to true if any error occurs, false otherwise. 355 * @param error set to true if any error occurs, false otherwise.
343 * @return QString the options value. QString::null if error == true 356 * @return QString the options value. QString::null if error == true
344 */ 357 */
345bool Interfaces::removeInterfaceOption(const QString &option){ 358bool Interfaces::removeInterfaceOption(const QString &option){
346 return removeOption(currentIface, option); 359 return removeOption(currentIface, option);
347} 360}
348 361
349/** 362/**
350 * Removes a value for an option in the currently selected interface. 363 * Removes a value for an option in the currently selected interface.
351 * @param option the options to set the value. 364 * @param option the options to set the value.
352 * @param value the value that option should be set to. 365 * @param value the value that option should be set to.
353 * @param error set to true if any error occurs, false otherwise. 366 * @param error set to true if any error occurs, false otherwise.
354 * @return QString the options value. QString::null if error == true 367 * @return QString the options value. QString::null if error == true
355 */ 368 */
356bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ 369bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
357 return removeOption(currentIface, option, value); 370 return removeOption(currentIface, option, value);
358} 371}
359 372
360/** 373/**
@@ -471,136 +484,157 @@ bool Interfaces::setStanza(const QString &stanza, const QString &option, QString
471 if(line.at(point) != ' ') 484 if(line.at(point) != ' ')
472 valid = false; 485 valid = false;
473 } 486 }
474 if(valid){ 487 if(valid){
475 if(found == true){ 488 if(found == true){
476 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 489 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
477 } 490 }
478 found = true; 491 found = true;
479 iterator = it; 492 iterator = it;
480 } 493 }
481 } 494 }
482 } 495 }
483 return found; 496 return found;
484} 497}
485 498
486/** 499/**
487 * Sets a value of an option in a stanza 500 * Sets a value of an option in a stanza
488 * @param start the start of the stanza 501 * @param start the start of the stanza
489 * @param option the option to use when setting value. 502 * @param option the option to use when setting value.
490 * @return bool true if successfull, false otherwise. 503 * @return bool true if successfull, false otherwise.
491 */ 504 */
492bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 505bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
493 if(start == interfaces.end()) 506 if(start == interfaces.end())
494 return false; 507 return false;
495 508 qDebug("setting option");
496 bool found = false; 509 bool found = false;
510 bool replaced = false;
511 QStringList::Iterator insertAt = NULL;
497 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 512 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
498 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 513 qDebug(" Interfaces::setOption got line >%s<",(*it).latin1());
499 if(!found && value != ""){ 514 // FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line
500 // Got to the end of the stanza without finding it, so append it. 515 // but since it works with an empty interfaces file I (tille) will not do anything more
501 interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 516 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){
502 } 517 if (found) break;
503 found = true; 518// && it != start){
504 break; 519// if(!found && value != ""){
505 } 520// // Got to the end of the stanza without finding it, so append it.
521// qDebug(" Got to the end of the stanza without finding it, so append it.");
522// interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
523// }
524 qDebug("found 1");
525// interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value));
526 found = true;
527 insertAt = it;
528
529 }
506 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 530 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
507 // Found it in stanza so replace it. 531 // Found it in stanza so replace it.
532 qDebug("found 2");
508 if(found) 533 if(found)
509 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 534 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
510 found = true; 535 found = true;
536 replaced = true;
511 (*it) = QString("\t%1 %2").arg(option).arg(value); 537 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 } 538 }
513 } 539 }
514 if(!found){ 540 if(!found){
541 qDebug("! found insert anyway");
515 QStringList::Iterator p = start; 542 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 543 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true; 544 found = true;
518 } 545 }
546
547 if(found && !replaced){
548 qDebug("found iface but not the option so insert it here...");
549 interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value));
550 }
519 return found; 551 return found;
520} 552}
521 553
522/** 554/**
523 * Removes a stanza and all of its options 555 * Removes a stanza and all of its options
524 * @param stanza the stanza to remove 556 * @param stanza the stanza to remove
525 * @return bool true if successfull. 557 * @return bool true if successfull.
526 */ 558 */
527bool Interfaces::removeStanza(QStringList::Iterator &stanza){ 559bool Interfaces::removeStanza(QStringList::Iterator &stanza){
528 if(stanza == interfaces.end()) 560 if(stanza == interfaces.end())
529 return false; 561 return false;
530 (*stanza) = ""; 562 (*stanza) = "";
531 return removeAllOptions(stanza); 563 return removeAllOptions(stanza);
532} 564}
533 565
534/** 566/**
535 * Removes a option in a stanza 567 * Removes a option in a stanza
536 * @param start the start of the stanza 568 * @param start the start of the stanza
537 * @param option the option to remove 569 * @param option the option to remove
538 * @return bool true if successfull, false otherwise. 570 * @return bool true if successfull, false otherwise.
539 */ 571 */
540bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ 572bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){
541 if(start == interfaces.end()) 573 if(start == interfaces.end())
542 return false; 574 return false;
543 575
544 bool found = false; 576 bool found = false;
545 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 577 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
546 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 578 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
547 // got to the end without finding it 579 // got to the end without finding it
548 break; 580 break;
549 } 581 }
550 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 582 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
551 // Found it in stanza so replace it. 583 // Found it in stanza so replace it.
552 if(found) 584 if(found)
553 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 585 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
554 found = true; 586 found = true;
555 (*it) = ""; 587 it = interfaces.remove( it ); // we really want to remove the line
588 --it; // we do ++it later in the head of the for loop
556 } 589 }
557 } 590 }
558 return found; 591 return found;
559} 592}
560 593
561/** 594/**
562 * Removes a option in a stanza 595 * Removes a option in a stanza
563 * @param start the start of the stanza 596 * @param start the start of the stanza
564 * @param option the option to use when setting value. 597 * @param option the option to use when setting value.
565 * @return bool true if successfull, false otherwise. 598 * @return bool true if successfull, false otherwise.
566 */ 599 */
567bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 600bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
568 if(start == interfaces.end()) 601 if(start == interfaces.end())
569 return false; 602 return false;
570 603
571 bool found = false; 604 bool found = false;
572 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 605 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
573 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 606 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
574 // got to the end without finding it 607 // got to the end without finding it
575 break; 608 break;
576 } 609 }
577 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ 610 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
578 // Found it in stanza so replace it. 611 // Found it in stanza so replace it.
579 if(found) 612 if(found)
580 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 613 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
581 found = true; 614 found = true;
582 (*it) = ""; 615 it = interfaces.remove( it ); // we really want to remove the line
616 --it; // we do ++it later in the head of the for loop
583 } 617 }
584 } 618 }
585 return found; 619 return found;
586} 620}
587 621
588/** 622/**
589 * Removes all options in a stanza 623 * Removes all options in a stanza
590 * @param start the start of the stanza 624 * @param start the start of the stanza
591 * @return bool true if successfull, false otherwise. 625 * @return bool true if successfull, false otherwise.
592 */ 626 */
593bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ 627bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
594 if(start == interfaces.end()) 628 if(start == interfaces.end())
595 return false; 629 return false;
596 630
597 QStringList::Iterator it = start; 631 QStringList::Iterator it = start;
598 it = ++it; 632 it = ++it;
599 for (; it != interfaces.end(); ++it ) { 633 for (; it != interfaces.end(); ++it ) {
600 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 634 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
601 break; 635 break;
602 } 636 }
603 it = interfaces.remove(it); 637 it = interfaces.remove(it);
604 it = --it; 638 it = --it;
605 } 639 }
606 // Leave a space between this interface and the next. 640 // Leave a space between this interface and the next.