141 lines
3.5 KiB
C++
141 lines
3.5 KiB
C++
#ifndef __NETWORKMANAGER_H__
|
|
#define __NETWORKMANAGER_H__
|
|
#include <QWidget>
|
|
#include <QProcess>
|
|
#include <QSocketNotifier>
|
|
#include <QMap>
|
|
#include "ParaSettingUI.h"
|
|
#include "wpamsg.h"
|
|
#include <QTimer>
|
|
#include "myinclude.h"
|
|
#include "print_net.h"
|
|
|
|
namespace Ui {
|
|
class NetworkManager;
|
|
}
|
|
enum {
|
|
AUTH_NONE_OPEN,
|
|
AUTH_NONE_WEP,
|
|
AUTH_NONE_WEP_SHARED,
|
|
AUTH_IEEE8021X,
|
|
AUTH_WPA_PSK,
|
|
AUTH_WPA_EAP,
|
|
AUTH_WPA2_PSK,
|
|
AUTH_WPA2_EAP
|
|
};
|
|
struct ScanResult{
|
|
char ssid[50];
|
|
char bssid[50];
|
|
char qual[20];
|
|
char flags[80];
|
|
};
|
|
|
|
#define WPA_GUI_KEY_DATA "[key is configured]"
|
|
|
|
class NetworkManager : public QWidget,public ParaSettingUI
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit NetworkManager(QWidget *parent = 0);
|
|
~NetworkManager();
|
|
void bindSysPara(SysPara *sysPara);
|
|
void applyUIPara();
|
|
void updateSysStatusToUI();
|
|
void applyLanUIPara(void);
|
|
qint32 isIpv4Address(QString ip);
|
|
void updateAuthorization(int auth);
|
|
#if 1
|
|
public slots:
|
|
virtual int ctrlRequest(const char *cmd, char *buf, size_t *buflen);
|
|
virtual void updateStatus();
|
|
virtual void updateResults();
|
|
virtual void updateNetworks();
|
|
virtual void selectSSID( const QString & sel );
|
|
virtual void selectNetwork( const QString & sel );
|
|
virtual void scan();
|
|
virtual void processMsg(char *msg);
|
|
//virtual void processCtrlReq(const char *req);
|
|
virtual void receiveMsgs();
|
|
virtual int setNetworkParam(int id, const char *field,
|
|
const char *value, bool quote);
|
|
virtual void addNetwork();
|
|
virtual void triggerUpdate();
|
|
virtual void authChanged(int sel);
|
|
virtual void ping();
|
|
virtual void removeNetwork();
|
|
#endif
|
|
|
|
Q_SIGNALS:
|
|
void updateJSONData();
|
|
|
|
void net_startPrint();
|
|
void net_pausePrint();
|
|
void net_stopPrint();
|
|
void OpenNewFile();
|
|
private slots:
|
|
void on_pushButtonSetIP_clicked(bool checked);
|
|
|
|
void on_pushButtonSetCancel_clicked(bool checked);
|
|
|
|
void on_pushButtonScan_pressed();
|
|
|
|
void on_pushButtonConnect_pressed();
|
|
|
|
void on_pushButtonDisconnect_pressed();
|
|
|
|
void on_scanSSIDSelect_activated(const QString &arg1);
|
|
|
|
void on_pushButtonAddNetworkd_pressed();
|
|
|
|
void on_pushButtonRemove_pressed();
|
|
|
|
void on_GetJsonpushButton_clicked();
|
|
|
|
void onfinish_get_json();
|
|
|
|
void onjson_timer_handler();
|
|
|
|
void onjson_server_error();
|
|
|
|
void on_applicate_pushButton_clicked();
|
|
void ShowNet_dataMessege();
|
|
//void on_checkBoxShortNet_clicked(bool checked);
|
|
void on_checkBoxRemoveDigitCode_clicked(bool checked);
|
|
void on_checkBoxRemoveCode_clicked(bool checked);
|
|
void on_radioButtonGetDataEnable_clicked(bool checked);
|
|
void on_spinBox_ModbusPort_valueChanged(const QString &arg1);
|
|
|
|
private:
|
|
Ui::NetworkManager *ui;
|
|
QProcess *processNetwork;
|
|
bool networkMayHaveChanged;
|
|
bool beSentScanCmd;
|
|
char *ctrl_iface;
|
|
int edit_network_id;
|
|
struct wpa_ctrl *ctrl_conn;
|
|
int pingsToStatusUpdate;
|
|
//WpaMsgList msgs;
|
|
char *ctrl_iface_dir;
|
|
struct wpa_ctrl *monitor_conn;
|
|
//UserDataRequest *udr;
|
|
QSocketNotifier *msgNotifier;
|
|
WpaMsgList msgs;
|
|
//struct ScanResult scanResult[30];
|
|
QMap<QString, QStringList> scanResultMap;
|
|
|
|
PrintNet *net_data;
|
|
|
|
int openCtrlConnection(const char *ifname);
|
|
QString wpaStateTranslate(char *state);
|
|
QString bssid;
|
|
QTimer *timer;
|
|
|
|
QTimer *Json_timer;
|
|
bool Jsom_timer_stop;
|
|
|
|
bool wlanStartUpFailed;
|
|
|
|
bool Json_ip_init_done;
|
|
};
|
|
#endif // __NETWORKMANAGER_H__
|