Libkdav2

davcollectiondeletejob.cpp
1 /*
2  Copyright (c) 2010 GrĂ©gory Oestreicher <[email protected]>
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 
25 using 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 
38 void 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 
QUrl url() const
Returns the url that identifies the DAV object.
Definition: davurl.cpp:41
void emitResult()
static DavManager * self()
Returns the global instance of the DAV manager.
Definition: davmanager.cpp:52
base class for the jobs used by the resource.
Definition: davjobbase.h:37
DavJob * createDeleteJob(const QUrl &url)
Returns a preconfigured DAV DELETE job.
Definition: davmanager.cpp:80
A helper class to combine url and protocol of a DAV url.
Definition: davurl.h:35
void start() override
Starts the job.
DavCollectionDeleteJob(const DavUrl &url, QObject *parent=nullptr)
Creates a new DAV collection delete job.
void setErrorFromJob(DavJob *, ErrorNumber jobErrorCode=ERR_PROBLEM_WITH_REQUEST)
Set the error of this job from a failed DavJob (executed by this job).
Definition: davjobbase.cpp:99
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jan 27 2022 23:10:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.