mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 21:20:19 +00:00
609715ab69
The "report_error()" interface is a lot simpler, although some of the C++ code uses QStrings which make them a bit annoying, especially for the varargs model. Still, even with the explicit conversion to UTF8 and "char *", the report_error() model is much nicer. This also just makes refreshDisplay() do the error reporting in the UI automatically, so a number of error paths don't even have to worry. And the multi-line model of error reporting means that it all automatically does the right thing, and reports errors for each file rather than just for the last file that failed to open. So this removes closer to a hundred lines of cruft, while being a simpler interface and doing better error reporting. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
101 lines
2.5 KiB
C++
101 lines
2.5 KiB
C++
#ifndef SUBSURFACEWEBSERVICES_H
|
|
#define SUBSURFACEWEBSERVICES_H
|
|
|
|
#include <QDialog>
|
|
#include <QNetworkReply>
|
|
#include <QTemporaryFile>
|
|
#include <QTimer>
|
|
#include <libxml/tree.h>
|
|
|
|
#include "ui_webservices.h"
|
|
|
|
class QAbstractButton;
|
|
class QNetworkReply;
|
|
class QHttpMultiPart;
|
|
|
|
class WebServices : public QDialog {
|
|
Q_OBJECT
|
|
public:
|
|
explicit WebServices(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
|
void hidePassword();
|
|
void hideUpload();
|
|
void hideDownload();
|
|
|
|
static QNetworkAccessManager *manager();
|
|
|
|
private
|
|
slots:
|
|
virtual void startDownload() = 0;
|
|
virtual void startUpload() = 0;
|
|
virtual void buttonClicked(QAbstractButton *button) = 0;
|
|
virtual void downloadTimedOut();
|
|
|
|
protected
|
|
slots:
|
|
void updateProgress(qint64 current, qint64 total);
|
|
|
|
protected:
|
|
void resetState();
|
|
void connectSignalsForDownload(QNetworkReply *reply);
|
|
void connectSignalsForUpload();
|
|
|
|
Ui::WebServices ui;
|
|
QNetworkReply *reply;
|
|
QTimer timeout;
|
|
QByteArray downloadedData;
|
|
QString defaultApplyText;
|
|
};
|
|
|
|
class SubsurfaceWebServices : public WebServices {
|
|
Q_OBJECT
|
|
public:
|
|
explicit SubsurfaceWebServices(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
|
|
|
private
|
|
slots:
|
|
void startDownload();
|
|
void buttonClicked(QAbstractButton *button);
|
|
void downloadFinished();
|
|
void downloadError(QNetworkReply::NetworkError error);
|
|
void startUpload()
|
|
{
|
|
} /*no op*/
|
|
private:
|
|
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();
|
|
void downloadDives();
|
|
void prepareDivesForUpload();
|
|
|
|
private
|
|
slots:
|
|
void startDownload();
|
|
void buttonClicked(QAbstractButton *button);
|
|
void saveToZipFile();
|
|
void listDownloadFinished();
|
|
void downloadFinished();
|
|
void uploadFinished();
|
|
void downloadError(QNetworkReply::NetworkError error);
|
|
void uploadError(QNetworkReply::NetworkError error);
|
|
void startUpload();
|
|
|
|
private:
|
|
void uploadDives(QIODevice *dldContent);
|
|
explicit DivelogsDeWebServices(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
|
void setStatusText(int status);
|
|
bool prepare_dives_for_divelogs(const QString &filename, bool selected);
|
|
void download_dialog_traverse_xml(xmlNodePtr node, unsigned int *download_status);
|
|
unsigned int download_dialog_parse_response(const QByteArray &length);
|
|
|
|
QHttpMultiPart *multipart;
|
|
QTemporaryFile zipFile;
|
|
bool uploadMode;
|
|
};
|
|
|
|
#endif // SUBSURFACEWEBSERVICES_H
|