diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-09-03 14:20:19 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-10-30 10:36:49 -0700 |
commit | e49d6213ad129284a45d53c3fcdc03249e84efe2 (patch) | |
tree | 2946a666ab38af3375e7bb2b8c5dd887d4a7f9a1 /desktop-widgets/subsurfacewebservices.h | |
parent | 588abd019fb2ed3f607682f2b6c7fe86a7a5bb90 (diff) | |
download | subsurface-e49d6213ad129284a45d53c3fcdc03249e84efe2.tar.gz |
Move qt-ui to desktop-widgets
Since we have now destkop and mobile versions, 'qt-ui' was a very
poor name choice for a folder that contains only destkop-enabled
widgets.
Also, move the graphicsview-common.h/cpp to subsurface-core because
it doesn't depend on qgraphicsview, it merely implements all the
colors that we use throughout Subsurface, and we will use colors on both
desktop and mobile versions
Same thing applies for metrics.h/cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/subsurfacewebservices.h')
-rw-r--r-- | desktop-widgets/subsurfacewebservices.h | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/desktop-widgets/subsurfacewebservices.h b/desktop-widgets/subsurfacewebservices.h new file mode 100644 index 000000000..2b454ebc7 --- /dev/null +++ b/desktop-widgets/subsurfacewebservices.h @@ -0,0 +1,142 @@ +#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 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; + QString userAgent; +}; + +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(bool selected); + +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; +}; + +class UserSurveyServices : public WebServices { + Q_OBJECT +public: + QNetworkReply* sendSurvey(QString values); + explicit UserSurveyServices(QWidget *parent = 0, Qt::WindowFlags f = 0); +private +slots: + // need to declare them as no ops or Qt4 is unhappy + virtual void startDownload() { } + virtual void startUpload() { } + virtual void buttonClicked(QAbstractButton *button) { } +}; + +class CloudStorageAuthenticate : public QObject { + Q_OBJECT +public: + QNetworkReply* backend(QString email, QString password, QString pin = "", QString newpasswd = ""); + explicit CloudStorageAuthenticate(QObject *parent); +signals: + void finishedAuthenticate(); + void passwordChangeSuccessful(); +private +slots: + void uploadError(QNetworkReply::NetworkError error); + void sslErrors(QList<QSslError> errorList); + void uploadFinished(); +private: + QNetworkReply *reply; + QString userAgent; + +}; + +#ifdef __cplusplus +extern "C" { +#endif +extern void set_save_userid_local(short value); +extern void set_userid(char *user_id); +#ifdef __cplusplus +} +#endif + +#endif // SUBSURFACEWEBSERVICES_H |