File indexing completed on 2024-05-12 05:22:16

0001 /*
0002  * This file is part of LibKGAPI library
0003  *
0004  * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #pragma once
0010 
0011 #include "fetchjob.h"
0012 #include "kgapidrive_export.h"
0013 
0014 namespace KGAPI2
0015 {
0016 
0017 namespace Drive
0018 {
0019 
0020 /**
0021  * @brief A fetch job that retrieves DriveAbout data.
0022  */
0023 class KGAPIDRIVE_EXPORT AboutFetchJob : public KGAPI2::FetchJob
0024 {
0025     Q_OBJECT
0026 
0027     /**
0028      * @brief Whether to include shared and public files to change IDs count
0029      *
0030      * When calculating the number of remaining change IDs, whether to include
0031      * shared files and public files the user has opened. When set to false, this
0032      * counts only change IDs for owned files and any shared or public files that
0033      * the user has explicitly added to a folder in Drive.
0034      *
0035      * Default value is true.
0036      *
0037      * This property can be modified only when the job is not running.
0038      */
0039     Q_PROPERTY(bool includeSubscribed READ includeSubscribed WRITE setIncludeSubscribed)
0040 
0041     /**
0042      * @brief Maximum number of remaining change IDs to count.
0043      *
0044      * Default value is 0, i.e. no limit
0045      *
0046      * This property can be modified only when the job is not running.
0047      */
0048     Q_PROPERTY(qlonglong maxChangeIdCount READ maxChangeIdCount WRITE setMaxChangeIdCount)
0049 
0050     /**
0051      * @brief Change ID to start counting from when calculating number of
0052      *        remaining change IDs.
0053      *
0054      * Default value is 0, i.e. first ID
0055      *
0056      * This property can be modified only when the job is not running.
0057      */
0058     Q_PROPERTY(qlonglong startChangeId READ startChangeId WRITE setStartChangeId)
0059 
0060 public:
0061     /**
0062      * @brief Constructs a new fetch job.
0063      *
0064      * The @p account must be authenticated with one of the following scopes:
0065      * <ul>
0066      * <li>https://www.googleapis.com/auth/drive.readonly.metadata</li>
0067      * <li>https://www.googleapis.com/auth/drive.readonly</li>
0068      * <li>https://www.googleapis.com/auth/drive</li>
0069      * <li>https://www.googleapis.com/auth/drive.file</li>
0070      * <li>https://www.googleapis.com/auth/drive.metadata.readonly</li>
0071      * </ul>
0072      *
0073      * @param account Account to authenticate the request with
0074      * @param parent
0075      */
0076     explicit AboutFetchJob(const AccountPtr &account, QObject *parent = nullptr);
0077     ~AboutFetchJob() override;
0078 
0079     /**
0080      * @brief Returns whether to include shared and public files to change IDs count.
0081      */
0082     [[nodiscard]] bool includeSubscribed() const;
0083 
0084     /**
0085      * @brief Sets whether to include shared and public files to change IDs count.
0086      *
0087      * @param includeSubscribed
0088      */
0089     void setIncludeSubscribed(bool includeSubscribed);
0090 
0091     /**
0092      * @brief Returns maximum number of remaining change IDs to count.
0093      */
0094     [[nodiscard]] qlonglong maxChangeIdCount() const;
0095 
0096     /**
0097      * @brief Sets maximum number of remaining change IDs to count.
0098      *
0099      * @param maxChangeIdCount
0100      */
0101     void setMaxChangeIdCount(qlonglong maxChangeIdCount);
0102 
0103     /**
0104      * @brief Returns change ID to start counting from when calculating number of
0105      *        remaining change IDs.
0106      */
0107     [[nodiscard]] qlonglong startChangeId() const;
0108 
0109     /**
0110      * @brief Sets change ID to start counting from when calculating number of
0111      *        remaining change IDs.
0112      *
0113      * @param startChangeId
0114      */
0115     void setStartChangeId(qlonglong startChangeId);
0116 
0117     /**
0118      * @brief Returns the retrieved DriveAbout object
0119      *
0120      * This method can only be called after the job has emitted finished()
0121      */
0122     [[nodiscard]] AboutPtr aboutData() const;
0123 
0124 protected:
0125     /**
0126      * @brief KGAPI2::Job::start implementation
0127      */
0128     void start() override;
0129 
0130     /**
0131      * @brief KGAPI2::Job::handleReply implementation
0132      *
0133      * @param reply
0134      * @param rawData
0135      */
0136     KGAPI2::ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) override;
0137 
0138 private:
0139     class Private;
0140     Private *const d;
0141     friend class Private;
0142 };
0143 
0144 } // namespace Drive
0145 
0146 } // namespace KGAPI2