Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfaces.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfaces.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index 436e449..6b161ae 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp | |||
@@ -41,13 +41,13 @@ Interfaces::Interfaces(QString useInterfacesFile){ | |||
41 | currentIface = interfaces.end(); | 41 | currentIface = interfaces.end(); |
42 | currentMapping = interfaces.end(); | 42 | currentMapping = interfaces.end(); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Get a list of all interfaces in the interface file. Usefull for | 47 | * Get a list of all interfaces in the interface file. Useful for |
48 | * hardware that is not currently connected such as an 802.11b card | 48 | * hardware that is not currently connected such as an 802.11b card |
49 | * not plugged in, but configured for when it is plugged in. | 49 | * not plugged in, but configured for when it is plugged in. |
50 | * @return Return string list of interfaces. | 50 | * @return Return string list of interfaces. |
51 | **/ | 51 | **/ |
52 | QStringList Interfaces::getInterfaceList(){ | 52 | QStringList Interfaces::getInterfaceList(){ |
53 | QStringList list; | 53 | QStringList list; |
@@ -123,13 +123,13 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ | |||
123 | 123 | ||
124 | /** | 124 | /** |
125 | * Set the current interface to interface. This needs to be done before you | 125 | * Set the current interface to interface. This needs to be done before you |
126 | * can call getFamily(), getMethod, and get/setOption(). | 126 | * can call getFamily(), getMethod, and get/setOption(). |
127 | * @param interface the name of the interface to set. All whitespace is | 127 | * @param interface the name of the interface to set. All whitespace is |
128 | * removed from the interface name. | 128 | * removed from the interface name. |
129 | * @return bool true if it is successfull. | 129 | * @return bool true if it is successful. |
130 | */ | 130 | */ |
131 | bool Interfaces::setInterface(QString interface){ | 131 | bool Interfaces::setInterface(QString interface){ |
132 | interface = interface.simplifyWhiteSpace(); | 132 | interface = interface.simplifyWhiteSpace(); |
133 | interface = interface.replace(QRegExp(" "), ""); | 133 | interface = interface.replace(QRegExp(" "), ""); |
134 | return setStanza(IFACE, interface, currentIface); | 134 | return setStanza(IFACE, interface, currentIface); |
135 | } | 135 | } |
@@ -146,13 +146,13 @@ bool Interfaces::isInterfaceSet() const { | |||
146 | * Add a new interface of with the settings - family and method | 146 | * Add a new interface of with the settings - family and method |
147 | * @param interface the name of the interface to set. All whitespace is | 147 | * @param interface the name of the interface to set. All whitespace is |
148 | * removed from the interface name. | 148 | * removed from the interface name. |
149 | * @param family the family of this interface inet or inet, ipx or inet6 | 149 | * @param family the family of this interface inet or inet, ipx or inet6 |
150 | * Must of one of the families defined in interfaces.h | 150 | * Must of one of the families defined in interfaces.h |
151 | * @param method for the family. see interfaces man page for family methods. | 151 | * @param method for the family. see interfaces man page for family methods. |
152 | * @return true if successfull. | 152 | * @return true if successful. |
153 | */ | 153 | */ |
154 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ | 154 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ |
155 | qDebug("Interfaces::addInterface(%s)",interface.latin1()); | 155 | qDebug("Interfaces::addInterface(%s)",interface.latin1()); |
156 | if(0 == acceptedFamily.contains(family)) | 156 | if(0 == acceptedFamily.contains(family)) |
157 | return false; | 157 | return false; |
158 | QString newInterface = interface.simplifyWhiteSpace(); | 158 | QString newInterface = interface.simplifyWhiteSpace(); |
@@ -162,13 +162,13 @@ bool Interfaces::addInterface(const QString &interface, const QString &family, c | |||
162 | return true; | 162 | return true; |
163 | } | 163 | } |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * Copies interface with name interface to name newInterface | 166 | * Copies interface with name interface to name newInterface |
167 | * @param newInterface name of the new interface. | 167 | * @param newInterface name of the new interface. |
168 | * @return bool true if successfull | 168 | * @return bool true if successful |
169 | */ | 169 | */ |
170 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ | 170 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ |
171 | qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1()); | 171 | qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1()); |
172 | if(!setInterface(interface)) | 172 | if(!setInterface(interface)) |
173 | return false; | 173 | return false; |
174 | 174 | ||
@@ -194,13 +194,13 @@ bool Interfaces::copyInterface(const QString &interface, const QString &newInter | |||
194 | 194 | ||
195 | return true; | 195 | return true; |
196 | } | 196 | } |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * Remove the currently selected interface and all of its options. | 199 | * Remove the currently selected interface and all of its options. |
200 | * @return bool if successfull or not. | 200 | * @return bool if successful or not. |
201 | */ | 201 | */ |
202 | bool Interfaces::removeInterface(){ | 202 | bool Interfaces::removeInterface(){ |
203 | return removeStanza(currentIface); | 203 | return removeStanza(currentIface); |
204 | } | 204 | } |
205 | 205 | ||
206 | /** | 206 | /** |
@@ -269,13 +269,13 @@ QString Interfaces::getInterfaceMethod(bool &error){ | |||
269 | return line; | 269 | return line; |
270 | } | 270 | } |
271 | 271 | ||
272 | /** | 272 | /** |
273 | * Sets the interface name to newName. | 273 | * Sets the interface name to newName. |
274 | * @param newName the new name of the interface. All whitespace is removed. | 274 | * @param newName the new name of the interface. All whitespace is removed. |
275 | * @return bool true if successfull. | 275 | * @return bool true if successful. |
276 | */ | 276 | */ |
277 | bool Interfaces::setInterfaceName(const QString &newName){ | 277 | bool Interfaces::setInterfaceName(const QString &newName){ |
278 | qDebug("setInterfaceName %s", newName.latin1()); | 278 | qDebug("setInterfaceName %s", newName.latin1()); |
279 | if(currentIface == interfaces.end()) | 279 | if(currentIface == interfaces.end()) |
280 | return false; | 280 | return false; |
281 | QString name = newName.simplifyWhiteSpace(); | 281 | QString name = newName.simplifyWhiteSpace(); |
@@ -289,13 +289,13 @@ bool Interfaces::setInterfaceName(const QString &newName){ | |||
289 | } | 289 | } |
290 | 290 | ||
291 | /** | 291 | /** |
292 | * Sets the interface family to newName. | 292 | * Sets the interface family to newName. |
293 | * @param newName the new name of the interface. Must be one of the families | 293 | * @param newName the new name of the interface. Must be one of the families |
294 | * defined in the interfaces.h file. | 294 | * defined in the interfaces.h file. |
295 | * @return bool true if successfull. | 295 | * @return bool true if successful. |
296 | */ | 296 | */ |
297 | bool Interfaces::setInterfaceFamily(const QString &newName){ | 297 | bool Interfaces::setInterfaceFamily(const QString &newName){ |
298 | if(currentIface == interfaces.end()) | 298 | if(currentIface == interfaces.end()) |
299 | return false; | 299 | return false; |
300 | if(acceptedFamily.contains(newName)==0) | 300 | if(acceptedFamily.contains(newName)==0) |
301 | return false; | 301 | return false; |
@@ -304,13 +304,13 @@ bool Interfaces::setInterfaceFamily(const QString &newName){ | |||
304 | return !returnValue; | 304 | return !returnValue; |
305 | } | 305 | } |
306 | 306 | ||
307 | /** | 307 | /** |
308 | * Sets the interface method to newName | 308 | * Sets the interface method to newName |
309 | * @param newName the new name of the interface | 309 | * @param newName the new name of the interface |
310 | * @return bool true if successfull. | 310 | * @return bool true if successful. |
311 | */ | 311 | */ |
312 | bool Interfaces::setInterfaceMethod(const QString &newName){ | 312 | bool Interfaces::setInterfaceMethod(const QString &newName){ |
313 | if(currentIface == interfaces.end()) | 313 | if(currentIface == interfaces.end()) |
314 | return false; | 314 | return false; |
315 | bool returnValue = false; | 315 | bool returnValue = false; |
316 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); | 316 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); |
@@ -369,24 +369,24 @@ bool Interfaces::removeInterfaceOption(const QString &option){ | |||
369 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ | 369 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ |
370 | return removeOption(currentIface, option, value); | 370 | return removeOption(currentIface, option, value); |
371 | } | 371 | } |
372 | 372 | ||
373 | /** | 373 | /** |
374 | * Removes all of the options from the currently selected interface. | 374 | * Removes all of the options from the currently selected interface. |
375 | * @return bool error if if successfull | 375 | * @return bool error if if successful |
376 | */ | 376 | */ |
377 | bool Interfaces::removeAllInterfaceOptions(){ | 377 | bool Interfaces::removeAllInterfaceOptions(){ |
378 | return removeAllOptions(currentIface); | 378 | return removeAllOptions(currentIface); |
379 | } | 379 | } |
380 | 380 | ||
381 | /** | 381 | /** |
382 | * Set the current map to interface's map. This needs to be done before you | 382 | * Set the current map to interface's map. This needs to be done before you |
383 | * can call addMapping(), set/getMap(), and get/setScript(). | 383 | * can call addMapping(), set/getMap(), and get/setScript(). |
384 | * @param interface the name of the interface to set. All whitespace is | 384 | * @param interface the name of the interface to set. All whitespace is |
385 | * removed from the interface name. | 385 | * removed from the interface name. |
386 | * @return bool true if it is successfull. | 386 | * @return bool true if it is successful. |
387 | */ | 387 | */ |
388 | bool Interfaces::setMapping(const QString &interface){ | 388 | bool Interfaces::setMapping(const QString &interface){ |
389 | QString interfaceName = interface.simplifyWhiteSpace(); | 389 | QString interfaceName = interface.simplifyWhiteSpace(); |
390 | interfaceName = interfaceName.replace(QRegExp(" "), ""); | 390 | interfaceName = interfaceName.replace(QRegExp(" "), ""); |
391 | return setStanza(MAPPING, interfaceName, currentMapping); | 391 | return setStanza(MAPPING, interfaceName, currentMapping); |
392 | } | 392 | } |
@@ -399,52 +399,52 @@ void Interfaces::addMapping(const QString &option){ | |||
399 | interfaces.append(""); | 399 | interfaces.append(""); |
400 | interfaces.append(QString(MAPPING " %1").arg(option)); | 400 | interfaces.append(QString(MAPPING " %1").arg(option)); |
401 | } | 401 | } |
402 | 402 | ||
403 | /** | 403 | /** |
404 | * Remove the currently selected map and all of its options. | 404 | * Remove the currently selected map and all of its options. |
405 | * @return bool if successfull or not. | 405 | * @return bool if successful or not. |
406 | */ | 406 | */ |
407 | bool Interfaces::removeMapping(){ | 407 | bool Interfaces::removeMapping(){ |
408 | return removeStanza(currentMapping); | 408 | return removeStanza(currentMapping); |
409 | } | 409 | } |
410 | 410 | ||
411 | /** | 411 | /** |
412 | * Set a map option within a mapping. | 412 | * Set a map option within a mapping. |
413 | * @param map map to use | 413 | * @param map map to use |
414 | * @param value value to go with map | 414 | * @param value value to go with map |
415 | * @return bool true if it is successfull. | 415 | * @return bool true if it is successful. |
416 | */ | 416 | */ |
417 | bool Interfaces::setMap(const QString &map, const QString &value){ | 417 | bool Interfaces::setMap(const QString &map, const QString &value){ |
418 | return setOption(currentMapping, map, value); | 418 | return setOption(currentMapping, map, value); |
419 | } | 419 | } |
420 | 420 | ||
421 | /** | 421 | /** |
422 | * Removes a map option within a mapping. | 422 | * Removes a map option within a mapping. |
423 | * @param map map to use | 423 | * @param map map to use |
424 | * @param value value to go with map | 424 | * @param value value to go with map |
425 | * @return bool true if it is successfull. | 425 | * @return bool true if it is successful. |
426 | */ | 426 | */ |
427 | bool Interfaces::removeMap(const QString &map, const QString &value){ | 427 | bool Interfaces::removeMap(const QString &map, const QString &value){ |
428 | return removeOption(currentMapping, map, value); | 428 | return removeOption(currentMapping, map, value); |
429 | } | 429 | } |
430 | 430 | ||
431 | /** | 431 | /** |
432 | * Get a map value within a mapping. | 432 | * Get a map value within a mapping. |
433 | * @param map map to get value of | 433 | * @param map map to get value of |
434 | * @param bool true if it is successfull. | 434 | * @param bool true if it is successful. |
435 | * @return value that goes to the map | 435 | * @return value that goes to the map |
436 | */ | 436 | */ |
437 | QString Interfaces::getMap(const QString &map, bool &error){ | 437 | QString Interfaces::getMap(const QString &map, bool &error){ |
438 | return getOption(currentMapping, map, error); | 438 | return getOption(currentMapping, map, error); |
439 | } | 439 | } |
440 | 440 | ||
441 | /** | 441 | /** |
442 | * Sets a script value of the current mapping to argument. | 442 | * Sets a script value of the current mapping to argument. |
443 | * @param argument the script name. | 443 | * @param argument the script name. |
444 | * @return true if successfull. | 444 | * @return true if successful. |
445 | */ | 445 | */ |
446 | bool Interfaces::setScript(const QString &argument){ | 446 | bool Interfaces::setScript(const QString &argument){ |
447 | return setOption(currentMapping, "script", argument); | 447 | return setOption(currentMapping, "script", argument); |
448 | } | 448 | } |
449 | 449 | ||
450 | /** | 450 | /** |
@@ -459,13 +459,13 @@ QString Interfaces::getScript(bool &error){ | |||
459 | 459 | ||
460 | /** | 460 | /** |
461 | * Helper function used to parse through the QStringList and put pointers in | 461 | * Helper function used to parse through the QStringList and put pointers in |
462 | * the correct place. | 462 | * the correct place. |
463 | * @param stanza The stanza (auto, iface, mapping) to look for. | 463 | * @param stanza The stanza (auto, iface, mapping) to look for. |
464 | * @param option string that must be in the stanza's main line. | 464 | * @param option string that must be in the stanza's main line. |
465 | * @param interator interator to place at location of stanza if successfull. | 465 | * @param interator interator to place at location of stanza if successful. |
466 | * @return bool true if the stanza is found. | 466 | * @return bool true if the stanza is found. |
467 | */ | 467 | */ |
468 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ | 468 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ |
469 | bool found = false; | 469 | bool found = false; |
470 | iterator = interfaces.end(); | 470 | iterator = interfaces.end(); |
471 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 471 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
@@ -497,13 +497,13 @@ bool Interfaces::setStanza(const QString &stanza, const QString &option, QString | |||
497 | } | 497 | } |
498 | 498 | ||
499 | /** | 499 | /** |
500 | * Sets a value of an option in a stanza | 500 | * Sets a value of an option in a stanza |
501 | * @param start the start of the stanza | 501 | * @param start the start of the stanza |
502 | * @param option the option to use when setting value. | 502 | * @param option the option to use when setting value. |
503 | * @return bool true if successfull, false otherwise. | 503 | * @return bool true if successful, false otherwise. |
504 | */ | 504 | */ |
505 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | 505 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
506 | if(start == interfaces.end()) | 506 | if(start == interfaces.end()) |
507 | return false; | 507 | return false; |
508 | qDebug("setting option"); | 508 | qDebug("setting option"); |
509 | bool found = false; | 509 | bool found = false; |
@@ -551,26 +551,26 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op | |||
551 | return found; | 551 | return found; |
552 | } | 552 | } |
553 | 553 | ||
554 | /** | 554 | /** |
555 | * Removes a stanza and all of its options | 555 | * Removes a stanza and all of its options |
556 | * @param stanza the stanza to remove | 556 | * @param stanza the stanza to remove |
557 | * @return bool true if successfull. | 557 | * @return bool true if successful. |
558 | */ | 558 | */ |
559 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ | 559 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ |
560 | if(stanza == interfaces.end()) | 560 | if(stanza == interfaces.end()) |
561 | return false; | 561 | return false; |
562 | (*stanza) = ""; | 562 | (*stanza) = ""; |
563 | return removeAllOptions(stanza); | 563 | return removeAllOptions(stanza); |
564 | } | 564 | } |
565 | 565 | ||
566 | /** | 566 | /** |
567 | * Removes a option in a stanza | 567 | * Removes a option in a stanza |
568 | * @param start the start of the stanza | 568 | * @param start the start of the stanza |
569 | * @param option the option to remove | 569 | * @param option the option to remove |
570 | * @return bool true if successfull, false otherwise. | 570 | * @return bool true if successful, false otherwise. |
571 | */ | 571 | */ |
572 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ | 572 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ |
573 | if(start == interfaces.end()) | 573 | if(start == interfaces.end()) |
574 | return false; | 574 | return false; |
575 | 575 | ||
576 | bool found = false; | 576 | bool found = false; |
@@ -592,13 +592,13 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString | |||
592 | } | 592 | } |
593 | 593 | ||
594 | /** | 594 | /** |
595 | * Removes a option in a stanza | 595 | * Removes a option in a stanza |
596 | * @param start the start of the stanza | 596 | * @param start the start of the stanza |
597 | * @param option the option to use when setting value. | 597 | * @param option the option to use when setting value. |
598 | * @return bool true if successfull, false otherwise. | 598 | * @return bool true if successful, false otherwise. |
599 | */ | 599 | */ |
600 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | 600 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
601 | if(start == interfaces.end()) | 601 | if(start == interfaces.end()) |
602 | return false; | 602 | return false; |
603 | 603 | ||
604 | bool found = false; | 604 | bool found = false; |
@@ -619,13 +619,13 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString | |||
619 | return found; | 619 | return found; |
620 | } | 620 | } |
621 | 621 | ||
622 | /** | 622 | /** |
623 | * Removes all options in a stanza | 623 | * Removes all options in a stanza |
624 | * @param start the start of the stanza | 624 | * @param start the start of the stanza |
625 | * @return bool true if successfull, false otherwise. | 625 | * @return bool true if successful, false otherwise. |
626 | */ | 626 | */ |
627 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ | 627 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ |
628 | if(start == interfaces.end()) | 628 | if(start == interfaces.end()) |
629 | return false; | 629 | return false; |
630 | 630 | ||
631 | QStringList::Iterator it = start; | 631 | QStringList::Iterator it = start; |
@@ -677,13 +677,13 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString | |||
677 | return value; | 677 | return value; |
678 | } | 678 | } |
679 | 679 | ||
680 | /** | 680 | /** |
681 | * Write out the interfaces file to the file passed into the constructor. | 681 | * Write out the interfaces file to the file passed into the constructor. |
682 | * Removes any excess blank lines over 1 line long. | 682 | * Removes any excess blank lines over 1 line long. |
683 | * @return bool true if successfull, false if not. | 683 | * @return bool true if successful, false if not. |
684 | */ | 684 | */ |
685 | bool Interfaces::write(){ | 685 | bool Interfaces::write(){ |
686 | QFile::remove(interfacesFile); | 686 | QFile::remove(interfacesFile); |
687 | QFile file(interfacesFile); | 687 | QFile file(interfacesFile); |
688 | 688 | ||
689 | if (!file.open(IO_ReadWrite)){ | 689 | if (!file.open(IO_ReadWrite)){ |