forked from busyluo/NetAssistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
113 lines (82 loc) · 2.51 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
#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();
void setUdpGuiExt();
void setTcpSvrGuiExt();
void setTcpClientGuiExt();
QList<int> tcpClientSocketDescriptorList;
int TcpClientLinkCnt;
signals:
void sendDataToClient(char *msg, int length, int socketDescriptor, int socketDescriptorEx);
private slots:
void on_actionEnglish_triggered();
void on_pBtnNetCnnt_clicked(bool checked);
void on_cBoxNetType_currentIndexChanged(int index);
void on_pBtnSendData_clicked();
void on_pBtnClearRcvDisp_clicked();
void on_lEditUdpPort_textChanged(QString text);
void on_lEditUdpIP_textChanged(QString text);
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