From 89144b2832c7df351c09ab69ca5d69f910b1411f Mon Sep 17 00:00:00 2001 From: lotodore Date: Sun, 23 Dec 2012 00:33:04 +0100 Subject: [PATCH] Fixing log upload error handling. --- src/game_defs.h | 2 ++ src/gui/qt/logfiledialog/logfiledialog.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/game_defs.h b/src/game_defs.h index 07a0bde2..b9d33307 100644 --- a/src/game_defs.h +++ b/src/game_defs.h @@ -104,6 +104,8 @@ enum PlayerActionLog { }; #define LOG_UPLOAD_ID_SIZE 40 +#define LOG_UPLOAD_OK_STR "OK" +#define LOG_UPLOAD_ERROR_STR "ERROR" enum LogUploadErrorCode { LOG_UPLOAD_ERROR_NO_FILE = 1, diff --git a/src/gui/qt/logfiledialog/logfiledialog.cpp b/src/gui/qt/logfiledialog/logfiledialog.cpp index d4b0b0aa..3e63b85b 100644 --- a/src/gui/qt/logfiledialog/logfiledialog.cpp +++ b/src/gui/qt/logfiledialog/logfiledialog.cpp @@ -259,19 +259,21 @@ void LogFileDialog::showLogAnalysis(QString /*filename*/, QString returnMessage) { uploadInProgressAnimationStop(); - QString id = returnMessage.trimmed(); + returnMessage = returnMessage.trimmed(); + QString retStr(returnMessage.mid(0, returnMessage.indexOf(' '))); - if(id.length() == LOG_UPLOAD_ID_SIZE && id.at(0) != '<') { - - qDebug() << id << endl; - QDesktopServices::openUrl(QUrl("http://logfile-analysis.pokerth.net/?ID="+id)); + if (retStr == LOG_UPLOAD_OK_STR) { + QString hash(returnMessage.mid(retStr.size()).trimmed()); + qDebug() << hash << endl; + QDesktopServices::openUrl(QUrl("http://logfile-analysis.pokerth.net/?ID=" + hash)); } else { qDebug() << returnMessage << endl; QString serverMsg(tr("Processing of the log file on the web server failed.\nPlease verify that you are uploading a valid PokerTH log file.")); // if there is an error code, display a corresponding message. - if (returnMessage.at(0).isDigit()) { + if (retStr == LOG_UPLOAD_ERROR_STR) { + QString errorId(returnMessage.mid(retStr.size()).trimmed()); serverMsg += "\n" + tr("Failure reason: "); - switch (returnMessage.toInt()) + switch (errorId.toInt()) { case LOG_UPLOAD_ERROR_NO_FILE : serverMsg += tr("No file received.");