From d0ab264b8aa5f5c7fcb21dd172a1f3f5b777356b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Thu, 2 Sep 2010 18:10:46 +0200 Subject: Include clean-up in the big src directory --- src/webpage.cpp | 117 +++++++++++++++++++++++++++----------------------------- 1 file changed, 56 insertions(+), 61 deletions(-) (limited to 'src/webpage.cpp') diff --git a/src/webpage.cpp b/src/webpage.cpp index fbccbbe5..bde5aad2 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -32,49 +32,44 @@ // Self Includes #include "webpage.h" -#include "webpage.moc" // Auto Includes #include "rekonq.h" // Local Includes +#include "adblockmanager.h" #include "application.h" -#include "mainwindow.h" +#include "iconmanager.h" #include "mainview.h" -#include "webtab.h" -#include "webpluginfactory.h" +#include "mainwindow.h" #include "networkaccessmanager.h" -#include "adblockmanager.h" +#include "newtabpage.h" #include "urlbar.h" -#include "iconmanager.h" +#include "webpluginfactory.h" +#include "webtab.h" #include "sslinfodialog_p.h" // KDE Includes +#include +#include #include -#include +#include +#include +#include +#include +#include +#include #include -#include -#include +#include #include -#include - -#include -#include -#include -#include -#include - // Qt Includes -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include // Returns true if the scheme and domain of the two urls match... @@ -108,42 +103,42 @@ static bool downloadResource (const KUrl& srcUrl, const KIO::MetaData& metaData QWidget* parent = 0, const QString& suggestedName = QString()) { KUrl destUrl; - + int result = KIO::R_OVERWRITE; const QUrl fileName ((suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName)); - do + do { destUrl = KFileDialog::getSaveFileName(fileName, QString(), parent); - + if(destUrl.isEmpty()) return false; - if (destUrl.isLocalFile()) + if (destUrl.isLocalFile()) { QFileInfo finfo (destUrl.toLocalFile()); - if (finfo.exists()) + if (finfo.exists()) { QDateTime now = QDateTime::currentDateTime(); - QPointer dlg = new KIO::RenameDialog( parent, - i18n("Overwrite File?"), - srcUrl, + QPointer dlg = new KIO::RenameDialog( parent, + i18n("Overwrite File?"), + srcUrl, destUrl, KIO::RenameDialog_Mode(KIO::M_OVERWRITE | KIO::M_SKIP), - -1, + -1, finfo.size(), - now.toTime_t(), + now.toTime_t(), finfo.created().toTime_t(), - now.toTime_t(), + now.toTime_t(), finfo.lastModified().toTime_t() ); result = dlg->exec(); delete dlg; } } - } + } while (result == KIO::R_CANCEL && destUrl.isValid()); - + // Save download history Application::instance()->addDownload(srcUrl.pathOrUrl() , destUrl.pathOrUrl()); @@ -162,7 +157,7 @@ static bool downloadResource (const KUrl& srcUrl, const KIO::MetaData& metaData } return false; } - + KIO::Job *job = KIO::file_copy(srcUrl, destUrl, -1, KIO::Overwrite); if (!metaData.isEmpty()) @@ -172,7 +167,7 @@ static bool downloadResource (const KUrl& srcUrl, const KIO::MetaData& metaData job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available. job->uiDelegate()->setAutoErrorHandlingEnabled(true); return true; - + } @@ -216,7 +211,7 @@ WebPage::WebPage(QWidget *parent) // protocol handler signals connect(&_protHandler, SIGNAL(downloadUrl(const KUrl &)), this, SLOT(downloadUrl(const KUrl &))); - + connect(Application::iconManager(), SIGNAL(iconChanged()), mainFrame(), SIGNAL(iconChanged())); } @@ -318,7 +313,7 @@ WebPage *WebPage::createWindow(QWebPage::WebWindowType type) void WebPage::handleUnsupportedContent(QNetworkReply *reply) { Q_ASSERT (reply); - // NOTE: + // NOTE: // Until kio implements a way to resume/continue a network // request. We must abort the reply to prevent a zombie process // from continuing to download the unsupported content! @@ -330,18 +325,18 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (reply->error() != QNetworkReply::NoError) return; - + KUrl replyUrl = reply->url(); // HACK ------------------------------------------- // This is done to fix #231204 && #212808 - + QString mimeType; QString suggestedFileName; - + QString app = reply->header(QNetworkRequest::ContentTypeHeader).toString(); QStringList headerList = app.split( ';' ); - + if(headerList.count() > 0) { mimeType = headerList.takeFirst().trimmed(); @@ -362,24 +357,24 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); } - + // NOTE // This part has been copied from KWebPage::downloadResponse code - if (reply->hasRawHeader("Content-Disposition")) + if (reply->hasRawHeader("Content-Disposition")) { KIO::MetaData metaData = reply->attribute(static_cast(KIO::AccessManager::MetaData)).toMap(); - if (metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0) + if (metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0) { suggestedFileName = metaData.value(QL1S("content-disposition-filename")); - } - else + } + else { const QString value = QL1S(reply->rawHeader("Content-Disposition").simplified()); - if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive)) + if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive)) { const int length = value.size(); int pos = value.indexOf(QL1S("filename"), 0, Qt::CaseInsensitive); - if (pos > -1) + if (pos > -1) { pos += 9; while (pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"'))) @@ -389,7 +384,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) while (endPos < length && value.at(endPos) != QL1C('"') && value.at(endPos) != QL1C(';')) endPos++; - if (endPos > pos) + if (endPos > pos) { suggestedFileName = value.mid(pos, (endPos-pos)).trimmed(); } @@ -397,11 +392,11 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } } } - + kDebug() << "Detected MimeType = " << mimeType; kDebug() << "Suggested File Name = " << suggestedFileName; // ------------------------------------------------ - + KService::Ptr appService = KMimeTypeTrader::self()->preferredService(mimeType); bool isLocal = replyUrl.isLocalFile(); @@ -423,7 +418,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) KParts::BrowserOpenOrSaveQuestion dlg(Application::instance()->mainWindow(), replyUrl, mimeType); if(!suggestedFileName.isEmpty()) dlg.setSuggestedFileName(suggestedFileName); - + switch (dlg.askEmbedOrSave()) { case KParts::BrowserOpenOrSaveQuestion::Save: @@ -444,7 +439,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (partServices.count() > 0) { QString p = replyUrl.pathOrUrl(); - + // A part can handle this. Embed it! QString html; html += ""; @@ -461,7 +456,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) html += ""; html += ""; - mainFrame()->setHtml(html); + mainFrame()->setHtml(html); _isOnRekonqPage = true; Application::instance()->mainWindow()->mainView()->urlBar()->setQUrl(replyUrl); Application::instance()->mainWindow()->updateActions(); @@ -485,8 +480,8 @@ void WebPage::loadStarted() void WebPage::loadFinished(bool ok) { Q_UNUSED(ok); - - + + Application::adblockManager()->applyHidingRules(this); QStringList list = ReKonfig::walletBlackList(); @@ -534,7 +529,7 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) case QNetworkReply::OperationCanceledError: // operation canceled via abort() or close() calls // ignore this.. return; - + case QNetworkReply::ContentAccessDenied: // access to remote content denied (similar to HTTP error 401) kDebug() << "We (hopefully) are managing this through the adblock :)"; break; -- cgit v1.2.1