diff options
-rw-r--r-- | src/protocolhandler.cpp | 50 | ||||
-rw-r--r-- | src/urlbar/urlresolver.cpp | 3 |
2 files changed, 28 insertions, 25 deletions
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index be236843..23743acf 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -49,6 +49,8 @@ #include <KProcess> #include <KStandardDirs> #include <KToolInvocation> +#include <KProtocolInfo> +#include <KRun> // Qt Includes #include <QtNetwork/QNetworkRequest> @@ -74,10 +76,14 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra _url = request.url(); _frame = frame; - // "http(s)" (fast) handling - if (_url.protocol() == QL1S("http") || _url.protocol() == QL1S("https")) + // rekonq can handle http/s browsing easily + if (_url.protocol() == QL1S("http") || _url.protocol() == QL1S("https") || _url.protocol() == QL1S("file")) return false; + // rekonq can handle file & ftp schemes, if you like,, + if (_url.protocol() == QL1S("ftp") || _url.protocol() == QL1S("file")) + return false; + // relative urls if (_url.isRelative()) return false; @@ -104,28 +110,8 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra return true; } - // "mailto" handling - if (_url.protocol() == QL1S("mailto")) - { - KToolInvocation::invokeMailer(_url); - return true; - } - - // "apturl" handling - if (_url.protocol() == QL1S ("apt")) - { - //Declare apturl as QString - QString apturl="apturl"; - //We need to convert the url to QStringList to pass as a argument to apturl - QStringList host; - host << _url.url(); - - if ( KProcess::execute (apturl,host)==0) - return true; - else - return false; - - } + // NOTE + // handle here "custom" rekonq protocols // "abp" handling if (_url.protocol() == QL1S("abp")) @@ -172,6 +158,22 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra return true; } + //If rekonq cant handle a protocol by itself, it will hand it over to KDE via KRun + if(KProtocolInfo::isKnownProtocol(_url)) + { + new KRun(_url, Application::instance()->mainWindow()); + return true; //No need to delete KRun, it autodeletes itself + } + else + { + //Error Message, for those protocols even KDE cant handle + KMessageBox::error( Application::instance()->mainWindow(), i18nc("@info", + "rekonq can not handle this URL. \ + Please use an appropriate application to open it.")); + return false; + } + + return false; } diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp index 8ecc5537..71d6e69c 100644 --- a/src/urlbar/urlresolver.cpp +++ b/src/urlbar/urlresolver.cpp @@ -42,6 +42,7 @@ #include <KService> #include <KConfig> #include <KConfigGroup> +#include <KProtocolInfo> // Qt Includes #include <QByteArray> @@ -77,7 +78,7 @@ UrlResolver::UrlResolver(const QString &typedUrl) { kDebug() << "browse regexp empty. Setting value.."; - QString protocol = "^(http://|https://|file://|ftp://|man:|info:|apt:|about:)"; + QString protocol = QString("^(%1)").arg(KProtocolInfo::protocols().join("|")); QString localhost = "^localhost"; |