# HG changeset patch # User alfadur # Date 1507482260 -7200 # Node ID 8d266b2d0f9c9b2dc2a06fb7424b6242f18ad228 # Parent 28e859ea393b6481bbaecd133bdce5808117f494 Improve error messages when feedback or DLC fail to reach Internet Problems with a missing SSL library are hinted at. diff -r 28e859ea393b -r 8d266b2d0f9c QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sun Oct 08 16:50:47 2017 +0200 +++ b/QTfrontend/hwform.cpp Sun Oct 08 19:04:20 2017 +0200 @@ -2250,11 +2250,27 @@ { QNetworkReply *reply = qobject_cast(sender()); - if (reply && (reply->error() == QNetworkReply::NoError)) { - FeedbackDialog dialog(this); - dialog.exec(); - } else - MessageDialog::ShowErrorMessage(tr("This page requires an internet connection."), this); + if (reply) { + switch (reply->error()) { + case QNetworkReply::NoError: + { + FeedbackDialog dialog(this); + dialog.exec(); + } + break; + case QNetworkReply::UnknownNetworkError: + MessageDialog::ShowFatalMessage( + tr("Unknown network error (possibly missing SSL library)."), this); + break; + default: + MessageDialog::ShowFatalMessage( + QString(tr("This feature requires an Internet connection, but you don't appear to be online (error code: %1).")).arg(reply->error()), this); + break; + } + } + else { + MessageDialog::ShowFatalMessage(tr("Internal error: Reply object is invalid."), this); + } } void HWForm::startGame() diff -r 28e859ea393b -r 8d266b2d0f9c QTfrontend/ui/page/pagedata.cpp --- a/QTfrontend/ui/page/pagedata.cpp Sun Oct 08 16:50:47 2017 +0200 +++ b/QTfrontend/ui/page/pagedata.cpp Sun Oct 08 19:04:20 2017 +0200 @@ -136,22 +136,34 @@ void PageDataDownload::pageDownloaded() { QNetworkReply * reply = qobject_cast(sender()); + const char *html = + "

Hedgewars Downloadable Content



" + "

%1

"; - if (reply && (reply->error() == QNetworkReply::NoError)) { - QString html = QString::fromUtf8(reply->readAll()); - int begin = html.indexOf(""); - int end = html.indexOf(""); - if(begin != -1 && begin < end) + if (reply) { + if (reply->error() == QNetworkReply::NoError) { - html.truncate(end); - html.remove(0, begin); + QString html = QString::fromUtf8(reply->readAll()); + int begin = html.indexOf(""); + int end = html.indexOf(""); + if(begin != -1 && begin < end) + { + html.truncate(end); + html.remove(0, begin); + } + web->setHtml(html); } - web->setHtml(html); - } else - web->setHtml(QString( - "

Hedgewars Downloadable Content



" - "

%1

") - .arg(tr("This page requires an internet connection."))); + else + { + QString message = reply->error() == QNetworkReply::UnknownNetworkError ? + tr("Unknown network error (possibly missing SSL library).") : + QString(tr("This feature requires an Internet connection, but you don't appear to be online (error code: %1).")).arg(reply->error()); + web->setHtml(QString(html).arg(message)); + } + } + else { + web->setHtml(QString(html).arg(tr("Internal error: Reply object is invalid."))); + } } void PageDataDownload::fileDownloaded()