Kgapi

createjob.h
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#pragma once
10
11#include "job.h"
12#include "kgapicore_export.h"
13
14namespace KGAPI2
15{
16
17/**
18 * @headerfile createjob.h
19 * @brief Abstract superclass for all jobs that create new objects on the
20 * server.
21 *
22 * @author Daniel Vrátil <dvratil@redhat.com>
23 * @since 2.0
24 */
25class KGAPICORE_EXPORT CreateJob : public KGAPI2::Job
26{
27 Q_OBJECT
28
29public:
30 /**
31 * @brief Constructor for jobs that don't require authentication
32 *
33 * @param parent
34 */
35 explicit CreateJob(QObject *parent = nullptr);
36
37 /**
38 * @brief Constructor for jobs that require authentication
39 *
40 * @param account Account to use to authenticate the requests sent by this job
41 * @param parent
42 */
43 explicit CreateJob(const KGAPI2::AccountPtr &account, QObject *parent = nullptr);
44
45 /**
46 * @brief Destructor
47 */
48 ~CreateJob() override;
49
50 /**
51 * @return Returns newly created items
52 */
53 virtual ObjectsList items() const;
54
55protected:
56 /**
57 * @brief KGAPI::Job::dispatchRequest()
58 *
59 * @param accessManager
60 * @param request
61 * @param data
62 * @param contentType
63 */
64 void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override;
65
66 /**
67 * @brief KGAPI2::Job::handleReply implementation
68 *
69 * \param reply
70 * \param rawData
71 */
72 void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override;
73
74 /**
75 * @brief KGAPI2::Job::aboutToStart() implementation
76 */
77 void aboutToStart() override;
78
79 /**
80 * @brief A reply handler that returns items parsed from \@ rawData
81 *
82 * This method can be reimplemented in FetchJob subclasses. It is called
83 * automatically when a reply is received and the returned items are stored
84 * in FetchJob and accessible via FetchJob::items when the job has finished.
85 *
86 * If you need more control over handling reply and items, you can reimplement
87 * FetchJob::handleReply. Note that reimplementing FetchJob::handleReply
88 * usually requires reimplementing FetchJob::items as well and storing the
89 * parsed items in your implementation.
90 *
91 * @param reply A QNetworkReply received from Google's server
92 * @param rawData Content of body of the @p reply. Don't use
93 * QNetworkReply::readAll(), because the content has already been read
94 * by Job implementation and thus it would return empty data.
95 *
96 * @return Items parsed from @p rawData
97 */
98 virtual ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData);
99
100private:
101 class Private;
102 Private *const d;
103 friend class Private;
104};
105
106} // namespace KGAPI2
Abstract superclass for all jobs that create new objects on the server.
Definition createjob.h:26
Abstract base class for all jobs in LibKGAPI.
Definition job.h:41
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:08:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.