Purpose

reviewboardjobs.h
1/*
2 SPDX-FileCopyrightText: 2010 Aleix Pol Gonzalez <aleixpol@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KDEVPLATFORM_PLUGIN_REVIEWBOARDJOBS_H
8#define KDEVPLATFORM_PLUGIN_REVIEWBOARDJOBS_H
9
10#include <QList>
11#include <QNetworkAccessManager>
12#include <QPair>
13#include <QUrl>
14
15#include <KJob>
16
17class QNetworkReply;
18
19namespace ReviewBoard
20{
21/**
22 * Http call to the specified service.
23 * Converts returned json data to a QVariant to be used from actual API calls
24 *
25 * @note It is reviewboard-agnostic.
26 */
27class HttpCall : public KJob
28{
30 Q_PROPERTY(QVariant result READ result)
31public:
32 enum Method {
33 Get,
34 Put,
35 Post,
36 };
37
38 HttpCall(const QUrl &s,
39 const QString &apiPath,
40 const QList<QPair<QString, QString>> &queryParameters,
41 Method m,
42 const QByteArray &post,
43 bool multipart,
45
46 void start() override;
47
48 QVariant result() const;
49
50private Q_SLOTS:
51 void onFinished();
52
53private:
54 // TODO: change to QJsonObject
55 QVariant m_result;
56 QNetworkReply *m_reply;
57 QUrl m_requrl;
58 QByteArray m_post;
59
60 QNetworkAccessManager m_manager;
61 bool m_multipart;
62 Method m_method;
63};
64
65class ReviewRequest : public KJob
66{
68public:
69 ReviewRequest(const QUrl &server, const QString &id, QObject *parent)
70 : KJob(parent)
71 , m_server(server)
72 , m_id(id)
73 {
74 }
75 QString requestId() const
76 {
77 return m_id;
78 }
79 void setRequestId(QString id)
80 {
81 m_id = id;
82 }
83 QUrl server() const
84 {
85 return m_server;
86 }
87
88private:
89 QUrl m_server;
90 QString m_id;
91};
92
93class NewRequest : public ReviewRequest
94{
96public:
97 NewRequest(const QUrl &server, const QString &project, QObject *parent = nullptr);
98 void start() override;
99
100private Q_SLOTS:
101 void done();
102
103private:
104 HttpCall *m_newreq;
105 QString m_project;
106};
107
108class UpdateRequest : public ReviewRequest
109{
111public:
112 UpdateRequest(const QUrl &server, const QString &id, const QVariantMap &newValues, QObject *parent = nullptr);
113 void start() override;
114
115private Q_SLOTS:
116 void done();
117
118private:
119 HttpCall *m_req;
120 QString m_project;
121};
122
123class SubmitPatchRequest : public ReviewRequest
124{
126public:
127 SubmitPatchRequest(const QUrl &server, const QUrl &patch, const QString &basedir, const QString &id, QObject *parent = nullptr);
128 void start() override;
129
130private Q_SLOTS:
131 void done();
132
133private:
134 HttpCall *m_uploadpatch;
135 QUrl m_patch;
136 QString m_basedir;
137};
138
139class ProjectsListRequest : public KJob
140{
142public:
143 ProjectsListRequest(const QUrl &server, QObject *parent = nullptr);
144 void start() override;
145 QVariantList repositories() const;
146
147private Q_SLOTS:
148 void requestRepositoryList(int startIndex);
149 void done(KJob *done);
150
151private:
152 QUrl m_server;
153 QVariantList m_repositories;
154};
155
156class ReviewListRequest : public KJob
157{
159public:
160 ReviewListRequest(const QUrl &server, const QString &user, const QString &reviewStatus, QObject *parent = nullptr);
161 void start() override;
162 QVariantList reviews() const;
163
164private Q_SLOTS:
165 void requestReviewList(int startIndex);
166 void done(KJob *done);
167
168private:
169 QUrl m_server;
170 QString m_user;
171 QString m_reviewStatus;
172 QVariantList m_reviews;
173};
174
175QByteArray urlToData(const QUrl &);
176}
177
178#endif
Http call to the specified service.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.