class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension {
let domain: NSFileProviderDomain
var socketClient: LocalSocketClient = LocalSocketClient()
+ var ncAccount: FileProviderDomainNextcloudAccountData = FileProviderDomainNextcloudAccountData()
required init(domain: NSFileProviderDomain) {
self.domain = domain
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)
+ }
}
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;
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)
}
}
}