From 29fa4f8d667d543595e652e7402d395d507ba464 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 12 Nov 2024 12:12:31 -0500 Subject: Add user volume, simple client add cli Signed-off-by: Andrew Opalach --- src/libclient/client.c | 20 ++++++++++++++++++-- src/libclient/client.h | 5 ++++- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/libclient') diff --git a/src/libclient/client.c b/src/libclient/client.c index 0776842..d7a2325 100644 --- a/src/libclient/client.c +++ b/src/libclient/client.c @@ -50,7 +50,7 @@ static void connection_callback(void *userdata, struct aki_rpc_connection *conn) static void connection_closed_callback(void *userdata, struct aki_rpc_connection *conn) { struct camu_client *client = (struct camu_client *)userdata; - al_assert(client->conn == conn); + al_assert(client->conn == NULL || client->conn == conn); client->conn = NULL; } @@ -59,6 +59,7 @@ bool camu_client_login(struct camu_client *client, struct aki_event_loop *loop, { client->loop = loop; al_str_clone(&client->username, username); + client->conn = NULL; aki_rpc_init(&client->client, client->loop, connection_callback, connection_closed_callback, client); for (u32 i = 0; i < AL_ARRAY_SIZE(commands); i++) { commands[i].userdata = client; @@ -109,7 +110,17 @@ void camu_client_get_page(struct camu_client *client, s32 id, u32 num) aki_rpc_connection_command(client->conn, packet, NULL, NULL); } -void camu_client_add(struct camu_client *client, str *list, str *unique_id, u32 index) +void camu_client_add_from_path(struct camu_client *client, str *list, str *path) +{ + struct aki_packet *packet = aki_rpc_get_packet(&client->client, CAMU_SERVER_LIST_ACTION); + aki_packet_write_str(packet, list); + aki_packet_write_u8(packet, CAMU_LIST_ADD); + aki_packet_write_u8(packet, CAMU_RESOURCE_FILE); + aki_packet_write_str(packet, path); + aki_rpc_connection_command(client->conn, packet, NULL, NULL); +} + +void camu_client_add_from_post(struct camu_client *client, str *list, str *unique_id, u32 index) { struct aki_packet *packet = aki_rpc_get_packet(&client->client, CAMU_SERVER_LIST_ACTION); aki_packet_write_str(packet, list); @@ -119,3 +130,8 @@ void camu_client_add(struct camu_client *client, str *list, str *unique_id, u32 aki_packet_write_u32(packet, index); aki_rpc_connection_command(client->conn, packet, NULL, NULL); } + +void camu_client_disconnect(struct camu_client *client) +{ + aki_rpc_conn_flush(client->conn); +} diff --git a/src/libclient/client.h b/src/libclient/client.h index 02a6639..c073c9e 100644 --- a/src/libclient/client.h +++ b/src/libclient/client.h @@ -28,4 +28,7 @@ void camu_client_toggle_sink(struct camu_client *client, str *sink, str *list, b void camu_client_create_search(struct camu_client *client, str *module, str *query); void camu_client_get_page(struct camu_client *client, s32 id, u32 num); -void camu_client_add(struct camu_client *client, str *list, str *unique_id, u32 index); +void camu_client_add_from_path(struct camu_client *client, str *list, str *path); +void camu_client_add_from_post(struct camu_client *client, str *list, str *unique_id, u32 index); + +void camu_client_disconnect(struct camu_client *client); -- cgit v1.2.3-101-g0448