10#include "knewstuffcore_debug.h"
14using namespace KNSCore;
16class KNSCore::HttpJobPrivate
20 LoadType loadType =
Reload;
24HTTPJob::HTTPJob(
const QUrl &source, LoadType loadType, JobFlags flags,
QObject *parent)
26 , d(new HttpJobPrivate)
29 d->loadType = loadType;
33HTTPJob::HTTPJob(
QObject *parent)
35 , d(new HttpJobPrivate)
39HTTPJob::~HTTPJob() =
default;
43 HTTPWorker *worker =
new HTTPWorker(d->source, HTTPWorker::GetJob,
this);
44 connect(worker, &HTTPWorker::data,
this, &HTTPJob::handleWorkerData);
45 connect(worker, &HTTPWorker::completed,
this, &HTTPJob::handleWorkerCompleted);
46 connect(worker, &HTTPWorker::error,
this, &HTTPJob::handleWorkerError);
47 connect(worker, &HTTPWorker::httpError,
this, &HTTPJob::httpError);
48 worker->startRequest();
51void HTTPJob::handleWorkerData(
const QByteArray &data)
53 Q_EMIT HTTPJob::data(
this, data);
56void HTTPJob::handleWorkerCompleted()
61void KNSCore::HTTPJob::handleWorkerError(
const QString &error)
63 setError(KJob::UserDefinedError);
67HTTPJob *HTTPJob::get(
const QUrl &source, LoadType loadType, JobFlags flags,
QObject *parent)
69 HTTPJob *job =
new HTTPJob(source, loadType, flags,
parent);
74#include "moc_httpjob.cpp"
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const