summaryrefslogtreecommitdiff
path: root/saltoqd/fmsmanager.h
blob: 46c68ef135cd31eee2b5d9b3d58ead1a81a895e2 (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
49
#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);
	void handleDeleteResult(const QJsonObject &msg);

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

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

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

#endif // FMSMANAGER_H