From 6f1322fe474d24c58c43f3b196535c0277f108cd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 30 Sep 2024 16:04:48 +0800 Subject: [PATCH] Properly provide both user-provided username AND backing user ID to File Provider Extension Signed-off-by: Claudio Cambra --- .../FileProviderExt/FileProviderSocketLineProcessor.swift | 7 ++++--- .../Services/ClientCommunicationProtocol.h | 1 + .../Services/ClientCommunicationService.swift | 4 +++- src/gui/macOS/fileprovidersocketcontroller.cpp | 8 +++++--- src/gui/macOS/fileproviderxpc_mac.mm | 2 ++ 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift index 3a9f54a10..ebc4bc4b9 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift @@ -46,11 +46,12 @@ class FileProviderSocketLineProcessor: NSObject, LineProcessor { delegate.removeAccountConfig() } else if command == "ACCOUNT_DETAILS" { guard let accountDetailsSubsequence = splitLine.last else { return } - let splitAccountDetails = accountDetailsSubsequence.split(separator: "~", maxSplits: 2) + let splitAccountDetails = accountDetailsSubsequence.split(separator: "~", maxSplits: 3) let user = String(splitAccountDetails[0]) - let serverUrl = String(splitAccountDetails[1]) - let password = String(splitAccountDetails[2]) + let userId = String(splitAccountDetails[1]) + let serverUrl = String(splitAccountDetails[2]) + let password = String(splitAccountDetails[3]) delegate.setupDomainAccount(user: user, serverUrl: serverUrl, password: password) } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/ClientCommunicationProtocol.h b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/ClientCommunicationProtocol.h index 1ab5e8853..6f7f0e24d 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/ClientCommunicationProtocol.h +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/ClientCommunicationProtocol.h @@ -21,6 +21,7 @@ - (void)getExtensionAccountIdWithCompletionHandler:(void(^)(NSString *extensionAccountId, NSError *error))completionHandler; - (void)configureAccountWithUser:(NSString *)user + userId:(NSString *)userId serverUrl:(NSString *)serverUrl password:(NSString *)password; - (void)removeAccountConfig; diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/ClientCommunicationService.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/ClientCommunicationService.swift index 76a0f00ce..41670fe55 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/ClientCommunicationService.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/Services/ClientCommunicationService.swift @@ -48,11 +48,13 @@ class ClientCommunicationService: NSObject, NSFileProviderServiceSource, NSXPCLi completionHandler(accountUserId, nil) } - func configureAccount(withUser user: String, + func configureAccount(withUser user: String, + userId: String, serverUrl: String, password: String) { Logger.desktopClientConnection.info("Received configure account information over client communication service") self.fpExtension.setupDomainAccount(user: user, + userId: userId, serverUrl: serverUrl, password: password) } diff --git a/src/gui/macOS/fileprovidersocketcontroller.cpp b/src/gui/macOS/fileprovidersocketcontroller.cpp index fcd5517b7..dad2032b5 100644 --- a/src/gui/macOS/fileprovidersocketcontroller.cpp +++ b/src/gui/macOS/fileprovidersocketcontroller.cpp @@ -213,13 +213,15 @@ void FileProviderSocketController::sendAccountDetails() const const auto credentials = account->credentials(); Q_ASSERT(credentials); - const auto accountUser = account->davUser(); - const auto accountUrl = account->url().toString(); - const auto accountPassword = credentials->password(); + const auto accountUser = credentials->user(); // User-provided username/email + const auto accountUserId = account->davUser(); // Backing user id on server + const auto accountUrl = account->url().toString(); // Server base URL + const auto accountPassword = credentials->password(); // Account password // We cannot use colons as separators here due to "https://" in the url const auto message = QString(QStringLiteral("ACCOUNT_DETAILS:") + accountUser + "~" + + accountUserId + "~" + accountUrl + "~" + accountPassword); sendMessage(message); diff --git a/src/gui/macOS/fileproviderxpc_mac.mm b/src/gui/macOS/fileproviderxpc_mac.mm index e94dc2cbc..b7128cf69 100644 --- a/src/gui/macOS/fileproviderxpc_mac.mm +++ b/src/gui/macOS/fileproviderxpc_mac.mm @@ -64,11 +64,13 @@ void FileProviderXPC::authenticateExtension(const QString &extensionAccountId) c const auto account = accountState->account(); const auto credentials = account->credentials(); NSString *const user = credentials->user().toNSString(); + NSString *const userId = account->davUser().toNSString(); NSString *const serverUrl = account->url().toString().toNSString(); NSString *const password = credentials->password().toNSString(); const auto clientCommService = (NSObject *)_clientCommServices.value(extensionAccountId); [clientCommService configureAccountWithUser:user + userId:userId serverUrl:serverUrl password:password]; }