Libkdav2

davcollectionsmultifetchjob.cpp
1/*
2 Copyright (c) 2010 Tobias Koenig <tokoe@kde.org>
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 "davcollectionsmultifetchjob.h"
20
21#include "davcollectionsfetchjob.h"
22
23using namespace KDAV2;
24
26 : KJob(parent), mUrls(urls), mSubJobCount(urls.size())
27{
28}
29
31{
32 if (mUrls.isEmpty()) {
33 emitResult();
34 }
35
36 foreach (const DavUrl &url, mUrls) {
38 connect(job, &DavCollectionsFetchJob::result, this, &DavCollectionsMultiFetchJob::davJobFinished);
40 job->start();
41 }
42}
43
45{
46 return mCollections;
47}
48
49void DavCollectionsMultiFetchJob::davJobFinished(KJob *job)
50{
52
53 if (job->error()) {
54 setError(job->error());
55 setErrorText(job->errorText());
56 } else {
57 mCollections << fetchJob->collections();
58 }
59
60 if (--mSubJobCount == 0) {
61 emitResult();
62 }
63}
64
A job that fetches all DAV collection.
void collectionDiscovered(int protocol, const QString &collectionUrl, const QString &configuredUrl)
This signal is emitted every time a new collection has been discovered.
void start() override
Starts the job.
DavCollection::List collections() const
Returns the list of fetched DAV collections.
void collectionDiscovered(int protocol, const QString &collectionUrl, const QString &configuredUrl)
This signal is emitted every time a new collection has been discovered.
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:36
void setErrorText(const QString &errorText)
void emitResult()
int error() const
void result(KJob *job)
void setError(int errorCode)
QString errorText() const
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 Tue Mar 26 2024 11:13:28 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.