From 529d83b19e502b2d2c951954112e4faf00101452 Mon Sep 17 00:00:00 2001 From: Javier Hernandez Date: Thu, 11 Jan 2024 11:53:41 +0100 Subject: rest: Support adding clients inside folder Add support for adding clients that are inside a folder. Add new folder_id field, if zero it means computer is not in a folder. --- src/dbi.h | 1 + src/rest.c | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/dbi.h b/src/dbi.h index 3b88861..37ecf2b 100644 --- a/src/dbi.h +++ b/src/dbi.h @@ -82,6 +82,7 @@ struct og_computer { unsigned int repo_id; unsigned int center; unsigned int room; + unsigned int folder_id; unsigned int id; bool maintenance; bool remote; diff --git a/src/rest.c b/src/rest.c index bf2e1e5..75a4782 100644 --- a/src/rest.c +++ b/src/rest.c @@ -2130,6 +2130,11 @@ static int og_cmd_post_client_add(json_t *element, sizeof(computer.serial_number)); } else if (!strcmp(key, "hardware_id")) { err = og_json_parse_uint(value, &computer.hardware_id); + } else if (!strcmp(key, "folder_id")) { + err = og_json_parse_uint(value, &computer.folder_id); + if (!err) + computer.folder_id = computer.folder_id & 0x0000ffff; + } else if (!strcmp(key, "netdriver")) { err = og_json_parse_string_copy(value, computer.netdriver, @@ -2221,16 +2226,16 @@ static int og_cmd_post_client_add(json_t *element, " oglivedir," " inremotepc," " maintenance" - ") VALUES ('%s', '%s', '%s', '%s', %u, 0, %u," + ") VALUES ('%s', '%s', '%s', '%s', %u, %u, %u," " %u, '%s', '%s', '%s', '%s'," " '%s', %u, %u)", computer.name, computer.serial_number, computer.ip, computer.mac, computer.room, - computer.hardware_id, computer.repo_id, - computer.netmask, computer.boot, - computer.netiface, computer.netdriver, - computer.livedir, computer.remote, - computer.maintenance); + computer.folder_id, computer.hardware_id, + computer.repo_id, computer.netmask, + computer.boot, computer.netiface, + computer.netdriver, computer.livedir, + computer.remote, computer.maintenance); if (!result) { dbi_conn_error(dbi->conn, &msglog); -- cgit v1.2.3-18-g5258