mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Whitespace cleanup
That one slipped by me... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
61d5aac2e8
commit
3a0f138023
1 changed files with 69 additions and 69 deletions
|
@ -296,10 +296,10 @@ void SubsurfaceWebServices::setStatusText(int status)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case DD_STATUS_ERROR_CONNECT: text = tr("Connection Error: "); break;
|
case DD_STATUS_ERROR_CONNECT: text = tr("Connection Error: "); break;
|
||||||
case DD_STATUS_ERROR_ID: text = tr("Invalid user identifier!"); break;
|
case DD_STATUS_ERROR_ID: text = tr("Invalid user identifier!"); break;
|
||||||
case DD_STATUS_ERROR_PARSE: text = tr("Cannot parse response!"); break;
|
case DD_STATUS_ERROR_PARSE: text = tr("Cannot parse response!"); break;
|
||||||
case DD_STATUS_OK: text = tr("Download Success!"); break;
|
case DD_STATUS_OK: text = tr("Download Success!"); break;
|
||||||
}
|
}
|
||||||
ui.status->setText(text);
|
ui.status->setText(text);
|
||||||
}
|
}
|
||||||
|
@ -356,80 +356,80 @@ struct DiveListResult
|
||||||
|
|
||||||
static DiveListResult parseDiveLogsDeDiveList(const QByteArray &xmlData)
|
static DiveListResult parseDiveLogsDeDiveList(const QByteArray &xmlData)
|
||||||
{
|
{
|
||||||
/* XML format seems to be:
|
/* XML format seems to be:
|
||||||
* <DiveDateReader version="1.0">
|
* <DiveDateReader version="1.0">
|
||||||
* <DiveDates>
|
* <DiveDates>
|
||||||
* <date diveLogsId="nnn" lastModified="YYYY-MM-DD hh:mm:ss">DD.MM.YYYY hh:mm</date>
|
* <date diveLogsId="nnn" lastModified="YYYY-MM-DD hh:mm:ss">DD.MM.YYYY hh:mm</date>
|
||||||
* [repeat <date></date>]
|
* [repeat <date></date>]
|
||||||
* </DiveDates>
|
* </DiveDates>
|
||||||
* </DiveDateReader>
|
* </DiveDateReader>
|
||||||
*/
|
*/
|
||||||
QXmlStreamReader reader(xmlData);
|
QXmlStreamReader reader(xmlData);
|
||||||
const QString invalidXmlError = DivelogsDeWebServices::tr("Invalid response from server");
|
const QString invalidXmlError = DivelogsDeWebServices::tr("Invalid response from server");
|
||||||
bool seenDiveDates = false;
|
bool seenDiveDates = false;
|
||||||
DiveListResult result;
|
DiveListResult result;
|
||||||
result.idCount = 0;
|
result.idCount = 0;
|
||||||
|
|
||||||
if (reader.readNextStartElement() && reader.name() != "DiveDateReader") {
|
if (reader.readNextStartElement() && reader.name() != "DiveDateReader") {
|
||||||
result.errorCondition = invalidXmlError;
|
result.errorCondition = invalidXmlError;
|
||||||
result.errorDetails =
|
result.errorDetails =
|
||||||
DivelogsDeWebServices::tr("Expected XML tag 'DiveDateReader', got instead '%1")
|
DivelogsDeWebServices::tr("Expected XML tag 'DiveDateReader', got instead '%1")
|
||||||
.arg(reader.name().toString());
|
.arg(reader.name().toString());
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (reader.readNextStartElement()) {
|
while (reader.readNextStartElement()) {
|
||||||
if (reader.name() != "DiveDates") {
|
if (reader.name() != "DiveDates") {
|
||||||
if (reader.name() == "Login") {
|
if (reader.name() == "Login") {
|
||||||
QString status = reader.readElementText();
|
QString status = reader.readElementText();
|
||||||
// qDebug() << "Login status:" << status;
|
// qDebug() << "Login status:" << status;
|
||||||
|
|
||||||
// Note: there has to be a better way to determine a successful login...
|
// Note: there has to be a better way to determine a successful login...
|
||||||
if (status == "failed") {
|
if (status == "failed") {
|
||||||
result.errorCondition = "Login failed";
|
result.errorCondition = "Login failed";
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// qDebug() << "Skipping" << reader.name();
|
// qDebug() << "Skipping" << reader.name();
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process <DiveDates>
|
// process <DiveDates>
|
||||||
seenDiveDates = true;
|
seenDiveDates = true;
|
||||||
while (reader.readNextStartElement()) {
|
while (reader.readNextStartElement()) {
|
||||||
if (reader.name() != "date") {
|
if (reader.name() != "date") {
|
||||||
// qDebug() << "Skipping" << reader.name();
|
// qDebug() << "Skipping" << reader.name();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QStringRef id = reader.attributes().value("divelogsId");
|
QStringRef id = reader.attributes().value("divelogsId");
|
||||||
// qDebug() << "Found" << reader.name() << "with id =" << id;
|
// qDebug() << "Found" << reader.name() << "with id =" << id;
|
||||||
if (!id.isEmpty()) {
|
if (!id.isEmpty()) {
|
||||||
result.idList += id.toLatin1();
|
result.idList += id.toLatin1();
|
||||||
result.idList += ',';
|
result.idList += ',';
|
||||||
++result.idCount;
|
++result.idCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// chop the ending comma, if any
|
// chop the ending comma, if any
|
||||||
result.idList.chop(1);
|
result.idList.chop(1);
|
||||||
|
|
||||||
if (!seenDiveDates) {
|
if (!seenDiveDates) {
|
||||||
result.errorCondition = invalidXmlError;
|
result.errorCondition = invalidXmlError;
|
||||||
result.errorDetails = DivelogsDeWebServices::tr("Expected XML tag 'DiveDates' not found");
|
result.errorDetails = DivelogsDeWebServices::tr("Expected XML tag 'DiveDates' not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (reader.hasError()) {
|
if (reader.hasError()) {
|
||||||
// if there was an XML error, overwrite the result or other error conditions
|
// if there was an XML error, overwrite the result or other error conditions
|
||||||
result.errorCondition = invalidXmlError;
|
result.errorCondition = invalidXmlError;
|
||||||
result.errorDetails = DivelogsDeWebServices::tr("Malformed XML response. Line %1: %2")
|
result.errorDetails = DivelogsDeWebServices::tr("Malformed XML response. Line %1: %2")
|
||||||
.arg(reader.lineNumber()).arg(reader.errorString());
|
.arg(reader.lineNumber()).arg(reader.errorString());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DivelogsDeWebServices* DivelogsDeWebServices::instance()
|
DivelogsDeWebServices* DivelogsDeWebServices::instance()
|
||||||
|
|
Loading…
Add table
Reference in a new issue