2021-12-17 18:02:39 +08:00
|
|
|
#ifndef NETWORKMANAGER_H
|
|
|
|
|
#define NETWORKMANAGER_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
|
|
#include "json/jsonobject.h"
|
|
|
|
|
|
|
|
|
|
class NetworkManager : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2021-12-28 18:23:02 +08:00
|
|
|
static host getLocalHost();
|
|
|
|
|
static bool setLocalHost(const host& h);
|
2021-12-17 18:02:39 +08:00
|
|
|
//static NetworkManager* Instance();
|
|
|
|
|
//static void qIfConfig(const localhost& lhost);
|
|
|
|
|
static QString interfaceName();
|
|
|
|
|
static bool isDHCP();
|
|
|
|
|
static IpAddr getDefaultIpAddr();
|
|
|
|
|
static QList<QStringList> getIpAddrList();
|
|
|
|
|
static QString getDefaultGateway();
|
|
|
|
|
static QList<QStringList> getIpRouteList();
|
|
|
|
|
|
|
|
|
|
//static void setInterfaceName(const QString& name);
|
2021-12-28 18:23:02 +08:00
|
|
|
static bool checkPassWord(const QString& pwd, QString& err_info);
|
2021-12-17 18:02:39 +08:00
|
|
|
static bool restart(QString& err_info);
|
|
|
|
|
static bool setJsonDHCP(bool enable);
|
|
|
|
|
|
|
|
|
|
static bool setDefaultIpAddr(const IpAddr& addr, QString& err_info);
|
|
|
|
|
static bool setIpAddrList(const QList<QStringList>& list, QString& err_info);
|
|
|
|
|
static bool setDefaultGateway(const QString& gw, QString& err_info);
|
|
|
|
|
static bool setIpRouteList(const QList<QStringList>& list, QString& err_info);
|
|
|
|
|
static QString NewExp(QString ip, QString mask);
|
|
|
|
|
|
2021-12-20 18:08:32 +08:00
|
|
|
static bool validate(const QString& addr);
|
2021-12-17 18:02:39 +08:00
|
|
|
|
|
|
|
|
static bool testSetMode(QString& err_info);
|
|
|
|
|
static void testGetMode();
|
2021-12-20 15:23:33 +08:00
|
|
|
|
2021-12-17 18:02:39 +08:00
|
|
|
//private:
|
|
|
|
|
//explicit NetworkManager(QObject* parent = nullptr);
|
|
|
|
|
//static NetworkManager* instance;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//QString InterfaceName;
|
|
|
|
|
//bool isDHCP;
|
|
|
|
|
//IpAddress default_IpAddr;
|
|
|
|
|
//QList<IpAddress> addresses;
|
|
|
|
|
|
|
|
|
|
//IpRoute default_IpRoute;
|
|
|
|
|
//QList<IpRoute> routes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // NETWORKMANAGER_H
|