File indexing completed on 2024-06-16 04:52:28

0001 /*
0002     Copyright (c) 2010 Grégory Oestreicher <greg@kamago.net>
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_DAVPRINCIPALHOMESETSFETCHJOB_H
0020 #define KDAV2_DAVPRINCIPALHOMESETSFETCHJOB_H
0021 
0022 #include "kpimkdav2_export.h"
0023 
0024 #include "davjobbase.h"
0025 #include "davurl.h"
0026 
0027 #include <KCoreAddons/KJob>
0028 
0029 #include <QtCore/QStringList>
0030 
0031 namespace KDAV2
0032 {
0033 
0034 /**
0035  * @short A job that fetches home sets for a principal.
0036  */
0037 class KPIMKDAV2_EXPORT DavPrincipalHomeSetsFetchJob : public DavJobBase
0038 {
0039     Q_OBJECT
0040 
0041 public:
0042     /**
0043      * Creates a new dav principals home sets fetch job.
0044      *
0045      * @param url The DAV url of the DAV principal.
0046      * @param parent The parent object.
0047      */
0048     explicit DavPrincipalHomeSetsFetchJob(const DavUrl &url, QObject *parent = nullptr);
0049 
0050     /**
0051      * Starts the job.
0052      */
0053     void start() Q_DECL_OVERRIDE;
0054 
0055     /**
0056      * Returns the found home sets.
0057      */
0058     QStringList homeSets() const;
0059     QUrl url() const;
0060 
0061 private Q_SLOTS:
0062     void davJobFinished(KJob *);
0063 
0064 private:
0065     /**
0066      * Start the fetch process.
0067      *
0068      * There may be two rounds necessary if the first request
0069      * does not returns the home sets, but only the current-user-principal
0070      * or the principal-URL. The bool flag is here to prevent requesting
0071      * those last two on each request, as they are only fetched in
0072      * the first round.
0073      *
0074      * @param fetchHomeSetsOnly If set to true the request will not include
0075      *        the current-user-principal and principal-URL props.
0076      */
0077     void fetchHomeSets(bool fetchHomeSetsOnly);
0078 
0079     DavUrl mUrl;
0080     QStringList mHomeSets;
0081 };
0082 
0083 }
0084 
0085 #endif