diff options
author | jan Iversen <jan@casacondor.com> | 2019-12-09 13:24:08 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-11 12:36:43 -0500 |
commit | 9fd95c18bd08dd6d197c9e02a302dc97bd221f44 (patch) | |
tree | 24e4c21ef2891a859f900ce3f57f3b4b7c700242 /desktop-widgets/subsurfacewebservices.cpp | |
parent | 8becc29ca881332b3567ec15a396da9845837318 (diff) | |
download | subsurface-9fd95c18bd08dd6d197c9e02a302dc97bd221f44.tar.gz |
desktop-widgets: divelogsDE: delay handling until user select upload
Do not prepare zip file, just because user selected the divelogs.de
radiobutton
Move prepareDives to startUpload (slot handling user clicking on
upload button).
Signed-off-by: Jan Iversen <jan@casacondor.com>
Diffstat (limited to 'desktop-widgets/subsurfacewebservices.cpp')
-rw-r--r-- | desktop-widgets/subsurfacewebservices.cpp | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp index bca36b5e4..bc1311f5b 100644 --- a/desktop-widgets/subsurfacewebservices.cpp +++ b/desktop-widgets/subsurfacewebservices.cpp @@ -238,9 +238,8 @@ void DivelogsDeWebServices::prepareDivesForUpload(bool selected) { // this is called when the user selects the divelogs.de radiobutton - // Prepare zip file - if (!uploadDives(selected)) - return; + // Remember if all dives or selected dives are to be uploaded + useSelectedDives = selected; // Adjust UI hideDownload(); @@ -290,6 +289,32 @@ bool DivelogsDeWebServices::uploadDives(bool selected) } f.close(); f.remove(); + + { + QNetworkRequest request; + request.setUrl(QUrl("https://divelogs.de/DivelogsDirectImport.php")); + request.setRawHeader("Accept", "text/xml, application/xml"); + request.setRawHeader("User-Agent", userAgent.toUtf8()); + + QHttpPart part; + part.setRawHeader("Content-Disposition", "form-data; name=\"user\""); + part.setBody(ui.userID->text().toUtf8()); + multipart->append(part); + + part.setRawHeader("Content-Disposition", "form-data; name=\"pass\""); + part.setBody(ui.password->text().toUtf8()); + multipart->append(part); + + reply = manager()->post(request, multipart); + connect(reply, SIGNAL(finished()), this, SLOT(uploadFinished())); + connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, + SLOT(uploadError(QNetworkReply::NetworkError))); + connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, + SLOT(updateProgress(qint64, qint64))); + + timeout.start(30000); // 30s + + } return true; } @@ -319,28 +344,14 @@ void DivelogsDeWebServices::startUpload() ui.userID->setEnabled(false); ui.password->setEnabled(false); - QNetworkRequest request; - request.setUrl(QUrl("https://divelogs.de/DivelogsDirectImport.php")); - request.setRawHeader("Accept", "text/xml, application/xml"); - request.setRawHeader("User-Agent", userAgent.toUtf8()); - - QHttpPart part; - part.setRawHeader("Content-Disposition", "form-data; name=\"user\""); - part.setBody(ui.userID->text().toUtf8()); - multipart->append(part); - - part.setRawHeader("Content-Disposition", "form-data; name=\"pass\""); - part.setBody(ui.password->text().toUtf8()); - multipart->append(part); - - reply = manager()->post(request, multipart); - connect(reply, SIGNAL(finished()), this, SLOT(uploadFinished())); - connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, - SLOT(uploadError(QNetworkReply::NetworkError))); - connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, - SLOT(updateProgress(qint64, qint64))); + // Prepare zip file + if (!uploadDives(useSelectedDives)) + return; - timeout.start(30000); // 30s + // Remember for later + // connect(reply, SIGNAL(finished()), this, SLOT(listDownloadFinished())); + // connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), + // this, SLOT(downloadError(QNetworkReply::NetworkError))); } void DivelogsDeWebServices::startDownload() |