summaryrefslogtreecommitdiff
path: root/src/libclient
diff options
context:
space:
mode:
Diffstat (limited to 'src/libclient')
-rw-r--r--src/libclient/client.c20
-rw-r--r--src/libclient/client.h5
2 files changed, 22 insertions, 3 deletions
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);