From 3aa17f3d2d6b2e40da55456d2c7336abbb1df3b5 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 10 Jan 2010 12:55:58 +0100 Subject: Protocol Handling fix We can now manage all the most important protocols :D --- src/protocolhandler.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 602ac016..cd75d06f 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -25,6 +25,7 @@ // Self Includes #include "protocolhandler.h" +#include "protocolhandler.moc" // Auto Includes #include "rekonq.h" @@ -74,13 +75,17 @@ ProtocolHandler::~ProtocolHandler() } -bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame) +bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *frame) { _url = request.url(); _frame = frame; kDebug() << "URL PROTOCOL: " << _url; + // relative urls + if(_url.isRelative()) + return false; + // "http(s)" (fast) handling if( _url.protocol() == QLatin1String("http") || _url.protocol() == QLatin1String("https") ) return false; @@ -134,6 +139,29 @@ bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame) return true; } } + + return false; +} + + +bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *frame) +{ + _url = request.url(); + _frame = frame; + + kDebug() << "URL PROTOCOL: " << _url; + + // "http(s)" (fast) handling + if( _url.protocol() == QLatin1String("http") || _url.protocol() == QLatin1String("https") ) + return false; + + // "mailto" handling: It needs to be handled both here(mail links clicked) + // and in prehandling (mail url launched) + if ( _url.protocol() == QLatin1String("mailto") ) + { + KToolInvocation::invokeMailer(_url); + return true; + } // "ftp" handling. A little bit "hard" handling this. Hope I found // the best solution. @@ -154,6 +182,7 @@ bool ProtocolHandler::handle(const QNetworkRequest &request, QWebFrame *frame) if(fileInfo.isDir()) { _lister->openUrl(_url); + Application::instance()->mainWindow()->mainView()->urlBar()->setUrl(_url); return true; } } -- cgit v1.2.1