Kgapi

createjob.cpp
1 /*
2  * This file is part of LibKGAPI library
3  *
4  * SPDX-FileCopyrightText: 2013 Daniel Vrátil <[email protected]>
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 
15 using namespace KGAPI2;
16 
17 class Q_DECL_HIDDEN CreateJob::Private
18 {
19  public:
20  ObjectsList items;
21 };
22 
24  Job(parent),
25  d(new Private)
26 {
27 }
28 
30  Job(account, parent),
31  d(new Private)
32 {
33 }
34 
36 {
37  delete d;
38 }
39 
41 {
42  return d->items;
43 }
44 
46  const QNetworkRequest& request,
47  const QByteArray& data,
48  const QString& contentType)
49 {
50  QNetworkRequest r = request;
51  if (!r.hasRawHeader("Content-Type")) {
53  }
54 
55  accessManager->post(r, data);
56 }
57 
58 void CreateJob::handleReply(const QNetworkReply *reply, const QByteArray &rawData)
59 {
60  d->items << handleReplyWithItems(reply, rawData);
61 }
62 
64 {
65  d->items.clear();
66 
68 }
69 
71  const QByteArray& rawData)
72 {
73  Q_UNUSED(reply)
74  Q_UNUSED(rawData)
75 
76  return ObjectsList();
77 }
void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override
KGAPI::Job::dispatchRequest()
Definition: createjob.cpp:45
AccountPtr account() const
Returns account used to authenticate requests.
Definition: job.cpp:425
virtual ObjectsList items() const
Definition: createjob.cpp:40
bool hasRawHeader(const QByteArray &headerName) const const
Abstract superclass for all jobs that create new objects on the server.
Definition: createjob.h:25
virtual ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData)
A reply handler that returns items parsed from @ rawData.
Definition: createjob.cpp:70
Abstract base class for all jobs in LibKGAPI.
Definition: job.h:40
QNetworkReply * post(const QNetworkRequest &request, QIODevice *data)
~CreateJob() override
Destructor.
Definition: createjob.cpp:35
A job to fetch a single map tile described by a StaticMapUrl.
Definition: blog.h:16
CreateJob(QObject *parent=nullptr)
Constructor for jobs that don&#39;t require authentication.
Definition: createjob.cpp:23
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
void aboutToStart() override
KGAPI2::Job::aboutToStart() implementation.
Definition: createjob.cpp:63
QObject * parent() const const
virtual void aboutToStart()
This method is invoked right before Job::start() is called.
Definition: job.cpp:523
void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override
KGAPI2::Job::handleReply implementation.
Definition: createjob.cpp:58
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:10:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.