summaryrefslogtreecommitdiff
authorsimon <simon>2002-11-08 15:17:49 (UTC)
committer simon <simon>2002-11-08 15:17:49 (UTC)
commit447735be20fad2642617e3ba4f7ef0b598f597db (patch) (unidiff)
tree2627703ed5020debe5c408f42e31841618fbb47c
parentc2d39953b626147400114dbde85d87bdf5081576 (diff)
downloadopie-447735be20fad2642617e3ba4f7ef0b598f597db.zip
opie-447735be20fad2642617e3ba4f7ef0b598f597db.tar.gz
opie-447735be20fad2642617e3ba4f7ef0b598f597db.tar.bz2
- fix some more gcc3 warnings by removing statements with no effect:
- for ( it; it != interfaces.end(); ++it ){ + for ( ; it != interfaces.end(); ++it ){
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interfaces/interfaces.cpp4
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp4
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/networksetup/interfaces/interfaces.cpp b/noncore/net/networksetup/interfaces/interfaces.cpp
index 377a6db..f1b8067 100644
--- a/noncore/net/networksetup/interfaces/interfaces.cpp
+++ b/noncore/net/networksetup/interfaces/interfaces.cpp
@@ -138,97 +138,97 @@ bool Interfaces::setInterface(QString interface){
138 interface = interface.replace(QRegExp(" "), ""); 138 interface = interface.replace(QRegExp(" "), "");
139 return setStanza(IFACE, interface, currentIface); 139 return setStanza(IFACE, interface, currentIface);
140} 140}
141 141
142/** 142/**
143 * A quick helper funtion to see if the current interface is set. 143 * A quick helper funtion to see if the current interface is set.
144 * @return bool true if set, false otherwise. 144 * @return bool true if set, false otherwise.
145 */ 145 */
146bool Interfaces::isInterfaceSet(){ 146bool Interfaces::isInterfaceSet(){
147 return (currentIface != interfaces.end()); 147 return (currentIface != interfaces.end());
148} 148}
149 149
150/** 150/**
151 * Add a new interface of with the settings - family and method 151 * Add a new interface of with the settings - family and method
152 * @param interface the name of the interface to set. All whitespace is 152 * @param interface the name of the interface to set. All whitespace is
153 * removed from the interface name. 153 * removed from the interface name.
154 * @param family the family of this interface inet or inet, ipx or inet6 154 * @param family the family of this interface inet or inet, ipx or inet6
155 * Must of one of the families defined in interfaces.h 155 * Must of one of the families defined in interfaces.h
156 * @param method for the family. see interfaces man page for family methods. 156 * @param method for the family. see interfaces man page for family methods.
157 * @return true if successfull. 157 * @return true if successfull.
158 */ 158 */
159bool Interfaces::addInterface(QString interface, QString family, QString method){ 159bool Interfaces::addInterface(QString interface, QString family, QString method){
160 if(acceptedFamily.contains(family)==0) 160 if(acceptedFamily.contains(family)==0)
161 return false; 161 return false;
162 interface = interface.simplifyWhiteSpace(); 162 interface = interface.simplifyWhiteSpace();
163 interface = interface.replace(QRegExp(" "), ""); 163 interface = interface.replace(QRegExp(" "), "");
164 interfaces.append(""); 164 interfaces.append("");
165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); 165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method));
166 return true; 166 return true;
167} 167}
168 168
169/** 169/**
170 * Copies interface with name interface to name newInterface 170 * Copies interface with name interface to name newInterface
171 * @param newInterface name of the new interface. 171 * @param newInterface name of the new interface.
172 * @return bool true if successfull 172 * @return bool true if successfull
173 */ 173 */
174bool Interfaces::copyInterface(QString interface, QString newInterface){ 174bool Interfaces::copyInterface(QString interface, QString newInterface){
175 if(!setInterface(interface)) return false; 175 if(!setInterface(interface)) return false;
176 176
177 QStringList::Iterator it = currentIface; 177 QStringList::Iterator it = currentIface;
178 it++; 178 it++;
179 179
180 bool error; 180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); 181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) return false; 182 if(!setInterface(newInterface)) return false;
183 QStringList::Iterator newIface = currentIface; 183 QStringList::Iterator newIface = currentIface;
184 newIface++; 184 newIface++;
185 185
186 for ( it; it != interfaces.end(); ++it ){ 186 for ( ; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) 187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break; 188 break;
189 newIface = interfaces.insert(newIface, *it); 189 newIface = interfaces.insert(newIface, *it);
190 } 190 }
191 191
192 return true; 192 return true;
193} 193}
194 194
195/** 195/**
196 * Remove the currently selected interface and all of its options. 196 * Remove the currently selected interface and all of its options.
197 * @return bool if successfull or not. 197 * @return bool if successfull or not.
198 */ 198 */
199bool Interfaces::removeInterface(){ 199bool Interfaces::removeInterface(){
200 if(currentIface == interfaces.end()) 200 if(currentIface == interfaces.end())
201 return false; 201 return false;
202 (*currentIface) = ""; 202 (*currentIface) = "";
203 return removeAllInterfaceOptions(); 203 return removeAllInterfaceOptions();
204} 204}
205 205
206/** 206/**
207 * Gets the hardware name of the interface that is currently selected. 207 * Gets the hardware name of the interface that is currently selected.
208 * @return QString name of the hardware interface (eth0, usb2, wlan1...). 208 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
209 * @param error set to true if any error occurs, false otherwise. 209 * @param error set to true if any error occurs, false otherwise.
210 */ 210 */
211QString Interfaces::getInterfaceName(bool &error){ 211QString Interfaces::getInterfaceName(bool &error){
212 if(currentIface == interfaces.end()){ 212 if(currentIface == interfaces.end()){
213 error = true; 213 error = true;
214 return QString(); 214 return QString();
215 } 215 }
216 QString line = (*currentIface); 216 QString line = (*currentIface);
217 line = line.mid(QString(IFACE).length() +1, line.length()); 217 line = line.mid(QString(IFACE).length() +1, line.length());
218 line = line.simplifyWhiteSpace(); 218 line = line.simplifyWhiteSpace();
219 int findSpace = line.find(" "); 219 int findSpace = line.find(" ");
220 if( findSpace < 0){ 220 if( findSpace < 0){
221 error = true; 221 error = true;
222 return QString(); 222 return QString();
223 } 223 }
224 error = false; 224 error = false;
225 return line.mid(0, findSpace); 225 return line.mid(0, findSpace);
226} 226}
227 227
228/** 228/**
229 * Gets the family name of the interface that is currently selected. 229 * Gets the family name of the interface that is currently selected.
230 * @return QString name of the family (inet, inet6, ipx). 230 * @return QString name of the family (inet, inet6, ipx).
231 * @param error set to true if any error occurs, false otherwise. 231 * @param error set to true if any error occurs, false otherwise.
232 */ 232 */
233QString Interfaces::getInterfaceFamily(bool &error){ 233QString Interfaces::getInterfaceFamily(bool &error){
234 QString name = getInterfaceName(error); 234 QString name = getInterfaceName(error);
@@ -511,97 +511,97 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString
511 (*it) = QString("\t%1 %2").arg(option).arg(value); 511 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 } 512 }
513 } 513 }
514 if(!found){ 514 if(!found){
515 QStringList::Iterator p = start; 515 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true; 517 found = true;
518 } 518 }
519 return found; 519 return found;
520} 520}
521/** 521/**
522 * Removes a option in a stanza 522 * Removes a option in a stanza
523 * @param start the start of the stanza 523 * @param start the start of the stanza
524 * @param option the option to use when setting value. 524 * @param option the option to use when setting value.
525 * @return bool true if successfull, false otherwise. 525 * @return bool true if successfull, false otherwise.
526 */ 526 */
527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ 527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){
528 if(start == interfaces.end()) 528 if(start == interfaces.end())
529 return false; 529 return false;
530 530
531 bool found = false; 531 bool found = false;
532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
534 // got to the end without finding it 534 // got to the end without finding it
535 break; 535 break;
536 } 536 }
537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ 537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
538 // Found it in stanza so replace it. 538 // Found it in stanza so replace it.
539 if(found) 539 if(found)
540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
541 found = true; 541 found = true;
542 (*it) = ""; 542 (*it) = "";
543 } 543 }
544 } 544 }
545 return found; 545 return found;
546} 546}
547 547
548/** 548/**
549 * Removes all options in a stanza 549 * Removes all options in a stanza
550 * @param start the start of the stanza 550 * @param start the start of the stanza
551 * @return bool true if successfull, false otherwise. 551 * @return bool true if successfull, false otherwise.
552 */ 552 */
553bool Interfaces::removeAllOptions(QStringList::Iterator start){ 553bool Interfaces::removeAllOptions(QStringList::Iterator start){
554 if(start == interfaces.end()) 554 if(start == interfaces.end())
555 return false; 555 return false;
556 556
557 QStringList::Iterator it = start; 557 QStringList::Iterator it = start;
558 it = ++it; 558 it = ++it;
559 for (it; it != interfaces.end(); ++it ) { 559 for (; it != interfaces.end(); ++it ) {
560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
561 break; 561 break;
562 } 562 }
563 it = interfaces.remove(it); 563 it = interfaces.remove(it);
564 it = --it; 564 it = --it;
565 } 565 }
566 // Leave a space between this interface and the next. 566 // Leave a space between this interface and the next.
567 interfaces.insert(it, QString("")); 567 interfaces.insert(it, QString(""));
568 return true; 568 return true;
569} 569}
570 570
571/** 571/**
572 * Gets a value of an option in a stanza 572 * Gets a value of an option in a stanza
573 * @param start the start of the stanza 573 * @param start the start of the stanza
574 * @param option the option to use when getting the value. 574 * @param option the option to use when getting the value.
575 * @param bool true if errors false otherwise. 575 * @param bool true if errors false otherwise.
576 * @return QString the value of option QString::null() if error == true. 576 * @return QString the value of option QString::null() if error == true.
577 */ 577 */
578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ 578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){
579 if(start == interfaces.end()){ 579 if(start == interfaces.end()){
580 error = false; 580 error = false;
581 return QString(); 581 return QString();
582 } 582 }
583 583
584 QString value; 584 QString value;
585 bool found = false; 585 bool found = false;
586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
588 break; 588 break;
589 } 589 }
590 if((*it).contains(option) && (*it).at(0) != '#'){ 590 if((*it).contains(option) && (*it).at(0) != '#'){
591 if(found) 591 if(found)
592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); 592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
593 found = true; 593 found = true;
594 QString line = (*it).simplifyWhiteSpace(); 594 QString line = (*it).simplifyWhiteSpace();
595 int space = line.find(" ", option.length()); 595 int space = line.find(" ", option.length());
596 if(space != -1) 596 if(space != -1)
597 value = line.mid(space+1, line.length()); 597 value = line.mid(space+1, line.length());
598 else 598 else
599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); 599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1());
600 } 600 }
601 } 601 }
602 error = !found; 602 error = !found;
603 return value; 603 return value;
604} 604}
605 605
606/** 606/**
607 * Write out the interfaces file to the file passed into the constructor. 607 * Write out the interfaces file to the file passed into the constructor.
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index 377a6db..f1b8067 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -138,97 +138,97 @@ bool Interfaces::setInterface(QString interface){
138 interface = interface.replace(QRegExp(" "), ""); 138 interface = interface.replace(QRegExp(" "), "");
139 return setStanza(IFACE, interface, currentIface); 139 return setStanza(IFACE, interface, currentIface);
140} 140}
141 141
142/** 142/**
143 * A quick helper funtion to see if the current interface is set. 143 * A quick helper funtion to see if the current interface is set.
144 * @return bool true if set, false otherwise. 144 * @return bool true if set, false otherwise.
145 */ 145 */
146bool Interfaces::isInterfaceSet(){ 146bool Interfaces::isInterfaceSet(){
147 return (currentIface != interfaces.end()); 147 return (currentIface != interfaces.end());
148} 148}
149 149
150/** 150/**
151 * Add a new interface of with the settings - family and method 151 * Add a new interface of with the settings - family and method
152 * @param interface the name of the interface to set. All whitespace is 152 * @param interface the name of the interface to set. All whitespace is
153 * removed from the interface name. 153 * removed from the interface name.
154 * @param family the family of this interface inet or inet, ipx or inet6 154 * @param family the family of this interface inet or inet, ipx or inet6
155 * Must of one of the families defined in interfaces.h 155 * Must of one of the families defined in interfaces.h
156 * @param method for the family. see interfaces man page for family methods. 156 * @param method for the family. see interfaces man page for family methods.
157 * @return true if successfull. 157 * @return true if successfull.
158 */ 158 */
159bool Interfaces::addInterface(QString interface, QString family, QString method){ 159bool Interfaces::addInterface(QString interface, QString family, QString method){
160 if(acceptedFamily.contains(family)==0) 160 if(acceptedFamily.contains(family)==0)
161 return false; 161 return false;
162 interface = interface.simplifyWhiteSpace(); 162 interface = interface.simplifyWhiteSpace();
163 interface = interface.replace(QRegExp(" "), ""); 163 interface = interface.replace(QRegExp(" "), "");
164 interfaces.append(""); 164 interfaces.append("");
165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); 165 interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method));
166 return true; 166 return true;
167} 167}
168 168
169/** 169/**
170 * Copies interface with name interface to name newInterface 170 * Copies interface with name interface to name newInterface
171 * @param newInterface name of the new interface. 171 * @param newInterface name of the new interface.
172 * @return bool true if successfull 172 * @return bool true if successfull
173 */ 173 */
174bool Interfaces::copyInterface(QString interface, QString newInterface){ 174bool Interfaces::copyInterface(QString interface, QString newInterface){
175 if(!setInterface(interface)) return false; 175 if(!setInterface(interface)) return false;
176 176
177 QStringList::Iterator it = currentIface; 177 QStringList::Iterator it = currentIface;
178 it++; 178 it++;
179 179
180 bool error; 180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); 181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) return false; 182 if(!setInterface(newInterface)) return false;
183 QStringList::Iterator newIface = currentIface; 183 QStringList::Iterator newIface = currentIface;
184 newIface++; 184 newIface++;
185 185
186 for ( it; it != interfaces.end(); ++it ){ 186 for ( ; it != interfaces.end(); ++it ){
187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) 187 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
188 break; 188 break;
189 newIface = interfaces.insert(newIface, *it); 189 newIface = interfaces.insert(newIface, *it);
190 } 190 }
191 191
192 return true; 192 return true;
193} 193}
194 194
195/** 195/**
196 * Remove the currently selected interface and all of its options. 196 * Remove the currently selected interface and all of its options.
197 * @return bool if successfull or not. 197 * @return bool if successfull or not.
198 */ 198 */
199bool Interfaces::removeInterface(){ 199bool Interfaces::removeInterface(){
200 if(currentIface == interfaces.end()) 200 if(currentIface == interfaces.end())
201 return false; 201 return false;
202 (*currentIface) = ""; 202 (*currentIface) = "";
203 return removeAllInterfaceOptions(); 203 return removeAllInterfaceOptions();
204} 204}
205 205
206/** 206/**
207 * Gets the hardware name of the interface that is currently selected. 207 * Gets the hardware name of the interface that is currently selected.
208 * @return QString name of the hardware interface (eth0, usb2, wlan1...). 208 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
209 * @param error set to true if any error occurs, false otherwise. 209 * @param error set to true if any error occurs, false otherwise.
210 */ 210 */
211QString Interfaces::getInterfaceName(bool &error){ 211QString Interfaces::getInterfaceName(bool &error){
212 if(currentIface == interfaces.end()){ 212 if(currentIface == interfaces.end()){
213 error = true; 213 error = true;
214 return QString(); 214 return QString();
215 } 215 }
216 QString line = (*currentIface); 216 QString line = (*currentIface);
217 line = line.mid(QString(IFACE).length() +1, line.length()); 217 line = line.mid(QString(IFACE).length() +1, line.length());
218 line = line.simplifyWhiteSpace(); 218 line = line.simplifyWhiteSpace();
219 int findSpace = line.find(" "); 219 int findSpace = line.find(" ");
220 if( findSpace < 0){ 220 if( findSpace < 0){
221 error = true; 221 error = true;
222 return QString(); 222 return QString();
223 } 223 }
224 error = false; 224 error = false;
225 return line.mid(0, findSpace); 225 return line.mid(0, findSpace);
226} 226}
227 227
228/** 228/**
229 * Gets the family name of the interface that is currently selected. 229 * Gets the family name of the interface that is currently selected.
230 * @return QString name of the family (inet, inet6, ipx). 230 * @return QString name of the family (inet, inet6, ipx).
231 * @param error set to true if any error occurs, false otherwise. 231 * @param error set to true if any error occurs, false otherwise.
232 */ 232 */
233QString Interfaces::getInterfaceFamily(bool &error){ 233QString Interfaces::getInterfaceFamily(bool &error){
234 QString name = getInterfaceName(error); 234 QString name = getInterfaceName(error);
@@ -511,97 +511,97 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString
511 (*it) = QString("\t%1 %2").arg(option).arg(value); 511 (*it) = QString("\t%1 %2").arg(option).arg(value);
512 } 512 }
513 } 513 }
514 if(!found){ 514 if(!found){
515 QStringList::Iterator p = start; 515 QStringList::Iterator p = start;
516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 516 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
517 found = true; 517 found = true;
518 } 518 }
519 return found; 519 return found;
520} 520}
521/** 521/**
522 * Removes a option in a stanza 522 * Removes a option in a stanza
523 * @param start the start of the stanza 523 * @param start the start of the stanza
524 * @param option the option to use when setting value. 524 * @param option the option to use when setting value.
525 * @return bool true if successfull, false otherwise. 525 * @return bool true if successfull, false otherwise.
526 */ 526 */
527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ 527bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){
528 if(start == interfaces.end()) 528 if(start == interfaces.end())
529 return false; 529 return false;
530 530
531 bool found = false; 531 bool found = false;
532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 532 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 533 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
534 // got to the end without finding it 534 // got to the end without finding it
535 break; 535 break;
536 } 536 }
537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ 537 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
538 // Found it in stanza so replace it. 538 // Found it in stanza so replace it.
539 if(found) 539 if(found)
540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 540 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
541 found = true; 541 found = true;
542 (*it) = ""; 542 (*it) = "";
543 } 543 }
544 } 544 }
545 return found; 545 return found;
546} 546}
547 547
548/** 548/**
549 * Removes all options in a stanza 549 * Removes all options in a stanza
550 * @param start the start of the stanza 550 * @param start the start of the stanza
551 * @return bool true if successfull, false otherwise. 551 * @return bool true if successfull, false otherwise.
552 */ 552 */
553bool Interfaces::removeAllOptions(QStringList::Iterator start){ 553bool Interfaces::removeAllOptions(QStringList::Iterator start){
554 if(start == interfaces.end()) 554 if(start == interfaces.end())
555 return false; 555 return false;
556 556
557 QStringList::Iterator it = start; 557 QStringList::Iterator it = start;
558 it = ++it; 558 it = ++it;
559 for (it; it != interfaces.end(); ++it ) { 559 for (; it != interfaces.end(); ++it ) {
560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 560 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
561 break; 561 break;
562 } 562 }
563 it = interfaces.remove(it); 563 it = interfaces.remove(it);
564 it = --it; 564 it = --it;
565 } 565 }
566 // Leave a space between this interface and the next. 566 // Leave a space between this interface and the next.
567 interfaces.insert(it, QString("")); 567 interfaces.insert(it, QString(""));
568 return true; 568 return true;
569} 569}
570 570
571/** 571/**
572 * Gets a value of an option in a stanza 572 * Gets a value of an option in a stanza
573 * @param start the start of the stanza 573 * @param start the start of the stanza
574 * @param option the option to use when getting the value. 574 * @param option the option to use when getting the value.
575 * @param bool true if errors false otherwise. 575 * @param bool true if errors false otherwise.
576 * @return QString the value of option QString::null() if error == true. 576 * @return QString the value of option QString::null() if error == true.
577 */ 577 */
578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ 578QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){
579 if(start == interfaces.end()){ 579 if(start == interfaces.end()){
580 error = false; 580 error = false;
581 return QString(); 581 return QString();
582 } 582 }
583 583
584 QString value; 584 QString value;
585 bool found = false; 585 bool found = false;
586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 586 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 587 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
588 break; 588 break;
589 } 589 }
590 if((*it).contains(option) && (*it).at(0) != '#'){ 590 if((*it).contains(option) && (*it).at(0) != '#'){
591 if(found) 591 if(found)
592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); 592 qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
593 found = true; 593 found = true;
594 QString line = (*it).simplifyWhiteSpace(); 594 QString line = (*it).simplifyWhiteSpace();
595 int space = line.find(" ", option.length()); 595 int space = line.find(" ", option.length());
596 if(space != -1) 596 if(space != -1)
597 value = line.mid(space+1, line.length()); 597 value = line.mid(space+1, line.length());
598 else 598 else
599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); 599 qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1());
600 } 600 }
601 } 601 }
602 error = !found; 602 error = !found;
603 return value; 603 return value;
604} 604}
605 605
606/** 606/**
607 * Write out the interfaces file to the file passed into the constructor. 607 * Write out the interfaces file to the file passed into the constructor.