summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar jan Iversen <jan@casacondor.com>2019-12-10 14:33:54 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-11 11:08:51 -0500
commite3416fa152a3ac0ba40dc115812d3986169f4b5a (patch)
tree75f0055436ba4d50fd267ba01f575e387cbf105e /core
parentbba9385d769fc56fcd051106aa400359719b0bfb (diff)
downloadsubsurface-e3416fa152a3ac0ba40dc115812d3986169f4b5a.tar.gz
core: copy doUpload from desktop-widgets to core
Add DiveShareExportDialog::do_upload() to uploadDiveShare::do_upload(), while cleaning it from UI. Add signal connections as used in uploadDiveLogsDE Signed-off-by: Jan Iversen <jan@casacondor.com>
Diffstat (limited to 'core')
-rw-r--r--core/uploadDiveShare.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/core/uploadDiveShare.cpp b/core/uploadDiveShare.cpp
index 67354d084..0ad8b520b 100644
--- a/core/uploadDiveShare.cpp
+++ b/core/uploadDiveShare.cpp
@@ -26,6 +26,34 @@ uploadDiveShare::uploadDiveShare():
void uploadDiveShare::doUpload(bool selected, const QString &uid, bool noPublic)
{
+ //generate json
+ struct membuffer buf = {};
+ export_list(&buf, NULL, selected, false);
+ QByteArray json_data(buf.buffer, buf.len);
+ free_buffer(&buf);
+
+ //Request to server
+ QNetworkRequest request;
+ if (noPublic)
+ request.setUrl(QUrl("http://dive-share.appspot.com/upload?private=true"));
+ else
+ request.setUrl(QUrl("http://dive-share.appspot.com/upload"));
+ request.setRawHeader("User-Agent", getUserAgent().toUtf8());
+ if (uid.length() != 0)
+ request.setRawHeader("X-UID", uid.toUtf8());
+
+ // Execute async.
+ reply = manager()->put(request, json_data);
+
+ // connect signals from upload process
+ connect(reply, SIGNAL(finished()), this, SLOT(slot_uploadFinished()));
+ connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
+ SLOT(slot_uploadError(QNetworkReply::NetworkError)));
+ connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this,
+ SLOT(slot_updateProgress(qint64, qint64)));
+ connect(&timeout, SIGNAL(timeout()), this, SLOT(slot_uploadTimeout()));
+
+ timeout.start(30000); // 30s
}
@@ -65,7 +93,7 @@ void uploadDiveShare::slot_uploadTimeout()
reply->deleteLater();
reply = NULL;
}
- QString err(tr("divelogs.de not responding"));
+ QString err(tr("dive-share.com not responding"));
report_error(err.toUtf8());
emit uploadFinish(false, err);
}