diff --git a/autotests/drive/data/file1_copy_request.txt b/autotests/drive/data/file1_copy_request.txt --- a/autotests/drive/data/file1_copy_request.txt +++ b/autotests/drive/data/file1_copy_request.txt @@ -1,4 +1,4 @@ -POST https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/copy?convert=false&ocr=false&pinned=false&prettyPrint=false +POST https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/copy?convert=false&ocr=false&pinned=false&supportsAllDrives=true&prettyPrint=false Content-Type: application/json { diff --git a/autotests/drive/data/file1_create_request.txt b/autotests/drive/data/file1_create_request.txt --- a/autotests/drive/data/file1_create_request.txt +++ b/autotests/drive/data/file1_create_request.txt @@ -1,4 +1,4 @@ -POST https://www.googleapis.com/drive/v2/files?convert=false&ocr=false&pinned=false&useContentAsIndexableText=false&supportsAllDrives=true&prettyPrint=false +POST https://www.googleapis.com/drive/v2/files?convert=false&ocr=false&pinned=false&supportsAllDrives=true&useContentAsIndexableText=false&prettyPrint=false Content-Type: application/json { diff --git a/autotests/drive/data/file2_copy_request.txt b/autotests/drive/data/file2_copy_request.txt --- a/autotests/drive/data/file2_copy_request.txt +++ b/autotests/drive/data/file2_copy_request.txt @@ -1,4 +1,4 @@ -POST https://www.googleapis.com/drive/v2/files/abc123def456ghi789/copy?convert=false&ocr=false&pinned=false&prettyPrint=false +POST https://www.googleapis.com/drive/v2/files/abc123def456ghi789/copy?convert=false&ocr=false&pinned=false&supportsAllDrives=true&prettyPrint=false Content-Type: application/json { diff --git a/autotests/drive/data/file2_create_request.txt b/autotests/drive/data/file2_create_request.txt index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@isRunning = false; diff --git a/src/drive/fileabstractdatajob.h b/src/drive/fileabstractdatajob.h --- a/src/drive/fileabstractdatajob.h +++ b/src/drive/fileabstractdatajob.h @@ -98,6 +98,17 @@ READ timedTextTrackName WRITE setTimedTextTrackName) + /** + * Sets whether the request supports both My Drives and shared drives. + * + * Set to true by default as LibKGAPI supports Team Drives. + * + * This property can be modified only when the job is not running. + */ + Q_PROPERTY(bool supportsAllDrives + READ supportsAllDrives + WRITE setSupportsAllDrives) + public: explicit FileAbstractDataJob(const AccountPtr &account, QObject *parent = nullptr); @@ -121,6 +132,26 @@ QString timedTextTrackName() const; void setTimedTextTrackName(const QString &timedTextTrackName); + /** + * @brief Whether the request supports both My Drives and shared drives. + * + * Set to true by default as LibKGAPI supports Team Drives. + * + * @deprecated This parameter will only be effective until June 1, 2020. Afterwards all applications + * are assumed to support shared drives. + */ + KGAPIDRIVE_DEPRECATED bool supportsAllDrives() const; + + /** + * @brief Sets whether the request supports both My Drives and shared drives. + * + * Set to true by default as LibKGAPI supports Team Drives. + * + * @deprecated This parameter will only be effective until June 1, 2020. Afterwards all applications + * are assumed to support shared drives. + */ + KGAPIDRIVE_DEPRECATED void setSupportsAllDrives(bool supportsAllDrives); + protected: QUrl updateUrl(QUrl &url); diff --git a/src/drive/fileabstractdatajob.cpp b/src/drive/fileabstractdatajob.cpp --- a/src/drive/fileabstractdatajob.cpp +++ b/src/drive/fileabstractdatajob.cpp @@ -40,12 +40,14 @@ bool pinned; QString timedTextLanguage; QString timedTextTrackName; + bool supportsAllDrives; }; FileAbstractDataJob::Private::Private(): convert(false), ocr(false), - pinned(false) + pinned(false), + supportsAllDrives(true) { } @@ -152,6 +154,16 @@ d->timedTextTrackName = timedTextTrackName; } +bool FileAbstractDataJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void FileAbstractDataJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + QUrl FileAbstractDataJob::updateUrl(QUrl &url) { QUrlQuery query(url); @@ -177,8 +189,11 @@ if (!d->timedTextTrackName.isEmpty()) { query.addQueryItem(QStringLiteral("timedTextTrackName"), d->timedTextTrackName); } - url.setQuery(query); + query.removeQueryItem(QStringLiteral("supportsAllDrives")); + query.addQueryItem(QStringLiteral("supportsAllDrives"), Utils::bool2Str(d->supportsAllDrives)); + + url.setQuery(query); return url; } diff --git a/src/drive/fileabstractmodifyjob.h b/src/drive/fileabstractmodifyjob.h --- a/src/drive/fileabstractmodifyjob.h +++ b/src/drive/fileabstractmodifyjob.h @@ -49,6 +49,26 @@ const AccountPtr &account, QObject *parent = nullptr); ~FileAbstractModifyJob() override; + /** + * @brief Whether the request supports both My Drives and shared drives. + * + * Set to true by default as LibKGAPI supports Team Drives. + * + * @deprecated This parameter will only be effective until June 1, 2020. Afterwards all applications + * are assumed to support shared drives. + */ + KGAPIDRIVE_DEPRECATED bool supportsAllDrives() const; + + /** + * @brief Sets whether the request supports both My Drives and shared drives. + * + * Set to true by default as LibKGAPI supports Team Drives. + * + * @deprecated This parameter will only be effective until June 1, 2020. Afterwards all applications + * are assumed to support shared drives. + */ + KGAPIDRIVE_DEPRECATED void setSupportsAllDrives(bool supportsAllDrives); + protected: void start() override; KGAPI2::ObjectsList handleReplyWithItems(const QNetworkReply *reply, diff --git a/src/drive/fileabstractmodifyjob.cpp b/src/drive/fileabstractmodifyjob.cpp --- a/src/drive/fileabstractmodifyjob.cpp +++ b/src/drive/fileabstractmodifyjob.cpp @@ -28,6 +28,7 @@ #include #include +#include using namespace KGAPI2; @@ -41,11 +42,14 @@ QStringList filesIds; + bool supportsAllDrives; + private: FileAbstractModifyJob *q; }; FileAbstractModifyJob::Private::Private(FileAbstractModifyJob *parent): + supportsAllDrives(true), q(parent) { } @@ -58,7 +62,11 @@ } const QString fileId = filesIds.takeFirst(); - const QUrl url = q->url(fileId); + QUrl url = q->url(fileId); + + QUrlQuery query(url); + query.addQueryItem(QStringLiteral("supportsAllDrives"), supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(query); QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentLengthHeader, 0); @@ -114,6 +122,16 @@ d->processNext(); } +bool FileAbstractModifyJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void FileAbstractModifyJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + ObjectsList FileAbstractModifyJob::handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) { diff --git a/src/drive/fileabstractuploadjob.h b/src/drive/fileabstractuploadjob.h --- a/src/drive/fileabstractuploadjob.h +++ b/src/drive/fileabstractuploadjob.h @@ -76,26 +76,6 @@ bool useContentAsIndexableText() const; void setUseContentAsIndexableText(bool useContentAsIndexableText); - /** - * @brief Whether the request supports both My Drives and shared drives. - * - * Set to true by default as LibKGAPI supports Team Drives. - * - * @deprecated This parameter will only be effective until June 1, 2020. Afterwards all applications - * are assumed to support shared drives. - */ - KGAPIDRIVE_DEPRECATED bool supportsAllDrives() const; - - /** - * @brief Sets whether the request supports both My Drives and shared drives. - * - * Set to true by default as LibKGAPI supports Team Drives. - * - * @deprecated This parameter will only be effective until June 1, 2020. Afterwards all applications - * are assumed to support shared drives. - */ - KGAPIDRIVE_DEPRECATED void setSupportsAllDrives(bool supportsAllDrives); - QMap < QString /* file path */, FilePtr /* metadata */ > files() const; protected: diff --git a/src/drive/fileabstractuploadjob.cpp b/src/drive/fileabstractuploadjob.cpp --- a/src/drive/fileabstractuploadjob.cpp +++ b/src/drive/fileabstractuploadjob.cpp @@ -58,8 +58,6 @@ QMap uploadedFiles; - bool supportsAllDrives; - bool useContentAsIndexableText; File::SerializationOptions serializationOptions = File::NoOptions; @@ -69,7 +67,6 @@ FileAbstractUploadJob::Private::Private(FileAbstractUploadJob *parent): originalFilesCount(0), - supportsAllDrives(true), useContentAsIndexableText(false), q(parent) { @@ -187,7 +184,6 @@ contentType = QStringLiteral("application/json"); } - query.addQueryItem(QStringLiteral("supportsAllDrives"), supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); url.setQuery(query); QNetworkRequest request(url); @@ -307,16 +303,6 @@ return d->uploadedFiles; } -bool FileAbstractUploadJob::supportsAllDrives() const -{ - return d->supportsAllDrives; -} - -void FileAbstractUploadJob::setSupportsAllDrives(bool supportsAllDrives) -{ - d->supportsAllDrives = supportsAllDrives; -} - void FileAbstractUploadJob::dispatchRequest(QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data,