123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- // netinterfaces.h :
- //
- #if !defined(AGD_NETINTERFACES_H__54DE87BE_1F3C_4914_A062_9CCFCB496122__INCLUDED_)
- #define AGD_NETINTERFACES_H__54DE87BE_1F3C_4914_A062_9CCFCB496122__INCLUDED_
- #include <vector>
- #include <QObject>
- #include <QList>
- #include <QQmlListProperty>
- #include <qqmlparserstatus.h>
- #include <gfa/gfanet.h>
- /////////////////////////////////////////////////////////////////////////////
- // netinterfaces.h - Declarations:
- class Emitter
- {
- public:
- virtual void emitError(const char *pszFormatStr, ...) const = 0;
- };
- /////////////////////////////////////////////////////////////////////////////
- #if 0
- class Nameservers : public QObject
- {
- Q_OBJECT
- public:
- explicit Nameservers(struct in_addr (&namesvr)[3], QObject *pParent = 0);
- virtual ~Nameservers(void);
- private:
- struct in_addr (&m_dnsSvr)[3];
- };
- #endif
- /////////////////////////////////////////////////////////////////////////////
- class IPv4Address : public QObject
- {
- Q_OBJECT
- Q_PROPERTY(QString address READ address WRITE set_address NOTIFY address_Changed)
- Q_PROPERTY(int b0 READ b0 WRITE set_b0 NOTIFY b0_Changed)
- Q_PROPERTY(int b1 READ b1 WRITE set_b1 NOTIFY b1_Changed)
- Q_PROPERTY(int b2 READ b2 WRITE set_b2 NOTIFY b2_Changed)
- Q_PROPERTY(int b3 READ b3 WRITE set_b3 NOTIFY b3_Changed)
- public:
- explicit IPv4Address(struct in_addr &addr, const Emitter &errHandler, QObject *pParent = 0);
- virtual ~IPv4Address(void);
- private:
- QString address(void) const;
- int b0(void) const;
- int b1(void) const;
- int b2(void) const;
- int b3(void) const;
-
- void set_address(const QString &addr);
- void set_b0(int b);
- void set_b1(int b);
- void set_b2(int b);
- void set_b3(int b);
- signals:
- void address_Changed(const QString&);
- void b0_Changed(int);
- void b1_Changed(int);
- void b2_Changed(int);
- void b3_Changed(int);
- private:
- struct in_addr &m_addr;
- const Emitter &m_errHandler;
- };
- /////////////////////////////////////////////////////////////////////////////
- class Interface : public QObject
- {
- Q_OBJECT
- Q_PROPERTY(QString name READ name)
- Q_PROPERTY(QString family READ family)
- Q_PROPERTY(QString method READ method)
- // static
- Q_PROPERTY(IPv4Address* ipAddress READ ipAddress)
- Q_PROPERTY(IPv4Address* netMask READ netMask)
- Q_PROPERTY(IPv4Address* gateway READ gateway)
- Q_PROPERTY(IPv4Address* bcastAddress READ bcastAddress)
- Q_PROPERTY(IPv4Address* ptpAddress READ ptpAddress)
- Q_PROPERTY(QQmlListProperty<IPv4Address> dnsServer READ dnsServer)
- #if 0
- Q_PROPERTY(QStringList dnsServers READ dnsServers)
- #endif
- // Q_PROPERTY(QString dns1 READ dns1)
- // Q_PROPERTY(QString dns2 READ dns2)
- // Q_PROPERTY(QString dns3 READ dns3)
- // dhcp
- public:
- explicit Interface(ITF_IFACE_BLOCK &ifb, const Emitter &errHandler, QObject *pParent = 0);
- virtual ~Interface(void);
- inline const ITF_IFACE_BLOCK & getIface(void) const {
- return m_ifb;}
- enum AddressFamily
- {
- AF_Unknown = -1,
- AF_Inet,
- AF_Inet6,
- AF_Ipx,
- AF_Can,
- AF_Invalid
- };
- Q_ENUMS(AddressFamily)
- private:
- QString name(void) const;
- QString family(void) const;
- QString method(void) const;
- IPv4Address* ipAddress(void);
- IPv4Address* netMask(void);
- IPv4Address* gateway(void);
- IPv4Address* bcastAddress(void);
- IPv4Address* ptpAddress(void);
- QQmlListProperty<IPv4Address> dnsServer(void);
- // QString dns1(void) const;
- // QString dns2(void) const;
- // QString dns3(void) const;
- #if 0
- QStringList dnsServers(void) const;
- #endif
- private:
- ITF_IFACE_BLOCK &m_ifb;
- IPv4Address m_ipAddr;
- IPv4Address m_netmask;
- IPv4Address m_gateway;
- IPv4Address m_bcastAddr;
- IPv4Address m_ptpAddr;
- QList<IPv4Address*> m_dnsList;
- const Emitter &m_errHandler;
- #if 0
- QStringList m_dnsList;
- Nameservers m_dnsSvr;
- #endif
- };
- /////////////////////////////////////////////////////////////////////////////
- class NetInterfaces : public QObject, public QQmlParserStatus, public Emitter
- {
- Q_OBJECT
- Q_INTERFACES(QQmlParserStatus)
- public:
- explicit NetInterfaces(QObject *pParent = 0);
- virtual ~NetInterfaces(void);
- public:
- Q_INVOKABLE void reset(void);
- Q_INVOKABLE bool initialize(void);
- Q_INVOKABLE bool save(void);
- Q_INVOKABLE bool save(QString path);
- Q_INVOKABLE QVariantList getInterface(const QString &itfName);
- virtual void classBegin();
- virtual void componentComplete();
- virtual void emitError(const char *pszFormatStr, ...) const;
- private:
- signals:
- void sigError(QString msg) const;
- private:
- ETC_NETWORK_INTERFACES m_eni;
- std::vector<Interface*> m_itfList;
- };
- /////////////////////////////////////////////////////////////////////////////
- #endif // !defined(AGD_NETINTERFACES_H__54DE87BE_1F3C_4914_A062_9CCFCB496122__INCLUDED_)
|