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

0001 /*
0002     SPDX-FileCopyrightText: 2019 David Barchiesi <david@barchie.si>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kgapidrive_export.h"
0010 #include "object.h"
0011 #include "types.h"
0012 
0013 #include <QString>
0014 
0015 #include <QDateTime>
0016 
0017 namespace KGAPI2
0018 {
0019 
0020 namespace Drive
0021 {
0022 
0023 /**
0024  * @brief Drives contains a representation of a Drive.
0025  *
0026  * Getters and setters' documentation is based on Google Drive's API v2 reference
0027  * @see <a href="https://developers.google.com/drive/v2/reference/drives">Drives</a>
0028  *
0029  * @since 5.11.41
0030  * @author David Barchiesi <david@barchie.si>
0031  */
0032 class KGAPIDRIVE_EXPORT Drives : public KGAPI2::Object
0033 {
0034 public:
0035     /**
0036      * @brief Drives::Restrictions holds the structure used for
0037      * a set of restrictions that apply to this shared drive
0038      * or items inside this shared drive.
0039      */
0040     class Restrictions
0041     {
0042     public:
0043         struct Fields {
0044             static const QString AdminManagedRestrictions;
0045             static const QString CopyRequiresWriterPermission;
0046             static const QString DomainUsersOnly;
0047             static const QString DriveMembersOnly;
0048         };
0049 
0050         Restrictions();
0051         Restrictions(const Restrictions &other);
0052         ~Restrictions();
0053         bool operator==(const Restrictions &other) const;
0054         bool operator!=(const Restrictions &other) const
0055         {
0056             return !operator==(other);
0057         }
0058 
0059         /**
0060          * @brief Returns whether administrative privileges on this shared
0061          * drive are required to modify restrictions.
0062          */
0063         bool adminManagedRestrictions() const;
0064 
0065         /**
0066          * @brief Sets whether administrative privileges on this shared drive
0067          * are required to modify restrictions.
0068          *
0069          * @param adminManagedRestrictions
0070          */
0071         void setAdminManagedRestrictions(bool adminManagedRestrictions) const;
0072 
0073         /**
0074          * @brief Returns whether the options to copy, print, or download files
0075          * inside this shared drive, should be disabled for readers and commenters.
0076          * When this restriction is set to true, it will override the similarly
0077          * named field to true for any file inside this shared drive.
0078          */
0079         [[nodiscard]] bool copyRequiresWriterPermission() const;
0080 
0081         /**
0082          * @brief Sets whether the options to copy, print, or download files
0083          * inside this shared drive, should be disabled for readers and commenters.
0084          * When this restriction is set to true, it will override the similarly
0085          * named field to true for any file inside this shared drive.
0086          *
0087          * @param copyRequiresWriterPermission
0088          */
0089         void setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const;
0090 
0091         /**
0092          * @brief Returns whether access to this shared drive and items inside
0093          * this shared drive is restricted to users of the domain to which this
0094          * shared drive belongs. This restriction may be overridden by other
0095          * sharing policies controlled outside of this shared drive.
0096          */
0097         [[nodiscard]] bool domainUsersOnly() const;
0098 
0099         /**
0100          * @brief Sets whether access to this shared drive and items inside this
0101          * shared drive is restricted to users of the domain to which this
0102          * shared drive belongs. This restriction may be overridden by other
0103          * sharing policies controlled outside of this shared drive.
0104          *
0105          * @param domainUsersOnly
0106          */
0107         void setDomainUsersOnly(bool domainUsersOnly) const;
0108 
0109         /**
0110          * @brief Returns whether access to items inside this shared drive is
0111          * restricted to its members.
0112          */
0113         [[nodiscard]] bool driveMembersOnly() const;
0114 
0115         /**
0116          * @brief Sets whether access to items inside this shared drive is
0117          * restricted to its members.
0118          *
0119          * @param driveMembersOnly
0120          */
0121         void setDriveMembersOnly(bool driveMembersOnly) const;
0122 
0123     private:
0124         class Private;
0125         QScopedPointer<Private> const d;
0126         friend class Private;
0127         friend class Drives;
0128     };
0129 
0130     using RestrictionsPtr = QSharedPointer<Restrictions>;
0131 
0132     /**
0133      * @brief Drives::Capabilities holds the structure used for
0134      * capabilities the current user has on this shared drive.
0135      */
0136     class Capabilities
0137     {
0138     public:
0139         struct Fields {
0140             static const QString CanAddChildren;
0141             static const QString CanChangeCopyRequiresWriterPermissionRestriction;
0142             static const QString CanChangeDomainUsersOnlyRestriction;
0143             static const QString CanChangeDriveBackground;
0144             static const QString CanChangeDriveMembersOnlyRestriction;
0145             static const QString CanComment;
0146             static const QString CanCopy;
0147             static const QString CanDeleteChildren;
0148             static const QString CanDeleteDrive;
0149             static const QString CanDownload;
0150             static const QString CanEdit;
0151             static const QString CanListChildren;
0152             static const QString CanManageMembers;
0153             static const QString CanReadRevisions;
0154             static const QString CanRename;
0155             static const QString CanRenameDrive;
0156             static const QString CanShare;
0157             static const QString CanTrashChildren;
0158         };
0159 
0160         Capabilities();
0161         Capabilities(const Capabilities &other);
0162         ~Capabilities();
0163         bool operator==(const Capabilities &other) const;
0164         bool operator!=(const Capabilities &other) const
0165         {
0166             return !operator==(other);
0167         }
0168 
0169         /**
0170          * @brief Returns whether the current user can add children to folders
0171          * in this shared drive.
0172          */
0173         bool canAddChildren() const;
0174 
0175         /**
0176          * @brief Returns whether the current user can change the
0177          * copyRequiresWriterPermission restriction of this shared drive.
0178          */
0179         bool canChangeCopyRequiresWriterPermissionRestriction() const;
0180 
0181         /**
0182          * @brief Returns whether the current user can change the domainUsersOnly
0183          * restriction of this shared drive.
0184          */
0185         bool canChangeDomainUsersOnlyRestriction() const;
0186 
0187         /**
0188          * @brief Returns whether the current user can change the background of
0189          * this shared drive.
0190          */
0191         bool canChangeDriveBackground() const;
0192 
0193         /**
0194          * @brief Returns whether the current user can change the driveMembersOnly
0195          * restriction of this shared drive.
0196          */
0197         bool canChangeDriveMembersOnlyRestriction() const;
0198 
0199         /**
0200          * @brief Returns Whether the current user can comment on files in
0201          * this shared drive.
0202          */
0203         bool canComment() const;
0204 
0205         /**
0206          * @brief Returns Whether the current user can copy files in this shared drive.
0207          */
0208         bool canCopy() const;
0209 
0210         /**
0211          * @brief Returns Whether the current user can delete children from
0212          * folders in this shared drive.
0213          */
0214         bool canDeleteChildren() const;
0215 
0216         /**
0217          * @brief Returns Whether the current user can delete this shared drive.
0218          *
0219          * Attempting to delete the shared drive may still fail if there are
0220          * untrashed items inside the shared drive.
0221          */
0222         bool canDeleteDrive() const;
0223 
0224         /**
0225          * @brief Returns Whether the current user can download files in this
0226          * shared drive.
0227          */
0228         bool canDownload() const;
0229 
0230         /**
0231          * @brief Returns Whether the current user can edit files in this
0232          * shared drive
0233          */
0234         bool canEdit() const;
0235 
0236         /**
0237          * @brief Returns Whether the current user can list the children of
0238          * folders in this shared drive.
0239          */
0240         bool canListChildren() const;
0241 
0242         /**
0243          * @brief Returns Whether the current user can add members to this shared drive
0244          * or remove them or change their role.
0245          */
0246         bool canManageMembers() const;
0247 
0248         /**
0249          * @brief Returns Whether the current user can read the revisions
0250          * resource of files in this shared drive.
0251          */
0252         bool canReadRevisions() const;
0253 
0254         /**
0255          * @brief Returns Whether the current user can rename files or folders
0256          * in this shared drive.
0257          */
0258         bool canRename() const;
0259 
0260         /**
0261          * @brief Returns Whether the current user can rename this shared drive.
0262          */
0263         bool canRenameDrive() const;
0264 
0265         /**
0266          * @brief Returns Whether the current user can share files or folders
0267          * in this shared drive.
0268          */
0269         bool canShare() const;
0270 
0271         /**
0272          * @brief Returns Whether the current user can trash children from
0273          * folders in this shared drive.
0274          */
0275         bool canTrashChildren() const;
0276 
0277     private:
0278         class Private;
0279         QScopedPointer<Private> const d;
0280         friend class Private;
0281         friend class Drives;
0282     };
0283 
0284     using CapabilitiesPtr = QSharedPointer<Capabilities>;
0285 
0286     /**
0287      * @brief Drives::BackgroundImageFile holds the structure used
0288      * for backgroundImageFile property.
0289      */
0290     class BackgroundImageFile
0291     {
0292     public:
0293         struct Fields {
0294             static const QString Id;
0295             static const QString XCoordinate;
0296             static const QString YCoordinate;
0297             static const QString Width;
0298         };
0299 
0300         BackgroundImageFile();
0301         BackgroundImageFile(const BackgroundImageFile &other);
0302         ~BackgroundImageFile();
0303         bool operator==(const BackgroundImageFile &other) const;
0304         bool operator!=(const BackgroundImageFile &other) const
0305         {
0306             return !operator==(other);
0307         }
0308 
0309         /**
0310          * @brief Returns the ID of an image file in Google Drive
0311          * to use for the background image.
0312          */
0313         QString id() const;
0314 
0315         /**
0316          * @brief Sets the ID of an image file in Google Drive to
0317          * use for the background image.
0318          *
0319          * @param id
0320          */
0321         void setId(const QString &id) const;
0322 
0323         /**
0324          * @brief Returns the X coordinate of the upper left corner of
0325          * the cropping area in the background image. This is a value
0326          * in the closed range of 0 to 1. This value represents the
0327          * horizontal distance from the left side of the entire image
0328          * to the left side of the cropping area divided by the width
0329          * of the entire image.
0330          */
0331         float xCoordinate() const;
0332 
0333         /**
0334          * @brief Returns the X coordinate of the upper left corner of
0335          * the cropping area in the background image. This is a value
0336          * in the closed range of 0 to 1. This value represents the
0337          * horizontal distance from the left side of the entire image
0338          * to the left side of the cropping area divided by the width
0339          * of the entire image.
0340          *
0341          * @param xCoordinate
0342          */
0343         void setXCoordinate(float xCoordinate) const;
0344 
0345         /**
0346          * @brief Returns the Y coordinate of the upper left corner of the
0347          * cropping area in the background image. This is a value in the
0348          * closed range of 0 to 1. This value represents the vertical
0349          * distance from the top side of the entire image to the top side
0350          * of the cropping area divided by the height of the entire image.
0351          */
0352         float yCoordinate() const;
0353 
0354         /**
0355          * @brief Sets the Y coordinate of the upper left corner of the
0356          * cropping area in the background image. This is a value in the
0357          * closed range of 0 to 1. This value represents the vertical
0358          * distance from the top side of the entire image to the top side
0359          * of the cropping area divided by the height of the entire image.
0360          *
0361          * @param yCoordinate
0362          */
0363         void setYCoordinate(float yCoordinate) const;
0364 
0365         /**
0366          * @brief Returns the width of the cropped image in the closed
0367          * range of 0 to 1. This value represents the width of the cropped
0368          * image divided by the width of the entire image. The height is
0369          * computed by applying a width to height aspect ratio of 80 to 9.
0370          * The resulting image must be at least 1280 pixels wide and
0371          * 144 pixels high.
0372          */
0373         float width() const;
0374 
0375         /**
0376          * @brief Sets the width of the cropped image in the closed
0377          * range of 0 to 1. This value represents the width of the cropped
0378          * image divided by the width of the entire image. The height is
0379          * computed by applying a width to height aspect ratio of 80 to 9.
0380          * The resulting image must be at least 1280 pixels wide and
0381          * 144 pixels high.
0382          *
0383          * @param width
0384          */
0385         void setWidth(float width) const;
0386 
0387     private:
0388         class Private;
0389         QScopedPointer<Private> const d;
0390         friend class Private;
0391         friend class Drives;
0392     };
0393 
0394     using BackgroundImageFilePtr = QSharedPointer<BackgroundImageFile>;
0395 
0396     struct Fields {
0397         static const QString Kind;
0398         static const QString Items;
0399         static const QString KindDrive;
0400         static const QString PageToken;
0401         static const QString NextPageToken;
0402         static const QString Id;
0403         static const QString Name;
0404         static const QString ThemeId;
0405         static const QString ColorRgb;
0406         static const QString BackgroundImageFile;
0407         static const QString BackgroundImageLink;
0408         static const QString Capabilities;
0409         static const QString CreatedDate;
0410         static const QString Hidden;
0411         static const QString Restrictions;
0412     };
0413 
0414     Drives();
0415     Drives(const Drives &other);
0416     ~Drives() override;
0417     bool operator==(const Drives &other) const;
0418     bool operator!=(const Drives &other) const
0419     {
0420         return !operator==(other);
0421     }
0422 
0423     /**
0424      * @brief Returns the ID of this shared drive which
0425      * is also the ID of the top level folder of this
0426      * shared drive.
0427      */
0428     QString id() const;
0429 
0430     /**
0431      * @brief Sets the ID of this shared drive which
0432      * is also the ID of the top level folder of this
0433      * shared drive.
0434      *
0435      * @param id
0436      */
0437     void setId(const QString &id) const;
0438 
0439     /**
0440      * @brief Returns the name of the drive.
0441      */
0442     QString name() const;
0443 
0444     /**
0445      * @brief Sets the name of the drive.
0446      *
0447      * @param name
0448      */
0449     void setName(const QString &name) const;
0450 
0451     /**
0452      * @brief Returns the themeId of the drive.
0453      */
0454     QString themeId() const;
0455 
0456     /**
0457      * @brief Sets the themeId of the shared drive.
0458      *
0459      * @param themeId
0460      */
0461     void setThemeId(const QString &themeId) const;
0462 
0463     /**
0464      * @brief Returns the colorRgb of the shared drive.
0465      */
0466     QString colorRgb() const;
0467 
0468     /**
0469      * @brief Sets the colorRgb of the shared drive.
0470      *
0471      * @param colorRgb
0472      */
0473     void setColorRgb(const QString &colorRgb) const;
0474 
0475     /**
0476      * @brief Returns the image file and cropping parameters from which a background image for this shared drive is set.
0477      */
0478     BackgroundImageFilePtr backgroundImageFile() const;
0479 
0480     /**
0481      * @brief Sets the backgroundImageFile of the shared drive.
0482      *
0483      * @param backgroundImageFile
0484      */
0485     void setBackgroundImageFile(const BackgroundImageFilePtr &backgroundImageFile) const;
0486 
0487     /**
0488      * @brief Returns the backgroundImageLink of the shared drive.
0489      */
0490     QString backgroundImageLink() const;
0491 
0492     /**
0493      * @brief Returns the capabilities the current user has on this shared drive.
0494      */
0495     CapabilitiesPtr capabilities() const;
0496 
0497     /**
0498      * @brief Returns the time at which the shared drive was created.
0499      */
0500     QDateTime createdDate() const;
0501 
0502     /**
0503      * @brief Returns whether the shared drive is hidden from default view.
0504      */
0505     bool hidden() const;
0506 
0507     /**
0508      * @brief Returns the set of restrictions that apply to this shared drive or
0509      * items inside this shared drive.
0510      */
0511     RestrictionsPtr restrictions() const;
0512 
0513     /**
0514      * @brief Sets the restrictions of the shared drive.
0515      *
0516      * @param restrictions
0517      */
0518     void setRestrictions(const RestrictionsPtr &restrictions) const;
0519 
0520     static DrivesPtr fromJSON(const QByteArray &jsonData);
0521     static DrivesList fromJSONFeed(const QByteArray &jsonData, FeedData &feedData);
0522     static QByteArray toJSON(const DrivesPtr &drives);
0523 
0524 private:
0525     class Private;
0526     QScopedPointer<Private> const d;
0527     friend class Private;
0528 };
0529 
0530 } /* namespace Drive */
0531 
0532 } /* namespace KGAPI2 */