summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sturmlechner <asturm@gentoo.org>2019-08-15 19:09:01 +0200
committerAndreas Sturmlechner <asturm@gentoo.org>2019-08-15 19:09:43 +0200
commit538efaea5738d193f38cd76a5a4afe12837d1347 (patch)
tree6ba208b3f3fe932727aa29cc03391b129ed1e1f2 /kde-misc
parentkde-misc/kio-gdrive: Revbump for >=kde-apps/libkgapi-19.08.0 compat (diff)
downloadgentoo-538efaea5738d193f38cd76a5a4afe12837d1347.tar.gz
gentoo-538efaea5738d193f38cd76a5a4afe12837d1347.tar.bz2
gentoo-538efaea5738d193f38cd76a5a4afe12837d1347.zip
kde-misc/kio-gdrive: Add patch to refresh credentials
Package-Manager: Portage-2.3.71, Repoman-2.3.17 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Diffstat (limited to 'kde-misc')
-rw-r--r--kde-misc/kio-gdrive/files/kio-gdrive-1.2.6-refresh-credentials.patch101
-rw-r--r--kde-misc/kio-gdrive/kio-gdrive-1.2.6-r1.ebuild5
2 files changed, 105 insertions, 1 deletions
diff --git a/kde-misc/kio-gdrive/files/kio-gdrive-1.2.6-refresh-credentials.patch b/kde-misc/kio-gdrive/files/kio-gdrive-1.2.6-refresh-credentials.patch
new file mode 100644
index 000000000000..2d5958827866
--- /dev/null
+++ b/kde-misc/kio-gdrive/files/kio-gdrive-1.2.6-refresh-credentials.patch
@@ -0,0 +1,101 @@
+From 4ded388b2b2672f5f7fb953a0150a69fcfaa7cb0 Mon Sep 17 00:00:00 2001
+From: David Barchiesi <david@barchie.si>
+Date: Mon, 8 Jul 2019 09:54:08 +0200
+Subject: Re get Google credentials from KAccounts when a refresh is needed.
+
+Summary: Currently, when the Google access token in use expires, the KIO slave silently ignores refreshing the token (only 'not implemented' gets logged) and fails all subsequent api requests. This patch prevents the slave from breaking by requesting new credentials from KAccounts.
+
+Test Plan: Open a Google Drive folder in Dolphin, wait until accounts token needs a refresh, open another Google Drive folder. The folder loads because a new access token was requested.
+
+Reviewers: elvisangelaccio
+
+Reviewed By: elvisangelaccio
+
+Subscribers: mck182, elvisangelaccio
+
+Differential Revision: https://phabricator.kde.org/D22009
+---
+ src/kaccountsmanager.cpp | 45 ++++++++++++++++++++++++++++++++-------------
+ src/kaccountsmanager.h | 2 ++
+ 2 files changed, 34 insertions(+), 13 deletions(-)
+
+diff --git a/src/kaccountsmanager.cpp b/src/kaccountsmanager.cpp
+index 08272df..dc35852 100644
+--- a/src/kaccountsmanager.cpp
++++ b/src/kaccountsmanager.cpp
+@@ -85,8 +85,19 @@ AccountPtr KAccountsManager::createAccount()
+
+ AccountPtr KAccountsManager::refreshAccount(const AccountPtr &account)
+ {
+- Q_UNUSED(account)
+- qCWarning(GDRIVE) << Q_FUNC_INFO << "not implemented.";
++ const QString accountName = account->accountName();
++ for (auto it = m_accounts.constBegin(); it != m_accounts.constEnd(); ++it) {
++ if (it.value()->accountName() != accountName) {
++ continue;
++ }
++
++ const auto id = it.key();
++ qCDebug(GDRIVE) << "Refreshing" << accountName;
++ auto gapiAccount = getAccountCredentials(id, accountName);
++ m_accounts.insert(id, gapiAccount);
++ return gapiAccount;
++ }
++
+ return {};
+ }
+
+@@ -143,19 +154,27 @@ void KAccountsManager::loadAccounts()
+ }
+ qCDebug(GDRIVE) << account->displayName() << "supports gdrive!";
+
+- auto job = new GetCredentialsJob(id, nullptr);
+- job->exec();
++ auto gapiAccount = getAccountCredentials(id, account->displayName());
++ m_accounts.insert(id, gapiAccount);
++ }
++ }
++}
+
+- auto gapiAccount = AccountPtr(new Account(account->displayName(),
+- job->credentialsData().value(QStringLiteral("AccessToken")).toString(),
+- job->credentialsData().value(QStringLiteral("RefreshToken")).toString()));
++AccountPtr KAccountsManager::getAccountCredentials(Accounts::AccountId id, const QString& displayName)
++{
++ auto job = new GetCredentialsJob(id, nullptr);
++ job->exec();
+
+- const auto scopes = job->credentialsData().value(QStringLiteral("Scope")).toStringList();
+- for (const auto &scope : scopes) {
+- gapiAccount->addScope(QUrl::fromUserInput(scope));
+- }
++ auto gapiAccount = AccountPtr(new Account(displayName,
++ job->credentialsData().value(QStringLiteral("AccessToken")).toString(),
++ job->credentialsData().value(QStringLiteral("RefreshToken")).toString()));
+
+- m_accounts.insert(id, gapiAccount);
+- }
++ const auto scopes = job->credentialsData().value(QStringLiteral("Scope")).toStringList();
++ for (const auto &scope : scopes) {
++ gapiAccount->addScope(QUrl::fromUserInput(scope));
+ }
++
++ qCDebug(GDRIVE) << "Got account credentials for:" << gapiAccount->accountName() << ", accessToken:" << gapiAccount->accessToken() << ", refreshToken:" << gapiAccount->refreshToken();
++
++ return gapiAccount;
+ }
+diff --git a/src/kaccountsmanager.h b/src/kaccountsmanager.h
+index 235d11a..d2dbc43 100644
+--- a/src/kaccountsmanager.h
++++ b/src/kaccountsmanager.h
+@@ -40,6 +40,8 @@ public:
+ private:
+ void loadAccounts();
+
++ KGAPI2::AccountPtr getAccountCredentials(Accounts::AccountId id, const QString& displayName);
++
+ QMap<Accounts::AccountId, KGAPI2::AccountPtr> m_accounts;
+ };
+
+--
+cgit v1.1
diff --git a/kde-misc/kio-gdrive/kio-gdrive-1.2.6-r1.ebuild b/kde-misc/kio-gdrive/kio-gdrive-1.2.6-r1.ebuild
index 41e4f617d5c1..f6f2fa71b1fa 100644
--- a/kde-misc/kio-gdrive/kio-gdrive-1.2.6-r1.ebuild
+++ b/kde-misc/kio-gdrive/kio-gdrive-1.2.6-r1.ebuild
@@ -39,7 +39,10 @@ BDEPEND="dev-util/intltool"
DOCS=( README.md )
-PATCHES=( "${FILESDIR}"/${P}-libkgapi-19.08-{1,2}.patch )
+PATCHES=(
+ "${FILESDIR}"/${P}-libkgapi-19.08-{1,2}.patch
+ "${FILESDIR}"/${P}-refresh-credentials.patch
+)
src_configure() {
local mycmakeargs=(