diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-12-07 17:10:58 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-12-09 16:23:57 +0200 |
commit | 70fce6ce6b37ea0372ea8072fcea3672344d43a4 (patch) | |
tree | ef1ea24288d98fe8757807661c0f36dd612605d3 | |
parent | 551449986701ccfc23cf32388648ec43b4ae1338 (diff) | |
download | subsurface-70fce6ce6b37ea0372ea8072fcea3672344d43a4.tar.gz |
Divelogs.de: further improve reading the server reponse
We now check for the following entries:
<Login>succeeded</Login>
<FileCopy>failed</FileCopy>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 1a1798e16..3b1b25443 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -543,6 +543,7 @@ void DivelogsDeWebServices::prepareDivesForUpload() if (filename) { QFile f(filename); if (f.exists()) { + f.open(QIODevice::ReadOnly); uploadDives((QIODevice *)&f); f.close(); f.remove(); @@ -744,18 +745,21 @@ void DivelogsDeWebServices::uploadFinished() // an error condition, such as a failed login QByteArray xmlData = reply->readAll(); char *resp = xmlData.data(); - // qDebug() << resp; if (resp) { char *parsed = strstr(resp, "<Login>"); - // char *endat = strstr(resp, "</divelogsDataImport>"); if (parsed) { - if (strstr(resp, "failed")) - ui.status->setText(tr("Login failed")); - else + if (strstr(resp, "<Login>succeeded</Login>")) { + if (strstr(resp, "<FileCopy>failed</FileCopy>")) { + ui.status->setText(tr("Upload failed")); + return; + } ui.status->setText(tr("Upload successful")); - } else { - ui.status->setText(tr("Cannot parse response")); + return; + } + ui.status->setText(tr("Login failed")); + return; } + ui.status->setText(tr("Cannot parse response")); } } |