From 84e6c164af5a36f0b3dc51ceeae146813938fe89 Mon Sep 17 00:00:00 2001 From: Pawel Kurowski Date: Sun, 14 Jan 2018 14:08:54 +0100 Subject: [PATCH] launch universal-switch, if any of associated vconf flags is set Change-Id: I9efc756419d76bc79b8dd9a531a775f3eacdfe13 --- bus/at-spi-bus-launcher.c | 77 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c index 118379f..ee4735d 100644 --- a/bus/at-spi-bus-launcher.c +++ b/bus/at-spi-bus-launcher.c @@ -37,6 +37,9 @@ //TODO: move to vconf/vconf-internal-setting-keys.h? #define VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH "db/setting/accessibility/universal-switch" +#define VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SCANNING "db/setting/accessibility/universal-switch/scanning" + +#define MAX_NUMBER_OF_KEYS_PER_CLIENT 2 #define APP_CONTROL_OPERATION_SCREEN_READ "http://tizen.org/appcontrol/operation/read_screen" #define APP_CONTROL_OPERATION_UNIVERSAL_SWITCH "http://tizen.org/appcontrol/operation/universal_switch" @@ -80,7 +83,8 @@ typedef enum { typedef struct { const char * name; const char * app_control_operation; - const char * vconf_key; + const char * vconf_key[MAX_NUMBER_OF_KEYS_PER_CLIENT]; + int number_of_keys; int launch_repeats; int pid; } A11yBusClient; @@ -971,10 +975,26 @@ _terminate_client(A11yBusClient *client) void vconf_client_cb(keynode_t *node, void *user_data) { A11yBusClient *client = user_data; - int client_needed = vconf_keynode_get_bool(node); - LOGD("vconf_keynode_get_bool(node): %i", client_needed); - if (client_needed < 0) - return; + + gboolean client_needed = FALSE; + int i; + for (i = 0; i < client->number_of_keys; i++) { + int status = 0; + int ret =vconf_get_bool(client->vconf_key[i], &status); + if (ret != 0) + { + LOGD("Could not read %s key value.\n", client->vconf_key[i]); + return; + } + LOGD("vconf_keynode_get_bool(node): %i", status); + if (status < 0) + return; + + if (status == 1) { + client_needed = TRUE; + break; + } + } //check if process really exists (e.g didn't crash) if (client->pid > 0) @@ -997,26 +1017,32 @@ static gboolean register_executable(A11yBusClient *client) { gboolean client_needed = FALSE; - if(!client->vconf_key) { - LOGE("Vconf_key missing for client: %s \n", client->vconf_key); - return FALSE; - } + int i; + for (i = 0; i < client->number_of_keys; i++) { + if (!client->vconf_key[i]) { + LOGE("Vconf_key missing for client: %d \n", i); + return FALSE; + } - int ret = vconf_get_bool(client->vconf_key, &client_needed); - if (ret != 0) - { - LOGD("Could not read %s key value.\n", client->vconf_key); - return FALSE; - } - ret = vconf_notify_key_changed(client->vconf_key, vconf_client_cb, client); - if(ret != 0) - { - LOGD("Could not add information level callback\n"); - return FALSE; - } + int status = 0; + int ret = vconf_get_bool(client->vconf_key[i], &status); + if (ret != 0) + { + LOGD("Could not read %s key value.\n", client->vconf_key[i]); + return FALSE; + } + ret = vconf_notify_key_changed(client->vconf_key[i], vconf_client_cb, client); + if (ret != 0) + { + LOGD("Could not add information level callback\n"); + return FALSE; + } + if (status) + client_needed = TRUE; + } if (client_needed) - g_timeout_add_seconds(2,_launch_process_repeat_until_success, client); + g_timeout_add_seconds(2,_launch_process_repeat_until_success, client); return TRUE; } @@ -1045,11 +1071,14 @@ main (int argc, _global_app->screen_reader.name = "screen-reader"; _global_app->screen_reader.app_control_operation = APP_CONTROL_OPERATION_SCREEN_READ; - _global_app->screen_reader.vconf_key = VCONFKEY_SETAPPL_ACCESSIBILITY_TTS; + _global_app->screen_reader.vconf_key[0] = VCONFKEY_SETAPPL_ACCESSIBILITY_TTS; + _global_app->screen_reader.number_of_keys = 1; _global_app->universal_switch.name = "universal-switch"; _global_app->universal_switch.app_control_operation = APP_CONTROL_OPERATION_UNIVERSAL_SWITCH; - _global_app->universal_switch.vconf_key = VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH; + _global_app->universal_switch.vconf_key[0] = VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH; + _global_app->universal_switch.vconf_key[1] = VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SCANNING; + _global_app->universal_switch.number_of_keys = 2; for (i = 1; i < argc; i++) { -- 2.7.4