Kgapi

fetchjob.cpp
1/*
2 * This file is part of LibKGAPI library
3 *
4 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "fetchjob.h"
10#include "debug.h"
11#include "object.h"
12
13#include <QNetworkAccessManager>
14#include <QNetworkRequest>
15
16using namespace KGAPI2;
17
18class Q_DECL_HIDDEN FetchJob::Private
19{
20public:
21 ObjectsList items;
22};
23
25 : Job(parent)
26 , d(new Private)
27{
28}
29
30FetchJob::FetchJob(const AccountPtr &account, QObject *parent)
31 : Job(account, parent)
32 , d(new Private)
33{
34}
35
37{
38 delete d;
39}
40
42{
43 if (isRunning()) {
44 qCWarning(KGAPIDebug) << "Called items() on a running job, returning empty list.";
45 return ObjectsList();
46 }
47
48 return d->items;
49}
50
51void FetchJob::dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType)
52{
53 Q_UNUSED(data)
54 Q_UNUSED(contentType)
55
56 accessManager->get(request);
57}
58
59void FetchJob::handleReply(const QNetworkReply *reply, const QByteArray &rawData)
60{
61 d->items << handleReplyWithItems(reply, rawData);
62}
63
65{
66 d->items.clear();
67
69}
70
72{
73 Q_UNUSED(reply)
74 Q_UNUSED(rawData)
75
76 return ObjectsList();
77}
78
79#include "moc_fetchjob.cpp"
Abstract superclass for all jobs that fetch resources from Google.
Definition fetchjob.h:25
FetchJob(QObject *parent=nullptr)
Constructor for jobs that don't require authentication.
Definition fetchjob.cpp:24
~FetchJob() override
Destructor.
Definition fetchjob.cpp:36
void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override
KGAPI::Job::handleReply implementation.
Definition fetchjob.cpp:59
void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override
KGAPI::Job::dispatchRequest implementation.
Definition fetchjob.cpp:51
void aboutToStart() override
KGAPI::Job::aboutToStart implementation.
Definition fetchjob.cpp:64
virtual ObjectsList items() const
Returns all items fetched by this job.
Definition fetchjob.cpp:41
virtual ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData)
A reply handler that returns items parsed from @ rawData.
Definition fetchjob.cpp:71
Abstract base class for all jobs in LibKGAPI.
Definition job.h:41
virtual void aboutToStart()
This method is invoked right before Job::start() is called.
Definition job.cpp:539
bool isRunning
Whether the job is running.
Definition job.h:67
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
void clear()
QNetworkReply * get(const QNetworkRequest &request)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:55:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.