diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-12-03 23:40:59 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:06 +0100 |
commit | ca4cb062c2f9f14687f2ed3fac0723ede60c617d (patch) | |
tree | 7b929979a7bc2857dde57f3adaf15e4d99889319 /src/webtab | |
parent | Fix default download path (diff) | |
download | rekonq-ca4cb062c2f9f14687f2ed3fac0723ede60c617d.tar.xz |
Get sure we are using suggested file name if available
Diffstat (limited to 'src/webtab')
-rw-r--r-- | src/webtab/webpage.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp index de87ad42..ca2a23b2 100644 --- a/src/webtab/webpage.cpp +++ b/src/webtab/webpage.cpp @@ -337,19 +337,20 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { Q_ASSERT(reply); - if (!reply) + if (reply->error() != QNetworkReply::NoError) return; + KIO::Integration::AccessManager::putReplyOnHold(reply); + // handle protocols WebKit cannot handle... if (_protHandler.postHandling(reply->request(), mainFrame())) { return; } - if (reply->error() != QNetworkReply::NoError) - return; - - KIO::Integration::AccessManager::putReplyOnHold(reply); + // 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")); // Get mimeType... extractMimeType(reply, _mimeType); @@ -358,10 +359,6 @@ 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; // ------------------------------------------------ @@ -373,10 +370,18 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (appService.isNull()) // no service can handle this. We can just download it.. { - isLocal - ? KMessageBox::sorry(view(), i18n("No service can handle this file.")) - : downloadUrl(reply->url()); + if (isLocal) + { + KMessageBox::sorry(view(), i18n("No service can handle this file.")); + return; + } + DownloadManager::self()->downloadResource( reply->url(), + KIO::MetaData(), + view(), + false, + _suggestedFileName, + !settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)); return; } @@ -386,10 +391,18 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) // "recall" loop. if (appService->exec().trimmed().startsWith(QL1S("rekonq"))) { - isLocal - ? KMessageBox::sorry(view(), i18n("rekonq cannot properly handle this, sorry")) - : downloadUrl(reply->url()); + if (isLocal) + { + KMessageBox::sorry(view(), i18n("rekonq cannot properly handle this, sorry")); + return; + } + DownloadManager::self()->downloadResource( reply->url(), + KIO::MetaData(), + view(), + false, + _suggestedFileName, + !settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)); return; } @@ -685,7 +698,7 @@ void WebPage::downloadRequest(const QNetworkRequest &request) request.attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap(), view(), false, - QString(), + _suggestedFileName, !settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)); } |