From d9f6bd88c222e257a1b6c11f69b146d88bea6a90 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sat, 22 Dec 2012 20:56:00 +0100 Subject: [PATCH] More work on log upload error codes. --- src/game_defs.h | 1 - src/gui/qt/logfiledialog/logfiledialog.cpp | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/game_defs.h b/src/game_defs.h index 63a81380..07a0bde2 100644 --- a/src/game_defs.h +++ b/src/game_defs.h @@ -103,7 +103,6 @@ enum PlayerActionLog { LOG_ACTION_JOIN // has joined the game }; -#define LOG_UPLOAD_ERROR_PREFIX "ERROR" #define LOG_UPLOAD_ID_SIZE 40 enum LogUploadErrorCode { diff --git a/src/gui/qt/logfiledialog/logfiledialog.cpp b/src/gui/qt/logfiledialog/logfiledialog.cpp index 2d7b1753..d4b0b0aa 100644 --- a/src/gui/qt/logfiledialog/logfiledialog.cpp +++ b/src/gui/qt/logfiledialog/logfiledialog.cpp @@ -261,19 +261,17 @@ void LogFileDialog::showLogAnalysis(QString /*filename*/, QString returnMessage) QString id = returnMessage.trimmed(); - if(id.length() == LOG_UPLOAD_ID_SIZE && !id.contains(LOG_UPLOAD_ERROR_PREFIX)) { + if(id.length() == LOG_UPLOAD_ID_SIZE && id.at(0) != '<') { qDebug() << id << endl; QDesktopServices::openUrl(QUrl("http://logfile-analysis.pokerth.net/?ID="+id)); } 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 a readable message, display it. - if (returnMessage.startsWith(LOG_UPLOAD_ERROR_PREFIX)) { + // if there is an error code, display a corresponding message. + if (returnMessage.at(0).isDigit()) { serverMsg += "\n" + tr("Failure reason: "); - QString errorCodeStr = returnMessage.mid(sizeof(LOG_UPLOAD_ERROR_PREFIX)).trimmed(); - int errorCode = errorCodeStr.toInt(); - switch (errorCode) + switch (returnMessage.toInt()) { case LOG_UPLOAD_ERROR_NO_FILE : serverMsg += tr("No file received."); @@ -296,7 +294,7 @@ void LogFileDialog::showLogAnalysis(QString /*filename*/, QString returnMessage) case LOG_UPLOAD_ERROR_FILE_MOVE : case LOG_UPLOAD_ERROR_INSERT_DB : default : - serverMsg += tr("Internal error. Please try again later. ID: ") + errorCodeStr; + serverMsg += tr("Internal error. Please try again later. ID: ") + returnMessage; break; } }