diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2013-02-26 18:42:19 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2013-02-26 18:42:19 +0100 |
commit | 5a5b8f01c699ec16a82f07b436433dc4e73e4f1b (patch) | |
tree | 80517ff8486a0115020152162b2d5db2051ebb9e /src/download | |
parent | Fix CTRL+F part shortcut (diff) | |
download | rekonq-5a5b8f01c699ec16a82f07b436433dc4e73e4f1b.tar.xz |
If KGet is selected as download manager, let it decide destination
WARNING:
to let this work, we had to change rekonq behavior, NOT
remembering in rekonq downloads history what has been downloaded
via KGet
BUG:304387
CCMAIL: ericsbinaryworld@gmail.com
Diffstat (limited to 'src/download')
-rw-r--r-- | src/download/downloadmanager.cpp | 58 | ||||
-rw-r--r-- | src/download/downloadmanager.h | 1 |
2 files changed, 17 insertions, 42 deletions
diff --git a/src/download/downloadmanager.cpp b/src/download/downloadmanager.cpp index ac03fb29..95b31543 100644 --- a/src/download/downloadmanager.cpp +++ b/src/download/downloadmanager.cpp @@ -156,28 +156,6 @@ DownloadItem* DownloadManager::addDownload(KIO::CopyJob *job) } -DownloadItem* DownloadManager::addKGetDownload(const QString &srcUrl, const QString &destUrl) -{ - QString downloadFilePath = KStandardDirs::locateLocal("appdata" , "downloads"); - QFile downloadFile(downloadFilePath); - if (!downloadFile.open(QFile::WriteOnly | QFile::Append)) - { - kDebug() << "Unable to open download file (WRITE mode).."; - return 0; - } - QDataStream out(&downloadFile); - out << srcUrl; - out << destUrl; - out << QDateTime::currentDateTime(); - downloadFile.close(); - DownloadItem *item = new DownloadItem(srcUrl, destUrl, QDateTime::currentDateTime(), this); - item->setIsKGetDownload(); - m_downloadList.append(item); - emit newDownloadAdded(item); - return item; -} - - bool DownloadManager::clearDownloadsHistory() { m_downloadList.clear(); @@ -218,6 +196,23 @@ void DownloadManager::removeDownloadItem(int index) bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &metaData, QWidget *parent, bool forceDirRequest, const QString &suggestedName, bool registerDownload) { + // manage downloads with KGet if found + if (ReKonfig::kgetDownload() && !KStandardDirs::findExe("kget").isNull()) + { + //KGet integration: + if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget")) + { + KToolInvocation::kdeinitExecWait("kget"); + } + QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main"); + if (!kget.isValid()) + return false; + + QDBusMessage transfer = kget.call(QL1S("addTransfer"), srcUrl.prettyUrl(), QString(), true); + + return true; + } + KUrl destUrl; const QString fileName((suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName)); @@ -237,25 +232,6 @@ bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData & if (!destUrl.isValid()) return false; - // manage downloads with KGet if found - if (ReKonfig::kgetDownload() && !KStandardDirs::findExe("kget").isNull()) - { - //KGet integration: - if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget")) - { - KToolInvocation::kdeinitExecWait("kget"); - } - QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main"); - if (!kget.isValid()) - return false; - - QDBusMessage transfer = kget.call(QL1S("addTransfer"), srcUrl.prettyUrl(), destUrl.prettyUrl(), true); - - if (registerDownload) - addKGetDownload(srcUrl.pathOrUrl(), destUrl.pathOrUrl()); - return true; - } - KIO::CopyJob *job = KIO::copy(srcUrl, destUrl); if (!metaData.isEmpty()) diff --git a/src/download/downloadmanager.h b/src/download/downloadmanager.h index c61e761c..1b0825d8 100644 --- a/src/download/downloadmanager.h +++ b/src/download/downloadmanager.h @@ -86,7 +86,6 @@ private: void init(); DownloadItem* addDownload(KIO::CopyJob *job); - DownloadItem* addKGetDownload(const QString &srcUrl, const QString &destUrl); Q_SIGNALS: void newDownloadAdded(QObject *item); |