Diffstat (limited to 'noncore/net/networksetup/interfaces/interfaces.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/interfaces/interfaces.cpp | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/noncore/net/networksetup/interfaces/interfaces.cpp b/noncore/net/networksetup/interfaces/interfaces.cpp index f1b8067..708f399 100644 --- a/noncore/net/networksetup/interfaces/interfaces.cpp +++ b/noncore/net/networksetup/interfaces/interfaces.cpp @@ -72,3 +72,3 @@ QStringList Interfaces::getInterfaceList(){ */ -bool Interfaces::isAuto(QString interface){ +bool Interfaces::isAuto(const QString &interface){ QStringList autoLines = interfaces.grep(QRegExp(AUTO)); @@ -88,3 +88,3 @@ bool Interfaces::isAuto(QString interface){ * */ -bool Interfaces::setAuto(QString interface, bool setAuto){ +bool Interfaces::setAuto(const QString &interface, bool setAuto){ // Don't need to set it if it is already set. @@ -158,9 +158,9 @@ bool Interfaces::isInterfaceSet(){ */ -bool Interfaces::addInterface(QString interface, QString family, QString method){ +bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ if(acceptedFamily.contains(family)==0) return false; - interface = interface.simplifyWhiteSpace(); - interface = interface.replace(QRegExp(" "), ""); + QString newInterface = interface.simplifyWhiteSpace(); + newInterface = newInterface.replace(QRegExp(" "), ""); interfaces.append(""); - interfaces.append(QString(IFACE " %1 %2 %3").arg(interface).arg(family).arg(method)); + interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); return true; @@ -173,3 +173,3 @@ bool Interfaces::addInterface(QString interface, QString family, QString method) */ -bool Interfaces::copyInterface(QString interface, QString newInterface){ +bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ if(!setInterface(interface)) return false; @@ -282,9 +282,9 @@ QString Interfaces::getInterfaceMethod(bool &error){ */ -bool Interfaces::setInterfaceName(QString newName){ +bool Interfaces::setInterfaceName(const QString &newName){ if(currentIface == interfaces.end()) return false; - newName = newName.simplifyWhiteSpace(); - newName = newName.replace(QRegExp(" "), ""); + QString name = newName.simplifyWhiteSpace(); + name = name.replace(QRegExp(" "), ""); bool returnValue = false; - (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); + (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); return !returnValue; @@ -298,3 +298,3 @@ bool Interfaces::setInterfaceName(QString newName){ */ -bool Interfaces::setInterfaceFamily(QString newName){ +bool Interfaces::setInterfaceFamily(const QString &newName){ if(currentIface == interfaces.end()) @@ -313,3 +313,3 @@ bool Interfaces::setInterfaceFamily(QString newName){ */ -bool Interfaces::setInterfaceMethod(QString newName){ +bool Interfaces::setInterfaceMethod(const QString &newName){ if(currentIface == interfaces.end()) @@ -331,3 +331,3 @@ bool Interfaces::setInterfaceMethod(QString newName){ */ -QString Interfaces::getInterfaceOption(QString option, bool &error){ +QString Interfaces::getInterfaceOption(const QString &option, bool &error){ return getOption(currentIface, option, error); @@ -343,3 +343,3 @@ QString Interfaces::getInterfaceOption(QString option, bool &error){ */ -bool Interfaces::setInterfaceOption(QString option, QString value){ +bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ return setOption(currentIface, option, value); @@ -354,3 +354,3 @@ bool Interfaces::setInterfaceOption(QString option, QString value){ */ -bool Interfaces::removeInterfaceOption(QString option, QString value){ +bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ return removeOption(currentIface, option, value); @@ -373,6 +373,6 @@ bool Interfaces::removeAllInterfaceOptions(){ */ -bool Interfaces::setMapping(QString interface){ - interface = interface.simplifyWhiteSpace(); - interface = interface.replace(QRegExp(" "), ""); - return setStanza(MAPPING, interface, currentMapping); +bool Interfaces::setMapping(const QString &interface){ + QString interfaceName = interface.simplifyWhiteSpace(); + interfaceName = interfaceName.replace(QRegExp(" "), ""); + return setStanza(MAPPING, interfaceName, currentMapping); } @@ -383,3 +383,3 @@ bool Interfaces::setMapping(QString interface){ */ -void Interfaces::addMapping(QString option){ +void Interfaces::addMapping(const QString &option){ interfaces.append(""); @@ -405,3 +405,3 @@ bool Interfaces::removeMapping(){ */ -bool Interfaces::setMap(QString map, QString value){ +bool Interfaces::setMap(const QString &map, const QString &value){ return setOption(currentMapping, map, value); @@ -415,3 +415,3 @@ bool Interfaces::setMap(QString map, QString value){ */ -bool Interfaces::removeMap(QString map, QString value){ +bool Interfaces::removeMap(const QString &map, const QString &value){ return removeOption(currentMapping, map, value); @@ -425,3 +425,3 @@ bool Interfaces::removeMap(QString map, QString value){ */ -QString Interfaces::getMap(QString map, bool &error){ +QString Interfaces::getMap(const QString &map, bool &error){ return getOption(currentMapping, map, error); @@ -434,3 +434,3 @@ QString Interfaces::getMap(QString map, bool &error){ */ -bool Interfaces::setScript(QString argument){ +bool Interfaces::setScript(const QString &argument){ return setOption(currentMapping, "script", argument); @@ -446,2 +446,4 @@ QString Interfaces::getScript(bool &error){ + + /** @@ -454,3 +456,3 @@ QString Interfaces::getScript(bool &error){ */ -bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ +bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ bool found = false; @@ -491,3 +493,3 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator */ -bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ +bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ if(start == interfaces.end()) @@ -526,3 +528,3 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString */ -bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ +bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ if(start == interfaces.end()) @@ -552,3 +554,3 @@ bool Interfaces::removeOption(QStringList::Iterator start, QString option, QStri */ -bool Interfaces::removeAllOptions(QStringList::Iterator start){ +bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ if(start == interfaces.end()) @@ -577,3 +579,3 @@ bool Interfaces::removeAllOptions(QStringList::Iterator start){ */ -QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ +QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ if(start == interfaces.end()){ |