diff options
author | Yoann Laissus <yoann.laissus@gmail.com> | 2012-02-09 18:40:21 +0100 |
---|---|---|
committer | Yoann Laissus <yoann.laissus@gmail.com> | 2012-02-09 18:40:21 +0100 |
commit | f5c45173623e39fb5ad67ae870c4bdfe5fe8520c (patch) | |
tree | 79e1703c95cf40c3d426f1ff1980bc50d6778028 /src/webpage.cpp | |
parent | Fix right icon duplication in the UrlBar on some website (diff) | |
parent | Clean up sessionmanager mess :) (diff) | |
download | rekonq-f5c45173623e39fb5ad67ae870c4bdfe5fe8520c.tar.xz |
Merge branch 'master' of git://anongit.kde.org/rekonq
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r-- | src/webpage.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp index 89c52e8a..6a6f1bc9 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -289,6 +289,10 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (KParts::BrowserRun::isTextExecutable(_mimeType)) _mimeType = QL1S("text/plain"); + // Get suggested file name... + const KIO::MetaData& data = reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap(); + _suggestedFileName = data.value(QL1S("content-disposition-filename")); + kDebug() << "Detected MimeType = " << _mimeType; kDebug() << "Suggested File Name = " << _suggestedFileName; // ------------------------------------------------ @@ -302,7 +306,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { isLocal ? KMessageBox::sorry(view(), i18n("No service can handle this file.")) - : downloadReply(reply, _suggestedFileName); + : downloadUrl(reply->url()); return; } @@ -316,15 +320,20 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { KParts::BrowserOpenOrSaveQuestion dlg(rApp->mainWindow(), replyUrl, _mimeType); - // Get suggested file name... - DownloadManager::extractSuggestedFileName(reply, _suggestedFileName); if (!_suggestedFileName.isEmpty()) dlg.setSuggestedFileName(_suggestedFileName); + // read askEmbedOrSave preferences. If we don't have to show dialog and rekonq settings are + // to automatically choose download dir, we won't show local dir choose dialog + KConfigGroup cg = KConfigGroup(KSharedConfig::openConfig("filetypesrc", KConfig::NoGlobals), QL1S("Notification Messages")); + bool hideDialog = cg.readEntry(QL1S("askEmbedOrSave") + _mimeType, false); + + kDebug() << "Hide dialog for " << _mimeType << "? " << hideDialog; + switch (dlg.askEmbedOrSave()) { case KParts::BrowserOpenOrSaveQuestion::Save: - downloadReply(reply, _suggestedFileName); + rApp->downloadManager()->downloadResource(reply->url(), KIO::MetaData(), view(), !hideDialog, _suggestedFileName); return; case KParts::BrowserOpenOrSaveQuestion::Cancel: @@ -418,10 +427,6 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) { Q_ASSERT(reply); - // check suggested file name - if (_suggestedFileName.isEmpty()) - DownloadManager::extractSuggestedFileName(reply, _suggestedFileName); - QWebFrame* frame = qobject_cast<QWebFrame *>(reply->request().originatingObject()); const bool isMainFrameRequest = (frame == mainFrame()); const bool isLoadingUrlReply = (mainFrame()->url() == reply->url()); @@ -454,14 +459,11 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) // ignore this.. return; - case QNetworkReply::ContentAccessDenied: // access to remote content denied (similar to HTTP error 401) + // WARNING: This is also typical adblocked element error: IGNORE THIS! + case QNetworkReply::ContentAccessDenied: // access to remote content denied break; case QNetworkReply::UnknownNetworkError: // unknown network-related error detected - // FIXME: DO WE REALLY NEED THIS??? - _protHandler.postHandling(reply->request(), frame); - return; - case QNetworkReply::ConnectionRefusedError: // remote server refused connection case QNetworkReply::HostNotFoundError: // invalid hostname case QNetworkReply::TimeoutError: // connection time out @@ -470,7 +472,7 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) case QNetworkReply::ContentNotFoundError: // remote content not found on server (similar to HTTP error 404) case QNetworkReply::ProtocolUnknownError: // Unknown protocol case QNetworkReply::ProtocolInvalidOperationError: // requested operation is invalid for this protocol - + default: kDebug() << "ERROR " << reply->error() << ": " << reply->errorString(); if (reply->url() == _loadingUrl) { @@ -489,10 +491,6 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply) } break; - default: - // Nothing to do here.. - break; - } } @@ -553,12 +551,6 @@ QString WebPage::errorPage(QNetworkReply *reply) } -void WebPage::downloadReply(const QNetworkReply *reply, const QString &suggestedFileName) -{ - rApp->downloadManager()->downloadResource(reply->url(), KIO::MetaData(), view(), suggestedFileName); -} - - void WebPage::downloadRequest(const QNetworkRequest &request) { rApp->downloadManager()->downloadResource(request.url(), |