From 30664197a1076384077a95c2c9917ba554de4101 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 3 Oct 2012 18:55:13 +0200 Subject: Network error management (again) Following the 1.x series, a better error management based on SOLID (i.e. added dependency about) showing local network problems, if any, or suggesting search engines or cached copy. Removed the hated "wall of text" --- src/CMakeLists.txt | 1 + src/webtab/webpage.cpp | 76 ++++++++++++++++++++++---------------------------- 2 files changed, 34 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5d5c8c2..b8dd0c06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -227,6 +227,7 @@ TARGET_LINK_LIBRARIES ( kdeinit_rekonq ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KPARTS_LIBS} + ${KDE4_SOLID_LIBS} ) # Nepomuk optional target link libraries diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp index 585c6aab..93d59d90 100644 --- a/src/webtab/webpage.cpp +++ b/src/webtab/webpage.cpp @@ -69,6 +69,8 @@ #include +#include + // Qt Includes #include #include @@ -313,6 +315,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r } removeSessionMetaData(QL1S("no-cache")); } + return KWebPage::acceptNavigationRequest(frame, request, type); } @@ -583,7 +586,7 @@ QString WebPage::errorPage(QNetworkReply *reply) bool isOpened = file.open(QIODevice::ReadOnly); if (!isOpened) { - return QString("Couldn't open the rekonqinfo.html file"); + return QString("Couldn't open the rekonqinfo.html file! This probably means you installed rekonq in a bad way."); } // NOTE: @@ -597,33 +600,39 @@ QString WebPage::errorPage(QNetworkReply *reply) // 2. title QString title = i18n("There was a problem while loading the page"); - // 3. main content QString msg; - msg += i18n("

Oops! Rekonq cannot load %1

", urlString); + // test to see if networking is enabled on the system + if(Solid::Networking::status() != Solid::Networking::Connected) + { + msg += QL1S("

") + i18n("Network is NOT available") + QL1S("

"); + QString faceIconPath = QString("file://") + KIconLoader::global()->iconPath("face-surprise" , -KIconLoader::SizeHuge, false); + msg += QL1S(""); + msg += QL1S("
"); + msg += QL1S(""); + msg += QL1S(""); - msg += i18n("

Wrongly typed?

"); + msg += QL1S("

"); - msg += QL1S(""); - msg += QL1S("
"); + msg += i18n("Maybe you are having problems with your network settings.
Try checking your network connections, your proxy settings and your firewall.

Then try again.
",QL1S("about:settings/network"), QL1S("about:settings/proxy"),QL1S("about:settings/firewall"), urlString ); + + msg += QL1S("

"); - msg += QL1S("

"); + msg += QL1S("

"); - msg += i18n("We tried to load url: %1.
", urlString); - msg += i18n("Check your address for errors like ww.kde.org instead of www.kde.org.
"); - msg += i18n("If you spelled right, just try to reload it.
", urlString); - msg += i18n("Otherwise, just be careful the next time around."); + // done. Replace variables and show it + QString html = QL1S(file.readAll()); - msg += QL1S("

"); + html.replace(QL1S("$DEFAULT_PATH"), dataPath); + html.replace(QL1S("$PAGE_TITLE"), title); + html.replace(QL1S("$MAIN_CONTENT"), msg); - QString laughIconPath = QString("file://") + KIconLoader::global()->iconPath("face-laugh" , -KIconLoader::SizeHuge, false); - msg += QL1S("
"); - msg += QL1S(""); - msg += QL1S("
"); + return html; + } - msg += i18n("

Network problems?

"); + msg += QL1S("

") + i18n("Oops! Rekonq cannot load %1", urlString) + QL1S("

"); QString faceIconPath = QString("file://") + KIconLoader::global()->iconPath("face-surprise" , -KIconLoader::SizeHuge, false); msg += QL1S(""); @@ -631,32 +640,15 @@ QString WebPage::errorPage(QNetworkReply *reply) msg += QL1S(""); msg += QL1S("
"); - msg += QL1S("

"); - - msg += i18n("Maybe you are having problems with your network.
"); - msg += i18n("Try checking your network connections", QL1S("about:settings/network")); - msg += i18n(", your proxy settings ", QL1S("about:settings/proxy")); - msg += i18n("and your firewall.
", QL1S("about:settings/firewall")); - msg += i18n("Then try again.
"); - - msg += QL1S("

"); - - msg += QL1S("
"); - - - msg += i18n("

Suggestions

"); - - msg += QL1S(""); - msg += QL1S("
"); - - msg += QL1S("

"); + msg += QL1S("

") + reply->errorString() + QL1S("

"); // Default SearchEngine KService::Ptr defaultEngine = SearchEngine::defaultEngine(); + msg += QL1S("

"); if (defaultEngine) { - msg += i18n("Consult your default search engine about:"); + msg += i18n("Ask your default search engine about:"); msg += QL1S(" "); msg += i18n("search with %1", defaultEngine->name()); msg += QL1S("!
"); @@ -665,16 +657,14 @@ QString WebPage::errorPage(QNetworkReply *reply) { msg += i18n("You don't have a default search engine set. We won't suggest you one."); } + msg += QL1S("

"); - msg += i18n("At least, you can consult a cached snapshot of the site:
"); - msg += i18n("Try checking the Wayback Machine", QL1S("http://wayback.archive.org/web/*/") + urlString); + msg += QL1S("

"); + msg += i18n("Consult a cached snapshot of the site: "); + msg += i18n("try checking the Wayback Machine", QL1S("http://wayback.archive.org/web/*/") + urlString); msg += i18n(" or the Google Cache.", QL1S("http://google.com/search?q=cache:") + urlString); - msg += QL1S("

"); - QString winkIconPath = QString("file://") + KIconLoader::global()->iconPath("face-wink" , -KIconLoader::SizeHuge, false); - msg += QL1S("
"); - msg += QL1S(""); msg += QL1S("
"); // done. Replace variables and show it -- cgit v1.2.1