File indexing completed on 2024-05-12 05:22:22
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 <QString> 0014 #include <QUrl> 0015 0016 #include <QDateTime> 0017 0018 namespace KGAPI2 0019 { 0020 0021 namespace Drive 0022 { 0023 0024 /** 0025 * @brief Revision contains a revision of a file. 0026 * 0027 * Getters and setters' documentation is based on Google Drive's API v2 reference 0028 * @see <a href="https://developers.google.com/drive/v2/reference/revisions">Revisions</a> 0029 * 0030 * @since 2.0 0031 * @author Andrius da Costa Ribas <andriusmao@gmail.com> 0032 * @author Daniel Vrátil <dvratil@redhat.com> 0033 */ 0034 class KGAPIDRIVE_EXPORT Revision : public KGAPI2::Object 0035 { 0036 public: 0037 explicit Revision(); 0038 explicit Revision(const Revision &other); 0039 ~Revision() override; 0040 bool operator==(const Revision &other) const; 0041 bool operator!=(const Revision &other) const 0042 { 0043 return !operator==(other); 0044 } 0045 0046 /** 0047 * @brief Returns the id of the revision. 0048 */ 0049 [[nodiscard]] QString id() const; 0050 0051 /** 0052 * @brief Returns a link back to this revision. 0053 */ 0054 [[nodiscard]] QUrl selfLink() const; 0055 0056 /** 0057 * @brief Returns the MIME type of the revision. 0058 */ 0059 [[nodiscard]] QString mimeType() const; 0060 0061 /** 0062 * @brief Returns the last time this revision was modified. 0063 */ 0064 [[nodiscard]] QDateTime modifiedDate() const; 0065 0066 /** 0067 * @brief Returns whether this revision is pinned to prevent automatic purging. 0068 * 0069 * This will only be populated and can only be modified on files with content 0070 * stored in Drive which are not Google Docs. 0071 * 0072 * Revisions can also be pinned when they are created through the 0073 * drive.files.insert/update/copy by using the pinned query parameter. 0074 */ 0075 [[nodiscard]] bool pinned() const; 0076 0077 /** 0078 * @brief Sets whether this revision is pinned to prevent automatic purging. 0079 * 0080 * This will only be populated and can only be modified on files with content 0081 * stored in Drive which are not Google Docs. 0082 * 0083 * Revisions can also be pinned when they are created through the 0084 * drive.files.insert/update/copy by using the pinned query parameter. 0085 * 0086 * @param pinned 0087 */ 0088 void setPinned(bool pinned); 0089 0090 /** 0091 * @brief Returns whether this revision is published. 0092 * 0093 * This is only populated and can only be modified for Google Docs. 0094 */ 0095 [[nodiscard]] bool published() const; 0096 0097 /** 0098 * @brief Sets whether this revision is published. 0099 * 0100 * @param published 0101 */ 0102 void setPublished(bool published); 0103 0104 /** 0105 * @brief Returns a link to the published revision. 0106 */ 0107 [[nodiscard]] QUrl publishedLink() const; 0108 0109 /** 0110 * @brief Returns whether subsequent revisions will be automatically republished. 0111 * 0112 * This is only populated and can only be modified for Google Docs. 0113 */ 0114 [[nodiscard]] bool publishAuto() const; 0115 0116 /** 0117 * @brief Sets whether subsequent revisions will be automatically republished. 0118 * 0119 * This is only populated and can only be modified for Google Docs. 0120 * 0121 * @param publishAuto 0122 */ 0123 void setPublishAuto(bool publishAuto); 0124 0125 /** 0126 * @brief Returns whether this revision is published outside the domain. 0127 * 0128 * This is only populated and can only be modified for Google Docs. 0129 */ 0130 [[nodiscard]] bool publishedOutsideDomain() const; 0131 0132 /** 0133 * @brief Sets whether this revision is published outside the domain. 0134 * 0135 * This is only populated and can only be modified for Google Docs. 0136 * 0137 * @param publishedOutsideDomain 0138 */ 0139 void setPublishedOutsideDomain(bool publishedOutsideDomain); 0140 0141 /** 0142 * @brief Returns a short term download URL for the file. 0143 * 0144 * This will only be populated on files with content stored in Drive. 0145 */ 0146 [[nodiscard]] QUrl downloadUrl() const; 0147 0148 /** 0149 * @brief Returns the links for exporting Google Docs to specific formats. 0150 * 0151 * This is a map from the export format to URL. 0152 */ 0153 QMap<QString /* format */, QUrl /* url */> exportLinks() const; 0154 0155 /** 0156 * @brief Returns the name of the last user to modify this revision. 0157 */ 0158 [[nodiscard]] QString lastModifyingUserName() const; 0159 0160 /** 0161 * @brief Returns object representing the last user to modify this revision 0162 */ 0163 [[nodiscard]] UserPtr lastModifyingUser() const; 0164 0165 /** 0166 * @brief Returns the original filename when this revision was created. 0167 * 0168 * This will only be populated on files with content stored in Drive. 0169 */ 0170 [[nodiscard]] QString originalFilename() const; 0171 0172 /** 0173 * @brief Returns an MD5 checksum for the content of this revision. 0174 * 0175 * This will only be populated on files with content stored in Drive 0176 */ 0177 [[nodiscard]] QString md5Checksum() const; 0178 0179 /** 0180 * @brief Returns the size of the revision in bytes. 0181 * 0182 * This will only be populated on files with content stored in Drive. 0183 */ 0184 [[nodiscard]] qlonglong fileSize() const; 0185 0186 static RevisionPtr fromJSON(const QByteArray &jsonData); 0187 static RevisionsList fromJSONFeed(const QByteArray &jsonData); 0188 static QByteArray toJSON(const RevisionPtr &revision); 0189 0190 private: 0191 class Private; 0192 Private *const d; 0193 friend class Private; 0194 }; 0195 0196 } /* namespace Drive */ 0197 0198 } /* namespace KGAPI2 */