summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -340,8 +340,18 @@ bool Interfaces::setInterfaceOption(const QString &option, const QString &value)
/**
* Removes a value for an option in the currently selected interface.
* @param option the options to set the value.
+ * @param error set to true if any error occurs, false otherwise.
+ * @return QString the options value. QString::null if error == true
+ */
+bool Interfaces::removeInterfaceOption(const QString &option){
+ return removeOption(currentIface, option);
+}
+
+/**
+ * Removes a value for an option in the currently selected interface.
+ * @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
*/
@@ -525,8 +535,35 @@ bool Interfaces::removeStanza(QStringList::Iterator &stanza){
/**
* Removes a option in a stanza
* @param start the start of the stanza
+ * @param option the option to remove
+ * @return bool true if successfull, false otherwise.
+ */
+bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){
+ if(start == interfaces.end())
+ return false;
+
+ bool found = false;
+ for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
+ if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
+ // got to the end without finding it
+ break;
+ }
+ if((*it).contains(option) && it != start && (*it).at(0) != '#'){
+ // Found it in stanza so replace it.
+ if(found)
+ qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
+ found = true;
+ (*it) = "";
+ }
+ }
+ return found;
+}
+
+/**
+ * Removes a option in a stanza
+ * @param start the start of the stanza
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
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
@@ -40,8 +40,9 @@ public:
QString getInterfaceMethod(bool &error);
bool setInterfaceMethod(const QString &newName);
QString getInterfaceOption(const QString &option, bool &error);
bool setInterfaceOption(const QString &option, const QString &value);
+ bool removeInterfaceOption(const QString &option);
bool removeInterfaceOption(const QString &option, const QString &value);
bool removeAllInterfaceOptions();
bool setMapping(const QString &interface);
@@ -59,8 +60,9 @@ private:
bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
bool removeStanza(QStringList::Iterator &stanza);
bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
bool removeAllOptions(const QStringList::Iterator &start);
+ bool removeOption(const QStringList::Iterator &start, const QString &option);
bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
QString interfacesFile;