File indexing completed on 2024-12-01 04:48:04

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 
0015 namespace OXA
0016 {
0017 /**
0018  * @short A job that requests all folders from the OX server.
0019  *
0020  * @author Tobias Koenig <tokoe@kde.org>
0021  */
0022 class FoldersRequestJob : public KJob
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     /**
0028      * Describes the mode of the request job.
0029      */
0030     enum Mode {
0031         Modified, ///< Fetches all new and modified folders
0032         Deleted ///< Fetches all deleted folders
0033     };
0034 
0035     /**
0036      * Creates a new folders request job.
0037      *
0038      * @param lastSync The timestamp of the last sync. Only added, modified or deleted folders
0039      *                 after this date will be requested. 0 will request all available folders.
0040      * @param mode The mode of folders to request.
0041      * @param parent The parent object.
0042      */
0043     explicit FoldersRequestJob(qulonglong lastSync = 0, Mode mode = Modified, QObject *parent = nullptr);
0044 
0045     /**
0046      * Starts the job.
0047      */
0048     void start() override;
0049 
0050     /**
0051      * Returns the list of all requested folders.
0052      */
0053     [[nodiscard]] Folder::List folders() const;
0054 
0055 private:
0056     void davJobFinished(KJob *);
0057     const qulonglong mLastSync;
0058     const Mode mMode;
0059     Folder::List mFolders;
0060 };
0061 }