From 366eb888415f30b8c00610991760a6e91d1b39f4 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Tue, 13 Dec 2016 17:16:58 +0900 Subject: [PATCH 01/16] Fix log tag in result cb(LOG_DEBUG -> LOG_INFO) Change-Id: I09e5cf6e5afa0cc60a7217010bcc3347aac3a86b Signed-off-by: Suyeon Hwang --- client/vc.c | 4 ++-- client/vc_mgr.c | 6 +++--- client/vc_widget.c | 4 ++-- server/vcd_server.c | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/vc.c b/client/vc.c index 537c336..008396c 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1628,7 +1628,7 @@ static Eina_Bool __vc_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_DEBUG, TAG_VCC, "Result info : result text(%s) event(%d)", temp_text, event); + SLOG(LOG_INFO, TAG_VCC, "Result info : result text(%s) event(%d)", temp_text, event); vc_cmd_print_list(vc_cmd_list); @@ -1636,7 +1636,7 @@ static Eina_Bool __vc_notify_result(void *data) callback(event, vc_cmd_list, temp_text, user_data); vc_client_not_use_callback(g_vc); - SLOG(LOG_DEBUG, TAG_VCC, "Client result callback called"); + SLOG(LOG_INFO, TAG_VCC, "Client result callback called"); vc_cmd_list_destroy(vc_cmd_list, true); diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 4dfe493..791de02 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -1954,7 +1954,7 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) vc_info_parser_get_result(&temp_text, &event, &temp_message, -1, vc_cmd_list, vc_mgr_client_get_exclusive_command(g_vc_m)); - SLOG(LOG_DEBUG, TAG_VCM, "Result info : result type(%d) result text(%s) event(%d) result_message(%s)", + SLOG(LOG_INFO, TAG_VCM, "Result info : result type(%d) result text(%s) event(%d) result_message(%s)", result_type, temp_text, event, temp_message); vc_cmd_print_list(vc_cmd_list); @@ -2046,14 +2046,14 @@ static Eina_Bool __vc_mgr_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_DEBUG, TAG_VCM, "Result : result text(%s) event(%d)", temp_text, event); + SLOG(LOG_INFO, TAG_VCM, "Result : result text(%s) event(%d)", temp_text, event); vc_cmd_print_list(vc_cmd_list); vc_mgr_client_use_callback(g_vc_m); callback(event, vc_cmd_list, temp_text, user_data); vc_mgr_client_not_use_callback(g_vc_m); - SLOG(LOG_DEBUG, TAG_VCM, "Result callback called"); + SLOG(LOG_INFO, TAG_VCM, "Result callback called"); vc_cmd_list_destroy(vc_cmd_list, true); diff --git a/client/vc_widget.c b/client/vc_widget.c index fc32ff5..17eb951 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -1016,7 +1016,7 @@ static Eina_Bool __vc_widget_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); + SLOG(LOG_INFO, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); vc_cmd_print_list(vc_cmd_list); @@ -1024,7 +1024,7 @@ static Eina_Bool __vc_widget_notify_result(void *data) callback(event, vc_cmd_list, temp_text, user_data); vc_widget_client_not_use_callback(g_vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "Widget result callback called"); + SLOG(LOG_INFO, TAG_VCW, "Widget result callback called"); /* Release result */ if (NULL != temp_text) free(temp_text); diff --git a/server/vcd_server.c b/server/vcd_server.c index 41f225e..7787e21 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -451,7 +451,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int vc_info_parser_unset_result(vcd_client_manager_get_exclusive()); vcd_client_manager_set_result_text(all_result); - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)", + SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)", event, all_result, non_fixed_result, msg, count); if (VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT == vcd_client_get_recognition_mode()) { @@ -508,7 +508,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int int filtered_count = 0; int top_priority = VC_COMMAND_PRIORITY_BACKGROUND; for (i = 0; i < count; i++) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] [%d] Result id(%d)", i, result_id[i]); + SLOG(LOG_INFO, TAG_VCD, "[Server] [%d] Result id(%d)", i, result_id[i]); if (0 > result_id[i]) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Result ID(%d) is NOT valid", result_id[i]); @@ -532,7 +532,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int int is_action = 0; for (i = 0; i < filtered_count; i++) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] [%d] Filtered Result id(%d)", i, filtered_id[i]); + SLOG(LOG_INFO, TAG_VCD, "[Server] [%d] Filtered Result id(%d)", i, filtered_id[i]); if (filtered_id[i] < 0) { SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Filtered ID(%d) is NOT valid", filtered_id[i]); @@ -572,7 +572,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int } if (NULL != nlu_result) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU (%s)", nlu_result); + SLOG(LOG_INFO, TAG_VCD, "[Server] NLU (%s)", nlu_result); vc_info_parser_set_nlu_result(nlu_result); if (0 == is_action) { vc_cmd_h nlu_cmd; -- 2.7.4 From ecaab19fdc94a53a16d51f40104ce123d4c715b5 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 14 Dec 2016 16:44:28 +0900 Subject: [PATCH 02/16] Fix SVACE issue Change-Id: Ida5604af5260c977a819741581e884da6b539345 Signed-off-by: sooyeon.kim --- common/vc_cmd_db.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 5ed395c..7696982 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -1298,7 +1298,9 @@ static int __vc_db_generate_command(vc_cmd_s* cmd, char** fixed_cmd, GSList** cm // remove close brace, '}' char* temp_close = strchr(src_cmd, '}'); - temp_close[0] = '\0'; + if (NULL != temp_close) { + temp_close[0] = '\0'; + } // extract fixed command and remove space in front of '{' char *tok_ptr = NULL; -- 2.7.4 From 33e44a1ec333f64be52c8ae7494ae76311f2a8cf Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 19 Dec 2016 15:34:24 +0900 Subject: [PATCH 03/16] Fix Memory leak / Change log level of 'vcinfo' logs. Change-Id: Ic0bf404adaa3defa609cc0e75f54b758d95e8439 Signed-off-by: Suyeon Hwang --- common/vc_config_mgr.c | 56 +++++++++++++++++++++++------------------------ common/vc_config_parser.c | 39 +++++++++++++++++++-------------- common/vc_info_parser.c | 12 +++++----- common/vc_json_parser.c | 7 +++--- server/vcd_server.c | 3 +++ 5 files changed, 62 insertions(+), 55 deletions(-) diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 822f81d..b82940e 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -145,7 +145,7 @@ int __vc_config_mgr_check_engine_is_valid(const char* engine_id) SLOG(LOG_DEBUG, vc_config_tag(), "Default engine is changed : %s", g_config_info->engine_id); if (0 != vc_parser_set_engine(g_config_info->engine_id)) { - SLOG(LOG_ERROR, vc_config_tag(), " Fail to save config"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save config"); return -1; } @@ -233,7 +233,7 @@ int __vc_config_mgr_select_lang(const char* engine_id, char** language) engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, vc_config_tag(), "engine info is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] engine info is NULL"); return false; } @@ -382,13 +382,13 @@ int __vc_config_set_auto_language() /* Check current config info */ if (NULL == g_config_info) { - SLOG(LOG_ERROR, vc_config_tag(), "Current config info is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Current config info is NULL"); return VC_CONFIG_ERROR_OPERATION_FAILED; } /* Check current language */ if (NULL == g_config_info->language) { - SLOG(LOG_ERROR, vc_config_tag(), "Current config language is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Current config language is NULL"); return VC_CONFIG_ERROR_OPERATION_FAILED; } @@ -401,7 +401,7 @@ int __vc_config_set_auto_language() /* vc default language change */ char* before_lang = NULL; if (0 != vc_parser_set_language(candidate_lang)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to save default language"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save default language"); return -1; } @@ -840,7 +840,7 @@ int vc_config_mgr_unset_lang_cb(int uid) int vc_config_mgr_set_enabled_cb(int uid, vc_config_enabled_cb enabled_cb) { if (NULL == enabled_cb) { - SLOG(LOG_ERROR, vc_config_tag(), "enabled cb is NULL : uid(%d) ", uid); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] enabled cb is NULL : uid(%d) ", uid); return VC_CONFIG_ERROR_INVALID_PARAMETER; } @@ -891,7 +891,7 @@ int vc_config_mgr_unset_enabled_cb(int uid) int vc_config_mgr_get_auto_language(bool* value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -907,14 +907,14 @@ int vc_config_mgr_get_auto_language(bool* value) int vc_config_mgr_set_auto_language(bool value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } if (g_config_info->auto_lang != value) { /* Check language is valid */ if (0 != vc_parser_set_auto_lang(value)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to save engine id"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save engine id"); return -1; } g_config_info->auto_lang = value; @@ -930,12 +930,12 @@ int vc_config_mgr_set_auto_language(bool value) int vc_config_mgr_get_language_list(vc_supported_language_cb callback, void* user_data) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "There is no engine"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] There is no engine"); return -1; } @@ -986,7 +986,7 @@ int vc_config_mgr_get_language_list(vc_supported_language_cb callback, void* use int vc_config_mgr_get_default_language(char** language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -997,7 +997,7 @@ int vc_config_mgr_get_default_language(char** language) if (NULL != g_config_info->language) { *language = strdup(g_config_info->language); } else { - SLOG(LOG_ERROR, vc_config_tag(), " language is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] language is NULL"); return -1; } @@ -1007,7 +1007,7 @@ int vc_config_mgr_get_default_language(char** language) int vc_config_mgr_set_default_language(const char* language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1018,13 +1018,13 @@ int vc_config_mgr_set_default_language(const char* language) /* Check language is valid */ if (NULL != g_config_info->language) { if (0 != vc_parser_set_language(language)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to save engine id"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save engine id"); return -1; } free(g_config_info->language); g_config_info->language = strdup(language); } else { - SLOG(LOG_ERROR, vc_config_tag(), " language is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] language is NULL"); return -1; } @@ -1034,7 +1034,7 @@ int vc_config_mgr_set_default_language(const char* language) int vc_config_mgr_get_enabled(bool* value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1050,12 +1050,12 @@ int vc_config_mgr_get_enabled(bool* value) int vc_config_mgr_set_enabled(bool value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } if (0 != vc_parser_set_enabled(value)) { - SLOG(LOG_ERROR, vc_config_tag(), "Fail to set enabled"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to set enabled"); return -1; } @@ -1067,17 +1067,17 @@ int vc_config_mgr_set_enabled(bool value) int vc_config_mgr_get_nonfixed_support(bool* value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } if (NULL == value) { - SLOG(LOG_ERROR, vc_config_tag(), "Input parameter is NULL"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Input parameter is NULL"); return -1; } if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "There is no engine"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] There is no engine"); return -1; } @@ -1111,7 +1111,7 @@ int vc_config_mgr_get_nonfixed_support(bool* value) bool vc_config_check_default_engine_is_valid(const char* engine) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1145,7 +1145,7 @@ bool vc_config_check_default_engine_is_valid(const char* engine) bool vc_config_check_default_language_is_valid(const char* language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1205,7 +1205,7 @@ bool vc_config_check_default_language_is_valid(const char* language) int vc_config_mgr_set_foreground(int pid, bool value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1215,7 +1215,7 @@ int vc_config_mgr_set_foreground(int pid, bool value) int vc_config_mgr_get_foreground(int* pid) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, vc_config_tag(), "Not initialized"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Not initialized"); return -1; } @@ -1269,7 +1269,7 @@ int __vc_config_mgr_print_engine_info() j++; } } else { - SLOG(LOG_ERROR, vc_config_tag(), " language is NONE"); + SLOG(LOG_DEBUG, vc_config_tag(), " language is NONE"); } SLOG(LOG_DEBUG, vc_config_tag(), " "); iter = g_slist_next(iter); @@ -1309,4 +1309,4 @@ int __vc_config_mgr_print_client_info() SLOG(LOG_DEBUG, vc_config_tag(), "--------------------------------------------"); return 0; -} +} \ No newline at end of file diff --git a/common/vc_config_parser.c b/common/vc_config_parser.c index f4c3456..92ca095 100644 --- a/common/vc_config_parser.c +++ b/common/vc_config_parser.c @@ -128,7 +128,7 @@ int vc_parser_get_engine_info(const char* path, vc_engine_info_s** engine_info) temp->name = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] <%s> has no content", VC_TAG_ENGINE_ID); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] <%s> has no content", VC_TAG_ENGINE_ID); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)VC_TAG_ENGINE_ID)) { key = xmlNodeGetContent(cur); @@ -138,7 +138,7 @@ int vc_parser_get_engine_info(const char* path, vc_engine_info_s** engine_info) temp->uuid = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] <%s> has no content", VC_TAG_ENGINE_ID); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] <%s> has no content", VC_TAG_ENGINE_ID); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)VC_TAG_ENGINE_LANGUAGE_SET)) { xmlNodePtr lang_node = NULL; @@ -155,7 +155,7 @@ int vc_parser_get_engine_info(const char* path, vc_engine_info_s** engine_info) temp->languages = g_slist_append(temp->languages, temp_lang); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] <%s> has no content", VC_TAG_ENGINE_LANGUAGE); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] <%s> has no content", VC_TAG_ENGINE_LANGUAGE); } } @@ -171,12 +171,12 @@ int vc_parser_get_engine_info(const char* path, vc_engine_info_s** engine_info) } else if (0 == xmlStrcmp(key, (const xmlChar *)"false")) { temp->non_fixed_support = false; } else { - SLOG(LOG_ERROR, vc_config_tag(), "Auto voice is wrong"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Auto voice is wrong"); temp->non_fixed_support = false; } xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] <%s> has no content", VC_TAG_ENGINE_NON_FIXED_SUPPORT); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] <%s> has no content", VC_TAG_ENGINE_NON_FIXED_SUPPORT); } } else { @@ -257,7 +257,7 @@ int vc_parser_print_engine_info(vc_engine_info_s* engine_info) i++; } } else { - SLOG(LOG_ERROR, vc_config_tag(), " language is NONE"); + SLOG(LOG_DEBUG, vc_config_tag(), " language is NONE"); } SLOG(LOG_DEBUG, vc_config_tag(), "====================="); @@ -343,7 +343,7 @@ int vc_parser_load_config(vc_config_s** config_info) temp->engine_id = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] enable is NULL"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] enable is NULL"); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)VC_TAG_CONFIG_AUTO_LANGUAGE)) { key = xmlNodeGetContent(cur); @@ -355,13 +355,13 @@ int vc_parser_load_config(vc_config_s** config_info) } else if (0 == xmlStrcmp(key, (const xmlChar *)"off")) { temp->auto_lang = false; } else { - SLOG(LOG_ERROR, vc_config_tag(), "Auto voice is wrong"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Auto voice is wrong"); temp->auto_lang = false; } xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] voice type is NULL"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] voice type is NULL"); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)VC_TAG_CONFIG_LANGUAGE)) { key = xmlNodeGetContent(cur); @@ -371,7 +371,7 @@ int vc_parser_load_config(vc_config_s** config_info) temp->language = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] language is NULL"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] language is NULL"); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar*)VC_TAG_CONFIG_ENABLED)) { key = xmlNodeGetContent(cur); @@ -383,11 +383,11 @@ int vc_parser_load_config(vc_config_s** config_info) } else if (0 == xmlStrcmp(key, (const xmlChar *)"off")) { temp->enabled = false; } else { - SLOG(LOG_ERROR, vc_config_tag(), "Enabled service is wrong"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Enabled service is wrong"); temp->enabled = false; } } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Enabled service is NULL"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Enabled service is NULL"); } } else { @@ -656,7 +656,7 @@ int vc_parser_find_config_changed(int* auto_lang, char** language, int* enabled) xmlFree(key_old); } } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Old config and new config are different"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] Old config and new config are different"); } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)VC_TAG_CONFIG_LANGUAGE)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)VC_TAG_CONFIG_LANGUAGE)) { @@ -674,7 +674,7 @@ int vc_parser_find_config_changed(int* auto_lang, char** language, int* enabled) xmlFree(key_old); } } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] old config and new config are different"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] old config and new config are different"); } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)VC_TAG_CONFIG_ENABLED)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)VC_TAG_CONFIG_ENABLED)) { @@ -695,7 +695,7 @@ int vc_parser_find_config_changed(int* auto_lang, char** language, int* enabled) xmlFree(key_old); } } else { - SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] old config and new config are different"); + SLOG(LOG_WARN, vc_config_tag(), "[WARNING] old config and new config are different"); } } else { @@ -716,7 +716,7 @@ int vc_parser_set_foreground(int pid, bool value) int cur_pid = 0; /* Get foreground pid */ if (0 != vc_parser_get_foreground(&cur_pid)) { - SLOG(LOG_DEBUG, vc_config_tag(), "Fail to get pid from info file"); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to get pid from info file"); return -1; } @@ -759,17 +759,20 @@ int vc_parser_set_foreground(int pid, bool value) cur = xmlDocGetRootElement(doc); if (cur == NULL) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Empty document"); + xmlFreeDoc(doc); return -1; } if (xmlStrcmp(cur->name, (const xmlChar *) VC_TAG_INFO_BASE_TAG)) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] The wrong type, root node is NOT %s", VC_TAG_INFO_BASE_TAG); + xmlFreeDoc(doc); return -1; } cur = cur->xmlChildrenNode; if (cur == NULL) { SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Empty document"); + xmlFreeDoc(doc); return -1; } @@ -792,10 +795,12 @@ int vc_parser_set_foreground(int pid, bool value) int ret = xmlSaveFile(VC_RUNTIME_INFO_FOREGROUND, doc); if (0 >= ret) { - SLOG(LOG_DEBUG, vc_config_tag(), "[ERROR] Fail to save foreground info : %d", ret); + SLOG(LOG_ERROR, vc_config_tag(), "[ERROR] Fail to save foreground info : %d", ret); + xmlFreeDoc(doc); return -1; } SLOG(LOG_DEBUG, vc_config_tag(), "[Success] Save foreground info pid(%d)", pid); + xmlFreeDoc(doc); return 0; } diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index c4fc2d4..f46f80a 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -109,7 +109,7 @@ int vc_cmd_parser_delete_file(int pid, vc_cmd_type_e type) if (APP_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] fail to get app id, ret(%d)", ret); } else { - SLOG(LOG_ERROR, vc_info_tag(), "Background cmd: appid = %s", appid); + SLOG(LOG_DEBUG, vc_info_tag(), "Background cmd: appid = %s", appid); } } @@ -379,14 +379,14 @@ int vc_info_parser_get_nlu_result(char** nlu_result) int ret; ret = fscanf(fp, "size(%d)\n", &readn); if (ret <= 0) { - SLOG(LOG_DEBUG, vc_info_tag(), "[ERROR] Fail to get buffer size"); + SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to get buffer size"); fclose(fp); return -1; } SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] buffer size (%d)", readn); if (10000000 < readn || 0 > readn) { - SLOG(LOG_DEBUG, vc_info_tag(), "[ERROR] Invalid buffer size"); + SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Invalid buffer size"); fclose(fp); return -1; } @@ -413,7 +413,7 @@ int vc_info_parser_get_result_pid_list(GSList** pid_list, const char* result) { int ret = vc_db_get_result_pid_list(result, pid_list); if (0 != ret) { - SLOG(LOG_DEBUG, vc_info_tag(), "[ERROR] Fail to delete result table"); + SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Fail to delete result table"); return -1; } return 0; @@ -658,7 +658,7 @@ int __vc_cmd_parser_print_commands(GSList* cmd_list) cmd = iter->data; if (NULL == cmd) { - SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] NULL data from command list"); + SLOG(LOG_WARN, vc_info_tag(), "[WARNING] NULL data from command list"); iter = g_slist_next(iter); continue; } @@ -670,4 +670,4 @@ int __vc_cmd_parser_print_commands(GSList* cmd_list) } return 0; -} +} \ No newline at end of file diff --git a/common/vc_json_parser.c b/common/vc_json_parser.c index 748a607..8ab0e4f 100755 --- a/common/vc_json_parser.c +++ b/common/vc_json_parser.c @@ -206,7 +206,7 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati if (APP_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, vc_json_tag(), "[ERROR] fail to get app id, ret(%d)", ret); } else { - SLOG(LOG_ERROR, vc_json_tag(), "Background cmd: appid = %s", appid); + SLOG(LOG_DEBUG, vc_json_tag(), "Background cmd: appid = %s", appid); } } else { appid = strdup(temp_text); @@ -346,7 +346,7 @@ static int __vc_json_set_commands(JsonObject *root_obj, int type, char* invocati } return ret; } - SLOG(LOG_WARN, vc_json_tag(), "[INFO] pid(%d), type(%d), format(%d), domain(%d), cmd(%s), appid(%s)", cmd->pid, type, cmd->format, cmd->domain, cmd->command, cmd->appid); + SLOG(LOG_INFO, vc_json_tag(), "[INFO] pid(%d), type(%d), format(%d), domain(%d), cmd(%s), appid(%s)", cmd->pid, type, cmd->format, cmd->domain, cmd->command, cmd->appid); if (NULL != cmd->appid) { free(cmd->appid); @@ -469,5 +469,4 @@ int vc_json_set_all_commands_from_file(const char* file_path) g_object_unref(parser); return ret; -} - +} \ No newline at end of file diff --git a/server/vcd_server.c b/server/vcd_server.c index 7787e21..112e13b 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -242,18 +242,21 @@ static int __vcd_activate_app_by_appcontrol(const char* appid) ret = app_control_add_extra_data(app_control, "voice_launch", "get_result"); if (APP_CONTROL_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to add extra data, ret(%d)", ret); + app_control_destroy(app_control); return VCD_ERROR_OPERATION_FAILED; } // Set an app ID. ret = app_control_set_app_id(app_control, appid); if (APP_CONTROL_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set app id, ret(%d)", ret); + app_control_destroy(app_control); return VCD_ERROR_OPERATION_FAILED; } // Sent launch request ret = app_control_send_launch_request(app_control, NULL, NULL); if (APP_CONTROL_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send launch request, ret(%d)", ret); + app_control_destroy(app_control); return VCD_ERROR_OPERATION_FAILED; } // Destroy app control -- 2.7.4 From 7a7aae2381ae63723b86d7e3f9db05c109e25f8e Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 21 Dec 2016 14:09:21 +0900 Subject: [PATCH 04/16] Change sound stream api Change-Id: I76d900d292911691ca6ea937377758fc47a183e5 (cherry picked from commit 4147202b511a6f201695e2af9f742d76bcff5f13) --- server/vcd_recorder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index aa7f0b0..5ad08b5 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -636,7 +636,7 @@ int vcd_recorder_start() if (SOUND_MANAGER_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to acquire focus : %d", ret); } else { - ret = audio_in_set_stream_info(g_audio_h, g_stream_info_h); + ret = audio_in_set_sound_stream_info(g_audio_h, g_stream_info_h); if (AUDIO_IO_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to set stream info : %d", ret); } -- 2.7.4 From 874b9d08c169fcc47d0c13f401fa6c63f360a9d0 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Fri, 23 Dec 2016 17:26:33 +0900 Subject: [PATCH 05/16] Change deprecated api(readdir_r -> readdir) Change-Id: I2ddffe4758041c8af9dbac2c5f1119cb1a14782e Signed-off-by: Suyeon Hwang --- common/vc_config_mgr.c | 10 ++-------- server/vcd_engine_agent.c | 8 +------- server/vcd_server.c | 16 ++-------------- 3 files changed, 5 insertions(+), 29 deletions(-) mode change 100644 => 100755 common/vc_config_mgr.c mode change 100644 => 100755 server/vcd_engine_agent.c mode change 100644 => 100755 server/vcd_server.c diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c old mode 100644 new mode 100755 index 822f81d..961a3b6 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -535,9 +535,7 @@ int vc_config_mgr_initialize(int uid) /* Get file name from default engine directory */ DIR *dp = NULL; - int ret = -1; - struct dirent entry; - struct dirent *dirp = NULL; + struct dirent *dirp; g_engine_list = NULL; @@ -561,11 +559,7 @@ int vc_config_mgr_initialize(int uid) dp = opendir(VC_DEFAULT_ENGINE_INFO); if (NULL != dp) { do { - ret = readdir_r(dp, &entry, &dirp); - if (0 != ret) { - SLOG(LOG_ERROR, vc_config_tag(), "[File ERROR] Fail to read directory"); - break; - } + dirp = readdir(dp); if (NULL != dirp) { if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name)) diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c old mode 100644 new mode 100755 index 12f5754..3d9ec29 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -414,18 +414,12 @@ int __internal_update_engine_list() /* Get file name from default engine directory */ DIR *dp = NULL; - int ret = -1; - struct dirent entry; struct dirent *dirp = NULL; dp = opendir(VC_DEFAULT_ENGINE); if (NULL != dp) { do { - ret = readdir_r(dp, &entry, &dirp); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[File ERROR] Fail to read directory"); - break; - } + dirp = readdir(dp); if (NULL != dirp) { if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name)) diff --git a/server/vcd_server.c b/server/vcd_server.c old mode 100644 new mode 100755 index 7787e21..bdef2f0 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -865,8 +865,6 @@ static void __vcd_file_clean_up() SLOG(LOG_DEBUG, TAG_VCD, "== Old file clean up == "); DIR *dp = NULL; - int ret = -1; - struct dirent entry; struct dirent *dirp = NULL; dp = opendir(VC_RUNTIME_INFO_ROOT); @@ -877,11 +875,7 @@ static void __vcd_file_clean_up() char remove_path[256] = {0, }; do { - ret = readdir_r(dp, &entry, &dirp); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[File ERROR] Fail to read directory"); - break; - } + dirp = readdir(dp); if (NULL != dirp) { if (!strncmp("vc_", dirp->d_name, strlen("vc_"))) { @@ -1033,9 +1027,7 @@ static Eina_Bool __finalize_quit_ecore_loop(void *data) static void __read_proc() { DIR *dp = NULL; - struct dirent entry; struct dirent *dirp = NULL; - int ret = -1; int tmp; GList *iter = NULL; @@ -1052,11 +1044,7 @@ static void __read_proc() SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open proc"); } else { do { - ret = readdir_r(dp, &entry, &dirp); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to readdir"); - break; - } + dirp = readdir(dp); if (NULL != dirp) { tmp = atoi(dirp->d_name); -- 2.7.4 From 6558d63c58523b4d16c3b2c3e72481301c1774a5 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Thu, 22 Dec 2016 00:10:12 -0800 Subject: [PATCH 06/16] Add internal method for asr result This reverts commit a54acbf16b441a041280630fc32295d8a4355fae. Change-Id: Ia836be7836a0f228577fea2dd66ed3ea16d342df (cherry picked from commit f1a57c169d24867fced57deeef6f33f885db658f) --- client/vc_widget.c | 127 +++++++++++++++++++++++++++++++++++++++ client/vc_widget_client.c | 32 ++++++++++ client/vc_widget_client.h | 5 ++ client/vc_widget_dbus.c | 96 +++++++++++++++++++++++++++++ client/vc_widget_dbus.h | 1 + common/vc_defs.h | 3 + include/voice_control_internal.h | 17 +++++- include/voice_control_widget.h | 52 ++++++++++++++++ packaging/voice-control.spec | 1 + server/vcd_client_data.c | 28 +++++++++ server/vcd_client_data.h | 4 ++ server/vcd_dbus.c | 62 +++++++++++++++++++ server/vcd_dbus.h | 2 + server/vcd_dbus_server.c | 48 +++++++++++++++ server/vcd_dbus_server.h | 1 + server/vcd_server.c | 46 ++++++++++++-- server/vcd_server.h | 1 + 17 files changed, 520 insertions(+), 6 deletions(-) mode change 100755 => 100644 include/voice_control_widget.h diff --git a/client/vc_widget.c b/client/vc_widget.c index ff34a07..6212288 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -25,6 +25,7 @@ #include "vc_widget_dbus.h" #include "voice_control_command.h" #include "voice_control_command_expand.h" +#include "voice_control_internal.h" #include "voice_control_widget.h" @@ -384,6 +385,53 @@ int vc_widget_unprepare() return VC_ERROR_NONE; } +int vc_widget_enable_asr_result(bool enable) +{ + SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Enable asr result"); + + vc_state_e state; + if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); + SLOG(LOG_DEBUG, TAG_VCW, "====="); + SLOG(LOG_DEBUG, TAG_VCW, " "); + return VC_ERROR_INVALID_STATE; + } + + /* check state */ + if (state != VC_STATE_READY) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); + SLOG(LOG_DEBUG, TAG_VCW, "====="); + SLOG(LOG_DEBUG, TAG_VCW, " "); + return VC_ERROR_INVALID_STATE; + } + + int count = 0; + int ret = -1; + + do { + ret = vc_widget_dbus_request_enable_asr_result(g_vc_w->handle, enable); + if (0 != ret) { + if (VC_ERROR_TIMED_OUT != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to enable asr result : %s", __vc_widget_get_error_code(ret)); + break; + } else { + SLOG(LOG_WARN, TAG_VCW, "[WARNING] retry to enable asr result : %s", __vc_widget_get_error_code(ret)); + usleep(10000); + count++; + if (VC_RETRY_COUNT == count) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request"); + break; + } + } + } + } while (0 != ret); + + SLOG(LOG_DEBUG, TAG_VCW, "====="); + SLOG(LOG_DEBUG, TAG_VCW, " "); + + return ret; +} + int vc_widget_foreach_supported_languages(vc_supported_language_cb callback, void* user_data) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Foreach Supported Language"); @@ -1042,6 +1090,44 @@ void __vc_widget_cb_result() return; } +bool __vc_widget_cb_asr_result() +{ + char* temp_text; + int event; + vc_cmd_list_h vc_cmd_list = NULL; + + vc_asr_result_cb callback = NULL; + void* user_data = NULL; + + vc_widget_client_get_asr_result_cb(g_vc_w, &callback, &user_data); + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Client result callback is NULL"); + return EINA_FALSE; + } + + if (0 != vc_cmd_list_create(&vc_cmd_list)) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to create command list"); + return EINA_FALSE; + } + + vc_info_parser_get_result(&temp_text, &event, NULL, -1, vc_cmd_list, false); + + SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); + + vc_widget_client_use_callback(g_vc_w); + bool ret = callback(event, temp_text, user_data); + vc_widget_client_not_use_callback(g_vc_w); + + SLOG(LOG_DEBUG, TAG_VCW, "Widget asr result callback called"); + + /* Release result */ + if (NULL != temp_text) free(temp_text); + + vc_cmd_list_destroy(vc_cmd_list, true); + + return ret; +} + static Eina_Bool __vc_widget_notify_state_changed(void *data) { vc_state_changed_cb changed_callback = NULL; @@ -1296,6 +1382,47 @@ int vc_widget_unset_state_changed_cb() return 0; } +int vc_widget_set_asr_result_cb(vc_asr_result_cb callback, void* user_data) +{ + if (NULL == callback) + return VC_ERROR_INVALID_PARAMETER; + + vc_state_e state; + if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); + return VC_ERROR_INVALID_STATE; + } + + /* check state */ + if (state != VC_STATE_INITIALIZED) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); + return VC_ERROR_INVALID_STATE; + } + + vc_widget_client_set_asr_result_cb(g_vc_w, callback, user_data); + + return 0; +} + +int vc_widget_unset_asr_result_cb() +{ + vc_state_e state; + if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); + return VC_ERROR_INVALID_STATE; + } + + /* check state */ + if (state != VC_STATE_INITIALIZED) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); + return VC_ERROR_INVALID_STATE; + } + + vc_widget_client_set_asr_result_cb(g_vc_w, NULL, NULL); + + return 0; +} + int vc_widget_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) { if (NULL == callback) diff --git a/client/vc_widget_client.c b/client/vc_widget_client.c index 2bea424..d32c23d 100644 --- a/client/vc_widget_client.c +++ b/client/vc_widget_client.c @@ -30,6 +30,8 @@ typedef struct { vc_result_cb result_cb; void* result_user_data; + vc_asr_result_cb asr_result_cb; + void* asr_result_user_data; vc_error_cb error_cb; void* error_user_data; vc_service_state_changed_cb service_state_changed_cb; @@ -119,6 +121,8 @@ int vc_widget_client_create(vc_h* vc) widget->result_cb = NULL; widget->result_user_data = NULL; + widget->asr_result_cb = NULL; + widget->asr_result_user_data = NULL; widget->service_state_changed_cb = NULL; widget->service_state_changed_user_data = NULL; widget->state_changed_cb = NULL; @@ -262,6 +266,34 @@ int vc_widget_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_ return 0; } +int vc_widget_client_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* user_data) +{ + vc_widget_s* widget = __widget_get(vc); + + /* check handle */ + if (NULL == widget) + return VC_ERROR_INVALID_PARAMETER; + + widget->asr_result_cb = callback; + widget->asr_result_user_data = user_data; + + return 0; +} + +int vc_widget_client_get_asr_result_cb(vc_h vc, vc_asr_result_cb* callback, void** user_data) +{ + vc_widget_s* widget = __widget_get(vc); + + /* check handle */ + if (NULL == widget) + return VC_ERROR_INVALID_PARAMETER; + + *callback = widget->asr_result_cb; + *user_data = widget->asr_result_user_data; + + return 0; +} + int vc_widget_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data) { vc_widget_s* widget = __widget_get(vc); diff --git a/client/vc_widget_client.h b/client/vc_widget_client.h index 12a2a85..ca2dc90 100644 --- a/client/vc_widget_client.h +++ b/client/vc_widget_client.h @@ -19,6 +19,7 @@ #define __VC_WIDGET_CLIENT_H_ #include "voice_control_common.h" +#include "voice_control_internal.h" #include "voice_control_widget.h" #ifdef __cplusplus @@ -45,6 +46,10 @@ int vc_widget_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_da int vc_widget_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data); +int vc_widget_client_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* user_data); + +int vc_widget_client_get_asr_result_cb(vc_h vc, vc_asr_result_cb* callback, void** user_data); + int vc_widget_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data); int vc_widget_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* callback, void** user_data); diff --git a/client/vc_widget_dbus.c b/client/vc_widget_dbus.c index d491393..8ed3ff4 100644 --- a/client/vc_widget_dbus.c +++ b/client/vc_widget_dbus.c @@ -33,6 +33,8 @@ extern void __vc_widget_cb_show_tooltip(int pid, bool show); extern void __vc_widget_cb_result(); +extern bool __vc_widget_cb_asr_result(); + extern int __vc_widget_cb_service_state(int state); @@ -166,6 +168,33 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd } /* VCD_WIDGET_METHOD_RESULT */ + else if (dbus_message_is_method_call(msg, if_name, VCD_WIDGET_METHOD_ASR_RESULT)) { + SLOG(LOG_DEBUG, TAG_VCW, "===== Get widget asr result"); + int ret = 0; + if (false == __vc_widget_cb_asr_result()) + ret = 0; + else + ret = 1; + + DBusMessage* reply = dbus_message_new_method_return(msg); + if (NULL != reply) { + dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); + if (!dbus_connection_send(g_w_conn_listener, reply, NULL)) + SLOG(LOG_ERROR, TAG_VCW, ">>>> vc widget get asr result : fail to send reply"); + else + SLOG(LOG_DEBUG, TAG_VCW, ">>>> vc widget get asr result"); + + dbus_connection_flush(g_w_conn_listener); + dbus_message_unref(reply); + } else { + SLOG(LOG_ERROR, TAG_VCW, ">>>> vc widget asr get result : fail to create reply message"); + } + + SLOG(LOG_DEBUG, TAG_VCW, "====="); + SLOG(LOG_DEBUG, TAG_VCW, " "); + + } /* VCD_WIDGET_METHOD_ASR_RESULT */ + else if (dbus_message_is_signal(msg, if_name, VCD_WIDGET_METHOD_ERROR)) { SLOG(LOG_DEBUG, TAG_VCW, "===== Get widget error"); int reason; @@ -696,6 +725,73 @@ int vc_widget_dbus_set_foreground(int pid, bool value) return 0; } +int vc_widget_dbus_request_enable_asr_result(int pid, bool enable) +{ + DBusMessage* msg; + + /* create a signal & check for errors */ + msg = dbus_message_new_method_call( + VC_SERVER_SERVICE_NAME, + VC_SERVER_SERVICE_OBJECT_PATH, + VC_SERVER_SERVICE_INTERFACE, + VC_WIDGET_METHOD_ENABLE_ASR_RESULT); + + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCW, ">>>> vc widget enable asr result : Fail to make message "); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCW, ">>>> vc widget enable asr result : pid(%d), enable(%d)", pid, enable); + } + + DBusMessageIter args; + dbus_message_iter_init_append(msg, &args); + + /* Append result*/ + int temp; + if (false == enable) temp = 0; + else temp = 1; + dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(pid)); + dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(temp)); + + DBusError err; + dbus_error_init(&err); + + DBusMessage* result_msg; + int result = VC_ERROR_OPERATION_FAILED; + + result_msg = dbus_connection_send_with_reply_and_block(g_w_conn_sender, msg, g_w_waiting_time, &err); + dbus_message_unref(msg); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } + + if (NULL != result_msg) { + dbus_message_get_args(result_msg, &err, + DBUS_TYPE_INT32, &result, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCW, "<<<< Get arguments error (%s)", err.message); + dbus_error_free(&err); + result = VC_ERROR_OPERATION_FAILED; + } + dbus_message_unref(result_msg); + + if (0 == result) { + SLOG(LOG_DEBUG, TAG_VCW, "<<<< vc widget enable asr result : result = %d", result); + } else { + SLOG(LOG_ERROR, TAG_VCW, "<<<< vc widget enable asr result : result = %d", result); + } + } else { + SLOG(LOG_DEBUG, TAG_VCW, "<<<< Result Message is NULL"); + vc_widget_dbus_reconnect(); + result = VC_ERROR_TIMED_OUT; + } + + return result; +} int vc_widget_dbus_request_start(int pid, int silence) { diff --git a/client/vc_widget_dbus.h b/client/vc_widget_dbus.h index fe995c5..01fba7a 100644 --- a/client/vc_widget_dbus.h +++ b/client/vc_widget_dbus.h @@ -38,6 +38,7 @@ int vc_widget_dbus_request_start_recording(int pid, bool command); int vc_widget_dbus_set_foreground(int pid, bool value); +int vc_widget_dbus_request_enable_asr_result(int pid, bool enable); int vc_widget_dbus_request_start(int pid, int silence); diff --git a/common/vc_defs.h b/common/vc_defs.h index 5859338..095ba66 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -98,11 +98,14 @@ extern "C" { #define VC_WIDGET_METHOD_START_RECORDING "vc_widget_method_start_recording" +#define VC_WIDGET_METHOD_ENABLE_ASR_RESULT "vc_widget_method_enable_asr_result" + #define VC_WIDGET_METHOD_START "vc_widget_method_start" #define VC_WIDGET_METHOD_STOP "vc_widget_method_stop" #define VC_WIDGET_METHOD_CANCEL "vc_widget_method_cancel" #define VCD_WIDGET_METHOD_RESULT "vcd_widget_method_result" +#define VCD_WIDGET_METHOD_ASR_RESULT "vcd_widget_method_asr_result" #define VCD_WIDGET_METHOD_ERROR "vcd_widget_method_error" #define VCD_WIDGET_METHOD_HELLO "vcd_widget_method_hello" #define VCD_WIDGET_METHOD_SHOW_TOOLTIP "vcd_widget_method_show_tooltip" diff --git a/include/voice_control_internal.h b/include/voice_control_internal.h index 4935a91..8465e9e 100644 --- a/include/voice_control_internal.h +++ b/include/voice_control_internal.h @@ -19,7 +19,6 @@ #define __VOICE_CONTROL_INTERNAL_H__ #include -#include #ifdef __cplusplus @@ -28,6 +27,22 @@ extern "C" #endif /** +* @brief Called when client gets the asr recognition result from vc-daemon. +* +* @param[in] event The result event +* @param[in] result ASR text +* @param[in] user_data The user data passed from the callback registration function +* +* @return @c true when asr result is consumed \n @c false to propagate. +* +* @pre An application registers callback function using vc_mgr_set_pre_result_cb(). +* +* @see vc_widget_set_asr_result_cb() +* @see vc_widget_unset_asr_result_cb() +*/ +typedef bool (*vc_asr_result_cb)(vc_result_event_e event, const char* result, void *user_data); + +/** * @brief Sets command list from file. * @since_tizen 3.0 * @privlevel public diff --git a/include/voice_control_widget.h b/include/voice_control_widget.h old mode 100755 new mode 100644 index 2f8ca7a..03b6c89 --- a/include/voice_control_widget.h +++ b/include/voice_control_widget.h @@ -21,6 +21,7 @@ #include #include #include +#include /** @@ -515,6 +516,57 @@ int vc_widget_set_error_cb(vc_error_cb callback, void* user_data); */ int vc_widget_unset_error_cb(); +/** + * @brief Sets option for obtain ASR result as dictation via result callback. + * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/recorder + * + * @param[in] enable enable to get asr result + * + * @return 0 on success, otherwise a negative error value + * @retval #VC_ERROR_NONE Successful + * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #VC_ERROR_INVALID_STATE Invalid state + * @retval #VC_ERROR_PERMISSION_DENIED Permission denied + * @retval #VC_ERROR_NOT_SUPPORTED Not supported + * + * @pre The state should be #VC_STATE_READY. + * + */ +int vc_widget_enable_asr_result(bool enable); + +/** +* @brief Registers a callback function for an asr result. +* +* @param[in] callback Callback function to register +* @param[in] user_data The user data to be passed to the callback function +* +* @return 0 on success, otherwise a negative error value +* @retval #VC_ERROR_NONE Successful +* @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #VC_ERROR_INVALID_STATE Invalid state +* +* @pre The state should be #VC_STATE_INITIALIZED. +* +* @see vc_asr_result_cb() +* @see vc_widget_enable_asr_result() +* @see vc_widget_unset_asr_result_cb() +*/ +int vc_widget_set_asr_result_cb(vc_asr_result_cb callback, void* user_data); + +/** +* @brief Unregisters the callback function. +* +* @return 0 on success, otherwise a negative error value +* @retval #VC_ERROR_NONE Successful +* @retval #VC_ERROR_INVALID_STATE Invalid state +* +* @pre The state should be #VC_STATE_INITIALIZED. +* +* @see vc_widget_set_asr_result_cb() +*/ +int vc_widget_unset_asr_result_cb(); #ifdef __cplusplus } diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index a1e54b0..be8e8a0 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -148,6 +148,7 @@ mkdir -p %{_libdir}/voice/vc %{_includedir}/voice_control_common.h %{_includedir}/voice_control_key_defines.h %{_includedir}/voice_control_command_expand.h +%{_includedir}/voice_control_internal.h %files manager-devel %defattr(-,root,root,-) diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 70f3749..5e0253d 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -1349,3 +1349,31 @@ int vcd_client_widget_unset_command(int pid) return 0; } + +int vcd_client_widget_set_asr_result_enabled(int pid, bool enable) +{ + widget_info_s *info = NULL; + info = __widget_get_element(pid); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + info->asr_result_enabled = enable; + + return 0; +} + +int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable) +{ + widget_info_s *info = NULL; + info = __widget_get_element(pid); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + *enable = info->asr_result_enabled; + + return 0; +} \ No newline at end of file diff --git a/server/vcd_client_data.h b/server/vcd_client_data.h index 62f3120..d84ba3b 100644 --- a/server/vcd_client_data.h +++ b/server/vcd_client_data.h @@ -62,6 +62,7 @@ typedef struct { typedef struct { int pid; bool widget_cmd; + bool asr_result_enabled; } widget_info_s; typedef enum { @@ -168,6 +169,9 @@ int vcd_client_widget_set_command(int pid); int vcd_client_widget_unset_command(int pid); +int vcd_client_widget_set_asr_result_enabled(int pid, bool enable); + +int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable); #ifdef __cplusplus } diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 0d33cb3..7d0f348 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -311,6 +311,65 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type) return 0; } +int vcdc_send_asr_result(int pid, int cmd_type, bool* is_consumed) +{ + if (0 != __dbus_check()) { + return VCD_ERROR_OPERATION_FAILED; + } + + DBusMessage* msg = NULL; + + SLOG(LOG_DEBUG, TAG_VCD, "[Dbus] Result command type(%d)", cmd_type); + + switch (cmd_type) { + case VC_COMMAND_TYPE_WIDGET: + msg = __get_message(pid, VCD_WIDGET_METHOD_ASR_RESULT, VCD_CLIENT_TYPE_WIDGET); + break; + default: + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Command type is NOT valid(%d)", cmd_type); + return VCD_ERROR_INVALID_PARAMETER; + } + + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + DBusError err; + dbus_error_init(&err); + + DBusMessage* result_msg; + + int result = 0; + result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); + dbus_message_unref(msg); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } + + if (NULL != result_msg) { + dbus_message_get_args(result_msg, &err, + DBUS_TYPE_INT32, &result, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCD, "<<<< Get arguments error (%s)", err.message); + dbus_error_free(&err); + result = VCD_ERROR_OPERATION_FAILED; + } + + dbus_message_unref(result_msg); + SLOG(LOG_DEBUG, TAG_VCD, "<<<< vc send asr result : result = %d", result); + *is_consumed = result; + return VCD_ERROR_NONE; + } else { + SLOG(LOG_ERROR, TAG_VCD, "<<<< Result message is NULL "); + return VCD_ERROR_OPERATION_FAILED; + } +} + int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_result) { if (0 != __dbus_check()) { @@ -834,6 +893,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_CANCEL)) vcd_dbus_server_widget_cancel(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_ENABLE_ASR_RESULT)) + vcd_dbus_server_widget_enable_asr_result(g_conn_listener, msg); + else { SLOG(LOG_DEBUG, TAG_VCD, "Message is NOT valid"); dbus_message_unref(msg); diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h index a075a25..5c4e357 100644 --- a/server/vcd_dbus.h +++ b/server/vcd_dbus.h @@ -44,6 +44,8 @@ int vcdc_send_set_volume(int manger_pid, float volume); int vcdc_send_result(int pid, int manager_pid, int cmd_type); +int vcdc_send_asr_result(int pid, int cmd_type, bool* is_consumed); + int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_result); int vcdc_send_result_to_manager(int manger_pid, int result_type); diff --git a/server/vcd_dbus_server.c b/server/vcd_dbus_server.c index e263cdd..4a19a0b 100644 --- a/server/vcd_dbus_server.c +++ b/server/vcd_dbus_server.c @@ -1826,3 +1826,51 @@ int vcd_dbus_server_widget_cancel(DBusConnection* conn, DBusMessage* msg) return 0; } +int vcd_dbus_server_widget_enable_asr_result(DBusConnection* conn, DBusMessage* msg) +{ + DBusError err; + dbus_error_init(&err); + + int pid; + int enable; + int ret = VCD_ERROR_OPERATION_FAILED; + dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &enable, DBUS_TYPE_INVALID); + + SLOG(LOG_DEBUG, TAG_VCD, ">>>>> VCD widget enable asr result"); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget enable asr result : get arguments error (%s)", err.message); + dbus_error_free(&err); + ret = VCD_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd widget enable asr result : pid(%d) enable(%d)", pid, enable); + ret = vcd_server_widget_enable_asr_result(pid, enable); + } + + DBusMessage* reply; + reply = dbus_message_new_method_return(msg); + + if (NULL != reply) { + dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); + + if (0 == ret) { + SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + } + + if (!dbus_connection_send(conn, reply, NULL)) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); + } + + dbus_connection_flush(conn); + dbus_message_unref(reply); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); + } + + SLOG(LOG_DEBUG, TAG_VCD, "<<<<<"); + SLOG(LOG_DEBUG, TAG_VCD, " "); + + return 0; +} \ No newline at end of file diff --git a/server/vcd_dbus_server.h b/server/vcd_dbus_server.h index b29fc5d..4a7fc7b 100644 --- a/server/vcd_dbus_server.h +++ b/server/vcd_dbus_server.h @@ -108,6 +108,7 @@ int vcd_dbus_server_widget_stop(DBusConnection* conn, DBusMessage* msg); int vcd_dbus_server_widget_cancel(DBusConnection* conn, DBusMessage* msg); +int vcd_dbus_server_widget_enable_asr_result(DBusConnection* conn, DBusMessage* msg); #ifdef __cplusplus } diff --git a/server/vcd_server.c b/server/vcd_server.c index 112e13b..eeed30e 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -488,6 +488,37 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int } } #if 1 + + int pid = vcd_client_widget_get_foreground_pid(); + if (-1 != pid) { + if (NULL != all_result) { + vc_info_parser_set_result(all_result, event, msg, NULL, false); + bool enable = false; + vcd_client_widget_get_asr_result_enabled(pid, &enable); + if (true == enable) { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send ASR result to Widget client"); + bool is_consumed = false; + if (0 != vcdc_send_asr_result(pid, VC_COMMAND_TYPE_WIDGET, &is_consumed)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send asr result"); + } else { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result is consumed(%d)", is_consumed); + if (true == is_consumed) { + vcdc_send_show_tooltip(pid, false); + if (-1 != vcd_client_manager_get_pid()) { + /* Manager client is available */ + if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) { + SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result"); + } + } + + vcd_client_manager_set_exclusive(false); + return; + } + } + } + } + } + /* if nlu_result is exist, Add command handle(is_action) into result list */ /* Normal result */ SLOG(LOG_DEBUG, TAG_VCD, "[Server] === Get engine result ==="); @@ -616,11 +647,6 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int int pid = vcd_client_widget_get_foreground_pid(); if (-1 != pid) { - if (NULL != all_result) { - /* Send result text to widget */ - vcdc_send_result(pid, vcd_client_manager_get_pid(), VC_COMMAND_TYPE_WIDGET); - } - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip hide"); /* Send to hide tooltip */ vcdc_send_show_tooltip(pid, false); @@ -2228,3 +2254,13 @@ int vcd_server_widget_cancel(int pid) return VCD_ERROR_NONE; } +int vcd_server_widget_enable_asr_result(int pid, bool enable) +{ + int ret; + ret = vcd_client_widget_set_asr_result_enabled(pid, enable); + if (0 != ret) { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Fail to enable asr result : %d", ret); + } + + return ret; +} diff --git a/server/vcd_server.h b/server/vcd_server.h index 5166ccb..c8b0284 100644 --- a/server/vcd_server.h +++ b/server/vcd_server.h @@ -116,6 +116,7 @@ int vcd_server_widget_stop(int pid); int vcd_server_widget_cancel(int pid); +int vcd_server_widget_enable_asr_result(int pid, bool enable); #ifdef __cplusplus } -- 2.7.4 From c0af39d5e482d9cf06f2993426b4e37a5fb0533c Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Mon, 26 Dec 2016 16:01:46 +0900 Subject: [PATCH 07/16] Fix log level of 'vcdb' and 'vcd' logs Change-Id: I4cdee201d254a3bb3f38c704c6a54c68b13ecf5f Signed-off-by: Suyeon Hwang --- common/vc_cmd_db.c | 4 ++-- server/vcd_recorder.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 7696982..16ca81d 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -377,7 +377,7 @@ static int __vc_db_get_commands(int pid, vc_cmd_type_e type, GSList** cmd_list) if (type == temp_cmd->type) { *cmd_list = g_slist_append(*cmd_list, temp_cmd); } else { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Command type(%d) is NOT valid : request type(%d)", temp_cmd->type, type); + SLOG(LOG_WARN, vc_db_tag(), "[WARNING] Command type(%d) is NOT valid : request type(%d)", temp_cmd->type, type); } ret = sqlite3_step(stmt); if (SQLITE_DONE == ret) @@ -1487,7 +1487,7 @@ int vc_db_insert_commands_list(int pid, vc_cmd_type_e type, GSList* cmd_list, ch return ret; } } else { - SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Command type(%d) is NOT valid : request type(%d)", temp_cmd->type, type); + SLOG(LOG_WARN, vc_db_tag(), "[WARNING] Command type(%d) is NOT valid : request type(%d)", temp_cmd->type, type); } iter = g_slist_next(iter); } diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 5ad08b5..160ecec 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -580,12 +580,12 @@ int vcd_recorder_start() int ret = -1; g_buffer_count = 0; - SLOG(LOG_ERROR, TAG_VCD, "[Recorder] Enter, recorder state(%d)", g_recorder_state); + SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Enter, recorder state(%d)", g_recorder_state); if (VCD_RECORDER_STATE_RECORDING == g_recorder_state) return 0; bool started = false; - SLOG(LOG_ERROR, TAG_VCD, "[Recorder] audio type : %s", g_current_audio_type); + SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] audio type : %s", g_current_audio_type); if (NULL != g_current_audio_type) { if (0 == strncmp(VCP_AUDIO_ID_BLUETOOTH, g_current_audio_type, strlen(VCP_AUDIO_ID_BLUETOOTH))) { @@ -614,7 +614,7 @@ int vcd_recorder_start() g_bt_extend_count = 0; #endif } else if (0 == strncmp(VCP_AUDIO_ID_MSF, g_current_audio_type, strlen(VCP_AUDIO_ID_MSF))) { - SLOG(LOG_ERROR, TAG_VCD, "[Recorder] call RegisterMSFAudioCallback() function"); + SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] call RegisterMSFAudioCallback() function"); #ifdef TV_MSF_WIFI_MODE ret = RegisterMSFAudioCallback(__msf_wifi_audio_data_receive_cb, NULL); @@ -629,7 +629,7 @@ int vcd_recorder_start() } } - SLOG(LOG_ERROR, TAG_VCD, "[Recorder] started = %d", started); + SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] started = %d", started); if (false == started) { #if 0 ret = sound_manager_acquire_focus(g_stream_info_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL); -- 2.7.4 From 99db1687554d3b0bd7d5671e9f19d397378bed44 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Wed, 28 Dec 2016 21:09:18 +0900 Subject: [PATCH 08/16] Add ref count for db init/deinit Change-Id: I4234b263278ef94db192d1142b8e12a9451b9416 Signed-off-by: Wonnam Jang (cherry picked from commit 45e9a90b27cbb347f2839bd645513687520186c3) --- common/vc_cmd_db.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 16ca81d..3a040a6 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -59,6 +59,7 @@ const char* vc_db_tag() static sqlite3* db_handle = NULL; char* path = NULL; int g_fpid = -1; +int g_ref_cnt = 0; static int __vc_db_transaction(const char* transaction) { @@ -1063,6 +1064,11 @@ int vc_db_initialize(void) { SLOG(LOG_INFO, vc_db_tag(), "DB initialization"); + if (0 < g_ref_cnt) { + g_ref_cnt++; + return VC_DB_ERROR_NONE; + } + path = (char*)calloc(256, sizeof(char)); if (NULL == path) { SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to allocate memory"); @@ -1112,12 +1118,16 @@ int vc_db_initialize(void) SLOG(LOG_ERROR, vc_db_tag(), "sqlite3_exec returned %d: %s", ret, err_msg); } } - + g_ref_cnt++; return VC_DB_ERROR_NONE; } int vc_db_finalize(void) { + if (0 >= g_ref_cnt) return VC_DB_ERROR_INVALID_STATE; + if (0 != --g_ref_cnt) + return VC_DB_ERROR_NONE; + if (NULL != path) { free(path); path = NULL; -- 2.7.4 From a114d972263d15d37313543d224592f5bde19052 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 28 Dec 2016 21:50:54 +0900 Subject: [PATCH 09/16] Add internal method for enable/disable command type Change-Id: I95241d6fcab013766bb3febb5a2445c639143a28 Signed-off-by: Kwangyoun Kim (cherry picked from commit 4f7cc1642addef112004b8223eeb3372f3db7012) --- client/vc_mgr.c | 112 ++++++++++++++++++++++++++++ client/vc_mgr_dbus.c | 158 ++++++++++++++++++++++++++++++++++++++++ client/vc_mgr_dbus.h | 3 + common/vc_defs.h | 3 + include/voice_control_manager.h | 25 +++++++ server/vcd_client_data.c | 36 +++++---- server/vcd_config.c | 42 +++++++++++ server/vcd_config.h | 5 ++ server/vcd_dbus.c | 6 ++ server/vcd_dbus_server.c | 108 +++++++++++++++++++++++++++ server/vcd_dbus_server.h | 4 + server/vcd_server.c | 74 ++++++++++++++++--- server/vcd_server.h | 4 + 13 files changed, 555 insertions(+), 25 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 878f3a7..2001006 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -650,6 +650,118 @@ int vc_mgr_is_command_format_supported(vc_cmd_format_e format, bool* support) return VC_ERROR_NONE; } +int vc_mgr_enable_command_type(int cmd_type) +{ + SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Enable Command Type"); + + vc_state_e state; + if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + return VC_ERROR_INVALID_STATE; + } + + /* check state */ + if (state != VC_STATE_READY) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + return VC_ERROR_INVALID_STATE; + } + + /* Check service state */ + vc_service_state_e service_state = -1; + vc_mgr_client_get_service_state(g_vc_m, &service_state); + if (service_state != VC_SERVICE_STATE_READY) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + return VC_ERROR_INVALID_STATE; + } + + int ret; + int count = 0; + do { + ret = vc_mgr_dbus_request_enable_command_type(g_vc_m->handle, cmd_type); + if (0 != ret) { + if (VC_ERROR_TIMED_OUT != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request enable command type : %s", __vc_mgr_get_error_code(ret)); + break; + } else { + SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request enable command type : %s", __vc_mgr_get_error_code(ret)); + usleep(10000); + count++; + if (VC_RETRY_COUNT == count) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); + break; + } + } + } + } while (0 != ret); + + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + + return ret; +} + +int vc_mgr_disable_command_type(int cmd_type) +{ + SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Disable Command Type"); + + vc_state_e state; + if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + return VC_ERROR_INVALID_STATE; + } + + /* check state */ + if (state != VC_STATE_READY) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + return VC_ERROR_INVALID_STATE; + } + + /* Check service state */ + vc_service_state_e service_state = -1; + vc_mgr_client_get_service_state(g_vc_m, &service_state); + if (service_state != VC_SERVICE_STATE_READY) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'"); + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + return VC_ERROR_INVALID_STATE; + } + + int ret; + int count = 0; + do { + ret = vc_mgr_dbus_request_disable_command_type(g_vc_m->handle, cmd_type); + if (0 != ret) { + if (VC_ERROR_TIMED_OUT != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request disable command type : %s", __vc_mgr_get_error_code(ret)); + break; + } else { + SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request disable command type : %s", __vc_mgr_get_error_code(ret)); + usleep(10000); + count++; + if (VC_RETRY_COUNT == count) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); + break; + } + } + } + } while (0 != ret); + + SLOG(LOG_DEBUG, TAG_VCM, "====="); + SLOG(LOG_DEBUG, TAG_VCM, " "); + + return ret; +} + int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) { SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Set Command list"); diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c index 93cbb17..2349eea 100644 --- a/client/vc_mgr_dbus.c +++ b/client/vc_mgr_dbus.c @@ -1829,6 +1829,164 @@ int vc_mgr_dbus_request_cancel(int pid) return result; } +int vc_mgr_dbus_request_enable_command_type(int pid, int cmd_type) +{ + DBusError err; + dbus_error_init(&err); + + bool exist = dbus_bus_name_has_owner(g_m_conn_sender, VC_SERVER_SERVICE_NAME, &err); + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } + + int ret; + if (false == exist) { + ret = __dbus_restore_daemon(); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to restore daemon"); + return VC_ERROR_TIMED_OUT; + } + return VC_ERROR_OPERATION_FAILED; + } + + DBusMessage* msg; + + /* create a signal & check for errors */ + msg = dbus_message_new_method_call( + VC_SERVER_SERVICE_NAME, + VC_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */ + VC_SERVER_SERVICE_INTERFACE, /* interface name of the signal */ + VC_MANAGER_METHOD_ENABLE_COMMAND_TYPE); /* name of the signal */ + + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCM, ">>>> vc enable command type : Fail to make message "); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc enable command type : pid(%d) type(%d)", pid, cmd_type); + } + + dbus_message_append_args(msg, + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &cmd_type, + DBUS_TYPE_INVALID); + + DBusMessage* result_msg; + int result = VC_ERROR_OPERATION_FAILED; + + result_msg = dbus_connection_send_with_reply_and_block(g_m_conn_sender, msg, g_m_waiting_time, &err); + dbus_message_unref(msg); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } + + if (NULL != result_msg) { + dbus_message_get_args(result_msg, &err, + DBUS_TYPE_INT32, &result, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "<<<< Get arguments error (%s)", err.message); + dbus_error_free(&err); + result = VC_ERROR_OPERATION_FAILED; + } + dbus_message_unref(result_msg); + + if (0 == result) { + SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc enable command type : result = %d", result); + } else { + SLOG(LOG_ERROR, TAG_VCM, "<<<< vc enable command type : result = %d", result); + } + } else { + SLOG(LOG_DEBUG, TAG_VCM, "<<<< Result Message is NULL"); + vc_mgr_dbus_reconnect(); + result = VC_ERROR_TIMED_OUT; + } + + return result; +} + +int vc_mgr_dbus_request_disable_command_type(int pid, int cmd_type) +{ + DBusError err; + dbus_error_init(&err); + + bool exist = dbus_bus_name_has_owner(g_m_conn_sender, VC_SERVER_SERVICE_NAME, &err); + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } + + int ret; + if (false == exist) { + ret = __dbus_restore_daemon(); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to restore daemon"); + return VC_ERROR_TIMED_OUT; + } + return VC_ERROR_OPERATION_FAILED; + } + + DBusMessage* msg; + + /* create a signal & check for errors */ + msg = dbus_message_new_method_call( + VC_SERVER_SERVICE_NAME, + VC_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */ + VC_SERVER_SERVICE_INTERFACE, /* interface name of the signal */ + VC_MANAGER_METHOD_DISABLE_COMMAND_TYPE); /* name of the signal */ + + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCM, ">>>> vc disable command type : Fail to make message "); + return VC_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc disable command type : pid(%d) type(%d)", pid, cmd_type); + } + + dbus_message_append_args(msg, + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &cmd_type, + DBUS_TYPE_INVALID); + + DBusMessage* result_msg; + int result = VC_ERROR_OPERATION_FAILED; + + result_msg = dbus_connection_send_with_reply_and_block(g_m_conn_sender, msg, g_m_waiting_time, &err); + dbus_message_unref(msg); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); + dbus_error_free(&err); + } + + if (NULL != result_msg) { + dbus_message_get_args(result_msg, &err, + DBUS_TYPE_INT32, &result, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCM, "<<<< Get arguments error (%s)", err.message); + dbus_error_free(&err); + result = VC_ERROR_OPERATION_FAILED; + } + dbus_message_unref(result_msg); + + if (0 == result) { + SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc disable command type : result = %d", result); + } else { + SLOG(LOG_ERROR, TAG_VCM, "<<<< vc disable command type : result = %d", result); + } + } else { + SLOG(LOG_DEBUG, TAG_VCM, "<<<< Result Message is NULL"); + vc_mgr_dbus_reconnect(); + result = VC_ERROR_TIMED_OUT; + } + + return result; +} + static DBusMessage* __get_message(int pid, const char* method, int type) { char service_name[64]; diff --git a/client/vc_mgr_dbus.h b/client/vc_mgr_dbus.h index c12baa6..267aa05 100644 --- a/client/vc_mgr_dbus.h +++ b/client/vc_mgr_dbus.h @@ -64,6 +64,9 @@ int vc_mgr_dbus_send_result(int pid, int cmd_type, int result_id); int vc_mgr_dbus_send_result_selection(int pid); +int vc_mgr_dbus_request_enable_command_type(int pid, int cmd_type); + +int vc_mgr_dbus_request_disable_command_type(int pid, int cmd_type); #ifdef __cplusplus } diff --git a/common/vc_defs.h b/common/vc_defs.h index 095ba66..f647506 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -127,6 +127,8 @@ extern "C" { #define VC_MANAGER_METHOD_SET_CLIENT_INFO "vc_manager_method_set_client_info" #define VC_MANAGER_METHOD_SET_PRIVATE_DATA "vc_manager_method_set_private_data" #define VC_MANAGER_METHOD_GET_PRIVATE_DATA "vc_manager_method_get_private_data" +#define VC_MANAGER_METHOD_ENABLE_COMMAND_TYPE "vc_manager_method_enable_command_type" +#define VC_MANAGER_METHOD_DISABLE_COMMAND_TYPE "vc_manager_method_disable_command_type" #define VC_MANAGER_METHOD_START "vc_manager_method_request_start" #define VC_MANAGER_METHOD_STOP "vc_manager_method_request_stop" @@ -149,6 +151,7 @@ extern "C" { #define VCC_MANAGER_METHOD_SET_FOREGROUND "vcd_manager_method_set_foreground" + /****************************************************************************************** * Definitions for configuration *******************************************************************************************/ diff --git a/include/voice_control_manager.h b/include/voice_control_manager.h index 32f4cd7..9d738dc 100644 --- a/include/voice_control_manager.h +++ b/include/voice_control_manager.h @@ -982,6 +982,31 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d */ int vc_mgr_unset_dialog_request_cb(); +/** +* @brief Enable command type as candidate command. +* +* @return 0 on success, otherwise a negative error value +* @retval #VC_ERROR_NONE Successful +* @retval #VC_ERROR_INVALID_STATE Invalid state +* +* @pre The state should be #VC_STATE_READY. +* +* @see vc_mgr_disable_command_type() +*/ +int vc_mgr_enable_command_type(int cmd_type); + +/** +* @brief Disable command type as candidate command. +* +* @return 0 on success, otherwise a negative error value +* @retval #VC_ERROR_NONE Successful +* @retval #VC_ERROR_INVALID_STATE Invalid state +* +* @pre The state should be #VC_STATE_READY. +* +* @see vc_mgr_enable_command_type() +*/ +int vc_mgr_disable_command_type(int cmd_type); #ifdef __cplusplus } diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 5e0253d..562b77a 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -319,7 +319,7 @@ int vcd_client_command_collect_command() __vcd_client_release_commands(); /* Check exclusive system command */ - if (true == g_manager.exclusive_cmd_option) { + if (true == g_manager.exclusive_cmd_option && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_EXCLUSIVE)) { SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Exclusive option of manager is ON"); GSList* ex_sys_cmd_list = NULL; @@ -339,7 +339,7 @@ int vcd_client_command_collect_command() /* 3. Set system command */ GSList* sys_cmd_list = NULL; - if (true == g_manager.manager_cmd) { + if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_SYSTEM)) { ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_SYSTEM, &sys_cmd_list); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the system command list"); @@ -351,7 +351,7 @@ int vcd_client_command_collect_command() } GSList* sys_back_cmd_list = NULL; - if (true == g_manager.manager_cmd) { + if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_SYSTEM_BACKGROUND)) { ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_SYSTEM_BACKGROUND, &sys_back_cmd_list); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the system command list"); @@ -372,7 +372,7 @@ int vcd_client_command_collect_command() /* 4-1. Set widget command */ widget_info_s* widget_info = NULL; widget_info = __widget_get_element(fg_pid); - if (NULL != widget_info) { + if (NULL != widget_info && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) { if (true == widget_info->widget_cmd) { ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_WIDGET, &widget_cmd_list); if (0 != ret) { @@ -386,16 +386,18 @@ int vcd_client_command_collect_command() } /* 4-2. Set foreground command of foreground app */ - ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_FOREGROUND, &fg_cmd_list); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the fg command list"); - } else { - g_cur_cmd_list.foreground_cmds = fg_cmd_list; + if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_FOREGROUND)) { + ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_FOREGROUND, &fg_cmd_list); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the fg command list"); + } else { + g_cur_cmd_list.foreground_cmds = fg_cmd_list; + } } } else { SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] No foreground app"); } - if (true == g_manager.manager_cmd) { + if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_FOREGROUND)) { /* 4-3. Set foreground command by manager */ ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_FOREGROUND, &fg_cmd_list); if (0 != ret) { @@ -407,12 +409,14 @@ int vcd_client_command_collect_command() /* 5. Set background commands */ GSList* bg_cmd_list = NULL; - ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_BACKGROUND, &bg_cmd_list); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the bg command list"); - } else { - /* Add item to global command list */ - g_cur_cmd_list.background_cmds = bg_cmd_list; + if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_BACKGROUND)) { + ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_BACKGROUND, &bg_cmd_list); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the bg command list"); + } else { + /* Add item to global command list */ + g_cur_cmd_list.background_cmds = bg_cmd_list; + } } return 0; } diff --git a/server/vcd_config.c b/server/vcd_config.c index 7c46573..287ba23 100644 --- a/server/vcd_config.c +++ b/server/vcd_config.c @@ -28,6 +28,16 @@ static vcd_state_e g_state; static int g_foreground_pid; +#define COMMAND_TYPE_MAX 7 +static int g_enabled_command_type[COMMAND_TYPE_MAX] = { + 0, /* NONE */ + 1, /* FOREGROUND */ + 1, /* BACKGROUND */ + 1, /* WIDGET */ + 1, /* SYSTEM */ + 1, /* SYSTEM_BACKGROUND */ + 1 /* EXCLUSIVE */ +}; void __vcd_config_lang_changed_cb(const char* before_lang, const char* current_lang) { @@ -128,3 +138,35 @@ int vcd_config_set_foreground(int pid, bool value) } return 0; } + +int vcd_config_enable_command_type(int cmd_type) +{ + if (cmd_type <= 0 || cmd_type >= COMMAND_TYPE_MAX) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid command type"); + return -1; + } + + g_enabled_command_type[cmd_type] = 1; + return 0; +} + +int vcd_config_disable_command_type(int cmd_type) +{ + if (cmd_type <= 0 || cmd_type >= COMMAND_TYPE_MAX) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid command type"); + return -1; + } + + g_enabled_command_type[cmd_type] = 0; + return 0; +} + +int vcd_config_get_command_type_enabled(int cmd_type) +{ + if (cmd_type <= 0 || cmd_type >= COMMAND_TYPE_MAX) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid command type"); + return 0; + } + + return g_enabled_command_type[cmd_type]; +} diff --git a/server/vcd_config.h b/server/vcd_config.h index 2cf332f..047d6d6 100644 --- a/server/vcd_config.h +++ b/server/vcd_config.h @@ -43,6 +43,11 @@ int vcd_config_get_foreground(int* pid); int vcd_config_set_foreground(int pid, bool value); +int vcd_config_enable_command_type(int cmd_type); + +int vcd_config_disable_command_type(int cmd_type); + +int vcd_config_get_command_type_enabled(int cmd_type); #ifdef __cplusplus } diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 7d0f348..586e65b 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -839,6 +839,12 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_DO_ACTION)) vcd_dbus_server_mgr_do_action(g_conn_listener, msg); + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_ENABLE_COMMAND_TYPE)) + vcd_dbus_server_mgr_enable_command_type(g_conn_listener, msg); + + else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_DISABLE_COMMAND_TYPE)) + vcd_dbus_server_mgr_disable_command_type(g_conn_listener, msg); + /* client event */ else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_INITIALIZE)) vcd_dbus_server_initialize(g_conn_listener, msg); diff --git a/server/vcd_dbus_server.c b/server/vcd_dbus_server.c index 4a19a0b..169e3f4 100644 --- a/server/vcd_dbus_server.c +++ b/server/vcd_dbus_server.c @@ -742,6 +742,114 @@ int vcd_dbus_server_mgr_do_action(DBusConnection* conn, DBusMessage* msg) return 0; } +int vcd_dbus_server_mgr_enable_command_type(DBusConnection* conn, DBusMessage* msg) +{ + DBusError err; + dbus_error_init(&err); + + int pid = 0; + int cmd_type = 0; + + int ret = VCD_ERROR_OPERATION_FAILED; + + SLOG(LOG_DEBUG, TAG_VCD, ">>>>> VCD Manager enable command type"); + + dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &cmd_type, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr enable command type : get arguments error (%s)", err.message); + dbus_error_free(&err); + ret = VCD_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr enable command type : pid(%d), cmd_type(%d)", pid, cmd_type); + ret = vcd_server_mgr_enable_command_type(pid, cmd_type); + } + + DBusMessage* reply; + reply = dbus_message_new_method_return(msg); + + if (NULL != reply) { + dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); + + if (0 == ret) { + SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + } + + if (!dbus_connection_send(conn, reply, NULL)) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); + } + + dbus_connection_flush(conn); + dbus_message_unref(reply); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); + } + + SLOG(LOG_DEBUG, TAG_VCD, "<<<<<"); + SLOG(LOG_DEBUG, TAG_VCD, " "); + + return 0; +} + +int vcd_dbus_server_mgr_disable_command_type(DBusConnection* conn, DBusMessage* msg) +{ + DBusError err; + dbus_error_init(&err); + + int pid = 0; + int cmd_type = 0; + + int ret = VCD_ERROR_OPERATION_FAILED; + + SLOG(LOG_DEBUG, TAG_VCD, ">>>>> VCD Manager disable command type"); + + dbus_message_get_args(msg, &err, + DBUS_TYPE_INT32, &pid, + DBUS_TYPE_INT32, &cmd_type, + DBUS_TYPE_INVALID); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr disable command type : get arguments error (%s)", err.message); + dbus_error_free(&err); + ret = VCD_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr disable command type : pid(%d), cmd_type(%d)", pid, cmd_type); + ret = vcd_server_mgr_disable_command_type(pid, cmd_type); + } + + DBusMessage* reply; + reply = dbus_message_new_method_return(msg); + + if (NULL != reply) { + dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); + + if (0 == ret) { + SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + } + + if (!dbus_connection_send(conn, reply, NULL)) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); + } + + dbus_connection_flush(conn); + dbus_message_unref(reply); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); + } + + SLOG(LOG_DEBUG, TAG_VCD, "<<<<<"); + SLOG(LOG_DEBUG, TAG_VCD, " "); + + return 0; +} + int vcd_dbus_server_mgr_start(DBusConnection* conn, DBusMessage* msg) { DBusError err; diff --git a/server/vcd_dbus_server.h b/server/vcd_dbus_server.h index 4a7fc7b..626d415 100644 --- a/server/vcd_dbus_server.h +++ b/server/vcd_dbus_server.h @@ -63,6 +63,10 @@ int vcd_dbus_server_mgr_cancel(DBusConnection* conn, DBusMessage* msg); int vcd_dbus_server_mgr_result_selection(DBusConnection* conn, DBusMessage* msg); +int vcd_dbus_server_mgr_enable_command_type(DBusConnection* conn, DBusMessage* msg); + +int vcd_dbus_server_mgr_disable_command_type(DBusConnection* conn, DBusMessage* msg); + /* * Dbus Server functions for client */ diff --git a/server/vcd_server.c b/server/vcd_server.c index a452b68..07f9fbe 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1535,11 +1535,13 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive if (false == exclusive_cmd) { /* Notify show tooltip */ - int pid = vcd_client_widget_get_foreground_pid(); - if (-1 != pid) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip show and widget command"); - ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); - return 0; + if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) { + int pid = vcd_client_widget_get_foreground_pid(); + if (-1 != pid) { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip show and widget command"); + ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); + return 0; + } } } else { vcd_client_manager_set_exclusive(exclusive_cmd); @@ -1627,10 +1629,12 @@ int vcd_server_mgr_cancel() } if (false == vcd_client_manager_get_exclusive()) { - int pid = vcd_client_widget_get_foreground_pid(); - if (-1 != pid) { - SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip hide"); - ecore_timer_add(0, __vcd_request_show_tooltip, (void*)false); + if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) { + int pid = vcd_client_widget_get_foreground_pid(); + if (-1 != pid) { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip hide"); + ecore_timer_add(0, __vcd_request_show_tooltip, (void*)false); + } } } else { vcd_client_manager_set_exclusive(false); @@ -1758,6 +1762,58 @@ int vcd_server_mgr_do_action(int pid, int type, const char* action) return ret; } +int vcd_server_mgr_enable_command_type(int pid, int cmd_type) +{ + int ret = -1; + + /* check if pid is valid */ + if (false == vcd_client_manager_is_valid(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] The manager pid(%d) is NOT valid", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + vcd_state_e state = vcd_config_get_service_state(); + if (VCD_STATE_READY != state) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready"); + return VCD_ERROR_INVALID_STATE; + } + + ret = vcd_config_enable_command_type(cmd_type); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to enable command type"); + } else { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Enable command type(%d)", cmd_type); + } + + return ret; +} + +int vcd_server_mgr_disable_command_type(int pid, int cmd_type) +{ + int ret = -1; + + /* check if pid is valid */ + if (false == vcd_client_manager_is_valid(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] The manager pid(%d) is NOT valid", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + vcd_state_e state = vcd_config_get_service_state(); + if (VCD_STATE_READY != state) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready"); + return VCD_ERROR_INVALID_STATE; + } + + ret = vcd_config_disable_command_type(cmd_type); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to disable command type"); + } else { + SLOG(LOG_DEBUG, TAG_VCD, "[Server] Disable command type(%d)", cmd_type); + } + + return ret; +} + /* * VC Server Functions for Client */ diff --git a/server/vcd_server.h b/server/vcd_server.h index c8b0284..b97589d 100644 --- a/server/vcd_server.h +++ b/server/vcd_server.h @@ -74,6 +74,10 @@ int vcd_server_mgr_get_private_data(int pid, const char* key, char** data); int vcd_server_mgr_do_action(int pid, int type, const char* action); +int vcd_server_mgr_enable_command_type(int pid, int cmd_type); + +int vcd_server_mgr_disable_command_type(int pid, int cmd_type); + /* * For client */ -- 2.7.4 From 30747512b113e3f9b5788779d517ed9cb74646c0 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Mon, 26 Dec 2016 13:51:43 +0900 Subject: [PATCH 10/16] Enhancement for widget client internal multi handle Change-Id: I5aaf4cee1d8a4d2cd48bbe8a9966a6c965cba620 Signed-off-by: Kwangyoun Kim (cherry picked from commit d99e9cfd7db9ccc0dcef3e0232999d4fa7786192) --- client/vc_widget.c | 676 ++++++++++++++++++++++++----------------- client/vc_widget_client.c | 158 +++++----- client/vc_widget_client.h | 53 ++++ include/voice_control_widget.h | 57 ++-- server/vcd_dbus.c | 2 +- server/vcd_server.c | 4 +- 6 files changed, 563 insertions(+), 387 deletions(-) diff --git a/client/vc_widget.c b/client/vc_widget.c index 6212288..3989c99 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -31,15 +31,10 @@ #define VC_WIDGET_CONFIG_HANDLE 200000 -static Ecore_Timer* g_w_connect_timer = NULL; - static Ecore_Event_Handler* g_focus_in_handler = NULL; static Ecore_Event_Handler* g_focus_out_handler = NULL; static Ecore_Timer* g_w_start_timer = NULL; -static Ecore_Timer* g_w_tooltip_timer = NULL; - -static vc_h g_vc_w = NULL; static int g_daemon_pid = 0; @@ -88,28 +83,41 @@ static void __vc_widget_lang_changed_cb(const char* before_lang, const char* cur vc_current_language_changed_cb callback; void* lang_user_data; - vc_widget_client_get_current_lang_changed_cb(g_vc_w, &callback, &lang_user_data); - if (NULL != callback) { - vc_widget_client_use_callback(g_vc_w); - callback(before_lang, current_lang, lang_user_data); - vc_widget_client_not_use_callback(g_vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "Language changed callback is called"); - } else { - SLOG(LOG_WARN, TAG_VCW, "[WARNING] Language changed callback is null"); - } + GSList* client_list = vc_widget_client_get_client_list(); + vc_widget_s *widget_data = NULL; + vc_h vc_w = NULL; + + int count = g_slist_length(client_list); + int i; + for (i = 0; i < count; i++) { + widget_data = g_slist_nth_data(client_list, i); + if (NULL != widget_data) { + vc_w = widget_data->vc; + + vc_widget_client_get_current_lang_changed_cb(vc_w, &callback, &lang_user_data); + + if (NULL != callback) { + vc_widget_client_use_callback(vc_w); + callback(before_lang, current_lang, lang_user_data); + vc_widget_client_not_use_callback(vc_w); + SLOG(LOG_DEBUG, TAG_VCW, "Language changed callback is called"); + } else { + SLOG(LOG_WARN, TAG_VCW, "[WARNING] Language changed callback is null"); + } + } + } return; } -int vc_widget_initialize() +int vc_widget_initialize(vc_h* vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Initialize"); - /* check handle */ - if (true == vc_widget_client_is_valid(g_vc_w)) { - SLOG(LOG_ERROR, TAG_VCW, "[WARNING] Already initialized"); - return VC_ERROR_NONE; + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; } if (0 == vc_widget_client_get_count()) { @@ -117,41 +125,41 @@ int vc_widget_initialize() SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to open connection"); return VC_ERROR_OPERATION_FAILED; } - } else { - SLOG(LOG_WARN, TAG_VCW, "[WARN] Already initialized"); - return VC_ERROR_NONE; } - if (0 != vc_widget_client_create(&g_vc_w)) { + if (0 != vc_widget_client_create(vc_w)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to create client!!!!!"); return VC_ERROR_OUT_OF_MEMORY; } - int ret = vc_config_mgr_initialize(g_vc_w->handle + VC_WIDGET_CONFIG_HANDLE); + /* TODO - each handle? */ + int ret = vc_config_mgr_initialize((*vc_w)->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to init config manager : %s", __vc_widget_get_error_code(__vc_widget_convert_config_error_code(ret))); - vc_widget_client_destroy(g_vc_w); + vc_widget_client_destroy((*vc_w)); return __vc_widget_convert_config_error_code(ret); } - ret = vc_config_mgr_set_lang_cb(g_vc_w->handle + VC_WIDGET_CONFIG_HANDLE, __vc_widget_lang_changed_cb); + ret = vc_config_mgr_set_lang_cb((*vc_w)->handle, __vc_widget_lang_changed_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set config changed : %d", ret); - vc_config_mgr_finalize(g_vc_w->handle + VC_WIDGET_CONFIG_HANDLE); - vc_widget_client_destroy(g_vc_w); + vc_config_mgr_finalize((*vc_w)->handle); + vc_widget_client_destroy((*vc_w)); return __vc_widget_convert_config_error_code(ret); } - ret = vc_db_initialize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to initialize DB : %d", ret); - vc_config_mgr_finalize(g_vc_w->handle + VC_WIDGET_CONFIG_HANDLE); - vc_widget_client_destroy(g_vc_w); - return ret; + if (1 == vc_widget_client_get_count()) { + ret = vc_db_initialize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to initialize DB : %d", ret); + vc_config_mgr_finalize((*vc_w)->handle); + vc_widget_client_destroy((*vc_w)); + return ret; + } } - SLOG(LOG_DEBUG, TAG_VCW, "[Success] pid(%d)", g_vc_w->handle); + SLOG(LOG_DEBUG, TAG_VCW, "[Success] uid(%d)", (*vc_w)->handle); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -159,9 +167,9 @@ int vc_widget_initialize() return VC_ERROR_NONE; } -static void __vc_widget_internal_unprepare() +static void __vc_widget_internal_unprepare(vc_h vc_w) { - int ret = vc_widget_dbus_request_finalize(g_vc_w->handle); + int ret = vc_widget_dbus_request_finalize(getpid()); if (0 != ret) { SLOG(LOG_WARN, TAG_VCW, "[ERROR] Fail to request finalize : %s", __vc_widget_get_error_code(ret)); } @@ -182,11 +190,11 @@ static void __vc_widget_internal_unprepare() return; } -int vc_widget_deinitialize() +int vc_widget_deinitialize(vc_h vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Deinitialize"); - if (false == vc_widget_client_is_valid(g_vc_w)) { + if (false == vc_widget_client_is_valid(vc_w)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] NOT initialized"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -194,26 +202,29 @@ int vc_widget_deinitialize() } vc_state_e state; - vc_widget_client_get_state(g_vc_w, &state); + vc_widget_client_get_state(vc_w, &state); + vc_widget_s* widget = widget_get(vc_w); /* check state */ switch (state) { case VC_STATE_READY: - __vc_widget_internal_unprepare(); + if (1 == vc_widget_client_get_count()) { + __vc_widget_internal_unprepare(vc_w); + } /* no break. need to next step*/ case VC_STATE_INITIALIZED: - if (NULL != g_w_connect_timer) { + if (NULL != widget->conn_timer) { SLOG(LOG_DEBUG, TAG_VCW, "Connect Timer is deleted"); - ecore_timer_del(g_w_connect_timer); - g_w_connect_timer = NULL; + ecore_timer_del(widget->conn_timer); + widget->conn_timer = NULL; } - vc_config_mgr_unset_lang_cb(g_vc_w->handle + VC_WIDGET_CONFIG_HANDLE); - vc_config_mgr_finalize(g_vc_w->handle + VC_WIDGET_CONFIG_HANDLE); + vc_config_mgr_unset_lang_cb(vc_w->handle); + vc_config_mgr_finalize(vc_w->handle); /* Free resources */ - vc_widget_client_destroy(g_vc_w); - g_vc_w = NULL; + vc_widget_client_destroy(vc_w); + vc_w = NULL; break; case VC_STATE_NONE: break; @@ -221,13 +232,15 @@ int vc_widget_deinitialize() SLOG(LOG_DEBUG, TAG_VCW, "Success: destroy"); - int ret = vc_db_finalize(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to finalize DB, ret(%d)", ret); - } + if (0 == vc_widget_client_get_count()) { + int ret = vc_db_finalize(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to finalize DB, ret(%d)", ret); + } - if (0 != vc_widget_dbus_close_connection()) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to close connection"); + if (0 != vc_widget_dbus_close_connection()) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to close connection"); + } } SLOG(LOG_DEBUG, TAG_VCW, "====="); @@ -265,6 +278,8 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) static Eina_Bool __vc_widget_connect_daemon(void *data) { + vc_h vc_w = (vc_h)data; + /* Send hello */ if (0 != vc_widget_dbus_request_hello()) { return EINA_TRUE; @@ -272,38 +287,43 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Connect daemon"); - g_w_connect_timer = NULL; + vc_widget_s* widget = widget_get(vc_w); + widget->conn_timer = NULL; /* request initialization */ int ret = -1; int service_state = 0; - ret = vc_widget_dbus_request_initialize(g_vc_w->handle, &service_state, &g_daemon_pid); + ret = vc_widget_dbus_request_initialize(getpid(), &service_state, &g_daemon_pid); if (VC_ERROR_ENGINE_NOT_FOUND == ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to initialize : %s", __vc_widget_get_error_code(ret)); - vc_widget_client_set_error(g_vc_w, VC_ERROR_ENGINE_NOT_FOUND); - ecore_timer_add(0, __vc_widget_notify_error, g_vc_w); + vc_widget_client_set_error(vc_w, VC_ERROR_ENGINE_NOT_FOUND); + ecore_timer_add(0, __vc_widget_notify_error, vc_w); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); return EINA_FALSE; + } else if (VC_ERROR_INVALID_PARAMETER == ret) { + SLOG(LOG_WARN, TAG_VCW, "[WARNING] Invalid Parameter"); } else if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to initialize : %s", __vc_widget_get_error_code(ret)); - vc_widget_client_set_error(g_vc_w, VC_ERROR_TIMED_OUT); - ecore_timer_add(0, __vc_widget_notify_error, g_vc_w); + vc_widget_client_set_error(vc_w, VC_ERROR_TIMED_OUT); + ecore_timer_add(0, __vc_widget_notify_error, vc_w); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); return EINA_FALSE; } - vc_widget_client_set_service_state(g_vc_w, (vc_service_state_e)service_state); + vc_widget_client_set_service_state(vc_w, (vc_service_state_e)service_state); - g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); - g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + if (NULL == g_focus_in_handler) + g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + if (NULL == g_focus_out_handler) + g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); char appid[255] = {'\0',}; aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); @@ -317,8 +337,8 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) } } - vc_widget_client_set_state(g_vc_w, VC_STATE_READY); - ecore_timer_add(0, __vc_widget_notify_state_changed, g_vc_w); + vc_widget_client_set_state(vc_w, VC_STATE_READY); + ecore_timer_add(0, __vc_widget_notify_state_changed, vc_w); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -326,12 +346,12 @@ static Eina_Bool __vc_widget_connect_daemon(void *data) return EINA_FALSE; } -int vc_widget_prepare() +int vc_widget_prepare(vc_h vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Prepare"); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -346,7 +366,8 @@ int vc_widget_prepare() return VC_ERROR_INVALID_STATE; } - g_w_connect_timer = ecore_timer_add(0, __vc_widget_connect_daemon, NULL); + vc_widget_s* widget = widget_get(vc_w); + widget->conn_timer = ecore_timer_add(0, __vc_widget_connect_daemon, (void*)vc_w); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -354,12 +375,12 @@ int vc_widget_prepare() return VC_ERROR_NONE; } -int vc_widget_unprepare() +int vc_widget_unprepare(vc_h vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Unprepare"); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -374,10 +395,10 @@ int vc_widget_unprepare() return VC_ERROR_INVALID_STATE; } - __vc_widget_internal_unprepare(); + __vc_widget_internal_unprepare(vc_w); - vc_widget_client_set_state(g_vc_w, VC_STATE_INITIALIZED); - ecore_timer_add(0, __vc_widget_notify_state_changed, g_vc_w); + vc_widget_client_set_state(vc_w, VC_STATE_INITIALIZED); + ecore_timer_add(0, __vc_widget_notify_state_changed, vc_w); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -385,12 +406,12 @@ int vc_widget_unprepare() return VC_ERROR_NONE; } -int vc_widget_enable_asr_result(bool enable) +int vc_widget_enable_asr_result(vc_h vc_w, bool enable) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Enable asr result"); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -409,7 +430,7 @@ int vc_widget_enable_asr_result(bool enable) int ret = -1; do { - ret = vc_widget_dbus_request_enable_asr_result(g_vc_w->handle, enable); + ret = vc_widget_dbus_request_enable_asr_result(getpid(), enable); if (0 != ret) { if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to enable asr result : %s", __vc_widget_get_error_code(ret)); @@ -426,13 +447,15 @@ int vc_widget_enable_asr_result(bool enable) } } while (0 != ret); + vc_widget_client_set_asr_result_enabled(vc_w, enable); + SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); return ret; } -int vc_widget_foreach_supported_languages(vc_supported_language_cb callback, void* user_data) +int vc_widget_foreach_supported_languages(vc_h vc_w, vc_supported_language_cb callback, void* user_data) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Foreach Supported Language"); @@ -444,7 +467,7 @@ int vc_widget_foreach_supported_languages(vc_supported_language_cb callback, voi } vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -464,7 +487,7 @@ int vc_widget_foreach_supported_languages(vc_supported_language_cb callback, voi return VC_ERROR_NONE; } -int vc_widget_get_current_language(char** language) +int vc_widget_get_current_language(vc_h vc_w, char** language) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Get Current Language"); @@ -476,7 +499,7 @@ int vc_widget_get_current_language(char** language) } vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -496,7 +519,7 @@ int vc_widget_get_current_language(char** language) return ret; } -int vc_widget_get_state(vc_state_e* state) +int vc_widget_get_state(vc_h vc_w, vc_state_e* state) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Get State"); @@ -506,7 +529,7 @@ int vc_widget_get_state(vc_state_e* state) } vc_state_e temp; - if (0 != vc_widget_client_get_state(g_vc_w, &temp)) { + if (0 != vc_widget_client_get_state(vc_w, &temp)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -528,7 +551,7 @@ int vc_widget_get_state(vc_state_e* state) return VC_ERROR_NONE; } -int vc_widget_get_service_state(vc_service_state_e* state) +int vc_widget_get_service_state(vc_h vc_w, vc_service_state_e* state) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Get Service State"); @@ -538,7 +561,7 @@ int vc_widget_get_service_state(vc_service_state_e* state) } vc_state_e temp; - if (0 != vc_widget_client_get_state(g_vc_w, &temp)) { + if (0 != vc_widget_client_get_state(vc_w, &temp)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -554,7 +577,7 @@ int vc_widget_get_service_state(vc_service_state_e* state) /* get service state */ vc_service_state_e service_state; - if (0 != vc_widget_client_get_service_state(g_vc_w, &service_state)) { + if (0 != vc_widget_client_get_service_state(vc_w, &service_state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get service state"); return VC_ERROR_OPERATION_FAILED; } @@ -575,12 +598,12 @@ int vc_widget_get_service_state(vc_service_state_e* state) return VC_ERROR_NONE; } -int vc_widget_set_foreground(bool value) +int vc_widget_set_foreground(vc_h vc_w, bool value) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Set foreground state"); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not valid"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -608,12 +631,12 @@ int vc_widget_set_foreground(bool value) return VC_ERROR_NONE; } -int vc_widget_is_format_supported(vc_cmd_format_e format, bool* support) +int vc_widget_is_format_supported(vc_h vc_w, vc_cmd_format_e format, bool* support) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Is command type supported"); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not valid"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -712,7 +735,7 @@ int vc_widget_start(bool stop_by_silence, vc_cmd_group_h vc_group) } else { int count = 0; do { - ret = vc_widget_dbus_request_start(g_vc_w->handle, stop_by_silence); + ret = vc_widget_dbus_request_start(getpid(), stop_by_silence); if (0 != ret) { if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request start : %s", __vc_widget_get_error_code(ret)); @@ -798,7 +821,7 @@ int vc_widget_stop() int count = 0; do { - ret = vc_widget_dbus_request_stop(g_vc_w->handle); + ret = vc_widget_dbus_request_stop(getpid()); if (0 != ret) { if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request stop : %s", __vc_widget_get_error_code(ret)); @@ -819,12 +842,12 @@ int vc_widget_stop() } #endif -int vc_widget_cancel() +int vc_widget_cancel(vc_h vc_w) { SLOG(LOG_DEBUG, TAG_VCW, "===== [Widget] Cancel Recognition"); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); SLOG(LOG_DEBUG, TAG_VCW, "====="); SLOG(LOG_DEBUG, TAG_VCW, " "); @@ -841,7 +864,7 @@ int vc_widget_cancel() /* Check service state */ vc_service_state_e service_state = -1; - vc_widget_client_get_service_state(g_vc_w, &service_state); + vc_widget_client_get_service_state(vc_w, &service_state); if (service_state != VC_SERVICE_STATE_RECORDING && service_state != VC_SERVICE_STATE_PROCESSING) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: service state is not 'RECORDING' or 'PROCESSING'"); SLOG(LOG_DEBUG, TAG_VCW, "====="); @@ -853,7 +876,7 @@ int vc_widget_cancel() int ret = -1; do { - ret = vc_widget_dbus_request_cancel(g_vc_w->handle); + ret = vc_widget_dbus_request_cancel(getpid()); if (0 != ret) { if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request cancel : %s", __vc_widget_get_error_code(ret)); @@ -877,17 +900,18 @@ int vc_widget_cancel() static Eina_Bool __vc_widget_notify_error(void *data) { + vc_h vc_w = (vc_h)data; vc_error_cb callback = NULL; void* user_data; int reason; - vc_widget_client_get_error_cb(g_vc_w, &callback, &user_data); - vc_widget_client_get_error(g_vc_w, &reason); + vc_widget_client_get_error_cb(vc_w, &callback, &user_data); + vc_widget_client_get_error(vc_w, &reason); if (NULL != callback) { - vc_widget_client_use_callback(g_vc_w); + vc_widget_client_use_callback(vc_w); callback(reason, user_data); - vc_widget_client_not_use_callback(g_vc_w); + vc_widget_client_not_use_callback(vc_w); SLOG(LOG_DEBUG, TAG_VCW, "[Error] callback is called"); } else { SLOG(LOG_WARN, TAG_VCW, "[WARNING] Error callback is null"); @@ -899,32 +923,47 @@ static Eina_Bool __vc_widget_notify_error(void *data) int __vc_widget_cb_error(int reason, int daemon_pid, char* msg) { vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { - SLOG(LOG_ERROR, TAG_VCW, "[WARNING] Invalid client"); - return -1; - } - /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCW, "[WARNING] not connected client yet"); - return -1; - } + GSList* client_list = vc_widget_client_get_client_list(); - if (VC_ERROR_SERVICE_RESET == reason) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] VC daemon reset"); + vc_widget_s *data = NULL; + vc_h vc_w = NULL; - vc_widget_client_set_state(g_vc_w, VC_STATE_INITIALIZED); - __vc_widget_notify_state_changed(g_vc_w); + int count = g_slist_length(client_list); + int i; + for (i = 0; i < count; i++) { + data = g_slist_nth_data(client_list, i); + if (NULL != data) { + vc_w = data->vc; - if (0 != vc_widget_prepare()) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to prepare"); - } - } + if (0 != vc_widget_client_get_state(vc_w, &state)) { + SLOG(LOG_ERROR, TAG_VCW, "[WARNING] Invalid client"); + return -1; + } - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Error reason(%d), msg(%s)", reason, msg); + /* check state */ + if (state != VC_STATE_READY) { + SLOG(LOG_ERROR, TAG_VCW, "[WARNING] not connected client yet"); + return -1; + } - vc_widget_client_set_error(g_vc_w, reason); - ecore_timer_add(0, __vc_widget_notify_error, g_vc_w); + if (VC_ERROR_SERVICE_RESET == reason) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] VC daemon reset"); + + vc_widget_client_set_state(vc_w, VC_STATE_INITIALIZED); + __vc_widget_notify_state_changed(vc_w); + + if (0 != vc_widget_prepare(vc_w)) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to prepare"); + } + } + + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Error reason(%d), msg(%s)", reason, msg); + + vc_widget_client_set_error(vc_w, reason); + ecore_timer_add(0, __vc_widget_notify_error, vc_w); + } + } return 0; } @@ -936,51 +975,60 @@ static Eina_Bool __vc_widget_start_recording(void *data) g_w_start_timer = NULL; } + int ret; + ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_WIDGET); + if (0 != ret) + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_WIDGET, ret); + vc_widget_send_current_command_list_cb send_command_list_cb = NULL; void* send_command_user_data = NULL; vc_cmd_list_h vc_cmd_list = NULL; - int ret = vc_widget_client_get_send_command_list_cb(g_vc_w, &send_command_list_cb, &send_command_user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCW, "[WARNING] Invalid client"); - return -1; - } - - if (NULL != send_command_list_cb) { - vc_widget_client_use_callback(g_vc_w); - send_command_list_cb(&vc_cmd_list, send_command_user_data); - vc_widget_client_not_use_callback(g_vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "client result callback called"); - - } else { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] User show tooltip callback is NULL"); - } + GSList* client_list = vc_widget_client_get_client_list(); + vc_widget_s *widget_data = NULL; + vc_h vc_w = NULL; bool widget_command = false; - if (NULL != vc_cmd_list) { - vc_cmd_list_s* list = NULL; - list = (vc_cmd_list_s*)vc_cmd_list; - - ret = vc_cmd_parser_delete_file(getpid(), VC_COMMAND_TYPE_WIDGET); - if (0 != ret) - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_WIDGET, ret); - - ret = vc_cmd_parser_save_file(getpid(), VC_COMMAND_TYPE_WIDGET, list->list, NULL); - if (0 == ret) { - /* widget command is valid */ - widget_command = true; - SLOG(LOG_DEBUG, TAG_VCW, "Widget command is valid"); - } else { - ret = VC_ERROR_OPERATION_FAILED; - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to save command group : %s", __vc_widget_get_error_code(ret)); + int count = g_slist_length(client_list); + int i; + for (i = 0; i < count; i++) { + widget_data = g_slist_nth_data(client_list, i); + if (NULL != widget_data) { + vc_w = widget_data->vc; + + vc_widget_client_get_send_command_list_cb(vc_w, &send_command_list_cb, &send_command_user_data); + + if (NULL != send_command_list_cb) { + vc_widget_client_use_callback(vc_w); + send_command_list_cb(&vc_cmd_list, send_command_user_data); + vc_widget_client_not_use_callback(vc_w); + SLOG(LOG_DEBUG, TAG_VCW, "client command list callback called"); + if (NULL != vc_cmd_list) { + vc_cmd_list_s* list = NULL; + list = (vc_cmd_list_s*)vc_cmd_list; + ret = vc_cmd_parser_save_file(getpid(), VC_COMMAND_TYPE_WIDGET, list->list, NULL); + if (0 == ret) { + /* widget command is valid */ + widget_command = true; + SLOG(LOG_DEBUG, TAG_VCW, "Widget command is valid"); + } else { + ret = VC_ERROR_OPERATION_FAILED; + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to save command group : %s", __vc_widget_get_error_code(ret)); + } + } + } else { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] User show tooltip callback is NULL"); + } } } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] command list (%d)", g_slist_length(((vc_cmd_list_s*)vc_cmd_list)->list)); + ret = -1; - int count = 0; + count = 0; while (0 != ret) { - ret = vc_widget_dbus_request_start_recording(g_vc_w->handle, widget_command); + ret = vc_widget_dbus_request_start_recording(getpid(), widget_command); if (0 != ret) { if (VC_ERROR_TIMED_OUT != ret) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request start recording to daemon : %s", __vc_widget_get_error_code(ret)); @@ -1002,25 +1050,36 @@ static Eina_Bool __vc_widget_start_recording(void *data) static Eina_Bool __vc_widget_notify_tooltip(void *data) { - if (NULL != g_w_tooltip_timer) { - ecore_timer_del(g_w_tooltip_timer); - g_w_tooltip_timer = NULL; - } + bool show = (bool)data; vc_widget_show_tooltip_cb callback; void* user_data; - bool show; - vc_widget_client_get_show_tooltip_cb(g_vc_w, &callback, &user_data); - vc_widget_client_get_show_tooltip(g_vc_w, &show); + GSList* client_list = vc_widget_client_get_client_list(); - if (NULL != callback) { - vc_widget_client_use_callback(g_vc_w); - callback(show, user_data); - vc_widget_client_not_use_callback(g_vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "client result callback called"); - } else { - SLOG(LOG_WARN, TAG_VCW, "[WARNING] Show tooltip callback is NULL"); + vc_widget_s *widget_data = NULL; + vc_h vc_w = NULL; + + int count = g_slist_length(client_list); + int i; + for (i = 0; i < count; i++) { + widget_data = g_slist_nth_data(client_list, i); + if (NULL != widget_data) { + vc_w = widget_data->vc; + + vc_widget_client_set_show_tooltip(vc_w, show); + vc_widget_client_get_show_tooltip_cb(vc_w, &callback, &user_data); + vc_widget_client_get_show_tooltip(vc_w, &show); + + if (NULL != callback) { + vc_widget_client_use_callback(vc_w); + callback(show, user_data); + vc_widget_client_not_use_callback(vc_w); + SLOG(LOG_DEBUG, TAG_VCW, "client show tooltip callback called"); + } else { + SLOG(LOG_WARN, TAG_VCW, "[WARNING] Show tooltip callback is NULL"); + } + } } if (true == show) { @@ -1032,15 +1091,7 @@ static Eina_Bool __vc_widget_notify_tooltip(void *data) void __vc_widget_cb_show_tooltip(int pid, bool show) { - if (0 != vc_widget_client_get_handle(pid, &g_vc_w)) { - SLOG(LOG_ERROR, TAG_VCW, "Handle is not valid : pid(%d)", pid); - return; - } - - vc_widget_client_set_show_tooltip(g_vc_w, show); - g_w_tooltip_timer = ecore_timer_add(0, __vc_widget_notify_tooltip, NULL); - - return; + ecore_timer_add(0, __vc_widget_notify_tooltip, (void*)show); } static Eina_Bool __vc_widget_notify_result(void *data) @@ -1048,16 +1099,6 @@ static Eina_Bool __vc_widget_notify_result(void *data) char* temp_text; int event; vc_cmd_list_h vc_cmd_list = NULL; - - vc_result_cb callback = NULL; - void* user_data = NULL; - - vc_widget_client_get_result_cb(g_vc_w, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Client result callback is NULL"); - return EINA_FALSE; - } - if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to create command list"); return EINA_FALSE; @@ -1065,15 +1106,37 @@ static Eina_Bool __vc_widget_notify_result(void *data) vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); - SLOG(LOG_INFO, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); + SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); + + vc_result_cb callback = NULL; + void* user_data = NULL; + + GSList* client_list = vc_widget_client_get_client_list(); + + vc_widget_s *widget_data = NULL; + vc_h vc_w = NULL; + + int count = g_slist_length(client_list); + int i; + for (i = 0; i < count; i++) { + widget_data = g_slist_nth_data(client_list, i); + if (NULL != widget_data) { + vc_w = widget_data->vc; + vc_widget_client_get_result_cb(vc_w, &callback, &user_data); + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Client result callback is NULL"); + return EINA_FALSE; + } - vc_cmd_print_list(vc_cmd_list); + vc_cmd_print_list(vc_cmd_list); - vc_widget_client_use_callback(g_vc_w); - callback(event, vc_cmd_list, temp_text, user_data); - vc_widget_client_not_use_callback(g_vc_w); + vc_widget_client_use_callback(vc_w); + callback(event, vc_cmd_list, temp_text, user_data); + vc_widget_client_not_use_callback(vc_w); - SLOG(LOG_INFO, TAG_VCW, "Widget result callback called"); + SLOG(LOG_DEBUG, TAG_VCW, "Widget result callback called"); + } + } /* Release result */ if (NULL != temp_text) free(temp_text); @@ -1095,55 +1158,78 @@ bool __vc_widget_cb_asr_result() char* temp_text; int event; vc_cmd_list_h vc_cmd_list = NULL; - - vc_asr_result_cb callback = NULL; - void* user_data = NULL; - - vc_widget_client_get_asr_result_cb(g_vc_w, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Client result callback is NULL"); - return EINA_FALSE; - } - if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to create command list"); - return EINA_FALSE; + return false; } vc_info_parser_get_result(&temp_text, &event, NULL, -1, vc_cmd_list, false); - SLOG(LOG_DEBUG, TAG_VCW, "Result info : result text(%s) event(%d)", temp_text, event); - vc_widget_client_use_callback(g_vc_w); - bool ret = callback(event, temp_text, user_data); - vc_widget_client_not_use_callback(g_vc_w); + vc_asr_result_cb callback = NULL; + void* user_data = NULL; + + GSList* client_list = vc_widget_client_get_client_list(); + + vc_widget_s *data = NULL; + vc_h vc_w = NULL; + + bool consumed = false; + int count = g_slist_length(client_list); + int i; + for (i = 0; i < count; i++) { + data = g_slist_nth_data(client_list, i); + if (NULL != data) { + vc_w = data->vc; + bool enabled = false; + vc_widget_client_get_asr_result_enabled(vc_w, &enabled); + if (false == enabled) + continue; + + vc_widget_client_get_asr_result_cb(vc_w, &callback, &user_data); + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Client result callback is NULL"); + continue; + } + + vc_widget_client_use_callback(vc_w); + consumed = callback(event, temp_text, user_data); + vc_widget_client_not_use_callback(vc_w); + if (true == consumed) + break; - SLOG(LOG_DEBUG, TAG_VCW, "Widget asr result callback called"); + SLOG(LOG_DEBUG, TAG_VCW, "Widget asr result callback called"); + } + } /* Release result */ if (NULL != temp_text) free(temp_text); vc_cmd_list_destroy(vc_cmd_list, true); - return ret; + return consumed; } static Eina_Bool __vc_widget_notify_state_changed(void *data) { + vc_h vc_w = (vc_h)data; + + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); + vc_state_changed_cb changed_callback = NULL; void* user_data; - vc_widget_client_get_state_changed_cb(g_vc_w, &changed_callback, &user_data); + vc_widget_client_get_state_changed_cb(vc_w, &changed_callback, &user_data); vc_state_e current_state; vc_state_e before_state; - vc_widget_client_get_before_state(g_vc_w, ¤t_state, &before_state); + vc_widget_client_get_before_state(vc_w, ¤t_state, &before_state); if (NULL != changed_callback) { - vc_widget_client_use_callback(g_vc_w); + vc_widget_client_use_callback(vc_w); changed_callback(before_state, current_state, user_data); - vc_widget_client_not_use_callback(g_vc_w); + vc_widget_client_not_use_callback(vc_w); SLOG(LOG_DEBUG, TAG_VCW, "State changed callback is called"); } else { SLOG(LOG_WARN, TAG_VCW, "[WARNING] State changed callback is null"); @@ -1152,13 +1238,14 @@ static Eina_Bool __vc_widget_notify_state_changed(void *data) return EINA_FALSE; } -int vc_widget_set_result_cb(vc_result_cb callback, void* user_data) +int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { return VC_ERROR_INVALID_STATE; } @@ -1168,15 +1255,16 @@ int vc_widget_set_result_cb(vc_result_cb callback, void* user_data) return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_result_cb(g_vc_w, callback, user_data); + vc_widget_client_set_result_cb(vc_w, callback, user_data); return 0; } -int vc_widget_unset_result_cb() +int vc_widget_unset_result_cb(vc_h vc_w) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1187,18 +1275,19 @@ int vc_widget_unset_result_cb() return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_result_cb(g_vc_w, NULL, NULL); + vc_widget_client_set_result_cb(vc_w, NULL, NULL); return 0; } -int vc_widget_set_show_tooltip_cb(vc_widget_show_tooltip_cb callback, void* user_data) +int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, void* user_data) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1209,15 +1298,16 @@ int vc_widget_set_show_tooltip_cb(vc_widget_show_tooltip_cb callback, void* user return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_show_tooltip_cb(g_vc_w, callback, user_data); + vc_widget_client_set_show_tooltip_cb(vc_w, callback, user_data); return 0; } -int vc_widget_unset_show_tooltip_cb() +int vc_widget_unset_show_tooltip_cb(vc_h vc_w) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1228,15 +1318,16 @@ int vc_widget_unset_show_tooltip_cb() return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_show_tooltip_cb(g_vc_w, NULL, NULL); + vc_widget_client_set_show_tooltip_cb(vc_w, NULL, NULL); return 0; } -int vc_widget_set_send_current_command_list_cb(vc_widget_send_current_command_list_cb callback, void* user_data) +int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current_command_list_cb callback, void* user_data) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1247,15 +1338,16 @@ int vc_widget_set_send_current_command_list_cb(vc_widget_send_current_command_li return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_send_command_list_cb(g_vc_w, callback, user_data); + vc_widget_client_set_send_command_list_cb(vc_w, callback, user_data); return 0; } -int vc_widget_unset_send_current_command_list_cb() +int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1266,47 +1358,62 @@ int vc_widget_unset_send_current_command_list_cb() return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_send_command_list_cb(g_vc_w, NULL, NULL); + vc_widget_client_set_send_command_list_cb(vc_w, NULL, NULL); return 0; } int __vc_widget_cb_service_state(int state) { - vc_service_state_e current_state = (vc_service_state_e)state; - vc_service_state_e before_state; - vc_widget_client_get_service_state(g_vc_w, &before_state); + GSList* client_list = vc_widget_client_get_client_list(); - if (current_state == before_state) { - return 0; - } + vc_widget_s *data = NULL; + vc_h vc_w = NULL; - SLOG(LOG_DEBUG, TAG_VCW, "Service State changed : Before(%d) Current(%d)", - before_state, current_state); + int count = g_slist_length(client_list); + int i; + for (i = 0; i < count; i++) { + data = g_slist_nth_data(client_list, i); + if (NULL != data) { + vc_w = data->vc; - /* Save service state */ - vc_widget_client_set_service_state(g_vc_w, current_state); + vc_service_state_e current_state = (vc_service_state_e)state; + vc_service_state_e before_state; + vc_widget_client_get_service_state(vc_w, &before_state); - vc_service_state_changed_cb callback = NULL; - void* service_user_data = NULL; - vc_widget_client_get_service_state_changed_cb(g_vc_w, &callback, &service_user_data); + if (current_state == before_state) { + continue; + } - if (NULL != callback) { - vc_widget_client_use_callback(g_vc_w); - callback((vc_service_state_e)before_state, (vc_service_state_e)current_state, service_user_data); - vc_widget_client_not_use_callback(g_vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "Service state changed callback is called"); - } else { - SLOG(LOG_WARN, TAG_VCW, "[WARNING] Service state changed callback is null"); + SLOG(LOG_DEBUG, TAG_VCW, "Service State changed : Before(%d) Current(%d)", + before_state, current_state); + + /* Save service state */ + vc_widget_client_set_service_state(vc_w, current_state); + + vc_service_state_changed_cb callback = NULL; + void* service_user_data = NULL; + vc_widget_client_get_service_state_changed_cb(vc_w, &callback, &service_user_data); + + if (NULL != callback) { + vc_widget_client_use_callback(vc_w); + callback((vc_service_state_e)before_state, (vc_service_state_e)current_state, service_user_data); + vc_widget_client_not_use_callback(vc_w); + SLOG(LOG_DEBUG, TAG_VCW, "Service state changed callback is called"); + } else { + SLOG(LOG_WARN, TAG_VCW, "[WARNING] Service state changed callback is null"); + } + } } return 0; } -int vc_widget_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) +int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_cb callback, void* user_data) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1317,15 +1424,16 @@ int vc_widget_set_service_state_changed_cb(vc_service_state_changed_cb callback, return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_service_state_changed_cb(g_vc_w, callback, user_data); + vc_widget_client_set_service_state_changed_cb(vc_w, callback, user_data); return 0; } -int vc_widget_unset_service_state_changed_cb() +int vc_widget_unset_service_state_changed_cb(vc_h vc_w) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1336,18 +1444,19 @@ int vc_widget_unset_service_state_changed_cb() return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_service_state_changed_cb(g_vc_w, NULL, NULL); + vc_widget_client_set_service_state_changed_cb(vc_w, NULL, NULL); return 0; } -int vc_widget_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) +int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void* user_data) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1358,15 +1467,16 @@ int vc_widget_set_state_changed_cb(vc_state_changed_cb callback, void* user_data return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_state_changed_cb(g_vc_w, callback, user_data); + vc_widget_client_set_state_changed_cb(vc_w, callback, user_data); return 0; } -int vc_widget_unset_state_changed_cb() +int vc_widget_unset_state_changed_cb(vc_h vc_w) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1377,18 +1487,19 @@ int vc_widget_unset_state_changed_cb() return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_state_changed_cb(g_vc_w, NULL, NULL); + vc_widget_client_set_state_changed_cb(vc_w, NULL, NULL); return 0; } -int vc_widget_set_asr_result_cb(vc_asr_result_cb callback, void* user_data) +int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user_data) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1399,15 +1510,16 @@ int vc_widget_set_asr_result_cb(vc_asr_result_cb callback, void* user_data) return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_asr_result_cb(g_vc_w, callback, user_data); + vc_widget_client_set_asr_result_cb(vc_w, callback, user_data); return 0; } -int vc_widget_unset_asr_result_cb() +int vc_widget_unset_asr_result_cb(vc_h vc_w) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1418,18 +1530,19 @@ int vc_widget_unset_asr_result_cb() return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_asr_result_cb(g_vc_w, NULL, NULL); + vc_widget_client_set_asr_result_cb(vc_w, NULL, NULL); return 0; } -int vc_widget_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) +int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_changed_cb callback, void* user_data) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1440,15 +1553,16 @@ int vc_widget_set_current_language_changed_cb(vc_current_language_changed_cb cal return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_current_lang_changed_cb(g_vc_w, callback, user_data); + vc_widget_client_set_current_lang_changed_cb(vc_w, callback, user_data); return 0; } -int vc_widget_unset_current_language_changed_cb() +int vc_widget_unset_current_language_changed_cb(vc_h vc_w) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1459,18 +1573,19 @@ int vc_widget_unset_current_language_changed_cb() return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_current_lang_changed_cb(g_vc_w, NULL, NULL); + vc_widget_client_set_current_lang_changed_cb(vc_w, NULL, NULL); return 0; } -int vc_widget_set_error_cb(vc_error_cb callback, void* user_data) +int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1481,15 +1596,16 @@ int vc_widget_set_error_cb(vc_error_cb callback, void* user_data) return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_error_cb(g_vc_w, callback, user_data); + vc_widget_client_set_error_cb(vc_w, callback, user_data); return 0; } -int vc_widget_unset_error_cb() +int vc_widget_unset_error_cb(vc_h vc_w) { + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; - if (0 != vc_widget_client_get_state(g_vc_w, &state)) { + if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1500,7 +1616,7 @@ int vc_widget_unset_error_cb() return VC_ERROR_INVALID_STATE; } - vc_widget_client_set_error_cb(g_vc_w, NULL, NULL); + vc_widget_client_set_error_cb(vc_w, NULL, NULL); return 0; } diff --git a/client/vc_widget_client.c b/client/vc_widget_client.c index d32c23d..e2415a6 100644 --- a/client/vc_widget_client.c +++ b/client/vc_widget_client.c @@ -20,54 +20,14 @@ #include "voice_control_command.h" #include "voice_control_common.h" - -typedef struct { - /* base info */ - vc_h vc; - int pid; - int uid; /*<< unique id = pid + handle */ - int xid; /*<< main X window id */ - - vc_result_cb result_cb; - void* result_user_data; - vc_asr_result_cb asr_result_cb; - void* asr_result_user_data; - vc_error_cb error_cb; - void* error_user_data; - vc_service_state_changed_cb service_state_changed_cb; - void* service_state_changed_user_data; - vc_state_changed_cb state_changed_cb; - void* state_changed_user_data; - vc_widget_show_tooltip_cb show_tooltip_cb; - void* show_tooltip_user_data; - vc_current_language_changed_cb current_lang_changed_cb; - void* current_lang_changed_user_data; - - vc_widget_send_current_command_list_cb send_command_list_cb; - void* send_command_list_user_data; - - /* tooltip */ - bool show_tooltip; - - /* service state */ - vc_service_state_e service_state; - - /* state */ - vc_state_e before_state; - vc_state_e current_state; - - /* mutex */ - int cb_ref_count; - - /* error data */ - int reason; -} vc_widget_s; - - +/* Max number of handle */ +static const int g_max_handle = 999; +/* allocated handle */ +static int g_allocated_handle = 0; /* widget list */ static GSList *g_widget_list = NULL; -static vc_widget_s* __widget_get(vc_h vc) +vc_widget_s* widget_get(vc_h vc) { if (vc == NULL) { SLOG(LOG_WARN, TAG_VCW, "[WARNING] Input parameter is NULL"); @@ -94,6 +54,18 @@ static vc_widget_s* __widget_get(vc_h vc) return NULL; } +static int __client_generate_uid(int pid) +{ + g_allocated_handle++; + + if (g_allocated_handle > g_max_handle) { + g_allocated_handle = 1; + } + + /* generate uid, handle number should be smaller than 1000 */ + return pid * 1000 + g_allocated_handle; +} + int vc_widget_client_create(vc_h* vc) { vc_widget_s *widget = NULL; @@ -111,7 +83,7 @@ int vc_widget_client_create(vc_h* vc) return VC_ERROR_OUT_OF_MEMORY; } - temp->handle = getpid(); + temp->handle = __client_generate_uid(getpid()); /* initialize widget data */ widget->vc = temp; @@ -123,6 +95,7 @@ int vc_widget_client_create(vc_h* vc) widget->result_user_data = NULL; widget->asr_result_cb = NULL; widget->asr_result_user_data = NULL; + widget->asr_result_enabled = false; widget->service_state_changed_cb = NULL; widget->service_state_changed_user_data = NULL; widget->state_changed_cb = NULL; @@ -135,6 +108,8 @@ int vc_widget_client_create(vc_h* vc) widget->before_state = VC_STATE_INITIALIZED; widget->current_state = VC_STATE_INITIALIZED; + widget->conn_timer = NULL; + widget->cb_ref_count = 0; g_widget_list = g_slist_append(g_widget_list, widget); @@ -182,9 +157,14 @@ int vc_widget_client_destroy(vc_h vc) return -1; } +GSList* vc_widget_client_get_client_list() +{ + return g_widget_list; +} + bool vc_widget_client_is_valid(vc_h vc) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) { @@ -240,7 +220,7 @@ int vc_widget_client_get_handle(int uid, vc_h* vc) /* set/get callback function */ int vc_widget_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -254,7 +234,7 @@ int vc_widget_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_da int vc_widget_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -266,9 +246,35 @@ int vc_widget_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_ return 0; } +int vc_widget_client_set_asr_result_enabled(vc_h vc, bool enabled) +{ + vc_widget_s* widget = widget_get(vc); + + /* check handle */ + if (NULL == widget) + return VC_ERROR_INVALID_PARAMETER; + + widget->asr_result_enabled = enabled; + + return 0; +} + +int vc_widget_client_get_asr_result_enabled(vc_h vc, bool* enabled) +{ + vc_widget_s* widget = widget_get(vc); + + /* check handle */ + if (NULL == widget) + return VC_ERROR_INVALID_PARAMETER; + + *enabled = widget->asr_result_enabled; + + return 0; +} + int vc_widget_client_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -282,7 +288,7 @@ int vc_widget_client_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* int vc_widget_client_get_asr_result_cb(vc_h vc, vc_asr_result_cb* callback, void** user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -296,7 +302,7 @@ int vc_widget_client_get_asr_result_cb(vc_h vc, vc_asr_result_cb* callback, void int vc_widget_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -310,7 +316,7 @@ int vc_widget_client_set_service_state_changed_cb(vc_h vc, vc_service_state_chan int vc_widget_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* callback, void** user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -324,7 +330,7 @@ int vc_widget_client_get_service_state_changed_cb(vc_h vc, vc_service_state_chan int vc_widget_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -338,7 +344,7 @@ int vc_widget_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, int vc_widget_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void** user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -352,7 +358,7 @@ int vc_widget_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback int vc_widget_client_set_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb callback, void* user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -366,7 +372,7 @@ int vc_widget_client_set_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb call int vc_widget_client_get_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb* callback, void** user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -380,7 +386,7 @@ int vc_widget_client_get_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb* cal int vc_widget_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb callback, void* user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -394,7 +400,7 @@ int vc_widget_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_ch int vc_widget_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb* callback, void** user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -408,7 +414,7 @@ int vc_widget_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_ch int vc_widget_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -422,7 +428,7 @@ int vc_widget_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data int vc_widget_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -436,7 +442,7 @@ int vc_widget_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_da int vc_widget_client_set_send_command_list_cb(vc_h vc, vc_widget_send_current_command_list_cb callback, void* user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -450,7 +456,7 @@ int vc_widget_client_set_send_command_list_cb(vc_h vc, vc_widget_send_current_co int vc_widget_client_get_send_command_list_cb(vc_h vc, vc_widget_send_current_command_list_cb* callback, void** user_data) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -466,7 +472,7 @@ int vc_widget_client_get_send_command_list_cb(vc_h vc, vc_widget_send_current_co /* set/get option */ int vc_widget_client_set_service_state(vc_h vc, vc_service_state_e state) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -479,7 +485,7 @@ int vc_widget_client_set_service_state(vc_h vc, vc_service_state_e state) int vc_widget_client_get_service_state(vc_h vc, vc_service_state_e* state) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -493,7 +499,7 @@ int vc_widget_client_get_service_state(vc_h vc, vc_service_state_e* state) int vc_widget_client_set_state(vc_h vc, vc_state_e state) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -507,7 +513,7 @@ int vc_widget_client_set_state(vc_h vc, vc_state_e state) int vc_widget_client_get_state(vc_h vc, vc_state_e* state) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -541,7 +547,7 @@ int vc_widget_client_get_state_by_uid(int uid, vc_state_e* state) int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -555,7 +561,7 @@ int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* be int vc_widget_client_set_xid(vc_h vc, int xid) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -568,7 +574,7 @@ int vc_widget_client_set_xid(vc_h vc, int xid) int vc_widget_cilent_get_xid(vc_h vc, int* xid) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -581,7 +587,7 @@ int vc_widget_cilent_get_xid(vc_h vc, int* xid) int vc_widget_client_set_error(vc_h vc, int reason) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -594,7 +600,7 @@ int vc_widget_client_set_error(vc_h vc, int reason) int vc_widget_client_get_error(vc_h vc, int* reason) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -607,7 +613,7 @@ int vc_widget_client_get_error(vc_h vc, int* reason) int vc_widget_client_set_show_tooltip(vc_h vc, bool show) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -620,7 +626,7 @@ int vc_widget_client_set_show_tooltip(vc_h vc, bool show) int vc_widget_client_get_show_tooltip(vc_h vc, bool* show) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -638,7 +644,7 @@ int vc_widget_client_get_count() int vc_widget_client_use_callback(vc_h vc) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) @@ -650,7 +656,7 @@ int vc_widget_client_use_callback(vc_h vc) int vc_widget_client_not_use_callback(vc_h vc) { - vc_widget_s* widget = __widget_get(vc); + vc_widget_s* widget = widget_get(vc); /* check handle */ if (NULL == widget) diff --git a/client/vc_widget_client.h b/client/vc_widget_client.h index ca2dc90..b5c9633 100644 --- a/client/vc_widget_client.h +++ b/client/vc_widget_client.h @@ -26,6 +26,51 @@ extern "C" { #endif +typedef struct { + /* base info */ + vc_h vc; + int pid; + int uid; /*<< unique id = pid + handle */ + int xid; /*<< main X window id */ + + vc_result_cb result_cb; + void* result_user_data; + vc_asr_result_cb asr_result_cb; + void* asr_result_user_data; + bool asr_result_enabled; + vc_error_cb error_cb; + void* error_user_data; + vc_service_state_changed_cb service_state_changed_cb; + void* service_state_changed_user_data; + vc_state_changed_cb state_changed_cb; + void* state_changed_user_data; + vc_widget_show_tooltip_cb show_tooltip_cb; + void* show_tooltip_user_data; + vc_current_language_changed_cb current_lang_changed_cb; + void* current_lang_changed_user_data; + + vc_widget_send_current_command_list_cb send_command_list_cb; + void* send_command_list_user_data; + + /* tooltip */ + bool show_tooltip; + + /* service state */ + vc_service_state_e service_state; + + /* state */ + vc_state_e before_state; + vc_state_e current_state; + + Ecore_Timer* conn_timer; + + /* mutex */ + int cb_ref_count; + + /* error data */ + int reason; +} vc_widget_s; + /* * Common function */ @@ -39,6 +84,10 @@ bool vc_widget_client_is_valid_by_uid(int uid); int vc_widget_client_get_handle(int uid, vc_h* vc); +vc_widget_s* widget_get(vc_h vc); + +GSList* vc_widget_client_get_client_list(); + /* * set/get callback function */ @@ -103,6 +152,10 @@ int vc_widget_client_set_show_tooltip(vc_h vc, bool show); int vc_widget_client_get_show_tooltip(vc_h vc, bool* show); +int vc_widget_client_set_asr_result_enabled(vc_h vc, bool enabled); + +int vc_widget_client_get_asr_result_enabled(vc_h vc, bool* enabled); + /* utils */ int vc_widget_client_get_count(); diff --git a/include/voice_control_widget.h b/include/voice_control_widget.h index 03b6c89..510eb20 100644 --- a/include/voice_control_widget.h +++ b/include/voice_control_widget.h @@ -23,6 +23,7 @@ #include #include +typedef struct vc_s *vc_h; /** * @addtogroup VOICE_CONTROL_WIDGET @@ -88,7 +89,7 @@ typedef void (*vc_widget_send_current_command_list_cb)(vc_cmd_list_h* vc_cmd_lis * * @see vc_widget_deinitialize() */ -int vc_widget_initialize(); +int vc_widget_initialize(vc_h* vc); /** * @brief Deinitialize voice control for widget. @@ -102,7 +103,7 @@ int vc_widget_initialize(); * * @see vc_widget_initialize() */ -int vc_widget_deinitialize(); +int vc_widget_deinitialize(vc_h vc); /** * @brief Connects the voice control service asynchronously. @@ -119,7 +120,7 @@ int vc_widget_deinitialize(); * * @see vc_widget_unprepare() */ -int vc_widget_prepare(); +int vc_widget_prepare(vc_h vc); /** * @brief Disconnects the voice control service. @@ -136,7 +137,7 @@ int vc_widget_prepare(); * * @see vc_widget_prepare() */ -int vc_widget_unprepare(); +int vc_widget_unprepare(vc_h vc); /** * @brief Retrieves all supported languages using callback function. @@ -157,7 +158,7 @@ int vc_widget_unprepare(); * @see vc_supported_language_cb() * @see vc_widget_get_current_language() */ -int vc_widget_foreach_supported_languages(vc_supported_language_cb callback, void* user_data); +int vc_widget_foreach_supported_languages(vc_h vc, vc_supported_language_cb callback, void* user_data); /** * @brief Gets current language set by user. @@ -180,7 +181,7 @@ int vc_widget_foreach_supported_languages(vc_supported_language_cb callback, voi * * @see vc_widget_foreach_supported_languages() */ -int vc_widget_get_current_language(char** language); +int vc_widget_get_current_language(vc_h vc, char** language); /** * @brief Gets current state of voice control widget. @@ -199,7 +200,7 @@ int vc_widget_get_current_language(char** language); * @see vc_widget_set_state_changed_cb() * @see vc_widget_unset_state_changed_cb() */ -int vc_widget_get_state(vc_state_e* state); +int vc_widget_get_state(vc_h vc, vc_state_e* state); /** * @brief Gets current state of voice control service. @@ -217,7 +218,7 @@ int vc_widget_get_state(vc_state_e* state); * @see vc_set_service_state_changed_cb() * @see vc_unset_service_state_changed_cb() */ -int vc_widget_get_service_state(vc_service_state_e* state); +int vc_widget_get_service_state(vc_h vc, vc_service_state_e* state); /** * @brief Checks whether the command format is supported. @@ -234,7 +235,7 @@ int vc_widget_get_service_state(vc_service_state_e* state); * * @pre The state should be #VC_STATE_READY. */ -int vc_widget_is_command_format_supported(vc_cmd_format_e format, bool* support); +int vc_widget_is_command_format_supported(vc_h vc, vc_cmd_format_e format, bool* support); /** @@ -251,7 +252,7 @@ int vc_widget_is_command_format_supported(vc_cmd_format_e format, bool* support) * * @pre The state should be #VC_STATE_READY. */ -int vc_widget_set_foreground(bool value); +int vc_widget_set_foreground(vc_h vc, bool value); /** * @brief Cancels recognition. @@ -272,7 +273,7 @@ int vc_widget_set_foreground(bool value); * @see vc_widget_stop() * @see vc_state_changed_cb() */ -int vc_widget_cancel(); +int vc_widget_cancel(vc_h vc); /** * @brief Registers a callback function for getting recognition result. @@ -291,7 +292,7 @@ int vc_widget_cancel(); * @see vc_widget_result_cb() * @see vc_widget_unset_result_cb() */ -int vc_widget_set_result_cb(vc_result_cb callback, void* user_data); +int vc_widget_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data); /** @@ -307,7 +308,7 @@ int vc_widget_set_result_cb(vc_result_cb callback, void* user_data); * * @see vc_widget_set_result_cb() */ -int vc_widget_unset_result_cb(); +int vc_widget_unset_result_cb(vc_h vc); /** * @brief Registers a callback function for showing or hiding tooltip. @@ -326,7 +327,7 @@ int vc_widget_unset_result_cb(); * @see vc_widget_show_tooltip_cb() * @see vc_widget_unset_show_tooltip_cb() */ -int vc_widget_set_show_tooltip_cb(vc_widget_show_tooltip_cb callback, void* user_data); +int vc_widget_set_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb callback, void* user_data); /** * @brief Unregisters the callback function. @@ -341,7 +342,7 @@ int vc_widget_set_show_tooltip_cb(vc_widget_show_tooltip_cb callback, void* user * * @see vc_widget_set_show_tooltip_cb() */ -int vc_widget_unset_show_tooltip_cb(); +int vc_widget_unset_show_tooltip_cb(vc_h vc); /** * @brief Registers a callback function for setting current command. @@ -360,7 +361,7 @@ int vc_widget_unset_show_tooltip_cb(); * @see vc_widget_send_current_command_list_cb() * @see vc_widget_unset_send_current_command_list_cb() */ -int vc_widget_set_send_current_command_list_cb(vc_widget_send_current_command_list_cb callback, void* user_data); +int vc_widget_set_send_current_command_list_cb(vc_h vc, vc_widget_send_current_command_list_cb callback, void* user_data); /** * @brief Unregisters the callback function. @@ -375,7 +376,7 @@ int vc_widget_set_send_current_command_list_cb(vc_widget_send_current_command_li * * @see vc_widget_set_send_current_command_list_cb() */ -int vc_widget_unset_send_current_command_list_cb(); +int vc_widget_unset_send_current_command_list_cb(vc_h vc); /** * @brief Registers a callback function to be called when service state is changed. @@ -394,7 +395,7 @@ int vc_widget_unset_send_current_command_list_cb(); * @see vc_service_state_changed_cb() * @see vc_widget_unset_service_state_changed_cb() */ -int vc_widget_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data); +int vc_widget_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data); /** * @brief Unregisters the callback function. @@ -409,7 +410,7 @@ int vc_widget_set_service_state_changed_cb(vc_service_state_changed_cb callback, * * @see vc_widget_set_service_state_changed_cb() */ -int vc_widget_unset_service_state_changed_cb(); +int vc_widget_unset_service_state_changed_cb(vc_h vc); /** * @brief Registers a callback function for getting state changed. @@ -429,7 +430,7 @@ int vc_widget_unset_service_state_changed_cb(); * @see vc_state_changed_cb() * @see vc_widget_unset_state_changed_cb() */ -int vc_widget_set_state_changed_cb(vc_state_changed_cb callback, void* user_data); +int vc_widget_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* user_data); /** * @brief Unregisters the callback function. @@ -444,7 +445,7 @@ int vc_widget_set_state_changed_cb(vc_state_changed_cb callback, void* user_data * * @see vc_widget_set_state_changed_cb() */ -int vc_widget_unset_state_changed_cb(); +int vc_widget_unset_state_changed_cb(vc_h vc); /** * @brief Registers a callback function to be called when current language is changed. @@ -464,7 +465,7 @@ int vc_widget_unset_state_changed_cb(); * @see vc_current_language_changed_cb() * @see vc_widget_unset_current_language_changed_cb() */ -int vc_widget_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data); +int vc_widget_set_current_language_changed_cb(vc_h vc, vc_current_language_changed_cb callback, void* user_data); /** * @brief Unregisters the callback function. @@ -479,7 +480,7 @@ int vc_widget_set_current_language_changed_cb(vc_current_language_changed_cb cal * * @see vc_widget_set_current_language_changed_cb() */ -int vc_widget_unset_current_language_changed_cb(); +int vc_widget_unset_current_language_changed_cb(vc_h vc); /** * @brief Registers a callback function for an error occurred. @@ -499,7 +500,7 @@ int vc_widget_unset_current_language_changed_cb(); * @see vc_error_cb() * @see vc_widget_unset_error_cb() */ -int vc_widget_set_error_cb(vc_error_cb callback, void* user_data); +int vc_widget_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data); /** * @brief Unregisters the callback function. @@ -514,7 +515,7 @@ int vc_widget_set_error_cb(vc_error_cb callback, void* user_data); * * @see vc_widget_set_error_cb() */ -int vc_widget_unset_error_cb(); +int vc_widget_unset_error_cb(vc_h vc); /** * @brief Sets option for obtain ASR result as dictation via result callback. @@ -534,7 +535,7 @@ int vc_widget_unset_error_cb(); * @pre The state should be #VC_STATE_READY. * */ -int vc_widget_enable_asr_result(bool enable); +int vc_widget_enable_asr_result(vc_h vc, bool enable); /** * @brief Registers a callback function for an asr result. @@ -553,7 +554,7 @@ int vc_widget_enable_asr_result(bool enable); * @see vc_widget_enable_asr_result() * @see vc_widget_unset_asr_result_cb() */ -int vc_widget_set_asr_result_cb(vc_asr_result_cb callback, void* user_data); +int vc_widget_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* user_data); /** * @brief Unregisters the callback function. @@ -566,7 +567,7 @@ int vc_widget_set_asr_result_cb(vc_asr_result_cb callback, void* user_data); * * @see vc_widget_set_asr_result_cb() */ -int vc_widget_unset_asr_result_cb(); +int vc_widget_unset_asr_result_cb(vc_h vc); #ifdef __cplusplus } diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 7d0f348..55b75f8 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -341,7 +341,7 @@ int vcdc_send_asr_result(int pid, int cmd_type, bool* is_consumed) DBusMessage* result_msg; int result = 0; - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); + result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, 5000, &err); dbus_message_unref(msg); if (dbus_error_is_set(&err)) { diff --git a/server/vcd_server.c b/server/vcd_server.c index a452b68..4308f1e 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -2099,8 +2099,8 @@ int vcd_server_widget_initialize(int pid) /* check if pid is valid */ if (true == vcd_client_widget_is_available(pid)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] The pid is already exist"); - return VCD_ERROR_INVALID_PARAMETER; + SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] The pid is already exist"); + return VCD_ERROR_NONE; } /* Add client information to client manager */ -- 2.7.4 From c03e6c1e5c835f3a211efaa4cde12be2dbee4f69 Mon Sep 17 00:00:00 2001 From: Wonnam Jang Date: Mon, 2 Jan 2017 18:49:02 +0900 Subject: [PATCH 11/16] Add defence code when widget command is not registered Change-Id: Iebb921fc11044f46b0075d90c9da200c106ff539 Signed-off-by: Wonnam Jang (cherry picked from commit 69e68b702425f2d1f74151d107c1d43623bd4606) --- client/vc_widget.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/vc_widget.c b/client/vc_widget.c index 3989c99..9d3f835 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -1007,6 +1007,11 @@ static Eina_Bool __vc_widget_start_recording(void *data) if (NULL != vc_cmd_list) { vc_cmd_list_s* list = NULL; list = (vc_cmd_list_s*)vc_cmd_list; + if (NULL == list || NULL == list->list) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] No registered commands from send_command_list_cb"); + break; + } + ret = vc_cmd_parser_save_file(getpid(), VC_COMMAND_TYPE_WIDGET, list->list, NULL); if (0 == ret) { /* widget command is valid */ @@ -1023,7 +1028,10 @@ static Eina_Bool __vc_widget_start_recording(void *data) } } - SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] command list (%d)", g_slist_length(((vc_cmd_list_s*)vc_cmd_list)->list)); + if (NULL != vc_cmd_list) + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] command list (%d)", g_slist_length(((vc_cmd_list_s*)vc_cmd_list)->list)); + else + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] command list (NULL)"); ret = -1; count = 0; @@ -1048,6 +1056,7 @@ static Eina_Bool __vc_widget_start_recording(void *data) return EINA_FALSE; } + static Eina_Bool __vc_widget_notify_tooltip(void *data) { bool show = (bool)data; -- 2.7.4 From 9d64cddb8e8e894cdc68ceb16b980d1294b39142 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Tue, 3 Jan 2017 11:39:25 +0900 Subject: [PATCH 12/16] Add null checker for vc handle Change-Id: I35c95b0f1dbcdc9a77943d495fa8d7c434ef9d34 Signed-off-by: sooyeon.kim (cherry picked from commit 56d901b6741cf34b6dec4cba51d9b8020106f829) --- client/vc_widget.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/client/vc_widget.c b/client/vc_widget.c index 3989c99..3143799 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -1240,6 +1240,11 @@ static Eina_Bool __vc_widget_notify_state_changed(void *data) int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1262,6 +1267,11 @@ int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) int vc_widget_unset_result_cb(vc_h vc_w) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1282,6 +1292,11 @@ int vc_widget_unset_result_cb(vc_h vc_w) int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, void* user_data) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1305,6 +1320,11 @@ int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, int vc_widget_unset_show_tooltip_cb(vc_h vc_w) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1325,6 +1345,11 @@ int vc_widget_unset_show_tooltip_cb(vc_h vc_w) int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current_command_list_cb callback, void* user_data) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1345,6 +1370,11 @@ int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1411,6 +1441,11 @@ int __vc_widget_cb_service_state(int state) int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_cb callback, void* user_data) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1431,6 +1466,11 @@ int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_c int vc_widget_unset_service_state_changed_cb(vc_h vc_w) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1451,6 +1491,11 @@ int vc_widget_unset_service_state_changed_cb(vc_h vc_w) int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void* user_data) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1474,6 +1519,11 @@ int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void int vc_widget_unset_state_changed_cb(vc_h vc_w) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1494,6 +1544,11 @@ int vc_widget_unset_state_changed_cb(vc_h vc_w) int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user_data) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1517,6 +1572,11 @@ int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user int vc_widget_unset_asr_result_cb(vc_h vc_w) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1537,6 +1597,11 @@ int vc_widget_unset_asr_result_cb(vc_h vc_w) int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_changed_cb callback, void* user_data) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1560,6 +1625,11 @@ int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_cha int vc_widget_unset_current_language_changed_cb(vc_h vc_w) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { @@ -1580,6 +1650,11 @@ int vc_widget_unset_current_language_changed_cb(vc_h vc_w) int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -1603,6 +1678,11 @@ int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) int vc_widget_unset_error_cb(vc_h vc_w) { + if (NULL == vc_w) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); + return VC_ERROR_INVALID_PARAMETER; + } + SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; if (0 != vc_widget_client_get_state(vc_w, &state)) { -- 2.7.4 From c15f5dbfbd7112c6f3b56ce566921d0892b90b0e Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Tue, 3 Jan 2017 15:14:06 +0900 Subject: [PATCH 13/16] Fix invalid memory access Change-Id: Ic4620f58cbc31c157771a4bc21696d7489fb8dae (cherry picked from commit c5bbe2e34202f7242ab614616060ccb408d707cc) --- client/vc_widget.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/client/vc_widget.c b/client/vc_widget.c index 0f746be..98843fc 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -1028,11 +1028,6 @@ static Eina_Bool __vc_widget_start_recording(void *data) } } - if (NULL != vc_cmd_list) - SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] command list (%d)", g_slist_length(((vc_cmd_list_s*)vc_cmd_list)->list)); - else - SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] command list (NULL)"); - ret = -1; count = 0; while (0 != ret) { -- 2.7.4 From 7ad17f06545f11d99c867fa7c3bccf632b51a9b2 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Wed, 4 Jan 2017 17:13:48 +0900 Subject: [PATCH 14/16] Change command collect timing Change-Id: I974664edf6c44dd7148b46c249bef55549e875bb (cherry picked from commit 705d95e146a43803ff7184b5ee087a607ef8a6f9) --- server/vcd_client_data.c | 12 +++++++++++- server/vcd_server.c | 13 ------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 562b77a..010bde0 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -444,6 +444,16 @@ int vcd_client_foreach_command(client_foreach_command_cb callback, void* user_da return VCD_ERROR_INVALID_PARAMETER; } + if (0 != vcd_client_command_collect_command()) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command"); + return VCD_ERROR_OPERATION_FAILED; + } + + if (0 >= vcd_client_get_length()) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] No current command"); + return VCD_ERROR_OPERATION_FAILED; + } + // int id_count = 1; GSList *iter = NULL; vc_cmd_s* temp_cmd; @@ -1380,4 +1390,4 @@ int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable) *enable = info->asr_result_enabled; return 0; -} \ No newline at end of file +} diff --git a/server/vcd_server.c b/server/vcd_server.c index cd4088d..dcefbac 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1451,19 +1451,6 @@ static int __start_internal_recognition() { int ret; - /* 2. Get commands */ - ret = vcd_client_command_collect_command(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to collect command : %d", ret); - return VCD_ERROR_OPERATION_FAILED; - } - - ret = vcd_client_get_length(); - if (0 == ret) { - SLOG(LOG_WARN, TAG_VCD, "[Server WARNIING] No current command : %d", ret); - return VCD_ERROR_OPERATION_FAILED; - } - /* 3. Set command to engine */ ret = vcd_engine_set_commands(); if (0 != ret) { -- 2.7.4 From 6ecf371b926ff2c34ff24dec815ea6b366be4cb8 Mon Sep 17 00:00:00 2001 From: Kwangyoun Kim Date: Thu, 12 Jan 2017 14:46:35 +0900 Subject: [PATCH 15/16] Fix invalid command collect logic Change-Id: Icad239763cd78701585fa546dd215a4b2cb194da --- server/vcd_server.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/vcd_server.c b/server/vcd_server.c index dcefbac..9feed7e 100755 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1451,6 +1451,11 @@ static int __start_internal_recognition() { int ret; + if (0 != vcd_client_command_collect_command()) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command"); + return VCD_ERROR_OPERATION_FAILED; + } + /* 3. Set command to engine */ ret = vcd_engine_set_commands(); if (0 != ret) { -- 2.7.4 From dc7e5fe498f7a92acdd3d085d75b53814edb9996 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Wed, 15 Feb 2017 16:40:50 +0900 Subject: [PATCH 16/16] Update header and doc files written in English Change-Id: I35ff11ee224d999d6395b5891bf88b0e272efffc Signed-off-by: Suyeon Hwang (cherry picked from commit f752ead99bcf2736ff9ef5468df9e45c6b4fd7f5) --- doc/uix_vc_doc.h | 21 ++-- include/voice_control.h | 242 +++++++++++++++++----------------------- include/voice_control_command.h | 191 ++++++++++++++----------------- include/voice_control_common.h | 108 +++++++++--------- 4 files changed, 248 insertions(+), 314 deletions(-) diff --git a/doc/uix_vc_doc.h b/doc/uix_vc_doc.h index 621b7de..040b006 100644 --- a/doc/uix_vc_doc.h +++ b/doc/uix_vc_doc.h @@ -18,18 +18,17 @@ #ifndef __TIZEN_UIX_VOICE_CONTROL_DOC_H__ #define __TIZEN_UIX_VOICE_CONTROL_DOC_H__ + /** - * @defgroup CAPI_UIX_VOICE_CONTROL_MODULE Voice control * @ingroup CAPI_UIX_FRAMEWORK + * @defgroup CAPI_UIX_VOICE_CONTROL_MODULE Voice control * @brief The @ref CAPI_UIX_VOICE_CONTROL_MODULE API provides functions for registering command and getting notification when registered command is recognized. - * * @section CAPI_UIX_VOICE_CONTROL_MODULE_HEADER Required Header - * \#include
+ * \#include
* * @section CAPI_UIX_VOICE_CONTROL_MODULE_OVERVIEW Overview * A main function of Voice Control API register command and gets notification for recognition result. * Applications can add their own commands and be provided result when their command is recognized by user voice input. - * * To use of Voice Control, use the following steps:
* 1. Initialize
* 2. Register callback functions for notifications
@@ -46,10 +45,7 @@ * 9. If an application wants to finish voice control,
* 9-1. Destroy command and command list handle
* 9-2. Deinitialize
- * * An application can obtain command handle from command list, and also get information from handle. - * - * * The Voice Control API also notifies you (by callback mechanism) when the states of client and service are changed, * command is recognized, current language is changed or error occurred. * An application should register callback functions: vc_state_changed_cb(), vc_service_state_changed_cb(), vc_result_cb(), @@ -60,10 +56,10 @@ * * @image html capi_uix_voice_control_state_diagram.png " " * The following diagram shows the states of Voice Control service. + * * @image html capi_uix_voice_control_service_state_diagram.png "" * * @section CAPI_UIX_VOICE_CONTROL_MODULE_STATE_TRANSITIONS State Transitions - * * * * @@ -95,14 +91,12 @@ * * * - *
FUNCTIONInitializedSYNC
* * @section CAPI_UIX_VOICE_CONTROL_MODULE_STATE_DEPENDENT_FUNCTION_CALLS State Dependent Function Calls * The following table shows state-dependent function calls. * It is forbidden to call functions listed below in wrong states. * Violation of this rule may result in an unpredictable behavior. - * * * * @@ -198,15 +192,14 @@ * * @section CAPI_UIX_VOICE_CONTROL_MODULE_FEATURES Related Features * This API is related with the following features:
- * - http://tizen.org/feature/microphone
- * - http://tizen.org/feature/speech.control
- * + * - http://tizen.org/feature/microphone
+ * - http://tizen.org/feature/speech.control
* It is recommended to design feature related codes in your application for reliability.
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.
* To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
* More details on featuring your application can be found from Feature Element. - * */ + #endif /* __TIZEN_UIX_VOICE_CONTROL_DOC_H__ */ diff --git a/include/voice_control.h b/include/voice_control.h index 1adcfb7..d8ccd26 100644 --- a/include/voice_control.h +++ b/include/voice_control.h @@ -18,54 +18,64 @@ #ifndef __VOICE_CONTROL_H__ #define __VOICE_CONTROL_H__ + #include #include + /** * @addtogroup CAPI_UIX_VOICE_CONTROL_MODULE * @{ */ + #ifdef __cplusplus extern "C" { #endif + /** * @file voice_control.h * @brief This file contains the voice control client API and related callback definitions and enums. */ + /** * @file voice_control_command.h * @brief This file contains the command list and command API and related handle definitions and enums. */ + /** * @file voice_control_common.h * @brief This file contains the callback function definitions and enums. */ + /** - * @brief Definitions for foreground command type. + * @brief Definition for foreground command type. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_FOREGROUND 1 + /** - * @brief Definitions for background command type. + * @brief Definition for background command type. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ #define VC_COMMAND_TYPE_BACKGROUND 2 + /** - * @brief Definitions for ended dialog. + * @brief Definition for ended dialog. * @since_tizen 3.0 */ #define VC_DIALOG_END 0 + /** - * @brief Definitions for continued dialog. + * @brief Definition for continued dialog. * @since_tizen 3.0 */ #define VC_DIALOG_CONTINUE 1 @@ -76,116 +86,108 @@ extern "C" * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @remarks If the function succeeds, @a vc must be released with vc_deinitialize(). - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory * @retval #VC_ERROR_OPERATION_FAILED Operation failure * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @post If this function is called, the state will be #VC_STATE_INITIALIZED. - * * @see vc_deinitialize() */ int vc_initialize(void); + /** * @brief Deinitializes voice control. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_OPERATION_FAILED Operation failure * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_deinitialize() */ int vc_deinitialize(void); + /** * @brief Connects the voice control service. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_OPERATION_FAILED Operation failure * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. * @post If this function is called, the state will be #VC_STATE_READY. - * * @see vc_unprepare() */ int vc_prepare(void); + /** * @brief Disconnects the voice control service. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_READY. * @post If this function is called, the state will be #VC_STATE_INITIALIZED. - * * @see vc_prepare() */ int vc_unprepare(void); + /** * @brief Retrieves all supported languages using callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[in] callback Callback function to invoke * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_OPERATION_FAILED Operation failure * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. - * @post This function invokes vc_supported_language_cb() repeatedly for getting languages. - * + * @post This function invokes vc_supported_language_cb() repeatedly for getting languages. * @see vc_supported_language_cb() * @see vc_get_current_language() */ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user_data); + /** * @brief Gets current language. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @remark If the function succeeds, @a language must be released with free() by you when you no longer need it. - * - * @param[out] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n - * followed by ISO 639-1 for the two-letter language code. \n - * For example, "ko_KR" for Korean, "en_US" for American English. - * - * @return 0 on success, otherwise a negative error value + * @param[out] language A language is specified as an ISO 3166 alpha-2 two letter country-code + * followed by ISO 639-1 for the two-letter language code. + * For example, "ko_KR" for Korean, "en_US" for American English + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory @@ -193,48 +195,43 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY. - * * @see vc_foreach_supported_languages() */ int vc_get_current_language(char** language); + /** * @brief Gets current state of voice control client. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[out] state The current state - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_state_changed_cb() * @see vc_set_state_changed_cb() */ int vc_get_state(vc_state_e* state); + /** * @brief Gets current state of voice control service. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[out] state The current state - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * - * @pre The state should be #VC_STATE_READY. - * + * @pre The state should be #VC_STATE_READY. * @see vc_request_start() * @see vc_request_stop() * @see vc_request_cancel() @@ -243,356 +240,325 @@ int vc_get_state(vc_state_e* state); */ int vc_get_service_state(vc_service_state_e* state); + /** * @brief Gets the system command list. * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @remarks In the system command list, there are system commands predefined by product manufacturers. Those commands have the highest priority. - * Therefore, the user can not set any commands same with the system commands. \n - * The @a vc_sys_cmd_list must be released using free() when it is no longer required. - * + * Therefore, the user can not set any commands same with the system commands. + * The @a vc_sys_cmd_list must be released using free() when it is no longer required. * @param[out] vc_sys_cmd_list System command list handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The service state should be #VC_SERVICE_STATE_READY. - * * @see vc_unset_command_list() */ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list); + /** * @brief Sets the invocation name. * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @remarks Invocation name is used to activate background commands. The invocation name can be the same as the application name or any other phrase. - * For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set to "Tizen Sample". - * In order to activate the background command, users can say "Tizen Sample, Play music". - * The invocation name is dependent on the current language. For example, if the current language is "en_US"(English), the invocation name is also "en_US". - * If the current language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized. - * This function should be called before vc_set_command_list(). - * + * For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set to "Tizen Sample". + * In order to activate the background command, users can say "Tizen Sample, Play music". + * The invocation name is dependent on the current language. For example, if the current language is "en_US"(English), the invocation name is also "en_US". + * If the current language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized. + * This function should be called before vc_set_command_list(). * @param[in] name Invocation name that an application wants to be invoked by - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_READY. - * * @see vc_set_command_list() */ int vc_set_invocation_name(const char* name); + /** * @brief Requests to start the dialogue. * @details Using this function, the developer can request starting the dialogue to the framework. - * When the developer requests the dialogue, two types of texts, @a disp_text and @a utt_text, can be sent by this function. - * @a disp_text is a text for displaying, and @a utt_text is that for uttering. - * For example, if @a disp_text is "October 10th" and @a utt_text is "Today is October 10th.", "October 10th" will be displayed on the screen and "Today is October 10th." will be spoken. - * Also, the developer can set whether the dialogue starts automatically or not, using @a auto_start. - * If the developer sets @a auto_start as @c true, the framework will start to record next speech and continue the dialogue. - * + * When the developer requests the dialogue, two types of texts, @a disp_text and @a utt_text, can be sent by this function. + * @a disp_text is a text for displaying, and @a utt_text is that for uttering. + * For example, if @a disp_text is "October 10th" and @a utt_text is "Today is October 10th.", "October 10th" will be displayed on the screen and "Today is October 10th." will be spoken. + * Also, the developer can set whether the dialogue starts automatically or not, using @a auto_start. + * If the developer sets @a auto_start as @c true, the framework will start to record next speech and continue the dialogue. * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @remarks If @a auto_start is @c true, the recognition will start again. In this case, it can be restarted up to 4 times. - * * @param[in] disp_text Text to be displayed on the screen * @param[in] utt_text Text to be spoken * @param[in] auto_start A variable for setting whether the dialog session will be restarted automatically or not - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The service state should be #VC_SERVICE_STATE_READY. */ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_start); + /** * @brief Sets command list. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. \n - * The matched commands of command list should be set and they should include type and command text at least. - * + * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. + * The matched commands of command list should be set and they should include type and command text at least. * @param[in] vc_cmd_list Command list handle * @param[in] type Command type - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_READY. - * * @see vc_unset_command_list() */ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type); + /** * @brief Unsets command list. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[in] type Command type - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_READY. - * * @see vc_set_command_list() */ int vc_unset_command_list(int type); + /** * @brief Gets the recognition result. * @since_tizen 3.0 * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[in] callback Callback function to get recognition result * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_READY. - * * @see vc_result_cb() */ int vc_get_result(vc_result_cb callback, void* user_data); + /** * @brief Registers a callback function for getting recognition result. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[in] callback Callback function to register * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_result_cb() * @see vc_unset_result_cb() */ int vc_set_result_cb(vc_result_cb callback, void* user_data); + /** * @brief Unregisters the callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_set_result_cb() */ int vc_unset_result_cb(void); + /** * @brief Registers a callback function to be called when state is changed. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[in] callback Callback function to register * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_service_state_changed_cb() * @see vc_unset_service_state_changed_cb() */ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data); + /** * @brief Unregisters the callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_set_service_state_changed_cb() */ int vc_unset_service_state_changed_cb(void); + /** * @brief Registers a callback function to be called when state is changed. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[in] callback Callback function to register * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_state_changed_cb() * @see vc_unset_state_changed_cb() */ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data); + /** * @brief Unregisters the callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_set_state_changed_cb() */ int vc_unset_state_changed_cb(void); + /** * @brief Registers a callback function to be called when current language is changed. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[in] callback Callback function to register * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_current_language_changed_cb() * @see vc_unset_current_language_changed_cb() */ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data); + /** * @brief Unregisters the callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_set_current_language_changed_cb() */ int vc_unset_current_language_changed_cb(void); + /** * @brief Registers a callback function to be called when an error occurred. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * * @param[in] callback Callback function to register * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_error_cb() * @see vc_unset_error_cb() */ int vc_set_error_cb(vc_error_cb callback, void* user_data); + /** * @brief Unregisters the callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/recorder - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_STATE Invalid state * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @pre The state should be #VC_STATE_INITIALIZED. - * * @see vc_set_error_cb() */ int vc_unset_error_cb(void); diff --git a/include/voice_control_command.h b/include/voice_control_command.h index f4e5ff7..da7045e 100644 --- a/include/voice_control_command.h +++ b/include/voice_control_command.h @@ -18,16 +18,18 @@ #ifndef __VOICE_CONTROL_COMMAND_H__ #define __VOICE_CONTROL_COMMAND_H__ + #include + /** * @defgroup CAPI_UIX_VOICE_CONTROL_COMMAND_MODULE Voice control command * @ingroup CAPI_UIX_VOICE_CONTROL_MODULE - * * @brief The @ref CAPI_UIX_VOICE_CONTROL_COMMAND_MODULE API provides functions for creating/destroying command list and add/remove/retrieve commands of list. * @{ */ + #ifdef __cplusplus extern "C" { @@ -35,31 +37,35 @@ extern "C" /** - * @brief Definition for fixed command format + * @brief Definition for fixed command format. * @since_tizen 3.0 */ #define VC_COMMAND_FORMAT_FIXED 0 + /** - * @brief Definition for fixed and variable fixed command format + * @brief Definition for fixed and variable fixed command format. * @since_tizen 3.0 */ #define VC_COMMAND_FORMAT_FIXED_AND_VFIXED 1 + /** - * @brief Definition for variable fixed and fixed command format + * @brief Definition for variable fixed and fixed command format. * @since_tizen 3.0 */ #define VC_COMMAND_FORMAT_VFIXED_AND_FIXED 2 + /** - * @brief Definition for fixed and non-fixed command format + * @brief Definition for fixed and non-fixed command format. * @since_tizen 3.0 */ #define VC_COMMAND_FORMAT_FIXED_AND_NONFIXED 3 + /** - * @brief Definition for non-fixed and fixed command format + * @brief Definition for non-fixed and fixed command format. * @since_tizen 3.0 */ #define VC_COMMAND_FORMAT_NONFIXED_AND_FIXED 4 @@ -71,22 +77,22 @@ extern "C" */ typedef struct vc_cmd_s* vc_cmd_h; + /** * @brief The voice command list handle. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef struct vc_cmd_list_s* vc_cmd_list_h; + /** * @brief Called to retrieve The commands in list. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_command The command handle * @param[in] user_data The user data passed from the foreach function - * - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. + * @return @c true to continue with the next iteration of the loop, + * @c false to break out of the loop * @pre vc_cmd_list_foreach_commands() will invoke this callback. - * * @see vc_cmd_list_foreach_commands() */ typedef bool (*vc_cmd_list_cb)(vc_cmd_h vc_command, void* user_data); @@ -95,48 +101,44 @@ typedef bool (*vc_cmd_list_cb)(vc_cmd_h vc_command, void* user_data); /** * @brief Creates a handle for command list. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @remarks If the function succeeds, @a The list handle must be released with vc_cmd_list_destroy(). - * * @param[out] vc_cmd_list The command list handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_destroy() */ int vc_cmd_list_create(vc_cmd_list_h* vc_cmd_list); + /** * @brief Destroys the handle for command list. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle * @param[in] free_command The command free option @c true = release each commands in list, - * @c false = remove command from list - * - * @return 0 on success, otherwise a negative error value + * @c false = remove command from list + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_create() */ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool free_command); + /** * @brief Gets command count of list. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle * @param[out] count The count - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied @@ -144,144 +146,135 @@ int vc_cmd_list_destroy(vc_cmd_list_h vc_cmd_list, bool free_command); */ int vc_cmd_list_get_count(vc_cmd_list_h vc_cmd_list, int* count); + /** * @brief Adds command to command list. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle * @param[in] vc_command The command handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_remove() */ int vc_cmd_list_add(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); + /** * @brief Removes command from command list. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle * @param[in] vc_command The command handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_add() */ int vc_cmd_list_remove(vc_cmd_list_h vc_cmd_list, vc_cmd_h vc_command); + /** * @brief Retrieves all commands of command list using callback function. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle * @param[in] callback Callback function to invoke * @param[in] user_data The user data to be passed to the callback function - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * - * @post This function invokes vc_cmd_list_cb() repeatedly for getting commands. - * + * @post This function invokes vc_cmd_list_cb() repeatedly for getting commands. * @see vc_cmd_list_cb() */ int vc_cmd_list_foreach_commands(vc_cmd_list_h vc_cmd_list, vc_cmd_list_cb callback, void* user_data); + /** * @brief Moves index to first command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_EMPTY List empty * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_last() */ int vc_cmd_list_first(vc_cmd_list_h vc_cmd_list); + /** * @brief Moves index to last command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_EMPTY List empty * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_first() */ int vc_cmd_list_last(vc_cmd_list_h vc_cmd_list); + /** * @brief Moves index to next command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_EMPTY List empty * @retval #VC_ERROR_ITERATION_END List reached end * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_prev() */ int vc_cmd_list_next(vc_cmd_list_h vc_cmd_list); + /** * @brief Moves index to previous command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_EMPTY List empty * @retval #VC_ERROR_ITERATION_END List reached end * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_next() */ int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list); + /** * @brief Get current command from command list by index. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_cmd_list The command list handle * @param[out] vc_command The command handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_EMPTY List empty * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_list_first() * @see vc_cmd_list_last() * @see vc_cmd_list_prev() @@ -289,92 +282,85 @@ int vc_cmd_list_prev(vc_cmd_list_h vc_cmd_list); */ int vc_cmd_list_get_current(vc_cmd_list_h vc_cmd_list, vc_cmd_h* vc_command); + /** * @brief Creates a handle for command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @remarks If the function succeeds, @a The command handle must be released - * with vc_cmd_destroy() or vc_cmd_list_destroy(). - * You should set command and type if command is valid. - * The command format is set to #VC_COMMAND_FORMAT_FIXED by default and can be changed with vc_cmd_set_format(). - * + * with vc_cmd_destroy() or vc_cmd_list_destroy(). + * You should set command and type if command is valid. + * The command format is set to #VC_COMMAND_FORMAT_FIXED by default and can be changed with vc_cmd_set_format(). * @param[out] vc_command The command handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_destroy() */ int vc_cmd_create(vc_cmd_h* vc_command); + /** * @brief Destroys the handle. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_command The command handle - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_create() */ int vc_cmd_destroy(vc_cmd_h vc_command); + /** * @brief Sets command or action. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_command The command handle * @param[in] command The command or action text - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_get_command() */ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command); + /** * @brief Gets command. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @remark If the function succeeds, @a command must be released with free() by you if they are not NULL. - * * @param[in] vc_command The command handle * @param[out] command The command text - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_set_command() */ int vc_cmd_get_command(vc_cmd_h vc_command, char** command); + /** * @brief Gets the unfixed command. * @since_tizen 3.0 - * * @remark If the function succeeds, the @a command must be released with free() if it is not NULL. - * If the command of the given @a vc_command is NULL (@a vc_command is NOT NULL), @a command will be also NULL. - * This function should be used for commands which have non-fixed format. - * + * If the command of the given @a vc_command is NULL (@a vc_command is NOT NULL), @a command will be also NULL. + * This function should be used for commands which have non-fixed format. * @param[in] vc_command The command handle * @param[out] command The unfixed command text - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied @@ -382,77 +368,70 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command); */ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command); + /** * @brief Sets command type. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * - * @remark If you do not set the command type, the default value is -1. - * You should set type if command is valid - * + * @remark If you do not set the command type, the default value is @c -1. + * You should set type if command is valid * @param[in] vc_command The command handle * @param[in] type The command type - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_get_type() */ int vc_cmd_set_type(vc_cmd_h vc_command, int type); + /** * @brief Gets command type. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] vc_command The command handle * @param[out] type The command type - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported - * * @see vc_cmd_set_type() */ int vc_cmd_get_type(vc_cmd_h vc_command, int* type); + /** * @brief Sets the command format. * @since_tizen 3.0 - * * @remark The default format is #VC_COMMAND_FORMAT_FIXED. - * * @param[in] vc_command The command handle * @param[in] format The command format - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported feature - * * @see vc_cmd_get_format() */ int vc_cmd_set_format(vc_cmd_h vc_command, int format); + /** * @brief Gets the command format. * @since_tizen 3.0 - * * @remark The default format is #VC_COMMAND_FORMAT_FIXED. - * * @param[in] vc_command The command handle * @param[out] format The command format - * - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #VC_ERROR_NONE Successful * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter * @retval #VC_ERROR_PERMISSION_DENIED Permission denied * @retval #VC_ERROR_NOT_SUPPORTED Not supported feature - * * @see vc_cmd_set_format() */ int vc_cmd_get_format(vc_cmd_h vc_command, int* format); @@ -462,8 +441,10 @@ int vc_cmd_get_format(vc_cmd_h vc_command, int* format); } #endif + /** * @}@} */ + #endif /* __VOICE_CONTROL_COMMAND_H__ */ diff --git a/include/voice_control_common.h b/include/voice_control_common.h index c938da2..a23ccbe 100644 --- a/include/voice_control_common.h +++ b/include/voice_control_common.h @@ -20,158 +20,151 @@ #include + /** * @addtogroup CAPI_UIX_VOICE_CONTROL_MODULE * @{ */ + #ifdef __cplusplus extern "C" { #endif + /** - * @brief Enumerations of error codes. + * @brief Enumeration for error codes. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { - VC_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - VC_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */ - VC_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */ - VC_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - VC_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from service */ - VC_ERROR_RECORDER_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Busy recorder */ - VC_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ - VC_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< VC NOT supported */ - VC_ERROR_INVALID_STATE = TIZEN_ERROR_VOICE_CONTROL | 0x011, /**< Invalid state */ - VC_ERROR_INVALID_LANGUAGE = TIZEN_ERROR_VOICE_CONTROL | 0x012, /**< Invalid language */ - VC_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_VOICE_CONTROL | 0x013, /**< No available engine */ - VC_ERROR_OPERATION_FAILED = TIZEN_ERROR_VOICE_CONTROL | 0x014, /**< Operation failed */ - VC_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ - VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ - VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ - VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In progress to ready (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In progress to recording (Since 3.0) */ - VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In progress to processing (Since 3.0) */ + VC_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + VC_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */ + VC_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */ + VC_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + VC_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from service */ + VC_ERROR_RECORDER_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Busy recorder */ + VC_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + VC_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< VC NOT supported */ + VC_ERROR_INVALID_STATE = TIZEN_ERROR_VOICE_CONTROL | 0x011, /**< Invalid state */ + VC_ERROR_INVALID_LANGUAGE = TIZEN_ERROR_VOICE_CONTROL | 0x012, /**< Invalid language */ + VC_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_VOICE_CONTROL | 0x013, /**< No available engine */ + VC_ERROR_OPERATION_FAILED = TIZEN_ERROR_VOICE_CONTROL | 0x014, /**< Operation failed */ + VC_ERROR_OPERATION_REJECTED = TIZEN_ERROR_VOICE_CONTROL | 0x015, /**< Operation rejected */ + VC_ERROR_ITERATION_END = TIZEN_ERROR_VOICE_CONTROL | 0x016, /**< List reached end */ + VC_ERROR_EMPTY = TIZEN_ERROR_VOICE_CONTROL | 0x017, /**< List empty */ + VC_ERROR_SERVICE_RESET = TIZEN_ERROR_VOICE_CONTROL | 0x018, /**< Service daemon reset (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_VOICE_CONTROL | 0x019, /**< In progress to ready (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_VOICE_CONTROL | 0x020, /**< In progress to recording (Since 3.0) */ + VC_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_VOICE_CONTROL | 0x021 /**< In progress to processing (Since 3.0) */ } vc_error_e; + /** - * @brief Enumerations of result event. + * @brief Enumeration for result event. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { - VC_RESULT_EVENT_RESULT_SUCCESS = 0, /**< Normal result */ - VC_RESULT_EVENT_REJECTED = 1 /**< Rejected result */ + VC_RESULT_EVENT_RESULT_SUCCESS = 0, /**< Normal result */ + VC_RESULT_EVENT_REJECTED = 1 /**< Rejected result */ } vc_result_event_e; + /** - * @brief Enumerations of service state. + * @brief Enumeration for service state. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { - VC_SERVICE_STATE_NONE = 0, /**< 'None' state */ - VC_SERVICE_STATE_READY = 1, /**< 'Ready' state */ - VC_SERVICE_STATE_RECORDING = 2, /**< 'Recording' state */ + VC_SERVICE_STATE_NONE = 0, /**< 'None' state */ + VC_SERVICE_STATE_READY = 1, /**< 'Ready' state */ + VC_SERVICE_STATE_RECORDING = 2, /**< 'Recording' state */ VC_SERVICE_STATE_PROCESSING = 3 /**< 'Processing' state */ } vc_service_state_e; + /** - * @brief Enumerations of client state. + * @brief Enumeration for client state. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif */ typedef enum { - VC_STATE_NONE = 0, /**< 'None' state */ - VC_STATE_INITIALIZED = 1, /**< 'Initialized' state */ - VC_STATE_READY = 2 /**< 'Ready' state */ + VC_STATE_NONE = 0, /**< 'None' state */ + VC_STATE_INITIALIZED = 1, /**< 'Initialized' state */ + VC_STATE_READY = 2 /**< 'Ready' state */ } vc_state_e; /** * @brief Called when client gets the recognition result. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * - * @remarks If the duplicated commands are recognized, the event(e.g. #VC_RESULT_EVENT_REJECTED) of command may be rejected \n - * for selecting command as priority. If you set similar or same commands or the recognized results are multi-results, - * vc_cmd_list has the multi commands. - * + * @remarks If the duplicated commands are recognized, the event(e.g. #VC_RESULT_EVENT_REJECTED) of command may be rejected + * for selecting command as priority. If you set similar or same commands or the recognized results are multi-results, + * vc_cmd_list has the multi commands. * @param[in] event The result event (e.g. #VC_RESULT_EVENT_RESULT_SUCCESS, #VC_RESULT_EVENT_REJECTED) * @param[in] vc_cmd_list The recognized command list * @param[in] result The spoken text * @param[in] user_data The user data passed from the callback registration function - * * @pre An application registers callback function. - * * @see vc_set_result_cb() */ typedef void (*vc_result_cb)(vc_result_event_e event, vc_cmd_list_h vc_cmd_list, const char* result, void *user_data); + /** * @brief Called when default language is changed. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] previous Previous language * @param[in] current Current language * @param[in] user_data The user data passed from the callback registration function - * * @pre An application registers this callback to detect changing mode. - * * @see vc_set_current_language_changed_cb() */ typedef void (*vc_current_language_changed_cb)(const char* previous, const char* current, void* user_data); + /** * @brief Called to retrieve supported language. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * - * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n - * followed by ISO 639-1 for the two-letter language code. \n - * For example, "ko_KR" for Korean, "en_US" for American English. + * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code + * followed by ISO 639-1 for the two-letter language code. + * For example, "ko_KR" for Korean, "en_US" for American English * @param[in] user_data The user data passed from the foreach function - * - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. - * + * @return @c true to continue with the next iteration of the loop, + * @c false to break out of the loop * @pre The function will invoke this callback. */ typedef bool (*vc_supported_language_cb)(const char* language, void* user_data); + /** * @brief Called when the state of voice control client is changed. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] previous A previous state * @param[in] current A current state * @param[in] user_data The user data passed from the callback registration function - * * @pre An application registers this callback to detect changing state. - * * @see vc_set_state_changed_cb() */ typedef void (*vc_state_changed_cb)(vc_state_e previous, vc_state_e current, void* user_data); + /** * @brief Called when the state of voice control service is changed. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] previous A previous state * @param[in] current A current state * @param[in] user_data The user data passed from the callback registration function - * * @pre An application registers this callback to detect changing service state. - * * @see vc_set_service_state_changed_cb() */ typedef void (*vc_service_state_changed_cb)(vc_service_state_e previous, vc_service_state_e current, void* user_data); + /** * @brief Called when error occurred. * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif - * * @param[in] reason The error type (e.g. #VC_ERROR_OUT_OF_MEMORY, #VC_ERROR_TIMED_OUT) * @param[in] user_data The user data passed from the callback registration function - * * @pre An application registers this callback to detect error. - * * @see vc_set_error_cb() */ typedef void (*vc_error_cb)(vc_error_e reason, void *user_data); @@ -181,6 +174,7 @@ typedef void (*vc_error_cb)(vc_error_e reason, void *user_data); } #endif + /** * @}@} */ -- 2.7.4
FUNCTION