Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfaces.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfaces.cpp | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index f1b8067..708f399 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp | |||
@@ -71,5 +71,5 @@ QStringList Interfaces::getInterfaceList(){ | |||
71 | * @return true is interface is in auto | 71 | * @return true is interface is in auto |
72 | */ | 72 | */ |
73 | bool Interfaces::isAuto(QString interface){ | 73 | bool Interfaces::isAuto(const QString &interface){ |
74 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); | 74 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); |
75 | QStringList awi = autoLines.grep(QRegExp(interface)); | 75 | QStringList awi = autoLines.grep(QRegExp(interface)); |
@@ -87,5 +87,5 @@ bool Interfaces::isAuto(QString interface){ | |||
87 | * @return false if already set to setAuto. | 87 | * @return false if already set to setAuto. |
88 | * */ | 88 | * */ |
89 | bool Interfaces::setAuto(QString interface, bool setAuto){ | 89 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ |
90 | // Don't need to set it if it is already set. | 90 | // Don't need to set it if it is already set. |
91 | if(isAuto(interface) == setAuto) | 91 | if(isAuto(interface) == setAuto) |
@@ -157,11 +157,11 @@ bool Interfaces::isInterfaceSet(){ | |||
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(const QString &interface, const QString &family, const 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 | QString newInterface = interface.simplifyWhiteSpace(); |
163 | interface = interface.replace(QRegExp(" "), ""); | 163 | newInterface = newInterface.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(newInterface).arg(family).arg(method)); |
166 | return true; | 166 | return true; |
167 | } | 167 | } |
@@ -172,5 +172,5 @@ bool Interfaces::addInterface(QString interface, QString family, QString method) | |||
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(const QString &interface, const QString &newInterface){ |
175 | if(!setInterface(interface)) return false; | 175 | if(!setInterface(interface)) return false; |
176 | 176 | ||
@@ -281,11 +281,11 @@ QString Interfaces::getInterfaceMethod(bool &error){ | |||
281 | * @return bool true if successfull. | 281 | * @return bool true if successfull. |
282 | */ | 282 | */ |
283 | bool Interfaces::setInterfaceName(QString newName){ | 283 | bool Interfaces::setInterfaceName(const QString &newName){ |
284 | if(currentIface == interfaces.end()) | 284 | if(currentIface == interfaces.end()) |
285 | return false; | 285 | return false; |
286 | newName = newName.simplifyWhiteSpace(); | 286 | QString name = newName.simplifyWhiteSpace(); |
287 | newName = newName.replace(QRegExp(" "), ""); | 287 | name = name.replace(QRegExp(" "), ""); |
288 | bool returnValue = false; | 288 | bool returnValue = false; |
289 | (*currentIface) = QString("iface %1 %2 %3").arg(newName).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); | 289 | (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); |
290 | return !returnValue; | 290 | return !returnValue; |
291 | } | 291 | } |
@@ -297,5 +297,5 @@ bool Interfaces::setInterfaceName(QString newName){ | |||
297 | * @return bool true if successfull. | 297 | * @return bool true if successfull. |
298 | */ | 298 | */ |
299 | bool Interfaces::setInterfaceFamily(QString newName){ | 299 | bool Interfaces::setInterfaceFamily(const QString &newName){ |
300 | if(currentIface == interfaces.end()) | 300 | if(currentIface == interfaces.end()) |
301 | return false; | 301 | return false; |
@@ -312,5 +312,5 @@ bool Interfaces::setInterfaceFamily(QString newName){ | |||
312 | * @return bool true if successfull. | 312 | * @return bool true if successfull. |
313 | */ | 313 | */ |
314 | bool Interfaces::setInterfaceMethod(QString newName){ | 314 | bool Interfaces::setInterfaceMethod(const QString &newName){ |
315 | if(currentIface == interfaces.end()) | 315 | if(currentIface == interfaces.end()) |
316 | return false; | 316 | return false; |
@@ -330,5 +330,5 @@ bool Interfaces::setInterfaceMethod(QString newName){ | |||
330 | * @return QString the options value. QString::null if error == true | 330 | * @return QString the options value. QString::null if error == true |
331 | */ | 331 | */ |
332 | QString Interfaces::getInterfaceOption(QString option, bool &error){ | 332 | QString Interfaces::getInterfaceOption(const QString &option, bool &error){ |
333 | return getOption(currentIface, option, error); | 333 | return getOption(currentIface, option, error); |
334 | } | 334 | } |
@@ -342,5 +342,5 @@ QString Interfaces::getInterfaceOption(QString option, bool &error){ | |||
342 | * @return QString the options value. QString::null if error == true | 342 | * @return QString the options value. QString::null if error == true |
343 | */ | 343 | */ |
344 | bool Interfaces::setInterfaceOption(QString option, QString value){ | 344 | bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ |
345 | return setOption(currentIface, option, value); | 345 | return setOption(currentIface, option, value); |
346 | } | 346 | } |
@@ -353,5 +353,5 @@ bool Interfaces::setInterfaceOption(QString option, QString value){ | |||
353 | * @return QString the options value. QString::null if error == true | 353 | * @return QString the options value. QString::null if error == true |
354 | */ | 354 | */ |
355 | bool Interfaces::removeInterfaceOption(QString option, QString value){ | 355 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ |
356 | return removeOption(currentIface, option, value); | 356 | return removeOption(currentIface, option, value); |
357 | } | 357 | } |
@@ -372,8 +372,8 @@ bool Interfaces::removeAllInterfaceOptions(){ | |||
372 | * @return bool true if it is successfull. | 372 | * @return bool true if it is successfull. |
373 | */ | 373 | */ |
374 | bool Interfaces::setMapping(QString interface){ | 374 | bool Interfaces::setMapping(const QString &interface){ |
375 | interface = interface.simplifyWhiteSpace(); | 375 | QString interfaceName = interface.simplifyWhiteSpace(); |
376 | interface = interface.replace(QRegExp(" "), ""); | 376 | interfaceName = interfaceName.replace(QRegExp(" "), ""); |
377 | return setStanza(MAPPING, interface, currentMapping); | 377 | return setStanza(MAPPING, interfaceName, currentMapping); |
378 | } | 378 | } |
379 | 379 | ||
@@ -382,5 +382,5 @@ bool Interfaces::setMapping(QString interface){ | |||
382 | * @param interface the name(s) of the interfaces to set to this mapping | 382 | * @param interface the name(s) of the interfaces to set to this mapping |
383 | */ | 383 | */ |
384 | void Interfaces::addMapping(QString option){ | 384 | void Interfaces::addMapping(const QString &option){ |
385 | interfaces.append(""); | 385 | interfaces.append(""); |
386 | interfaces.append(QString(MAPPING " %1").arg(option)); | 386 | interfaces.append(QString(MAPPING " %1").arg(option)); |
@@ -404,5 +404,5 @@ bool Interfaces::removeMapping(){ | |||
404 | * @return bool true if it is successfull. | 404 | * @return bool true if it is successfull. |
405 | */ | 405 | */ |
406 | bool Interfaces::setMap(QString map, QString value){ | 406 | bool Interfaces::setMap(const QString &map, const QString &value){ |
407 | return setOption(currentMapping, map, value); | 407 | return setOption(currentMapping, map, value); |
408 | } | 408 | } |
@@ -414,5 +414,5 @@ bool Interfaces::setMap(QString map, QString value){ | |||
414 | * @return bool true if it is successfull. | 414 | * @return bool true if it is successfull. |
415 | */ | 415 | */ |
416 | bool Interfaces::removeMap(QString map, QString value){ | 416 | bool Interfaces::removeMap(const QString &map, const QString &value){ |
417 | return removeOption(currentMapping, map, value); | 417 | return removeOption(currentMapping, map, value); |
418 | } | 418 | } |
@@ -424,5 +424,5 @@ bool Interfaces::removeMap(QString map, QString value){ | |||
424 | * @return value that goes to the map | 424 | * @return value that goes to the map |
425 | */ | 425 | */ |
426 | QString Interfaces::getMap(QString map, bool &error){ | 426 | QString Interfaces::getMap(const QString &map, bool &error){ |
427 | return getOption(currentMapping, map, error); | 427 | return getOption(currentMapping, map, error); |
428 | } | 428 | } |
@@ -433,5 +433,5 @@ QString Interfaces::getMap(QString map, bool &error){ | |||
433 | * @return true if successfull. | 433 | * @return true if successfull. |
434 | */ | 434 | */ |
435 | bool Interfaces::setScript(QString argument){ | 435 | bool Interfaces::setScript(const QString &argument){ |
436 | return setOption(currentMapping, "script", argument); | 436 | return setOption(currentMapping, "script", argument); |
437 | } | 437 | } |
@@ -445,4 +445,6 @@ QString Interfaces::getScript(bool &error){ | |||
445 | } | 445 | } |
446 | 446 | ||
447 | |||
448 | |||
447 | /** | 449 | /** |
448 | * Helper function used to parse through the QStringList and put pointers in | 450 | * Helper function used to parse through the QStringList and put pointers in |
@@ -453,5 +455,5 @@ QString Interfaces::getScript(bool &error){ | |||
453 | * @return bool true if the stanza is found. | 455 | * @return bool true if the stanza is found. |
454 | */ | 456 | */ |
455 | bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator &iterator){ | 457 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ |
456 | bool found = false; | 458 | bool found = false; |
457 | iterator = interfaces.end(); | 459 | iterator = interfaces.end(); |
@@ -490,5 +492,5 @@ bool Interfaces::setStanza(QString stanza, QString option, QStringList::Iterator | |||
490 | * @return bool true if successfull, false otherwise. | 492 | * @return bool true if successfull, false otherwise. |
491 | */ | 493 | */ |
492 | bool Interfaces::setOption(QStringList::Iterator start, QString option, QString value){ | 494 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
493 | if(start == interfaces.end()) | 495 | if(start == interfaces.end()) |
494 | return false; | 496 | return false; |
@@ -525,5 +527,5 @@ bool Interfaces::setOption(QStringList::Iterator start, QString option, QString | |||
525 | * @return bool true if successfull, false otherwise. | 527 | * @return bool true if successfull, false otherwise. |
526 | */ | 528 | */ |
527 | bool Interfaces::removeOption(QStringList::Iterator start, QString option, QString value){ | 529 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
528 | if(start == interfaces.end()) | 530 | if(start == interfaces.end()) |
529 | return false; | 531 | return false; |
@@ -551,5 +553,5 @@ bool Interfaces::removeOption(QStringList::Iterator start, QString option, QStri | |||
551 | * @return bool true if successfull, false otherwise. | 553 | * @return bool true if successfull, false otherwise. |
552 | */ | 554 | */ |
553 | bool Interfaces::removeAllOptions(QStringList::Iterator start){ | 555 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ |
554 | if(start == interfaces.end()) | 556 | if(start == interfaces.end()) |
555 | return false; | 557 | return false; |
@@ -576,5 +578,5 @@ bool Interfaces::removeAllOptions(QStringList::Iterator start){ | |||
576 | * @return QString the value of option QString::null() if error == true. | 578 | * @return QString the value of option QString::null() if error == true. |
577 | */ | 579 | */ |
578 | QString Interfaces::getOption(QStringList::Iterator start, QString option, bool &error){ | 580 | QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ |
579 | if(start == interfaces.end()){ | 581 | if(start == interfaces.end()){ |
580 | error = false; | 582 | error = false; |