Kgapi

permission.h
1/*
2 SPDX-FileCopyrightText: 2012 Andrius da Costa Ribas <andriusmao@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#pragma once
8
9#include "file.h"
10#include "kgapidrive_export.h"
11#include "object.h"
12#include "types.h"
13
14#include <QString>
15#include <QUrl>
16
17namespace KGAPI2
18{
19
20namespace Drive
21{
22
23/**
24 * @brief Permission contains a permission for a file.
25 *
26 * Getters and setters' documentation is based on Google Drive's API v2 reference
27 * @see <a href="https://developers.google.com/drive/v2/reference/permissions">Permissions</a>
28 *
29 * @since 2.0
30 * @author Andrius da Costa Ribas <andriusmao@gmail.com>
31 * @author Daniel Vrátil <dvratil@redhat.com>
32 */
33class KGAPIDRIVE_EXPORT Permission : public KGAPI2::Object
34{
35public:
36 enum Role {
37 UndefinedRole = -1,
38 OwnerRole = 0,
39 ReaderRole = 1,
40 WriterRole = 2,
41 CommenterRole = 3,
42 OrganizerRole = 4,
43 FileOrganizerRole = 5,
44 };
45
46 enum Type { UndefinedType = -1, TypeUser = 0, TypeGroup = 1, TypeDomain = 2, TypeAnyone = 3 };
47
48 /**
49 * @brief Details of whether the permissions on this shared drive item are
50 * inherited or directly on this item. This is an output-only field which
51 * is present only for shared drive items.
52 */
54 {
55 public:
56 enum PermissionType {
57 UndefinedType = -1,
58 TypeFile = 0,
59 TypeMember = 1,
60 };
61
65 bool operator==(const PermissionDetails &other) const;
66 bool operator!=(const PermissionDetails &other) const
67 {
68 return !operator==(other);
69 }
70
71 /**
72 * @brief The permission type for this user.
73 */
74 PermissionDetails::PermissionType permissionType() const;
75
76 /**
77 * @brief The primary role for this user.
78 */
79 [[nodiscard]] Permission::Role role() const;
80
81 /**
82 * @brief Additional roles for this user. Only commenter is currently possible,
83 * though more may be supported in the future.
84 */
85 [[nodiscard]] QList<Permission::Role> additionalRoles() const;
86
87 /**
88 * @brief The ID of the item from which this permission is inherited.
89 * This is an output-only field and is only populated for members of
90 * the shared drive.
91 */
92 [[nodiscard]] QString inheritedFrom() const;
93
94 /**
95 * @brief Whether this permission is inherited. This field is always populated. This is an output-only field.
96 */
97 [[nodiscard]] bool inherited() const;
98
99 private:
100 class Private;
102 friend class Private;
103 friend class Permission;
104 };
105
108
109 explicit Permission();
110 explicit Permission(const Permission &other);
111 ~Permission() override;
112 bool operator==(const Permission &other) const;
113 bool operator!=(const Permission &other) const
114 {
115 return !operator==(other);
116 }
117
118 /**
119 * @brief Returns the id of the permission.
120 */
121 QString id() const;
122
123 /**
124 * @brief Sets the id of the permission.
125 *
126 * @param id
127 */
128 void setId(const QString &id);
129
130 /**
131 * @brief Returns a link back to this permission.
132 */
133 QUrl selfLink() const;
134
135 /**
136 * @brief Returns the name of this permission.
137 */
138 QString name() const;
139
140 /**
141 * @brief Returns the primary role for this user.
142 */
143 Permission::Role role() const;
144
145 /**
146 * @brief Sets the primary role for this user.
147 */
148 void setRole(Permission::Role role);
149
150 /**
151 * @brief Returns additional roles for this user. Only commenter is currently allowed.
152 */
153 QList<Role> additionalRoles() const;
154
155 /**
156 * @brief Sets additional roles for this user. Only commenter is currently allowed.
157 *
158 * @param additionalRoles
159 */
160 void setAdditionalRoles(const QList<Role> &additionalRoles);
161
162 /**
163 * @brief Returns the account type.
164 */
165 Permission::Type type() const;
166
167 /**
168 * @brief Sets the account type.
169 *
170 * @param type
171 */
172 void setType(Permission::Type type);
173
174 /**
175 * @brief Returns the authkey parameter required for this permission.
176 */
177 QString authKey() const;
178
179 /**
180 * @brief Returns whether the link is required for this permission.
181 */
182 bool withLink() const;
183
184 /**
185 * @brief Sets whether the link is required for this permission.
186 *
187 * @param withLink
188 */
189 void setWithLink(bool withLink);
190
191 /**
192 * @brief Returns a link to the profile photo, if available.
193 */
194 QUrl photoLink() const;
195
196 /**
197 * @brief Returns the email address or domain name for the entity.
198 *
199 * This is not populated in responses.
200 * You can use the alias "me" as the value for this property to refer to the
201 * current authorized user.
202 */
203 QString value() const;
204
205 /**
206 * @brief Sets the email address or domain name for the entity.
207 *
208 * This is not populated in responses.
209 * You can use the alias "me" as the value for this property to refer to the
210 * current authorized user.
211 *
212 * @param value
213 */
214 void setValue(const QString &value);
215
216 /**
217 * @brief The email address of the user or group this permission refers to.
218 * This is an output-only field which is present when the permission type is
219 * user or group.
220 */
221 QString emailAddress() const;
222
223 /**
224 * @brief The domain name of the entity this permission refers to.
225 * This is an output-only field which is present when the permission
226 * type is user, group or domain.
227 */
228 QString domain() const;
229
230 /**
231 * @brief The time at which this permission will expire.
232 */
233 QDateTime expirationDate() const;
234
235 /**
236 * @brief Whether the account associated with this permission has been
237 * deleted. This field only pertains to user and group permissions.
238 */
239 bool deleted() const;
240
241 /**
242 * @brief Details of whether the permissions on this shared drive
243 * item are inherited or directly on this item.
244 */
245 Permission::PermissionDetailsList permissionDetails() const;
246
247 static PermissionPtr fromJSON(const QByteArray &jsonData);
248 static PermissionsList fromJSONFeed(const QByteArray &jsonData);
249 static QByteArray toJSON(const PermissionPtr &permission);
250
251private:
252 class Private;
253 Private *const d;
254 friend class Private;
255 friend class File::Private;
256};
257
258} /* namespace Drive */
259
260} /* namespace KGAPI2 */
Details of whether the permissions on this shared drive item are inherited or directly on this item.
Definition permission.h:54
Permission contains a permission for a file.
Definition permission.h:34
Base class for all objects.
Definition object.h:31
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 Sat Dec 21 2024 17:00:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.