-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilezillaadminconnection.h
More file actions
65 lines (49 loc) · 1.33 KB
/
filezillaadminconnection.h
File metadata and controls
65 lines (49 loc) · 1.33 KB
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
#ifndef FILEZILLAADMINCONNECTION_H
#define FILEZILLAADMINCONNECTION_H
#include <QObject>
#include <QtNetwork/QTcpSocket>
#include <QByteArray>
#include "filezillaserverdesc.h"
#ifdef WIN32
#include <cstdint>
#endif
struct FilezillaReply
{
int type;
int id;
int length;
QByteArray data;
};
class FilezillaAdminConnection : public QObject
{
Q_OBJECT
public:
enum ConnectionState { INIT, AUTH, NORMAL };
explicit FilezillaAdminConnection(QObject *parent = 0);
~FilezillaAdminConnection();
void connectToHost(const QString& host, int port, const QString &password);
FilezillaServerDesc serverDescription;
bool SendCommand(int type, char *data, int32_t length);
bool SendCommand(int type);
private:
QTcpSocket *mSocket;
QByteArray mDataRead;
ConnectionState mConnState;
QString mPassword;
bool parseData();
bool parseInitData();
bool parseAuthData();
bool parseNormalData();
void removeParsedData(int numBytes);
signals:
void authSuccess();
void connFail(const QString& message);
void connMessage(const QString &message);
void replyReceived(FilezillaReply reply);
void connectionClosed();
private slots:
void bytesToRead();
void socketError(QAbstractSocket::SocketError error);
public slots:
};
#endif // FILEZILLAADMINCONNECTION_H