Interfaces Class Reference
This class provides a clean frontend for parsing the network interfaces file. More...
#include <interfaces.h>
Collaboration diagram for Interfaces:

Public Member Functions | |
| Interfaces (QString useInterfacesFile="/etc/network/interfaces") | |
| Constructor. | |
| QStringList | getInterfaceList () |
| Get a list of all interfaces in the interface file. | |
| bool | isAuto (const QString &interface) const |
| Find out if interface is in an "auto" group or not. | |
| bool | setAuto (const QString &interface, bool setAuto) |
| Attempt to set the auto option for interface to setAuto. | |
| bool | removeInterface () |
| Remove the currently selected interface and all of its options. | |
| bool | addInterface (const QString &interface, const QString &family, const QString &method) |
| Add a new interface of with the settings - family and method. | |
| bool | copyInterface (const QString &oldInterface, const QString &newInterface) |
| Copies interface with name interface to name newInterface. | |
| bool | setInterface (QString interface) |
| Set the current interface to interface. | |
| bool | isInterfaceSet () const |
| A quick helper funtion to see if the current interface is set. | |
| QString | getInterfaceName (bool &error) |
| Gets the hardware name of the interface that is currently selected. | |
| bool | setInterfaceName (const QString &newName) |
| Sets the interface name to newName. | |
| QString | getInterfaceFamily (bool &error) |
| Gets the family name of the interface that is currently selected. | |
| bool | setInterfaceFamily (const QString &newName) |
| Sets the interface family to newName. | |
| QString | getInterfaceMethod (bool &error) |
| Gets the method of the interface that is currently selected. | |
| bool | setInterfaceMethod (const QString &newName) |
| Sets the interface method to newName. | |
| QString | getInterfaceOption (const QString &option, bool &error) |
| Get a value for an option in the currently selected interface. | |
| bool | setInterfaceOption (const QString &option, const QString &value) |
| Set a value for an option in the currently selected interface. | |
| bool | removeInterfaceOption (const QString &option) |
| Removes a value for an option in the currently selected interface. | |
| bool | removeInterfaceOption (const QString &option, const QString &value) |
| Removes a value for an option in the currently selected interface. | |
| bool | removeAllInterfaceOptions () |
| Removes all of the options from the currently selected interface. | |
| bool | setMapping (const QString &interface) |
| Set the current map to interface's map. | |
| bool | removeMapping () |
| Remove the currently selected map and all of its options. | |
| void | addMapping (const QString &options) |
| Adds a new Mapping to the interfaces file with interfaces. | |
| bool | setMap (const QString &map, const QString &value) |
| Set a map option within a mapping. | |
| bool | removeMap (const QString &map, const QString &value) |
| Removes a map option within a mapping. | |
| QString | getMap (const QString &map, bool &error) |
| Get a map value within a mapping. | |
| bool | setScript (const QString &argument) |
| Sets a script value of the current mapping to argument. | |
| QString | getScript (bool &error) |
| bool | write () |
| Write out the interfaces file to the file passed into the constructor. | |
Detailed Description
This class provides a clean frontend for parsing the network interfaces file.It provides helper functions to minipulate the options within the file. See the interfaces man page for the syntax rules.
Definition at line 22 of file interfaces.h.
Constructor & Destructor Documentation
|
|
Constructor.
Reads in the interfaces file and then split the file up by the
Definition at line 19 of file interfaces.cpp. References QValueList::append(), QFile::close(), QValueList::end(), QString::latin1(), QFile::open(), QTextStream::readLine(), and QStringList::split(). |
Member Function Documentation
|
|
Get a list of all interfaces in the interface file. Useful for hardware that is not currently connected such as an 802.11b card not plugged in, but configured for when it is plugged in.
Definition at line 52 of file interfaces.cpp. References QValueList::append(), QString::at(), QValueList::begin(), QString::contains(), QValueList::end(), QString::find(), QString::length(), QString::mid(), and QString::simplifyWhiteSpace(). |
|
|
Find out if interface is in an "auto" group or not. Report any duplicates such as eth0 being in two differnt auto's
Definition at line 75 of file interfaces.cpp. References QValueList::count(), and QStringList::grep(). Referenced by setAuto(), and InterfaceSetupImp::setProfile(). |
|
||||||||||||
|
Attempt to set the auto option for interface to setAuto.
Definition at line 89 of file interfaces.cpp. References QValueList::append(), QValueList::begin(), QValueList::end(), isAuto(), and QString::simplifyWhiteSpace(). Referenced by InterfaceSetupImp::saveSettings(). |
|
|
Remove the currently selected interface and all of its options.
Definition at line 202 of file interfaces.cpp. |
|
||||||||||||||||
|
Add a new interface of with the settings - family and method.
Definition at line 154 of file interfaces.cpp. References QValueList::append(), QValueList::contains(), QString::latin1(), QString::replace(), and QString::simplifyWhiteSpace(). Referenced by copyInterface(), and InterfaceSetupImp::setProfile(). |
|
||||||||||||
|
Copies interface with name interface to name newInterface.
Definition at line 170 of file interfaces.cpp. References addInterface(), QValueList::end(), getInterfaceFamily(), getInterfaceMethod(), QValueList::insert(), QString::latin1(), and setInterface(). Referenced by InterfaceSetupImp::setProfile(). |
|
|
Set the current interface to interface. This needs to be done before you can call getFamily(), getMethod, and get/setOption().
Definition at line 131 of file interfaces.cpp. References QString::replace(), and QString::simplifyWhiteSpace(). Referenced by copyInterface(), and InterfaceSetupImp::setProfile(). |
|
|
A quick helper funtion to see if the current interface is set.
Definition at line 141 of file interfaces.cpp. References QValueList::end(). Referenced by InterfaceSetupImp::saveSettings(). |
|
|
Gets the hardware name of the interface that is currently selected.
Definition at line 211 of file interfaces.cpp. References QValueList::end(), QString::find(), QString::length(), QString::mid(), and QString::simplifyWhiteSpace(). Referenced by getInterfaceFamily(), getInterfaceMethod(), InterfaceSetupImp::saveChanges(), setInterfaceFamily(), setInterfaceMethod(), and InterfaceSetupImp::setProfile(). |
|
|
Sets the interface name to newName.
Definition at line 277 of file interfaces.cpp. References QValueList::end(), getInterfaceFamily(), getInterfaceMethod(), QString::latin1(), QString::replace(), and QString::simplifyWhiteSpace(). |
|
|
Gets the family name of the interface that is currently selected.
Definition at line 233 of file interfaces.cpp. References QString::find(), getInterfaceName(), QString::length(), QString::mid(), and QString::simplifyWhiteSpace(). Referenced by copyInterface(), getInterfaceMethod(), setInterfaceMethod(), and setInterfaceName(). |
|
|
Sets the interface family to newName.
Definition at line 297 of file interfaces.cpp. References QValueList::contains(), QValueList::end(), getInterfaceMethod(), and getInterfaceName(). |
|
|
Gets the method of the interface that is currently selected.
Definition at line 256 of file interfaces.cpp. References getInterfaceFamily(), getInterfaceName(), QString::length(), QString::mid(), and QString::simplifyWhiteSpace(). Referenced by copyInterface(), InterfaceSetupImp::saveSettings(), setInterfaceFamily(), setInterfaceName(), and InterfaceSetupImp::setProfile(). |
|
|
Sets the interface method to newName.
Definition at line 312 of file interfaces.cpp. References QValueList::end(), getInterfaceFamily(), and getInterfaceName(). Referenced by InterfaceSetupImp::saveSettings(). |
|
||||||||||||
|
Get a value for an option in the currently selected interface. For example calling getInterfaceOption("address") on the following stanza would return 192.168.1.1. iface eth0 static address 192.168.1.1
Definition at line 330 of file interfaces.cpp. Referenced by InterfaceSetupImp::setProfile(). |
|
||||||||||||
|
Set a value for an option in the currently selected interface. If option doesn't exist then it is added along with the value. If value isEmpty() then we will remove the option
Definition at line 344 of file interfaces.cpp. References QString::latin1(), removeInterfaceOption(), and QString::stripWhiteSpace(). Referenced by InterfaceSetupImp::saveSettings(). |
|
|
Removes a value for an option in the currently selected interface.
Definition at line 358 of file interfaces.cpp. Referenced by InterfaceSetupImp::saveSettings(), and setInterfaceOption(). |
|
||||||||||||
|
Removes a value for an option in the currently selected interface.
Definition at line 369 of file interfaces.cpp. |
|
|
Removes all of the options from the currently selected interface.
Definition at line 377 of file interfaces.cpp. |
|
|
Set the current map to interface's map. This needs to be done before you can call addMapping(), set/getMap(), and get/setScript().
Definition at line 388 of file interfaces.cpp. References QString::replace(), and QString::simplifyWhiteSpace(). Referenced by InterfaceSetupImp::setProfile(). |
|
|
Remove the currently selected map and all of its options.
Definition at line 407 of file interfaces.cpp. |
|
|
Adds a new Mapping to the interfaces file with interfaces.
Definition at line 398 of file interfaces.cpp. References QValueList::append(). Referenced by InterfaceSetupImp::setProfile(). |
|
||||||||||||
|
Set a map option within a mapping.
Definition at line 417 of file interfaces.cpp. Referenced by InterfaceSetupImp::setProfile(). |
|
||||||||||||
|
Removes a map option within a mapping.
Definition at line 427 of file interfaces.cpp. |
|
||||||||||||
|
Get a map value within a mapping.
Definition at line 437 of file interfaces.cpp. |
|
|
Sets a script value of the current mapping to argument.
Definition at line 446 of file interfaces.cpp. Referenced by InterfaceSetupImp::setProfile(). |
|
|
Definition at line 454 of file interfaces.cpp. |
|
|
Write out the interfaces file to the file passed into the constructor. Removes any excess blank lines over 1 line long.
Definition at line 685 of file interfaces.cpp. References QValueList::begin(), QFile::close(), QValueList::end(), QString::length(), QFile::open(), QFile::remove(), QString::replace(), and QString::simplifyWhiteSpace(). Referenced by InterfaceSetupImp::saveChanges(). |
The documentation for this class was generated from the following files:
