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>
This commit is contained in:
jan Iversen 2019-12-10 14:39:53 +01:00 committed by Dirk Hohndel
parent e3416fa152
commit e5f3e927a7

View file

@ -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);
}