forked from busyluo/NetAssistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
158 lines (119 loc) · 3.12 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtNetwork>
#include <QDataStream>
#include <QTextStream>
#include "TcpServer.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
/**
* @brief set udp mode
*/
void setUdpGuiExt();
/**
* @brief set tcp server mode
*/
void setTcpSvrGuiExt();
/**
* @brief set tcp client mode
*/
void setTcpClientGuiExt();
QList<int> tcpClientSocketDescriptorList;
int TcpClientLinkCnt;
signals:
void sendDataToClient(char *msg, int length, int socketDescriptor, int socketDescriptorEx);
private slots:
/**
* @brief language changed
*/
void on_actionEnglish_triggered();
/**
* @brief btn for connect net
* @param checked
*/
void on_pBtnNetCnnt_clicked(bool checked);
/**
* @brief index of net type changed
* @param index
*/
void on_cBoxNetType_currentIndexChanged(int index);
/**
* @brief btn for send data
*/
void on_pBtnSendData_clicked();
/**
* @brief clear data show
*/
void on_pBtnClearRcvDisp_clicked();
/**
* @brief modify udp port
* @param text
*/
void on_lEditUdpPort_textChanged(QString text);
/**
* @brief modify udp ip
* @param text
*/
void on_lEditUdpIP_textChanged(QString text);
/**
* @brief reset udp count
*/
void on_pBtnResetCnt_clicked();
char ConvertHexChar(char ch);
char ConvertHexStr(QString hexSubStr);
//=======UDP========
void udpDataReceived();
//=====TCP Client=====
void tcpClientDataReceived();
//=====TCP Server=====
bool slotTryCreateTcpServer();
void slotDeleteTcpServer();
void tcpServerDataReceived(char* msg, int length, int socketDescriptorEx);
void addClientLink(QString clientAddrPort, int socketDescriptor);
void removeClientLink(QString clientAddrPort, int socketDescriptor);
void toSendData();
void toSendFile();
void insertDateTimeInRcvDisp();
void msDelay(unsigned int msec);
void on_pBtnSaveRcvData_clicked();
void on_cBoxLoopSnd_toggled(bool checked);
void on_lEdit_Interval_ms_editingFinished();
void on_pBtnClearSndDisp_clicked();
void on_pBtnLoadSndData_clicked();
void on_StartRcvFile_clicked(bool checked);
void on_cBoxStartSndFile_clicked(bool checked);
void on_cBox_SndHexDisp_clicked(bool checked);
void on_actionChinese_triggered();
private:
Ui::MainWindow *ui;
QString m_ip;
//-----UDP-----
QUdpSocket *udpSocket;
QHostAddress lhAddr;
int lhPort;
QHostAddress rmtAddr;
int rmtPort;
//-----TCP Client-----
QHostAddress *rmtServerIP;
QTcpSocket *tcpClientSocket;
TcpServer *mtcpServer;
//Global state
unsigned int rcvDataCnt;
unsigned int sndDataCnt;
//bool NetState;
QTimer *timer;
bool loopSending;
QString CurIPPort;
QString CurPath;
QFile *curFile;
QTranslator translator;
};
#endif // MAINWINDOW_H