Kgapi

commentdeletecontentjob.cpp
1/*
2 * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6
7#include "commentdeletecontentjob.h"
8#include "bloggerservice.h"
9#include "comment.h"
10#include "utils.h"
11
12#include <QNetworkReply>
13#include <QNetworkRequest>
14
15using namespace KGAPI2;
16using namespace KGAPI2::Blogger;
17
18class Q_DECL_HIDDEN CommentDeleteContentJob::Private
19{
20public:
21 Private(const QString &blogId, const QString &postId, const QString &commentId);
22
23 const QString blogId;
24 const QString postId;
25 const QString commentId;
26};
27
28CommentDeleteContentJob::Private::Private(const QString &blogId_, const QString &postId_, const QString &commentId_)
29 : blogId(blogId_)
30 , postId(postId_)
31 , commentId(commentId_)
32{
33}
34
35CommentDeleteContentJob::CommentDeleteContentJob(const QString &blogId,
36 const QString &postId,
37 const QString &commentId,
38 const AccountPtr &account,
39 QObject *parent)
40 : ModifyJob(account, parent)
41 , d(new Private(blogId, postId, commentId))
42{
43}
44
45CommentDeleteContentJob::CommentDeleteContentJob(const CommentPtr &comment, const AccountPtr &account, QObject *parent)
46 : ModifyJob(account, parent)
47 , d(new Private(comment->blogId(), comment->postId(), comment->id()))
48{
49}
50
51CommentDeleteContentJob::~CommentDeleteContentJob()
52{
53 delete d;
54}
55
56void CommentDeleteContentJob::start()
57{
58 QNetworkRequest request(BloggerService::deleteCommentContentUrl(d->blogId, d->postId, d->commentId));
59 enqueueRequest(request);
60}
61
62ObjectsList CommentDeleteContentJob::handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData)
63{
64 const QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString();
65 ContentType ct = Utils::stringToContentType(contentType);
67 if (ct != KGAPI2::JSON) {
69 setErrorString(tr("Invalid response content type"));
71 return items;
72 }
73
74 items << Comment::fromJSON(rawData);
76 return items;
77}
78
79#include "moc_commentdeletecontentjob.cpp"
void setErrorString(const QString &errorString)
Set job error description to errorString.
Definition job.cpp:401
virtual void emitFinished()
Emits Job::finished() signal.
Definition job.cpp:493
void setError(KGAPI2::Error error)
Set job error to error.
Definition job.cpp:386
virtual void enqueueRequest(const QNetworkRequest &request, const QByteArray &data=QByteArray(), const QString &contentType=QString())
Enqueues request in dispatcher queue.
Definition job.cpp:513
Abstract superclass for all jobs that somehow modify resources on Google.
Definition modifyjob.h:25
ObjectsList items() const
Definition modifyjob.cpp:43
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
@ InvalidResponse
LibKGAPI error - Google returned invalid response.
Definition types.h:183
ContentType
Definition types.h:210
QVariant header(QNetworkRequest::KnownHeaders header) const const
QString tr(const char *sourceText, const char *disambiguation, int n)
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:50:41 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.