Libkdav2

davcollectiondeletejob.cpp
1/*
2 Copyright (c) 2010 Grégory Oestreicher <greg@kamago.net>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/
18
19#include "davcollectiondeletejob.h"
20
21#include "daverror.h"
22#include "davjob.h"
23#include "davmanager.h"
24
25using namespace KDAV2;
26
28 : DavJobBase(parent), mUrl(url)
29{
30}
31
33{
34 DavJob *job = DavManager::self()->createDeleteJob(mUrl.url());
35 connect(job, &DavJob::result, this, &DavCollectionDeleteJob::davJobFinished);
36}
37
38void DavCollectionDeleteJob::davJobFinished(KJob *job)
39{
40 auto *deleteJob = qobject_cast<DavJob*>(job);
41
42 //TODO Ignore deleteJob->error() != KIO::ERR_NO_CONTENT
43 if (deleteJob->error()) {
44 setErrorFromJob(deleteJob, ERR_COLLECTIONDELETE);
45 }
46
47 emitResult();
48}
49
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:38
void setErrorFromJob(DavJob *, ErrorNumber jobErrorCode=ERR_PROBLEM_WITH_REQUEST)
Set the error of this job from a failed DavJob (executed by this job).
static DavManager * self()
Returns the global instance of the DAV manager.
DavJob * createDeleteJob(const QUrl &url)
Returns a preconfigured DAV DELETE job.
A helper class to combine url and protocol of a DAV url.
Definition davurl.h:36
QUrl url() const
Returns the url that identifies the DAV object.
Definition davurl.cpp:41
void emitResult()
void result(KJob *job)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:05 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.