summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/downloadmanager.cpp40
-rw-r--r--src/downloadmanager.h3
-rw-r--r--src/webpage.cpp10
3 files changed, 5 insertions, 48 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 6241394a..2e7e4607 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -201,43 +201,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();
- }
- }
-}
-
diff --git a/src/downloadmanager.h b/src/downloadmanager.h
index 2eee1924..ce8de507 100644
--- a/src/downloadmanager.h
+++ b/src/downloadmanager.h
@@ -58,6 +58,7 @@ public:
{
return m_downloadList;
}
+
bool clearDownloadsHistory();
bool downloadResource(const KUrl &url, const KIO::MetaData &metaData = KIO::MetaData(),
@@ -65,8 +66,6 @@ public:
void downloadLinksWithKGet(const QVariant &contentList);
- static void extractSuggestedFileName(const QNetworkReply* reply, QString& fileName);
-
Q_SIGNALS:
void newDownloadAdded(QObject *item);
void notifyDownload(const QString&, Rekonq::Notify = Rekonq::Download);
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 15d6cabf..2fdf4d01 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;
// ------------------------------------------------
@@ -316,8 +320,6 @@ 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);
@@ -418,10 +420,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());