diff options
author | jan Iversen <jan@casacondor.com> | 2019-12-10 14:39:53 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-11 11:08:51 -0500 |
commit | e5f3e927a703e6dbd235ebc9500c413295bd0d78 (patch) | |
tree | 5e79e9c25fcfe563ebda9285ef64859b5815b3e2 /desktop-widgets | |
parent | e3416fa152a3ac0ba40dc115812d3986169f4b5a (diff) | |
download | subsurface-e5f3e927a703e6dbd235ebc9500c413295bd0d78.tar.gz |
desktop-widgets: use shared uploadDiveShare for diveshare.
Remove shared code from DiveShareExportDialog::doUpload()
and add call to uploadDiveShare::doUpload()
Remark signal handling is not implemented.
Signed-off-by: Jan Iversen <jan@casacondor.com>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/diveshareexportdialog.cpp | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/desktop-widgets/diveshareexportdialog.cpp b/desktop-widgets/diveshareexportdialog.cpp index c35ac5d43..5207569fb 100644 --- a/desktop-widgets/diveshareexportdialog.cpp +++ b/desktop-widgets/diveshareexportdialog.cpp @@ -6,6 +6,7 @@ #include "desktop-widgets/subsurfacewebservices.h" #include "core/qthelper.h" #include "core/cloudstorage.h" +#include "core/uploadDiveShare.h" #include "core/settings/qPrefCloudStorage.h" #include <QDesktopServices> @@ -105,8 +106,10 @@ void DiveShareExportDialog::finishedSlot() void DiveShareExportDialog::doUpload() { //Store current settings - qPrefCloudStorage::set_diveshare_uid(ui->txtUID->text()); - qPrefCloudStorage::set_diveshare_private(ui->chkPrivate->isChecked()); + QString uid = ui->txtUID->text(); + bool noPublic = ui->chkPrivate->isChecked(); + qPrefCloudStorage::set_diveshare_uid(uid); + qPrefCloudStorage::set_diveshare_private(noPublic); //Change UI into results mode ui->frameConfigure->setVisible(false); @@ -114,25 +117,5 @@ void DiveShareExportDialog::doUpload() ui->progressBar->setVisible(true); ui->progressBar->setRange(0, 0); - //generate json - struct membuffer buf = {}; - export_list(&buf, NULL, exportSelected, false); - QByteArray json_data(buf.buffer, buf.len); - free_buffer(&buf); - - //Request to server - QNetworkRequest request; - - if (ui->chkPrivate->isChecked()) - request.setUrl(QUrl(DIVESHARE_BASE_URI "/upload?private=true")); - else - request.setUrl(QUrl(DIVESHARE_BASE_URI "/upload")); - - request.setRawHeader("User-Agent", getUserAgent().toUtf8()); - if (ui->txtUID->text().length() != 0) - request.setRawHeader("X-UID", ui->txtUID->text().toUtf8()); - - reply = manager()->put(request, json_data); - - QObject::connect(reply, SIGNAL(finished()), this, SLOT(finishedSlot())); + uploadDiveShare::instance()->doUpload(exportSelected, uid, noPublic); } |