9#include "permissionmodifyjob.h"
10#include "driveservice.h"
11#include "permission.h"
14#include <QNetworkReply>
15#include <QNetworkRequest>
19using namespace KGAPI2::Drive;
23static constexpr bool removeExpirationDefault =
false;
24static constexpr bool transferOwnershipDefault =
false;
25static constexpr bool useDomainAdminAccessDefault =
false;
28class Q_DECL_HIDDEN PermissionModifyJob::Private
31 Private(PermissionModifyJob *parent);
36 bool supportsAllDrives;
37 bool removeExpiration;
38 bool transferOwnership;
39 bool useDomainAdminAccess;
42 PermissionModifyJob *
const q;
45PermissionModifyJob::Private::Private(PermissionModifyJob *parent)
46 : supportsAllDrives(true)
47 , removeExpiration(removeExpirationDefault)
48 , transferOwnership(transferOwnershipDefault)
49 , useDomainAdminAccess(useDomainAdminAccessDefault)
54void PermissionModifyJob::Private::processNext()
62 QUrl url = DriveService::modifyPermissionUrl(fileId, permission->id());
65 query.addQueryItem(QStringLiteral(
"supportsAllDrives"), Utils::bool2Str(supportsAllDrives));
67 if (removeExpiration != removeExpirationDefault) {
68 query.addQueryItem(QStringLiteral(
"removeExpiration"), Utils::bool2Str(removeExpiration));
71 if (transferOwnership != transferOwnershipDefault) {
72 query.addQueryItem(QStringLiteral(
"transferOwnership"), Utils::bool2Str(transferOwnership));
75 if (useDomainAdminAccess != useDomainAdminAccessDefault) {
76 query.addQueryItem(QStringLiteral(
"useDomainAdminAccess"), Utils::bool2Str(useDomainAdminAccess));
82 const QByteArray rawData = Permission::toJSON(permission);
83 q->
enqueueRequest(request, rawData, QStringLiteral(
"application/json"));
88 , d(new Private(this))
91 d->permissions << permission;
96 , d(new Private(this))
99 d->permissions << permissions;
102PermissionModifyJob::~PermissionModifyJob() =
default;
104bool PermissionModifyJob::removeExpiration()
const
106 return d->removeExpiration;
109void PermissionModifyJob::setRemoveExpiration(
bool removeExpiration)
111 d->removeExpiration = removeExpiration;
114bool PermissionModifyJob::supportsAllDrives()
const
116 return d->supportsAllDrives;
119void PermissionModifyJob::setSupportsAllDrives(
bool supportsAllDrives)
121 d->supportsAllDrives = supportsAllDrives;
124bool PermissionModifyJob::transferOwnership()
const
126 return d->transferOwnership;
129void PermissionModifyJob::setTransferOwnership(
bool transferOwnership)
131 d->transferOwnership = transferOwnership;
134bool PermissionModifyJob::useDomainAdminAccess()
const
136 return d->useDomainAdminAccess;
139void PermissionModifyJob::setUseDomainAdminAccess(
bool useDomainAdminAccess)
141 d->useDomainAdminAccess = useDomainAdminAccess;
144void PermissionModifyJob::start()
152 ContentType ct = Utils::stringToContentType(contentType);
154 if (ct == KGAPI2::JSON) {
155 items << Permission::fromJSON(rawData);
168#include "moc_permissionmodifyjob.cpp"
void setErrorString(const QString &errorString)
Set job error description to errorString.
AccountPtr account() const
Returns account used to authenticate requests.
virtual void emitFinished()
Emits Job::finished() signal.
void setError(KGAPI2::Error error)
Set job error to error.
virtual void enqueueRequest(const QNetworkRequest &request, const QByteArray &data=QByteArray(), const QString &contentType=QString())
Enqueues request in dispatcher queue.
Abstract superclass for all jobs that somehow modify resources on Google.
ObjectsList items() const
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
A job to fetch a single map tile described by a StaticMapUrl.
@ InvalidResponse
LibKGAPI error - Google returned invalid response.
bool isEmpty() const const
QObject * parent() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
void setQuery(const QString &query, ParsingMode mode)
QString toString() const const