Kgapi

createjob.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 "createjob.h"
10#include "object.h"
11
12#include <QNetworkAccessManager>
13#include <QNetworkRequest>
14
15using namespace KGAPI2;
16
17class Q_DECL_HIDDEN CreateJob::Private
18{
19public:
20 ObjectsList items;
21};
22
24 : Job(parent)
25 , d(new Private)
26{
27}
28
29CreateJob::CreateJob(const AccountPtr &account, QObject *parent)
30 : Job(account, parent)
31 , d(new Private)
32{
33}
34
36{
37 delete d;
38}
39
41{
42 return d->items;
43}
44
45void CreateJob::dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType)
46{
47 QNetworkRequest r = request;
48 if (!r.hasRawHeader("Content-Type")) {
50 }
51
52 accessManager->post(r, data);
53}
54
55void CreateJob::handleReply(const QNetworkReply *reply, const QByteArray &rawData)
56{
57 d->items << handleReplyWithItems(reply, rawData);
58}
59
61{
62 d->items.clear();
63
65}
66
68{
69 Q_UNUSED(reply)
70 Q_UNUSED(rawData)
71
72 return ObjectsList();
73}
74
75#include "moc_createjob.cpp"
Abstract superclass for all jobs that create new objects on the server.
Definition createjob.h:26
virtual ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData)
A reply handler that returns items parsed from @ rawData.
Definition createjob.cpp:67
CreateJob(QObject *parent=nullptr)
Constructor for jobs that don't require authentication.
Definition createjob.cpp:23
void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override
KGAPI2::Job::handleReply implementation.
Definition createjob.cpp:55
void aboutToStart() override
KGAPI2::Job::aboutToStart() implementation.
Definition createjob.cpp:60
virtual ObjectsList items() const
Definition createjob.cpp:40
void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override
KGAPI::Job::dispatchRequest()
Definition createjob.cpp:45
~CreateJob() override
Destructor.
Definition createjob.cpp:35
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
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
void clear()
QNetworkReply * post(const QNetworkRequest &request, QHttpMultiPart *multiPart)
bool hasRawHeader(const QByteArray &headerName) const const
void setHeader(KnownHeaders header, const QVariant &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:54:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.