File indexing completed on 2024-05-12 05:22:32
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 "kgapitasks_export.h" 0013 0014 #include <QScopedPointer> 0015 0016 namespace KGAPI2 0017 { 0018 0019 /** 0020 * @brief A job to fetch all tasks from given tasklist in user's Google Tasks 0021 * account. 0022 * 0023 * @author Daniel Vrátil <dvratil@redhat.com> 0024 * @since 2.0 0025 */ 0026 class KGAPITASKS_EXPORT TaskFetchJob : public KGAPI2::FetchJob 0027 { 0028 Q_OBJECT 0029 0030 /** 0031 * @brief Whether to fetch deleted tasks as well 0032 * 0033 * When an tasks is deleted from tasklist, it's stored as a placeholder 0034 * on Google server and can still be retrieved. Such task will have 0035 * KGAPI2::Task::deleted set to @p true. 0036 * 0037 * By default, the job will fetch deleted tasks. 0038 * 0039 * This property does not have any effect when fetching a specific task and 0040 * can be modified only when the job is not running. 0041 * 0042 * @see setFetchDeleted, fetchDeleted 0043 */ 0044 Q_PROPERTY(bool fetchDeleted READ fetchDeleted WRITE setFetchDeleted) 0045 0046 /** 0047 * @brief Whether to fetch completed tasks as well 0048 * 0049 * By default, the job will fetch completed tasks. 0050 * 0051 * This property does not have any effect when fetching a specific event and 0052 * can be modified only when the job is not running. 0053 * 0054 * @see setFetchCompleted, fetchCompleted 0055 */ 0056 Q_PROPERTY(bool fetchCompleted READ fetchCompleted WRITE setFetchCompleted) 0057 0058 /** 0059 * @brief Timestamp to fetch only tasks modified since then 0060 * 0061 * When set, this job will only fetch tasks that have been modified since 0062 * given timestamp. 0063 * 0064 * By default the timestamp is 0 and all tasks are fetched. 0065 * 0066 * This property does not have any effect when fetching a specific task and 0067 * can be modified only when the job is not running. 0068 * 0069 * @see setFetchOnlyUpdated, fetchOnlyUpdated 0070 */ 0071 Q_PROPERTY(quint64 fetchOnlyUpdated READ fetchOnlyUpdated WRITE setFetchOnlyUpdated) 0072 0073 /** 0074 * @brief Timestamp of the newest completed task that will be fetched 0075 * 0076 * Only tasks that have been completed before or precisely at the time 0077 * indicated by this property will be fetched. 0078 * 0079 * By default the timestamp is 0 and no limit is applied. 0080 * 0081 * This property does not have any effect when fetching a specific task and 0082 * can be modified only when the job is not running. 0083 * 0084 * @see completedMax, setCompletedMax 0085 */ 0086 Q_PROPERTY(quint64 completedMax READ completedMax WRITE setCompletedMax) 0087 0088 /** 0089 * @brief Timestamp of the oldest completed task that will be fetched 0090 * 0091 * Only tasks that have been completed after or precisely at the time 0092 * indicated by this property will be fetched. 0093 * 0094 * By default the timestamp is 0 and no limit is applied. 0095 * 0096 * This property does not have any effect when fetching a specific task and 0097 * can be modified only when the job is not running. 0098 * 0099 * @see completedMin, setCompletedMin 0100 */ 0101 Q_PROPERTY(quint64 completedMin READ completedMin WRITE setCompletedMin) 0102 0103 /** 0104 * @brief Timestamp of the newest due task that will be fetched 0105 * 0106 * Only tasks that are due before or precisely at the time indicated by 0107 * this property will be fetched. 0108 * 0109 * By default the timestamp is 0 and no limit is applied. 0110 * 0111 * This property does not have any effect when fetching a specific task and 0112 * can be modified only when the job is not running. 0113 * 0114 * @see dueMax, setDueMax 0115 */ 0116 Q_PROPERTY(quint64 dueMax READ dueMax WRITE setDueMax) 0117 0118 /** 0119 * @brief Timestamp of the oldest due task that will be fetched 0120 * 0121 * Only tasks that are due after or precisely at the time indicated by 0122 * this property will be fetched. 0123 * 0124 * By default the timestamp is 0 and no limit is applied. 0125 * 0126 * This property does not have any effect when fetching a specific task and 0127 * can be modified only when the job is not running. 0128 * 0129 * @see dueMin, setDueMin 0130 */ 0131 Q_PROPERTY(quint64 dueMin READ dueMin WRITE setDueMin) 0132 0133 public: 0134 /** 0135 * @brief Constructs a job that will fetch all tasks from a tasklist with 0136 * given @p taskListId 0137 * 0138 * Result of this job might not contain all tasks, depending on configured 0139 * filters. 0140 * 0141 * @param taskListId ID of tasklist from which to fetch tasks 0142 * @param account Account to authenticate the request 0143 * @param parent 0144 */ 0145 explicit TaskFetchJob(const QString &taskListId, const AccountPtr &account, QObject *parent = nullptr); 0146 0147 /** 0148 * @brief Constructs a job that will fetch a task with given @p taskId 0149 * from a tasklist with given @p taskListId 0150 * 0151 * Note that none of the properties fetchDeleted, fetchCompleted, 0152 * fetchOnlyUpdated, completedMax, completedMin, dueMax or dueMin are applied 0153 * in this case. 0154 * 0155 * @param taskId ID of task to fetch 0156 * @param taskListId ID of tasklist in which the event is 0157 * @param account Account to authenticate the request 0158 * @param parent 0159 */ 0160 explicit TaskFetchJob(const QString &taskId, const QString &taskListId, const AccountPtr &account, QObject *parent = nullptr); 0161 0162 /** 0163 * @brief Destructor 0164 */ 0165 ~TaskFetchJob() override; 0166 0167 /** 0168 * @brief Sets whether to fetch should deleted tasks 0169 * 0170 * @param fetchDeleted 0171 */ 0172 void setFetchDeleted(bool fetchDeleted = true); 0173 0174 /** 0175 * @brief Returns whether to fetch will deleted tasks 0176 */ 0177 bool fetchDeleted() const; 0178 0179 /** 0180 * @brief Sets whether the job should fetch completed tasks 0181 * 0182 * @param fetchCompleted 0183 */ 0184 void setFetchCompleted(bool fetchCompleted = true); 0185 0186 /** 0187 * @brief Returns whether the job will fetch completed tasks 0188 */ 0189 bool fetchCompleted() const; 0190 0191 /** 0192 * @brief Sets the job to fetch only events modified since @p timestamp 0193 * 0194 * @param timestamp 0195 */ 0196 void setFetchOnlyUpdated(quint64 timestamp); 0197 0198 /** 0199 * @brief Returns whether the job will fetch only modified events 0200 * 0201 * @return 0 when all events will be fetched, a timestamp of since when the 0202 * modified events will be fetched. 0203 */ 0204 quint64 fetchOnlyUpdated(); 0205 0206 /** 0207 * @brief Sets timestamp of newest completed task that can be fetched. 0208 * 0209 * @param timestamp 0210 */ 0211 void setCompletedMax(quint64 timestamp); 0212 0213 /** 0214 * @brief Returns upper date limit for fetching completed tasks 0215 */ 0216 quint64 completedMax() const; 0217 0218 /** 0219 * @brief Sets timestamp of oldest completed task that can be fetched. 0220 * 0221 * @param timestamp 0222 */ 0223 void setCompletedMin(quint64 timestamp); 0224 0225 /** 0226 * @brief Returns bottom date limit for fetching completed tasks 0227 */ 0228 quint64 completedMin() const; 0229 0230 /** 0231 * @brief Sets timestamp of newest due task that can be fetched. 0232 * 0233 * @param timestamp 0234 */ 0235 void setDueMax(quint64 timestamp); 0236 0237 /** 0238 * @brief Returns upper date limit for fetching due tasks 0239 */ 0240 quint64 dueMax() const; 0241 0242 /** 0243 * @brief Sets timestamp of oldest due task that can be fetched. 0244 * 0245 * @param timestamp 0246 */ 0247 void setDueMin(quint64 timestamp); 0248 0249 /** 0250 * @brief Returns bottom date limit for fetching due tasks. 0251 */ 0252 quint64 dueMin() const; 0253 0254 protected: 0255 /** 0256 * @brief KGAPI2::Job::start implementation 0257 */ 0258 void start() override; 0259 0260 /** 0261 * @brief KGAPI2::FetchJob::handleReplyWithItems implementation 0262 * 0263 * @param reply 0264 * @param rawData 0265 */ 0266 ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) override; 0267 0268 private: 0269 class Private; 0270 QScopedPointer<Private> const d; 0271 friend class Private; 0272 }; 0273 0274 } // namespace KGAPI2