-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 @@ -138,97 +138,97 @@ bool Interfaces::setInterface(QString interface){ interface = interface.replace(QRegExp(" "), ""); return setStanza(IFACE, interface, currentIface); } /** * A quick helper funtion to see if the current interface is set. * @return bool true if set, false otherwise. */ bool Interfaces::isInterfaceSet(){ return (currentIface != interfaces.end()); } /** * Add a new interface of with the settings - family and method * @param interface the name of the interface to set. All whitespace is * removed from the interface name. * @param family the family of this interface inet or inet, ipx or inet6 * Must of one of the families defined in interfaces.h * @param method for the family. see interfaces man page for family methods. * @return true if successfull. */ bool Interfaces::addInterface(QString interface, QString family, QString method){ if(acceptedFamily.contains(family)==0) return false; interface = interface.simplifyWhiteSpace(); interface = interface.replace(QRegExp(" "), ""); interfaces.append(""); interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); return true; } /** * Copies interface with name interface to name newInterface * @param newInterface name of the new interface. * @return bool true if successfull */ bool Interfaces::copyInterface(QString interface, QString newInterface){ if(!setInterface(interface)) return false; QStringList::Iterator it = currentIface; it++; bool error; addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); if(!setInterface(newInterface)) return false; QStringList::Iterator newIface = currentIface; newIface++; - for ( it; it != interfaces.end(); ++it ){ + for ( ; it != interfaces.end(); ++it ){ if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) break; newIface = interfaces.insert(newIface, *it); } return true; } /** * Remove the currently selected interface and all of its options. * @return bool if successfull or not. */ bool Interfaces::removeInterface(){ if(currentIface == interfaces.end()) return false; (*currentIface) = ""; return removeAllInterfaceOptions(); } /** * Gets the hardware name of the interface that is currently selected. * @return QString name of the hardware interface (eth0, usb2, wlan1...). * @param error set to true if any error occurs, false otherwise. */ QString Interfaces::getInterfaceName(bool &error){ if(currentIface == interfaces.end()){ error = true; return QString(); } QString line = (*currentIface); line = line.mid(QString(IFACE).length() +1, line.length()); line = line.simplifyWhiteSpace(); int findSpace = line.find(" "); if( findSpace < 0){ error = true; return QString(); } error = false; return line.mid(0, findSpace); } /** * Gets the family name of the interface that is currently selected. * @return QString name of the family (inet, inet6, ipx). * @param error set to true if any error occurs, false otherwise. */ QString Interfaces::getInterfaceFamily(bool &error){ QString name = getInterfaceName(error); @@ -511,97 +511,97 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString (*it) = QString("\t%1 %2").arg(option).arg(value); } } if(!found){ QStringList::Iterator p = start; interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); found = true; } 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(QStringList::Iterator start, QString option, QString value){ 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).contains(value) && 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 all options in a stanza * @param start the start of the stanza * @return bool true if successfull, false otherwise. */ bool Interfaces::removeAllOptions(QStringList::Iterator start){ if(start == interfaces.end()) return false; QStringList::Iterator it = start; it = ++it; - for (it; it != interfaces.end(); ++it ) { + for (; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ break; } it = interfaces.remove(it); it = --it; } // Leave a space between this interface and the next. interfaces.insert(it, QString("")); return true; } /** * Gets a value of an option in a stanza * @param start the start of the stanza * @param option the option to use when getting the value. * @param bool true if errors false otherwise. * @return QString the value of option QString::null() if error == true. */ QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ if(start == interfaces.end()){ error = false; return QString(); } QString value; bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ break; } if((*it).contains(option) && (*it).at(0) != '#'){ if(found) qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); found = true; QString line = (*it).simplifyWhiteSpace(); int space = line.find(" ", option.length()); if(space != -1) value = line.mid(space+1, line.length()); else qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); } } error = !found; return value; } /** * 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){ interface = interface.replace(QRegExp(" "), ""); return setStanza(IFACE, interface, currentIface); } /** * A quick helper funtion to see if the current interface is set. * @return bool true if set, false otherwise. */ bool Interfaces::isInterfaceSet(){ return (currentIface != interfaces.end()); } /** * Add a new interface of with the settings - family and method * @param interface the name of the interface to set. All whitespace is * removed from the interface name. * @param family the family of this interface inet or inet, ipx or inet6 * Must of one of the families defined in interfaces.h * @param method for the family. see interfaces man page for family methods. * @return true if successfull. */ bool Interfaces::addInterface(QString interface, QString family, QString method){ if(acceptedFamily.contains(family)==0) return false; interface = interface.simplifyWhiteSpace(); interface = interface.replace(QRegExp(" "), ""); interfaces.append(""); interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); return true; } /** * Copies interface with name interface to name newInterface * @param newInterface name of the new interface. * @return bool true if successfull */ bool Interfaces::copyInterface(QString interface, QString newInterface){ if(!setInterface(interface)) return false; QStringList::Iterator it = currentIface; it++; bool error; addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); if(!setInterface(newInterface)) return false; QStringList::Iterator newIface = currentIface; newIface++; - for ( it; it != interfaces.end(); ++it ){ + for ( ; it != interfaces.end(); ++it ){ if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) break; newIface = interfaces.insert(newIface, *it); } return true; } /** * Remove the currently selected interface and all of its options. * @return bool if successfull or not. */ bool Interfaces::removeInterface(){ if(currentIface == interfaces.end()) return false; (*currentIface) = ""; return removeAllInterfaceOptions(); } /** * Gets the hardware name of the interface that is currently selected. * @return QString name of the hardware interface (eth0, usb2, wlan1...). * @param error set to true if any error occurs, false otherwise. */ QString Interfaces::getInterfaceName(bool &error){ if(currentIface == interfaces.end()){ error = true; return QString(); } QString line = (*currentIface); line = line.mid(QString(IFACE).length() +1, line.length()); line = line.simplifyWhiteSpace(); int findSpace = line.find(" "); if( findSpace < 0){ error = true; return QString(); } error = false; return line.mid(0, findSpace); } /** * Gets the family name of the interface that is currently selected. * @return QString name of the family (inet, inet6, ipx). * @param error set to true if any error occurs, false otherwise. */ QString Interfaces::getInterfaceFamily(bool &error){ QString name = getInterfaceName(error); @@ -511,97 +511,97 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString (*it) = QString("\t%1 %2").arg(option).arg(value); } } if(!found){ QStringList::Iterator p = start; interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); found = true; } 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(QStringList::Iterator start, QString option, QString value){ 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).contains(value) && 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 all options in a stanza * @param start the start of the stanza * @return bool true if successfull, false otherwise. */ bool Interfaces::removeAllOptions(QStringList::Iterator start){ if(start == interfaces.end()) return false; QStringList::Iterator it = start; it = ++it; - for (it; it != interfaces.end(); ++it ) { + for (; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ break; } it = interfaces.remove(it); it = --it; } // Leave a space between this interface and the next. interfaces.insert(it, QString("")); return true; } /** * Gets a value of an option in a stanza * @param start the start of the stanza * @param option the option to use when getting the value. * @param bool true if errors false otherwise. * @return QString the value of option QString::null() if error == true. */ QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ if(start == interfaces.end()){ error = false; return QString(); } QString value; bool found = false; for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ break; } if((*it).contains(option) && (*it).at(0) != '#'){ if(found) qDebug(QString("Interfaces: Get Options found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); found = true; QString line = (*it).simplifyWhiteSpace(); int space = line.find(" ", option.length()); if(space != -1) value = line.mid(space+1, line.length()); else qDebug(QString("Interfaces: Option %1 with no value").arg(option).latin1()); } } error = !found; return value; } /** * Write out the interfaces file to the file passed into the constructor. |