Kgapi

fileresumablemodifyjob.cpp
1/*
2 * This file is part of LibKGAPI library
3 *
4 * SPDX-FileCopyrightText: 2020 David Barchiesi <david@barchie.si>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "fileresumablemodifyjob.h"
10#include "debug.h"
11#include "driveservice.h"
12#include "utils.h"
13
14#include <QUrlQuery>
15
16using namespace KGAPI2;
17using namespace KGAPI2::Drive;
18
19class Q_DECL_HIDDEN FileResumableModifyJob::Private
20{
21public:
22 QString fileId;
23 bool createNewRevision = true;
24 bool changeModifiedDate = false;
25 bool updateViewedDate = true;
26};
27
28FileResumableModifyJob::FileResumableModifyJob(const FilePtr &metadata, const AccountPtr &account, QObject *parent)
29 : FileAbstractResumableJob(metadata, account, parent)
30 , d(new Private)
31{
32 d->fileId = metadata->id();
33}
34
35FileResumableModifyJob::FileResumableModifyJob(const QString &fileId, const AccountPtr &account, QObject *parent)
36 : FileAbstractResumableJob(account, parent)
37 , d(new Private)
38{
39 d->fileId = fileId;
40}
41
42FileResumableModifyJob::FileResumableModifyJob(QIODevice *device, const FilePtr &metadata, const AccountPtr &account, QObject *parent)
43 : FileAbstractResumableJob(device, metadata, account, parent)
44 , d(new Private)
45{
46 d->fileId = metadata->id();
47}
48
49FileResumableModifyJob::FileResumableModifyJob(QIODevice *device, const QString &fileId, const AccountPtr &account, QObject *parent)
50 : FileAbstractResumableJob(device, account, parent)
51 , d(new Private)
52{
53 d->fileId = fileId;
54}
55
56FileResumableModifyJob::~FileResumableModifyJob() = default;
57
58bool FileResumableModifyJob::createNewRevision() const
59{
60 return d->createNewRevision;
61}
62
63void FileResumableModifyJob::setCreateNewRevision(bool createNewRevision)
64{
65 if (isRunning()) {
66 qCWarning(KGAPIDebug) << "Can't modify createNewRevision property when the job is running";
67 return;
68 }
69
70 d->createNewRevision = createNewRevision;
71}
72
73bool FileResumableModifyJob::updateModifiedDate() const
74{
75 return d->updateViewedDate;
76}
77
78void FileResumableModifyJob::setUpdateModifiedDate(bool updateModifiedDate)
79{
80 if (isRunning()) {
81 qCWarning(KGAPIDebug) << "Can't modify updateModifiedDate property when the job is running";
82 return;
83 }
84
85 d->updateViewedDate = updateModifiedDate;
86}
87
88bool FileResumableModifyJob::updateViewedDate() const
89{
90 return d->updateViewedDate;
91}
92
93void FileResumableModifyJob::setUpdateViewedDate(bool updateViewedDate)
94{
95 if (isRunning()) {
96 qCWarning(KGAPIDebug) << "Can't modify updateViewedDate property when job is running";
97 return;
98 }
99
100 d->updateViewedDate = updateViewedDate;
101}
102
103QUrl FileResumableModifyJob::createUrl()
104{
105 QUrl url = DriveService::uploadMediaFileUrl(d->fileId);
106
107 QUrlQuery query(url);
108 query.addQueryItem(QStringLiteral("newRevision"), Utils::bool2Str(d->createNewRevision));
109 query.addQueryItem(QStringLiteral("setModifiedDate"), Utils::bool2Str(d->changeModifiedDate));
110 query.addQueryItem(QStringLiteral("updateViewedDate"), Utils::bool2Str(d->updateViewedDate));
111 url.setQuery(query);
112
113 return url;
114}
115
116#include "moc_fileresumablemodifyjob.cpp"
Abstract superclass for KGAPI2::Drive::File create or modify jobs that use chunked uploading of the f...
bool isRunning
Whether the job is running.
Definition job.h:67
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
A job to fetch a single map tile described by a StaticMapUrl.
Definition blog.h:16
void setQuery(const QString &query, ParsingMode mode)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:59:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.