KNewStuff

downloadjob.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6 
7 #include "downloadjob.h"
8 
9 #include "httpworker.h"
10 
11 #include "knewstuffcore_debug.h"
12 
13 using namespace KNSCore;
14 
15 class DownloadJob::Private
16 {
17 public:
18  Private() {}
19  QUrl source;
20  QUrl destination;
21 };
22 
23 DownloadJob::DownloadJob(const QUrl& source, const QUrl& destination, int permissions, JobFlags flags, QObject* parent)
24  : FileCopyJob(source, destination, permissions, flags, parent)
25  , d(new Private)
26 {
27  d->source = source;
28  d->destination = destination;
29 }
30 
31 DownloadJob::DownloadJob(QObject* parent)
32  : FileCopyJob(parent)
33  , d(new Private)
34 {
35 }
36 
37 DownloadJob::~DownloadJob()
38 {
39  delete d;
40 }
41 
42 void DownloadJob::start()
43 {
44  qCDebug(KNEWSTUFFCORE) << Q_FUNC_INFO;
45  HTTPWorker* worker = new HTTPWorker(d->source, d->destination, HTTPWorker::DownloadJob, this);
46  connect(worker, &HTTPWorker::completed, this, &DownloadJob::handleWorkerCompleted);
47  connect(worker, &HTTPWorker::error, this, &DownloadJob::handleWorkerError);
48  worker->startRequest();
49 }
50 
51 void DownloadJob::handleWorkerCompleted()
52 {
53  emitResult();
54 }
55 
56 void KNSCore::DownloadJob::handleWorkerError(const QString& error)
57 {
58  setError(KJob::UserDefinedError);
59  setErrorText(error);
60 }
Contains the core functionality for handling interaction with NewStuff providers. ...
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.