Libkdav2

davcollectionsmultifetchjob.cpp
1 /*
2  Copyright (c) 2010 Tobias Koenig <[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 "davcollectionsmultifetchjob.h"
20 
21 #include "davcollectionsfetchjob.h"
22 
23 using 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) {
37  DavCollectionsFetchJob *job = new DavCollectionsFetchJob(url, this);
38  connect(job, &DavCollectionsFetchJob::result, this, &DavCollectionsMultiFetchJob::davJobFinished);
40  job->start();
41  }
42 }
43 
45 {
46  return mCollections;
47 }
48 
49 void DavCollectionsMultiFetchJob::davJobFinished(KJob *job)
50 {
51  DavCollectionsFetchJob *fetchJob = qobject_cast<DavCollectionsFetchJob *>(job);
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 
DavCollection::List collections() const
Returns the list of fetched DAV collections.
bool isEmpty() const const
void setErrorText(const QString &errorText)
void start() override
Starts the job.
void result(KJob *job)
A helper class to combine url and protocol of a DAV url.
Definition: davurl.h:35
DavCollectionsMultiFetchJob(const DavUrl::List &urls, QObject *parent=nullptr)
Creates a new dav collections multi fetch job.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void collectionDiscovered(int protocol, const QString &collectionUrl, const QString &configuredUrl)
This signal is emitted every time a new collection has been discovered.
QString errorText() const
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.
A job that fetches all DAV collection.
void emitResult()
int error() const
void setError(int errorCode)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Aug 10 2022 04:09:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.