KNewStuff

httpworker.h
1/*
2 SPDX-FileCopyrightText: 2016 Dan Leinir Turthra Jensen <admin@leinir.dk>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef HTTPWORKER_H
8#define HTTPWORKER_H
9
10#include <QNetworkReply>
11#include <QUrl>
12
13class QNetworkReply;
14namespace KNSCore
15{
16class HTTPWorkerPrivate;
17class HTTPWorker : public QObject
18{
20public:
21 enum JobType {
22 GetJob,
23 DownloadJob, // Much the same as a get... except with a filesystem destination, rather than outputting data
24 };
25 explicit HTTPWorker(const QUrl &url, JobType jobType = GetJob, QObject *parent = nullptr);
26 explicit HTTPWorker(const QUrl &source, const QUrl &destination, JobType jobType = DownloadJob, QObject *parent = nullptr);
27 ~HTTPWorker() override;
28
29 void startRequest();
30
31 void setUrl(const QUrl &url);
32
33 Q_SIGNAL void error(QString error);
34 Q_SIGNAL void progress(qlonglong current, qlonglong total);
35 Q_SIGNAL void completed();
36 Q_SIGNAL void data(const QByteArray &data);
37
38 /**
39 * Fired in case there is a http error reported
40 * In some instances this is useful information for our users, and we want to make sure we report this centrally
41 * @param status The HTTP status code (fired in cases where it is perceived by QNetworkReply as an error)
42 * @param rawHeaders The raw HTTP headers for the errored-out network request
43 */
44 Q_SIGNAL void httpError(int status, QList<QNetworkReply::RawHeaderPair> rawHeaders);
45
46 Q_SLOT void handleReadyRead();
47 Q_SLOT void handleFinished();
48 Q_SLOT void handleData(const QByteArray &data);
49
50private:
51 const std::unique_ptr<HTTPWorkerPrivate> d;
52};
53
54}
55
56#endif // HTTPWORKER_H
Q_SCRIPTABLE CaptureState status()
Q_OBJECTQ_OBJECT
Q_SIGNALQ_SIGNAL
Q_SLOTQ_SLOT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:20:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.