summaryrefslogtreecommitdiff
path: root/saltoqd/fmsmanager.h
blob: 3d2ab90f3d20044e58c22baf5d22f2ab5a4c1df4 (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
38
39
40
41
42
43
44
45
46
47
48
#ifndef FMSMANAGER_H
#define FMSMANAGER_H

#include <QtCore/QDateTime>
#include "toqmanager.h"

class ObexTransfer;

class FmsManager : public QObject, public ToqManager::EndpointHandler
{
	Q_OBJECT
public:
	explicit FmsManager(ObexConnection *obex, ToqManager *toq);

	void handleMessage(const ToqConnection::Message &msg) Q_DECL_OVERRIDE;

	void updateFile(const QString &path, const QByteArray &contents);
	void deleteFile(const QString &path);

private:
	void handleTransferResult(const QJsonObject &msg);

private slots:
	void handleQueue();
	void handleToqDisconnected();
	void handleObexConnected();
	void handleObexDisconnected();
	void handleObexError(int response);
	void cleanCurTransfer();

private:
	struct File {
		QDateTime mtime;
		QByteArray contents;
		quint32 checksum;
	};

private:
	ObexConnection *_obex;
	ToqManager *_toq;
	QMap<QString, File> _files;
	QSet<QString> _pending;
	ObexTransfer *_curTransfer;
	int _curTransferTransactionId;
	QString _curTransferPath;
};

#endif // FMSMANAGER_H