2022-06-09 08:58:56 +02:00
|
|
|
/* generated file, don't edit. */
|
|
|
|
|
|
2024-02-01 15:21:21 +01:00
|
|
|
|
2022-06-09 08:58:56 +02:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
public class FileFacadeReceiveDispatcher {
|
|
|
|
|
let facade: FileFacade
|
|
|
|
|
init(facade: FileFacade) {
|
|
|
|
|
self.facade = facade
|
|
|
|
|
}
|
2024-03-11 16:25:43 +01:00
|
|
|
public func dispatch(method: String, arg: [String]) async throws -> String {
|
2022-06-09 08:58:56 +02:00
|
|
|
switch method {
|
|
|
|
|
case "open":
|
|
|
|
|
let location = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
let mimeType = try! JSONDecoder().decode(String.self, from: arg[1].data(using: .utf8)!)
|
|
|
|
|
try await self.facade.open(
|
|
|
|
|
location,
|
|
|
|
|
mimeType
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return "null"
|
2022-06-09 08:58:56 +02:00
|
|
|
case "openFileChooser":
|
|
|
|
|
let boundingRect = try! JSONDecoder().decode(IpcClientRect.self, from: arg[0].data(using: .utf8)!)
|
2023-02-28 13:43:55 +01:00
|
|
|
let filter = try! JSONDecoder().decode([String]?.self, from: arg[1].data(using: .utf8)!)
|
2024-10-08 13:53:04 +02:00
|
|
|
let isFileOnly = try! JSONDecoder().decode(Bool?.self, from: arg[2].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.openFileChooser(
|
2023-02-28 13:43:55 +01:00
|
|
|
boundingRect,
|
2024-10-08 13:53:04 +02:00
|
|
|
filter,
|
|
|
|
|
isFileOnly
|
2022-06-09 08:58:56 +02:00
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-13 17:36:27 +02:00
|
|
|
case "openFolderChooser":
|
|
|
|
|
let result = try await self.facade.openFolderChooser(
|
|
|
|
|
)
|
|
|
|
|
return toJson(result)
|
2025-10-27 11:53:52 +01:00
|
|
|
case "openMacImportFileChooser":
|
|
|
|
|
let result = try await self.facade.openMacImportFileChooser(
|
|
|
|
|
)
|
|
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "deleteFile":
|
|
|
|
|
let file = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
try await self.facade.deleteFile(
|
|
|
|
|
file
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return "null"
|
2022-06-09 08:58:56 +02:00
|
|
|
case "getName":
|
|
|
|
|
let file = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.getName(
|
2022-06-09 08:58:56 +02:00
|
|
|
file
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "getMimeType":
|
|
|
|
|
let file = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.getMimeType(
|
2022-06-09 08:58:56 +02:00
|
|
|
file
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "getSize":
|
|
|
|
|
let file = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.getSize(
|
2022-06-09 08:58:56 +02:00
|
|
|
file
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "putFileIntoDownloadsFolder":
|
|
|
|
|
let localFileUri = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
2023-10-12 17:54:38 +02:00
|
|
|
let fileNameToUse = try! JSONDecoder().decode(String.self, from: arg[1].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.putFileIntoDownloadsFolder(
|
2023-10-12 17:54:38 +02:00
|
|
|
localFileUri,
|
|
|
|
|
fileNameToUse
|
2022-06-09 08:58:56 +02:00
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "upload":
|
|
|
|
|
let fileUrl = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
let targetUrl = try! JSONDecoder().decode(String.self, from: arg[1].data(using: .utf8)!)
|
|
|
|
|
let method = try! JSONDecoder().decode(String.self, from: arg[2].data(using: .utf8)!)
|
2024-02-01 15:21:21 +01:00
|
|
|
let headers = try! JSONDecoder().decode([String : String].self, from: arg[3].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.upload(
|
2022-06-09 08:58:56 +02:00
|
|
|
fileUrl,
|
|
|
|
|
targetUrl,
|
|
|
|
|
method,
|
|
|
|
|
headers
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "download":
|
|
|
|
|
let sourceUrl = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
let filename = try! JSONDecoder().decode(String.self, from: arg[1].data(using: .utf8)!)
|
2024-02-01 15:21:21 +01:00
|
|
|
let headers = try! JSONDecoder().decode([String : String].self, from: arg[2].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.download(
|
2022-06-09 08:58:56 +02:00
|
|
|
sourceUrl,
|
|
|
|
|
filename,
|
|
|
|
|
headers
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "hashFile":
|
|
|
|
|
let fileUri = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.hashFile(
|
2022-06-09 08:58:56 +02:00
|
|
|
fileUri
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "clearFileData":
|
|
|
|
|
try await self.facade.clearFileData(
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return "null"
|
2022-06-09 08:58:56 +02:00
|
|
|
case "joinFiles":
|
|
|
|
|
let filename = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
let files = try! JSONDecoder().decode([String].self, from: arg[1].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.joinFiles(
|
2022-06-09 08:58:56 +02:00
|
|
|
filename,
|
|
|
|
|
files
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
case "splitFile":
|
|
|
|
|
let fileUri = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
let maxChunkSizeBytes = try! JSONDecoder().decode(Int.self, from: arg[1].data(using: .utf8)!)
|
2022-06-13 10:30:35 +02:00
|
|
|
let result = try await self.facade.splitFile(
|
2022-06-09 08:58:56 +02:00
|
|
|
fileUri,
|
|
|
|
|
maxChunkSizeBytes
|
|
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2025-03-10 16:19:11 +01:00
|
|
|
case "writeTempDataFile":
|
2022-06-16 17:27:17 +02:00
|
|
|
let file = try! JSONDecoder().decode(DataFile.self, from: arg[0].data(using: .utf8)!)
|
2025-03-10 16:19:11 +01:00
|
|
|
let result = try await self.facade.writeTempDataFile(
|
2022-06-16 17:27:17 +02:00
|
|
|
file
|
2022-06-09 08:58:56 +02:00
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2025-03-10 16:19:11 +01:00
|
|
|
case "writeToAppDir":
|
|
|
|
|
let content = try! JSONDecoder().decode(DataWrapper.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
let path = try! JSONDecoder().decode(String.self, from: arg[1].data(using: .utf8)!)
|
|
|
|
|
try await self.facade.writeToAppDir(
|
|
|
|
|
content,
|
|
|
|
|
path
|
|
|
|
|
)
|
|
|
|
|
return "null"
|
|
|
|
|
case "readFromAppDir":
|
|
|
|
|
let path = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
let result = try await self.facade.readFromAppDir(
|
|
|
|
|
path
|
|
|
|
|
)
|
|
|
|
|
return toJson(result)
|
2022-06-16 17:27:17 +02:00
|
|
|
case "readDataFile":
|
|
|
|
|
let filePath = try! JSONDecoder().decode(String.self, from: arg[0].data(using: .utf8)!)
|
|
|
|
|
let result = try await self.facade.readDataFile(
|
|
|
|
|
filePath
|
2022-06-09 08:58:56 +02:00
|
|
|
)
|
2022-06-13 10:30:35 +02:00
|
|
|
return toJson(result)
|
2022-06-09 08:58:56 +02:00
|
|
|
default:
|
|
|
|
|
fatalError("licc messed up! \(method)")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|