Grab account keychain entry identifier data from socket in FileProviderExt

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2022-12-30 19:52:51 +01:00
parent 0b3f06a73f
commit 9b54e6414f
No known key found for this signature in database
GPG key ID: C839200C384636B0
2 changed files with 12 additions and 3 deletions

View file

@ -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)
}
}

View file

@ -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)
}
}
}