diff --git a/autotests/drive/data/change1_fetch_request.txt b/autotests/drive/data/change1_fetch_request.txt --- a/autotests/drive/data/change1_fetch_request.txt +++ b/autotests/drive/data/change1_fetch_request.txt @@ -1 +1 @@ -GET https://www.googleapis.com/drive/v2/changes/194 +GET https://www.googleapis.com/drive/v2/changes/194?supportsAllDrives=true diff --git a/autotests/drive/data/changes_fetch_page1_request.txt b/autotests/drive/data/changes_fetch_page1_request.txt --- a/autotests/drive/data/changes_fetch_page1_request.txt +++ b/autotests/drive/data/changes_fetch_page1_request.txt @@ -1 +1 @@ -GET https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true +GET https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true&includeItemsFromAllDrives=true&supportsAllDrives=true 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,40 +1,40 @@ -POST https://www.googleapis.com/drive/v2/files?convert=false&ocr=false&pinned=false&useContentAsIndexableText=false +POST https://www.googleapis.com/drive/v2/files?convert=false&ocr=false&pinned=false&useContentAsIndexableText=false&supportsAllDrives=true Content-Type: application/json { - "mimeType": "application/vnd.google-apps.spreadsheet", - "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", + "mimeType": "application/vnd.google-apps.spreadsheet", + "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", "labels": { - "restricted": false, - "starred": false, - "viewed": false, - "hidden": false, + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, "trashed": false - }, - "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUyMzM1MTc5MDUyNA\"", - "lastModifyingUserName": "John Doe", - "writersCanShare": true, - "sharedWithMeDate": "2018-03-14T13:35:25Z", - "title": "Super mega secret KDE PIM plans for world domination", + }, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUyMzM1MTc5MDUyNA\"", + "lastModifyingUserName": "John Doe", + "writersCanShare": true, + "sharedWithMeDate": "2018-03-14T13:35:25Z", + "title": "Super mega secret KDE PIM plans for world domination", "ownerNames": [ "Konqui Dev" - ], - "id": "abcdefghijklmnopqrstuvwxyz", + ], + "id": "abcdefghijklmnopqrstuvwxyz", "parents": [ { - "id": "zyxwvutsrqponmlkjihgfedcba", - "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/parents/zyxwvutsrqponmlkjihgfedcba", + "id": "zyxwvutsrqponmlkjihgfedcba", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/parents/zyxwvutsrqponmlkjihgfedcba", "parentLink": "https://www.googleapis.com/drive/v2/files/zyxwvutsrqponmlkjihgfedcba" } - ], - "shared": true, - "editable": false, - "kind": "drive#file", - "modifiedDate": "2018-04-10T09:16:30Z", - "createdDate": "2018-01-05T11:35:58Z", - "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet", - "embedLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/htmlembed?ouid=116901758143213967333", - "alternateLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/edit?usp=drivesdk", + ], + "shared": true, + "editable": false, + "kind": "drive#file", + "modifiedDate": "2018-04-10T09:16:30Z", + "createdDate": "2018-01-05T11:35:58Z", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet", + "embedLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/htmlembed?ouid=116901758143213967333", + "alternateLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/edit?usp=drivesdk", "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz" } diff --git a/autotests/drive/data/file2_create_request.txt b/autotests/drive/data/file2_create_request.txt index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Kz-Q-o9*9omf zbEXs(FFzYpK8qgJ611YobL%$e7mn+nwQUSZIxeE+mrv??mjqmiP6;qR;CeY} zZ_UJ0mVrU;#`!D#;`daSnwg$GC3KQ*2R6mOT;U$NP?9ybd1LI)`oJ0U=2!Z52k)3< zv?qr(DXVrTgf#_370m-y?)2F<{ToQl>npv|via)91UCAmTdc?JjNrN5H=MeBPGd`> zm+urYD@tr7@&Z@dj~h78dd$1Rd!wo852Gi=-9;{U=B~}PjXx}4w_mXu*LG)=ML{zQ_n)RNSZ!0~I<1(~ z)-S58E4@{pQ#YZtDbHvyMfiPElVzqfo!K~v`(ux%r4IueedGLwkA(CfW#cj&qfwzWXFFR&eeO};RxbDr~ W;Pq5{ulAL~u*{+R|KKCfVEhVKD!t?Y diff --git a/examples/teamdrive/mainwindow.h b/examples/teamdrive/mainwindow.h --- a/examples/teamdrive/mainwindow.h +++ b/examples/teamdrive/mainwindow.h @@ -102,11 +102,22 @@ void slotTeamdriveDeleteJobFinished(KGAPI2::Job *job); /** - * A specific contact in contact list has been selected. Sends a request - * to Google to retrieve full details about the specific contact + * A specific team drive in teamdrive list has been selected. Sends a request + * to Google to retrieve teh team drive file list. */ void teamdriveSelected(); + /** + * A specific item in the teamdrive list has been selected. Sends a request + * to Google to retrieve full details about the specific file + */ + void teamdriveItemSelected(); + + /** + * Team Drive item detail was fetched. + */ + void slotTeamdriveItemFetchJobFinished(KGAPI2::Job *job); + private: Ui::MainWindow *m_ui; diff --git a/examples/teamdrive/mainwindow.cpp b/examples/teamdrive/mainwindow.cpp --- a/examples/teamdrive/mainwindow.cpp +++ b/examples/teamdrive/mainwindow.cpp @@ -56,6 +56,8 @@ this, &MainWindow::renameSelectedTeamdrive); connect(m_ui->teamdriveList, &QListWidget::itemSelectionChanged, this, &MainWindow::teamdriveSelected); + connect(m_ui->teamdrivePreviewList, &QListWidget::itemSelectionChanged, + this, &MainWindow::teamdriveItemSelected); } MainWindow::~MainWindow() @@ -244,22 +246,23 @@ m_ui->renameTeamdriveButton->setEnabled(hasSelection); m_ui->renameTeamdriveEdit->setEnabled(hasSelection); + m_ui->teamdrivePreviewList->clear(); + if (!hasSelection) { - m_ui->teamdrivePreview->clear(); m_ui->renameTeamdriveEdit->clear(); return; } const QString id = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::UserRole).toString(); const QString name = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::DisplayRole).toString(); + m_ui->renameTeamdriveEdit->setText(name); KGAPI2::Drive::FileSearchQuery query; query.addQuery(KGAPI2::Drive::FileSearchQuery::Trashed, KGAPI2::Drive::FileSearchQuery::Equals, false); query.addQuery(KGAPI2::Drive::FileSearchQuery::Parents, KGAPI2::Drive::FileSearchQuery::In, id); KGAPI2::Drive::FileFetchJob *fileFetchJob = new KGAPI2::Drive::FileFetchJob(query, m_account, nullptr); - fileFetchJob->setIncludeTeamDriveItems(true); fileFetchJob->setFields((KGAPI2::Drive::FileFetchJob::BasicFields & ~KGAPI2::Drive::FileFetchJob::Permissions) | KGAPI2::Drive::FileFetchJob::Labels | KGAPI2::Drive::FileFetchJob::ExportLinks @@ -281,15 +284,61 @@ return; } - /* Get all items we have received from Google (should be just one) */ + /* Get all items we have received from Google */ KGAPI2::ObjectsList objects = fetchJob->items(); - QString text; Q_FOREACH (const KGAPI2::ObjectPtr &object, objects) { const KGAPI2::Drive::FilePtr file = object.dynamicCast(); - text += QStringLiteral("%1").arg(file->title()); - text += QLatin1Char('\n'); + + /* Convert the teamdrive to QListWidget item */ + QListWidgetItem *item = new QListWidgetItem(m_ui->teamdrivePreviewList); + item->setText(file->title()); + item->setData(Qt::UserRole, file->id()); + + m_ui->teamdrivePreviewList->addItem(item); + } +} + +void MainWindow::teamdriveItemSelected() +{ + bool hasSelection = (m_ui->teamdrivePreviewList->selectedItems().count() != 0); + if (!hasSelection) { + return; + } + + const QString id = m_ui->teamdrivePreviewList->selectedItems().at(0)->data(Qt::UserRole).toString(); + + KGAPI2::Drive::FileFetchJob *fileFetchJob = new KGAPI2::Drive::FileFetchJob(id, m_account, nullptr); + fileFetchJob->setFields((KGAPI2::Drive::FileFetchJob::BasicFields & ~KGAPI2::Drive::FileFetchJob::Permissions) + | KGAPI2::Drive::FileFetchJob::Labels + | KGAPI2::Drive::FileFetchJob::ExportLinks + | KGAPI2::Drive::FileFetchJob::LastViewedByMeDate); + connect(fileFetchJob, &KGAPI2::Job::finished, + this, &MainWindow::slotTeamdriveItemFetchJobFinished); +} + +void MainWindow::slotTeamdriveItemFetchJobFinished(KGAPI2::Job *job) +{ + KGAPI2::Drive::FileFetchJob *fetchJob = qobject_cast(job); + Q_ASSERT(fetchJob); + fetchJob->deleteLater(); + + if (fetchJob->error() != KGAPI2::NoError) { + m_ui->errorLabel->setText(QStringLiteral("Error: %1").arg(fetchJob->errorString())); + m_ui->errorLabel->setVisible(true); + return; + } + + KGAPI2::ObjectsList objects = fetchJob->items(); + if (objects.size() != 1) { + return; } - m_ui->teamdrivePreview->setText(text); + KGAPI2::ObjectPtr object = objects.at(0); + const KGAPI2::Drive::FilePtr file = object.dynamicCast(); + QStringList msgBuilder; + msgBuilder << file->title(); + msgBuilder << QString::number(file->fileSize()) + QStringLiteral(" bytes"); + QString msg = msgBuilder.join(QStringLiteral(", ")); + m_ui->statusbar->showMessage(msg); } diff --git a/examples/teamdrive/ui/main.ui b/examples/teamdrive/ui/main.ui --- a/examples/teamdrive/ui/main.ui +++ b/examples/teamdrive/ui/main.ui @@ -158,7 +158,7 @@ - + diff --git a/src/drive/changefetchjob.h b/src/drive/changefetchjob.h --- a/src/drive/changefetchjob.h +++ b/src/drive/changefetchjob.h @@ -104,6 +104,42 @@ qlonglong startChangeId() const; void setStartChangeId(qlonglong startChangeId); + /** + * @brief Whether both My Drive and shared drive items should be included in results. + * + * @deprecated This parameter will only be effective until June 1, 2020. Afterwards shared drive items will be included in the results. + */ + KGAPIDRIVE_DEPRECATED bool includeItemsFromAllDrives() const; + + /** + * @brief Sets whether both My Drive and shared drive items should be included in results. + * + * Set to true by default as LibKGAPI supports Team Drives. + * + * @deprecated This parameter will only be effective until June 1, 2020. Afterwards shared drive items will be included in the results. + */ + KGAPIDRIVE_DEPRECATED void setIncludeItemsFromAllDrives(bool includeItemsFromAllDrives); + + /** + * @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/changefetchjob.cpp b/src/drive/changefetchjob.cpp --- a/src/drive/changefetchjob.cpp +++ b/src/drive/changefetchjob.cpp @@ -46,6 +46,8 @@ bool includeSubscribed; int maxResults; qlonglong startChangeId; + bool includeItemsFromAllDrives; + bool supportsAllDrives; private: ChangeFetchJob *q; @@ -56,6 +58,8 @@ includeSubscribed(true), maxResults(0), startChangeId(0), + includeItemsFromAllDrives(true), + supportsAllDrives(true), q(parent) { } @@ -149,6 +153,26 @@ return d->startChangeId; } +bool ChangeFetchJob::includeItemsFromAllDrives() const +{ + return d->includeItemsFromAllDrives; +} + +void ChangeFetchJob::setIncludeItemsFromAllDrives(bool includeItemsFromAllDrives) +{ + d->includeItemsFromAllDrives = includeItemsFromAllDrives; +} + +bool ChangeFetchJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void ChangeFetchJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + void ChangeFetchJob::start() { QUrl url; @@ -163,11 +187,16 @@ if (d->startChangeId > 0) { query.addQueryItem(QStringLiteral("startChangeId"), QString::number(d->startChangeId)); } + query.addQueryItem(QStringLiteral("includeItemsFromAllDrives"), d->includeItemsFromAllDrives ? QStringLiteral("true") : QStringLiteral("false")); url.setQuery(query); } else { url = DriveService::fetchChangeUrl(d->changeId); } + QUrlQuery query(url); + query.addQueryItem(QStringLiteral("supportsAllDrives"), d->supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(query); + const QNetworkRequest request = d->createRequest(url); enqueueRequest(request); } diff --git a/src/drive/childreferencecreatejob.h b/src/drive/childreferencecreatejob.h --- a/src/drive/childreferencecreatejob.h +++ b/src/drive/childreferencecreatejob.h @@ -57,6 +57,26 @@ QObject *parent = nullptr); ~ChildReferenceCreateJob() 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; ObjectsList handleReplyWithItems(const QNetworkReply *reply, diff --git a/src/drive/childreferencecreatejob.cpp b/src/drive/childreferencecreatejob.cpp --- a/src/drive/childreferencecreatejob.cpp +++ b/src/drive/childreferencecreatejob.cpp @@ -28,6 +28,7 @@ #include #include +#include using namespace KGAPI2; @@ -41,12 +42,14 @@ QString folderId; ChildReferencesList references; + bool supportsAllDrives; private: ChildReferenceCreateJob *q; }; ChildReferenceCreateJob::Private::Private(ChildReferenceCreateJob *parent): + supportsAllDrives(true), q(parent) { } @@ -59,7 +62,11 @@ } const ChildReferencePtr reference = references.takeFirst(); - const QUrl url = DriveService::createChildReference(folderId); + QUrl url = DriveService::createChildReference(folderId); + + QUrlQuery withDriveSupportQuery(url); + withDriveSupportQuery.addQueryItem(QStringLiteral("supportsAllDrives"), supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(withDriveSupportQuery); QNetworkRequest request; request.setRawHeader("Authorization", "Bearer " + q->account()->accessToken().toLatin1()); @@ -120,6 +127,16 @@ delete d; } +bool ChildReferenceCreateJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void ChildReferenceCreateJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + void ChildReferenceCreateJob::start() { d->processNext(); diff --git a/src/drive/fileabstractuploadjob.h b/src/drive/fileabstractuploadjob.h --- a/src/drive/fileabstractuploadjob.h +++ b/src/drive/fileabstractuploadjob.h @@ -76,6 +76,26 @@ 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,6 +58,7 @@ QMap uploadedFiles; + bool supportsAllDrives; bool useContentAsIndexableText; File::SerializationOptions serializationOptions = File::NoOptions; @@ -68,6 +69,7 @@ FileAbstractUploadJob::Private::Private(FileAbstractUploadJob *parent): originalFilesCount(0), + supportsAllDrives(true), useContentAsIndexableText(false), q(parent) { @@ -185,6 +187,8 @@ rawData = File::toJSON(metaData, q->serializationOptions()); contentType = QStringLiteral("application/json"); } + + query.addQueryItem(QStringLiteral("supportsAllDrives"), supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); url.setQuery(query); request.setUrl(url); @@ -305,6 +309,16 @@ 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, diff --git a/src/drive/filefetchjob.h b/src/drive/filefetchjob.h --- a/src/drive/filefetchjob.h +++ b/src/drive/filefetchjob.h @@ -120,8 +120,41 @@ void setFields(qulonglong fields); qulonglong fields() const; - bool includeTeamDriveItems() const; - void setIncludeTeamDriveItems(bool includeTeamDriveItems); + /** + * @brief Whether both My Drive and shared drive items should be included in results. + * + * @deprecated This parameter will only be effective until June 1, 2020. Afterwards shared drive items will be included in the results. + */ + KGAPIDRIVE_DEPRECATED bool includeItemsFromAllDrives() const; + + /** + * @brief Sets whether both My Drive and shared drive items should be included in results. + * + * Set to true by default as LibKGAPI supports Team Drives. + * + * @deprecated This parameter will only be effective until June 1, 2020. Afterwards shared drive items will be included in the results. + */ + KGAPIDRIVE_DEPRECATED void setIncludeItemsFromAllDrives(bool includeItemsFromAllDrives); + + /** + * @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; diff --git a/src/drive/filefetchjob.cpp b/src/drive/filefetchjob.cpp --- a/src/drive/filefetchjob.cpp +++ b/src/drive/filefetchjob.cpp @@ -46,7 +46,8 @@ FileSearchQuery searchQuery; QStringList filesIDs; bool isFeed; - bool includeTeamDriveItems; + bool includeItemsFromAllDrives; + bool supportsAllDrives; bool updateViewedDate; @@ -58,6 +59,8 @@ FileFetchJob::Private::Private(FileFetchJob *parent): isFeed(false), + includeItemsFromAllDrives(true), + supportsAllDrives(true), updateViewedDate(false), fields(FileFetchJob::AllFields), q(parent) @@ -240,10 +243,7 @@ QStringLiteral("etag,kind,nextLink,nextPageToken,selfLink,items(%1)").arg(fieldsStrings.join(QStringLiteral(",")))); } - if (includeTeamDriveItems) { - query.addQueryItem(QStringLiteral("includeTeamDriveItems"), QStringLiteral("true")); - query.addQueryItem(QStringLiteral("supportsTeamDrives"), QStringLiteral("true")); - } + query.addQueryItem(QStringLiteral("includeItemsFromAllDrives"), includeItemsFromAllDrives ? QStringLiteral("true") : QStringLiteral("false")); url.setQuery(query); } else { @@ -262,6 +262,10 @@ } } + QUrlQuery withDriveSupportQuery(url); + withDriveSupportQuery.addQueryItem(QStringLiteral("supportsAllDrives"), supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(withDriveSupportQuery); + q->enqueueRequest(createRequest(url)); } @@ -333,14 +337,24 @@ return d->fields; } -bool FileFetchJob::includeTeamDriveItems() const +bool FileFetchJob::includeItemsFromAllDrives() const +{ + return d->includeItemsFromAllDrives; +} + +void FileFetchJob::setIncludeItemsFromAllDrives(bool includeItemsFromAllDrives) +{ + d->includeItemsFromAllDrives = includeItemsFromAllDrives; +} + +bool FileFetchJob::supportsAllDrives() const { - return d->includeTeamDriveItems; + return d->supportsAllDrives; } -void FileFetchJob::setIncludeTeamDriveItems(bool includeTeamDriveItems) +void FileFetchJob::setSupportsAllDrives(bool supportsAllDrives) { - d->includeTeamDriveItems = includeTeamDriveItems; + d->supportsAllDrives = supportsAllDrives; } diff --git a/src/drive/parentreferencecreatejob.h b/src/drive/parentreferencecreatejob.h --- a/src/drive/parentreferencecreatejob.h +++ b/src/drive/parentreferencecreatejob.h @@ -57,6 +57,26 @@ QObject *parent = nullptr); ~ParentReferenceCreateJob() 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/parentreferencecreatejob.cpp b/src/drive/parentreferencecreatejob.cpp --- a/src/drive/parentreferencecreatejob.cpp +++ b/src/drive/parentreferencecreatejob.cpp @@ -28,6 +28,7 @@ #include #include +#include using namespace KGAPI2; @@ -38,6 +39,7 @@ public: Private(ParentReferenceCreateJob *parent); void processNext(); + bool supportsAllDrives; QString fileId; ParentReferencesList references; @@ -47,6 +49,7 @@ }; ParentReferenceCreateJob::Private::Private(ParentReferenceCreateJob *parent): + supportsAllDrives(true), q(parent) { } @@ -59,7 +62,11 @@ } const ParentReferencePtr reference = references.takeFirst(); - const QUrl url = DriveService::createParentReferenceUrl(fileId); + QUrl url = DriveService::createParentReferenceUrl(fileId); + + QUrlQuery withDriveSupportQuery(url); + withDriveSupportQuery.addQueryItem(QStringLiteral("supportsAllDrives"), supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(withDriveSupportQuery); QNetworkRequest request; request.setRawHeader("Authorization", "Bearer " + q->account()->accessToken().toLatin1()); @@ -120,6 +127,16 @@ delete d; } +bool ParentReferenceCreateJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void ParentReferenceCreateJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + void ParentReferenceCreateJob::start() { d->processNext(); diff --git a/src/drive/permissioncreatejob.h b/src/drive/permissioncreatejob.h --- a/src/drive/permissioncreatejob.h +++ b/src/drive/permissioncreatejob.h @@ -45,6 +45,26 @@ const AccountPtr &account, QObject *parent = nullptr); ~PermissionCreateJob() 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/permissioncreatejob.cpp b/src/drive/permissioncreatejob.cpp --- a/src/drive/permissioncreatejob.cpp +++ b/src/drive/permissioncreatejob.cpp @@ -28,6 +28,7 @@ #include #include +#include using namespace KGAPI2; @@ -41,12 +42,14 @@ PermissionsList permissions; QString fileId; + bool supportsAllDrives; private: PermissionCreateJob *const q; }; PermissionCreateJob::Private::Private(PermissionCreateJob *parent): + supportsAllDrives(true), q(parent) { } @@ -60,7 +63,11 @@ const PermissionPtr permission = permissions.takeFirst(); - const QUrl url = DriveService::createPermissionUrl(fileId); + QUrl url = DriveService::createPermissionUrl(fileId); + + QUrlQuery withDriveSupportQuery(url); + withDriveSupportQuery.addQueryItem(QStringLiteral("supportsAllDrives"), supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(withDriveSupportQuery); QNetworkRequest request; request.setRawHeader("Authorization", "Bearer " + q->account()->accessToken().toLatin1()); @@ -97,6 +104,16 @@ delete d; } +bool PermissionCreateJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void PermissionCreateJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + void PermissionCreateJob::start() { d->processNext(); diff --git a/src/drive/permissiondeletejob.h b/src/drive/permissiondeletejob.h --- a/src/drive/permissiondeletejob.h +++ b/src/drive/permissiondeletejob.h @@ -54,6 +54,26 @@ const AccountPtr &account, QObject *parent = nullptr); ~PermissionDeleteJob() 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; diff --git a/src/drive/permissiondeletejob.cpp b/src/drive/permissiondeletejob.cpp --- a/src/drive/permissiondeletejob.cpp +++ b/src/drive/permissiondeletejob.cpp @@ -27,6 +27,7 @@ #include "driveservice.h" #include +#include using namespace KGAPI2; using namespace KGAPI2::Drive; @@ -36,6 +37,7 @@ public: QString fileId; QStringList permissionsIds; + bool supportsAllDrives; }; PermissionDeleteJob::PermissionDeleteJob(const QString &fileId, @@ -45,6 +47,7 @@ DeleteJob(account, parent), d(new Private) { + d->supportsAllDrives = true; d->fileId = fileId; d->permissionsIds << permission->id(); } @@ -56,6 +59,7 @@ DeleteJob(account, parent), d(new Private) { + d->supportsAllDrives = true; d->fileId = fileId; d->permissionsIds << permissionId; } @@ -67,6 +71,7 @@ DeleteJob(account, parent), d(new Private) { + d->supportsAllDrives = true; d->fileId = fileId; for (const PermissionPtr & permission : qAsConst(permissions)) { d->permissionsIds << permission->id(); @@ -80,6 +85,7 @@ DeleteJob(account, parent), d(new Private) { + d->supportsAllDrives = true; d->fileId = fileId; d->permissionsIds << permissionsIds; } @@ -89,15 +95,28 @@ delete d; } +bool PermissionDeleteJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void PermissionDeleteJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + void PermissionDeleteJob::start() { if (d->permissionsIds.isEmpty()) { emitFinished(); return; } const QString permissionId = d->permissionsIds.takeFirst(); - const QUrl url = DriveService::deletePermissionUrl(d->fileId, permissionId); + QUrl url = DriveService::deletePermissionUrl(d->fileId, permissionId); + QUrlQuery withDriveSupportQuery(url); + withDriveSupportQuery.addQueryItem(QStringLiteral("supportsAllDrives"), d->supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(withDriveSupportQuery); QNetworkRequest request(url); request.setRawHeader("Authorization", "Bearer " + account()->accessToken().toLatin1()); diff --git a/src/drive/permissionfetchjob.h b/src/drive/permissionfetchjob.h --- a/src/drive/permissionfetchjob.h +++ b/src/drive/permissionfetchjob.h @@ -48,6 +48,26 @@ const AccountPtr &account, QObject *parent = nullptr); ~PermissionFetchJob() 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/permissionfetchjob.cpp b/src/drive/permissionfetchjob.cpp --- a/src/drive/permissionfetchjob.cpp +++ b/src/drive/permissionfetchjob.cpp @@ -27,9 +27,9 @@ #include "permission.h" #include "utils.h" - #include #include +#include using namespace KGAPI2; using namespace KGAPI2::Drive; @@ -39,6 +39,7 @@ public: QString fileId; QString permissionId; + bool supportsAllDrives; }; @@ -48,6 +49,7 @@ FetchJob(account, parent), d(new Private) { + d->supportsAllDrives = true; d->fileId = fileId; } @@ -57,6 +59,7 @@ FetchJob(account, parent), d(new Private) { + d->supportsAllDrives = true; d->fileId = file->id(); } @@ -67,6 +70,7 @@ FetchJob(account, parent), d(new Private) { + d->supportsAllDrives = true; d->fileId = fileId; d->permissionId = permissionId; } @@ -78,6 +82,7 @@ FetchJob(account, parent), d(new Private) { + d->supportsAllDrives = true; d->fileId = file->id(); d->permissionId = permissionId; } @@ -87,14 +92,31 @@ delete d; } +bool PermissionFetchJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void PermissionFetchJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + void PermissionFetchJob::start() { - QNetworkRequest request; + QUrl url; if (d->permissionId.isEmpty()) { - request.setUrl(DriveService::fetchPermissionsUrl(d->fileId)); + url = DriveService::fetchPermissionsUrl(d->fileId); } else { - request.setUrl(DriveService::fetchPermissionUrl(d->fileId, d->permissionId)); + url = DriveService::fetchPermissionUrl(d->fileId, d->permissionId); } + + QUrlQuery withDriveSupportQuery(url); + withDriveSupportQuery.addQueryItem(QStringLiteral("supportsAllDrives"), d->supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(withDriveSupportQuery); + + QNetworkRequest request; + request.setUrl(url); request.setRawHeader("Authorization", "Bearer " + account()->accessToken().toLatin1()); enqueueRequest(request); diff --git a/src/drive/permissionmodifyjob.h b/src/drive/permissionmodifyjob.h --- a/src/drive/permissionmodifyjob.h +++ b/src/drive/permissionmodifyjob.h @@ -46,6 +46,26 @@ const AccountPtr &account, QObject *parent = nullptr); ~PermissionModifyJob() 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/permissionmodifyjob.cpp b/src/drive/permissionmodifyjob.cpp --- a/src/drive/permissionmodifyjob.cpp +++ b/src/drive/permissionmodifyjob.cpp @@ -29,6 +29,7 @@ #include #include +#include using namespace KGAPI2; @@ -42,12 +43,14 @@ QString fileId; PermissionsList permissions; + bool supportsAllDrives; private: PermissionModifyJob *q; }; PermissionModifyJob::Private::Private(PermissionModifyJob *parent): + supportsAllDrives(true), q(parent) { } @@ -60,7 +63,11 @@ } const PermissionPtr permission = permissions.takeFirst(); - const QUrl url = DriveService::modifyPermissionUrl(fileId, permission->id()); + QUrl url = DriveService::modifyPermissionUrl(fileId, permission->id()); + + QUrlQuery withDriveSupportQuery(url); + withDriveSupportQuery.addQueryItem(QStringLiteral("supportsAllDrives"), supportsAllDrives ? QStringLiteral("true") : QStringLiteral("false")); + url.setQuery(withDriveSupportQuery); QNetworkRequest request(url); request.setRawHeader("Authorization", "Bearer " + q->account()->accessToken().toLatin1()); @@ -96,6 +103,16 @@ delete d; } +bool PermissionModifyJob::supportsAllDrives() const +{ + return d->supportsAllDrives; +} + +void PermissionModifyJob::setSupportsAllDrives(bool supportsAllDrives) +{ + d->supportsAllDrives = supportsAllDrives; +} + void PermissionModifyJob::start() { d->processNext();