summaryrefslogtreecommitdiffstats
path: root/qt-ui/subsurfacewebservices.h
blob: 19c3f56c739a3ed1988f75f948053253deb3a618 (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
#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 buttonClicked(QAbstractButton* button) = 0;
	virtual void downloadFinished() = 0;
	virtual void downloadError(QNetworkReply::NetworkError error) = 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);
	
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);
};

#endif