2017-04-27 18:26:05 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-06-06 13:33:15 +00:00
|
|
|
#ifndef SUBSURFACEWEBSERVICES_H
|
|
|
|
#define SUBSURFACEWEBSERVICES_H
|
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QNetworkReply>
|
2013-11-15 02:57:09 +00:00
|
|
|
#include <QTemporaryFile>
|
2013-11-15 01:47:35 +00:00
|
|
|
#include <QTimer>
|
2013-06-06 14:31:55 +00:00
|
|
|
#include <libxml/tree.h>
|
2013-06-06 13:33:15 +00:00
|
|
|
|
2013-10-25 00:30:21 +00:00
|
|
|
#include "ui_webservices.h"
|
2013-10-03 18:54:25 +00:00
|
|
|
|
2013-06-06 13:33:15 +00:00
|
|
|
class QAbstractButton;
|
2013-11-15 02:57:09 +00:00
|
|
|
class QHttpMultiPart;
|
2013-06-06 13:33:15 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class WebServices : public QDialog {
|
2013-10-25 00:30:21 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-10-25 21:27:39 +00:00
|
|
|
explicit WebServices(QWidget *parent = 0);
|
2013-10-25 00:30:21 +00:00
|
|
|
void hidePassword();
|
|
|
|
void hideUpload();
|
2013-11-15 02:57:09 +00:00
|
|
|
void hideDownload();
|
2013-10-25 00:30:21 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
private
|
|
|
|
slots:
|
2013-10-25 00:30:21 +00:00
|
|
|
virtual void startDownload() = 0;
|
2013-10-25 00:52:11 +00:00
|
|
|
virtual void startUpload() = 0;
|
2014-02-28 04:09:57 +00:00
|
|
|
virtual void buttonClicked(QAbstractButton *button) = 0;
|
2022-04-11 04:49:11 +00:00
|
|
|
virtual void downloadFinished() = 0;
|
|
|
|
virtual void downloadError(QNetworkReply::NetworkError error) = 0;
|
2018-09-29 20:55:41 +00:00
|
|
|
void downloadTimedOut();
|
2013-10-25 00:30:21 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
protected
|
|
|
|
slots:
|
2013-11-15 00:52:08 +00:00
|
|
|
void updateProgress(qint64 current, qint64 total);
|
|
|
|
|
2013-10-25 00:30:21 +00:00
|
|
|
protected:
|
2013-11-15 00:50:46 +00:00
|
|
|
void resetState();
|
2013-11-15 00:52:08 +00:00
|
|
|
void connectSignalsForDownload(QNetworkReply *reply);
|
2013-11-15 02:57:09 +00:00
|
|
|
void connectSignalsForUpload();
|
2013-11-15 00:50:46 +00:00
|
|
|
|
2013-10-25 00:30:21 +00:00
|
|
|
Ui::WebServices ui;
|
|
|
|
QNetworkReply *reply;
|
2013-11-15 01:47:35 +00:00
|
|
|
QTimer timeout;
|
2013-10-25 00:30:21 +00:00
|
|
|
QByteArray downloadedData;
|
2013-12-09 17:23:32 +00:00
|
|
|
QString defaultApplyText;
|
2014-07-31 18:20:11 +00:00
|
|
|
QString userAgent;
|
2013-10-25 00:30:21 +00:00
|
|
|
};
|
|
|
|
|
2013-10-25 00:52:11 +00:00
|
|
|
class DivelogsDeWebServices : public WebServices {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
static DivelogsDeWebServices *instance();
|
2013-11-15 02:57:09 +00:00
|
|
|
void downloadDives();
|
2014-05-20 16:33:32 +00:00
|
|
|
void prepareDivesForUpload(bool selected);
|
2013-10-25 00:52:11 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
private
|
|
|
|
slots:
|
2013-10-25 00:52:11 +00:00
|
|
|
void startDownload();
|
2014-02-28 04:09:57 +00:00
|
|
|
void buttonClicked(QAbstractButton *button);
|
2013-11-15 02:57:09 +00:00
|
|
|
void saveToZipFile();
|
|
|
|
void listDownloadFinished();
|
2013-10-25 00:52:11 +00:00
|
|
|
void downloadFinished();
|
2019-12-09 13:02:05 +00:00
|
|
|
void uploadFinished(bool success, const QString &text);
|
2013-10-25 00:52:11 +00:00
|
|
|
void downloadError(QNetworkReply::NetworkError error);
|
2013-11-14 22:39:17 +00:00
|
|
|
void startUpload();
|
2019-12-09 13:02:05 +00:00
|
|
|
void updateProgress(qreal current, qreal total);
|
|
|
|
void uploadStatus(const QString &text);
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-10-25 00:52:11 +00:00
|
|
|
private:
|
2020-10-25 21:27:39 +00:00
|
|
|
explicit DivelogsDeWebServices(QWidget *parent = 0);
|
2013-10-25 00:52:11 +00:00
|
|
|
void setStatusText(int status);
|
|
|
|
void download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status);
|
2014-02-28 04:09:57 +00:00
|
|
|
unsigned int download_dialog_parse_response(const QByteArray &length);
|
2013-11-15 02:57:09 +00:00
|
|
|
|
|
|
|
QTemporaryFile zipFile;
|
2013-12-09 17:23:32 +00:00
|
|
|
bool uploadMode;
|
2019-12-09 12:24:08 +00:00
|
|
|
bool useSelectedDives;
|
2013-10-25 00:52:11 +00:00
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // SUBSURFACEWEBSERVICES_H
|