ipc: add GET_BINDING_STATE request

This commit is contained in:
Ronan Pigott 2020-06-13 20:39:57 -07:00
parent f9361ae36c
commit 4a5f7d3721
4 changed files with 47 additions and 1 deletions

View file

@ -286,11 +286,18 @@ static void pretty_print_config(json_object *c) {
printf("%s\n", json_object_get_string(config));
}
static void pretty_print_binding_state(json_object *m) {
json_object *name;
json_object_object_get_ex(m, "name", &name);
printf("%s\n", json_object_get_string(name));
}
static void pretty_print(int type, json_object *resp) {
if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES &&
type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS &&
type != IPC_GET_VERSION && type != IPC_GET_SEATS &&
type != IPC_GET_CONFIG && type != IPC_SEND_TICK) {
type != IPC_GET_CONFIG && type != IPC_SEND_TICK &&
type != IPC_GET_BINDING_STATE) {
printf("%s\n", json_object_to_json_string_ext(resp,
JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED));
return;
@ -310,6 +317,11 @@ static void pretty_print(int type, json_object *resp) {
return;
}
if (type == IPC_GET_BINDING_STATE) {
pretty_print_binding_state(resp);
return;
}
json_object *obj;
size_t len = json_object_array_length(resp);
for (size_t i = 0; i < len; ++i) {
@ -440,6 +452,8 @@ int main(int argc, char **argv) {
type = IPC_GET_VERSION;
} else if (strcasecmp(cmdtype, "get_binding_modes") == 0) {
type = IPC_GET_BINDING_MODES;
} else if (strcasecmp(cmdtype, "get_binding_state") == 0) {
type = IPC_GET_BINDING_STATE;
} else if (strcasecmp(cmdtype, "get_config") == 0) {
type = IPC_GET_CONFIG;
} else if (strcasecmp(cmdtype, "send_tick") == 0) {