File indexing completed on 2024-05-12 05:22:20

0001 /*
0002  * This file is part of LibKGAPI library
0003  *
0004  * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #pragma once
0010 
0011 #include "fileabstractuploadjob.h"
0012 #include "kgapidrive_export.h"
0013 
0014 namespace KGAPI2
0015 {
0016 
0017 namespace Drive
0018 {
0019 
0020 class KGAPIDRIVE_EXPORT FileModifyJob : public KGAPI2::Drive::FileAbstractUploadJob
0021 {
0022     Q_OBJECT
0023 
0024     /**
0025      * Whether a blob upload should create a new revision. If set to false,
0026      * the blob data in the current head revision is replaced. If true, a new
0027      * blob is created as head revision, and previous revisions are preserved
0028      * (causing increased use of the user's data storage quota).
0029      *
0030      * Default value is true.
0031      *
0032      * This property can be modified only when the job is not running.
0033      */
0034     Q_PROPERTY(bool createNewRevision READ createNewRevision WRITE setCreateNewRevision)
0035 
0036     /**
0037      * Whether to set the modified date with the supplied modified date.
0038      *
0039      * Default value is false.
0040      *
0041      * This property can be modified only when the job is not running.
0042      */
0043     Q_PROPERTY(bool updateModifiedDate READ updateModifiedDate WRITE setUpdateModifiedDate)
0044 
0045     /**
0046      * Whether to update the view date after successfully updating the file.
0047      *
0048      * Default value is true.
0049      *
0050      * This property can be modified only when the job is not running.
0051      */
0052     Q_PROPERTY(bool updateViewedDate READ updateViewedDate WRITE setUpdateViewedDate)
0053 
0054 public:
0055     explicit FileModifyJob(const FilePtr &metadata, const AccountPtr &account, QObject *parent = nullptr);
0056     explicit FileModifyJob(const QString &filePath, const QString &fileId, const AccountPtr &account, QObject *parent = nullptr);
0057     explicit FileModifyJob(const QString &filePath, const FilePtr &metaData, const AccountPtr &account, QObject *parent = nullptr);
0058     explicit FileModifyJob(const QMap<QString /* file path */, QString /* file ID */> &files, const AccountPtr &account, QObject *parent = nullptr);
0059     explicit FileModifyJob(const QMap<QString /* file path */, FilePtr /* metadata */> &files, const AccountPtr &account, QObject *parent = nullptr);
0060     ~FileModifyJob() override;
0061 
0062     [[nodiscard]] bool createNewRevision() const;
0063     void setCreateNewRevision(bool createNewRevision);
0064 
0065     [[nodiscard]] bool updateModifiedDate() const;
0066     void setUpdateModifiedDate(bool updateModifiedDate);
0067 
0068     [[nodiscard]] bool updateViewedDate() const;
0069     void setUpdateViewedDate(bool updateViewedDate);
0070 
0071 protected:
0072     QNetworkReply *dispatch(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data) override;
0073     [[nodiscard]] QUrl createUrl(const QString &filePath, const FilePtr &metaData) override;
0074 
0075 private:
0076     class Private;
0077     Private *const d;
0078     friend class Private;
0079 };
0080 
0081 } // namespace Drive
0082 
0083 } // namespace KGAPI2