File indexing completed on 2024-11-24 04:44:29

0001 /*
0002     This file is part of oxaccess.
0003 
0004     SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include <KJob>
0012 
0013 #include "folder.h"
0014 #include "object.h"
0015 
0016 namespace OXA
0017 {
0018 class ObjectsRequestJob : public KJob
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     /**
0024      * Describes the mode of the request job.
0025      */
0026     enum Mode {
0027         Modified, ///< Fetches all new and modified objects
0028         Deleted ///< Fetches all deleted objects
0029     };
0030 
0031     /**
0032      * Creates a new objects request job.
0033      *
0034      * @param folder The folder the objects shall be request from.
0035      * @param lastSync The timestamp of the last sync. Only added, modified or deleted objects
0036      *                 after this date will be requested. 0 will request all available objects.
0037      * @param mode The mode of objects to request.
0038      * @param parent The parent object.
0039      */
0040     explicit ObjectsRequestJob(const Folder &folder, qulonglong lastSync = 0, Mode mode = Modified, QObject *parent = nullptr);
0041 
0042     void start() override;
0043 
0044     [[nodiscard]] Object::List objects() const;
0045 
0046 private:
0047     void davJobFinished(KJob *);
0048     Folder mFolder;
0049     qulonglong mLastSync;
0050     const Mode mMode;
0051     Object::List mObjects;
0052 };
0053 }