Add ability for fileprovidersocketcontroller to send keychain account identifier...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 30 Dec 2022 15:36:13 +0000 (16:36 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 12 May 2023 05:21:09 +0000 (13:21 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/macOS/fileprovidersocketcontroller.cpp
src/gui/macOS/fileprovidersocketcontroller.h

index ec54da294c03896a3845edd854218f642f022fca..a473b55814da679a3d8dd83b4fcc0ff914399f21 100644 (file)
@@ -81,6 +81,7 @@ void FileProviderSocketController::parseReceivedLine(const QString &receivedLine
 
     if (command == QStringLiteral("FILE_PROVIDER_DOMAIN_IDENTIFIER_REQUEST_REPLY")) {
         _accountState = accountStateFromFileProviderDomainIdentifier(argument);
+        sendAccountKeychainEntryKey();
         return;
     }
 
@@ -134,6 +135,22 @@ void FileProviderSocketController::requestFileProviderDomainInfo() const
     sendMessage(requestMessage);
 }
 
+void FileProviderSocketController::sendAccountKeychainEntryKey() const
+{
+    Q_ASSERT(_accountState);
+    const auto account = _accountState->account();
+    Q_ASSERT(account);
+    const auto credentials = account->credentials();
+    Q_ASSERT(credentials);
+    const auto accountUrl = account->url().toString();
+    const auto accountUser = account->credentials()->user();
+    const auto accountId = account->id();
+    const auto accountKey = credentials->keychainKey(accountUrl, accountUser, accountId);
+
+    const auto message = QString(QStringLiteral("ACCOUNT_KEYCHAIN_NAME:") + accountKey);
+    sendMessage(message);
+}
+
 }
 
 }
index 6e3321494271b6fb8799b93e46276460393c1d78..67a4ebfd2fa0499076aa265517d0ae9a2de8e55c 100644 (file)
@@ -45,6 +45,7 @@ private slots:
 
     void parseReceivedLine(const QString &receivedLine);
     void requestFileProviderDomainInfo() const;
+    void sendAccountKeychainEntryKey() const;
 
 private:
     static AccountStatePtr accountStateFromFileProviderDomainIdentifier(const QString &domainIdentifier);