File indexing completed on 2024-05-12 05:22:13
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 "kgapicalendar_export.h" 0013 0014 #include <QScopedPointer> 0015 0016 namespace KGAPI2 0017 { 0018 0019 /** 0020 * @brief A job to fetch all events from given calendar in user's Google 0021 * Calendar account. 0022 * 0023 * @author Daniel Vrátil <dvratil@redhat.com> 0024 * @since 2.0 0025 */ 0026 class KGAPICALENDAR_EXPORT EventFetchJob : public KGAPI2::FetchJob 0027 { 0028 Q_OBJECT 0029 0030 /** 0031 * @brief Whether to fetch deleted events as well 0032 * 0033 * When an event is deleted from Google Calendar, it's stored as a placeholder 0034 * on Google server and can still be retrieved. Such event will have 0035 * KGAPI2::Event::deleted set to @p true. 0036 * 0037 * By default, the job will fetch deleted events. 0038 * 0039 * This property does not have any effect when fetching a specific event 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 Timestamp to fetch only events modified since then 0048 * 0049 * When set, this job will only fetch events that have been modified since 0050 * given timestamp. 0051 * 0052 * By default the timestamp is 0 and all events are fetched. 0053 * 0054 * This property does not have any effect when fetching a specific event and 0055 * can be modified only when the job is not running. 0056 * 0057 * @see setFetchOnlyUpdated, fetchOnlyUpdated 0058 */ 0059 Q_PROPERTY(quint64 fetchOnlyUpdated READ fetchOnlyUpdated WRITE setFetchOnlyUpdated) 0060 0061 /** 0062 * @brief Timestamp of the newest event that will be fetched 0063 * 0064 * Only events occurring before or precisely at the time indicated by this 0065 * property will be fetched. 0066 * 0067 * By default the timestamp is 0 and no limit is applied. 0068 * 0069 * This property does not have any effect when fetching a specific event and 0070 * can be modified only when the job is not running. 0071 * 0072 * @see setMaxTime, maxTime 0073 */ 0074 Q_PROPERTY(quint64 timeMax READ timeMax WRITE setTimeMax) 0075 0076 /** 0077 * @brief Timestamp of the oldest event that will be fetched 0078 * 0079 * Only events occurring after or precisely at the time indicated by this 0080 * property will be fetched. 0081 * 0082 * By default the timestamp is 0 and no limit is applied. 0083 * 0084 * This property does not have any effect when fetching a specific event and 0085 * can be modified only when the job is not running. 0086 * 0087 * @see setMinTime, minTime 0088 */ 0089 Q_PROPERTY(quint64 timeMin READ timeMin WRITE setTimeMin) 0090 0091 /** 0092 * @brief A filter to fetch only events matching fulltext filter 0093 * 0094 * By default the property is empty and no filter is applied. 0095 * 0096 * This property does not have any effect when fetching a specific event and 0097 * can be modified only when the job is not running. 0098 * 0099 * @see setFilter, filter 0100 */ 0101 Q_PROPERTY(QString filter READ filter WRITE setFilter) 0102 0103 /** 0104 * @brief A token to fetch updates incrementally 0105 * 0106 * By default the property is empty. Properties timeMin, timeMax, 0107 * updatedMin will be ignored if sync token is specified 0108 * 0109 * @see setSyncToken, syncToken 0110 */ 0111 Q_PROPERTY(QString syncToken READ syncToken WRITE setSyncToken) 0112 0113 public: 0114 /** 0115 * @brief Constructs a job that will fetch all events from a calendar with 0116 * given @p calendarId 0117 * 0118 * Result of this job might not contain all events, depending on configured 0119 * filters. 0120 * 0121 * @param calendarId ID of calendar from which to fetch events 0122 * @param account Account to authenticate the request 0123 * @param parent 0124 */ 0125 explicit EventFetchJob(const QString &calendarId, const AccountPtr &account, QObject *parent = nullptr); 0126 0127 /** 0128 * @brief Constructs a job that will fetch an event with given @p eventId 0129 * from a calendar with given @p calendarId 0130 * 0131 * Note that none of the filter, fetchOnlyUpdated, timeMax or timeMin properties 0132 * is applied in this case. 0133 * 0134 * @param eventId ID of event to fetch 0135 * @param calendarId ID of calendar in which the event is 0136 * @param account Account to authenticate the request 0137 * @param parent 0138 */ 0139 explicit EventFetchJob(const QString &eventId, const QString &calendarId, const AccountPtr &account, QObject *parent = nullptr); 0140 0141 /** 0142 * @brief Destructor 0143 */ 0144 ~EventFetchJob() override; 0145 0146 /** 0147 * @brief Sets fulltext filter. 0148 * 0149 * @param query 0150 */ 0151 void setFilter(const QString &query); 0152 0153 /** 0154 * @brief Returns fulltext filter string 0155 */ 0156 [[nodiscard]] QString filter() const; 0157 0158 /** 0159 * @brief Sets whether to fetch deleted events 0160 * 0161 * @param fetchDeleted 0162 */ 0163 void setFetchDeleted(bool fetchDeleted = true); 0164 0165 /** 0166 * @brief Returns whether deleted events are fetched. 0167 */ 0168 [[nodiscard]] bool fetchDeleted(); 0169 0170 /** 0171 * @brief Sets the job to fetch only events modified since @p timestamp 0172 * 0173 * @param timestamp 0174 */ 0175 void setFetchOnlyUpdated(quint64 timestamp); 0176 0177 /** 0178 * @brief Returns whether the job will fetch only modified events 0179 * 0180 * @return 0 when all events will be fetched, a timestamp of since when the 0181 * modified events will be fetched. 0182 */ 0183 [[nodiscard]] quint64 fetchOnlyUpdated() const; 0184 0185 /** 0186 * @brief Sets timestamp of newest event that can be fetched. 0187 * 0188 * @param timestamp 0189 */ 0190 void setTimeMax(quint64 timestamp); 0191 0192 /** 0193 * @brief Returns upper limit for event occurrence 0194 */ 0195 [[nodiscard]] quint64 timeMax() const; 0196 0197 /** 0198 * @brief Sets timestamp of older events that can be fetched. 0199 * 0200 * @param timestamp 0201 */ 0202 void setTimeMin(quint64 timestamp); 0203 0204 /** 0205 * @brief Returns lower boundary for events occurrence 0206 */ 0207 [[nodiscard]] quint64 timeMin() const; 0208 0209 /** 0210 * @brief Sets token for incremental updates 0211 * 0212 * @param syncToken 0213 */ 0214 void setSyncToken(const QString &syncToken); 0215 0216 /** 0217 * @brief Token for next incremental update 0218 */ 0219 [[nodiscard]] QString syncToken() const; 0220 0221 protected: 0222 /** 0223 * @brief KGAPI2::Job::start implementation 0224 */ 0225 void start() override; 0226 0227 /** 0228 * @brief KGAPI2::FetchJob::handleReplyWithItems implementation 0229 * 0230 * @param reply 0231 * @param rawData 0232 */ 0233 ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) override; 0234 0235 private: 0236 class Private; 0237 QScopedPointer<Private> const d; 0238 friend class Private; 0239 }; 0240 0241 } // namespace KGAPI2