From f8a2d38a68138a2677774a6cdac8cd90ec6ca185 Mon Sep 17 00:00:00 2001 From: Rohan Garg Date: Thu, 14 Oct 2010 23:30:36 +0530 Subject: Optimize rekonq to handle more protocols --- src/protocolhandler.cpp | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index be236843..4ac85738 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -49,6 +49,8 @@ #include #include #include +#include +#include // Qt Includes #include @@ -74,8 +76,8 @@ 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 and file browsing easily + if (_url.protocol() == QL1S("http") || _url.protocol() == QL1S("https") || _url.protocol() == QL1S("file")) return false; // relative urls @@ -104,29 +106,6 @@ 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; - - } - // "abp" handling if (_url.protocol() == QL1S("abp")) { @@ -172,6 +151,20 @@ 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 it self + } + else if(!KProtocolInfo::isKnownProtocol(_url)) + { + //Error Message, for those protocols even KDE cant handle + KMessageBox::error( Application::instance()->mainWindow(), i18n("rekonq cannot handle this URL, please use a appropriate application to open it")); + return false; + } + + return false; } -- cgit v1.2.1