aboutsummaryrefslogtreecommitdiffstats
path: root/core/uploadDiveLogsDE.h
blob: 0259d1fb1c75b2709cd6411f1318806a0b7a472f (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
// SPDX-License-Identifier: GPL-2.0
#ifndef UPLOADDIVELOGSDE_H
#define UPLOADDIVELOGSDE_H
#include <QNetworkReply>
#include <QHttpMultiPart>
#include <QTimer>
#include <QFile>


class uploadDiveLogsDE : public QObject {
	Q_OBJECT
	
public:
	static uploadDiveLogsDE *instance();
	void doUpload(bool selected, const QString &userid, const QString &password);

private slots:
	void updateProgressSlot(qint64 current, qint64 total);
	void uploadFinishedSlot();
	void uploadTimeoutSlot();
	void uploadErrorSlot(QNetworkReply::NetworkError error);

signals:
	void uploadFinish(bool success, const QString &text);
	void uploadProgress(qreal percentage, qreal total);
	void uploadStatus(const QString &text);
	
private:
	uploadDiveLogsDE();

	void uploadDives(const QString &filename, const QString &userid, const QString &password);
	void cleanupTempFile();

	// only to be used in desktop-widgets::subsurfacewebservices
	bool prepareDives(const QString &tempfile, bool selected);

	QFile tempFile;
	QNetworkReply *reply;
	QHttpMultiPart *multipart;
	QTimer timeout;
};
#endif // UPLOADDIVELOGSDE_H