From: Claudio Cambra Date: Fri, 30 Dec 2022 18:52:51 +0000 (+0100) Subject: Grab account keychain entry identifier data from socket in FileProviderExt X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~96^2^2~55^2~304 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9b54e6414fcb9e0da40fc9d69637fe2aa6a5762c;p=nextcloud-desktop.git Grab account keychain entry identifier data from socket in FileProviderExt Signed-off-by: Claudio Cambra --- diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift index b162508da..f31f02b97 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension.swift @@ -19,6 +19,7 @@ import NCDesktopClientSocketKit class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension { let domain: NSFileProviderDomain var socketClient: LocalSocketClient = LocalSocketClient() + var ncAccount: FileProviderDomainNextcloudAccountData = FileProviderDomainNextcloudAccountData() required init(domain: NSFileProviderDomain) { self.domain = domain @@ -93,10 +94,14 @@ class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension { self.socketClient.start(); } - func sendDelegateFileProviderDomainIdentifier() { + func sendFileProviderDomainIdentifier() { let command = "FILE_PROVIDER_DOMAIN_IDENTIFIER_REQUEST_REPLY" let argument = domain.identifier.rawValue let message = command + ":" + argument + "\n" socketClient.sendMessage(message) } + + func setupDomainAccount(keychainAccount:String) { + ncAccount = FileProviderDomainNextcloudAccountData(withKeychainAccount:keychainAccount) + } } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift index 038bb7426..5589e101e 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift @@ -25,7 +25,7 @@ class FileProviderSocketLineProcessor: NSObject, LineProcessor { func process(_ line: String) { NSLog("Processing file provider line: %@", line) - let splitLine = line.split(separator: ":") + let splitLine = line.split(separator: ":", maxSplits: 1) guard let commandSubsequence = splitLine.first else { NSLog("Input line did not have a first element") return; @@ -34,7 +34,11 @@ class FileProviderSocketLineProcessor: NSObject, LineProcessor { NSLog("Received command: %@", command) if (command == "SEND_FILE_PROVIDER_DOMAIN_IDENTIFIER") { - delegate.sendDelegateFileProviderDomainIdentifier() + delegate.sendFileProviderDomainIdentifier() + } else if (command == "ACCOUNT_KEYCHAIN_NAME") { + guard let keychainAccountSubsequence = splitLine.last else { return } + let keychainAccountString = String(keychainAccountSubsequence) + delegate.setupDomainAccount(keychainAccount:keychainAccountString) } } }