summaryrefslogtreecommitdiff
path: root/src/webpage.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-06-03 18:20:35 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-06-03 18:20:35 +0200
commit34c581e7e382084e9273b6c3b8762b36d527d4aa (patch)
treeaf494bb421e86f7d0a1ec4c7c8248af340c2c58b /src/webpage.cpp
parentCode janitoring (diff)
parentLast (diff)
downloadrekonq-34c581e7e382084e9273b6c3b8762b36d527d4aa.tar.xz
Merge branch 'DownloadManager'
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r--src/webpage.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 3e2798d3..29ee4a40 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -40,6 +40,7 @@
// Local Includes
#include "adblockmanager.h"
#include "application.h"
+#include "downloadmanager.h"
#include "iconmanager.h"
#include "mainview.h"
#include "mainwindow.h"
@@ -209,7 +210,7 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
while (result == KIO::R_CANCEL && destUrl.isValid());
// Save download history
- rApp->addDownload(srcUrl.pathOrUrl() , destUrl.pathOrUrl());
+ DownloadItem *item = rApp->downloadManager()->addDownload(srcUrl.pathOrUrl(), destUrl.pathOrUrl());
if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetDownload())
{
@@ -219,16 +220,25 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
KToolInvocation::kdeinitExecWait("kget");
}
QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main");
- if (kget.isValid())
- {
- kget.call("addTransfer", srcUrl.prettyUrl(), destUrl.prettyUrl(), true);
+ if (!kget.isValid())
+ return false;
+
+ QDBusMessage transfer = kget.call(QL1S("addTransfer"), srcUrl.prettyUrl(), destUrl.prettyUrl(), true);
+ if (transfer.arguments().isEmpty())
return true;
- }
- return false;
+
+ const QString transferPath = transfer.arguments().first().toString();
+ item->setKGetTransferDbusPath(transferPath);
+ return true;
}
KIO::Job *job = KIO::file_copy(srcUrl, destUrl, -1, KIO::Overwrite);
-
+ if (item)
+ {
+ QObject::connect(job, SIGNAL(percent(KJob *,unsigned long)), item, SLOT(updateProgress(KJob *,unsigned long)));
+ QObject::connect(job, SIGNAL(finished(KJob *)), item, SLOT(onFinished(KJob*)));
+ }
+
if (!metaData.isEmpty())
job->setMetaData(metaData);
@@ -236,7 +246,6 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available.
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
return true;
-
}