Diffstat (limited to 'noncore/net/networksetup/interfaces/interfaces.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/interfaces/interfaces.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/noncore/net/networksetup/interfaces/interfaces.h b/noncore/net/networksetup/interfaces/interfaces.h new file mode 100644 index 0000000..e09ea71 --- a/dev/null +++ b/noncore/net/networksetup/interfaces/interfaces.h | |||
@@ -0,0 +1,76 @@ | |||
1 | #ifndef INTERFACES_H | ||
2 | #define INTERFACES_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | |||
7 | #define INTERFACES_LOOPBACK "loopback" | ||
8 | |||
9 | #define INTERFACES_FAMILY_INET "inet" | ||
10 | #define INTERFACES_FAMILY_IPX "ipx" | ||
11 | #define INTERFACES_FAMILY_INET6 "inet6" | ||
12 | |||
13 | #define INTERFACES_METHOD_DHCP "dhcp" | ||
14 | #define INTERFACES_METHOD_STATIC "static" | ||
15 | #define INTERFACES_METHOD_PPP "ppp" | ||
16 | |||
17 | /** | ||
18 | * This class provides a clean frontend for parsing the network interfaces file. | ||
19 | * It provides helper functions to minipulate the options within the file. | ||
20 | * See the interfaces man page for the syntax rules. | ||
21 | */ | ||
22 | class Interfaces { | ||
23 | |||
24 | public: | ||
25 | Interfaces(QString useInterfacesFile = "/etc/network/interfaces"); | ||
26 | QStringList getInterfaceList(); | ||
27 | |||
28 | bool isAuto(QString interface); | ||
29 | bool setAuto(QString interface, bool setAuto); | ||
30 | |||
31 | bool removeInterface(); | ||
32 | bool addInterface(QString interface, QString family, QString method); | ||
33 | bool copyInterface(QString oldInterface, QString newInterface); | ||
34 | bool setInterface(QString interface); | ||
35 | bool isInterfaceSet(); | ||
36 | QString getInterfaceName(bool &error); | ||
37 | bool setInterfaceName(QString newName); | ||
38 | QString getInterfaceFamily(bool &error); | ||
39 | bool setInterfaceFamily(QString newName); | ||
40 | QString getInterfaceMethod(bool &error); | ||
41 | bool setInterfaceMethod(QString newName); | ||
42 | QString getInterfaceOption(QString option, bool &error); | ||
43 | bool setInterfaceOption(QString option, QString value); | ||
44 | bool removeInterfaceOption(QString option, QString value); | ||
45 | bool removeAllInterfaceOptions(); | ||
46 | |||
47 | bool setMapping(QString interface); | ||
48 | bool removeMapping(); | ||
49 | void addMapping(QString options); | ||
50 | bool setMap(QString map, QString value); | ||
51 | bool removeMap(QString map, QString value); | ||
52 | QString getMap(QString map, bool &error); | ||
53 | bool setScript(QString); | ||
54 | QString getScript(bool &error); | ||
55 | |||
56 | bool write(); | ||
57 | |||
58 | private: | ||
59 | bool setStanza(QString stanza, QString option,QStringList::Iterator &iterator); | ||
60 | bool setOption(QStringList::Iterator start, QString option, QString value); | ||
61 | bool removeOption(QStringList::Iterator start, QString option, QString value); | ||
62 | QString getOption(QStringList::Iterator start, QString option, bool &error); | ||
63 | bool removeAllOptions(QStringList::Iterator start); | ||
64 | |||
65 | QString interfacesFile; | ||
66 | QStringList interfaces; | ||
67 | QStringList::Iterator currentIface; | ||
68 | QStringList::Iterator currentMapping; | ||
69 | |||
70 | QStringList acceptedFamily; | ||
71 | }; | ||
72 | |||
73 | #endif | ||
74 | |||
75 | // interfaces | ||
76 | |||