Kgapi

deletejob.cpp
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#include "deletejob.h"
10
11#include <QNetworkAccessManager>
12#include <QNetworkRequest>
13#include <QUrlQuery>
14
15using namespace KGAPI2;
16
17class Q_DECL_HIDDEN DeleteJob::Private
18{
19};
20
22 : Job(parent)
23 , d(new Private)
24{
25}
26
27DeleteJob::DeleteJob(const AccountPtr &account, QObject *parent)
28 : Job(account, parent)
29 , d(new Private)
30{
31}
32
34{
35 delete d;
36}
37
38void DeleteJob::dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType)
39{
40 Q_UNUSED(data)
41 Q_UNUSED(contentType)
42
43 QNetworkRequest r = request;
44 if (!r.hasRawHeader("If-Match")) {
45 r.setRawHeader("If-Match", "*");
46 }
47
48 // Delete requests have no response body so there isn't anything to pretty print
49 QUrl cleanedUrl = r.url();
50 QUrlQuery cleanedQuery(cleanedUrl);
51 cleanedQuery.removeAllQueryItems(Job::StandardParams::PrettyPrint);
52 cleanedUrl.setQuery(cleanedQuery);
53 r.setUrl(cleanedUrl);
54
55 accessManager->deleteResource(r);
56}
57
58void DeleteJob::handleReply(const QNetworkReply *reply, const QByteArray &rawData)
59{
60 Q_UNUSED(reply)
61 Q_UNUSED(rawData)
62
63 start();
64}
65
66#include "moc_deletejob.cpp"
Abstract superclass for all jobs that delete resources from Google.
Definition deletejob.h:25
void dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override
KGAPI::Job::dispatchRequest implementation.
Definition deletejob.cpp:38
~DeleteJob() override
Destructor.
Definition deletejob.cpp:33
DeleteJob(QObject *parent=nullptr)
Constructor for jobs that don't require authentication.
Definition deletejob.cpp:21
void handleReply(const QNetworkReply *reply, const QByteArray &rawData) override
KGAPI2::Job::handleReply implementation.
Definition deletejob.cpp:58
Abstract base class for all jobs in LibKGAPI.
Definition job.h:41
virtual void start()=0
This method is invoked when job is started.
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
QNetworkReply * deleteResource(const QNetworkRequest &request)
bool hasRawHeader(const QByteArray &headerName) const const
void setRawHeader(const QByteArray &headerName, const QByteArray &headerValue)
void setUrl(const QUrl &url)
QUrl url() const const
void setQuery(const QString &query, ParsingMode mode)
void removeAllQueryItems(const QString &key)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:11 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.