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);
|
2023-09-20 10:09:57 +08:00
|
|
|
static NetworkManager* getInstance();
|
2021-12-17 18:02:39 +08:00
|
|
|
//static void qIfConfig(const localhost& lhost);
|
|
|
|
|
static QString interfaceName();
|
2023-09-20 10:09:57 +08:00
|
|
|
bool isDHCP();
|
|
|
|
|
IpAddr getDefaultIpAddr();
|
2021-12-17 18:02:39 +08:00
|
|
|
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);
|
2023-09-20 10:09:57 +08:00
|
|
|
bool setDHCP();
|
|
|
|
|
bool setIpAddr(const IpAddr& addr, const QString& aGateWay, QString& err_info);
|
|
|
|
|
void initNetworkInfo();
|
2021-12-17 18:02:39 +08:00
|
|
|
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
|
|
|
|
2023-09-20 10:09:57 +08:00
|
|
|
private:
|
|
|
|
|
explicit NetworkManager(QObject* parent = nullptr);
|
|
|
|
|
bool mIsDHCP;
|
|
|
|
|
QString mIpAddress;
|
|
|
|
|
QString mSubNetMask;
|
2021-12-17 18:02:39 +08:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // NETWORKMANAGER_H
|