File indexing completed on 2024-05-12 05:22:16
0001 /* 0002 SPDX-FileCopyrightText: 2012 Andrius da Costa Ribas <andriusmao@gmail.com> 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 <QSharedPointer> 0014 #include <QString> 0015 #include <QStringList> 0016 #include <QUrl> 0017 0018 namespace KGAPI2 0019 { 0020 0021 namespace Drive 0022 { 0023 0024 /** 0025 * @brief DriveAbout contains information about the current user along with 0026 * Google Drive API settings. 0027 * 0028 * Getters and setters' documentation is based on Google Drive's API v2 reference 0029 * @see <a href="https://developers.google.com/drive/v2/reference/about">About</a> 0030 * 0031 * @since 2.0 0032 * @author Andrius da Costa Ribas <andriusmao@gmail.com> 0033 * @author Daniel Vrátil <dvratil@redhat.com> 0034 */ 0035 class KGAPIDRIVE_EXPORT About : public KGAPI2::Object 0036 { 0037 public: 0038 /** 0039 * @brief DriveAbout::Format holds the structure used for importFormats[] 0040 * and exportFormats[] properties. 0041 */ 0042 class Format 0043 { 0044 public: 0045 explicit Format(const Format &other); 0046 virtual ~Format(); 0047 bool operator==(const Format &other) const; 0048 bool operator!=(const Format &other) const 0049 { 0050 return !operator==(other); 0051 } 0052 0053 /** 0054 * @brief Returns the content type to convert from. 0055 */ 0056 QString source() const; 0057 0058 /** 0059 * @brief Returns the possible content types to convert to. 0060 */ 0061 QStringList targets() const; 0062 0063 private: 0064 explicit Format(); 0065 0066 class Private; 0067 Private *const d; 0068 friend class Private; 0069 friend class About; 0070 }; 0071 0072 using FormatPtr = QSharedPointer<Format>; 0073 using FormatsList = QList<FormatPtr>; 0074 0075 /** 0076 * @brief DriveAbout::AdditionalRoleInfo holds the structure used for 0077 * additionalRoleInfo[] property. 0078 */ 0079 class AdditionalRoleInfo 0080 { 0081 public: 0082 /** 0083 * @brief DriveAbout::AdditionalRoleInfo::Role holds the structure used for 0084 * additionalRoleInfo[].roleSets[] property. 0085 */ 0086 class RoleSet 0087 { 0088 public: 0089 explicit RoleSet(const RoleSet &other); 0090 virtual ~RoleSet(); 0091 bool operator==(const RoleSet &other) const; 0092 bool operator!=(const RoleSet &other) const 0093 { 0094 return !operator==(other); 0095 } 0096 0097 /** 0098 * @brief Returns the primary permission role. 0099 */ 0100 QString primaryRole() const; 0101 0102 /** 0103 * @brief Returns the supported additional roles with the primary role. 0104 */ 0105 QStringList additionalRoles() const; 0106 0107 private: 0108 explicit RoleSet(); 0109 0110 class Private; 0111 Private *const d; 0112 friend class Private; 0113 friend class About; 0114 }; 0115 0116 using RoleSetPtr = QSharedPointer<RoleSet>; 0117 using RoleSetsList = QList<RoleSetPtr>; 0118 0119 explicit AdditionalRoleInfo(const AdditionalRoleInfo &other); 0120 virtual ~AdditionalRoleInfo(); 0121 bool operator==(const AdditionalRoleInfo &other) const; 0122 bool operator!=(const AdditionalRoleInfo &other) const 0123 { 0124 return !operator==(other); 0125 } 0126 0127 /** 0128 * @brief Returns the content type that this additional role info applies to. 0129 */ 0130 [[nodiscard]] QString type() const; 0131 0132 /** 0133 * @brief Returns the supported additional roles per primary role. 0134 */ 0135 [[nodiscard]] RoleSetsList roleSets() const; 0136 0137 private: 0138 explicit AdditionalRoleInfo(); 0139 0140 class Private; 0141 Private *const d; 0142 friend class Private; 0143 friend class About; 0144 }; 0145 0146 using AdditionalRoleInfoPtr = QSharedPointer<AdditionalRoleInfo>; 0147 using AdditionalRoleInfosList = QList<AdditionalRoleInfoPtr>; 0148 0149 /** 0150 * @brief DriveAbout::Feature holds the structure used for features[] property. 0151 */ 0152 class Feature 0153 { 0154 public: 0155 explicit Feature(const Feature &other); 0156 virtual ~Feature(); 0157 bool operator==(const Feature &other) const; 0158 bool operator!=(const Feature &other) const 0159 { 0160 return !operator==(other); 0161 } 0162 0163 /** 0164 * @brief Returns the name of the feature. 0165 */ 0166 QString featureName() const; 0167 0168 /** 0169 * @brief Returns the request limit rate for this feature, in queries per second. 0170 */ 0171 qreal featureRate() const; 0172 0173 private: 0174 explicit Feature(); 0175 0176 class Private; 0177 Private *const d; 0178 friend class Private; 0179 friend class About; 0180 }; 0181 0182 using FeaturePtr = QSharedPointer<Feature>; 0183 using FeaturesList = QList<FeaturePtr>; 0184 0185 /** 0186 * @brief DriveAbout::MaxUploadSize holds the structure used for maxUploadSizes[] property. 0187 */ 0188 class MaxUploadSize 0189 { 0190 public: 0191 explicit MaxUploadSize(const MaxUploadSize &other); 0192 virtual ~MaxUploadSize(); 0193 bool operator==(const MaxUploadSize &other) const; 0194 bool operator!=(const MaxUploadSize &other) const 0195 { 0196 return !operator==(other); 0197 } 0198 0199 /** 0200 * @brief Returns the file type. 0201 */ 0202 QString type() const; 0203 0204 /** 0205 * @brief Returns the max upload size for this type. 0206 */ 0207 qlonglong size() const; 0208 0209 private: 0210 explicit MaxUploadSize(); 0211 0212 class Private; 0213 Private *const d; 0214 friend class Private; 0215 friend class About; 0216 }; 0217 0218 using MaxUploadSizePtr = QSharedPointer<MaxUploadSize>; 0219 using MaxUploadSizesList = QList<MaxUploadSizePtr>; 0220 0221 struct KGAPIDRIVE_EXPORT Fields { 0222 static const QString AdditionalRoleInfo; 0223 static const QString AdditionalRoles; 0224 static const QString BackgroundImageLink; 0225 static const QString BytesUsed; 0226 static const QString CanCreateDrives; 0227 static const QString ColorRgb; 0228 static const QString DisplayName; 0229 static const QString DomainSharingPolicy; 0230 static const QString EmailAddress; 0231 static const QString Etag; 0232 static const QString ExportFormats; 0233 static const QString FeatureName; 0234 static const QString FeatureRate; 0235 static const QString Features; 0236 static const QString FolderColorPalette; 0237 static const QString Id; 0238 static const QString ImportFormats; 0239 static const QString IsAuthenticatedUser; 0240 static const QString IsCurrentAppInstalled; 0241 static const QString Kind; 0242 static const QString LanguageCode; 0243 static const QString LargestChangeId; 0244 static const QString MaxUploadSizes; 0245 static const QString Name; 0246 static const QString PermissionId; 0247 static const QString Picture; 0248 static const QString PrimaryRole; 0249 static const QString QuotaBytesByService; 0250 static const QString QuotaBytesTotal; 0251 static const QString QuotaBytesUsed; 0252 static const QString QuotaBytesUsedAggregate; 0253 static const QString QuotaBytesUsedInTrash; 0254 static const QString QuotaType; 0255 static const QString RemainingChangeIds; 0256 static const QString RoleSets; 0257 static const QString RootFolderId; 0258 static const QString SelfLink; 0259 static const QString ServiceName; 0260 static const QString Size; 0261 static const QString Source; 0262 static const QString Targets; 0263 static const QString TeamDriveThemes; 0264 static const QString Type; 0265 static const QString Url; 0266 static const QString User; 0267 }; 0268 0269 About(const About &other); 0270 ~About() override; 0271 0272 bool operator==(const About &other) const; 0273 bool operator!=(const About &other) const 0274 { 0275 return !operator==(other); 0276 } 0277 0278 /** 0279 * @brief Returns the link back to this item. 0280 */ 0281 QUrl selfLink() const; 0282 0283 /** 0284 * @brief Returns the name of the current user. 0285 */ 0286 QString name() const; 0287 0288 /** 0289 * @brief Returns the total number of quota bytes. 0290 */ 0291 qlonglong quotaBytesTotal() const; 0292 0293 /** 0294 * @brief Returns the total number of quota bytes used. 0295 */ 0296 qlonglong quotaBytesUsed() const; 0297 0298 /** 0299 * @brief Returns the total number of quota bytes used by trashed items. 0300 */ 0301 qlonglong quotaBytesUsedInTrash() const; 0302 0303 /** 0304 * @brief returns the total number of quota bytes used by all Google apps 0305 * (Drive, Picasa, etc.). 0306 * @since 5.3.2 0307 */ 0308 qlonglong quotaBytesUsedAggregate() const; 0309 0310 /** 0311 * @brief returns the total number of quota bytes used by all Google apps 0312 * (Drive, Picasa, etc.). 0313 * @deprecated since 5.3.2, use quotaBytesUsedAggregate() instead. 0314 */ 0315 #ifndef KGAPIDRIVE_NO_DEPRECATED 0316 KGAPIDRIVE_DEPRECATED qlonglong quotaBytesUserAggregate() const; 0317 #endif 0318 0319 /** 0320 * @brief Returns the largest change id. 0321 */ 0322 qlonglong largestChangeId() const; 0323 0324 /** 0325 * @brief Returns the number of remaining change ids. 0326 */ 0327 qlonglong remainingChangeIds() const; 0328 0329 /** 0330 * @brief Returns the id of the root folder. 0331 */ 0332 QString rootFolderId() const; 0333 0334 /** 0335 * @brief Returns the domain sharing policy for the current user. 0336 */ 0337 QString domainSharingPolicy() const; 0338 0339 /** 0340 * @brief Returns the allowable import formats. 0341 */ 0342 FormatsList importFormats() const; 0343 0344 /** 0345 * @brief Returns the allowable export formats. 0346 */ 0347 FormatsList exportFormats() const; 0348 0349 /** 0350 * @brief Returns information about supported additional roles per file type. 0351 * 0352 * The most specific type takes precedence. 0353 */ 0354 AdditionalRoleInfosList additionalRoleInfo() const; 0355 0356 /** 0357 * @brief Returns the list of additional features enabled on this account. 0358 */ 0359 FeaturesList features() const; 0360 0361 /** 0362 * @brief Returns the list of max upload sizes for each file type. 0363 * 0364 * The most specific type takes precedence. 0365 */ 0366 MaxUploadSizesList maxUploadSizes() const; 0367 0368 /** 0369 * @brief Returns the current user's ID as visible in the permissions collection. 0370 */ 0371 QString permissionId() const; 0372 0373 /** 0374 * @brief Returns whether the authenticated app is installed by the authenticated user. 0375 */ 0376 bool isCurrentAppInstalled() const; 0377 0378 /** 0379 * @brief Returns the authenticated user. 0380 */ 0381 UserPtr user() const; 0382 0383 /** 0384 * @brief Returns whether the user can create shared drives. 0385 */ 0386 bool canCreateDrives() const; 0387 0388 /** 0389 * @brief Constructs a new DriveAbout object from given JSON data 0390 * 0391 * @param jsonData 0392 */ 0393 static AboutPtr fromJSON(const QByteArray &jsonData); 0394 0395 private: 0396 About(); 0397 0398 class Private; 0399 QScopedPointer<Private> const d; 0400 friend class Private; 0401 }; 0402 0403 } /* namespace Drive */ 0404 0405 } /* namespace KGAPI2 */