summaryrefslogtreecommitdiff
path: root/distfoldd/clientagent.h
blob: d54bc699c6039dc770347b3405c1d93202501984 (plain)
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
#ifndef CLIENTAGENT_H
#define CLIENTAGENT_H

#include <QtCore/QQueue>
#include <QtNetwork/QHostAddress>

#include "agent.h"

class ClientAgent : public Agent
{
	Q_OBJECT
public:
	explicit ClientAgent(const QHostAddress& addr, uint port, const QDir& local_dir, SyncFlags flags, QObject *parent = 0);

	enum State {
		STATE_HELLO,
		STATE_FILE_LIST,
		STATE_FILE_ACTIONS
	};

protected:
	void handleMessage(MessageType msg, const QByteArray &data);

private:
	void sendFileList();
	void handleActionInfoList(const RemoteActionInfoList& list);
	void executeNextAction();
	void handlePulledFile(const QByteArray& data);
	void handlePushFile(const QString& wire_path);
	void handleDeleteFile(const QString& wire_path);

private:
	State _state;
	RemoteActionInfoList _pendingActions;
};

#endif // CLIENTAGENT_H