diff options
-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); |