Kgapi

eventfetchjob.h
1/*
2 * This file is part of LibKGAPI library
3 *
4 * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#pragma once
10
11#include "fetchjob.h"
12#include "event.h"
13#include "kgapicalendar_export.h"
14
15#include <QScopedPointer>
16
17namespace KGAPI2
18{
19
20/**
21 * @brief A job to fetch all events from given calendar in user's Google
22 * Calendar account.
23 *
24 * @author Daniel Vrátil <dvratil@redhat.com>
25 * @since 2.0
26 */
27class KGAPICALENDAR_EXPORT EventFetchJob : public KGAPI2::FetchJob
28{
29 Q_OBJECT
30
31 /**
32 * @brief Whether to fetch deleted events as well
33 *
34 * When an event is deleted from Google Calendar, it's stored as a placeholder
35 * on Google server and can still be retrieved. Such event will have
36 * KGAPI2::Event::deleted set to @p true.
37 *
38 * By default, the job will fetch deleted events.
39 *
40 * This property does not have any effect when fetching a specific event and
41 * can be modified only when the job is not running.
42 *
43 * @see setFetchDeleted, fetchDeleted
44 */
45 Q_PROPERTY(bool fetchDeleted READ fetchDeleted WRITE setFetchDeleted)
46
47 /**
48 * @brief Timestamp to fetch only events modified since then
49 *
50 * When set, this job will only fetch events that have been modified since
51 * given timestamp.
52 *
53 * By default the timestamp is 0 and all events are fetched.
54 *
55 * This property does not have any effect when fetching a specific event and
56 * can be modified only when the job is not running.
57 *
58 * @see setFetchOnlyUpdated, fetchOnlyUpdated
59 */
60 Q_PROPERTY(quint64 fetchOnlyUpdated READ fetchOnlyUpdated WRITE setFetchOnlyUpdated)
61
62 /**
63 * @brief Timestamp of the newest event that will be fetched
64 *
65 * Only events occurring before or precisely at the time indicated by this
66 * property will be fetched.
67 *
68 * By default the timestamp is 0 and no limit is applied.
69 *
70 * This property does not have any effect when fetching a specific event and
71 * can be modified only when the job is not running.
72 *
73 * @see setMaxTime, maxTime
74 */
75 Q_PROPERTY(quint64 timeMax READ timeMax WRITE setTimeMax)
76
77 /**
78 * @brief Timestamp of the oldest event that will be fetched
79 *
80 * Only events occurring after or precisely at the time indicated by this
81 * property will be fetched.
82 *
83 * By default the timestamp is 0 and no limit is applied.
84 *
85 * This property does not have any effect when fetching a specific event and
86 * can be modified only when the job is not running.
87 *
88 * @see setMinTime, minTime
89 */
90 Q_PROPERTY(quint64 timeMin READ timeMin WRITE setTimeMin)
91
92 /**
93 * @brief A filter to fetch only events matching fulltext filter
94 *
95 * By default the property is empty and no filter is applied.
96 *
97 * This property does not have any effect when fetching a specific event and
98 * can be modified only when the job is not running.
99 *
100 * @see setFilter, filter
101 */
102 Q_PROPERTY(QString filter READ filter WRITE setFilter)
103
104 /**
105 * @brief A token to fetch updates incrementally
106 *
107 * By default the property is empty. Properties timeMin, timeMax,
108 * updatedMin will be ignored if sync token is specified
109 *
110 * @see setSyncToken, syncToken
111 */
112 Q_PROPERTY(QString syncToken READ syncToken WRITE setSyncToken)
113
114public:
115 /**
116 * @brief Constructs a job that will fetch all events from a calendar with
117 * given @p calendarId
118 *
119 * Result of this job might not contain all events, depending on configured
120 * filters.
121 *
122 * @param calendarId ID of calendar from which to fetch events
123 * @param account Account to authenticate the request
124 * @param parent
125 */
126 explicit EventFetchJob(const QString &calendarId, const AccountPtr &account, QObject *parent = nullptr);
127
128 /**
129 * @brief Constructs a job that will fetch an event with given @p eventId
130 * from a calendar with given @p calendarId
131 *
132 * Note that none of the filter, fetchOnlyUpdated, timeMax or timeMin properties
133 * is applied in this case.
134 *
135 * @param eventId ID of event to fetch
136 * @param calendarId ID of calendar in which the event is
137 * @param account Account to authenticate the request
138 * @param parent
139 */
140 explicit EventFetchJob(const QString &eventId, const QString &calendarId, const AccountPtr &account, QObject *parent = nullptr);
141
142 /**
143 * @brief Destructor
144 */
145 ~EventFetchJob() override;
146
147 /**
148 * @brief Sets the types of events to retrieve.
149 *
150 * Default set is EventType::Default, EventType::FocusTime and EventType::OutOfOffice.
151 */
152 void setEventTypes(const QList<Event::EventType> eventTypes);
153
154 /**
155 * @brief Returns the types of events to retrieve.
156 */
157 QList<Event::EventType> eventTypes() const;
158
159 /**
160 * @brief Sets fulltext filter.
161 *
162 * @param query
163 */
164 void setFilter(const QString &query);
165
166 /**
167 * @brief Returns fulltext filter string
168 */
169 [[nodiscard]] QString filter() const;
170
171 /**
172 * @brief Sets whether to fetch deleted events
173 *
174 * @param fetchDeleted
175 */
176 void setFetchDeleted(bool fetchDeleted = true);
177
178 /**
179 * @brief Returns whether deleted events are fetched.
180 */
181 [[nodiscard]] bool fetchDeleted();
182
183 /**
184 * @brief Sets the job to fetch only events modified since @p timestamp
185 *
186 * @param timestamp
187 */
188 void setFetchOnlyUpdated(quint64 timestamp);
189
190 /**
191 * @brief Returns whether the job will fetch only modified events
192 *
193 * @return 0 when all events will be fetched, a timestamp of since when the
194 * modified events will be fetched.
195 */
196 [[nodiscard]] quint64 fetchOnlyUpdated() const;
197
198 /**
199 * @brief Sets timestamp of newest event that can be fetched.
200 *
201 * @param timestamp
202 */
203 void setTimeMax(quint64 timestamp);
204
205 /**
206 * @brief Returns upper limit for event occurrence
207 */
208 [[nodiscard]] quint64 timeMax() const;
209
210 /**
211 * @brief Sets timestamp of older events that can be fetched.
212 *
213 * @param timestamp
214 */
215 void setTimeMin(quint64 timestamp);
216
217 /**
218 * @brief Returns lower boundary for events occurrence
219 */
220 [[nodiscard]] quint64 timeMin() const;
221
222 /**
223 * @brief Sets token for incremental updates
224 *
225 * @param syncToken
226 */
227 void setSyncToken(const QString &syncToken);
228
229 /**
230 * @brief Token for next incremental update
231 */
232 [[nodiscard]] QString syncToken() const;
233
234protected:
235 /**
236 * @brief KGAPI2::Job::start implementation
237 */
238 void start() override;
239
240 /**
241 * @brief KGAPI2::FetchJob::handleReplyWithItems implementation
242 *
243 * @param reply
244 * @param rawData
245 */
246 ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) override;
247
248 /**
249 * @brief KGAPI2::Job::handleError implementation
250 *
251 * @param errorCode
252 * @param rawData
253 */
254 bool handleError(int errorCode, const QByteArray &rawData) override;
255
256private:
257 class Private;
258 QScopedPointer<Private> const d;
259 friend class Private;
260};
261
262} // namespace KGAPI2
A job to fetch all events from given calendar in user's Google Calendar account.
Represents a single event from Google Calendar.
Abstract superclass for all jobs that fetch resources from Google.
Definition fetchjob.h:25
Q_SCRIPTABLE bool setFilter(const QString &filter)
Q_SCRIPTABLE Q_NOREPLY void start()
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:36:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.