summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp37
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.h2
2 files changed, 39 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index 8f685fe..8d3e151 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -338,12 +338,22 @@ bool Interfaces::setInterfaceOption(const QString &option, const QString &value)
338 return setOption(currentIface, option, value); 338 return setOption(currentIface, option, value);
339} 339}
340 340
341/** 341/**
342 * Removes a value for an option in the currently selected interface. 342 * Removes a value for an option in the currently selected interface.
343 * @param option the options to set the value. 343 * @param option the options to set the value.
344 * @param error set to true if any error occurs, false otherwise.
345 * @return QString the options value. QString::null if error == true
346 */
347bool Interfaces::removeInterfaceOption(const QString &option){
348 return removeOption(currentIface, option);
349}
350
351/**
352 * Removes a value for an option in the currently selected interface.
353 * @param option the options to set the value.
344 * @param value the value that option should be set to. 354 * @param value the value that option should be set to.
345 * @param error set to true if any error occurs, false otherwise. 355 * @param error set to true if any error occurs, false otherwise.
346 * @return QString the options value. QString::null if error == true 356 * @return QString the options value. QString::null if error == true
347 */ 357 */
348bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ 358bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
349 return removeOption(currentIface, option, value); 359 return removeOption(currentIface, option, value);
@@ -523,12 +533,39 @@ bool Interfaces::removeStanza(QStringList::Iterator &stanza){
523 return removeAllOptions(stanza); 533 return removeAllOptions(stanza);
524} 534}
525 535
526/** 536/**
527 * Removes a option in a stanza 537 * Removes a option in a stanza
528 * @param start the start of the stanza 538 * @param start the start of the stanza
539 * @param option the option to remove
540 * @return bool true if successfull, false otherwise.
541 */
542bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){
543 if(start == interfaces.end())
544 return false;
545
546 bool found = false;
547 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
548 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
549 // got to the end without finding it
550 break;
551 }
552 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
553 // Found it in stanza so replace it.
554 if(found)
555 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
556 found = true;
557 (*it) = "";
558 }
559 }
560 return found;
561}
562
563/**
564 * Removes a option in a stanza
565 * @param start the start of the stanza
529 * @param option the option to use when setting value. 566 * @param option the option to use when setting value.
530 * @return bool true if successfull, false otherwise. 567 * @return bool true if successfull, false otherwise.
531 */ 568 */
532bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 569bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
533 if(start == interfaces.end()) 570 if(start == interfaces.end())
534 return false; 571 return false;
diff --git a/noncore/settings/networksettings/interfaces/interfaces.h b/noncore/settings/networksettings/interfaces/interfaces.h
index bac2a7e..bc9eaaa 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.h
+++ b/noncore/settings/networksettings/interfaces/interfaces.h
@@ -38,12 +38,13 @@ public:
38 QString getInterfaceFamily(bool &error); 38 QString getInterfaceFamily(bool &error);
39 bool setInterfaceFamily(const QString &newName); 39 bool setInterfaceFamily(const QString &newName);
40 QString getInterfaceMethod(bool &error); 40 QString getInterfaceMethod(bool &error);
41 bool setInterfaceMethod(const QString &newName); 41 bool setInterfaceMethod(const QString &newName);
42 QString getInterfaceOption(const QString &option, bool &error); 42 QString getInterfaceOption(const QString &option, bool &error);
43 bool setInterfaceOption(const QString &option, const QString &value); 43 bool setInterfaceOption(const QString &option, const QString &value);
44 bool removeInterfaceOption(const QString &option);
44 bool removeInterfaceOption(const QString &option, const QString &value); 45 bool removeInterfaceOption(const QString &option, const QString &value);
45 bool removeAllInterfaceOptions(); 46 bool removeAllInterfaceOptions();
46 47
47 bool setMapping(const QString &interface); 48 bool setMapping(const QString &interface);
48 bool removeMapping(); 49 bool removeMapping();
49 void addMapping(const QString &options); 50 void addMapping(const QString &options);
@@ -57,12 +58,13 @@ public:
57 58
58private: 59private:
59 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator); 60 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
60 bool removeStanza(QStringList::Iterator &stanza); 61 bool removeStanza(QStringList::Iterator &stanza);
61 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value); 62 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
62 bool removeAllOptions(const QStringList::Iterator &start); 63 bool removeAllOptions(const QStringList::Iterator &start);
64 bool removeOption(const QStringList::Iterator &start, const QString &option);
63 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value); 65 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
64 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error); 66 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
65 67
66 QString interfacesFile; 68 QString interfacesFile;
67 QStringList interfaces; 69 QStringList interfaces;
68 QStringList::Iterator currentIface; 70 QStringList::Iterator currentIface;