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/downloadmanager.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/downloadmanager.cpp')
-rw-r--r-- | src/downloadmanager.cpp | 45 |
1 files changed, 3 insertions, 42 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 6241394a..dd3cb119 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -141,13 +141,14 @@ void DownloadManager::downloadLinksWithKGet(const QVariant &contentList) // In this way, we can easily provide the extra functionality we need: // 1. KGet Integration // 2. Save downloads history -bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &metaData, QWidget *parent, const QString &suggestedName) +bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &metaData, + QWidget *parent, bool forceDirRequest, const QString &suggestedName) { KUrl destUrl; const QString fileName((suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName)); - if (ReKonfig::askDownloadPath()) + if (forceDirRequest || ReKonfig::askDownloadPath()) { // follow bug:184202 fixes destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent); @@ -201,43 +202,3 @@ bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData & job->uiDelegate()->setAutoErrorHandlingEnabled(true); return true; } - - -// ------------------------------------------------------------------------------------------------------------------- - - -// STATIC -void DownloadManager::extractSuggestedFileName(const QNetworkReply* reply, QString& fileName) -{ - fileName.clear(); - const KIO::MetaData& metaData = reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap(); - if (metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0) - fileName = metaData.value(QL1S("content-disposition-filename")); - - if (!fileName.isEmpty()) - return; - - if (!reply->hasRawHeader("Content-Disposition")) - return; - - const QString value(QL1S(reply->rawHeader("Content-Disposition").simplified().constData())); - if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive)) - { - const int length = value.size(); - int pos = value.indexOf(QL1S("filename"), 0, Qt::CaseInsensitive); - if (pos > -1) - { - pos += 9; - while (pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"'))) - pos++; - - int endPos = pos; - while (endPos < length && value.at(endPos) != QL1C('"') && value.at(endPos) != QL1C(';')) - endPos++; - - if (endPos > pos) - fileName = value.mid(pos, (endPos - pos)).trimmed(); - } - } -} - |