summaryrefslogtreecommitdiffstats
path: root/Uploader.h
blob: ccd36c12f4492cc46a5203ed2b1fcfc49b8b770b (plain) (blame)
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
#ifndef UPLOADER_H
#define UPLOADER_H

#include <QObject>
#include <QFtp>
#include <QHash>
#include <QFile>
#include <QByteArray>
#include "DirectoryScanner.h"

class Uploader : public QObject
{
	Q_OBJECT
public:
	Uploader(const QString &ftpServer, const QString &ftpPath, const QString &username, const QString &password, const QByteArray &secretKey, const QHash<const QString, QFileInfo> &fileList, QObject *parent = 0);
	void begin();

private:
	void uploadNextFile();
	QHash<const QString, QFileInfo> m_fileList;
	QHash<const QString, QFileInfo>::const_iterator m_listPosition;
	QFtp m_ftp;
	QString m_ftpServer;
	QString m_ftpPath;
	QString m_username;
	QString m_password;
	QByteArray m_secretKey;
	int m_cdCommand;
	int m_latestCommand;
	int m_latestPut;
	QFile *m_currentFile;

private slots:
	void stateChanged(int state);
	void commandFinished(int id, bool error);
	void listInfo(const QUrlInfo &i);
	void dataTransferProgress(qint64 done, qint64 total);

signals:
	void done();

};

#endif // UPLOADER_H