summaryrefslogtreecommitdiffstats
path: root/qt-ui/subsurfacewebservices.h
blob: 515e3fe9c5f2f86374d003cc1b78d260fa35f9b6 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef SUBSURFACEWEBSERVICES_H
#define SUBSURFACEWEBSERVICES_H

#include <QDialog>
#include <QNetworkReply>
#include <libxml/tree.h>

#include "ui_webservices.h"

class QAbstractButton;
class QNetworkReply;

class WebServices : public QDialog{
	Q_OBJECT
public:
    explicit WebServices(QWidget* parent = 0, Qt::WindowFlags f = 0);
	void hidePassword();
	void hideUpload();

private slots:
	virtual void startDownload() = 0;
	virtual void startUpload() = 0;
	virtual void buttonClicked(QAbstractButton* button) = 0;

protected:
	Ui::WebServices ui;
	QNetworkReply *reply;
	QNetworkAccessManager *manager;
	QByteArray downloadedData;
};

class SubsurfaceWebServices : public WebServices {
	Q_OBJECT
public:
	static SubsurfaceWebServices* instance();

private slots:
	void startDownload();
	void buttonClicked(QAbstractButton* button);
	void downloadFinished();
	void downloadError(QNetworkReply::NetworkError error);
	void startUpload(){} /*no op*/
private:
    explicit SubsurfaceWebServices(QWidget* parent = 0, Qt::WindowFlags f = 0);
	void setStatusText(int status);
	void download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status);
	unsigned int download_dialog_parse_response(const QByteArray& length);
};

class DivelogsDeWebServices : public WebServices {
	Q_OBJECT
public:
	static DivelogsDeWebServices * instance();

private slots:
	void startDownload();
	void buttonClicked(QAbstractButton* button);
	void downloadFinished();
	void downloadError(QNetworkReply::NetworkError error);
    void startUpload();
private:
    explicit DivelogsDeWebServices (QWidget* parent = 0, Qt::WindowFlags f = 0);
	void setStatusText(int status);
	void download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status);
	unsigned int download_dialog_parse_response(const QByteArray& length);
};

#endif