-
Notifications
You must be signed in to change notification settings - Fork 36
/
rcon.h
66 lines (56 loc) · 1.39 KB
/
rcon.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
#ifndef RCON_H
#define RCON_H
#include <QMainWindow>
#include <QTableWidgetItem>
#include <QTcpSocket>
#define RCON_AUTH 3
#define RCON_AUTH_RESPONSE 2
#define RCON_EXEC_COMMAND 2
#define RCON_EXEC_RESPONSE 0
enum QueuedCommandType
{
GetLogCommand, //Runs command without history, adds a log listener.
ConsoleCommand,//Runs commands with history
ContextCommand //Runs commands without history
};
class QueuedCommand
{
public:
QueuedCommand(QString cmd, QueuedCommandType cmdType)
{
this->command = cmd;
this->commandType = cmdType;
}
QueuedCommand(){this->command = "", this->commandType = ContextCommand;}
QString command;
QueuedCommandType commandType;
};
class ServerInfo;
class MainWindow;
const qint32 rconID = 0x7001;
class RconQuery : public QObject
{
Q_OBJECT
public:
RconQuery(MainWindow *main, ServerInfo *info);
~RconQuery() {
if(socket)
socket->deleteLater();
}
bool isAuthed;
QList<QueuedCommand> queuedList;
void auth();
void execCommand(QString command, bool history = true);
signals:
void rconOutput(ServerInfo *, QByteArray);
void rconAuth(ServerInfo *, QList<QueuedCommand>);
void rconHistory(QString);
private slots:
void socketReadyRead();
void socketDisconnected();
private:
QTcpSocket *socket;
ServerInfo *server;
qint32 responseSize;
};
#endif // RCON_H