Changeset View
Changeset View
Standalone View
Standalone View
src/drive/drives.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2019 David Barchiesi <david@barchie.si> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | GNU Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <https://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef LIBKGAPI2_DRIVEDRIVES_H | ||||
22 | #define LIBKGAPI2_DRIVEDRIVES_H | ||||
23 | | ||||
24 | #include "types.h" | ||||
25 | #include "object.h" | ||||
26 | #include "kgapidrive_export.h" | ||||
27 | | ||||
28 | #include <QString> | ||||
29 | | ||||
30 | #include <QDateTime> | ||||
31 | | ||||
32 | namespace KGAPI2 | ||||
33 | { | ||||
34 | | ||||
35 | namespace Drive | ||||
36 | { | ||||
37 | | ||||
38 | /** | ||||
39 | * @brief Drives contains a representation of a Drive. | ||||
40 | * | ||||
41 | * Getters and setters' documentation is based on Google Drive's API v2 reference | ||||
42 | * @see <a href="https://developers.google.com/drive/v2/reference/drives">Drives</a> | ||||
43 | * | ||||
44 | * @since 5.11.41 | ||||
45 | * @author David Barchiesi <david@barchie.si> | ||||
46 | */ | ||||
47 | class KGAPIDRIVE_EXPORT Drives: public KGAPI2::Object | ||||
48 | { | ||||
49 | | ||||
50 | public: | ||||
51 | | ||||
52 | /** | ||||
53 | * @brief Drives::Restrictions holds the structure used for | ||||
54 | * a set of restrictions that apply to this shared drive | ||||
55 | * or items inside this shared drive. | ||||
56 | */ | ||||
57 | class Restrictions | ||||
58 | { | ||||
59 | | ||||
60 | public: | ||||
61 | struct Fields { | ||||
62 | static const QString AdminManagedRestrictions; | ||||
63 | static const QString CopyRequiresWriterPermission; | ||||
64 | static const QString DomainUsersOnly; | ||||
65 | static const QString DriveMembersOnly; | ||||
66 | }; | ||||
67 | | ||||
68 | Restrictions(); | ||||
69 | Restrictions(const Restrictions &other); | ||||
70 | ~Restrictions(); | ||||
71 | bool operator==(const Restrictions &other) const; | ||||
72 | bool operator!=(const Restrictions &other) const { return !operator==(other); } | ||||
73 | | ||||
74 | /** | ||||
75 | * @brief Returns whether administrative privileges on this shared | ||||
76 | * drive are required to modify restrictions. | ||||
77 | */ | ||||
78 | bool adminManagedRestrictions() const; | ||||
79 | | ||||
80 | /** | ||||
81 | * @brief Sets whether administrative privileges on this shared drive | ||||
82 | * are required to modify restrictions. | ||||
83 | * | ||||
84 | * @param adminManagedRestrictions | ||||
85 | */ | ||||
86 | void setAdminManagedRestrictions(bool adminManagedRestrictions) const; | ||||
87 | | ||||
88 | /** | ||||
89 | * @brief Returns whether the options to copy, print, or download files | ||||
90 | * inside this shared drive, should be disabled for readers and commenters. | ||||
91 | * When this restriction is set to true, it will override the similarly | ||||
92 | * named field to true for any file inside this shared drive. | ||||
93 | */ | ||||
94 | bool copyRequiresWriterPermission() const; | ||||
95 | | ||||
96 | /** | ||||
97 | * @brief Sets whether the options to copy, print, or download files | ||||
98 | * inside this shared drive, should be disabled for readers and commenters. | ||||
99 | * When this restriction is set to true, it will override the similarly | ||||
100 | * named field to true for any file inside this shared drive. | ||||
101 | * | ||||
102 | * @param copyRequiresWriterPermission | ||||
103 | */ | ||||
104 | void setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const; | ||||
105 | | ||||
106 | /** | ||||
107 | * @brief Returns whether access to this shared drive and items inside | ||||
108 | * this shared drive is restricted to users of the domain to which this | ||||
109 | * shared drive belongs. This restriction may be overridden by other | ||||
110 | * sharing policies controlled outside of this shared drive. | ||||
111 | */ | ||||
112 | bool domainUsersOnly() const; | ||||
113 | | ||||
114 | /** | ||||
115 | * @brief Sets whether access to this shared drive and items inside this | ||||
116 | * shared drive is restricted to users of the domain to which this | ||||
117 | * shared drive belongs. This restriction may be overridden by other | ||||
118 | * sharing policies controlled outside of this shared drive. | ||||
119 | * | ||||
120 | * @param domainUsersOnly | ||||
121 | */ | ||||
122 | void setDomainUsersOnly(bool domainUsersOnly) const; | ||||
123 | | ||||
124 | /** | ||||
125 | * @brief Returns whether access to items inside this shared drive is | ||||
126 | * restricted to its members. | ||||
127 | */ | ||||
128 | bool driveMembersOnly() const; | ||||
129 | | ||||
130 | /** | ||||
131 | * @brief Sets whether access to items inside this shared drive is | ||||
132 | * restricted to its members. | ||||
133 | * | ||||
134 | * @param driveMembersOnly | ||||
135 | */ | ||||
136 | void setDriveMembersOnly(bool driveMembersOnly) const; | ||||
137 | | ||||
138 | private: | ||||
139 | class Private; | ||||
140 | QScopedPointer<Private> const d; | ||||
141 | friend class Private; | ||||
142 | friend class Drives; | ||||
143 | }; | ||||
144 | | ||||
145 | typedef QSharedPointer<Restrictions> RestrictionsPtr; | ||||
146 | | ||||
147 | /** | ||||
148 | * @brief Drives::Capabilities holds the structure used for | ||||
149 | * capabilities the current user has on this shared drive. | ||||
150 | */ | ||||
151 | class Capabilities | ||||
152 | { | ||||
153 | | ||||
154 | public: | ||||
155 | struct Fields { | ||||
156 | static const QString CanAddChildren; | ||||
157 | static const QString CanChangeCopyRequiresWriterPermissionRestriction; | ||||
158 | static const QString CanChangeDomainUsersOnlyRestriction; | ||||
159 | static const QString CanChangeDriveBackground; | ||||
160 | static const QString CanChangeDriveMembersOnlyRestriction; | ||||
161 | static const QString CanComment; | ||||
162 | static const QString CanCopy; | ||||
163 | static const QString CanDeleteChildren; | ||||
164 | static const QString CanDeleteDrive; | ||||
165 | static const QString CanDownload; | ||||
166 | static const QString CanEdit; | ||||
167 | static const QString CanListChildren; | ||||
168 | static const QString CanManageMembers; | ||||
169 | static const QString CanReadRevisions; | ||||
170 | static const QString CanRename; | ||||
171 | static const QString CanRenameDrive; | ||||
172 | static const QString CanShare; | ||||
173 | static const QString CanTrashChildren; | ||||
174 | }; | ||||
175 | | ||||
176 | Capabilities(); | ||||
177 | Capabilities(const Capabilities &other); | ||||
178 | ~Capabilities(); | ||||
179 | bool operator==(const Capabilities &other) const; | ||||
180 | bool operator!=(const Capabilities &other) const { return !operator==(other); } | ||||
181 | | ||||
182 | /** | ||||
183 | * @brief Returns whether the current user can add children to folders | ||||
184 | * in this shared drive. | ||||
185 | */ | ||||
186 | bool canAddChildren() const; | ||||
187 | | ||||
188 | /** | ||||
189 | * @brief Returns whether the current user can change the | ||||
190 | * copyRequiresWriterPermission restriction of this shared drive. | ||||
191 | */ | ||||
192 | bool canChangeCopyRequiresWriterPermissionRestriction() const; | ||||
193 | | ||||
194 | /** | ||||
195 | * @brief Returns whether the current user can change the domainUsersOnly | ||||
196 | * restriction of this shared drive. | ||||
197 | */ | ||||
198 | bool canChangeDomainUsersOnlyRestriction() const; | ||||
199 | | ||||
200 | /** | ||||
201 | * @brief Returns whether the current user can change the background of | ||||
202 | * this shared drive. | ||||
203 | */ | ||||
204 | bool canChangeDriveBackground() const; | ||||
205 | | ||||
206 | /** | ||||
207 | * @brief Returns whether the current user can change the driveMembersOnly | ||||
208 | * restriction of this shared drive. | ||||
209 | */ | ||||
210 | bool canChangeDriveMembersOnlyRestriction() const; | ||||
211 | | ||||
212 | /** | ||||
213 | * @brief Returns Whether the current user can comment on files in | ||||
214 | * this shared drive. | ||||
215 | */ | ||||
216 | bool canComment() const; | ||||
217 | | ||||
218 | /** | ||||
219 | * @brief Returns Whether the current user can copy files in this shared drive. | ||||
220 | */ | ||||
221 | bool canCopy() const; | ||||
222 | | ||||
223 | /** | ||||
224 | * @brief Returns Whether the current user can delete children from | ||||
225 | * folders in this shared drive. | ||||
226 | */ | ||||
227 | bool canDeleteChildren() const; | ||||
228 | | ||||
229 | /** | ||||
230 | * @brief Returns Whether the current user can delete this shared drive. | ||||
231 | * | ||||
232 | * Attempting to delete the shared drive may still fail if there are | ||||
233 | * untrashed items inside the shared drive. | ||||
234 | */ | ||||
235 | bool canDeleteDrive() const; | ||||
236 | | ||||
237 | /** | ||||
238 | * @brief Returns Whether the current user can download files in this | ||||
239 | * shared drive. | ||||
240 | */ | ||||
241 | bool canDownload() const; | ||||
242 | | ||||
243 | /** | ||||
244 | * @brief Returns Whether the current user can edit files in this | ||||
245 | * shared drive | ||||
246 | */ | ||||
247 | bool canEdit() const; | ||||
248 | | ||||
249 | /** | ||||
250 | * @brief Returns Whether the current user can list the children of | ||||
251 | * folders in this shared drive. | ||||
252 | */ | ||||
253 | bool canListChildren() const; | ||||
254 | | ||||
255 | /** | ||||
256 | * @brief Returns Whether the current user can add members to this shared drive | ||||
257 | * or remove them or change their role. | ||||
258 | */ | ||||
259 | bool canManageMembers() const; | ||||
260 | | ||||
261 | /** | ||||
262 | * @brief Returns Whether the current user can read the revisions | ||||
263 | * resource of files in this shared drive. | ||||
264 | */ | ||||
265 | bool canReadRevisions() const; | ||||
266 | | ||||
267 | /** | ||||
268 | * @brief Returns Whether the current user can rename files or folders | ||||
269 | * in this shared drive. | ||||
270 | */ | ||||
271 | bool canRename() const; | ||||
272 | | ||||
273 | /** | ||||
274 | * @brief Returns Whether the current user can rename this shared drive. | ||||
275 | */ | ||||
276 | bool canRenameDrive() const; | ||||
277 | | ||||
278 | /** | ||||
279 | * @brief Returns Whether the current user can share files or folders | ||||
280 | * in this shared drive. | ||||
281 | */ | ||||
282 | bool canShare() const; | ||||
283 | | ||||
284 | /** | ||||
285 | * @brief Returns Whether the current user can trash children from | ||||
286 | * folders in this shared drive. | ||||
287 | */ | ||||
288 | bool canTrashChildren() const; | ||||
289 | | ||||
290 | private: | ||||
291 | class Private; | ||||
292 | QScopedPointer<Private> const d; | ||||
293 | friend class Private; | ||||
294 | friend class Drives; | ||||
295 | }; | ||||
296 | | ||||
297 | typedef QSharedPointer<Capabilities> CapabilitiesPtr; | ||||
298 | | ||||
299 | /** | ||||
300 | * @brief Drives::BackgroundImageFile holds the structure used | ||||
301 | * for backgroundImageFile property. | ||||
302 | */ | ||||
303 | class BackgroundImageFile | ||||
304 | { | ||||
305 | | ||||
306 | public: | ||||
307 | struct Fields { | ||||
308 | static const QString Id; | ||||
309 | static const QString XCoordinate; | ||||
310 | static const QString YCoordinate; | ||||
311 | static const QString Width; | ||||
312 | }; | ||||
313 | | ||||
314 | BackgroundImageFile(); | ||||
315 | BackgroundImageFile(const BackgroundImageFile &other); | ||||
316 | ~BackgroundImageFile(); | ||||
317 | bool operator==(const BackgroundImageFile &other) const; | ||||
318 | bool operator!=(const BackgroundImageFile &other) const { return !operator==(other); } | ||||
319 | | ||||
320 | /** | ||||
321 | * @brief Returns the ID of an image file in Google Drive | ||||
322 | * to use for the background image. | ||||
323 | */ | ||||
324 | QString id() const; | ||||
325 | | ||||
326 | /** | ||||
327 | * @brief Sets the ID of an image file in Google Drive to | ||||
328 | * use for the background image. | ||||
329 | * | ||||
330 | * @param id | ||||
331 | */ | ||||
332 | void setId(const QString &id) const; | ||||
333 | | ||||
334 | /** | ||||
335 | * @brief Returns the X coordinate of the upper left corner of | ||||
336 | * the cropping area in the background image. This is a value | ||||
337 | * in the closed range of 0 to 1. This value represents the | ||||
338 | * horizontal distance from the left side of the entire image | ||||
339 | * to the left side of the cropping area divided by the width | ||||
340 | * of the entire image. | ||||
341 | */ | ||||
342 | float xCoordinate() const; | ||||
343 | | ||||
344 | /** | ||||
345 | * @brief Returns the X coordinate of the upper left corner of | ||||
346 | * the cropping area in the background image. This is a value | ||||
347 | * in the closed range of 0 to 1. This value represents the | ||||
348 | * horizontal distance from the left side of the entire image | ||||
349 | * to the left side of the cropping area divided by the width | ||||
350 | * of the entire image. | ||||
351 | * | ||||
352 | * @param xCoordinate | ||||
353 | */ | ||||
354 | void setXCoordinate(float xCoordinate) const; | ||||
355 | | ||||
356 | /** | ||||
357 | * @brief Returns the Y coordinate of the upper left corner of the | ||||
358 | * cropping area in the background image. This is a value in the | ||||
359 | * closed range of 0 to 1. This value represents the vertical | ||||
360 | * distance from the top side of the entire image to the top side | ||||
361 | * of the cropping area divided by the height of the entire image. | ||||
362 | */ | ||||
363 | float yCoordinate() const; | ||||
364 | | ||||
365 | /** | ||||
366 | * @brief Sets the Y coordinate of the upper left corner of the | ||||
367 | * cropping area in the background image. This is a value in the | ||||
368 | * closed range of 0 to 1. This value represents the vertical | ||||
369 | * distance from the top side of the entire image to the top side | ||||
370 | * of the cropping area divided by the height of the entire image. | ||||
371 | * | ||||
372 | * @param yCoordinate | ||||
373 | */ | ||||
374 | void setYCoordinate(float yCoordinate) const; | ||||
375 | | ||||
376 | /** | ||||
377 | * @brief Returns the width of the cropped image in the closed | ||||
378 | * range of 0 to 1. This value represents the width of the cropped | ||||
379 | * image divided by the width of the entire image. The height is | ||||
380 | * computed by applying a width to height aspect ratio of 80 to 9. | ||||
381 | * The resulting image must be at least 1280 pixels wide and | ||||
382 | * 144 pixels high. | ||||
383 | */ | ||||
384 | float width() const; | ||||
385 | | ||||
386 | /** | ||||
387 | * @brief Sets the width of the cropped image in the closed | ||||
388 | * range of 0 to 1. This value represents the width of the cropped | ||||
389 | * image divided by the width of the entire image. The height is | ||||
390 | * computed by applying a width to height aspect ratio of 80 to 9. | ||||
391 | * The resulting image must be at least 1280 pixels wide and | ||||
392 | * 144 pixels high. | ||||
393 | * | ||||
394 | * @param width | ||||
395 | */ | ||||
396 | void setWidth(float width) const; | ||||
397 | | ||||
398 | private: | ||||
399 | class Private; | ||||
400 | QScopedPointer<Private> const d; | ||||
401 | friend class Private; | ||||
402 | friend class Drives; | ||||
403 | }; | ||||
404 | | ||||
405 | typedef QSharedPointer<BackgroundImageFile> BackgroundImageFilePtr; | ||||
406 | | ||||
407 | struct Fields { | ||||
408 | static const QString Kind; | ||||
409 | static const QString Items; | ||||
410 | static const QString KindDrive; | ||||
411 | static const QString PageToken; | ||||
412 | static const QString NextPageToken; | ||||
413 | static const QString Id; | ||||
414 | static const QString Name; | ||||
415 | static const QString ThemeId; | ||||
416 | static const QString ColorRgb; | ||||
417 | static const QString BackgroundImageFile; | ||||
418 | static const QString BackgroundImageLink; | ||||
419 | static const QString Capabilities; | ||||
420 | static const QString CreatedDate; | ||||
421 | static const QString Hidden; | ||||
422 | static const QString Restrictions; | ||||
423 | }; | ||||
424 | | ||||
425 | Drives(); | ||||
426 | Drives(const Drives &other); | ||||
427 | ~Drives() override; | ||||
428 | bool operator==(const Drives &other) const; | ||||
429 | bool operator!=(const Drives &other) const { return !operator==(other); } | ||||
430 | | ||||
431 | /** | ||||
432 | * @brief Returns the ID of this shared drive which | ||||
433 | * is also the ID of the top level folder of this | ||||
434 | * shared drive. | ||||
435 | */ | ||||
436 | QString id() const; | ||||
437 | | ||||
438 | /** | ||||
439 | * @brief Sets the ID of this shared drive which | ||||
440 | * is also the ID of the top level folder of this | ||||
441 | * shared drive. | ||||
442 | * | ||||
443 | * @param id | ||||
444 | */ | ||||
445 | void setId(const QString &id) const; | ||||
446 | | ||||
447 | /** | ||||
448 | * @brief Returns the name of the drive. | ||||
449 | */ | ||||
450 | QString name() const; | ||||
451 | | ||||
452 | /** | ||||
453 | * @brief Sets the name of the drive. | ||||
454 | * | ||||
455 | * @param name | ||||
456 | */ | ||||
457 | void setName(const QString &name) const; | ||||
458 | | ||||
459 | /** | ||||
460 | * @brief Returns the themeId of the drive. | ||||
461 | */ | ||||
462 | QString themeId() const; | ||||
463 | | ||||
464 | /** | ||||
465 | * @brief Sets the themeId of the shared drive. | ||||
466 | * | ||||
467 | * @param themeId | ||||
468 | */ | ||||
469 | void setThemeId(const QString &themeId) const; | ||||
470 | | ||||
471 | /** | ||||
472 | * @brief Returns the colorRgb of the shared drive. | ||||
473 | */ | ||||
474 | QString colorRgb() const; | ||||
475 | | ||||
476 | /** | ||||
477 | * @brief Sets the colorRgb of the shared drive. | ||||
478 | * | ||||
479 | * @param colorRgb | ||||
480 | */ | ||||
481 | void setColorRgb(const QString &colorRgb) const; | ||||
482 | | ||||
483 | /** | ||||
484 | * @brief Returns the image file and cropping parameters from which a background image for this shared drive is set. | ||||
485 | */ | ||||
486 | BackgroundImageFilePtr backgroundImageFile() const; | ||||
487 | | ||||
488 | /** | ||||
489 | * @brief Sets the backgroundImageFile of the shared drive. | ||||
490 | * | ||||
491 | * @param backgroundImageFile | ||||
492 | */ | ||||
493 | void setBackgroundImageFile(const BackgroundImageFilePtr &backgroundImageFile) const; | ||||
494 | | ||||
495 | /** | ||||
496 | * @brief Returns the backgroundImageLink of the shared drive. | ||||
497 | */ | ||||
498 | QString backgroundImageLink() const; | ||||
499 | | ||||
500 | /** | ||||
501 | * @brief Returns the capabilities the current user has on this shared drive. | ||||
502 | */ | ||||
503 | CapabilitiesPtr capabilities() const; | ||||
504 | | ||||
505 | /** | ||||
506 | * @brief Returns the time at which the shared drive was created. | ||||
507 | */ | ||||
508 | QDateTime createdDate() const; | ||||
509 | | ||||
510 | /** | ||||
511 | * @brief Returns whether the shared drive is hidden from default view. | ||||
512 | */ | ||||
513 | bool hidden() const; | ||||
514 | | ||||
515 | /** | ||||
516 | * @brief Returns the set of restrictions that apply to this shared drive or | ||||
517 | * items inside this shared drive. | ||||
518 | */ | ||||
519 | RestrictionsPtr restrictions() const; | ||||
520 | | ||||
521 | /** | ||||
522 | * @brief Sets the restrictions of the shared drive. | ||||
523 | * | ||||
524 | * @param restrictions | ||||
525 | */ | ||||
526 | void setRestrictions(const RestrictionsPtr &restrictions) const; | ||||
527 | | ||||
528 | static DrivesPtr fromJSON(const QByteArray &jsonData); | ||||
529 | static DrivesList fromJSONFeed(const QByteArray &jsonData, FeedData &feedData); | ||||
530 | static QByteArray toJSON(const DrivesPtr &drives); | ||||
531 | | ||||
532 | private: | ||||
533 | class Private; | ||||
534 | QScopedPointer<Private> const d; | ||||
535 | friend class Private; | ||||
536 | }; | ||||
537 | | ||||
538 | } /* namespace Drive */ | ||||
539 | | ||||
540 | } /* namespace KGAPI2 */ | ||||
541 | | ||||
542 | #endif // LIBKGAPI2_DRIVEDRIVES_H |