KDAV

davcollectionsmultifetchjob.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "davcollectionsmultifetchjob.h"
8
9#include "davcollectionsfetchjob.h"
10
11using namespace KDAV;
12
13namespace KDAV
14{
15class DavCollectionsMultiFetchJobPrivate
16{
17public:
18 DavCollection::List mCollections;
19};
20}
21
23 : KCompositeJob(parent)
24 , d(new DavCollectionsMultiFetchJobPrivate)
25{
26 for (const DavUrl &url : std::as_const(urls)) {
29 addSubjob(job);
30 }
31}
32
33DavCollectionsMultiFetchJob::~DavCollectionsMultiFetchJob() = default;
34
36{
37 if (!hasSubjobs()) {
38 emitResult();
39 } else {
40 for (KJob *job : subjobs()) {
41 job->start();
42 }
43 }
44}
45
47{
48 return d->mCollections;
49}
50
51void DavCollectionsMultiFetchJob::slotResult(KJob *job)
52{
53 // If we use KCompositeJob::slotResult(job) we end up with behaviour that's very
54 // hard to unittest: the valid URLs might or might not get processed.
55 // Let's wait until all subjobs are done before emitting result.
56
57 if (job->error() && !error()) {
58 // Store error only if first error
59 setError(job->error());
60 setErrorText(job->errorText());
61 }
62 if (!job->error()) {
64 d->mCollections << fetchJob->collections();
65 }
66 removeSubjob(job);
67 if (!hasSubjobs()) {
68 emitResult();
69 }
70}
71
72#include "moc_davcollectionsmultifetchjob.cpp"
virtual bool addSubjob(KJob *job)
bool hasSubjobs() const
const QList< KJob * > & subjobs() const
virtual bool removeSubjob(KJob *job)
A job that fetches all DAV collection.
DavCollection::List collections() const
Returns the list of fetched DAV collections.
void collectionDiscovered(KDAV::Protocol protocol, const QString &collectionUrl, const QString &configuredUrl)
This signal is emitted every time a new collection has been discovered.
void collectionDiscovered(KDAV::Protocol protocol, const QString &collectionUrl, const QString &configuredUrl)
This signal is emitted every time a new collection has been discovered.
DavCollection::List collections() const
Returns the list of fetched DAV collections.
DavCollectionsMultiFetchJob(const DavUrl::List &urls, QObject *parent=nullptr)
Creates a new DAV collections multi fetch job.
A helper class to combine URL and protocol of a DAV URL.
Definition davurl.h:27
void setErrorText(const QString &errorText)
void emitResult()
int error() const
void setError(int errorCode)
QString errorText() const
The KDAV namespace.
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 Fri Nov 22 2024 12:05:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.