File indexing completed on 2024-06-16 04:52:27
0001 /* 0002 Copyright (c) 2010 Tobias Koenig <tokoe@kde.org> 0003 0004 This program is free software; you can redistribute it and/or modify 0005 it under the terms of the GNU General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or 0007 (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 GNU General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef KDAV2_DAVCOLLECTIONSFETCHJOB_H 0020 #define KDAV2_DAVCOLLECTIONSFETCHJOB_H 0021 0022 #include "kpimkdav2_export.h" 0023 0024 #include "davcollection.h" 0025 #include "davjobbase.h" 0026 #include "davurl.h" 0027 0028 #include <KCoreAddons/KJob> 0029 0030 namespace KDAV2 0031 { 0032 0033 /** 0034 * @short A job that fetches all DAV collection. 0035 * 0036 * This job is used to fetch all DAV collection that are available 0037 * under a certain DAV url. 0038 */ 0039 class KPIMKDAV2_EXPORT DavCollectionsFetchJob : public DavJobBase 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 /** 0045 * Creates a new dav collections fetch job. 0046 * 0047 * @param url The DAV url of the DAV collection whose sub collections shall be fetched. 0048 * @param parent The parent object. 0049 */ 0050 explicit DavCollectionsFetchJob(const DavUrl &url, QObject *parent = nullptr); 0051 0052 /** 0053 * Starts the job. 0054 */ 0055 void start() Q_DECL_OVERRIDE; 0056 0057 /** 0058 * Returns the list of fetched DAV collections. 0059 */ 0060 DavCollection::List collections() const; 0061 0062 /** 0063 * Return the DavUrl used by this job 0064 */ 0065 DavUrl davUrl() const; 0066 0067 Q_SIGNALS: 0068 /** 0069 * This signal is emitted every time a new collection has been discovered. 0070 * 0071 * @param collectionUrl The URL of the discovered collection 0072 * @param configuredUrl The URL given to the job 0073 */ 0074 void collectionDiscovered(int protocol, const QString &collectionUrl, const QString &configuredUrl); 0075 0076 private Q_SLOTS: 0077 void principalFetchFinished(KJob *); 0078 void collectionsFetchFinished(KJob *); 0079 void individualCollectionRefreshed(KJob *); 0080 0081 private: 0082 void doCollectionsFetch(const QUrl &url); 0083 void refreshIndividualCollection(const DavCollection &); 0084 void subjobFinished(); 0085 0086 DavUrl mUrl; 0087 DavCollection::List mCollections; 0088 uint mSubJobCount; 0089 }; 0090 0091 } 0092 0093 #endif