Kgapi

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

KDE's Doxygen guidelines are available online.