-rw-r--r-- | noncore/net/networksetup/interfaces/interfaces.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfaces.cpp | 4 |
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 | |||
@@ -154,65 +154,65 @@ bool Interfaces::isInterfaceSet(){ | |||
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 | */ |
159 | bool Interfaces::addInterface(QString interface, QString family, QString method){ | 159 | bool 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 | */ |
174 | bool Interfaces::copyInterface(QString interface, QString newInterface){ | 174 | bool 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 | */ |
199 | bool Interfaces::removeInterface(){ | 199 | bool 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 | */ |
211 | QString Interfaces::getInterfaceName(bool &error){ | 211 | QString 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(); |
@@ -527,65 +527,65 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString | |||
527 | bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ | 527 | bool 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 | */ |
553 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ | 553 | bool 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 | */ |
578 | QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ | 578 | QString 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) |
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 | |||
@@ -154,65 +154,65 @@ bool Interfaces::isInterfaceSet(){ | |||
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 | */ |
159 | bool Interfaces::addInterface(QString interface, QString family, QString method){ | 159 | bool 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 | */ |
174 | bool Interfaces::copyInterface(QString interface, QString newInterface){ | 174 | bool 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 | */ |
199 | bool Interfaces::removeInterface(){ | 199 | bool 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 | */ |
211 | QString Interfaces::getInterfaceName(bool &error){ | 211 | QString 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(); |
@@ -527,65 +527,65 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString | |||
527 | bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ | 527 | bool 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 | */ |
553 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ | 553 | bool 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 | */ |
578 | QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ | 578 | QString 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) |