interfaces.h
00001 #ifndef INTERFACES_H
00002 #define INTERFACES_H
00003
00004 #include <qstring.h>
00005 #include <qstringlist.h>
00006
00007 #define INTERFACES_LOOPBACK "loopback"
00008
00009 #define INTERFACES_FAMILY_INET "inet"
00010 #define INTERFACES_FAMILY_IPX "ipx"
00011 #define INTERFACES_FAMILY_INET6 "inet6"
00012
00013 #define INTERFACES_METHOD_DHCP "dhcp"
00014 #define INTERFACES_METHOD_STATIC "static"
00015 #define INTERFACES_METHOD_PPP "ppp"
00016
00022 class Interfaces {
00023
00024 public:
00025 Interfaces(QString useInterfacesFile = "/etc/network/interfaces");
00026 QStringList getInterfaceList();
00027
00028 bool isAuto(const QString &interface) const ;
00029 bool setAuto(const QString &interface, bool setAuto);
00030
00031 bool removeInterface();
00032 bool addInterface(const QString &interface, const QString &family, const QString &method);
00033 bool copyInterface(const QString &oldInterface, const QString &newInterface);
00034 bool setInterface(QString interface);
00035 bool isInterfaceSet() const ;
00036 QString getInterfaceName(bool &error);
00037 bool setInterfaceName(const QString &newName);
00038 QString getInterfaceFamily(bool &error);
00039 bool setInterfaceFamily(const QString &newName);
00040 QString getInterfaceMethod(bool &error);
00041 bool setInterfaceMethod(const QString &newName);
00042 QString getInterfaceOption(const QString &option, bool &error);
00043 bool setInterfaceOption(const QString &option, const QString &value);
00044 bool removeInterfaceOption(const QString &option);
00045 bool removeInterfaceOption(const QString &option, const QString &value);
00046 bool removeAllInterfaceOptions();
00047
00048 bool setMapping(const QString &interface);
00049 bool removeMapping();
00050 void addMapping(const QString &options);
00051 bool setMap(const QString &map, const QString &value);
00052 bool removeMap(const QString &map, const QString &value);
00053 QString getMap(const QString &map, bool &error);
00054 bool setScript(const QString &argument);
00055 QString getScript(bool &error);
00056
00057 bool write();
00058
00059 private:
00060 bool setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator);
00061 bool removeStanza(QStringList::Iterator &stanza);
00062 bool setOption(const QStringList::Iterator &start, const QString &option, const QString &value);
00063 bool removeAllOptions(const QStringList::Iterator &start);
00064 bool removeOption(const QStringList::Iterator &start, const QString &option);
00065 bool removeOption(const QStringList::Iterator &start, const QString &option, const QString &value);
00066 QString getOption(const QStringList::Iterator &start, const QString &option, bool &error);
00067
00068 QString interfacesFile;
00069 QStringList interfaces;
00070 QStringList::Iterator currentIface;
00071 QStringList::Iterator currentMapping;
00072
00073 QStringList acceptedFamily;
00074 };
00075
00076 #endif
00077
00078
00079
This file is part of the documentation for OPIE Version 1.0.