This repository has been archived by the owner on Feb 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plNetLog.h
133 lines (107 loc) · 4.01 KB
/
plNetLog.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
/******************************************************************************
* This file is part of plNetLog. *
* *
* plNetLog is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* plNetLog is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with plNetLog. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************/
#ifndef _PLNETLOG_H
#define _PLNETLOG_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <QMainWindow>
#include <QTreeWidget>
#include <QLineEdit>
#include <QCheckBox>
#include <QThread>
#include <QMutex>
#include <cstdio>
#include "ChunkBuffer.h"
/* From pnNbProtocol.h */
enum { kNetProtocolServerBit = 0x80 };
enum ENetProtocol {
kNetProtocolNil = 0,
// For test applications
kNetProtocolDebug = 1,
// Client connections
kNetProtocolCli2GateKeeper = 2,
kNetProtocolCli2Csr = 3,
kNetProtocolCli2Auth = 4,
kNetProtocolCli2Game = 5,
kNetProtocolCli2File = 6,
kNetProtocolCli2Unused_01 = 7,
// Server connections
kNetProtocolSrvConn = 0 | kNetProtocolServerBit,
kNetProtocolSrv2Mcp = 1 | kNetProtocolServerBit,
kNetProtocolSrv2Vault = 2 | kNetProtocolServerBit,
kNetProtocolSrv2Db = 3 | kNetProtocolServerBit,
kNetProtocolSrv2State = 4 | kNetProtocolServerBit,
kNetProtocolSrv2Log = 5 | kNetProtocolServerBit,
kNetProtocolSrv2Score = 6 | kNetProtocolServerBit,
};
enum WatchedProtocols
{
kWatchedProtocolCli2GateKeeper,
kWatchedProtocolCli2Auth,
kWatchedProtocolCli2Game,
kWatchedProtocolCount
};
enum Direction { kCli2Srv, kSrv2Cli };
#define kColorGateKeeper Qt::darkMagenta
#define kColorAuth Qt::blue
#define kColorGame Qt::darkGreen
struct MessageQueue
{
ChunkBuffer m_send;
ChunkBuffer m_recv;
};
class plNetLogGUI : public QMainWindow
{
Q_OBJECT
public:
plNetLogGUI(QWidget* parent = 0);
void addLogItems(unsigned protocol, int direction, ChunkBuffer& buffer);
void queueMessage(unsigned protocol, unsigned time, int direction,
const unsigned char* data, size_t size);
public slots:
void onLaunch();
void onClear() { m_logView->clear(); }
void addNodes();
void onSearch();
void onLoadGate();
void onLoadAuth();
void onLoadGame();
protected:
virtual void closeEvent(QCloseEvent*);
private:
QTreeWidget* m_logView;
QLineEdit* m_exePath;
QLineEdit* m_searchText;
QCheckBox* m_autoscroll;
QMutex m_logMutex;
MessageQueue m_msgQueues[kWatchedProtocolCount];
};
class PipeThread : public QThread
{
Q_OBJECT
public:
PipeThread(plNetLogGUI* parent);
~PipeThread();
protected:
virtual void run();
signals:
void moreLogItemsAreAvailable();
private:
HANDLE m_netPipe;
FILE* m_logDump[kWatchedProtocolCount];
};
#endif