Settings, no password yet
This commit is contained in:
@@ -84,6 +84,11 @@ final class XPCClient
|
||||
return results
|
||||
}
|
||||
|
||||
public func syncConversation(conversationId: String) async throws {
|
||||
let req = makeRequest(method: "SyncConversation", arguments: ["conversation_id": xpcString(conversationId)])
|
||||
_ = try await sendSync(req)
|
||||
}
|
||||
|
||||
public func getMessages(conversationId: String, limit: Int = 100, offset: Int = 0) async throws -> [Serialized.Message] {
|
||||
var args: [String: xpc_object_t] = [:]
|
||||
args["conversation_id"] = xpcString(conversationId)
|
||||
@@ -137,6 +142,24 @@ final class XPCClient
|
||||
|
||||
return FileHandle(fileDescriptor: fd, closeOnDealloc: true)
|
||||
}
|
||||
|
||||
public func getSettings() async throws -> Serialized.Settings {
|
||||
let req = makeRequest(method: "GetAllSettings")
|
||||
guard let reply = try await sendSync(req), xpc_get_type(reply) == XPC_TYPE_DICTIONARY else { throw Error.typeError }
|
||||
return Serialized.Settings.fromXPC(reply) ?? Serialized.Settings(serverUrl: "", username: "")
|
||||
}
|
||||
|
||||
public func setSettings(settings: Serialized.Settings) async throws {
|
||||
let req = makeRequest(
|
||||
method: "UpdateSettings",
|
||||
arguments: [
|
||||
"server_url": xpcString(settings.serverUrl),
|
||||
"username": xpcString(settings.username),
|
||||
]
|
||||
)
|
||||
|
||||
_ = try await sendSync(req)
|
||||
}
|
||||
|
||||
// MARK: - Types
|
||||
|
||||
|
||||
Reference in New Issue
Block a user