KDAV

davcollectiondeletejob.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Grégory Oestreicher <greg@kamago.net>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "davcollectiondeletejob.h"
8#include "davjobbase_p.h"
9
10#include "daverror.h"
11
12#include <KIO/DeleteJob>
13#include <KIO/Job>
14
15using namespace KDAV;
16
17namespace KDAV
18{
19class DavCollectionDeleteJobPrivate : public DavJobBasePrivate
20{
21public:
22 void davJobFinished(KJob *job);
23
24 DavUrl mUrl;
25};
26}
27
29 : DavJobBase(new DavCollectionDeleteJobPrivate, parent)
30{
32 d->mUrl = url;
33}
34
36{
39 job->addMetaData(QStringLiteral("PropagateHttpHeader"), QStringLiteral("true"));
40 job->addMetaData(QStringLiteral("cookies"), QStringLiteral("none"));
41 job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
42
43 connect(job, &KIO::DeleteJob::result, this, [d](KJob *job) {
44 d->davJobFinished(job);
45 });
46}
47
48void DavCollectionDeleteJobPrivate::davJobFinished(KJob *job)
49{
50 KIO::DeleteJob *deleteJob = qobject_cast<KIO::DeleteJob *>(job);
51
52 if (deleteJob->error() && deleteJob->error() != KIO::ERR_NO_CONTENT) {
53 const int responseCode = deleteJob->queryMetaData(QStringLiteral("responsecode")).isEmpty() //
54 ? 0
55 : deleteJob->queryMetaData(QStringLiteral("responsecode")).toInt();
56
57 setLatestResponseCode(responseCode);
58 setError(ERR_COLLECTIONDELETE);
59 setJobErrorText(deleteJob->errorText());
60 setJobError(deleteJob->error());
61 setErrorTextFromDavError();
62 }
63
64 emitResult();
65}
66
67#include "moc_davcollectiondeletejob.cpp"
A job that deletes a DAV collection.
DavCollectionDeleteJob(const DavUrl &url, QObject *parent=nullptr)
Creates a new DAV collection delete job.
void start() override
Starts the job.
base class for the jobs used by the resource.
Definition davjobbase.h:27
A helper class to combine URL and protocol of a DAV URL.
Definition davurl.h:27
void addMetaData(const QMap< QString, QString > &values)
QString queryMetaData(const QString &key)
int error() const
void result(KJob *job)
QString errorText() const
The KDAV namespace.
KIOCORE_EXPORT DeleteJob * del(const QList< QUrl > &src, JobFlags flags=DefaultFlags)
DefaultFlags
HideProgressInfo
ERR_NO_CONTENT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const
int toInt(bool *ok, int base) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.