File indexing completed on 2024-05-12 05:22:11
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "commentdeletecontentjob.h" 0008 #include "bloggerservice.h" 0009 #include "comment.h" 0010 #include "utils.h" 0011 0012 #include <QNetworkReply> 0013 #include <QNetworkRequest> 0014 0015 using namespace KGAPI2; 0016 using namespace KGAPI2::Blogger; 0017 0018 class Q_DECL_HIDDEN CommentDeleteContentJob::Private 0019 { 0020 public: 0021 Private(const QString &blogId, const QString &postId, const QString &commentId); 0022 0023 const QString blogId; 0024 const QString postId; 0025 const QString commentId; 0026 }; 0027 0028 CommentDeleteContentJob::Private::Private(const QString &blogId_, const QString &postId_, const QString &commentId_) 0029 : blogId(blogId_) 0030 , postId(postId_) 0031 , commentId(commentId_) 0032 { 0033 } 0034 0035 CommentDeleteContentJob::CommentDeleteContentJob(const QString &blogId, 0036 const QString &postId, 0037 const QString &commentId, 0038 const AccountPtr &account, 0039 QObject *parent) 0040 : ModifyJob(account, parent) 0041 , d(new Private(blogId, postId, commentId)) 0042 { 0043 } 0044 0045 CommentDeleteContentJob::CommentDeleteContentJob(const CommentPtr &comment, const AccountPtr &account, QObject *parent) 0046 : ModifyJob(account, parent) 0047 , d(new Private(comment->blogId(), comment->postId(), comment->id())) 0048 { 0049 } 0050 0051 CommentDeleteContentJob::~CommentDeleteContentJob() 0052 { 0053 delete d; 0054 } 0055 0056 void CommentDeleteContentJob::start() 0057 { 0058 QNetworkRequest request(BloggerService::deleteCommentContentUrl(d->blogId, d->postId, d->commentId)); 0059 enqueueRequest(request); 0060 } 0061 0062 ObjectsList CommentDeleteContentJob::handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) 0063 { 0064 const QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); 0065 ContentType ct = Utils::stringToContentType(contentType); 0066 ObjectsList items; 0067 if (ct != KGAPI2::JSON) { 0068 setError(KGAPI2::InvalidResponse); 0069 setErrorString(tr("Invalid response content type")); 0070 emitFinished(); 0071 return items; 0072 } 0073 0074 items << Comment::fromJSON(rawData); 0075 emitFinished(); 0076 return items; 0077 } 0078 0079 #include "moc_commentdeletecontentjob.cpp"