Kgapi

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

KDE's Doxygen guidelines are available online.