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 ef1d98e06a84910e342d8b634bb3ff46847ee614..4200f10f8414e001f031e639c68ebd2757f12637 GIT binary patch literal 3732 zc$}?O2~-nT8%+qvY7qo~peT?apb|n70!b_)yFigGs701DnM}e!HfAPlindnVzy&DS zDuUvI%BHyBT6a;YxB#xyqEJLcWK%&YbOzAcmYy!>pPZ93@4fHc@80`;?@e$}n7}d? z!;~nW!AMFA_Pu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b}yW`(_^R=(I5IcTI2J|Q&C0bXUd;i z@2#(LXnU=H_`(Bku&t0en9k``_ZNS+GK4%B6*SOSF|DvU>fQO8Pjb{lCnX;L=BU1$ zc|9TGWyX;T1Kzu|W|Nbi7T3NmmJeq37RF&cCwi6*WxO;}_AY6|3JnI40?T~(M9MJ9 sBfauAW$3_L{qUEabE`iubSql-W^c%P6FaYtm4fiB;rsvKPo7Ty6)=6yKmY&$ diff --git a/src/core/job.cpp b/src/core/job.cpp --- a/src/core/job.cpp +++ b/src/core/job.cpp @@ -484,7 +484,6 @@ void Job::emitFinished() { - qCDebug(KGAPIDebug); aboutToFinish(); d->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,