From c8aed00af31d6d8afb78e621084101b758637ba6 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 4 Jul 2022 16:55:59 +0900 Subject: [PATCH 01/16] Fix TC issues (ignore ipc error in vce TCs and remove unnecessary codes) Change-Id: I4944efd2ce825fc69ab6dcc86d90bc2b854f8d35 Signed-off-by: sooyeon --- server/vcd_server.c | 2 +- server/vcd_tidl.c | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/server/vcd_server.c b/server/vcd_server.c index f22895f..3939f9c 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1173,7 +1173,7 @@ int vcd_send_feedback_streaming(vce_feedback_event_e event, char* buffer, int le SLOG(LOG_INFO, TAG_VCD, "[Server DEBUG] Engine - Send TTS feedback streaming event(%d), uid(%u), is_mgr_client(%d)", event, g_current_tts_uid, (pid == vcd_client_manager_get_pid() ? true : false)); - if (pid == vcd_client_manager_get_pid()) { + if (VC_INVALID_TTS_UID == pid || pid == vcd_client_manager_get_pid() || -1 == vcd_client_manager_get_pid()) { /* send TTS feedback streaming to manager client */ ret = vcdc_send_feedback_streaming_to_manager(vcd_client_manager_get_pid(), pid, utt_id, event, buffer, len); if (VCD_ERROR_NONE != ret) { diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 631643b..b7709f3 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -594,7 +594,7 @@ static int __vc_request_dialog_cb(rpc_port_stub_vcd_stub_vc_context_h context, i SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d), ret(%d)", pid, disp_text, utt_text, continuous, ret); } - return ret; + return VCD_ERROR_NONE; } static int __vc_is_system_command_valid_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, bool *is_sys_cmd_valid, void *user_data) @@ -2018,13 +2018,7 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, client_tidl_info_s* info = vcd_client_get_tidl_info(pid); if (NULL == info) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); - return VCD_ERROR_INVALID_PARAMETER; - } - - bundle* msg = bundle_create(); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); - return VCD_ERROR_OUT_OF_MEMORY; + return VCD_ERROR_NONE; } SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send feedback streaming to app(%d), utt_id(%d), event(%d), length(%d)", pid, utt_id, event, len); @@ -2037,7 +2031,6 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, rpc_port_stub_vcd_stub_array_char_destroy(arr_char); - bundle_free(msg); return VCD_ERROR_NONE; } @@ -2548,7 +2541,7 @@ int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id pthread_mutex_unlock(&g_mgr_tidl_info_mutex); rpc_port_stub_vcd_mgr_stub_array_char_destroy(streaming_data); bundle_free(msg); - return VCD_ERROR_OPERATION_FAILED; + return VCD_ERROR_NONE; } rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h handle = mgr_tidl_info->send_buffer_cb; -- 2.7.4 From 3c819a707659fab46631a4f1780fb593b9c2cc2c Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 6 Jul 2022 13:56:28 +0900 Subject: [PATCH 02/16] Replace duplicated codes and Remove unnecessary logs Change-Id: I595a15ba1e9b430e6e6f31ab84a491d60f7fc175 Signed-off-by: sooyeon --- client/vc.c | 575 +++++++++++++---------------------------------- client/vc_mgr.c | 556 +++++++++------------------------------------ client/vc_setting_tidl.c | 14 +- client/vc_tidl.c | 74 +++--- client/vc_widget.c | 294 ++++++------------------ common/vc_main.h | 11 +- server/vcd_tidl.c | 76 +++---- 7 files changed, 411 insertions(+), 1189 deletions(-) diff --git a/client/vc.c b/client/vc.c index fecde6a..1b6d87a 100644 --- a/client/vc.c +++ b/client/vc.c @@ -397,7 +397,6 @@ int vc_initialize(void) SLOG(LOG_DEBUG, TAG_VCC, "[Success] pid(%d)", g_vc->handle); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_NONE; } @@ -690,15 +689,10 @@ int vc_prepare(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'CREATED'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); ecore_thread_run(__start_prepare_thread, __end_prepare_thread, NULL, NULL); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_NONE; } @@ -723,23 +717,14 @@ int vc_prepare_sync(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'INITIALIZED'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); int cnt = 0; while (EINA_TRUE == __vc_connect_daemon(NULL) && VC_CONNECTION_RETRY_COUNT > cnt) { cnt++; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - if (VC_CONNECTION_RETRY_COUNT == cnt) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to connect daemon"); - return VC_ERROR_OPERATION_FAILED; - } + RETVM_IF(VC_CONNECTION_RETRY_COUNT == cnt, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Fail to connect daemon"); return VC_ERROR_NONE; } @@ -759,23 +744,18 @@ int vc_unprepare(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); __vc_internal_unprepare(); vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unprepare DONE"); return VC_ERROR_NONE; } @@ -789,13 +769,7 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language"); - - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -804,6 +778,9 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user return VC_ERROR_INVALID_STATE; } + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language"); + + int ret = -1; ret = vc_config_mgr_get_language_list(callback, user_data); if (0 != ret) { @@ -811,7 +788,7 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get languages : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language DONE"); return VC_ERROR_NONE; } @@ -826,13 +803,7 @@ int vc_get_current_language(char** language) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language"); - - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -841,6 +812,9 @@ int vc_get_current_language(char** language) return VC_ERROR_INVALID_STATE; } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language"); + int ret = -1; ret = vc_config_mgr_get_default_language(language); if (0 != ret) { @@ -848,7 +822,7 @@ int vc_get_current_language(char** language) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get current languages : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language DONE"); return ret; } @@ -862,12 +836,7 @@ int vc_get_state(vc_state_e* state) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get State"); - - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (0 != vc_client_get_client_state(g_vc, &temp)) { @@ -876,6 +845,9 @@ int vc_get_state(vc_state_e* state) return VC_ERROR_INVALID_STATE; } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get State"); + *state = temp; switch (*state) { @@ -887,7 +859,7 @@ int vc_get_state(vc_state_e* state) //LCOV_EXCL_STOP } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get State DONE"); return VC_ERROR_NONE; } @@ -901,25 +873,15 @@ int vc_get_service_state(vc_service_state_e* state) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State"); - - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (0 != vc_client_get_client_state(g_vc, &temp)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } - if (VC_STATE_READY != temp) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != temp, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", temp); /* get service state */ vc_service_state_e service_state; @@ -928,6 +890,9 @@ int vc_get_service_state(vc_service_state_e* state) return VC_ERROR_OPERATION_FAILED; } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State"); + *state = service_state; switch (*state) { @@ -940,7 +905,7 @@ int vc_get_service_state(vc_service_state_e* state) //LCOV_EXCL_STOP } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Service State DONE"); return VC_ERROR_NONE; } @@ -954,36 +919,25 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get system command list"); - - if (NULL == vc_sys_cmd_list) { - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_sys_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); *vc_sys_cmd_list = NULL; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); + + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get system command list"); bool is_sys_cmd_valid = false; int count = 0; @@ -1050,7 +1004,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) return VC_ERROR_NONE; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get system command list DONE"); return ret; } @@ -1106,7 +1060,7 @@ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) SLOG(LOG_ERROR, TAG_VCC, "[DEBUG] Format(%d) support(%s)", format, *support ? "true" : "false"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Is command format supported DONE"); return VC_ERROR_NONE; } @@ -1171,6 +1125,40 @@ static int __vc_get_invocation_name(char** invocation_name) return VC_ERROR_NONE; } +void __set_command(vc_h vc, vc_cmd_type_e type) +{ + int ret = -1; + int count = 0; + bool is_prepared = false; + do { + ret = vc_tidl_request_set_command(vc->handle, type); + if (0 != ret) { + //LCOV_EXCL_START + if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { + vc_client_set_client_state(vc, VC_STATE_INITIALIZED); + if (0 == vc_prepare_sync()) { + is_prepared = true; + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); + } + } else if (VC_ERROR_TIMED_OUT != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set command to daemon : %s", __vc_get_error_code(ret)); + break; + } else { + SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request set command : %s", __vc_get_error_code(ret)); + usleep(10000); + count++; + if (VC_RETRY_COUNT == count) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); + break; + } + } + //LCOV_EXCL_STOP + } + } while (0 != ret); + + return; +} + int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) { if (0 != __vc_get_feature_enabled()) { @@ -1180,12 +1168,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list"); - - if (NULL == vc_cmd_list) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1195,26 +1178,20 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); + + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list"); /* check type */ if ((VC_COMMAND_TYPE_FOREGROUND != type) && (VC_COMMAND_TYPE_BACKGROUND != type)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command type: input type is %d", type); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_PARAMETER; } vc_cmd_list_s* list = NULL; list = (vc_cmd_list_s*)vc_cmd_list; - - if (NULL == list->list) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command list"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == list->list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Invalid command list"); int ret = 0; char* invocation_name = NULL; @@ -1234,33 +1211,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save command list : %s", __vc_get_error_code(ret)); } else { - int count = 0; - bool is_prepared = false; - do { - ret = vc_tidl_request_set_command(g_vc->handle, (vc_cmd_type_e)type); - if (0 != ret) { - //LCOV_EXCL_START - if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); - if (0 == vc_prepare_sync()) { - is_prepared = true; - SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); - } - } else if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set command to daemon : %s", __vc_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request set command : %s", __vc_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); - break; - } - } - //LCOV_EXCL_STOP - } - } while (0 != ret); + __set_command(g_vc, (vc_cmd_type_e)type); } FREE(invocation_name); @@ -1268,7 +1219,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) if (VC_COMMAND_TYPE_BACKGROUND == type) g_backup = true; - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list DONE"); return ret; } @@ -1282,21 +1233,17 @@ int vc_unset_command_list(int type) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list"); - vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); + + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list"); int count = 0; int ret = -1; @@ -1333,7 +1280,7 @@ int vc_unset_command_list(int type) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] cmd_type(%d), Fail to delete command list : %s", type, __vc_get_error_code(ret)); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list DONE"); return ret; } @@ -1348,8 +1295,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file"); - vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); @@ -1358,11 +1303,7 @@ int vc_set_command_list_from_file(const char* file_path, int type) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* check type */ if ((VC_COMMAND_TYPE_FOREGROUND != type) && (VC_COMMAND_TYPE_BACKGROUND != type)) { @@ -1371,6 +1312,9 @@ int vc_set_command_list_from_file(const char* file_path, int type) return VC_ERROR_INVALID_PARAMETER; } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file"); + int ret = 0; char* invocation_name = NULL; if (VC_COMMAND_TYPE_BACKGROUND == type) { @@ -1389,36 +1333,12 @@ int vc_set_command_list_from_file(const char* file_path, int type) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set commands from file : %s", __vc_get_error_code(ret)); } else { - int count = 0; - bool is_prepared = false; - do { - ret = vc_tidl_request_set_command(g_vc->handle, (vc_cmd_type_e)type); - if (0 != ret) { - if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); - if (0 == vc_prepare_sync()) { - is_prepared = true; - SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); - } - } else if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request set command to daemon : %s", __vc_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] retry request set command : %s", __vc_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request"); - break; - } - } - } - } while (0 != ret); + __set_command(g_vc, (vc_cmd_type_e)type); } FREE(invocation_name); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file DONE"); return ret; } //LCOV_EXCL_STOP @@ -1792,10 +1712,7 @@ static Eina_Bool __vc_notify_result(void *data) vc_client_get_result_cb(g_vc, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Client result callback is NULL"); - return EINA_FALSE; - } + RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCC, "[ERROR] Client result callback is NULL"); if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create command list"); @@ -1840,8 +1757,6 @@ int vc_get_result(vc_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result"); - vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); @@ -1850,16 +1765,12 @@ int vc_get_result(vc_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); + + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client result callback is NULL"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Client result callback is NULL"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_PARAMETER; - } + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result"); char* temp_text = NULL; int event = 0; @@ -1890,7 +1801,7 @@ int vc_get_result(vc_result_cb callback, void* user_data) /* Release result */ FREE(temp_text); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get result DONE"); return VC_ERROR_NONE; } @@ -1904,8 +1815,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client result callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1914,10 +1824,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_result_cb(g_vc, callback, user_data); @@ -1940,10 +1847,7 @@ int vc_unset_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_result_cb(g_vc, NULL, NULL); @@ -2003,8 +1907,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client service state changed callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2013,10 +1916,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_service_state_changed_cb(g_vc, callback, user_data); @@ -2039,10 +1939,7 @@ int vc_unset_service_state_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_service_state_changed_cb(g_vc, NULL, NULL); @@ -2058,8 +1955,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (callback == NULL) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client state changed callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2068,10 +1964,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_state_changed_cb(g_vc, callback, user_data); @@ -2094,10 +1987,7 @@ int vc_unset_state_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_state_changed_cb(g_vc, NULL, NULL); @@ -2113,8 +2003,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client current language changed callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2123,10 +2012,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set current language changed : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_current_lang_changed_cb(g_vc, callback, user_data); @@ -2149,10 +2035,7 @@ int vc_unset_current_language_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset current language changed : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_current_lang_changed_cb(g_vc, NULL, NULL); @@ -2168,8 +2051,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client error callback is NULL"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2178,10 +2060,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_error_cb(g_vc, callback, user_data); @@ -2204,10 +2083,7 @@ int vc_unset_error_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_error_cb(g_vc, NULL, NULL); @@ -2234,11 +2110,7 @@ int vc_set_invocation_name(const char* name) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); ret = vc_client_set_invocation_name(g_vc, name); if (0 != ret) { @@ -2253,7 +2125,6 @@ int vc_set_server_dialog(const char* app_id, const char* credential) vc_state_e state; int ret = -1; - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set server dialog, pid(%d), app_id(%s)", getpid(), app_id); if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } @@ -2261,32 +2132,23 @@ int vc_set_server_dialog(const char* app_id, const char* credential) return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == credential) { - SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Credential is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == credential, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Credential is NULL"); if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); + + + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set server dialog, pid(%d), app_id(%s)", getpid(), app_id); char* tmp_appid = NULL; if (NULL == app_id) { @@ -2331,7 +2193,7 @@ int vc_set_server_dialog(const char* app_id, const char* credential) FREE(tmp_appid); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set server dialog DONE"); return ret; } @@ -2340,8 +2202,8 @@ int vc_unset_server_dialog(const char* app_id) { vc_state_e state; int ret = -1; + char* tmp_appid = NULL; - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Unset server dialog, pid(%d), app_id(%s)", getpid(), app_id); if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } @@ -2351,27 +2213,18 @@ int vc_unset_server_dialog(const char* app_id) if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); + - char* tmp_appid = NULL; if (NULL == app_id) { ret = app_manager_get_app_id(getpid(), &tmp_appid); if (0 != ret || NULL == tmp_appid) { @@ -2384,7 +2237,7 @@ int vc_unset_server_dialog(const char* app_id) } int pid = getpid(); - SLOG(LOG_DEBUG, TAG_VCC, "Unset server dialog : pid(%d), app_id(%s)", pid, tmp_appid); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Unset server dialog : pid(%d), app_id(%s)", pid, tmp_appid); int count = 0; bool is_prepared = false; @@ -2416,7 +2269,7 @@ int vc_unset_server_dialog(const char* app_id) FREE(tmp_appid); FREE(credential); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Unset server dialog DONE"); return ret; } @@ -2426,7 +2279,6 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta { vc_state_e state; - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog"); if (0 != __vc_get_feature_enabled()) { return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE } @@ -2436,34 +2288,25 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'READY'"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); //LCOV_EXCL_LINE - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start); int ret = vc_tidl_request_request_dialog(getpid(), disp_text, utt_text, auto_start); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request dialog, ret(%d)", ret); return VC_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog DONE"); return VC_ERROR_NONE; } @@ -2478,11 +2321,7 @@ int vc_auth_enable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_STATE_READY != state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Current state(%d) is not 'READY'", state); /* check already authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; @@ -2490,11 +2329,7 @@ int vc_auth_enable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_AUTH_STATE_NONE != auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Already authority enabled"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_AUTH_STATE_NONE != auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Already authority enabled"); /* request authority */ int mgr_pid = -1; @@ -2541,11 +2376,7 @@ int vc_auth_disable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_STATE_READY != state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Current state(%d) is not 'READY'", state); /* check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; @@ -2553,11 +2384,7 @@ int vc_auth_disable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_AUTH_STATE_NONE == auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] No authority"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_AUTH_STATE_NONE == auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] No authority"); if (0 != vc_auth_unset_state_changed_cb()) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to unset state changed cb"); @@ -2596,11 +2423,7 @@ int vc_auth_get_state(vc_auth_state_e* state) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_STATE_READY != vc_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != vc_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Current state(%d) is not 'READY'", vc_state); /* get authority */ vc_auth_state_e temp = VC_AUTH_STATE_NONE; @@ -2630,11 +2453,7 @@ int vc_auth_set_state_changed_cb(vc_auth_state_changed_cb callback, void* user_d SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_AUTH_STATE_NONE == auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Auth is not enabled"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_AUTH_STATE_NONE == auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Auth is not enabled"); /* set cb into handle */ if (0 != vc_client_set_auth_state_changed_cb(g_vc, callback, user_data)) { @@ -2655,11 +2474,7 @@ int vc_auth_unset_state_changed_cb(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } - - if (VC_AUTH_STATE_NONE == auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Auto is not enabled"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_AUTH_STATE_NONE == auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Auth is not enabled"); /* unset cb from handle */ if (0 != vc_client_unset_auth_state_changed_cb(g_vc)) { @@ -2684,20 +2499,12 @@ int vc_auth_start(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: client state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); /* Check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; @@ -2705,11 +2512,7 @@ int vc_auth_start(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } - - if (VC_AUTH_STATE_VALID != auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not auth valid"); - return VC_ERROR_OPERATION_FAILED; - } + RETVM_IF(VC_AUTH_STATE_VALID != auth_state, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not auth valid"); /* get mgr_pid */ int mgr_pid = -1; @@ -2765,20 +2568,12 @@ int vc_auth_stop(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: client state is not 'Ready'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_RECORDING) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'RECORDING'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_RECORDING, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'RECORDING'", service_state); /* Check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; @@ -2786,11 +2581,7 @@ int vc_auth_stop(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } - - if (VC_AUTH_STATE_VALID != auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not auth valid"); - return VC_ERROR_OPERATION_FAILED; - } + RETVM_IF(VC_AUTH_STATE_VALID != auth_state, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not auth valid"); /* get mgr_pid */ int mgr_pid = -1; @@ -2846,11 +2637,7 @@ int vc_auth_cancel(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state is not 'Ready'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; @@ -2867,11 +2654,7 @@ int vc_auth_cancel(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } - - if (VC_AUTH_STATE_VALID != auth_state) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not auth valid"); - return VC_ERROR_OPERATION_FAILED; - } + RETVM_IF(VC_AUTH_STATE_VALID != auth_state, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not auth valid"); /* get mgr_pid */ int mgr_pid = -1; @@ -2922,10 +2705,7 @@ static void __start_tts_streaming_thread(void* data, Ecore_Thread* thread) void* user_data = NULL; vc_client_get_tts_streaming_cb(g_vc, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] tts streaming callback is null"); - return; - } + RETM_IF(NULL == callback, TAG_VCC, "[WARNING] tts streaming callback is null"); while (1) { int ret = -1; @@ -2987,10 +2767,7 @@ int __vc_cb_tts_streaming(int utt_id, vc_tts_event_e event, char* buffer, int le /* add tts data */ vc_tts_data_s* temp_tts_data = NULL; temp_tts_data = (vc_tts_data_s*)calloc(1, sizeof(vc_tts_data_s)); - if (NULL == temp_tts_data) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Out of memory"); - return VC_ERROR_OUT_OF_MEMORY; - } + RETVM_IF(NULL == temp_tts_data, VC_ERROR_OUT_OF_MEMORY, TAG_VCC, "[ERROR] Out of memory"); temp_tts_data->data = NULL; temp_tts_data->data_size = 0; @@ -3050,20 +2827,12 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ tts request, pid(%d), text(%s), language(%s), to_vc_manager(%d)", pid, text, language, to_vc_manager); @@ -3120,20 +2889,12 @@ int vc_tts_cancel(int utt_id) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ tts cancel, pid(%d), utt_id(%d)", pid, utt_id); @@ -3195,20 +2956,12 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); /* Check service state */ vc_service_state_e service_state = -1; vc_client_get_service_state(g_vc, &service_state); - if (service_state != VC_SERVICE_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ get tts audio format, pid(%d)", pid); @@ -3262,10 +3015,7 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set tts streaming callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_tts_streaming_cb(g_vc, callback, user_data); @@ -3288,10 +3038,7 @@ int vc_tts_unset_streaming_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset tts streaming callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_tts_streaming_cb(g_vc, NULL, NULL); @@ -3304,10 +3051,7 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) void* user_data = NULL; vc_client_get_tts_utterance_status_cb(g_vc, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_WARN, TAG_VCC, "[WARNING] Utterance status callback is null"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Utterance status callback is null"); SLOG(LOG_DEBUG, TAG_VCC, "Utterance status callback is called"); vc_client_use_callback(g_vc); @@ -3326,8 +3070,7 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Utterance status callback is null"); vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -3336,10 +3079,7 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set tts utterance status callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_tts_utterance_status_cb(g_vc, callback, user_data); @@ -3362,10 +3102,7 @@ int vc_tts_unset_utterance_status_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset tts utterance status callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_client_set_tts_utterance_status_cb(g_vc, NULL, NULL); diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 4fe673d..061f0be 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -583,11 +583,7 @@ int vc_mgr_prepare(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'CREATED'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); if (NULL == g_send_hello_timer) { g_tidl_send_hello_count = 0; @@ -625,11 +621,7 @@ int vc_mgr_unprepare(void) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); __vc_mgr_internal_unprepare(); @@ -654,11 +646,7 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -690,10 +678,7 @@ int vc_mgr_get_current_language(char** language) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -726,10 +711,7 @@ int vc_mgr_get_state(vc_state_e* state) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (NULL == g_vc_m) { @@ -767,10 +749,7 @@ int vc_mgr_get_service_state(vc_service_state_e* state) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e client_state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &client_state)) { @@ -827,11 +806,7 @@ int vc_mgr_set_demandable_client_rule(const char* rule) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); int ret = -1; ret = vc_info_parser_set_demandable_client(rule); @@ -888,10 +863,7 @@ int vc_mgr_is_command_format_supported(int format, bool* support) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == support) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter, support is NULL ptr"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == support, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -948,20 +920,12 @@ int vc_mgr_enable_command_type(int cmd_type) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret; @@ -1003,20 +967,12 @@ int vc_mgr_disable_command_type(int cmd_type) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret; @@ -1053,34 +1009,20 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - if (NULL == vc_cmd_list) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); vc_cmd_list_s* list = NULL; list = (vc_cmd_list_s*)vc_cmd_list; SLOG(LOG_INFO, TAG_VCM, "[List] (%p) (%p)", list, list->list); - if (NULL == list->list) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid command list"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == list->list, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input command list"); int i; int ret; @@ -1134,10 +1076,7 @@ int vc_mgr_unset_command_list(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); int ret = -1; @@ -1172,12 +1111,8 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == file_path) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter!!"); - return VC_ERROR_INVALID_PARAMETER; - } else { - SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); - } + RETVM_IF(NULL == file_path, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); + SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); /* check type */ if (VC_COMMAND_TYPE_FOREGROUND > type || VC_COMMAND_TYPE_EXCLUSIVE < type) { @@ -1193,18 +1128,12 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = vc_cmd_parser_delete_file(getpid(), type); if (0 != ret) @@ -1238,12 +1167,8 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == file_path) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter!! file_path is NULL ptr"); - return VC_ERROR_INVALID_PARAMETER; - } else { - SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); - } + RETVM_IF(NULL == file_path, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); + SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1252,18 +1177,12 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); /* Only support to set background commands for preloaded application */ int ret = vc_json_set_commands_from_file(file_path, VC_COMMAND_TYPE_BACKGROUND, NULL); @@ -1300,20 +1219,12 @@ int vc_mgr_set_audio_type(const char* audio_id) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; /* Request */ @@ -1344,10 +1255,7 @@ int vc_mgr_get_audio_type(char** audio_id) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == audio_id) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == audio_id, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1357,20 +1265,12 @@ int vc_mgr_get_audio_type(char** audio_id) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); char* temp = NULL; @@ -1417,31 +1317,18 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) 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, "@@@"); 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); - if (NULL == vc_cmd_list) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid Parameter"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid Parameter"); vc_cmd_list_h temp_list = NULL; if (0 != vc_cmd_list_create(&temp_list)) { @@ -1615,20 +1502,12 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); vc_mgr_client_set_recognition_mode(g_vc_m, mode); return VC_ERROR_NONE; @@ -1647,10 +1526,7 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) int ret = -1; - if (NULL == mode) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter, mode is NULL ptr"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == mode, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter, mode is NULL ptr"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1682,10 +1558,7 @@ int vc_mgr_set_private_data(const char* key, const char* data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == key) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == key, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1695,20 +1568,12 @@ int vc_mgr_set_private_data(const char* key, const char* data) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; ret = vc_mgr_tidl_request_set_private_data(g_vc_m->handle, key, data); @@ -1750,20 +1615,12 @@ int vc_mgr_get_private_data(const char* key, char** data) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; char* temp = NULL; @@ -1802,10 +1659,7 @@ int vc_mgr_set_domain(const char* domain) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == domain) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == domain, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1815,20 +1669,12 @@ int vc_mgr_set_domain(const char* domain) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; @@ -1862,10 +1708,7 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) return VC_ERROR_INVALID_PARAMETER; } - if (NULL == send_event) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == send_event, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1875,20 +1718,12 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; ret = vc_mgr_tidl_request_do_action(g_vc_m->handle, type, send_event); @@ -1935,20 +1770,12 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = -1; ret = vc_mgr_tidl_send_specific_engine_request(g_vc_m->handle, engine_app_id, event, request); @@ -1984,20 +1811,12 @@ int vc_mgr_start(bool exclusive_command_option) } /* 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); /* Check internal state for async */ vc_internal_state_e internal_state = -1; @@ -2066,20 +1885,12 @@ int vc_mgr_stop(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: client state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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_RECORDING) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'RECORDING'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_RECORDING, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'RECORDING'", service_state); /* Check internal state for async */ vc_internal_state_e internal_state = -1; @@ -2132,20 +1943,12 @@ int vc_mgr_cancel(void) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: client state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", 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_NONE) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state == VC_SERVICE_STATE_NONE, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state is NONE"); vc_internal_state_e internal_state = -1; vc_mgr_client_get_internal_state(g_vc_m, &internal_state); @@ -2228,10 +2031,7 @@ int vc_mgr_get_recording_volume(float* volume) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == volume) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == volume, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_service_state_e service_state = -1; if (0 != vc_mgr_client_get_service_state(g_vc_m, &service_state)) { @@ -2240,10 +2040,7 @@ int vc_mgr_get_recording_volume(float* volume) } /* check state */ - if (VC_SERVICE_STATE_RECORDING != service_state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Service state is not 'RECORDING'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SERVICE_STATE_RECORDING != service_state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Service state is not 'RECORDING'"); *volume = g_volume_db; @@ -2361,10 +2158,7 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) void* all_user_data = NULL; vc_mgr_client_get_all_result_cb(g_vc_m, &all_callback, &all_user_data); - if (NULL == all_callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] All result callback is NULL"); - return; - } + RETM_IF(NULL == all_callback, TAG_VCM, "[ERROR] All result callback is NULL"); if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create command list"); @@ -2392,10 +2186,7 @@ static void __vc_mgr_notify_all_result(vc_result_type_e result_type) void* user_data = NULL; vc_mgr_client_get_result_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client result callback is NULL"); - return; - } + RETM_IF(NULL == callback, TAG_VCM, "[ERROR] Client result callback is NULL"); vc_mgr_client_use_callback(g_vc_m); callback(event, vc_cmd_list, temp_text, user_data); @@ -2469,10 +2260,7 @@ static Eina_Bool __vc_mgr_notify_result(void *data) void* user_data = NULL; vc_mgr_client_get_result_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client result callback is NULL"); - return EINA_FALSE; - } + RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCM, "[ERROR] Client result callback is NULL"); if (0 != vc_cmd_list_create(&vc_cmd_list)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create command list"); @@ -2519,10 +2307,7 @@ void __vc_mgr_cb_pre_result(vc_pre_result_event_e event, const char* pre_result) void* user_data = NULL; vc_mgr_client_get_pre_result_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client pre result callback is NULL"); - return; - } + RETM_IF(NULL == callback, TAG_VCM, "[ERROR] Client pre result callback is NULL"); vc_mgr_client_use_callback(g_vc_m); callback(event, pre_result, user_data); @@ -2544,10 +2329,7 @@ static Eina_Bool __vc_mgr_speech_detected(void *data) void* user_data = NULL; vc_mgr_client_get_speech_detected_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client speech detected callback is NULL"); - return EINA_FALSE; - } + RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCM, "[ERROR] Client speech detected callback is NULL"); vc_mgr_client_use_callback(g_vc_m); callback(user_data); @@ -2575,8 +2357,7 @@ int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2585,10 +2366,7 @@ int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_all_result_cb(g_vc_m, callback, user_data); @@ -2615,10 +2393,7 @@ int vc_mgr_unset_all_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_all_result_cb(g_vc_m, NULL, NULL); @@ -2636,8 +2411,7 @@ int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2646,10 +2420,7 @@ int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_result_cb(g_vc_m, callback, user_data); @@ -2674,10 +2445,7 @@ int vc_mgr_unset_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_result_cb(g_vc_m, NULL, NULL); @@ -2695,8 +2463,7 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2705,10 +2472,7 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set pre result callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_pre_result_cb(g_vc_m, callback, user_data); @@ -2733,10 +2497,7 @@ int vc_mgr_unset_pre_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset pre result callback : Current state is not 'Initialize'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_pre_result_cb(g_vc_m, NULL, NULL); @@ -2763,10 +2524,7 @@ int vc_mgr_get_error_message(char** err_msg) return VC_ERROR_INVALID_STATE; } - if (NULL == err_msg) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == err_msg, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); if (false == g_err_callback_status) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Not in error callback"); @@ -2895,10 +2653,7 @@ int vc_mgr_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_state_changed_cb(g_vc_m, callback, user_data); @@ -2924,10 +2679,7 @@ int vc_mgr_unset_state_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_state_changed_cb(g_vc_m, NULL, NULL); @@ -3002,10 +2754,7 @@ int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, vo } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_service_state_changed_cb(g_vc_m, callback, user_data); @@ -3031,10 +2780,7 @@ int vc_mgr_unset_service_state_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_service_state_changed_cb(g_vc_m, NULL, NULL); return VC_ERROR_NONE; @@ -3061,10 +2807,7 @@ int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set speech detected callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_speech_detected_cb(g_vc_m, callback, user_data); @@ -3090,10 +2833,7 @@ int vc_mgr_unset_speech_detected_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset state changed callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_speech_detected_cb(g_vc_m, NULL, NULL); return VC_ERROR_NONE; @@ -3110,8 +2850,7 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3120,10 +2859,7 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set current language changed : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_current_lang_changed_cb(g_vc_m, callback, user_data); @@ -3149,10 +2885,7 @@ int vc_mgr_unset_current_language_changed_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset current language changed : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_current_lang_changed_cb(g_vc_m, NULL, NULL); @@ -3170,8 +2903,7 @@ int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3180,10 +2912,7 @@ int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_error_cb(g_vc_m, callback, user_data); @@ -3208,10 +2937,7 @@ int vc_mgr_unset_error_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_error_cb(g_vc_m, NULL, NULL); @@ -3307,10 +3033,7 @@ int __vc_mgr_cb_feedback_streaming(int pid, int utt_id, vc_feedback_event_e even /* add feedback data */ vc_feedback_data_s* temp_feedback_data = NULL; temp_feedback_data = (vc_feedback_data_s*)calloc(1, sizeof(vc_feedback_data_s)); - if (NULL == temp_feedback_data) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Out of memory"); - return VC_ERROR_OUT_OF_MEMORY; - } + RETVM_IF(NULL == temp_feedback_data, VC_ERROR_OUT_OF_MEMORY, TAG_VCM, "[ERROR] Out of memory"); SLOG(LOG_INFO, TAG_VCM, "[INFO] feedback streaming before queing"); temp_feedback_data->data = NULL; @@ -3367,8 +3090,7 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3377,10 +3099,7 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_dialog_request_cb(g_vc_m, callback, user_data); @@ -3405,10 +3124,7 @@ int vc_mgr_unset_dialog_request_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset error callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_dialog_request_cb(g_vc_m, NULL, NULL); @@ -3426,8 +3142,7 @@ int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* us return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3436,10 +3151,7 @@ int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* us } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set private data set callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Set private data set callback : Current state is not 'Initialized'"); vc_mgr_client_set_private_data_set_cb(g_vc_m, callback, user_data); @@ -3464,10 +3176,7 @@ int vc_mgr_unset_private_data_set_cb(void) } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset private data set callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Unset private data set callback : Current state is not 'Initialized'"); vc_mgr_client_set_private_data_set_cb(g_vc_m, NULL, NULL); @@ -3485,8 +3194,7 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3495,10 +3203,7 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba } /* check state*/ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set private data requested callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Set private data requested callback : Current state is not 'Initialized'"); vc_mgr_client_set_private_data_requested_cb(g_vc_m, callback, user_data); @@ -3523,10 +3228,7 @@ int vc_mgr_unset_private_data_requested_cb(void) } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset private data requested callback : Current state is not 'Initialized'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Unset private data requested callback : Current state is not 'Initialized'"); vc_mgr_client_set_private_data_requested_cb(g_vc_m, NULL, NULL); @@ -3726,8 +3428,7 @@ int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callba return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3736,10 +3437,7 @@ int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callba } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set specific engine result callback : Current state(%d) is not 'Initialized'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_specific_engine_result_cb(g_vc_m, callback, user_data); @@ -3758,10 +3456,7 @@ int vc_mgr_unset_specific_engine_result_cb(void) } /* check state */ - if (state != VC_STATE_INITIALIZED) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset specific engine result callback : Current state(%d) is not 'Initialize'", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); vc_mgr_client_set_specific_engine_result_cb(g_vc_m, NULL, NULL); @@ -3774,10 +3469,7 @@ void __vc_mgr_cb_specific_engine_result(const char* engine_app_id, const char* e void* user_data = NULL; vc_mgr_client_get_specific_engine_result_cb(g_vc_m, &callback, &user_data); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Client specific engine result callback is NULL"); - return; - } + RETM_IF(NULL == callback, TAG_VCM, "[ERROR] Client specific engine result callback is NULL"); vc_mgr_client_use_callback(g_vc_m); callback(engine_app_id, event, result, user_data); @@ -3800,8 +3492,7 @@ int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3810,10 +3501,7 @@ int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Set feedback audio format callback : Current state is not 'Initialized' (%d)", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Set feedback audio format callback : Current state is not 'Initialized'"); vc_mgr_client_set_feedback_audio_format_cb(g_vc_m, callback, user_data); @@ -3841,10 +3529,7 @@ int vc_mgr_unset_feedback_audio_format_cb() } /* check state */ - if (VC_STATE_INITIALIZED != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Unset feedback audio format callback : Current state is not 'Initialized' (%d)", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_INITIALIZED != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Unset feedback audio format callback : Current state is not 'Initialized'"); vc_mgr_client_set_feedback_audio_format_cb(g_vc_m, NULL, NULL); @@ -3865,8 +3550,7 @@ int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); pthread_mutex_lock(&g_feedback_streaming_cb_mutex); @@ -3943,8 +3627,7 @@ int vc_mgr_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* us return VC_ERROR_PERMISSION_DENIED; } - if (NULL == callback) - return VC_ERROR_INVALID_PARAMETER; + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); pthread_mutex_lock(&g_vc_tts_streaming_cb_mutex); @@ -4141,10 +3824,7 @@ int vc_mgr_start_feedback(void) } /* check state */ - if (VC_STATE_READY != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Start feedback : Current state is not 'Ready' (%d)", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Start feedback : Current state is not 'Ready' (%d)", state); #if 1 bool is_exist = ecore_thread_check(g_feedback_thread); @@ -4184,10 +3864,7 @@ int vc_mgr_stop_feedback(void) } /* check state */ - if (VC_STATE_READY != state) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state); #if 1 int ret = -1; @@ -4245,20 +3922,12 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", 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(%d) is not 'READY'", service_state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); int ret = vc_mgr_tidl_send_utterance_status(pid, utt_id, utt_status); if (0 != ret) @@ -4320,10 +3989,7 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* return VC_ERROR_INVALID_PARAMETER; } - if (NULL == buffer) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] buffer is invalid parameter"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == buffer, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state = VC_STATE_NONE; int ret = vc_mgr_client_get_client_state(g_vc_m, &state); @@ -4333,11 +3999,7 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* return VC_ERROR_INVALID_STATE; } - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); vc_service_state_e service_state = VC_SERVICE_STATE_NONE; ret = vc_mgr_client_get_service_state(g_vc_m, &service_state); diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index 42c8017..314daf9 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -81,7 +81,7 @@ static void __on_connected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* unsigned int pid = (uintptr_t)user_data; vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connected = true; info->connection_requesting = false; @@ -95,7 +95,7 @@ static void __on_disconnected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, vo unsigned int pid = (uintptr_t)user_data; vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connected = false; info->connection_requesting = false; @@ -110,7 +110,7 @@ static void __on_rejected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* unsigned int pid = (uintptr_t)user_data; vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connection_requesting = false; info->register_notify_callback_invoked = false; @@ -243,7 +243,7 @@ int vc_setting_tidl_close_connection() int pid = getpid(); vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); if (0 != rpc_port_proxy_vc_setting_proxy_vc_setting_destroy(info->rpc_h)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect"); @@ -265,7 +265,7 @@ int vc_setting_tidl_request_hello() int pid = getpid(); vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); if (!info->connected) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()"); @@ -298,8 +298,8 @@ int vc_setting_tidl_request_set_language(int pid, const char* language) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_setting_tidl_request_set_language"); vc_setting_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_setting_proxy_vc_setting_invoke_set_language(info->rpc_h, pid, language); if (RPC_PORT_ERROR_NONE != ret) { diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 61ea8ea..33d91a5 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -90,7 +90,7 @@ static void __on_connected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) unsigned int pid = (uintptr_t)user_data; vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connected = true; info->connection_requesting = false; @@ -104,7 +104,7 @@ static void __on_disconnected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) unsigned int pid = (uintptr_t)user_data; vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connected = false; info->connection_requesting = false; @@ -119,7 +119,7 @@ static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) unsigned int pid = (uintptr_t)user_data; vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETM_IF(NULL == info, "[ERROR] Fail to get tidl info"); + RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info"); info->connection_requesting = false; info->register_notify_callback_invoked = false; @@ -378,7 +378,7 @@ int vc_tidl_close_connection() int pid = getpid(); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); if (0 != rpc_port_proxy_vc_proxy_vc_destroy(info->rpc_h)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect"); @@ -400,7 +400,7 @@ int vc_tidl_request_hello() int pid = getpid(); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); if (!info->connected) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()"); @@ -433,8 +433,8 @@ int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* d SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_initialize"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -452,8 +452,8 @@ int vc_tidl_request_finalize(int pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_finalize"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_finalize(info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -471,8 +471,8 @@ int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_command"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type); if (RPC_PORT_ERROR_NONE != ret) { @@ -490,8 +490,8 @@ int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_unset_command"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type); if (RPC_PORT_ERROR_NONE != ret) { @@ -510,8 +510,8 @@ int vc_tidl_request_set_foreground(int pid, bool value) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_foreground"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value); if (RPC_PORT_ERROR_NONE != ret) { @@ -529,8 +529,8 @@ int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* c SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_server_dialog"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential); if (RPC_PORT_ERROR_NONE != ret) { @@ -549,8 +549,8 @@ int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* u SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_dialog"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous); if (RPC_PORT_ERROR_NONE != ret) { @@ -568,8 +568,8 @@ int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_is_system_command_valid"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid); if (RPC_PORT_ERROR_NONE != ret) { @@ -588,8 +588,8 @@ int vc_tidl_request_auth_enable(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_enable"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -607,8 +607,8 @@ int vc_tidl_request_auth_disable(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_disable"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -626,8 +626,8 @@ int vc_tidl_request_auth_start(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_start"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -645,8 +645,8 @@ int vc_tidl_request_auth_stop(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_stop"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -664,8 +664,8 @@ int vc_tidl_request_auth_cancel(int pid, int mgr_pid) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_cancel"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { @@ -684,8 +684,8 @@ int vc_tidl_request_request_tts(int pid, const char* text, const char* language, SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_tts"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); if (VC_ERROR_NONE != __invoke_register_feedback_callback(pid, info)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register feedback callback"); @@ -708,8 +708,8 @@ int vc_tidl_request_cancel_tts(int pid, int utt_id) SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_cancel_tts"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id); if (RPC_PORT_ERROR_NONE != ret) { @@ -727,8 +727,8 @@ int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_get_tts_audio_format"); vc_tidl_info_s* info = __get_tidl_info_s(pid); - RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected"); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type); if (RPC_PORT_ERROR_NONE != ret) { diff --git a/client/vc_widget.c b/client/vc_widget.c index 5161784..d4816f0 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -168,10 +168,7 @@ int vc_widget_initialize(vc_h* vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); if (0 == vc_widget_client_get_count()) { if (0 != vc_widget_tidl_open_connection()) { @@ -208,7 +205,7 @@ int vc_widget_initialize(vc_h* vc_w) SLOG(LOG_DEBUG, TAG_VCW, "[Success] uid(%d)", (*vc_w)->handle); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Initialize DONE"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; @@ -285,7 +282,6 @@ int vc_widget_deinitialize(vc_h vc_w) pthread_mutex_lock(&g_w_init_mutex); if (false == vc_widget_client_is_valid(vc_w)) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] NOT initialized"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -338,7 +334,7 @@ int vc_widget_deinitialize(vc_h vc_w) } } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Deinitialize DONE"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; @@ -365,8 +361,7 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) SLOG(LOG_DEBUG, TAG_VCW, "@@@ type(%d) is NOT valid", type); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - SLOG(LOG_DEBUG, TAG_VCW, ""); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ Focus changed DONE"); return ECORE_CALLBACK_RENEW; } @@ -570,7 +565,7 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) } g_w_prepare_thread = NULL; - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ Start prepare thread DONE"); return; } @@ -597,7 +592,6 @@ int vc_widget_prepare(vc_h vc_w) vc_state_e 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, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -605,7 +599,6 @@ int vc_widget_prepare(vc_h vc_w) /* check state */ if (state != VC_STATE_INITIALIZED) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -613,7 +606,6 @@ int vc_widget_prepare(vc_h vc_w) vc_widget_s* widget = widget_get(vc_w); if (NULL == widget) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get widget handle"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -630,7 +622,7 @@ int vc_widget_prepare(vc_h vc_w) g_ask_to_cancel_preparing = false; g_w_prepare_thread = ecore_thread_run(__start_prepare_thread, __end_prepare_thread, __cancel_prepare_thread, (void*)vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Prepare DONE"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } @@ -655,7 +647,6 @@ int vc_widget_unprepare(vc_h vc_w) vc_state_e 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, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -663,7 +654,6 @@ int vc_widget_unprepare(vc_h vc_w) /* check state */ if (state != VC_STATE_READY) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY', state(%d)", state); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_INVALID_STATE; } @@ -673,7 +663,7 @@ int vc_widget_unprepare(vc_h vc_w) vc_widget_client_set_state(vc_w, VC_STATE_INITIALIZED); g_w_notify_state_timer = ecore_timer_add(0, __vc_widget_notify_state_changed, vc_w); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Unprepare DONE"); pthread_mutex_unlock(&g_w_init_mutex); return VC_ERROR_NONE; } @@ -690,16 +680,11 @@ int vc_widget_enable_asr_result(vc_h vc_w, bool enable) vc_state_e 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, "@@@"); 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); int ret = -1; @@ -711,7 +696,7 @@ int vc_widget_enable_asr_result(vc_h vc_w, bool enable) vc_widget_client_set_asr_result_enabled(vc_w, enable); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Enable asr result DONE"); return ret; } @@ -725,16 +710,11 @@ int vc_widget_foreach_supported_languages(vc_h vc_w, vc_supported_language_cb ca return VC_ERROR_NONE; } - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_state_e 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -745,7 +725,7 @@ int vc_widget_foreach_supported_languages(vc_h vc_w, vc_supported_language_cb ca SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get languages : %s", __vc_widget_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Foreach Supported Language DONE"); return VC_ERROR_NONE; } @@ -759,16 +739,11 @@ int vc_widget_get_current_language(vc_h vc_w, char** language) return VC_ERROR_NONE; } - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_state_e 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -779,7 +754,7 @@ int vc_widget_get_current_language(vc_h vc_w, char** language) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to get current languages : %s", __vc_widget_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get Current Language DONE"); return ret; } @@ -793,15 +768,11 @@ int vc_widget_get_state(vc_h vc_w, vc_state_e* state) return VC_ERROR_NONE; } - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_state_e temp; if (0 != vc_widget_client_get_state(vc_w, &temp)) { SLOG(LOG_DEBUG, TAG_VCW, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -814,7 +785,7 @@ int vc_widget_get_state(vc_h vc_w, vc_state_e* state) default: SLOG(LOG_ERROR, TAG_VCW, "Invalid state"); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get State DONE"); return VC_ERROR_NONE; } @@ -828,23 +799,15 @@ int vc_widget_get_service_state(vc_h vc_w, vc_service_state_e* state) return VC_ERROR_NONE; } - if (NULL == state) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_state_e 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, "@@@"); return VC_ERROR_INVALID_STATE; } - if (temp != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(temp != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); /* get service state */ vc_service_state_e service_state; @@ -863,7 +826,7 @@ int vc_widget_get_service_state(vc_h vc_w, vc_service_state_e* state) default: SLOG(LOG_ERROR, TAG_VCW, "Invalid service state"); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Get Service State DONE"); return VC_ERROR_NONE; } @@ -880,16 +843,11 @@ int vc_widget_set_foreground(vc_h vc_w, bool value) vc_state_e 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, "@@@"); 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); SLOG(LOG_DEBUG, TAG_VCW, "Set foreground : pid(%d) value(%s)", getpid(), value ? "true" : "false"); int ret = vc_widget_tidl_set_foreground(getpid(), value); @@ -898,7 +856,7 @@ int vc_widget_set_foreground(vc_h vc_w, bool value) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set foreground : %s", __vc_widget_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Set foreground state DONE"); return VC_ERROR_NONE; } @@ -910,7 +868,6 @@ int vc_widget_is_format_supported(vc_h vc_w, vc_cmd_format_e format, bool* suppo vc_state_e 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -931,7 +888,7 @@ int vc_widget_is_format_supported(vc_h vc_w, vc_cmd_format_e format, bool* suppo SLOG(LOG_ERROR, TAG_VCW, "[DEBUG] Format(%d) support(%s)", format, *support ? "true" : "false"); - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Is command type supported DONE"); return VC_ERROR_NONE; } @@ -1117,23 +1074,17 @@ int vc_widget_cancel(vc_h vc_w) vc_state_e 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, "@@@"); 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, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'READY'"); /* Check service state */ vc_service_state_e service_state = -1; 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1144,7 +1095,7 @@ int vc_widget_cancel(vc_h vc_w) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request cancel : %s", __vc_widget_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + SLOG(LOG_DEBUG, TAG_VCW, "@@@ [Widget] Cancel Recognition DONE"); // TODO: check return value correct or not return VC_ERROR_NONE; @@ -1156,10 +1107,8 @@ static void __vc_widget_notify_error(void *data) vc_error_cb callback = NULL; void* user_data; int reason; - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return; - } + + RETM_IF(NULL == vc_w, TAG_VCW, "[ERROR] Input parameter is NULL"); vc_widget_client_get_error_cb(vc_w, &callback, &user_data); vc_widget_client_get_error(vc_w, &reason); @@ -1198,10 +1147,7 @@ int __vc_widget_cb_error(int reason, int daemon_pid, char* msg) } /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCW, "[WARNING] not connected client yet"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] not connected client yet"); if (VC_ERROR_SERVICE_RESET == reason) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] VC daemon reset"); @@ -1369,10 +1315,7 @@ static Eina_Bool __vc_widget_notify_result(void *data) 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; - } + RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCW, "[ERROR] Client result callback is NULL"); vc_cmd_print_list(vc_cmd_list); @@ -1446,10 +1389,7 @@ bool __vc_widget_cb_asr_result(int event, const char* asr_result) static Eina_Bool __vc_widget_notify_state_changed(void *data) { vc_h vc_w = (vc_h)data; - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); @@ -1482,14 +1422,10 @@ int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); 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(vc_w, &state)) { @@ -1497,10 +1433,7 @@ int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_result_cb(vc_w, callback, user_data); @@ -1514,10 +1447,7 @@ int vc_widget_unset_result_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1527,10 +1457,7 @@ int vc_widget_unset_result_cb(vc_h vc_w) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_result_cb(vc_w, NULL, NULL); @@ -1544,14 +1471,10 @@ int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); 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(vc_w, &state)) { @@ -1560,10 +1483,7 @@ int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_show_tooltip_cb(vc_w, callback, user_data); @@ -1577,10 +1497,7 @@ int vc_widget_unset_show_tooltip_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1590,10 +1507,7 @@ int vc_widget_unset_show_tooltip_cb(vc_h vc_w) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_show_tooltip_cb(vc_w, NULL, NULL); @@ -1607,10 +1521,7 @@ int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1620,10 +1531,7 @@ int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_send_command_list_cb(vc_w, callback, user_data); @@ -1637,10 +1545,7 @@ int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1650,10 +1555,7 @@ int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_send_command_list_cb(vc_w, NULL, NULL); @@ -1713,10 +1615,7 @@ int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_c return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1726,10 +1625,7 @@ int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_c } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_service_state_changed_cb(vc_w, callback, user_data); @@ -1743,10 +1639,7 @@ int vc_widget_unset_service_state_changed_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1756,10 +1649,7 @@ int vc_widget_unset_service_state_changed_cb(vc_h vc_w) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_service_state_changed_cb(vc_w, NULL, NULL); @@ -1773,14 +1663,10 @@ int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); 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(vc_w, &state)) { @@ -1789,10 +1675,7 @@ int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_state_changed_cb(vc_w, callback, user_data); @@ -1806,10 +1689,7 @@ int vc_widget_unset_state_changed_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1819,10 +1699,7 @@ int vc_widget_unset_state_changed_cb(vc_h vc_w) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_state_changed_cb(vc_w, NULL, NULL); @@ -1836,14 +1713,10 @@ int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); 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(vc_w, &state)) { @@ -1852,10 +1725,7 @@ int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_asr_result_cb(vc_w, callback, user_data); @@ -1869,10 +1739,7 @@ int vc_widget_unset_asr_result_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1882,10 +1749,7 @@ int vc_widget_unset_asr_result_cb(vc_h vc_w) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_asr_result_cb(vc_w, NULL, NULL); @@ -1899,14 +1763,10 @@ int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_cha return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); 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(vc_w, &state)) { @@ -1915,10 +1775,7 @@ int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_cha } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_current_lang_changed_cb(vc_w, callback, user_data); @@ -1932,10 +1789,7 @@ int vc_widget_unset_current_language_changed_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -1945,10 +1799,7 @@ int vc_widget_unset_current_language_changed_cb(vc_h vc_w) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_current_lang_changed_cb(vc_w, NULL, NULL); @@ -1962,14 +1813,10 @@ int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); 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(vc_w, &state)) { @@ -1978,10 +1825,7 @@ int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_error_cb(vc_w, callback, user_data); @@ -1995,10 +1839,7 @@ int vc_widget_unset_error_cb(vc_h vc_w) return VC_ERROR_NONE; } - if (NULL == vc_w) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Input parameter is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == vc_w, VC_ERROR_INVALID_PARAMETER, TAG_VCW, "[ERROR] Input parameter is NULL"); SLOG(LOG_DEBUG, TAG_VCW, "[CHECK] uid (%d)", vc_w->handle); vc_state_e state; @@ -2008,10 +1849,7 @@ int vc_widget_unset_error_cb(vc_h vc_w) } /* 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; - } + RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCW, "[ERROR] Invalid State: Current state is not 'Initialized'"); vc_widget_client_set_error_cb(vc_w, NULL, NULL); diff --git a/common/vc_main.h b/common/vc_main.h index 6b6d400..3090848 100644 --- a/common/vc_main.h +++ b/common/vc_main.h @@ -65,20 +65,21 @@ typedef struct vc_s *vc_h; #define COLOR_LIGHTBLUE "\033[0;37m" #define COLOR_END "\033[0;m" -#define PERR(fmt, args...) LOGE(COLOR_RED "* Critical * " fmt COLOR_END, ##args) +// #define PERR(fmt, args...) LOGE(COLOR_RED "* Critical * " fmt COLOR_END, ##args) +#define PERR(tag, fmt, args...) SLOG(LOG_ERROR, tag, COLOR_RED "* Critical * " fmt COLOR_END, ##args) -#define RETM_IF(expr, fmt, arg...) \ +#define RETM_IF(expr, tag, fmt, arg...) \ do { \ if (expr) { \ - PERR(fmt, ##arg); \ + PERR(tag, fmt, ##arg); \ return; \ } \ } while (0) -#define RETVM_IF(expr, val, fmt, arg...) \ +#define RETVM_IF(expr, val, tag, fmt, arg...) \ do { \ if (expr) { \ - PERR(fmt, ##arg); \ + PERR(tag, fmt, ##arg); \ return (val); \ } \ } while (0) diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index b7709f3..ac18b4b 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -131,34 +131,40 @@ static void __request_tidl_connect(vcd_client_type_e type, int pid) } } -void __send_msg(bundle* msg, vcd_client_type_e type, int pid) +void __send_msg_to_mgr(bundle* msg) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] send msg start"); - - if (VCD_CLIENT_TYPE_MANAGER == type) { - pthread_mutex_lock(&g_mgr_tidl_info_mutex); + pthread_mutex_lock(&g_mgr_tidl_info_mutex); - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to manager"); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to manager"); + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } - rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } - if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_invoke(handle, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_invoke(handle, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; +} + +void __send_msg(bundle* msg, vcd_client_type_e type, int pid) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] send msg start"); + + if (VCD_CLIENT_TYPE_MANAGER == type) { + __send_msg_to_mgr(msg); } else if (VCD_CLIENT_TYPE_NORMAL == type) { pthread_mutex_lock(&g_client_tidl_info_mutex); @@ -218,29 +224,7 @@ void __send_signal(bundle* msg, vcd_client_type_e type) SLOG(LOG_INFO, TAG_VCD, "[TIDL] send signal start"); if (VCD_CLIENT_TYPE_MANAGER == type) { - pthread_mutex_lock(&g_mgr_tidl_info_mutex); - - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to manager"); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } - - rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } - - if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_invoke(handle, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + __send_msg_to_mgr(msg); } /* signal to MANAGER */ else if (VCD_CLIENT_TYPE_NORMAL == type) { pthread_mutex_lock(&g_client_tidl_info_mutex); -- 2.7.4 From ff8aeee9682f924e59b8bc768c7ae62c0d0c9c8d Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 6 Jul 2022 15:10:13 +0900 Subject: [PATCH 03/16] Remove unnecessary logs Change-Id: I7f4316fba8a62061cbe819465f2520e10e187fcb Signed-off-by: sooyeon --- client/vc.c | 37 ++------- client/vc_mgr.c | 98 +++++++--------------- client/vc_mgr_tidl.c | 35 ++------ client/vc_setting.c | 213 ++++++++++-------------------------------------- client/vc_widget_tidl.c | 8 +- server/vcd_server.c | 13 ++- server/vcd_tidl.c | 141 +++++++++++++------------------- 7 files changed, 154 insertions(+), 391 deletions(-) diff --git a/client/vc.c b/client/vc.c index 1b6d87a..07234ba 100644 --- a/client/vc.c +++ b/client/vc.c @@ -341,7 +341,7 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) SLOG(LOG_DEBUG, TAG_VCC, "@@@ type(%d) is NOT valid", type); } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Focus changed DONE"); return ECORE_CALLBACK_RENEW; } @@ -451,7 +451,6 @@ int vc_deinitialize(void) if (false == vc_client_is_valid(g_vc)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NOT initialized"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -499,7 +498,7 @@ int vc_deinitialize(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to close connection"); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Deinitialize DONE"); return VC_ERROR_NONE; } @@ -621,7 +620,7 @@ static Eina_Bool __vc_connect_daemon(void *data) return EINA_FALSE; } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Connect daemon DONE"); return EINA_FALSE; } @@ -684,7 +683,6 @@ int vc_prepare(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -712,7 +710,6 @@ int vc_prepare_sync(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -774,7 +771,6 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -808,7 +804,6 @@ int vc_get_current_language(char** language) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -841,7 +836,6 @@ int vc_get_state(vc_state_e* state) vc_state_e temp; if (0 != vc_client_get_client_state(g_vc, &temp)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1039,7 +1033,6 @@ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1173,7 +1166,6 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1298,7 +1290,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1308,7 +1299,6 @@ int vc_set_command_list_from_file(const char* file_path, int type) /* check type */ if ((VC_COMMAND_TYPE_FOREGROUND != type) && (VC_COMMAND_TYPE_BACKGROUND != type)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid command type: input type is %d", type); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_PARAMETER; } @@ -1760,7 +1750,6 @@ int vc_get_result(vc_result_cb callback, void* user_data) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2105,7 +2094,6 @@ int vc_set_invocation_name(const char* name) int ret = vc_client_get_client_state(g_vc, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return ret; } @@ -2494,7 +2482,6 @@ int vc_auth_start(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2551,7 +2538,7 @@ int vc_auth_start(void) } } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request start DONE"); return ret; } @@ -2563,7 +2550,6 @@ int vc_auth_stop(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2620,7 +2606,7 @@ int vc_auth_stop(void) } } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request stop DONE"); return ret; } @@ -2632,7 +2618,6 @@ int vc_auth_cancel(void) vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2644,7 +2629,6 @@ int vc_auth_cancel(void) vc_client_get_service_state(g_vc, &service_state); if (service_state != VC_SERVICE_STATE_RECORDING && service_state != VC_SERVICE_STATE_PROCESSING) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'RECORDING' or 'PROCESSING'"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2692,7 +2676,7 @@ int vc_auth_cancel(void) } } - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request cancel DONE"); return ret; } @@ -2822,7 +2806,6 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2862,7 +2845,7 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i } } while (0 != ret); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request tts DONE"); return ret; } @@ -2884,7 +2867,6 @@ int vc_tts_cancel(int utt_id) if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2929,7 +2911,7 @@ int vc_tts_cancel(int utt_id) } } while (0 != ret); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Cancel tts DONE"); return ret; } @@ -2951,7 +2933,6 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -2991,7 +2972,7 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, } } while (0 != ret); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get tts audio format DONE"); return ret; } diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 061f0be..813ee44 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -334,7 +334,7 @@ int vc_mgr_initialize(void) */ SLOG(LOG_ERROR, TAG_VCM, "[Success] pid(%d)", g_vc_m->handle); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Initialize DONE"); return VC_ERROR_NONE; } @@ -365,7 +365,6 @@ int vc_mgr_deinitialize(void) if (false == vc_mgr_client_is_valid(g_vc_m)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] NOT initialized"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -425,7 +424,7 @@ int vc_mgr_deinitialize(void) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to close connection"); } - SLOG(LOG_ERROR, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Deinitialize DONE"); return VC_ERROR_NONE; } @@ -578,7 +577,6 @@ int vc_mgr_prepare(void) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -595,7 +593,7 @@ int vc_mgr_prepare(void) SLOG(LOG_INFO, TAG_VCM, "[INFO] timer handle is already created"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Calling Prepare DONE"); return VC_ERROR_NONE; } @@ -616,7 +614,6 @@ int vc_mgr_unprepare(void) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -628,7 +625,7 @@ int vc_mgr_unprepare(void) vc_mgr_client_set_client_state(g_vc_m, VC_STATE_INITIALIZED); ecore_timer_add(0, __vc_mgr_notify_state_changed, g_vc_m); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Unprepare DONE"); return VC_ERROR_NONE; } @@ -651,7 +648,6 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -662,7 +658,7 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get languages : %s", __vc_mgr_get_error_code(ret)); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Foreach Supported Language DONE"); return VC_ERROR_NONE; } @@ -718,7 +714,6 @@ int vc_mgr_get_state(vc_state_e* state) temp = VC_STATE_NONE; } else if (0 != vc_mgr_client_get_client_state(g_vc_m, &temp)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -731,7 +726,7 @@ int vc_mgr_get_state(vc_state_e* state) default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get State DONE"); return VC_ERROR_NONE; } @@ -758,10 +753,7 @@ int vc_mgr_get_service_state(vc_service_state_e* state) } /* check state */ - if (client_state != VC_STATE_READY) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Current state is not 'READY'"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(client_state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Current state is not 'READY'"); /* get service state */ vc_service_state_e service_state; @@ -780,7 +772,7 @@ int vc_mgr_get_service_state(vc_service_state_e* state) default: SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid state"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get Service State DONE"); return VC_ERROR_NONE; } @@ -801,7 +793,6 @@ int vc_mgr_set_demandable_client_rule(const char* rule) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -821,7 +812,7 @@ int vc_mgr_set_demandable_client_rule(const char* rule) return VC_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set Demandable client rule(%s) DONE", rule); return VC_ERROR_NONE; } @@ -868,7 +859,6 @@ int vc_mgr_is_command_format_supported(int format, bool* support) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -889,7 +879,7 @@ int vc_mgr_is_command_format_supported(int format, bool* support) SLOG(LOG_ERROR, TAG_VCM, "[DEBUG] Format(%d) support(%s)", format, *support ? "true" : "false"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Is command type supported DONE"); return VC_ERROR_NONE; } @@ -915,7 +905,6 @@ int vc_mgr_enable_command_type(int cmd_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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -936,7 +925,7 @@ int vc_mgr_enable_command_type(int cmd_type) SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Success to enable the command type(%d)", cmd_type); } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Enable Command Type DONE, ret(%d)", ret); return ret; } @@ -962,7 +951,6 @@ int vc_mgr_disable_command_type(int cmd_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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -983,7 +971,7 @@ int vc_mgr_disable_command_type(int cmd_type) SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Success to disable the command type(%d)", cmd_type); } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Disable Command Type DONE, ret(%d)", ret); return ret; } @@ -1004,7 +992,6 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1051,7 +1038,7 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) } } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list DONE, ret(%d)", ret); return ret; } @@ -1092,7 +1079,7 @@ int vc_mgr_unset_command_list(void) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to delete file, type(%d), ret(%d)", i, ret); } - SLOG(LOG_ERROR, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Unset Command list DONE"); // TODO: check return value correct or not return VC_ERROR_NONE; @@ -1117,7 +1104,6 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) /* check type */ if (VC_COMMAND_TYPE_FOREGROUND > type || VC_COMMAND_TYPE_EXCLUSIVE < type) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid command type: input type is %d", type); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_PARAMETER; } @@ -1149,7 +1135,7 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) } } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list from file DONE, ret(%d)", ret); return ret; } @@ -1189,7 +1175,7 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to insert preloaded commands into db"); - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set preloaded command list DONE, ret(%d)", ret); return ret; } @@ -1214,7 +1200,6 @@ int vc_mgr_set_audio_type(const char* audio_id) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1237,7 +1222,7 @@ int vc_mgr_set_audio_type(const char* audio_id) vc_mgr_client_set_audio_type(g_vc_m, audio_id); } - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set audio type DONE, ret(%d)", ret); return ret; } @@ -1260,7 +1245,6 @@ int vc_mgr_get_audio_type(char** audio_id) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1435,7 +1419,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) iter = g_slist_nth(client_info_list, 0); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Foreach current commands DONE"); return VC_ERROR_NONE; } @@ -1469,7 +1453,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) SLOG(LOG_INFO, TAG_VCM, "[Manager] No background commands"); } - SLOG(LOG_ERROR, TAG_VCM, "@@@"); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Foreach current commands DONE"); // TODO: check return value correct or not return VC_ERROR_NONE; @@ -1497,7 +1481,6 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1531,7 +1514,6 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1563,7 +1545,6 @@ int vc_mgr_set_private_data(const char* key, const char* data) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1584,7 +1565,7 @@ int vc_mgr_set_private_data(const char* key, const char* data) SLOG(LOG_DEBUG, TAG_VCM, "[SUCCESS] Set private data"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set private data DONE"); return VC_ERROR_NONE; } @@ -1610,7 +1591,6 @@ int vc_mgr_get_private_data(const char* key, char** data) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1640,7 +1620,7 @@ int vc_mgr_get_private_data(const char* key, char** data) temp = NULL; } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get private data DONE"); // TODO: check return value correct or not return VC_ERROR_NONE; @@ -1664,7 +1644,6 @@ int vc_mgr_set_domain(const char* domain) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1685,7 +1664,7 @@ int vc_mgr_set_domain(const char* domain) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set domain"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set domain DONE"); return VC_ERROR_NONE; } @@ -1713,7 +1692,6 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1733,7 +1711,7 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) } else { SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] do action"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] do action DONE"); return VC_ERROR_NONE; } @@ -1765,7 +1743,6 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1785,7 +1762,7 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e } else { SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] specific engine request"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] send specific engine request DONE"); return VC_ERROR_NONE; } @@ -1806,7 +1783,6 @@ int vc_mgr_start(bool exclusive_command_option) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1859,7 +1835,7 @@ int vc_mgr_start(bool exclusive_command_option) g_prev_volume_db = 0; g_cur_volume_db = 0; - SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Request start DONE, ret(%d)", ret); return ret; } @@ -1880,7 +1856,6 @@ int vc_mgr_stop(void) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1917,7 +1892,7 @@ int vc_mgr_stop(void) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Stop recognition"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Request stop DONE"); return ret; } @@ -1938,7 +1913,6 @@ int vc_mgr_cancel(void) 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -1975,7 +1949,7 @@ int vc_mgr_cancel(void) vc_mgr_client_set_exclusive_command(g_vc_m, false); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Request cancel DONE"); return ret; } @@ -2105,7 +2079,6 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) if (VC_RECOGNITION_MODE_RESTART_CONTINUOUSLY != recognition_mode) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'PROCESSING' and mode is not 'Restart continuously'"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } } @@ -2136,7 +2109,7 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) vc_mgr_client_unset_all_result(g_vc_m); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Select result DONE"); return VC_ERROR_NONE; } @@ -2537,7 +2510,7 @@ int vc_mgr_get_error_message(char** err_msg) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get error message"); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get error message DONE"); return ret; } @@ -3917,7 +3890,6 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e 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, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -3935,7 +3907,7 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e else SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Send utterance status"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] send utterance status DONE"); return ret; } @@ -3995,7 +3967,6 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* int ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4005,13 +3976,11 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* ret = vc_mgr_client_get_service_state(g_vc_m, &service_state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } if (VC_SERVICE_STATE_READY != service_state && VC_SERVICE_STATE_RECORDING != service_state) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY' and 'RECORDING', state(%d)", service_state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4048,7 +4017,6 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) int ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4056,7 +4024,6 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) ret = vc_mgr_client_get_service_state(g_vc_m, &service_state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4087,7 +4054,6 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) } else { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'INITIALIZED', state(%d)", state); SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current service state is not 'READY', service_state(%d)", service_state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4225,13 +4191,11 @@ int vc_mgr_change_system_volume(vc_system_volume_event_e event) int ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } if (state != VC_STATE_READY && state != VC_STATE_INITIALIZED) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY' and not 'INITIALIZED', state(%d)", state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } @@ -4260,13 +4224,11 @@ int vc_mgr_recover_system_volume(void) int ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } if (state != VC_STATE_READY && state != VC_STATE_INITIALIZED) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY' and not 'INITIALIZED', state(%d)", state); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return VC_ERROR_INVALID_STATE; } diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index eaa5ddf..18b7ac8 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -132,8 +132,6 @@ static void __notify_cb(void *user_data, bundle *msg) SLOG(LOG_INFO, TAG_VCM, "@@@ Get Speech detected"); __vc_mgr_cb_speech_detected(); - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_SPEECH_DETECTED */ else if (0 == strncmp(VCD_MANAGER_METHOD_ALL_RESULT, method, strlen(VCD_MANAGER_METHOD_ALL_RESULT))) { @@ -144,8 +142,6 @@ static void __notify_cb(void *user_data, bundle *msg) if (val) { __vc_mgr_cb_all_result((vc_result_type_e)atoi(val)); } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_ALL_RESULT */ else if (0 == strncmp(VCD_MANAGER_METHOD_PRE_RESULT, method, strlen(VCD_MANAGER_METHOD_PRE_RESULT))) { @@ -159,8 +155,6 @@ static void __notify_cb(void *user_data, bundle *msg) if (NULL != pre_result) { __vc_mgr_cb_pre_result((vc_pre_result_event_e)atoi(event), pre_result); } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_PRE_RESULT */ else if (0 == strncmp(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT, method, strlen(VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT))) { @@ -189,9 +183,6 @@ static void __notify_cb(void *user_data, bundle *msg) SLOG(LOG_INFO, TAG_VCM, "@@@ Get System Result"); __vc_mgr_cb_system_result(); - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VCD_MANAGER_METHOD_RESULT */ else if (0 == strncmp(VCD_MANAGER_METHOD_DIALOG, method, strlen(VCD_MANAGER_METHOD_DIALOG))) { @@ -212,8 +203,6 @@ static void __notify_cb(void *user_data, bundle *msg) utt_text = NULL; __vc_mgr_cb_dialog(atoi(pid), disp_text, utt_text, (bool)atoi(continous)); - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_DIALOG */ else if (0 == strncmp(VCD_MANAGER_METHOD_ERROR, method, strlen(VCD_MANAGER_METHOD_ERROR))) { @@ -236,8 +225,6 @@ static void __notify_cb(void *user_data, bundle *msg) free(temp_msg); temp_msg = NULL; } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_ERROR */ else if (0 == strncmp(VCD_MANAGER_METHOD_SET_PRIVATE_DATA, method, strlen(VCD_MANAGER_METHOD_SET_PRIVATE_DATA))) { @@ -256,8 +243,6 @@ static void __notify_cb(void *user_data, bundle *msg) } else { SLOG(LOG_ERROR, TAG_VCM, "@@ got invalid pid(%d)", atoi(pid)); } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_SET_PRIVATE_DATA */ else if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT))) { @@ -271,8 +256,6 @@ static void __notify_cb(void *user_data, bundle *msg) bundle_get_str(msg, VC_BUNDLE_AUDIO_RATE, &rate); __vc_mgr_cb_feedback_audio_format(atoi(rate), (vc_audio_channel_e)atoi(channel), (vc_audio_type_e)atoi(audio_type)); - - SLOG(LOG_INFO, TAG_VCM, "@@@"); } /* VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT */ // TODO: uncomment this line after vcc done @@ -292,13 +275,13 @@ static void __notify_cb(void *user_data, bundle *msg) // SLOG(LOG_INFO, TAG_VCM, "@@ foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false"); // __vc_mgr_cb_set_foreground(pid, (bool)value); - // SLOG(LOG_DEBUG, TAG_VCM, "@@@"); // } /* VCC_MANAGER_METHOD_SET_FOREGROUND */ else { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid msg"); } + SLOG(LOG_DEBUG, TAG_VCM, "@@@ __notify_cb DONE"); } static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_char_h data_in, bundle *msg) @@ -324,7 +307,7 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ __vc_mgr_cb_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len); free(buffer); - SLOG(LOG_INFO, TAG_VCM, "@@@"); + SLOG(LOG_INFO, TAG_VCM, "@@@ __send_buffer_cb DONE"); } /* VCD_MANAGER_METHOD_FEEDBACK_STREAMING */ else { @@ -423,7 +406,7 @@ static void __vcd_mgr_set_foreground_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_contex __vc_mgr_cb_set_foreground(pid, (bool)value); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Set foreground DONE"); } static int __vcd_mgr_get_private_data_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, const char *key, char **data, void *user_data) @@ -444,7 +427,7 @@ static int __vcd_mgr_get_private_data_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_conte temp_data = strdup("#NULL"); } *data = temp_data; - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request get private data DONE"); return ret; } @@ -461,7 +444,7 @@ static int __vcd_mgr_auth_enable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth enable DONE"); return ret; } @@ -478,7 +461,7 @@ static int __vcd_mgr_auth_disable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth disable DONE"); return ret; } @@ -495,7 +478,7 @@ static int __vcd_mgr_auth_start_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h c SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth start DONE"); return ret; } @@ -512,7 +495,7 @@ static int __vcd_mgr_auth_stop_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h co SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth stop DONE"); return ret; } @@ -529,7 +512,7 @@ static int __vcd_mgr_auth_cancel_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h SLOG(LOG_ERROR, TAG_VCM, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request auth cancel DONE"); return ret; } diff --git a/client/vc_setting.c b/client/vc_setting.c index 5f26cbe..aabd0b8 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -87,23 +87,17 @@ int vc_setting_initialize(void) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Initialize VC Setting"); - if (VC_SETTING_STATE_READY == g_state) { - SLOG(LOG_WARN, TAG_VCS, "[WARNING] VC Setting has already been initialized."); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_NONE; - } + RETVM_IF(VC_SETTING_STATE_READY == g_state, VC_ERROR_NONE, TAG_VCS, "[WARNING] VC Setting has already been initialized."); int ret = vc_config_mgr_initialize(getpid() + VC_SETTING_CONFIG_HANDLE); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to initialize config manager"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); return VC_ERROR_OPERATION_FAILED; } ret = vc_config_mgr_set_lang_cb(getpid() + VC_SETTING_CONFIG_HANDLE, __config_lang_changed_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to initialize config manager"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); vc_config_mgr_finalize(getpid() + VC_SETTING_CONFIG_HANDLE); return VC_ERROR_OPERATION_FAILED; } @@ -113,7 +107,7 @@ int vc_setting_initialize(void) g_state = VC_SETTING_STATE_READY; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Initialize VC Setting DONE"); return VC_ERROR_NONE; } @@ -122,11 +116,7 @@ int vc_setting_deinitialize() { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Deinitialize VC Setting"); - if (VC_SETTING_STATE_READY != g_state) { - SLOG(LOG_WARN, TAG_VCS, "[WARNING] VC Setting is not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_READY != g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[WARNING] VC Setting is not initialized"); vc_config_mgr_unset_lang_cb(getpid() + VC_SETTING_CONFIG_HANDLE); vc_config_mgr_unset_engine_cb(getpid() + VC_SETTING_CONFIG_HANDLE); @@ -134,7 +124,7 @@ int vc_setting_deinitialize() g_state = VC_SETTING_STATE_NONE; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Deinitialize VC Setting DONE"); return VC_ERROR_NONE; } @@ -148,19 +138,9 @@ int vc_setting_foreach_supported_engines(vc_setting_supported_engine_cb callback { SLOG(LOG_DEBUG, TAG_VCS, "===== Foreach supported engines"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Callback is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); SLOG(LOG_DEBUG, TAG_VCS, "===== Foreach supported engines 11"); g_engine_cb = callback; @@ -173,8 +153,6 @@ int vc_setting_foreach_supported_engines(vc_setting_supported_engine_cb callback SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Foreach supported engines"); } - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); return ret; } @@ -183,19 +161,9 @@ int vc_setting_get_engine(char** engine_id) { SLOG(LOG_DEBUG, TAG_VCS, "===== Get current engine"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == engine_id) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Engine id is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == engine_id, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Engine id is NULL"); int ret = vc_config_mgr_get_engine(engine_id); if (0 != ret) { @@ -204,8 +172,6 @@ int vc_setting_get_engine(char** engine_id) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Get current engine"); } - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); return ret; } @@ -214,19 +180,9 @@ int vc_setting_set_engine(const char* engine_appid) { SLOG(LOG_DEBUG, TAG_VCS, "===== Set current engine"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == engine_appid) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Engine appid is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == engine_appid, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Engine appid is NULL"); SECURE_SLOG(LOG_DEBUG, TAG_VCS, "New engine appid : %s", engine_appid); @@ -237,8 +193,6 @@ int vc_setting_set_engine(const char* engine_appid) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Set current engine"); } - SLOG(LOG_DEBUG, TAG_VCS, "====="); - SLOG(LOG_DEBUG, TAG_VCS, " "); return ret; } @@ -247,17 +201,9 @@ int vc_setting_foreach_supported_languages(vc_setting_supported_language_cb call { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Foreach supported languages"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_get_language_list((vc_supported_language_cb)callback, user_data); if (0 != ret) { @@ -266,7 +212,7 @@ int vc_setting_foreach_supported_languages(vc_setting_supported_language_cb call SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Foreach supported languages"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Foreach supported languages DONE"); return ret; } @@ -275,17 +221,9 @@ int vc_setting_get_language(char** language) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get default language"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_get_default_language(language); if (0 != ret) { @@ -294,7 +232,7 @@ int vc_setting_get_language(char** language) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Get default language"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get default language DONE"); return ret; } @@ -303,17 +241,9 @@ int vc_setting_set_language(const char* language) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set default language"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Input parameter is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_set_default_language(language); if (0 != ret) { @@ -338,7 +268,7 @@ int vc_setting_set_language(const char* language) } } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set default language DONE"); return ret; } @@ -347,15 +277,10 @@ int vc_setting_set_auto_language(bool value) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set auto voice"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); if (value != true && value != false) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Invalid value"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); return VC_ERROR_INVALID_PARAMETER; } @@ -366,7 +291,7 @@ int vc_setting_set_auto_language(bool value) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Set auto language (%s)", value ? "on" : "off"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set auto voice DONE"); return ret; } @@ -375,17 +300,9 @@ int vc_setting_get_auto_language(bool* value) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get auto language"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == value) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == value, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_get_auto_language(value); if (0 != ret) { @@ -394,7 +311,7 @@ int vc_setting_get_auto_language(bool* value) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Get auto language (%s)", *value ? "true" : "false"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get auto language DONE"); return VC_ERROR_NONE; } @@ -403,15 +320,10 @@ int vc_setting_set_enabled(bool value) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set service enabled"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); if (value != true && value != false) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Invalid value"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); return VC_ERROR_INVALID_PARAMETER; } @@ -422,7 +334,7 @@ int vc_setting_set_enabled(bool value) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Set service enabled (%s)", value ? "on" : "off"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set service enabled DONE"); return ret; } @@ -431,17 +343,9 @@ int vc_setting_get_enabled(bool* value) { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get service enabled"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == value) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == value, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); int ret = vc_config_mgr_get_enabled(value); if (0 != ret) { @@ -451,7 +355,7 @@ int vc_setting_get_enabled(bool* value) SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Get service enabled (%s)", *value ? "on" : "off"); } - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get service enabled DONE"); return ret; } @@ -460,22 +364,14 @@ int vc_setting_set_enabled_changed_cb(vc_setting_enabled_changed_cb callback, vo { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set service enabled callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); g_enabled_changed_cb = callback; g_enabled_changed_user_data = user_data; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set service enabled callback DONE"); return VC_ERROR_NONE; } @@ -484,16 +380,12 @@ int vc_setting_unset_enabled_changed_cb() { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset service enabled callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); g_enabled_changed_cb = NULL; g_enabled_changed_user_data = NULL; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset service enabled callback DONE"); return VC_ERROR_NONE; } @@ -502,22 +394,14 @@ int vc_setting_set_current_language_changed_cb(vc_setting_current_language_chang { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set current language changed callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Param is NULL"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); g_current_language_changed_cb = callback; g_current_language_changed_user_data = user_data; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set current language changed callback DONE"); return VC_ERROR_NONE; } @@ -526,16 +410,12 @@ int vc_setting_unset_current_language_changed_cb() { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset current language changed callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); g_current_language_changed_cb = NULL; g_current_language_changed_user_data = NULL; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset current language changed callback"); return VC_ERROR_NONE; } @@ -544,15 +424,12 @@ int vc_setting_set_engine_changed_cb(vc_setting_engine_changed_cb callback, void { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set engine changed callback"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Input param is NULL"); - return VC_ERROR_INVALID_PARAMETER; - } + RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCS, "[ERROR] Invalid parameter"); g_engine_changed_cb = callback; g_engine_changed_user_data = user_data; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Set engine changed callback DONE"); return VC_ERROR_NONE; } @@ -560,15 +437,11 @@ int vc_setting_unset_engine_changed_cb() { SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset engine changed callback"); - if (VC_SETTING_STATE_NONE == g_state) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Not initialized"); - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return VC_ERROR_INVALID_STATE; - } + RETVM_IF(VC_SETTING_STATE_NONE == g_state, VC_ERROR_INVALID_STATE, TAG_VCS, "[ERROR] Not initialized"); g_engine_changed_cb = NULL; g_engine_changed_user_data = NULL; - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); + SLOG(LOG_DEBUG, TAG_VCS, "@@@ Unset engine changed callback DONE"); return VC_ERROR_NONE; } diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index 091a57c..dbe49de 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -71,7 +71,6 @@ static void __notify_cb(void *user_data, bundle *msg) } else { SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget get hello : invalid pid "); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); } /* VCD_METHOD_HELLO */ else if (0 == strncmp(VCD_WIDGET_METHOD_SET_SERVICE_STATE, method, strlen(VCD_WIDGET_METHOD_SET_SERVICE_STATE))) { @@ -105,15 +104,12 @@ static void __notify_cb(void *user_data, bundle *msg) } else { SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget show tooltip : invalid pid"); } - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); } /* VCD_WIDGET_METHOD_SHOW_TOOLTIP */ else if (0 == strncmp(VCD_WIDGET_METHOD_RESULT, method, strlen(VCD_WIDGET_METHOD_RESULT))) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Get widget result"); __vc_widget_cb_result(); - - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); } /* VCD_WIDGET_METHOD_RESULT */ else if (0 == strncmp(VCD_WIDGET_METHOD_ERROR, method, strlen(VCD_WIDGET_METHOD_ERROR))) { @@ -137,13 +133,13 @@ static void __notify_cb(void *user_data, bundle *msg) SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get error message : reason(%d), daemon_pid(%d), msg(%s)", reason, daemon_pid, err_msg); __vc_widget_cb_error(reason, daemon_pid, err_msg); - - SLOG(LOG_DEBUG, TAG_VCW, "@@@"); } /* VCD_WIDGET_METHOD_ERROR */ else { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid msg"); } + + SLOG(LOG_DEBUG, TAG_VCW, "@@@ __notify_cb DONE"); } static void __on_connected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data) diff --git a/server/vcd_server.c b/server/vcd_server.c index 3939f9c..8a21bcd 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -74,7 +74,7 @@ static Eina_Bool __stop_by_silence(void *data) vcd_server_mgr_stop(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Silence Detected DONE"); return EINA_FALSE; } @@ -84,7 +84,7 @@ static Eina_Bool __cancel_by_interrupt(void *data) vcd_server_mgr_cancel(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by interrupt DONE"); return EINA_FALSE; } @@ -94,7 +94,7 @@ static void __cancel_by_error(void *data) vcd_server_mgr_cancel(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by error DONE"); return; } @@ -121,7 +121,6 @@ static Eina_Bool __restart_engine(void *data) SLOG(LOG_INFO, TAG_VCD, "[Server Success] Restart recognition"); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); return EINA_FALSE; } @@ -191,7 +190,7 @@ void __server_recorder_interrupt_callback() ecore_timer_add(0, __cancel_by_interrupt, NULL); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by sound interrupt DONE"); } static void __config_lang_changed_cb(const char* current_lang, void* user_data) @@ -211,7 +210,7 @@ static void __config_lang_changed_cb(const char* current_lang, void* user_data) SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set language of engine : %d", ret); } - SLOG(LOG_INFO, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "@@@ Change language DONE"); return; } @@ -231,7 +230,7 @@ static void __config_foreground_changed_cb(int previous, int current, void* user } } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Change foreground DONE"); return; } diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index ac18b4b..967ad20 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -351,7 +351,7 @@ static void __vc_terminate_cb(rpc_port_stub_vcd_stub_vc_context_h context, void } tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC FINALIZE DONE"); pthread_mutex_unlock(&g_client_tidl_info_mutex); @@ -870,8 +870,6 @@ static void __vc_mgr_terminate_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h co } mgr_tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); @@ -942,12 +940,12 @@ static void __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h __request_tidl_connect(VCD_CLIENT_TYPE_MANAGER, pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC MANAGER REGISTER CALLBACK DONE"); } static int __vc_mgr_initialize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int audio_streaming_mode, int *service_state, int *foreground, int *daemon_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Initialize"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Initialize : pid(%d) service state(%d) foreground(%d) daemon_pid(%d)", pid, *service_state, *foreground, *daemon_pid); int ret = -1; @@ -962,14 +960,12 @@ static int __vc_mgr_initialize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h c *daemon_pid = getpid(); SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr initialize : pid(%d) service state(%d) foreground(%d) daemon_pid(%d)", pid, *service_state, *foreground, *daemon_pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); return ret; } static int __vc_mgr_finalize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Finalize"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr finalize : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Finalize : pid(%d)", pid); int ret = -1; @@ -978,15 +974,14 @@ static int __vc_mgr_finalize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h con SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr finalize : pid(%d)", pid); return ret; } static int __vc_mgr_set_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Set command"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set command : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Set command : pid(%d)", pid); int ret = -1; @@ -996,15 +991,14 @@ static int __vc_mgr_set_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set command : pid(%d)", pid); return ret; } static int __vc_mgr_unset_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager unset command"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr unset command : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager unset command : pid(%d)", pid); int ret = -1; @@ -1014,15 +1008,14 @@ static int __vc_mgr_unset_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_ return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr unset command : pid(%d)", pid); return ret; } static int __vc_mgr_set_demandable_client_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Set demandable client"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set demandable client : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Set demandable client : pid(%d)", pid); int ret = -1; @@ -1032,15 +1025,14 @@ static int __vc_mgr_set_demandable_client_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_ return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set demandable client : pid(%d)", pid); return ret; } static int __vc_mgr_set_audio_type_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *audio_type, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set audio type"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d), audio type(%s)", pid, audio_type); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set audio type : pid(%d), audio type(%s)", pid, audio_type); int ret = -1; @@ -1050,15 +1042,14 @@ static int __vc_mgr_set_audio_type_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d), audio type(%s)", pid, audio_type); return ret; } static int __vc_mgr_get_audio_type_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, char **audio_type, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager get audio type"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager get audio type : pid(%d)", pid); int ret = -1; char* tmp_audio_type = NULL; @@ -1073,15 +1064,14 @@ static int __vc_mgr_get_audio_type_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context *audio_type = strdup(tmp_audio_type); free(tmp_audio_type); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d)", pid); return ret; } static void __vc_mgr_set_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *key, const char *data, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set private data"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set domain : pid(%d), key(%s), data(%s)", pid, key, data); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set private data : pid(%d), key(%s), data(%s)", pid, key, data); int ret = -1; @@ -1091,13 +1081,12 @@ static void __vc_mgr_set_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_cont SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set private data : pid(%d), key(%s), data(%s)", pid, key, data); } static int __vc_mgr_get_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *key, char **data, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager get private data"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr get private data : pid(%d), key(%s)", pid, key); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager get private data : pid(%d), key(%s)", pid, key); int ret = -1; char *temp_data = NULL; @@ -1115,15 +1104,14 @@ static int __vc_mgr_get_private_data_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_conte *data = strdup(temp_data); free(temp_data); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr get private data : pid(%d), key(%s)", pid, key); return ret; } static int __vc_mgr_set_client_info_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set client info"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set client info : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set client info : pid(%d)", pid); int ret = -1; @@ -1133,15 +1121,14 @@ static int __vc_mgr_set_client_info_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_contex return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set client info : pid(%d)", pid); return ret; } static int __vc_mgr_set_domain_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *domain, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set domain type"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set domain : pid(%d), domain(%s)", pid, domain); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set domain type : pid(%d), domain(%s)", pid, domain); int ret = -1; @@ -1151,15 +1138,14 @@ static int __vc_mgr_set_domain_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h c return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set domain : pid(%d), domain(%s)", pid, domain); return ret; } static void __vc_mgr_do_action_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int type, const char *send_event, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager request to do action"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr request to do action : pid(%d), type(%d) send_event(%s)", pid, type, send_event); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager request to do action : pid(%d), type(%d) send_event(%s)", pid, type, send_event); int ret = -1; @@ -1168,7 +1154,7 @@ static void __vc_mgr_do_action_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h c SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr request to do action : pid(%d), type(%d) send_event(%s)", pid, type, send_event); } static int __vc_mgr_start_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int recognition_mode, bool exclusive_command_option, bool start_by_client, int disabled_cmd_type, void *user_data) @@ -1187,15 +1173,14 @@ static int __vc_mgr_start_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h contex return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager start DONE"); return ret; } static int __vc_mgr_stop_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager stop"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr stop : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager stop : pid(%d)", pid); int ret = -1; @@ -1206,15 +1191,14 @@ static int __vc_mgr_stop_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr stop : pid(%d)", pid); return ret; } static int __vc_mgr_cancel_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager cancel"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr cancel : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager cancel : pid(%d)", pid); int ret = -1; @@ -1224,24 +1208,23 @@ static int __vc_mgr_cancel_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h conte return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr cancel : pid(%d)", pid); return ret; } static void __vc_mgr_set_audio_streaming_mode_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int mode, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set audio streaming mode"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio streaming mode : pid(%d) mode(%d)", pid, mode); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager set audio streaming mode : pid(%d) mode(%d)", pid, mode); vcd_config_set_audio_streaming_mode((vcd_audio_streaming_mode_e)mode); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio streaming mode : pid(%d) mode(%d)", pid, mode); } static void __vc_mgr_send_specific_engine_request_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, const char *engine_app_id, const char *event, const char *request, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager specific engine request"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager specific engine request"); int ret = -1; gsize decodingSize = 0; @@ -1257,23 +1240,21 @@ static void __vc_mgr_send_specific_engine_request_cb(rpc_port_stub_vcd_mgr_stub g_free(gDecodedRequest); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager specific engine request DONE"); } static void __vc_mgr_send_result_selection_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager result selection"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr result selection : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager result selection : pid(%d)", pid); vcd_server_mgr_result_select(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr result selection : pid(%d)", pid); } static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int utt_id, int utt_status, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send utterance status"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); pthread_mutex_lock(&g_client_tidl_info_mutex); @@ -1321,12 +1302,12 @@ static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr bundle_free(msg); pthread_mutex_unlock(&g_client_tidl_info_mutex); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); } static void __vc_mgr_send_audio_streaming_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, int event, rpc_port_stub_vcd_mgr_stub_array_char_h data, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send audio streaming"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager send audio streaming"); char* buffer = NULL; int len = 0; @@ -1340,7 +1321,7 @@ static void __vc_mgr_send_audio_streaming_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_ SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager send audio streaming DONE"); } int __mgr_tidl_open_connection() @@ -1485,8 +1466,6 @@ static void __vc_widget_terminate_cb(rpc_port_stub_vcd_widget_stub_vc_widget_con } widget_tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - pthread_mutex_unlock(&g_widget_tidl_info_mutex); char *sender = NULL; @@ -1551,7 +1530,7 @@ static void __vc_widget_register_cb_cb(rpc_port_stub_vcd_widget_stub_vc_widget_ __request_tidl_connect(VCD_CLIENT_TYPE_WIDGET, pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC WIDGET REGISTER CALLBACK DONE"); } static int __vc_widget_initialize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int *service_state, int *daemon_pid, void *user_data) @@ -1572,14 +1551,12 @@ static int __vc_widget_initialize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_co *daemon_pid = getpid(); SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget initialize : pid(%d) service state(%d) daemon_pid(%d)", pid, *service_state, *daemon_pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); return ret; } static int __vc_widget_finalize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Finalize"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget finalize : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Finalize : pid(%d)", pid); int ret = -1; @@ -1589,15 +1566,14 @@ static int __vc_widget_finalize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_cont return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget finalize : pid(%d)", pid); return ret; } static int __vc_widget_start_recording_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int command, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Start Recording"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start recording : pid(%d) command(%d)", pid, command); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Start Recording : pid(%d) command(%d)", pid, command); int ret = -1; @@ -1607,15 +1583,14 @@ static int __vc_widget_start_recording_cb(rpc_port_stub_vcd_widget_stub_vc_widge return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start recording : pid(%d) command(%d)", pid, command); return ret; } static int __vc_widget_start_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int silence, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Start"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start : pid(%d) silence(%d)", pid, silence); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Start : pid(%d) silence(%d)", pid, silence); int ret = -1; @@ -1625,15 +1600,14 @@ static int __vc_widget_start_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_ return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start : pid(%d) silence(%d)", pid, silence); return ret; } static int __vc_widget_stop_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Stop"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget stop : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Stop : pid(%d)", pid); int ret = -1; @@ -1643,15 +1617,14 @@ static int __vc_widget_stop_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget stop : pid(%d)", pid); return ret; } static int __vc_widget_cancel_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Cancel"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget cancel : pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Cancel : pid(%d)", pid); int ret = -1; @@ -1661,15 +1634,14 @@ static int __vc_widget_cancel_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget cancel : pid(%d)", pid); return ret; } static int __vc_widget_enable_asr_result_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int enable, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Enable Asr Result"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget enable asr result : pid(%d) enable(%d)", pid, enable); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Enable Asr Result : pid(%d) enable(%d)", pid, enable); int ret = -1; @@ -1679,15 +1651,14 @@ static int __vc_widget_enable_asr_result_cb(rpc_port_stub_vcd_widget_stub_vc_wid return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget enable asr result : pid(%d) enable(%d)", pid, enable); return ret; } static void __vc_widget_set_foreground_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int value, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Set Foreground"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget set foreground : pid(%d) value(%d)", pid, value); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Set Foreground : pid(%d) value(%d)", pid, value); int ret = -1; @@ -1700,7 +1671,7 @@ static void __vc_widget_set_foreground_cb(rpc_port_stub_vcd_widget_stub_vc_widge SLOG(LOG_DEBUG, TAG_VCD, "@@@ send request set foreground to manager"); vcdc_send_request_set_foreground(pid, value); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget set foreground : pid(%d) value(%d)", pid, value); return; } @@ -1791,8 +1762,6 @@ static void __vc_setting_terminate_cb(rpc_port_stub_vcd_setting_stub_vc_setting_ } setting_tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - pthread_mutex_unlock(&g_setting_tidl_info_mutex); } rpc_port_stub_vcd_setting_stub_vc_setting_context_set_tag(context, NULL); -- 2.7.4 From 0b2b2a9a540cd7870a3724ed5569cd62563630ca Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 6 Jul 2022 16:11:34 +0900 Subject: [PATCH 04/16] Replace codes to check feature and privilege Change-Id: I2691dbf7a1c3f4a5bcdb8e9eebb29b28cad050ce Signed-off-by: sooyeon --- client/vc.c | 388 ++++++++++--------------- client/vc_mgr.c | 882 +++++++++++++++++++------------------------------------- server/vce.c | 110 +++---- 3 files changed, 505 insertions(+), 875 deletions(-) diff --git a/client/vc.c b/client/vc.c index 07234ba..c61a3f0 100644 --- a/client/vc.c +++ b/client/vc.c @@ -208,6 +208,18 @@ static int __vc_check_privilege() return VC_ERROR_NONE; } +int __check_feature_privilege() +{ + if (0 != __vc_get_feature_enabled()) { + return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE + } + if (0 != __vc_check_privilege()) { + return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE + } + + return VC_ERROR_NONE; +} + //LCOV_EXCL_START static const char* __vc_get_error_code(vc_error_e err) { @@ -349,12 +361,10 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) int vc_initialize(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCC, "@@@ [Client] Initialize"); @@ -379,7 +389,7 @@ int vc_initialize(void) return VC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } - int ret = vc_config_mgr_initialize(g_vc->handle); + ret = vc_config_mgr_initialize(g_vc->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to init config manager : %s", __vc_get_error_code(__vc_convert_config_error_code(ret))); //LCOV_EXCL_LINE @@ -439,13 +449,9 @@ static void __vc_internal_unprepare(void) int vc_deinitialize(void) { int ret = VC_ERROR_NONE; - - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCC, "@@@ [Client] Deinitialize"); @@ -671,12 +677,10 @@ static void __end_prepare_thread(void *data, Ecore_Thread *thread) int vc_prepare(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare"); @@ -698,12 +702,10 @@ int vc_prepare(void) //LCOV_EXCL_START int vc_prepare_sync(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare"); @@ -729,12 +731,10 @@ int vc_prepare_sync(void) int vc_unprepare(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unprepare"); @@ -759,12 +759,10 @@ int vc_unprepare(void) int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -776,8 +774,6 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Foreach Supported Language"); - - int ret = -1; ret = vc_config_mgr_get_language_list(callback, user_data); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); @@ -792,12 +788,10 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user int vc_get_current_language(char** language) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -810,7 +804,6 @@ int vc_get_current_language(char** language) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Get Current Language"); - int ret = -1; ret = vc_config_mgr_get_default_language(language); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); @@ -824,12 +817,10 @@ int vc_get_current_language(char** language) int vc_get_state(vc_state_e* state) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -860,12 +851,10 @@ int vc_get_state(vc_state_e* state) int vc_get_service_state(vc_service_state_e* state) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -906,12 +895,10 @@ int vc_get_service_state(vc_service_state_e* state) int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == vc_sys_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); *vc_sys_cmd_list = NULL; @@ -935,7 +922,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) bool is_sys_cmd_valid = false; int count = 0; - int ret = -1; + ret = -1; bool is_prepared = false; do { ret = vc_tidl_request_is_system_command_valid(g_vc->handle, &is_sys_cmd_valid); @@ -1021,12 +1008,10 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) */ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Is command format supported"); @@ -1154,12 +1139,10 @@ void __set_command(vc_h vc, vc_cmd_type_e type) int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); @@ -1185,7 +1168,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) list = (vc_cmd_list_s*)vc_cmd_list; RETVM_IF(NULL == list->list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Invalid command list"); - int ret = 0; + ret = 0; char* invocation_name = NULL; if (VC_COMMAND_TYPE_BACKGROUND == type) { ret = __vc_get_invocation_name(&invocation_name); @@ -1218,12 +1201,10 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) int vc_unset_command_list(int type) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1238,7 +1219,7 @@ int vc_unset_command_list(int type) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unset Command list"); int count = 0; - int ret = -1; + ret = -1; bool is_prepared = false; while (0 != ret) { ret = vc_tidl_request_unset_command(g_vc->handle, (vc_cmd_type_e)type); @@ -1280,12 +1261,10 @@ int vc_unset_command_list(int type) //LCOV_EXCL_START int vc_set_command_list_from_file(const char* file_path, int type) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1305,7 +1284,7 @@ int vc_set_command_list_from_file(const char* file_path, int type) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Set Command list from file"); - int ret = 0; + ret = 0; char* invocation_name = NULL; if (VC_COMMAND_TYPE_BACKGROUND == type) { ret = __vc_get_invocation_name(&invocation_name); @@ -1740,12 +1719,10 @@ void __vc_cb_result(void) int vc_get_result(vc_result_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1770,7 +1747,7 @@ int vc_get_result(vc_result_cb callback, void* user_data) return VC_ERROR_INVALID_PARAMETER; } - int ret = vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); + ret = vc_info_parser_get_result(&temp_text, &event, NULL, getpid(), vc_cmd_list, false); if (0 != ret || NULL == temp_text) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get result, ret(%d) temp_text(%s)", ret, temp_text); //LCOV_EXCL_LINE return ret; @@ -1797,12 +1774,10 @@ int vc_get_result(vc_result_cb callback, void* user_data) int vc_set_result_cb(vc_result_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client result callback is NULL"); @@ -1822,12 +1797,10 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) int vc_unset_result_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1889,12 +1862,10 @@ int __vc_cb_manager_pid(int manager_pid) int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client service state changed callback is NULL"); @@ -1914,12 +1885,10 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* int vc_unset_service_state_changed_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1937,12 +1906,10 @@ int vc_unset_service_state_changed_cb(void) int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client state changed callback is NULL"); @@ -1962,12 +1929,10 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) int vc_unset_state_changed_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -1985,12 +1950,10 @@ int vc_unset_state_changed_cb(void) int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client current language changed callback is NULL"); @@ -2010,12 +1973,10 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, int vc_unset_current_language_changed_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2033,12 +1994,10 @@ int vc_unset_current_language_changed_cb(void) int vc_set_error_cb(vc_error_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client error callback is NULL"); @@ -2058,12 +2017,10 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) int vc_unset_error_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -2081,17 +2038,15 @@ int vc_unset_error_cb(void) int vc_set_invocation_name(const char* name) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set invocation name"); - int ret = vc_client_get_client_state(g_vc, &state); + ret = vc_client_get_client_state(g_vc, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return ret; @@ -2112,13 +2067,9 @@ int vc_set_server_dialog(const char* app_id, const char* credential) { vc_state_e state; int ret = -1; - - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == credential, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Credential is NULL"); @@ -2192,12 +2143,9 @@ int vc_unset_server_dialog(const char* app_id) int ret = -1; char* tmp_appid = NULL; - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2266,13 +2214,10 @@ int vc_unset_server_dialog(const char* app_id) int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_start) { vc_state_e state; - - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2288,7 +2233,7 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start); - int ret = vc_tidl_request_request_dialog(getpid(), disp_text, utt_text, auto_start); + ret = vc_tidl_request_request_dialog(getpid(), disp_text, utt_text, auto_start); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request dialog, ret(%d)", ret); return VC_ERROR_OPERATION_FAILED; @@ -2797,12 +2742,9 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request tts"); - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2858,12 +2800,9 @@ int vc_tts_cancel(int utt_id) SLOG(LOG_DEBUG, TAG_VCC, "@@@ Cancel tts"); - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2924,12 +2863,9 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get tts audio format"); - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (0 != vc_client_get_client_state(g_vc, &state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); @@ -2979,12 +2915,10 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (NULL == callback) return VC_ERROR_INVALID_PARAMETER; @@ -3005,12 +2939,10 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) int vc_tts_unset_streaming_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { @@ -3044,12 +2976,10 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* user_data) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Utterance status callback is null"); @@ -3069,12 +2999,10 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us int vc_tts_unset_utterance_status_cb(void) { - if (0 != __vc_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE - } - if (0 != __vc_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + int ret; + ret = __check_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_client_get_client_state(g_vc, &state)) { diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 813ee44..e07325f 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -273,11 +273,8 @@ static int __vc_mgr_check_privilege() return VC_ERROR_NONE; } -int vc_mgr_initialize(void) +int __check_mgr_feature_privilege() { - SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Initialize"); - - if (0 != __vc_mgr_get_feature_enabled()) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); return VC_ERROR_NOT_SUPPORTED; @@ -287,6 +284,18 @@ int vc_mgr_initialize(void) return VC_ERROR_PERMISSION_DENIED; } + return VC_ERROR_NONE; +} + +int vc_mgr_initialize(void) +{ + SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Initialize"); + + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; + /* check handle */ if (true == vc_mgr_client_is_valid(g_vc_m)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Already initialized"); @@ -303,7 +312,7 @@ int vc_mgr_initialize(void) return VC_ERROR_OUT_OF_MEMORY; } - int ret = vc_config_mgr_initialize(g_vc_m->handle + VC_MANAGER_CONFIG_HANDLE); + ret = vc_config_mgr_initialize(g_vc_m->handle + VC_MANAGER_CONFIG_HANDLE); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to init config manager : %d", ret); vc_mgr_client_destroy(g_vc_m); @@ -354,14 +363,10 @@ int vc_mgr_deinitialize(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Deinitialize"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (false == vc_mgr_client_is_valid(g_vc_m)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] NOT initialized"); @@ -403,12 +408,12 @@ int vc_mgr_deinitialize(void) int cnt = VC_COMMAND_TYPE_FOREGROUND; do { - int ret = vc_cmd_parser_delete_file(getpid(), cnt); + ret = vc_cmd_parser_delete_file(getpid(), cnt); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to delete file, type(%d), ret(%d)", cnt, ret); } while (VC_COMMAND_TYPE_EXCLUSIVE >= ++cnt); - int ret = vc_db_finalize(); + ret = vc_db_finalize(); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to finalize DB, ret(%d)", ret); } @@ -565,14 +570,10 @@ int vc_mgr_prepare(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Prepare"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -602,14 +603,10 @@ int vc_mgr_unprepare(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Unprepare"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -634,14 +631,10 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Foreach Supported Language"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -651,7 +644,6 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* return VC_ERROR_INVALID_STATE; } - int ret = -1; ret = vc_config_mgr_get_language_list(callback, user_data); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); @@ -665,14 +657,10 @@ int vc_mgr_foreach_supported_languages(vc_supported_language_cb callback, void* int vc_mgr_get_current_language(char** language) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -682,7 +670,6 @@ int vc_mgr_get_current_language(char** language) return VC_ERROR_INVALID_STATE; } - int ret = -1; ret = vc_config_mgr_get_default_language(language); if (0 != ret) { ret = vc_config_convert_error_code((vc_config_error_e)ret); @@ -698,14 +685,10 @@ int vc_mgr_get_state(vc_state_e* state) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get State"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -735,14 +718,10 @@ int vc_mgr_get_service_state(vc_service_state_e* state) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get Service State"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -781,14 +760,10 @@ int vc_mgr_set_demandable_client_rule(const char* rule) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Set Demandable client rule(%s)", rule); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -799,7 +774,6 @@ int vc_mgr_set_demandable_client_rule(const char* rule) /* check state */ RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", state); - int ret = -1; ret = vc_info_parser_set_demandable_client(rule); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] rule is NOT valid"); @@ -821,18 +795,14 @@ int vc_mgr_unset_demandable_client_rule(void) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Unset Demandable client"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_info_parser_set_demandable_client(NULL); - int ret = vc_mgr_tidl_request_demandable_client(g_vc_m->handle); + ret = vc_mgr_tidl_request_demandable_client(g_vc_m->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request unset client rule to daemon : %s", __vc_mgr_get_error_code(ret)); } @@ -845,14 +815,10 @@ int vc_mgr_is_command_format_supported(int format, bool* support) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Is command type supported"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == support, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -888,14 +854,10 @@ int vc_mgr_enable_command_type(int cmd_type) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Enable Command Type, cmd_type(%d)", cmd_type); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_COMMAND_TYPE_FOREGROUND > cmd_type || VC_COMMAND_TYPE_EXCLUSIVE < cmd_type) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] cmd_type is not valid. (%d)", cmd_type); @@ -916,8 +878,6 @@ int vc_mgr_enable_command_type(int cmd_type) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret; - ret = vc_mgr_client_enable_command_type(g_vc_m, (vc_cmd_type_e)cmd_type); // enable the cmd type if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to enable the command type(%d). ret(%d)", cmd_type, ret); @@ -934,14 +894,10 @@ int vc_mgr_disable_command_type(int cmd_type) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Disable Command Type, cmd_type(%d)", cmd_type); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_COMMAND_TYPE_FOREGROUND > cmd_type || VC_COMMAND_TYPE_EXCLUSIVE < cmd_type) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] cmd type is not valid, (%d)", cmd_type); @@ -962,8 +918,6 @@ int vc_mgr_disable_command_type(int cmd_type) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret; - ret = vc_mgr_client_disable_command_type(g_vc_m, (vc_cmd_type_e)cmd_type); // enable the cmd type if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to disable the command type(%d). ret(%d)", cmd_type, ret); @@ -980,14 +934,10 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1012,7 +962,6 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) RETVM_IF(NULL == list->list, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Input command list"); int i; - int ret; bool success_save = false; for (i = VC_COMMAND_TYPE_FOREGROUND; i <= VC_COMMAND_TYPE_EXCLUSIVE; i++) { ret = vc_cmd_parser_delete_file(getpid(), i); @@ -1047,14 +996,10 @@ int vc_mgr_unset_command_list(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Unset Command list"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1065,8 +1010,6 @@ int vc_mgr_unset_command_list(void) /* check state */ RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - - int ret = -1; ret = vc_mgr_tidl_request_unset_command(g_vc_m->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request unset command to daemon : %s", __vc_mgr_get_error_code(ret)); @@ -1089,14 +1032,10 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set Command list from file, type(%d)", type); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == file_path, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); @@ -1121,7 +1060,7 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = vc_cmd_parser_delete_file(getpid(), type); + ret = vc_cmd_parser_delete_file(getpid(), type); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to delete file, type(4), ret(%d)", ret); @@ -1144,14 +1083,10 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set preloaded command list"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == file_path, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); SLOG(LOG_INFO, TAG_VCM, "@@@ File path: %s", file_path); @@ -1171,7 +1106,7 @@ int vc_mgr_set_preloaded_commands_from_file(const char* file_path) RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); /* Only support to set background commands for preloaded application */ - int ret = vc_json_set_commands_from_file(file_path, VC_COMMAND_TYPE_BACKGROUND, NULL); + ret = vc_json_set_commands_from_file(file_path, VC_COMMAND_TYPE_BACKGROUND, NULL); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to insert preloaded commands into db"); @@ -1183,14 +1118,10 @@ int vc_mgr_set_audio_type(const char* audio_id) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Set audio type, audio_id(%s)", audio_id); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (NULL == audio_id || !strncmp(audio_id, "", strlen(audio_id))) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Input parameter is NULL"); @@ -1211,7 +1142,6 @@ int vc_mgr_set_audio_type(const char* audio_id) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; /* Request */ ret = vc_mgr_tidl_request_set_audio_type(g_vc_m->handle, audio_id); if (0 != ret) { @@ -1231,14 +1161,10 @@ int vc_mgr_get_audio_type(char** audio_id) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Get audio type"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == audio_id, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -1262,7 +1188,7 @@ int vc_mgr_get_audio_type(char** audio_id) if (NULL == temp) { /* Not initiallized */ - int ret = -1; + ret = -1; while (0 != ret) { ret = vc_mgr_tidl_request_get_audio_type(g_vc_m->handle, &temp); if (0 != ret) { @@ -1289,14 +1215,10 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Foreach current commands"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1324,7 +1246,6 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) int fg_pid = 0; int mgr_pid = 0; - int ret = -1; /* Get foreground pid */ if (0 != vc_mgr_client_get_foreground(g_vc_m, &fg_pid)) { @@ -1463,14 +1384,10 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Set recognition mode = %d", mode); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; /* check vc recognition mode */ if (mode < VC_RECOGNITION_MODE_STOP_BY_SILENCE || mode > VC_RECOGNITION_MODE_MANUAL) { @@ -1498,16 +1415,10 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } - - int ret = -1; + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == mode, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter, mode is NULL ptr"); @@ -1531,14 +1442,10 @@ int vc_mgr_set_private_data(const char* key, const char* data) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Set private data"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == key, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -1556,7 +1463,6 @@ int vc_mgr_set_private_data(const char* key, const char* data) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; ret = vc_mgr_tidl_request_set_private_data(g_vc_m->handle, key, data); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set private data : %s", __vc_mgr_get_error_code(ret)); @@ -1574,14 +1480,10 @@ int vc_mgr_get_private_data(const char* key, char** data) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get private data"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (NULL == key || NULL == data) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid parameter"); @@ -1602,10 +1504,7 @@ int vc_mgr_get_private_data(const char* key, char** data) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; char* temp = NULL; - - ret = vc_mgr_tidl_request_get_private_data(g_vc_m->handle, key, &temp); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get private data request : %s", __vc_mgr_get_error_code(ret)); @@ -1613,7 +1512,6 @@ int vc_mgr_get_private_data(const char* key, char** data) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Get private data, key(%s), data(%s)", key, temp); } - if (NULL != temp) { *data = strdup(temp); free(temp); @@ -1630,14 +1528,10 @@ int vc_mgr_set_domain(const char* domain) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Set domain"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == domain, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -1655,8 +1549,6 @@ int vc_mgr_set_domain(const char* domain) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; - ret = vc_mgr_tidl_request_set_domain(g_vc_m->handle, domain); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set domain request : %s", __vc_mgr_get_error_code(ret)); @@ -1673,14 +1565,10 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] do action"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (type < VC_SEND_EVENT_TYPE_TEXT || VC_SEND_EVENT_TYPE_HAPTIC_EVENT < type) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] send event type is not valid, (%d)", type); @@ -1703,7 +1591,6 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; ret = vc_mgr_tidl_request_do_action(g_vc_m->handle, type, send_event); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to do action request : %s", __vc_mgr_get_error_code(ret)); @@ -1720,14 +1607,10 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] send specific engine request"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] specific engine request. engine app id(%s), event(%s), request(%s)", engine_app_id, event, request); @@ -1754,7 +1637,6 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = -1; ret = vc_mgr_tidl_send_specific_engine_request(g_vc_m->handle, engine_app_id, event, request); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to specific engine request : %s", __vc_mgr_get_error_code(ret)); @@ -1771,14 +1653,10 @@ int vc_mgr_start(bool exclusive_command_option) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Request start"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1814,7 +1692,6 @@ int vc_mgr_start(bool exclusive_command_option) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get disabled command type"); } - int ret; vc_recognition_mode_e recognition_mode = VC_RECOGNITION_MODE_STOP_BY_SILENCE; if (0 != vc_mgr_get_recognition_mode(&recognition_mode)) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get recognition mode"); @@ -1844,14 +1721,10 @@ int vc_mgr_stop(void) { SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Request stop"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1881,7 +1754,7 @@ int vc_mgr_stop(void) return VC_ERROR_IN_PROGRESS_TO_READY; } - int ret = -1; + ret = -1; /* do request */ vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_STOPPING); ret = vc_mgr_tidl_request_stop(g_vc_m->handle); @@ -1901,14 +1774,10 @@ int vc_mgr_cancel(void) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Request cancel"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -1937,7 +1806,7 @@ int vc_mgr_cancel(void) return VC_ERROR_IN_PROGRESS_TO_READY; } - int ret = -1; + ret = -1; vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_CANCELING); ret = vc_mgr_tidl_request_cancel(g_vc_m->handle); if (0 != ret) { @@ -1996,14 +1865,10 @@ int __vc_mgr_set_volume(float volume) int vc_mgr_get_recording_volume(float* volume) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == volume, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2060,14 +1925,10 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Select result"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; /* Do not check state for 'restart continuously' mode */ @@ -2098,7 +1959,6 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) } /* Request */ - int ret = -1; ret = vc_mgr_tidl_send_result_selection(g_vc_m->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to send result selection : %s", __vc_mgr_get_error_code(ret)); @@ -2321,14 +2181,10 @@ void __vc_mgr_cb_speech_detected() int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2350,14 +2206,10 @@ int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) int vc_mgr_unset_all_result_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2375,14 +2227,10 @@ int vc_mgr_unset_all_result_cb(void) int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2402,14 +2250,10 @@ int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) int vc_mgr_unset_result_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2427,14 +2271,10 @@ int vc_mgr_unset_result_cb(void) int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2454,14 +2294,10 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) int vc_mgr_unset_pre_result_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2481,14 +2317,10 @@ int vc_mgr_get_error_message(char** err_msg) { SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] Get error message"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; /* check state */ vc_state_e state; @@ -2504,7 +2336,6 @@ int vc_mgr_get_error_message(char** err_msg) return VC_ERROR_OPERATION_FAILED; } - int ret; ret = vc_mgr_client_get_error_message(g_vc_m, err_msg); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get error message"); @@ -2607,14 +2438,10 @@ static Eina_Bool __vc_mgr_notify_state_changed(void *data) int vc_mgr_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (callback == NULL) return VC_ERROR_INVALID_PARAMETER; @@ -2636,14 +2463,10 @@ int vc_mgr_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) int vc_mgr_unset_state_changed_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2708,14 +2531,10 @@ int __vc_mgr_cb_service_state(int state) int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (callback == NULL) return VC_ERROR_INVALID_PARAMETER; @@ -2737,14 +2556,10 @@ int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, vo int vc_mgr_unset_service_state_changed_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2761,14 +2576,10 @@ int vc_mgr_unset_service_state_changed_cb(void) int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (callback == NULL) return VC_ERROR_INVALID_PARAMETER; @@ -2790,14 +2601,10 @@ int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void int vc_mgr_unset_speech_detected_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2814,14 +2621,10 @@ int vc_mgr_unset_speech_detected_cb(void) int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2842,14 +2645,10 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba int vc_mgr_unset_current_language_changed_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -2867,14 +2666,10 @@ int vc_mgr_unset_current_language_changed_cb(void) int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -2894,14 +2689,10 @@ int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) int vc_mgr_unset_error_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3054,14 +2845,10 @@ int __vc_mgr_cb_feedback_streaming(int pid, int utt_id, vc_feedback_event_e even int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3081,14 +2868,10 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d int vc_mgr_unset_dialog_request_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3106,14 +2889,10 @@ int vc_mgr_unset_dialog_request_cb(void) int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3133,14 +2912,10 @@ int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* us int vc_mgr_unset_private_data_set_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3158,14 +2933,10 @@ int vc_mgr_unset_private_data_set_cb(void) int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3185,14 +2956,10 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba int vc_mgr_unset_private_data_requested_cb(void) { - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3393,13 +3160,10 @@ int __vc_mgr_request_auth_cancel(int pid) int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callback, void* user_data) { - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3457,13 +3221,10 @@ int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] set feedback audio format"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3487,13 +3248,10 @@ int vc_mgr_unset_feedback_audio_format_cb() { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] unset feedback audio format"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { @@ -3515,13 +3273,10 @@ int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] set feedback streaming"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3554,13 +3309,10 @@ int vc_mgr_unset_feedback_streaming_cb() { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] unset feedback streaming"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; pthread_mutex_lock(&g_feedback_streaming_cb_mutex); @@ -3591,14 +3343,10 @@ int vc_mgr_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* us { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] set vc tts streaming callback"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); @@ -3631,14 +3379,10 @@ int vc_mgr_unset_vc_tts_streaming_cb() { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] unset vc tts streaming callback"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; pthread_mutex_lock(&g_vc_tts_streaming_cb_mutex); @@ -3780,13 +3524,10 @@ int vc_mgr_start_feedback(void) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] start feedback"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Request start TTS feedback"); @@ -3820,13 +3561,10 @@ int vc_mgr_stop_feedback(void) { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] stop feedback"); - if (0 != __vc_mgr_get_feature_enabled()) { - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Request stop TTS feedback"); @@ -3840,7 +3578,7 @@ int vc_mgr_stop_feedback(void) RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state); #if 1 - int ret = -1; + ret = -1; while (1) { vc_feedback_data_s* feedback_data = NULL; @@ -3873,14 +3611,10 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e { SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] send utterance status, pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_TTS_UTTERANCE_NONE > utt_status || VC_TTS_UTTERANCE_CANCELED < utt_status || 0 == utt_status) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] utt_status is not valid. (%d)", utt_status); @@ -3901,7 +3635,7 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e vc_mgr_client_get_service_state(g_vc_m, &service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Invalid State: Current service state(%d) is not 'READY'", service_state); - int ret = vc_mgr_tidl_send_utterance_status(pid, utt_id, utt_status); + ret = vc_mgr_tidl_send_utterance_status(pid, utt_id, utt_status); if (0 != ret) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to send utterance status : %s", __vc_mgr_get_error_code(ret)); else @@ -3947,14 +3681,10 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* { SLOG(LOG_INFO, TAG_VCM, "[Manager] Send audio streaming to the engine service, event(%d)", event); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_AUDIO_STREAMING_EVENT_FAIL > event || VC_AUDIO_STREAMING_EVENT_FINISH < event || 0 == event) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] event is invalid parameter (%d)", event); @@ -3964,7 +3694,7 @@ int vc_mgr_send_audio_streaming(vc_audio_streaming_event_e event, unsigned char* RETVM_IF(NULL == buffer, VC_ERROR_INVALID_PARAMETER, TAG_VCM, "[ERROR] Invalid parameter"); vc_state_e state = VC_STATE_NONE; - int ret = vc_mgr_client_get_client_state(g_vc_m, &state); + ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; @@ -3999,14 +3729,10 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) { SLOG(LOG_INFO, TAG_VCM, "[Manager] Set multi assistant mode, mode(%d)", mode); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_AUDIO_STREAMING_MODE_VC_SERVICE > mode || VC_AUDIO_STREAMING_MODE_OUTSIDE < mode) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] mode is invalid parameter (%d)", mode); @@ -4014,7 +3740,7 @@ int vc_mgr_set_audio_streaming_mode(vc_audio_streaming_mode_e mode) } vc_state_e state = VC_STATE_NONE; - int ret = vc_mgr_client_get_client_state(g_vc_m, &state); + ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; @@ -4173,14 +3899,10 @@ int vc_mgr_change_system_volume(vc_system_volume_event_e event) { SLOG(LOG_INFO, TAG_VCM, "[Manager] Change system volume"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; if (VC_SYSTEM_VOLUME_EVENT_CHANGE_FOR_NEARFIELD > event || VC_SYSTEM_VOLUME_EVENT_CHANGE_FOR_FARFIELD < event) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] event is invalid parameter (%d)", event); @@ -4188,7 +3910,7 @@ int vc_mgr_change_system_volume(vc_system_volume_event_e event) } vc_state_e state; - int ret = vc_mgr_client_get_client_state(g_vc_m, &state); + ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; @@ -4211,17 +3933,13 @@ int vc_mgr_recover_system_volume(void) { SLOG(LOG_INFO, TAG_VCM, "[Manager] recover system volume"); - if (0 != __vc_mgr_get_feature_enabled()) { - SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported"); - return VC_ERROR_NOT_SUPPORTED; - } - - if (0 != __vc_mgr_check_privilege()) { - return VC_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_mgr_feature_privilege(); + if (VC_ERROR_NONE != ret) + return ret; vc_state_e state = VC_STATE_NONE; - int ret = vc_mgr_client_get_client_state(g_vc_m, &state); + ret = vc_mgr_client_get_client_state(g_vc_m, &state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; diff --git a/server/vce.c b/server/vce.c index 7ea2327..1b4839f 100644 --- a/server/vce.c +++ b/server/vce.c @@ -172,7 +172,7 @@ static int __vce_check_privilege() return VCE_ERROR_NONE; } -int vce_main(int argc, char** argv, vce_request_callback_s *callback) +int __check_engine_feature_privilege() { if (0 != __vce_get_feature_enabled()) { return VCE_ERROR_NOT_SUPPORTED; @@ -181,11 +181,21 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback) return VCE_ERROR_PERMISSION_DENIED; } + return VCE_ERROR_NONE; +} + +int vce_main(int argc, char** argv, vce_request_callback_s *callback) +{ + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; + SLOG(LOG_DEBUG, TAG_VCD, " "); SLOG(LOG_DEBUG, TAG_VCD, " "); SLOG(LOG_INFO, TAG_VCD, "===== VC Engine Service Initialize"); - int ret = VCE_ERROR_NONE; + ret = VCE_ERROR_NONE; if (!ecore_init()) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail ecore_init()"); @@ -373,14 +383,10 @@ int vce_get_command_count(vce_cmd_h vce_command, int* count) int vce_get_audio_type(char** audio_type) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; ret = vcd_get_audio_type(audio_type); if (0 != ret) { @@ -392,14 +398,10 @@ int vce_get_audio_type(char** audio_type) int vce_set_private_data(const char* key, const char* data) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; if (NULL == key || NULL == data) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter"); @@ -428,14 +430,10 @@ int vce_set_private_data(const char* key, const char* data) int vce_get_private_data(const char* key, char** data) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; if (NULL == key || NULL == data) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter"); @@ -452,14 +450,10 @@ int vce_get_private_data(const char* key, char** data) int vce_start_recording() { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; ret = vcd_start_recording(); if (0 != ret) { @@ -471,14 +465,10 @@ int vce_start_recording() int vce_stop_recording() { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } - - int ret = VCE_ERROR_NONE; + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; ret = vcd_stop_recording(); if (0 != ret) { @@ -490,14 +480,12 @@ int vce_stop_recording() int vce_send_update_status(vce_update_event_e update_event, const char* msg) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; - int ret = vcd_send_update_status(update_event, msg); + ret = vcd_send_update_status(update_event, msg); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send update status"); } @@ -507,19 +495,17 @@ int vce_send_update_status(vce_update_event_e update_event, const char* msg) int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; if (NULL == callback_func) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter"); return VCE_ERROR_INVALID_PARAMETER; } - int ret = vcd_set_private_data_set_cb(callback_func); + ret = vcd_set_private_data_set_cb(callback_func); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data set cb"); } @@ -529,19 +515,17 @@ int vce_set_private_data_set_cb(vce_private_data_set_cb callback_func) int vce_set_private_data_requested_cb(vce_private_data_requested_cb callback_func) { - if (0 != __vce_get_feature_enabled()) { - return VCE_ERROR_NOT_SUPPORTED; - } - if (0 != __vce_check_privilege()) { - return VCE_ERROR_PERMISSION_DENIED; - } + int ret; + ret = __check_engine_feature_privilege(); + if (VCE_ERROR_NONE != ret) + return ret; if (NULL == callback_func) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid parameter"); return VCE_ERROR_INVALID_PARAMETER; } - int ret = vcd_set_private_data_requested_cb(callback_func); + ret = vcd_set_private_data_requested_cb(callback_func); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data requested cb"); } -- 2.7.4 From a0587234c44f725b11922ffc0afca5abfbbb4b08 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Fri, 29 Jul 2022 15:00:12 +0900 Subject: [PATCH 05/16] Fix svace and coverity issues Change-Id: Ic72a37bbbd082b9cbb35f8cafdf9384a6cbd60d6 Signed-off-by: sooyeon --- client/vc_mgr.c | 1 - client/vc_setting_tidl.c | 2 ++ client/vc_tidl.c | 2 ++ common/vc_info_parser.c | 1 - server/vcd_client_data.c | 1 - server/vcd_server.c | 6 +++--- server/vcd_tidl.c | 6 ++++++ 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index e07325f..3746242 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -34,7 +34,6 @@ #include "vc_mgr_tidl.h" #include "vc_mgr_data.h" #include "vc_mgr_player.h" -#include "voice_control.h" #include "voice_control_command.h" #include "voice_control_command_expand.h" #include "voice_control_common.h" diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index 314daf9..e2c8b10 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -73,6 +73,8 @@ static char* __get_engine_appid(void) SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); + free(engine_name); + return appid; } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 33d91a5..2601636 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -82,6 +82,8 @@ static char* __get_engine_appid(void) SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); + free(engine_name); + return appid; } diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 56ce84b..3e7ee27 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -25,7 +25,6 @@ #include "vc_info_parser.h" #include "vc_main.h" #include "voice_control_command.h" -#include "voice_control_command_expand.h" #include "voice_control_common.h" diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 057d919..6620180 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -22,7 +22,6 @@ #include "vcd_config.h" #include "vcd_main.h" -#include "voice_control_command_expand.h" /* Client list */ static GSList* g_client_list = NULL; diff --git a/server/vcd_server.c b/server/vcd_server.c index 8a21bcd..868a681 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1504,7 +1504,7 @@ static void __vcd_cleanup_client(vcd_client_type_e type) } if (0 == ret || mgr_pid > 0) { - SLOG(LOG_INFO, TAG_VCD, "@@@ Clean up %s client ", type ? (type == 1) ? "Widget" : "Manager" : "Normal"); + SLOG(LOG_INFO, TAG_VCD, "@@@ Clean up %s client ", type ? (type == VCD_CLIENT_TYPE_WIDGET) ? "Widget" : "Manager" : "Normal"); if (NULL != client_list && client_count > 0) { for (i = 0; i < client_count; i++) { exist = false; @@ -1513,7 +1513,7 @@ static void __vcd_cleanup_client(vcd_client_type_e type) iter = g_list_nth(g_proc_list, j); if (NULL != iter) { if (*(client_list + i) == GPOINTER_TO_INT(iter->data)) { - SLOG(LOG_INFO, TAG_VCD, "%s pid(%d) is running", type ? (type == 1) ? "Widget" : "Manager" : "Normal", *(client_list + i)); + SLOG(LOG_INFO, TAG_VCD, "%s pid(%d) is running", type ? (type == VCD_CLIENT_TYPE_WIDGET) ? "Widget" : "Manager" : "Normal", *(client_list + i)); exist = true; break; } @@ -1521,7 +1521,7 @@ static void __vcd_cleanup_client(vcd_client_type_e type) } if (false == exist) { - SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == 1) ? "Widget" : "Manager" : "Normal", *(client_list + i)); + SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == VCD_CLIENT_TYPE_WIDGET) ? "Widget" : "Manager" : "Normal", *(client_list + i)); if (VCD_CLIENT_TYPE_NORMAL == type) vcd_server_finalize(*(client_list + i)); else if (VCD_CLIENT_TYPE_WIDGET == type) diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 967ad20..b7ed0b9 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -253,6 +253,8 @@ void __send_signal(bundle* msg, vcd_client_type_e type) } } } + + free(client_list); pthread_mutex_unlock(&g_client_tidl_info_mutex); } /* signal to clients */ else if (VCD_CLIENT_TYPE_WIDGET == type) { @@ -1921,6 +1923,8 @@ int vcdc_send_manager_pid(int manager_pid) ret = vcd_client_get_tidl_list(&client_list, &client_count); if (0 != ret || 0 == client_count) { SLOG(LOG_WARN, TAG_VCD, "[WARNING] There is no client"); + if (NULL != client_list) + free(client_list); return VCD_ERROR_NONE; } @@ -1958,6 +1962,8 @@ int vcdc_send_manager_pid(int manager_pid) bundle_free(msg); } + free(client_list); + return VCD_ERROR_NONE; } -- 2.7.4 From 764c272cc58ca9cb10e63502e7aa23010b6e691a Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 1 Aug 2022 10:46:42 +0900 Subject: [PATCH 06/16] Update version (1.70.5) Change-Id: Idc0ab244ddd26b049995da126cdee2c6e73deb62 Signed-off-by: sooyeon --- CMakeLists.txt | 2 +- packaging/voice-control.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index daa639f..2142161 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ PROJECT(vc) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "${PREFIX}") -SET(VERSION 1.70.4) +SET(VERSION ${VERSION}) FIND_PROGRAM(UNAME NAMES uname) EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index eff8088..415086c 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -1,6 +1,6 @@ Name: voice-control Summary: Voice control client library and daemon -Version: 1.70.4 +Version: 1.70.5 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 -- 2.7.4 From cf8bc6a6522c6d716c13127333647ef959c2d0c5 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 1 Aug 2022 15:11:23 +0900 Subject: [PATCH 07/16] Change type casting using intptr_t Change-Id: I596abafd51aa4af3e537b0df561b40c50cfcbc52 Signed-off-by: sooyeon --- server/vcd_tidl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index b7ed0b9..e4a7426 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -1383,7 +1383,8 @@ int __mgr_tidl_close_connection() */ static void __widget_on_connected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) { - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); + int pid = (intptr_t)user_data; + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); widget_tidl_info->connected = true; widget_tidl_info->connection_requesting = false; @@ -1393,7 +1394,8 @@ static void __widget_on_connected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h static void __widget_on_disconnected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) { - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); + int pid = (intptr_t)user_data; + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); widget_tidl_info->connected = false; widget_tidl_info->connection_requesting = false; @@ -1403,7 +1405,8 @@ static void __widget_on_disconnected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_ static void __widget_on_rejected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) { - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); + int pid = (intptr_t)user_data; + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); widget_tidl_info->connection_requesting = false; @@ -1420,7 +1423,8 @@ static rpc_port_proxy_vcd_widget_proxy_vcd_widget_h __widget_create_rpc_port(con }; rpc_port_proxy_vcd_widget_proxy_vcd_widget_h handle = NULL; - if (0 != rpc_port_proxy_vcd_widget_proxy_vcd_widget_create(engine_app_id, &rpc_callback, (void *)pid, &handle)) { + intptr_t ptr_pid = pid; + if (0 != rpc_port_proxy_vcd_widget_proxy_vcd_widget_create(engine_app_id, &rpc_callback, (void *)ptr_pid, &handle)) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create proxy"); return NULL; } -- 2.7.4 From 9ed976933063155f80c7be99a864c8e72f56e0aa Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 1 Aug 2022 20:20:41 +0900 Subject: [PATCH 08/16] Fix tidl error handling codes Change-Id: I2d4662c41d486335b597d5f3930164150873f5d9 Signed-off-by: sooyeon --- client/vc_mgr_tidl.c | 100 +++++++++++++++++++++++++++----- client/vc_setting_tidl.c | 13 +++-- client/vc_tidl.c | 146 ++++++++++++++++++++++++++++++++++++----------- client/vc_widget_tidl.c | 58 ++++++++++++++++--- 4 files changed, 260 insertions(+), 57 deletions(-) diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index 18b7ac8..a6218ba 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -635,6 +635,15 @@ int vc_mgr_tidl_close_connection() return VC_ERROR_NONE; } +static int __convert_unhandled_error(int ret) +{ + if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { + return VC_ERROR_OPERATION_FAILED; + } + + return ret; +} + static void __request_tidl_connect() { if (g_proxy_tidl_info->connection_requesting) { @@ -755,7 +764,12 @@ int vc_mgr_tidl_request_initialize(int pid, int audio_streaming_mode, int* servi } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, audio_streaming_mode, &tmp_service_state, &tmp_forground, &tmp_daemon_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager initialize : Fail to invoke message, error(%d)", ret); return ret; } @@ -784,7 +798,12 @@ int vc_mgr_tidl_request_finalize(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_finalize(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager finalize : Fail to invoke message, error(%d)", ret); return ret; } @@ -807,7 +826,12 @@ int vc_mgr_tidl_request_set_command(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_command(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set command : Fail to invoke message, error(%d)", ret); return ret; } @@ -830,7 +854,12 @@ int vc_mgr_tidl_request_unset_command(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_unset_command(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager unset command : Fail to invoke message, error(%d)", ret); return ret; } @@ -853,7 +882,12 @@ int vc_mgr_tidl_request_demandable_client(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_demandable_client(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager demandable client : Fail to invoke message, error(%d)", ret); return ret; } @@ -876,7 +910,12 @@ int vc_mgr_tidl_request_set_audio_type(int pid, const char* audio_type) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_audio_type(g_proxy_tidl_info->rpc_h, pid, audio_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set audio type : Fail to invoke message, error(%d)", ret); return ret; } @@ -900,7 +939,12 @@ int vc_mgr_tidl_request_get_audio_type(int pid, char** audio_type) char *tmp = NULL; int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_get_audio_type(g_proxy_tidl_info->rpc_h, pid, &tmp); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get audio type : Fail to invoke message, error(%d)", ret); return ret; } @@ -946,7 +990,12 @@ int vc_mgr_tidl_request_get_private_data(int pid, const char* key, char** data) char *tmp = NULL; int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_get_private_data(g_proxy_tidl_info->rpc_h, pid, key, &tmp); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get private data : Fail to invoke message, error(%d)", ret); return ret; } @@ -972,7 +1021,12 @@ int vc_mgr_tidl_request_set_client_info(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_client_info(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set client info : Fail to invoke message, error(%d)", ret); return ret; } @@ -995,7 +1049,12 @@ int vc_mgr_tidl_request_set_domain(int pid, const char* domain) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_domain(g_proxy_tidl_info->rpc_h, pid, domain); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set domain : Fail to invoke message, error(%d)", ret); return ret; } @@ -1037,7 +1096,12 @@ int vc_mgr_tidl_request_start(int pid, int recognition_mode, bool exclusive_comm } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_start(g_proxy_tidl_info->rpc_h, pid, recognition_mode, exclusive_command_option, start_by_client, disabled_cmd_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager start : Fail to invoke message, error(%d)", ret); return ret; } @@ -1060,7 +1124,12 @@ int vc_mgr_tidl_request_stop(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_stop(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager stop : Fail to invoke message, error(%d)", ret); return ret; } @@ -1083,7 +1152,12 @@ int vc_mgr_tidl_request_cancel(int pid) } int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_cancel(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager cancel : Fail to invoke message, error(%d)", ret); return ret; } diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index e2c8b10..4f33b25 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -286,7 +286,7 @@ int vc_setting_tidl_request_hello() } -static int __covert_unhandled_error(int ret) +static int __convert_unhandled_error(int ret) { if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { return VC_ERROR_OPERATION_FAILED; @@ -304,9 +304,14 @@ int vc_setting_tidl_request_set_language(int pid, const char* language) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_setting_proxy_vc_setting_invoke_set_language(info->rpc_h, pid, language); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc setting set language : Fail to invoke message"); - return __covert_unhandled_error(ret); + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc setting set language : Fail to invoke message (%d)", ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc setting set language : pid(%d), language(%s)", pid, language); diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 2601636..46fc18a 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -421,7 +421,7 @@ int vc_tidl_request_hello() } -static int __covert_unhandled_error(int ret) +static int __convert_unhandled_error(int ret) { if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { return VC_ERROR_OPERATION_FAILED; @@ -439,9 +439,14 @@ int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* d RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : mgr = %d service = %d daemon_pid = %d", *mgr_pid, *service_state, *daemon_pid); //LCOV_EXCL_LINE @@ -458,9 +463,14 @@ int vc_tidl_request_finalize(int pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_finalize(info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", ret); @@ -477,9 +487,14 @@ int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d), cmd_type(%d)", pid, cmd_type); @@ -496,9 +511,14 @@ int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), cmd_type(%d)", pid, cmd_type); @@ -516,9 +536,14 @@ int vc_tidl_request_set_foreground(int pid, bool value) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground : pid(%d), value(%d)", pid, value); @@ -535,9 +560,14 @@ int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* c RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s), credential(%s)", pid, app_id, credential); @@ -555,9 +585,14 @@ int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* u RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous); @@ -574,9 +609,14 @@ int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid); @@ -594,9 +634,14 @@ int vc_tidl_request_auth_enable(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -613,9 +658,14 @@ int vc_tidl_request_auth_disable(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -632,9 +682,14 @@ int vc_tidl_request_auth_start(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -651,9 +706,14 @@ int vc_tidl_request_auth_stop(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -670,9 +730,14 @@ int vc_tidl_request_auth_cancel(int pid, int mgr_pid) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d), mgr_pid(%d)", pid, mgr_pid); @@ -695,9 +760,14 @@ int vc_tidl_request_request_tts(int pid, const char* text, const char* language, } int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_tts(info->rpc_h, pid, text, language, to_vcm, utt_id); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts : pid(%d)", pid); @@ -714,9 +784,14 @@ int vc_tidl_request_cancel_tts(int pid, int utt_id) RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts : pid(%d), utt_id(%d)", pid, utt_id); @@ -733,9 +808,14 @@ int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected"); int ret = rpc_port_proxy_vc_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message. err(%d)", ret); - return __covert_unhandled_error(ret); + return ret; } SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type); diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index dbe49de..f1203ff 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -347,6 +347,15 @@ int vc_widget_tidl_close_connection() return VC_ERROR_NONE; } +static int __convert_unhandled_error(int ret) +{ + if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { + return VC_ERROR_OPERATION_FAILED; + } + + return ret; +} + static void __request_tidl_connect() { if (g_proxy_tidl_info->connection_requesting) { @@ -449,7 +458,12 @@ int vc_widget_tidl_request_initialize(int pid, int* service_state, int* daemon_p int temp_service_state = 0; int temp_daemon_pid = 0; int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, &temp_service_state, &temp_daemon_pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget initialize : Fail to invoke message, error(%d)", ret); pthread_mutex_unlock(&g_w_init_mutex); return ret; @@ -482,7 +496,12 @@ int vc_widget_tidl_request_finalize(int pid) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_finalize(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget finalize : Fail to invoke message, error(%d)", ret); pthread_mutex_unlock(&g_w_init_mutex); return ret; @@ -507,7 +526,12 @@ int vc_widget_tidl_request_start_recording(int pid, bool command) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_start_recording(g_proxy_tidl_info->rpc_h, pid, (int)command); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start recording : Fail to invoke message, error(%d)", ret); return ret; } @@ -550,7 +574,12 @@ int vc_widget_tidl_request_enable_asr_result(int pid, bool enable) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_enable_asr_result(g_proxy_tidl_info->rpc_h, pid, (int)enable); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget enable asr result : Fail to invoke message, error(%d)", ret); return ret; } @@ -573,7 +602,12 @@ int vc_widget_tidl_request_start(int pid, int silence) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_start(g_proxy_tidl_info->rpc_h, pid, silence); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start : Fail to invoke message, error(%d)", ret); return ret; } @@ -596,7 +630,12 @@ int vc_widget_tidl_request_stop(int pid) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_stop(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget stop : Fail to invoke message, error(%d)", ret); return ret; } @@ -619,7 +658,12 @@ int vc_widget_tidl_request_cancel(int pid) } int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_cancel(g_proxy_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { + int exception = get_last_result(); + if (RPC_PORT_ERROR_NONE != exception) { + ret = __convert_unhandled_error(exception); + } + + if (VC_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget cancel : Fail to invoke message, error(%d)", ret); return ret; } -- 2.7.4 From 6f1081df0ac124696d5650b117d3a6a8a17cd51d Mon Sep 17 00:00:00 2001 From: sooyeon Date: Tue, 2 Aug 2022 14:55:20 +0900 Subject: [PATCH 09/16] Remove a logic to check TIDL privileges Change-Id: I82f566421225fd7d6e903fe45a7c30592e9fbf6c Signed-off-by: sooyeon --- client/vc.c | 22 ---------------------- client/vc_mgr.c | 18 ------------------ common/vc_command.c | 22 ---------------------- common/vc_defs.h | 2 -- server/vce.c | 22 ---------------------- 5 files changed, 86 deletions(-) diff --git a/client/vc.c b/client/vc.c index c61a3f0..2d91a48 100644 --- a/client/vc.c +++ b/client/vc.c @@ -178,28 +178,6 @@ static int __vc_check_privilege() //LCOV_EXCL_STOP } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - __check_privilege_deinitialize(); } diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 3746242..fcc1c81 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -246,24 +246,6 @@ static int __vc_mgr_check_privilege() return VC_ERROR_PERMISSION_DENIED; } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - } - - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); - if (false == ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - } - __check_privilege_deinitialize(); } diff --git a/common/vc_command.c b/common/vc_command.c index 34138f3..f61a7a5 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -171,28 +171,6 @@ static int __vc_cmd_check_privilege() //LCOV_EXCL_STOP } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCCMD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VC_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - __check_privilege_deinitialize(); } diff --git a/common/vc_defs.h b/common/vc_defs.h index d9a07b5..e163687 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -278,8 +278,6 @@ extern "C" { #define VC_PRIVILEGE_RECORDER "http://tizen.org/privilege/recorder" #define VC_MGR_PRIVILEGE "http://tizen.org/privilege/voicecontrol.manager" -#define VC_PRIVILEGE_DATASHARING "http://tizen.org/privilege/datasharing" -#define VC_PRIVILEGE_APPMGR "http://tizen.org/privilege/appmanager.launch" /****************************************************************************************** * Definitions for common enum diff --git a/server/vce.c b/server/vce.c index 1b4839f..98826b5 100644 --- a/server/vce.c +++ b/server/vce.c @@ -141,28 +141,6 @@ static int __vce_check_privilege() //LCOV_EXCL_STOP } - ret = __check_privilege(uid, VC_PRIVILEGE_DATASHARING); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_DATASHARING, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VCE_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - - ret = __check_privilege(uid, VC_PRIVILEGE_APPMGR); - if (false == ret) { - //LCOV_EXCL_START - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Permission is denied(%s)(%s)", VC_PRIVILEGE_APPMGR, uid); - __check_privilege_deinitialize(); - g_privilege_allowed = false; - pthread_mutex_unlock(&g_cynara_mutex); - return VCE_ERROR_PERMISSION_DENIED; - //LCOV_EXCL_STOP - } - __check_privilege_deinitialize(); } -- 2.7.4 From 7fdac59d13ac0c25146d6fcb8ff9997ba56c254c Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 3 Aug 2022 17:35:04 +0900 Subject: [PATCH 10/16] Remove unused functions Change-Id: I448171a8c8076a09886c8a5b26bb85d098e34360 Signed-off-by: sooyeon --- client/vc_client.c | 70 ------------------------------------------------------ client/vc_client.h | 8 ------- 2 files changed, 78 deletions(-) diff --git a/client/vc_client.c b/client/vc_client.c index 03e0908..5431b99 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -226,27 +226,6 @@ bool vc_client_is_valid(vc_h vc) return true; } -bool vc_client_is_valid_by_uid(unsigned int uid) -{ - vc_client_s *data = NULL; - - int count = g_slist_length(g_client_list); - int i; - - for (i = 0; i < count; i++) { - data = g_slist_nth_data(g_client_list, i); - - if (NULL != data) { - if (uid == data->vc->handle) - return true; - } - } - - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Fail to get client by vc"); - - return false; -} - //LCOV_EXCL_START int vc_client_get_handle(int pid, vc_h* vc) { @@ -478,27 +457,6 @@ int vc_client_get_client_state(vc_h vc, vc_state_e* state) return VC_ERROR_NONE; } -int vc_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) -{ - vc_client_s *data = NULL; - - int count = g_slist_length(g_client_list); - int i; - - for (i = 0; i < count; i++) { - data = g_slist_nth_data(g_client_list, i); - - if (NULL != data) { - if (uid == data->vc->handle) { - *state = data->current_state; - return VC_ERROR_NONE; - } - } - } - - return VC_ERROR_INVALID_PARAMETER; -} - int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) { vc_client_s* client = __client_get(vc); @@ -545,34 +503,6 @@ int vc_client_get_invocation_name(vc_h vc, char** invocation_name) return VC_ERROR_NONE; } -//LCOV_EXCL_START -int vc_client_set_xid(vc_h vc, int xid) -{ - vc_client_s* client = __client_get(vc); - - /* check handle */ - if (NULL == client) - return VC_ERROR_INVALID_PARAMETER; - - client->xid = xid; - - return VC_ERROR_NONE; -} - -int vc_client_get_xid(vc_h vc, int* xid) -{ - vc_client_s* client = __client_get(vc); - - /* check handle */ - if (NULL == client) - return VC_ERROR_INVALID_PARAMETER; - - *xid = client->xid; - - return VC_ERROR_NONE; -} -//LCOV_EXCL_STOP - int vc_client_set_is_foreground(vc_h vc, bool value) { vc_client_s* client = __client_get(vc); diff --git a/client/vc_client.h b/client/vc_client.h index cfc8d4b..b043d87 100644 --- a/client/vc_client.h +++ b/client/vc_client.h @@ -38,8 +38,6 @@ int vc_client_destroy(vc_h vc); bool vc_client_is_valid(vc_h vc); -bool vc_client_is_valid_by_uid(unsigned int uid); - int vc_client_get_handle(int pid, vc_h* vc); /* @@ -77,18 +75,12 @@ int vc_client_set_client_state(vc_h vc, vc_state_e state); int vc_client_get_client_state(vc_h vc, vc_state_e* state); -int vc_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state); - int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state); int vc_client_set_invocation_name(vc_h vc, const char* invocation_name); int vc_client_get_invocation_name(vc_h vc, char** invocation_name); -int vc_client_set_xid(vc_h vc, int xid); - -int vc_client_get_xid(vc_h vc, int* xid); - int vc_client_set_is_foreground(vc_h vc, bool value); int vc_client_get_is_foreground(vc_h vc, bool* value); -- 2.7.4 From 3df5023e45ee794386d11070b23076f2763d0b3d Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 3 Aug 2022 20:22:03 +0900 Subject: [PATCH 11/16] Remove vc handle in vc and vc_client Change-Id: I6dc961c12e2949539df54251b8a0b4a752620c3a Signed-off-by: sooyeon --- client/vc.c | 399 +++++++++++++++++++-------------------- client/vc_client.c | 536 ++++++++++++++++++++--------------------------------- client/vc_client.h | 80 ++++---- 3 files changed, 431 insertions(+), 584 deletions(-) diff --git a/client/vc.c b/client/vc.c index 2d91a48..4b872c2 100644 --- a/client/vc.c +++ b/client/vc.c @@ -49,7 +49,7 @@ static Ecore_Event_Handler* g_focus_out_handler = NULL; static Ecore_Thread* g_tts_thread = NULL; -static vc_h g_vc = NULL; +static unsigned int g_handle; static int g_daemon_pid = 0; @@ -238,12 +238,12 @@ static void __vc_lang_changed_cb(const char* before_lang, const char* current_la vc_current_language_changed_cb callback; void* lang_user_data; - vc_client_get_current_lang_changed_cb(g_vc, &callback, &lang_user_data); + vc_client_get_current_lang_changed_cb(&callback, &lang_user_data); if (NULL != callback) { - vc_client_use_callback(g_vc); + vc_client_use_callback(); callback(before_lang, current_lang, lang_user_data); - vc_client_not_use_callback(g_vc); + vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "Language changed callback is called"); } else { SLOG(LOG_WARN, TAG_VCC, "[WARNING] Language changed callback is null"); @@ -257,17 +257,17 @@ static Eina_Bool __notify_auth_changed_cb(void *data) vc_auth_state_changed_cb callback = NULL; void* user_data; - vc_client_get_auth_state_changed_cb(g_vc, &callback, &user_data); + vc_client_get_auth_state_changed_cb(&callback, &user_data); vc_auth_state_e before = -1; vc_auth_state_e current = -1; - vc_client_get_before_auth_state(g_vc, &before, ¤t); + vc_client_get_before_auth_state(&before, ¤t); if (NULL != callback) { - vc_client_use_callback(g_vc); + vc_client_use_callback(); callback(before, current, user_data); - vc_client_not_use_callback(g_vc); + vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "Auth state changed callback is called"); } else { SLOG(LOG_WARN, TAG_VCC, "[WARNING] Auth state changed callback is null"); @@ -288,18 +288,18 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); } - ret = vc_client_set_is_foreground(g_vc, true); + ret = vc_client_set_is_foreground(true); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (true) : %d", ret); } /* set authority valid */ vc_auth_state_e state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &state)) { + if (0 != vc_client_get_auth_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); } if (VC_AUTH_STATE_INVALID == state) { - vc_client_set_auth_state(g_vc, VC_AUTH_STATE_VALID); + vc_client_set_auth_state(VC_AUTH_STATE_VALID); /* notify auth changed cb */ ecore_timer_add(0, __notify_auth_changed_cb, NULL); @@ -311,18 +311,18 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (false) : %d", ret); } - ret = vc_client_set_is_foreground(g_vc, false); + ret = vc_client_set_is_foreground(false); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (false) : %d", ret); } /* set authority valid */ vc_auth_state_e state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &state)) { + if (0 != vc_client_get_auth_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); } if (VC_AUTH_STATE_VALID == state) { - vc_client_set_auth_state(g_vc, VC_AUTH_STATE_INVALID); + vc_client_set_auth_state(VC_AUTH_STATE_INVALID); /* notify authority changed cb */ ecore_timer_add(0, __notify_auth_changed_cb, NULL); @@ -347,12 +347,7 @@ int vc_initialize(void) SLOG(LOG_INFO, TAG_VCC, "@@@ [Client] Initialize"); /* check handle */ - if (true == vc_client_is_valid(g_vc)) { - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Already initialized"); //LCOV_EXCL_LINE - return VC_ERROR_NONE; //LCOV_EXCL_LINE - } - - if (0 < vc_client_get_count()) { + if (true == vc_client_is_valid()) { SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Already initialized"); //LCOV_EXCL_LINE return VC_ERROR_NONE; //LCOV_EXCL_LINE } @@ -362,28 +357,29 @@ int vc_initialize(void) return VC_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } - if (0 != vc_client_create(&g_vc)) { + if (0 != vc_client_create()) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create client!!!!!"); //LCOV_EXCL_LINE return VC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } - ret = vc_config_mgr_initialize(g_vc->handle); + g_handle = getpid(); + ret = vc_config_mgr_initialize(g_handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to init config manager : %s", __vc_get_error_code(__vc_convert_config_error_code(ret))); //LCOV_EXCL_LINE - vc_client_destroy(g_vc); //LCOV_EXCL_LINE + vc_client_destroy(); //LCOV_EXCL_LINE return __vc_convert_config_error_code(ret); //LCOV_EXCL_LINE } - ret = vc_config_mgr_set_lang_cb(g_vc->handle, __vc_lang_changed_cb); + ret = vc_config_mgr_set_lang_cb(g_handle, __vc_lang_changed_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set config changed : %d", ret); //LCOV_EXCL_LINE - vc_config_mgr_finalize(g_vc->handle); //LCOV_EXCL_LINE - vc_client_destroy(g_vc); //LCOV_EXCL_LINE + vc_config_mgr_finalize(g_handle); //LCOV_EXCL_LINE + vc_client_destroy(); //LCOV_EXCL_LINE return __vc_convert_config_error_code(ret); } - SLOG(LOG_DEBUG, TAG_VCC, "[Success] pid(%d)", g_vc->handle); + SLOG(LOG_DEBUG, TAG_VCC, "[Success] pid(%d)", g_handle); return VC_ERROR_NONE; @@ -393,7 +389,7 @@ static void __vc_internal_unprepare(void) { /* return authority */ vc_auth_state_e state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &state)) { + if (0 != vc_client_get_auth_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); //LCOV_EXCL_LINE } @@ -403,7 +399,7 @@ static void __vc_internal_unprepare(void) } } - int ret = vc_tidl_request_finalize(g_vc->handle); + int ret = vc_tidl_request_finalize(g_handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } @@ -433,13 +429,13 @@ int vc_deinitialize(void) SLOG(LOG_INFO, TAG_VCC, "@@@ [Client] Deinitialize"); - if (false == vc_client_is_valid(g_vc)) { + if (false == vc_client_is_valid()) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NOT initialized"); return VC_ERROR_INVALID_STATE; } vc_state_e state; - vc_client_get_client_state(g_vc, &state); + vc_client_get_client_state(&state); /* check state */ switch (state) { @@ -453,12 +449,12 @@ int vc_deinitialize(void) g_connect_timer = NULL; } - vc_config_mgr_unset_lang_cb(g_vc->handle); - vc_config_mgr_finalize(g_vc->handle); + vc_config_mgr_unset_lang_cb(g_handle); + vc_config_mgr_finalize(g_handle); /* Free client resources */ - vc_client_destroy(g_vc); - g_vc = NULL; + vc_client_destroy(); + g_handle = 0; break; case VC_STATE_NONE: break; @@ -499,8 +495,8 @@ static Eina_Bool __vc_connect_daemon(void *data) g_connect_timer = NULL; /* check handle */ - if (true == vc_client_is_valid(g_vc)) { - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] g_vc is valid"); + if (true == vc_client_is_valid()) { + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The current client is valid"); /* Initialize DB */ ret = vc_db_initialize(); @@ -513,21 +509,21 @@ static Eina_Bool __vc_connect_daemon(void *data) if (0 != ret) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); //LCOV_EXCL_LINE - ret = vc_tidl_request_initialize(g_vc->handle, &mgr_pid, &service_state, &g_daemon_pid); + ret = vc_tidl_request_initialize(g_handle, &mgr_pid, &service_state, &g_daemon_pid); //LCOV_EXCL_START if (VC_ERROR_ENGINE_NOT_FOUND == ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize : %s", __vc_get_error_code(ret)); - vc_client_set_error(g_vc, VC_ERROR_ENGINE_NOT_FOUND); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); + vc_client_set_error(VC_ERROR_ENGINE_NOT_FOUND); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); return EINA_FALSE; //LCOV_EXCL_STOP } else if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize :%s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE - vc_client_set_error(g_vc, VC_ERROR_TIMED_OUT); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); + vc_client_set_error(VC_ERROR_TIMED_OUT); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); ret = vc_db_finalize(); if (0 != ret) { @@ -541,18 +537,18 @@ static Eina_Bool __vc_connect_daemon(void *data) /* Set service state */ vc_service_state_e previous_service_state; - vc_client_get_service_state(g_vc, &previous_service_state); + vc_client_get_service_state(&previous_service_state); - vc_client_set_service_state(g_vc, (vc_service_state_e)service_state); + vc_client_set_service_state((vc_service_state_e)service_state); vc_service_state_changed_cb service_changed_callback = NULL; void* user_data = NULL; - vc_client_get_service_state_changed_cb(g_vc, &service_changed_callback, &user_data); + vc_client_get_service_state_changed_cb(&service_changed_callback, &user_data); if (NULL != service_changed_callback) { - vc_client_use_callback(g_vc); + vc_client_use_callback(); service_changed_callback(previous_service_state, service_state, user_data); - vc_client_not_use_callback(g_vc); + vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "Service state changed callback is called"); //LCOV_EXCL_LINE } else { SLOG(LOG_WARN, TAG_VCC, "[WARNING] Service state changed callback is null"); //LCOV_EXCL_LINE @@ -577,30 +573,30 @@ static Eina_Bool __vc_connect_daemon(void *data) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); //LCOV_EXCL_LINE } - ret = vc_client_set_is_foreground(g_vc, true); + ret = vc_client_set_is_foreground(true); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (true) : %d", ret); //LCOV_EXCL_LINE } /* set authority valid */ vc_auth_state_e state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &state)) { + if (0 != vc_client_get_auth_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); //LCOV_EXCL_LINE } if (VC_AUTH_STATE_INVALID == state) { - vc_client_set_auth_state(g_vc, VC_AUTH_STATE_VALID); + vc_client_set_auth_state(VC_AUTH_STATE_VALID); /* notify auth changed cb */ ecore_idler_add(__notify_auth_changed_cb, NULL); } } - vc_client_set_client_state(g_vc, VC_STATE_READY); - ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc); + vc_client_set_client_state(VC_STATE_READY); + ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, NULL); - vc_client_set_mgr_pid(g_vc, mgr_pid); + vc_client_set_mgr_pid(mgr_pid); } else { - SLOG(LOG_ERROR, TAG_VCC, "[Not ERROR] g_vc is not valid. It is destroyed."); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_VCC, "[Not ERROR] The current client is not valid. It is destroyed."); //LCOV_EXCL_LINE return EINA_FALSE; } @@ -663,7 +659,7 @@ int vc_prepare(void) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); //LCOV_EXCL_LINE return VC_ERROR_INVALID_STATE; } @@ -688,7 +684,7 @@ int vc_prepare_sync(void) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Prepare"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -717,7 +713,7 @@ int vc_unprepare(void) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unprepare"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -727,8 +723,8 @@ int vc_unprepare(void) __vc_internal_unprepare(); - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); - ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc); + vc_client_set_client_state(VC_STATE_INITIALIZED); + ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, NULL); SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Unprepare DONE"); @@ -745,7 +741,7 @@ int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -774,7 +770,7 @@ int vc_get_current_language(char** language) RETVM_IF(NULL == language, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -803,7 +799,7 @@ int vc_get_state(vc_state_e* state) RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e temp; - if (0 != vc_client_get_client_state(g_vc, &temp)) { + if (0 != vc_client_get_client_state(&temp)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not valid"); return VC_ERROR_INVALID_STATE; } @@ -837,7 +833,7 @@ int vc_get_service_state(vc_service_state_e* state) RETVM_IF(NULL == state, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e temp; - if (0 != vc_client_get_client_state(g_vc, &temp)) { + if (0 != vc_client_get_client_state(&temp)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -846,7 +842,7 @@ int vc_get_service_state(vc_service_state_e* state) /* get service state */ vc_service_state_e service_state; - if (0 != vc_client_get_service_state(g_vc, &service_state)) { + if (0 != vc_client_get_service_state(&service_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get service state"); //LCOV_EXCL_LINE return VC_ERROR_OPERATION_FAILED; } @@ -882,7 +878,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) *vc_sys_cmd_list = NULL; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -892,7 +888,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); @@ -903,11 +899,11 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) ret = -1; bool is_prepared = false; do { - ret = vc_tidl_request_is_system_command_valid(g_vc->handle, &is_sys_cmd_valid); + ret = vc_tidl_request_is_system_command_valid(g_handle, &is_sys_cmd_valid); if (0 != ret) { //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -929,7 +925,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) } while (0 != ret); int mgr_pid = -1; - ret = vc_client_get_mgr_pid(g_vc, &mgr_pid); + ret = vc_client_get_mgr_pid(&mgr_pid); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get the manager pid"); //LCOV_EXCL_LINE return VC_ERROR_OPERATION_FAILED; @@ -994,7 +990,7 @@ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Is command format supported"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1024,7 +1020,7 @@ int vc_is_command_format_supported(vc_cmd_format_e format, bool* support) static int __vc_get_invocation_name(char** invocation_name) { - int ret = vc_client_get_invocation_name(g_vc, invocation_name); + int ret = vc_client_get_invocation_name(invocation_name); if (0 != ret) { SLOG(LOG_WARN, TAG_VCC, "Fail to get invocation name"); //LCOV_EXCL_LINE return ret; //LCOV_EXCL_LINE @@ -1081,17 +1077,17 @@ static int __vc_get_invocation_name(char** invocation_name) return VC_ERROR_NONE; } -void __set_command(vc_h vc, vc_cmd_type_e type) +void __set_command(vc_cmd_type_e type) { int ret = -1; int count = 0; bool is_prepared = false; do { - ret = vc_tidl_request_set_command(vc->handle, type); + ret = vc_tidl_request_set_command(g_handle, type); if (0 != ret) { //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -1125,7 +1121,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) RETVM_IF(NULL == vc_cmd_list, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Input parameter is NULL"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1164,7 +1160,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save command list : %s", __vc_get_error_code(ret)); } else { - __set_command(g_vc, (vc_cmd_type_e)type); + __set_command((vc_cmd_type_e)type); } FREE(invocation_name); @@ -1185,7 +1181,7 @@ int vc_unset_command_list(int type) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1200,11 +1196,11 @@ int vc_unset_command_list(int type) ret = -1; bool is_prepared = false; while (0 != ret) { - ret = vc_tidl_request_unset_command(g_vc->handle, (vc_cmd_type_e)type); + ret = vc_tidl_request_unset_command(g_handle, (vc_cmd_type_e)type); if (0 != ret) { //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -1245,7 +1241,7 @@ int vc_set_command_list_from_file(const char* file_path, int type) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1280,7 +1276,7 @@ int vc_set_command_list_from_file(const char* file_path, int type) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set commands from file : %s", __vc_get_error_code(ret)); } else { - __set_command(g_vc, (vc_cmd_type_e)type); + __set_command((vc_cmd_type_e)type); } FREE(invocation_name); @@ -1550,19 +1546,17 @@ int vc_request_cancel(void) //LCOV_EXCL_START static void __vc_notify_error(void *data) { - vc_h vc = (vc_h)data; - vc_error_cb callback = NULL; void* user_data; int reason; - vc_client_get_error_cb(vc, &callback, &user_data); - vc_client_get_error(vc, &reason); + vc_client_get_error_cb(&callback, &user_data); + vc_client_get_error(&reason); if (NULL != callback) { - vc_client_use_callback(vc); + vc_client_use_callback(); callback(reason, user_data); - vc_client_not_use_callback(vc); + vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "Error callback is called"); } else { SLOG(LOG_WARN, TAG_VCC, "[WARNING] Error callback is null"); @@ -1572,7 +1566,7 @@ static void __vc_notify_error(void *data) int __vc_cb_error(int reason, int daemon_pid, char* msg) { vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid client"); return VC_ERROR_INVALID_PARAMETER; } @@ -1590,8 +1584,8 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) if (VC_ERROR_SERVICE_RESET == reason) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] VC daemon reset"); - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); - ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc); + vc_client_set_client_state(VC_STATE_INITIALIZED); + ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, NULL); if (0 != vc_prepare()) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to prepare"); @@ -1600,8 +1594,8 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Error reason(%d), msg(%s)", reason, msg); - vc_client_set_error(g_vc, reason); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); + vc_client_set_error(reason); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); return VC_ERROR_NONE; } @@ -1609,39 +1603,30 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) int __vc_cb_error_to_app(int pid, int reason, const char* msg) { SLOG(LOG_INFO, TAG_VCC, "[INFO] send error to app(%d)", pid); - - vc_h vc; - if (0 != vc_client_get_handle(pid, &vc)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get vc handle"); - return VC_ERROR_INVALID_PARAMETER; - } - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Error reason(%d), msg(%s)", reason, msg); - vc_client_set_error(vc, reason); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)vc); + vc_client_set_error(reason); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); return VC_ERROR_NONE; } static void __vc_notify_state_changed(void *data) { - vc_h vc = (vc_h)data; - vc_state_changed_cb changed_callback = NULL; void* user_data; - vc_client_get_state_changed_cb(vc, &changed_callback, &user_data); + vc_client_get_state_changed_cb(&changed_callback, &user_data); vc_state_e current_state; vc_state_e before_state; - vc_client_get_before_state(vc, ¤t_state, &before_state); + vc_client_get_before_state(¤t_state, &before_state); if (NULL != changed_callback) { - vc_client_use_callback(vc); + vc_client_use_callback(); changed_callback(before_state, current_state, user_data); - vc_client_not_use_callback(vc); + vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "State changed callback is called"); } else { SLOG(LOG_WARN, TAG_VCC, "[WARNING] State changed callback is null"); @@ -1657,7 +1642,7 @@ static Eina_Bool __vc_notify_result(void *data) vc_result_cb callback = NULL; void* user_data = NULL; - vc_client_get_result_cb(g_vc, &callback, &user_data); + vc_client_get_result_cb(&callback, &user_data); RETVM_IF(NULL == callback, EINA_FALSE, TAG_VCC, "[ERROR] Client result callback is NULL"); @@ -1672,9 +1657,9 @@ static Eina_Bool __vc_notify_result(void *data) vc_cmd_print_list(vc_cmd_list); - vc_client_use_callback(g_vc); + vc_client_use_callback(); callback(event, vc_cmd_list, temp_text, user_data); - vc_client_not_use_callback(g_vc); + vc_client_not_use_callback(); SLOG(LOG_INFO, TAG_VCC, "Client result callback called"); @@ -1703,7 +1688,7 @@ int vc_get_result(vc_result_cb callback, void* user_data) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1735,9 +1720,9 @@ int vc_get_result(vc_result_cb callback, void* user_data) vc_cmd_print_list(vc_cmd_list); - vc_client_use_callback(g_vc); + vc_client_use_callback(); callback(event, vc_cmd_list, temp_text, user_data); - vc_client_not_use_callback(g_vc); + vc_client_not_use_callback(); vc_cmd_list_destroy(vc_cmd_list, true); vc_cmd_list = NULL; @@ -1760,7 +1745,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client result callback is NULL"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set result callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1768,7 +1753,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_result_cb(g_vc, callback, user_data); + vc_client_set_result_cb(callback, user_data); return VC_ERROR_NONE; } @@ -1781,7 +1766,7 @@ int vc_unset_result_cb(void) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1789,7 +1774,7 @@ int vc_unset_result_cb(void) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_result_cb(g_vc, NULL, NULL); + vc_client_set_result_cb(NULL, NULL); return VC_ERROR_NONE; } @@ -1799,7 +1784,7 @@ int __vc_cb_service_state(int state) { vc_service_state_e current_state = (vc_service_state_e)state; vc_service_state_e before_state; - vc_client_get_service_state(g_vc, &before_state); + vc_client_get_service_state(&before_state); if (current_state == before_state) { return VC_ERROR_NONE; @@ -1809,16 +1794,16 @@ int __vc_cb_service_state(int state) before_state, current_state); /* Save service state */ - vc_client_set_service_state(g_vc, current_state); + vc_client_set_service_state(current_state); vc_service_state_changed_cb callback = NULL; void* service_user_data; - vc_client_get_service_state_changed_cb(g_vc, &callback, &service_user_data); + vc_client_get_service_state_changed_cb(&callback, &service_user_data); if (NULL != callback) { - vc_client_use_callback(g_vc); + vc_client_use_callback(); callback((vc_service_state_e)before_state, (vc_service_state_e)current_state, service_user_data); - vc_client_not_use_callback(g_vc); + vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "Service state changed callback is called"); } else { SLOG(LOG_WARN, TAG_VCC, "[WARNING] Service state changed callback is null"); @@ -1832,7 +1817,7 @@ int __vc_cb_manager_pid(int manager_pid) SLOG(LOG_DEBUG, TAG_VCC, "Manager pid is changed : %d", manager_pid); //LCOV_EXCL_LINE /* Save service state */ - vc_client_set_mgr_pid(g_vc, manager_pid); + vc_client_set_mgr_pid(manager_pid); return VC_ERROR_NONE; } @@ -1848,7 +1833,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client service state changed callback is NULL"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set result callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1856,7 +1841,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_service_state_changed_cb(g_vc, callback, user_data); + vc_client_set_service_state_changed_cb(callback, user_data); return VC_ERROR_NONE; } @@ -1869,7 +1854,7 @@ int vc_unset_service_state_changed_cb(void) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset result callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1877,7 +1862,7 @@ int vc_unset_service_state_changed_cb(void) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_service_state_changed_cb(g_vc, NULL, NULL); + vc_client_set_service_state_changed_cb(NULL, NULL); return VC_ERROR_NONE; } @@ -1892,7 +1877,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client state changed callback is NULL"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set state changed callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1900,7 +1885,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_state_changed_cb(g_vc, callback, user_data); + vc_client_set_state_changed_cb(callback, user_data); return VC_ERROR_NONE; } @@ -1913,7 +1898,7 @@ int vc_unset_state_changed_cb(void) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset state changed callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1921,7 +1906,7 @@ int vc_unset_state_changed_cb(void) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_state_changed_cb(g_vc, NULL, NULL); + vc_client_set_state_changed_cb(NULL, NULL); return VC_ERROR_NONE; } @@ -1936,7 +1921,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client current language changed callback is NULL"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set current language changed : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1944,7 +1929,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_current_lang_changed_cb(g_vc, callback, user_data); + vc_client_set_current_lang_changed_cb(callback, user_data); return VC_ERROR_NONE; } @@ -1957,7 +1942,7 @@ int vc_unset_current_language_changed_cb(void) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset current language changed : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1965,7 +1950,7 @@ int vc_unset_current_language_changed_cb(void) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_current_lang_changed_cb(g_vc, NULL, NULL); + vc_client_set_current_lang_changed_cb(NULL, NULL); return VC_ERROR_NONE; } @@ -1980,7 +1965,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Client error callback is NULL"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set error callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -1988,7 +1973,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_error_cb(g_vc, callback, user_data); + vc_client_set_error_cb(callback, user_data); return VC_ERROR_NONE; } @@ -2001,7 +1986,7 @@ int vc_unset_error_cb(void) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset error callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2009,7 +1994,7 @@ int vc_unset_error_cb(void) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_error_cb(g_vc, NULL, NULL); + vc_client_set_error_cb(NULL, NULL); return VC_ERROR_NONE; } @@ -2024,7 +2009,7 @@ int vc_set_invocation_name(const char* name) vc_state_e state; SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set invocation name"); - ret = vc_client_get_client_state(g_vc, &state); + ret = vc_client_get_client_state(&state); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return ret; @@ -2033,7 +2018,7 @@ int vc_set_invocation_name(const char* name) /* check state */ RETVM_IF(state != VC_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", state); - ret = vc_client_set_invocation_name(g_vc, name); + ret = vc_client_set_invocation_name(name); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set invocation name"); } @@ -2051,7 +2036,7 @@ int vc_set_server_dialog(const char* app_id, const char* credential) RETVM_IF(NULL == credential, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Credential is NULL"); - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return VC_ERROR_INVALID_STATE; } @@ -2061,7 +2046,7 @@ int vc_set_server_dialog(const char* app_id, const char* credential) /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); @@ -2088,7 +2073,7 @@ int vc_set_server_dialog(const char* app_id, const char* credential) ret = vc_tidl_request_set_server_dialog(pid, tmp_appid, credential); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -2125,7 +2110,7 @@ int vc_unset_server_dialog(const char* app_id) if (VC_ERROR_NONE != ret) return ret; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return VC_ERROR_INVALID_STATE; } @@ -2135,7 +2120,7 @@ int vc_unset_server_dialog(const char* app_id) /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); @@ -2160,7 +2145,7 @@ int vc_unset_server_dialog(const char* app_id) ret = vc_tidl_request_set_server_dialog(pid, tmp_appid, credential); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -2197,7 +2182,7 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta if (VC_ERROR_NONE != ret) return ret; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return VC_ERROR_INVALID_STATE; } @@ -2207,7 +2192,7 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start); @@ -2228,7 +2213,7 @@ int vc_auth_enable(void) { /* check state */ vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2236,7 +2221,7 @@ int vc_auth_enable(void) /* check already authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &auth_state)) { + if (0 != vc_client_get_auth_state(&auth_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2244,19 +2229,19 @@ int vc_auth_enable(void) /* request authority */ int mgr_pid = -1; - if (0 != vc_client_get_mgr_pid(g_vc, &mgr_pid)) { + if (0 != vc_client_get_mgr_pid(&mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get mgr info"); return VC_ERROR_OPERATION_FAILED; } - if (0 != vc_tidl_request_auth_enable(g_vc->handle, mgr_pid)) { + if (0 != vc_tidl_request_auth_enable(g_handle, mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to authority enabled"); return VC_ERROR_OPERATION_FAILED; } /* set authority into handle */ bool is_foreground = false; - if (0 != vc_client_get_is_foreground(g_vc, &is_foreground)) { + if (0 != vc_client_get_is_foreground(&is_foreground)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get is_foreground"); return VC_ERROR_OPERATION_FAILED; } @@ -2267,7 +2252,7 @@ int vc_auth_enable(void) auth_state = VC_AUTH_STATE_INVALID; } - if (0 != vc_client_set_auth_state(g_vc, auth_state)) { + if (0 != vc_client_set_auth_state(auth_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set auth state"); return VC_ERROR_OPERATION_FAILED; } @@ -2283,7 +2268,7 @@ int vc_auth_disable(void) { /* check state */ vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2291,7 +2276,7 @@ int vc_auth_disable(void) /* check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &auth_state)) { + if (0 != vc_client_get_auth_state(&auth_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2303,18 +2288,18 @@ int vc_auth_disable(void) /* request return authority by tidl */ int mgr_pid = -1; - if (0 != vc_client_get_mgr_pid(g_vc, &mgr_pid)) { + if (0 != vc_client_get_mgr_pid(&mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get mgr info"); return VC_ERROR_OPERATION_FAILED; } - if (0 != vc_tidl_request_auth_disable(g_vc->handle, mgr_pid)) { + if (0 != vc_tidl_request_auth_disable(g_handle, mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to authority disable"); return VC_ERROR_OPERATION_FAILED; } /* unset authority from handle */ - if (0 != vc_client_set_auth_state(g_vc, VC_AUTH_STATE_NONE)) { + if (0 != vc_client_set_auth_state(VC_AUTH_STATE_NONE)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set auth state"); return VC_ERROR_OPERATION_FAILED; } @@ -2330,7 +2315,7 @@ int vc_auth_get_state(vc_auth_state_e* state) { /* check state */ vc_state_e vc_state; - if (0 != vc_client_get_client_state(g_vc, &vc_state)) { + if (0 != vc_client_get_client_state(&vc_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2338,7 +2323,7 @@ int vc_auth_get_state(vc_auth_state_e* state) /* get authority */ vc_auth_state_e temp = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &temp)) { + if (0 != vc_client_get_auth_state(&temp)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2360,14 +2345,14 @@ int vc_auth_set_state_changed_cb(vc_auth_state_changed_cb callback, void* user_d /* check auth */ vc_auth_state_e auth_state; - if (0 != vc_client_get_auth_state(g_vc, &auth_state)) { + if (0 != vc_client_get_auth_state(&auth_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } RETVM_IF(VC_AUTH_STATE_NONE == auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Auth is not enabled"); /* set cb into handle */ - if (0 != vc_client_set_auth_state_changed_cb(g_vc, callback, user_data)) { + if (0 != vc_client_set_auth_state_changed_cb(callback, user_data)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set auth state changed cb"); return VC_ERROR_OPERATION_FAILED; } @@ -2381,14 +2366,14 @@ int vc_auth_unset_state_changed_cb(void) { /* check auth */ vc_auth_state_e auth_state; - if (0 != vc_client_get_auth_state(g_vc, &auth_state)) { + if (0 != vc_client_get_auth_state(&auth_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Handle is not available"); return VC_ERROR_INVALID_STATE; } RETVM_IF(VC_AUTH_STATE_NONE == auth_state, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Auth is not enabled"); /* unset cb from handle */ - if (0 != vc_client_unset_auth_state_changed_cb(g_vc)) { + if (0 != vc_client_unset_auth_state_changed_cb()) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to unset auth state changed cb"); return VC_ERROR_OPERATION_FAILED; } @@ -2403,7 +2388,7 @@ int vc_auth_start(void) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request start"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2413,12 +2398,12 @@ int vc_auth_start(void) /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); /* Check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &auth_state)) { + if (0 != vc_client_get_auth_state(&auth_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } @@ -2426,7 +2411,7 @@ int vc_auth_start(void) /* get mgr_pid */ int mgr_pid = -1; - if (0 != vc_client_get_mgr_pid(g_vc, &mgr_pid)) { + if (0 != vc_client_get_mgr_pid(&mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get mgr info"); return VC_ERROR_OPERATION_FAILED; } @@ -2436,10 +2421,10 @@ int vc_auth_start(void) bool is_prepared = false; /* Request */ while (0 != ret) { - ret = vc_tidl_request_auth_start(g_vc->handle, mgr_pid); + ret = vc_tidl_request_auth_start(g_handle, mgr_pid); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -2471,7 +2456,7 @@ int vc_auth_stop(void) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request stop"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2481,12 +2466,12 @@ int vc_auth_stop(void) /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_RECORDING, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'RECORDING'", service_state); /* Check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &auth_state)) { + if (0 != vc_client_get_auth_state(&auth_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } @@ -2494,7 +2479,7 @@ int vc_auth_stop(void) /* get mgr_pid */ int mgr_pid = -1; - if (0 != vc_client_get_mgr_pid(g_vc, &mgr_pid)) { + if (0 != vc_client_get_mgr_pid(&mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get mgr info"); return VC_ERROR_OPERATION_FAILED; } @@ -2504,10 +2489,10 @@ int vc_auth_stop(void) bool is_prepared = false; /* do request */ while (0 != ret) { - ret = vc_tidl_request_auth_stop(g_vc->handle, mgr_pid); + ret = vc_tidl_request_auth_stop(g_handle, mgr_pid); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -2539,7 +2524,7 @@ int vc_auth_cancel(void) SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Request cancel"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2549,7 +2534,7 @@ int vc_auth_cancel(void) /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); if (service_state != VC_SERVICE_STATE_RECORDING && service_state != VC_SERVICE_STATE_PROCESSING) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid State: service state is not 'RECORDING' or 'PROCESSING'"); return VC_ERROR_INVALID_STATE; @@ -2557,7 +2542,7 @@ int vc_auth_cancel(void) /* Check authority */ vc_auth_state_e auth_state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &auth_state)) { + if (0 != vc_client_get_auth_state(&auth_state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); return VC_ERROR_OPERATION_FAILED; } @@ -2565,7 +2550,7 @@ int vc_auth_cancel(void) /* get mgr_pid */ int mgr_pid = -1; - if (0 != vc_client_get_mgr_pid(g_vc, &mgr_pid)) { + if (0 != vc_client_get_mgr_pid(&mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get mgr info"); return VC_ERROR_OPERATION_FAILED; } @@ -2574,10 +2559,10 @@ int vc_auth_cancel(void) int count = 0; bool is_prepared = false; while (0 != ret) { - ret = vc_tidl_request_auth_cancel(g_vc->handle, mgr_pid); + ret = vc_tidl_request_auth_cancel(g_handle, mgr_pid); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -2611,7 +2596,7 @@ static void __start_tts_streaming_thread(void* data, Ecore_Thread* thread) vc_tts_streaming_cb callback = NULL; void* user_data = NULL; - vc_client_get_tts_streaming_cb(g_vc, &callback, &user_data); + vc_client_get_tts_streaming_cb(&callback, &user_data); RETM_IF(NULL == callback, TAG_VCC, "[WARNING] tts streaming callback is null"); while (1) { @@ -2648,9 +2633,9 @@ static void __start_tts_streaming_thread(void* data, Ecore_Thread* thread) if (NULL != tts_data) { SLOG(LOG_DEBUG, TAG_VCC, "tts streaming callback is called"); - vc_client_use_callback(g_vc); + vc_client_use_callback(); callback(tts_data->event, tts_data->data, tts_data->data_size, tts_data->utt_id, user_data); - vc_client_not_use_callback(g_vc); + vc_client_not_use_callback(); /* If no tts data and EVENT_FINISH */ if (0 >= vc_data_get_tts_data_size() && VC_TTS_EVENT_FINISH == tts_data->event) { @@ -2724,7 +2709,7 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i if (VC_ERROR_NONE != ret) return ret; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return VC_ERROR_INVALID_STATE; } @@ -2734,7 +2719,7 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ tts request, pid(%d), text(%s), language(%s), to_vc_manager(%d)", pid, text, language, to_vc_manager); @@ -2745,7 +2730,7 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i ret = vc_tidl_request_request_tts(pid, text, language, to_vc_manager, utt_id); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -2782,7 +2767,7 @@ int vc_tts_cancel(int utt_id) if (VC_ERROR_NONE != ret) return ret; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return VC_ERROR_INVALID_STATE; } @@ -2792,7 +2777,7 @@ int vc_tts_cancel(int utt_id) /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ tts cancel, pid(%d), utt_id(%d)", pid, utt_id); @@ -2808,7 +2793,7 @@ int vc_tts_cancel(int utt_id) ret = vc_tidl_request_cancel_tts(pid, utt_id); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -2845,7 +2830,7 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, if (VC_ERROR_NONE != ret) return ret; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] A handle is not valid"); return VC_ERROR_INVALID_STATE; } @@ -2855,7 +2840,7 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, /* Check service state */ vc_service_state_e service_state = -1; - vc_client_get_service_state(g_vc, &service_state); + vc_client_get_service_state(&service_state); RETVM_IF(service_state != VC_SERVICE_STATE_READY, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: service state(%d) is not 'READY'", service_state); SLOG(LOG_DEBUG, TAG_VCC, "@@@ get tts audio format, pid(%d)", pid); @@ -2866,7 +2851,7 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, ret = vc_tidl_request_get_tts_audio_format(pid, rate, channel, audio_type); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { - vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED); + vc_client_set_client_state(VC_STATE_INITIALIZED); if (0 == vc_prepare_sync()) { is_prepared = true; SLOG(LOG_INFO, TAG_VCC, "[INFO] Success vc_prepare_sync"); @@ -2902,7 +2887,7 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) return VC_ERROR_INVALID_PARAMETER; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set tts streaming callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2910,7 +2895,7 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_tts_streaming_cb(g_vc, callback, user_data); + vc_client_set_tts_streaming_cb(callback, user_data); return VC_ERROR_NONE; } @@ -2923,7 +2908,7 @@ int vc_tts_unset_streaming_cb(void) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset tts streaming callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2931,7 +2916,7 @@ int vc_tts_unset_streaming_cb(void) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_tts_streaming_cb(g_vc, NULL, NULL); + vc_client_set_tts_streaming_cb(NULL, NULL); return VC_ERROR_NONE; } @@ -2941,13 +2926,13 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) vc_tts_utterance_status_cb callback = NULL; void* user_data = NULL; - vc_client_get_tts_utterance_status_cb(g_vc, &callback, &user_data); + vc_client_get_tts_utterance_status_cb(&callback, &user_data); RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Utterance status callback is null"); SLOG(LOG_DEBUG, TAG_VCC, "Utterance status callback is called"); - vc_client_use_callback(g_vc); + vc_client_use_callback(); callback(utt_id, (vc_tts_utterance_status_e)utt_status, user_data); - vc_client_not_use_callback(g_vc); + vc_client_not_use_callback(); return VC_ERROR_NONE; } @@ -2962,7 +2947,7 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us RETVM_IF(NULL == callback, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Utterance status callback is null"); vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Set tts utterance status callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2970,7 +2955,7 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_tts_utterance_status_cb(g_vc, callback, user_data); + vc_client_set_tts_utterance_status_cb(callback, user_data); return VC_ERROR_NONE; } @@ -2983,7 +2968,7 @@ int vc_tts_unset_utterance_status_cb(void) return ret; vc_state_e state; - if (0 != vc_client_get_client_state(g_vc, &state)) { + if (0 != vc_client_get_client_state(&state)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Unset tts utterance status callback : A handle is not available"); return VC_ERROR_INVALID_STATE; } @@ -2991,7 +2976,7 @@ int vc_tts_unset_utterance_status_cb(void) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); - vc_client_set_tts_utterance_status_cb(g_vc, NULL, NULL); + vc_client_set_tts_utterance_status_cb(NULL, NULL); return VC_ERROR_NONE; } diff --git a/client/vc_client.c b/client/vc_client.c index 5431b99..4aacf8a 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -19,7 +19,6 @@ typedef struct { /* base info */ - vc_h vc; int pid; unsigned int uid; /*<< unique id = pid + handle */ int xid; /*<< main X window id */ @@ -74,152 +73,92 @@ typedef struct { char* invocation_name; } vc_client_s; -/* client list */ -static GSList *g_client_list = NULL; +static vc_client_s *g_client = NULL; -static vc_client_s* __client_get(vc_h vc) +int vc_client_create(void) { - if (vc == NULL) { - return NULL; - } - - vc_client_s *data = NULL; - - int count = g_slist_length(g_client_list); - int i; - - for (i = 0; i < count; i++) { - data = g_slist_nth_data(g_client_list, i); - - if (NULL != data) { - if (vc->handle == data->vc->handle) { - return data; - } - } - } - - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Fail to get client by vc"); //LCOV_EXCL_LINE - - return NULL; -} - -int vc_client_create(vc_h* vc) -{ - vc_client_s *client = NULL; - - client = (vc_client_s*)calloc(1, sizeof(vc_client_s)); - if (NULL == client) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE - return VC_ERROR_OUT_OF_MEMORY; + if (NULL != g_client) { + SLOG(LOG_WARN, TAG_VCC, "[WARNING] A client is already exist."); + return VC_ERROR_NONE; } - vc_h temp = (vc_h)calloc(1, sizeof(struct vc_s)); - if (NULL == temp) { + g_client = (vc_client_s*)calloc(1, sizeof(vc_client_s)); + if (NULL == g_client) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE - free(client); return VC_ERROR_OUT_OF_MEMORY; } - temp->handle = getpid(); - /* initialize client data */ - client->vc = temp; - client->pid = getpid(); - client->uid = temp->handle; - client->xid = -1; - - client->result_cb = NULL; - client->result_user_data = NULL; - client->service_state_changed_cb = NULL; - client->service_state_changed_user_data = NULL; - client->state_changed_cb = NULL; - client->state_changed_user_data = NULL; - client->current_lang_changed_cb = NULL; - client->current_lang_changed_user_data = NULL; - client->error_cb = NULL; - client->error_user_data = NULL; - client->tts_streaming_cb = NULL; - client->tts_streaming_user_data = NULL; - client->tts_utterance_status_cb = NULL; - client->tts_utterance_status_user_data = NULL; + g_client->pid = getpid(); + g_client->uid = getpid(); + g_client->xid = -1; + + g_client->result_cb = NULL; + g_client->result_user_data = NULL; + g_client->service_state_changed_cb = NULL; + g_client->service_state_changed_user_data = NULL; + g_client->state_changed_cb = NULL; + g_client->state_changed_user_data = NULL; + g_client->current_lang_changed_cb = NULL; + g_client->current_lang_changed_user_data = NULL; + g_client->error_cb = NULL; + g_client->error_user_data = NULL; + g_client->tts_streaming_cb = NULL; + g_client->tts_streaming_user_data = NULL; + g_client->tts_utterance_status_cb = NULL; + g_client->tts_utterance_status_user_data = NULL; #if 0 - client->exclusive_cmd = false; + g_client->exclusive_cmd = false; #endif - client->service_state = VC_RUNTIME_INFO_NO_FOREGROUND; + g_client->service_state = VC_RUNTIME_INFO_NO_FOREGROUND; - client->before_state = VC_STATE_INITIALIZED; - client->current_state = VC_STATE_INITIALIZED; + g_client->before_state = VC_STATE_INITIALIZED; + g_client->current_state = VC_STATE_INITIALIZED; - client->cb_ref_count = 0; + g_client->cb_ref_count = 0; /* Authority */ - client->auth_before_state = VC_AUTH_STATE_NONE; - client->auth_current_state = VC_AUTH_STATE_NONE; - client->auth_state_changed_cb = NULL; - client->auth_state_changed_user_data = NULL; - - client->is_foreground = false; - client->invocation_name = NULL; + g_client->auth_before_state = VC_AUTH_STATE_NONE; + g_client->auth_current_state = VC_AUTH_STATE_NONE; + g_client->auth_state_changed_cb = NULL; + g_client->auth_state_changed_user_data = NULL; - SLOG(LOG_INFO, TAG_VCC, "[INFO] client create. uid(%u)", client->uid); + g_client->is_foreground = false; + g_client->invocation_name = NULL; - g_client_list = g_slist_append(g_client_list, client); - - *vc = temp; + SLOG(LOG_INFO, TAG_VCC, "[INFO] client create. uid(%u)", g_client->uid); return VC_ERROR_NONE; } -int vc_client_destroy(vc_h vc) +int vc_client_destroy(void) { - if (vc == NULL) { - SLOG(LOG_ERROR, TAG_VCC, "Input parameter is NULL"); //LCOV_EXCL_LINE + if (NULL == g_client) { + SLOG(LOG_ERROR, TAG_VCC, "A client is already NULL"); //LCOV_EXCL_LINE return VC_ERROR_NONE; } - vc_client_s *data = NULL; - - int count = g_slist_length(g_client_list); - int i; - - for (i = 0; i < count; i++) { - data = g_slist_nth_data(g_client_list, i); - - if (NULL != data) { - if (vc->handle == data->vc->handle) { - g_client_list = g_slist_remove(g_client_list, data); - - while (0 != data->cb_ref_count) { - /* wait for release callback function */ - } - if (NULL != data->invocation_name) { - free(data->invocation_name); - data->invocation_name = NULL; - } - free(data); - free(vc); - data = NULL; - vc = NULL; - return VC_ERROR_NONE; - } - } + while (0 != g_client->cb_ref_count) { + /* wait for release callback function */ } + if (NULL != g_client->invocation_name) { + free(g_client->invocation_name); + g_client->invocation_name = NULL; + } + free(g_client); + g_client = NULL; - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] client Not found"); - - return VC_ERROR_INVALID_PARAMETER; + return VC_ERROR_NONE; } -bool vc_client_is_valid(vc_h vc) +bool vc_client_is_valid(void) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) { - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] vc is not valid"); + if (NULL == g_client) { + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The current client is not valid"); return false; } @@ -227,303 +166,265 @@ bool vc_client_is_valid(vc_h vc) } //LCOV_EXCL_START -int vc_client_get_handle(int pid, vc_h* vc) -{ - vc_client_s *data = NULL; +// int vc_client_get_handle(int pid, vc_h* vc) +// { +// vc_client_s *data = NULL; - int count = g_slist_length(g_client_list); - int i; +// int count = g_slist_length(g_client_list); +// int i; - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The number of VC clients(%d)", count); +// SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The number of VC clients(%d)", count); - for (i = 0; i < count; i++) { - data = g_slist_nth_data(g_client_list, i); +// for (i = 0; i < count; i++) { +// data = g_slist_nth_data(g_client_list, i); - if (NULL != data) { - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] pid(%d), handle(%d)", pid, data->vc->handle); - if (pid == data->vc->handle) { - *vc = data->vc; - return VC_ERROR_NONE; - } - } - } +// if (NULL != data) { +// SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] pid(%d), handle(%d)", pid, data->vc->handle); +// if (pid == data->vc->handle) { +// *vc = data->vc; +// return VC_ERROR_NONE; +// } +// } +// } - return VC_ERROR_INVALID_PARAMETER; -} +// return VC_ERROR_INVALID_PARAMETER; +// } //LCOV_EXCL_STOP /* set/get callback function */ -int vc_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data) +int vc_client_set_result_cb(vc_result_cb callback, void* user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->result_cb = callback; - client->result_user_data = user_data; + g_client->result_cb = callback; + g_client->result_user_data = user_data; return VC_ERROR_NONE; } //LCOV_EXCL_START -int vc_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data) +int vc_client_get_result_cb(vc_result_cb* callback, void** user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *callback = client->result_cb; - *user_data = client->result_user_data; + *callback = g_client->result_cb; + *user_data = g_client->result_user_data; return VC_ERROR_NONE; } //LCOV_EXCL_STOP -int vc_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data) +int vc_client_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->service_state_changed_cb = callback; - client->service_state_changed_user_data = user_data; + g_client->service_state_changed_cb = callback; + g_client->service_state_changed_user_data = user_data; return VC_ERROR_NONE; } //LCOV_EXCL_START -int vc_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* callback, void** user_data) +int vc_client_get_service_state_changed_cb(vc_service_state_changed_cb* callback, void** user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *callback = client->service_state_changed_cb; - *user_data = client->service_state_changed_user_data; + *callback = g_client->service_state_changed_cb; + *user_data = g_client->service_state_changed_user_data; return VC_ERROR_NONE; } //LCOV_EXCL_STOP -int vc_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* user_data) +int vc_client_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->state_changed_cb = callback; - client->state_changed_user_data = user_data; + g_client->state_changed_cb = callback; + g_client->state_changed_user_data = user_data; return VC_ERROR_NONE; } //LCOV_EXCL_START -int vc_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void** user_data) +int vc_client_get_state_changed_cb(vc_state_changed_cb* callback, void** user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *callback = client->state_changed_cb; - *user_data = client->state_changed_user_data; + *callback = g_client->state_changed_cb; + *user_data = g_client->state_changed_user_data; return VC_ERROR_NONE; } //LCOV_EXCL_STOP -int vc_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb callback, void* user_data) +int vc_client_set_current_lang_changed_cb(vc_current_language_changed_cb callback, void* user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->current_lang_changed_cb = callback; - client->current_lang_changed_user_data = user_data; + g_client->current_lang_changed_cb = callback; + g_client->current_lang_changed_user_data = user_data; return VC_ERROR_NONE; } //LCOV_EXCL_START -int vc_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb* callback, void** user_data) +int vc_client_get_current_lang_changed_cb(vc_current_language_changed_cb* callback, void** user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *callback = client->current_lang_changed_cb; - *user_data = client->current_lang_changed_user_data; + *callback = g_client->current_lang_changed_cb; + *user_data = g_client->current_lang_changed_user_data; return VC_ERROR_NONE; } //LCOV_EXCL_STOP -int vc_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) +int vc_client_set_error_cb(vc_error_cb callback, void* user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->error_cb = callback; - client->error_user_data = user_data; + g_client->error_cb = callback; + g_client->error_user_data = user_data; return VC_ERROR_NONE; } //LCOV_EXCL_START -int vc_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) +int vc_client_get_error_cb(vc_error_cb* callback, void** user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *callback = client->error_cb; - *user_data = client->error_user_data; + *callback = g_client->error_cb; + *user_data = g_client->error_user_data; return VC_ERROR_NONE; } //LCOV_EXCL_STOP /* set/get option */ -int vc_client_set_service_state(vc_h vc, vc_service_state_e state) +int vc_client_set_service_state(vc_service_state_e state) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->service_state = state; + g_client->service_state = state; return VC_ERROR_NONE; } -int vc_client_get_service_state(vc_h vc, vc_service_state_e* state) +int vc_client_get_service_state(vc_service_state_e* state) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *state = client->service_state; + *state = g_client->service_state; return VC_ERROR_NONE; } -int vc_client_set_client_state(vc_h vc, vc_state_e state) +int vc_client_set_client_state(vc_state_e state) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->before_state = client->current_state; - client->current_state = state; + g_client->before_state = g_client->current_state; + g_client->current_state = state; return VC_ERROR_NONE; } -int vc_client_get_client_state(vc_h vc, vc_state_e* state) +int vc_client_get_client_state(vc_state_e* state) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *state = client->current_state; + *state = g_client->current_state; return VC_ERROR_NONE; } -int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) +int vc_client_get_before_state(vc_state_e* state, vc_state_e* before_state) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *before_state = client->before_state; - *state = client->current_state; + *before_state = g_client->before_state; + *state = g_client->current_state; return VC_ERROR_NONE; } -int vc_client_set_invocation_name(vc_h vc, const char* invocation_name) +int vc_client_set_invocation_name(const char* invocation_name) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - if (NULL != client->invocation_name) { - free(client->invocation_name); - client->invocation_name = NULL; + if (NULL != g_client->invocation_name) { + free(g_client->invocation_name); + g_client->invocation_name = NULL; } if (NULL != invocation_name) { - client->invocation_name = strdup(invocation_name); + g_client->invocation_name = strdup(invocation_name); } return VC_ERROR_NONE; } -int vc_client_get_invocation_name(vc_h vc, char** invocation_name) +int vc_client_get_invocation_name(char** invocation_name) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - if (NULL != client->invocation_name) - *invocation_name = strdup(client->invocation_name); + if (NULL != g_client->invocation_name) + *invocation_name = strdup(g_client->invocation_name); return VC_ERROR_NONE; } -int vc_client_set_is_foreground(vc_h vc, bool value) +int vc_client_set_is_foreground(bool value) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->is_foreground = value; + g_client->is_foreground = value; return VC_ERROR_NONE; } -int vc_client_get_is_foreground(vc_h vc, bool* value) +int vc_client_get_is_foreground(bool* value) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *value = client->is_foreground; + *value = g_client->is_foreground; return VC_ERROR_NONE; } @@ -558,227 +459,190 @@ int vc_client_get_exclusive_cmd(vc_h vc, bool* value) #endif //LCOV_EXCL_STOP -int vc_client_set_error(vc_h vc, int reason) +int vc_client_set_error(int reason) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->reason = reason; + g_client->reason = reason; return VC_ERROR_NONE; } -int vc_client_get_error(vc_h vc, int* reason) +int vc_client_get_error(int* reason) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *reason = client->reason; + *reason = g_client->reason; return VC_ERROR_NONE; } /* utils */ -int vc_client_get_count() +int vc_client_use_callback(void) { - return g_slist_length(g_client_list); -} - -int vc_client_use_callback(vc_h vc) -{ - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->cb_ref_count++; + g_client->cb_ref_count++; return VC_ERROR_NONE; } -int vc_client_not_use_callback(vc_h vc) +int vc_client_not_use_callback(void) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->cb_ref_count--; + g_client->cb_ref_count--; return VC_ERROR_NONE; } //LCOV_EXCL_START /* Authority */ -int vc_client_set_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb callback, void* user_data) +int vc_client_set_auth_state_changed_cb(vc_auth_state_changed_cb callback, void* user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->auth_state_changed_cb = callback; - client->auth_state_changed_user_data = user_data; + g_client->auth_state_changed_cb = callback; + g_client->auth_state_changed_user_data = user_data; return VC_ERROR_NONE; } -int vc_client_get_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb* callback, void** user_data) +int vc_client_get_auth_state_changed_cb(vc_auth_state_changed_cb* callback, void** user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *callback = client->auth_state_changed_cb; - *user_data = client->auth_state_changed_user_data; + *callback = g_client->auth_state_changed_cb; + *user_data = g_client->auth_state_changed_user_data; return VC_ERROR_NONE; } -int vc_client_unset_auth_state_changed_cb(vc_h vc) +int vc_client_unset_auth_state_changed_cb(void) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->auth_state_changed_cb = NULL; - client->auth_state_changed_user_data = NULL; + g_client->auth_state_changed_cb = NULL; + g_client->auth_state_changed_user_data = NULL; return VC_ERROR_NONE; } -int vc_client_set_auth_state(vc_h vc, vc_auth_state_e state) +int vc_client_set_auth_state(vc_auth_state_e state) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->auth_before_state = client->auth_current_state; - client->auth_current_state = state; + g_client->auth_before_state = g_client->auth_current_state; + g_client->auth_current_state = state; return VC_ERROR_NONE; } -int vc_client_get_auth_state(vc_h vc, vc_auth_state_e* state) +int vc_client_get_auth_state(vc_auth_state_e* state) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *state = client->auth_current_state; + *state = g_client->auth_current_state; return VC_ERROR_NONE; } -int vc_client_get_before_auth_state(vc_h vc, vc_auth_state_e* before, vc_auth_state_e* current) +int vc_client_get_before_auth_state(vc_auth_state_e* before, vc_auth_state_e* current) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *before = client->auth_before_state; - *current = client->auth_current_state; + *before = g_client->auth_before_state; + *current = g_client->auth_current_state; return VC_ERROR_NONE; } //LCOV_EXCL_STOP -int vc_client_set_mgr_pid(vc_h vc, int mgr_pid) +int vc_client_set_mgr_pid(int mgr_pid) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->mgr_pid = mgr_pid; + g_client->mgr_pid = mgr_pid; return VC_ERROR_NONE; } -int vc_client_get_mgr_pid(vc_h vc, int* mgr_pid) +int vc_client_get_mgr_pid(int* mgr_pid) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *mgr_pid = client->mgr_pid; + *mgr_pid = g_client->mgr_pid; return VC_ERROR_NONE; } -int vc_client_set_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb callback, void* user_data) +int vc_client_set_tts_streaming_cb(vc_tts_streaming_cb callback, void* user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->tts_streaming_cb = callback; - client->tts_streaming_user_data = user_data; + g_client->tts_streaming_cb = callback; + g_client->tts_streaming_user_data = user_data; return VC_ERROR_NONE; } -int vc_client_get_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb* callback, void** user_data) +int vc_client_get_tts_streaming_cb(vc_tts_streaming_cb* callback, void** user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *callback = client->tts_streaming_cb; - *user_data = client->tts_streaming_user_data; + *callback = g_client->tts_streaming_cb; + *user_data = g_client->tts_streaming_user_data; return VC_ERROR_NONE; } -int vc_client_set_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb callback, void* user_data) +int vc_client_set_tts_utterance_status_cb(vc_tts_utterance_status_cb callback, void* user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - client->tts_utterance_status_cb = callback; - client->tts_utterance_status_user_data = user_data; + g_client->tts_utterance_status_cb = callback; + g_client->tts_utterance_status_user_data = user_data; return VC_ERROR_NONE; } -int vc_client_get_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb* callback, void** user_data) +int vc_client_get_tts_utterance_status_cb(vc_tts_utterance_status_cb* callback, void** user_data) { - vc_client_s* client = __client_get(vc); - /* check handle */ - if (NULL == client) + if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *callback = client->tts_utterance_status_cb; - *user_data = client->tts_utterance_status_user_data; + *callback = g_client->tts_utterance_status_cb; + *user_data = g_client->tts_utterance_status_user_data; return VC_ERROR_NONE; } diff --git a/client/vc_client.h b/client/vc_client.h index b043d87..6f89ea7 100644 --- a/client/vc_client.h +++ b/client/vc_client.h @@ -32,58 +32,58 @@ extern "C" { /* * Common function */ -int vc_client_create(vc_h* vc); +int vc_client_create(void); -int vc_client_destroy(vc_h vc); +int vc_client_destroy(void); -bool vc_client_is_valid(vc_h vc); +bool vc_client_is_valid(void); -int vc_client_get_handle(int pid, vc_h* vc); +// int vc_client_get_handle(int pid, vc_h* vc); /* * set/get callback function */ -int vc_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data); +int vc_client_set_result_cb(vc_result_cb callback, void* user_data); -int vc_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data); +int vc_client_get_result_cb(vc_result_cb* callback, void** user_data); -int vc_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data); +int vc_client_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data); -int vc_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* callback, void** user_data); +int vc_client_get_service_state_changed_cb(vc_service_state_changed_cb* callback, void** user_data); -int vc_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* user_data); +int vc_client_set_state_changed_cb(vc_state_changed_cb callback, void* user_data); -int vc_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void** user_data); +int vc_client_get_state_changed_cb(vc_state_changed_cb* callback, void** user_data); -int vc_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb callback, void* user_data); +int vc_client_set_current_lang_changed_cb(vc_current_language_changed_cb callback, void* user_data); -int vc_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb* callback, void** user_data); +int vc_client_get_current_lang_changed_cb(vc_current_language_changed_cb* callback, void** user_data); -int vc_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data); +int vc_client_set_error_cb(vc_error_cb callback, void* user_data); -int vc_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data); +int vc_client_get_error_cb(vc_error_cb* callback, void** user_data); /* * set/get option */ -int vc_client_set_service_state(vc_h vc, vc_service_state_e state); +int vc_client_set_service_state(vc_service_state_e state); -int vc_client_get_service_state(vc_h vc, vc_service_state_e* state); +int vc_client_get_service_state(vc_service_state_e* state); -int vc_client_set_client_state(vc_h vc, vc_state_e state); +int vc_client_set_client_state(vc_state_e state); -int vc_client_get_client_state(vc_h vc, vc_state_e* state); +int vc_client_get_client_state(vc_state_e* state); -int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state); +int vc_client_get_before_state(vc_state_e* state, vc_state_e* before_state); -int vc_client_set_invocation_name(vc_h vc, const char* invocation_name); +int vc_client_set_invocation_name(const char* invocation_name); -int vc_client_get_invocation_name(vc_h vc, char** invocation_name); +int vc_client_get_invocation_name(char** invocation_name); -int vc_client_set_is_foreground(vc_h vc, bool value); +int vc_client_set_is_foreground(bool value); -int vc_client_get_is_foreground(vc_h vc, bool* value); +int vc_client_get_is_foreground(bool* value); #if 0 int vc_client_set_exclusive_cmd(vc_h vc, bool value); @@ -91,44 +91,42 @@ int vc_client_set_exclusive_cmd(vc_h vc, bool value); int vc_client_get_exclusive_cmd(vc_h vc, bool* value); #endif -int vc_client_set_error(vc_h vc, int reason); +int vc_client_set_error(int reason); -int vc_client_get_error(vc_h vc, int* reason); +int vc_client_get_error(int* reason); /* utils */ -int vc_client_get_count(); +int vc_client_use_callback(void); -int vc_client_use_callback(vc_h vc); - -int vc_client_not_use_callback(vc_h vc); +int vc_client_not_use_callback(void); /* Authority */ -int vc_client_set_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb callback, void* user_data); +int vc_client_set_auth_state_changed_cb(vc_auth_state_changed_cb callback, void* user_data); -int vc_client_get_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb* callback, void** user_data); +int vc_client_get_auth_state_changed_cb(vc_auth_state_changed_cb* callback, void** user_data); -int vc_client_unset_auth_state_changed_cb(vc_h vc); +int vc_client_unset_auth_state_changed_cb(void); -int vc_client_set_auth_state(vc_h vc, vc_auth_state_e state); +int vc_client_set_auth_state(vc_auth_state_e state); -int vc_client_get_auth_state(vc_h vc, vc_auth_state_e* state); +int vc_client_get_auth_state(vc_auth_state_e* state); -int vc_client_get_before_auth_state(vc_h vc, vc_auth_state_e* before, vc_auth_state_e* current); +int vc_client_get_before_auth_state(vc_auth_state_e* before, vc_auth_state_e* current); -int vc_client_set_mgr_pid(vc_h vc, int mgr_pid); +int vc_client_set_mgr_pid(int mgr_pid); -int vc_client_get_mgr_pid(vc_h vc, int* mgr_pid); +int vc_client_get_mgr_pid(int* mgr_pid); /* TTS feedback */ -int vc_client_set_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb callback, void* user_data); +int vc_client_set_tts_streaming_cb(vc_tts_streaming_cb callback, void* user_data); -int vc_client_get_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb* callback, void** user_data); +int vc_client_get_tts_streaming_cb(vc_tts_streaming_cb* callback, void** user_data); -int vc_client_set_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb callback, void* user_data); +int vc_client_set_tts_utterance_status_cb(vc_tts_utterance_status_cb callback, void* user_data); -int vc_client_get_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb* callback, void** user_data); +int vc_client_get_tts_utterance_status_cb(vc_tts_utterance_status_cb* callback, void** user_data); #ifdef __cplusplus -- 2.7.4 From 1479d086189a526fd147814f17021f254b92fa43 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 4 Aug 2022 10:31:44 +0900 Subject: [PATCH 12/16] Remove unused codes Change-Id: Ie4c287f6745631d386d8aa5edc387c4662c1a95d Signed-off-by: sooyeon --- client/vc.c | 31 ++----------------------------- client/vc_tidl.c | 14 -------------- common/vc_defs.h | 1 - 3 files changed, 2 insertions(+), 44 deletions(-) diff --git a/client/vc.c b/client/vc.c index 4b872c2..3d359bb 100644 --- a/client/vc.c +++ b/client/vc.c @@ -1563,24 +1563,8 @@ static void __vc_notify_error(void *data) } } -int __vc_cb_error(int reason, int daemon_pid, char* msg) +int __vc_cb_error_to_app(int pid, int reason, const char* msg) { - vc_state_e state; - if (0 != vc_client_get_client_state(&state)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid client"); - return VC_ERROR_INVALID_PARAMETER; - } - - /* check state */ - if (state != VC_STATE_READY) { - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] State is not READY"); - if (VC_ERROR_SERVICE_RESET != reason) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] not connected client yet(%d)", reason); - return VC_ERROR_INVALID_STATE; - } - return VC_ERROR_NONE; - } - if (VC_ERROR_SERVICE_RESET == reason) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] VC daemon reset"); @@ -1592,18 +1576,7 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) } } - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Error reason(%d), msg(%s)", reason, msg); - - vc_client_set_error(reason); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); - - return VC_ERROR_NONE; -} - -int __vc_cb_error_to_app(int pid, int reason, const char* msg) -{ - SLOG(LOG_INFO, TAG_VCC, "[INFO] send error to app(%d)", pid); - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Error reason(%d), msg(%s)", reason, msg); + SLOG(LOG_ERROR, TAG_VCC, "[INFO] send error to app(%d), error reason(%d), msg(%s)", pid, reason, msg); vc_client_set_error(reason); ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 46fc18a..ac5550f 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -37,7 +37,6 @@ typedef struct { static GList* g_tidl_infos = NULL; -extern int __vc_cb_error(int reason, int daemon_pid, char* msg); extern int __vc_cb_error_to_app(int pid, int reason, char* msg); extern void __vc_cb_result(); extern int __vc_cb_service_state(int state); @@ -200,19 +199,6 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) __vc_cb_manager_pid(atoi(manager_pid)); } } /* VCD_METHOD_SEND_MANAGER_PID */ - else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR))) { - /* signal!!! */ - char* reason = NULL; - char* daemon_pid = NULL; - char* err_msg = NULL; - - bundle_get_str(msg, VC_BUNDLE_REASON, &reason); - bundle_get_str(msg, VC_BUNDLE_DAEMON_PID, &daemon_pid); - bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg); - - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), daemon_pid(%d), msg(%s)", atoi(reason), atoi(daemon_pid), err_msg); - __vc_cb_error(atoi(reason), atoi(daemon_pid), err_msg); - } /* VCD_METHOD_ERROR */ else if (0 == strncmp(VCD_METHOD_ERROR_TO_APP, method, strlen(VCD_METHOD_ERROR_TO_APP))) { /* signal!!! */ char* pid; diff --git a/common/vc_defs.h b/common/vc_defs.h index e163687..0f09459 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -115,7 +115,6 @@ extern "C" { #define VCD_METHOD_RESULT "vcd_method_result" -#define VCD_METHOD_ERROR "vcd_method_error" #define VCD_METHOD_ERROR_TO_APP "vcd_method_error_to_app" #define VCD_METHOD_HELLO "vcd_method_hello" #define VCD_METHOD_SET_SERVICE_STATE "vcd_method_set_service_state" -- 2.7.4 From 923012278c3711da471b42dc54763d7871e849d9 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 4 Aug 2022 11:25:29 +0900 Subject: [PATCH 13/16] Remove unnecessary codes (get_handle, xid) Change-Id: Ided2c548d480e7933aa0bb6ecf4312b8c84f6d8d Signed-off-by: sooyeon --- client/vc_client.c | 28 ---------------------------- client/vc_client.h | 2 -- 2 files changed, 30 deletions(-) diff --git a/client/vc_client.c b/client/vc_client.c index 4aacf8a..eb2c11c 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -21,7 +21,6 @@ typedef struct { /* base info */ int pid; unsigned int uid; /*<< unique id = pid + handle */ - int xid; /*<< main X window id */ vc_result_cb result_cb; void* result_user_data; @@ -92,7 +91,6 @@ int vc_client_create(void) /* initialize client data */ g_client->pid = getpid(); g_client->uid = getpid(); - g_client->xid = -1; g_client->result_cb = NULL; g_client->result_user_data = NULL; @@ -165,32 +163,6 @@ bool vc_client_is_valid(void) return true; } -//LCOV_EXCL_START -// int vc_client_get_handle(int pid, vc_h* vc) -// { -// vc_client_s *data = NULL; - -// int count = g_slist_length(g_client_list); -// int i; - -// SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] The number of VC clients(%d)", count); - -// for (i = 0; i < count; i++) { -// data = g_slist_nth_data(g_client_list, i); - -// if (NULL != data) { -// SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] pid(%d), handle(%d)", pid, data->vc->handle); -// if (pid == data->vc->handle) { -// *vc = data->vc; -// return VC_ERROR_NONE; -// } -// } -// } - -// return VC_ERROR_INVALID_PARAMETER; -// } -//LCOV_EXCL_STOP - /* set/get callback function */ int vc_client_set_result_cb(vc_result_cb callback, void* user_data) { diff --git a/client/vc_client.h b/client/vc_client.h index 6f89ea7..f8946a0 100644 --- a/client/vc_client.h +++ b/client/vc_client.h @@ -38,8 +38,6 @@ int vc_client_destroy(void); bool vc_client_is_valid(void); -// int vc_client_get_handle(int pid, vc_h* vc); - /* * set/get callback function */ -- 2.7.4 From d8d5d2c080de4c2d2c5cde429fc19a564fd74174 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 4 Aug 2022 13:42:54 +0900 Subject: [PATCH 14/16] Change variable names and function names Change-Id: I3eea6c8094a1752911243ce8e9202ecf3b256ec4 Signed-off-by: sooyeon --- client/vc.c | 74 +++++++++++++++++++++++------------------------ client/vc_client.c | 24 +++++++-------- client/vc_client.h | 4 +-- client/vc_mgr.c | 36 +++++++++++------------ client/vc_mgr_client.c | 14 ++++----- client/vc_mgr_client.h | 2 +- client/vc_setting.c | 12 ++++---- client/vc_tidl.c | 4 +-- client/vc_widget.c | 32 ++++++++++---------- client/vc_widget_client.c | 8 ++--- client/vc_widget_client.h | 4 +-- 11 files changed, 106 insertions(+), 108 deletions(-) diff --git a/client/vc.c b/client/vc.c index 3d359bb..1c9b8b9 100644 --- a/client/vc.c +++ b/client/vc.c @@ -49,7 +49,7 @@ static Ecore_Event_Handler* g_focus_out_handler = NULL; static Ecore_Thread* g_tts_thread = NULL; -static unsigned int g_handle; +static int g_pid; static int g_daemon_pid = 0; @@ -231,10 +231,10 @@ static int __vc_convert_config_error_code(vc_config_error_e code) return VC_ERROR_NONE; } -static void __vc_lang_changed_cb(const char* before_lang, const char* current_lang) +static void __vc_lang_changed_cb(const char* previous_lang, const char* current_lang) { - SLOG(LOG_DEBUG, TAG_VCC, "Lang changed : Before lang(%s) Current lang(%s)", - before_lang, current_lang); + SLOG(LOG_DEBUG, TAG_VCC, "Lang changed : previous lang(%s) Current lang(%s)", + previous_lang, current_lang); vc_current_language_changed_cb callback; void* lang_user_data; @@ -242,7 +242,7 @@ static void __vc_lang_changed_cb(const char* before_lang, const char* current_la if (NULL != callback) { vc_client_use_callback(); - callback(before_lang, current_lang, lang_user_data); + callback(previous_lang, current_lang, lang_user_data); vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "Language changed callback is called"); } else { @@ -259,14 +259,14 @@ static Eina_Bool __notify_auth_changed_cb(void *data) vc_client_get_auth_state_changed_cb(&callback, &user_data); - vc_auth_state_e before = -1; + vc_auth_state_e previous = -1; vc_auth_state_e current = -1; - vc_client_get_before_auth_state(&before, ¤t); + vc_client_get_previous_auth_state(&previous, ¤t); if (NULL != callback) { vc_client_use_callback(); - callback(before, current, user_data); + callback(previous, current, user_data); vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "Auth state changed callback is called"); } else { @@ -362,8 +362,8 @@ int vc_initialize(void) return VC_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } - g_handle = getpid(); - ret = vc_config_mgr_initialize(g_handle); + g_pid = getpid(); + ret = vc_config_mgr_initialize(g_pid); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to init config manager : %s", __vc_get_error_code(__vc_convert_config_error_code(ret))); //LCOV_EXCL_LINE @@ -371,15 +371,15 @@ int vc_initialize(void) return __vc_convert_config_error_code(ret); //LCOV_EXCL_LINE } - ret = vc_config_mgr_set_lang_cb(g_handle, __vc_lang_changed_cb); + ret = vc_config_mgr_set_lang_cb(g_pid, __vc_lang_changed_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set config changed : %d", ret); //LCOV_EXCL_LINE - vc_config_mgr_finalize(g_handle); //LCOV_EXCL_LINE + vc_config_mgr_finalize(g_pid); //LCOV_EXCL_LINE vc_client_destroy(); //LCOV_EXCL_LINE return __vc_convert_config_error_code(ret); } - SLOG(LOG_DEBUG, TAG_VCC, "[Success] pid(%d)", g_handle); + SLOG(LOG_DEBUG, TAG_VCC, "[Success] pid(%d)", g_pid); return VC_ERROR_NONE; @@ -399,7 +399,7 @@ static void __vc_internal_unprepare(void) } } - int ret = vc_tidl_request_finalize(g_handle); + int ret = vc_tidl_request_finalize(g_pid); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } @@ -449,12 +449,12 @@ int vc_deinitialize(void) g_connect_timer = NULL; } - vc_config_mgr_unset_lang_cb(g_handle); - vc_config_mgr_finalize(g_handle); + vc_config_mgr_unset_lang_cb(g_pid); + vc_config_mgr_finalize(g_pid); /* Free client resources */ vc_client_destroy(); - g_handle = 0; + g_pid = 0; break; case VC_STATE_NONE: break; @@ -509,7 +509,7 @@ static Eina_Bool __vc_connect_daemon(void *data) if (0 != ret) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); //LCOV_EXCL_LINE - ret = vc_tidl_request_initialize(g_handle, &mgr_pid, &service_state, &g_daemon_pid); + ret = vc_tidl_request_initialize(g_pid, &mgr_pid, &service_state, &g_daemon_pid); //LCOV_EXCL_START if (VC_ERROR_ENGINE_NOT_FOUND == ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize : %s", __vc_get_error_code(ret)); @@ -899,7 +899,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) ret = -1; bool is_prepared = false; do { - ret = vc_tidl_request_is_system_command_valid(g_handle, &is_sys_cmd_valid); + ret = vc_tidl_request_is_system_command_valid(g_pid, &is_sys_cmd_valid); if (0 != ret) { //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { @@ -1083,7 +1083,7 @@ void __set_command(vc_cmd_type_e type) int count = 0; bool is_prepared = false; do { - ret = vc_tidl_request_set_command(g_handle, type); + ret = vc_tidl_request_set_command(g_pid, type); if (0 != ret) { //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { @@ -1196,7 +1196,7 @@ int vc_unset_command_list(int type) ret = -1; bool is_prepared = false; while (0 != ret) { - ret = vc_tidl_request_unset_command(g_handle, (vc_cmd_type_e)type); + ret = vc_tidl_request_unset_command(g_pid, (vc_cmd_type_e)type); if (0 != ret) { //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { @@ -1563,7 +1563,7 @@ static void __vc_notify_error(void *data) } } -int __vc_cb_error_to_app(int pid, int reason, const char* msg) +int __vc_cb_error(int reason, const char* msg) { if (VC_ERROR_SERVICE_RESET == reason) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] VC daemon reset"); @@ -1576,7 +1576,7 @@ int __vc_cb_error_to_app(int pid, int reason, const char* msg) } } - SLOG(LOG_ERROR, TAG_VCC, "[INFO] send error to app(%d), error reason(%d), msg(%s)", pid, reason, msg); + SLOG(LOG_ERROR, TAG_VCC, "[INFO] send error reason(%d), msg(%s)", reason, msg); vc_client_set_error(reason); ecore_main_loop_thread_safe_call_async(__vc_notify_error, NULL); @@ -1592,13 +1592,13 @@ static void __vc_notify_state_changed(void *data) vc_client_get_state_changed_cb(&changed_callback, &user_data); vc_state_e current_state; - vc_state_e before_state; + vc_state_e previous_state; - vc_client_get_before_state(¤t_state, &before_state); + vc_client_get_previous_state(¤t_state, &previous_state); if (NULL != changed_callback) { vc_client_use_callback(); - changed_callback(before_state, current_state, user_data); + changed_callback(previous_state, current_state, user_data); vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "State changed callback is called"); } else { @@ -1756,15 +1756,15 @@ int vc_unset_result_cb(void) int __vc_cb_service_state(int state) { vc_service_state_e current_state = (vc_service_state_e)state; - vc_service_state_e before_state; - vc_client_get_service_state(&before_state); + vc_service_state_e previous_state; + vc_client_get_service_state(&previous_state); - if (current_state == before_state) { + if (current_state == previous_state) { return VC_ERROR_NONE; } - SLOG(LOG_DEBUG, TAG_VCC, "Service State changed : Before(%d) Current(%d)", - before_state, current_state); + SLOG(LOG_DEBUG, TAG_VCC, "Service State changed : previous(%d) current(%d)", + previous_state, current_state); /* Save service state */ vc_client_set_service_state(current_state); @@ -1775,7 +1775,7 @@ int __vc_cb_service_state(int state) if (NULL != callback) { vc_client_use_callback(); - callback((vc_service_state_e)before_state, (vc_service_state_e)current_state, service_user_data); + callback((vc_service_state_e)previous_state, (vc_service_state_e)current_state, service_user_data); vc_client_not_use_callback(); SLOG(LOG_DEBUG, TAG_VCC, "Service state changed callback is called"); } else { @@ -2207,7 +2207,7 @@ int vc_auth_enable(void) return VC_ERROR_OPERATION_FAILED; } - if (0 != vc_tidl_request_auth_enable(g_handle, mgr_pid)) { + if (0 != vc_tidl_request_auth_enable(g_pid, mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to authority enabled"); return VC_ERROR_OPERATION_FAILED; } @@ -2266,7 +2266,7 @@ int vc_auth_disable(void) return VC_ERROR_OPERATION_FAILED; } - if (0 != vc_tidl_request_auth_disable(g_handle, mgr_pid)) { + if (0 != vc_tidl_request_auth_disable(g_pid, mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to authority disable"); return VC_ERROR_OPERATION_FAILED; } @@ -2394,7 +2394,7 @@ int vc_auth_start(void) bool is_prepared = false; /* Request */ while (0 != ret) { - ret = vc_tidl_request_auth_start(g_handle, mgr_pid); + ret = vc_tidl_request_auth_start(g_pid, mgr_pid); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { vc_client_set_client_state(VC_STATE_INITIALIZED); @@ -2462,7 +2462,7 @@ int vc_auth_stop(void) bool is_prepared = false; /* do request */ while (0 != ret) { - ret = vc_tidl_request_auth_stop(g_handle, mgr_pid); + ret = vc_tidl_request_auth_stop(g_pid, mgr_pid); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { vc_client_set_client_state(VC_STATE_INITIALIZED); @@ -2532,7 +2532,7 @@ int vc_auth_cancel(void) int count = 0; bool is_prepared = false; while (0 != ret) { - ret = vc_tidl_request_auth_cancel(g_handle, mgr_pid); + ret = vc_tidl_request_auth_cancel(g_pid, mgr_pid); if (0 != ret) { if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { vc_client_set_client_state(VC_STATE_INITIALIZED); diff --git a/client/vc_client.c b/client/vc_client.c index eb2c11c..442ac1f 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -20,7 +20,6 @@ typedef struct { /* base info */ int pid; - unsigned int uid; /*<< unique id = pid + handle */ vc_result_cb result_cb; void* result_user_data; @@ -48,7 +47,7 @@ typedef struct { vc_service_state_e service_state; /* state */ - vc_state_e before_state; + vc_state_e previous_state; vc_state_e current_state; /* mutex */ @@ -58,7 +57,7 @@ typedef struct { int reason; /* Authority */ - vc_auth_state_e auth_before_state; + vc_auth_state_e auth_previous_state; vc_auth_state_e auth_current_state; vc_auth_state_changed_cb auth_state_changed_cb; void* auth_state_changed_user_data; @@ -90,7 +89,6 @@ int vc_client_create(void) /* initialize client data */ g_client->pid = getpid(); - g_client->uid = getpid(); g_client->result_cb = NULL; g_client->result_user_data = NULL; @@ -113,13 +111,13 @@ int vc_client_create(void) g_client->service_state = VC_RUNTIME_INFO_NO_FOREGROUND; - g_client->before_state = VC_STATE_INITIALIZED; + g_client->previous_state = VC_STATE_INITIALIZED; g_client->current_state = VC_STATE_INITIALIZED; g_client->cb_ref_count = 0; /* Authority */ - g_client->auth_before_state = VC_AUTH_STATE_NONE; + g_client->auth_previous_state = VC_AUTH_STATE_NONE; g_client->auth_current_state = VC_AUTH_STATE_NONE; g_client->auth_state_changed_cb = NULL; g_client->auth_state_changed_user_data = NULL; @@ -127,7 +125,7 @@ int vc_client_create(void) g_client->is_foreground = false; g_client->invocation_name = NULL; - SLOG(LOG_INFO, TAG_VCC, "[INFO] client create. uid(%u)", g_client->uid); + SLOG(LOG_INFO, TAG_VCC, "[INFO] client create. pid(%u)", g_client->pid); return VC_ERROR_NONE; } @@ -323,7 +321,7 @@ int vc_client_set_client_state(vc_state_e state) if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - g_client->before_state = g_client->current_state; + g_client->previous_state = g_client->current_state; g_client->current_state = state; return VC_ERROR_NONE; @@ -340,13 +338,13 @@ int vc_client_get_client_state(vc_state_e* state) return VC_ERROR_NONE; } -int vc_client_get_before_state(vc_state_e* state, vc_state_e* before_state) +int vc_client_get_previous_state(vc_state_e* state, vc_state_e* previous_state) { /* check handle */ if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *before_state = g_client->before_state; + *previous_state = g_client->previous_state; *state = g_client->current_state; return VC_ERROR_NONE; @@ -519,7 +517,7 @@ int vc_client_set_auth_state(vc_auth_state_e state) if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - g_client->auth_before_state = g_client->auth_current_state; + g_client->auth_previous_state = g_client->auth_current_state; g_client->auth_current_state = state; return VC_ERROR_NONE; @@ -536,13 +534,13 @@ int vc_client_get_auth_state(vc_auth_state_e* state) return VC_ERROR_NONE; } -int vc_client_get_before_auth_state(vc_auth_state_e* before, vc_auth_state_e* current) +int vc_client_get_previous_auth_state(vc_auth_state_e* previous, vc_auth_state_e* current) { /* check handle */ if (NULL == g_client) return VC_ERROR_INVALID_PARAMETER; - *before = g_client->auth_before_state; + *previous = g_client->auth_previous_state; *current = g_client->auth_current_state; return VC_ERROR_NONE; diff --git a/client/vc_client.h b/client/vc_client.h index f8946a0..21c3ea9 100644 --- a/client/vc_client.h +++ b/client/vc_client.h @@ -73,7 +73,7 @@ int vc_client_set_client_state(vc_state_e state); int vc_client_get_client_state(vc_state_e* state); -int vc_client_get_before_state(vc_state_e* state, vc_state_e* before_state); +int vc_client_get_previous_state(vc_state_e* state, vc_state_e* previous_state); int vc_client_set_invocation_name(const char* invocation_name); @@ -110,7 +110,7 @@ int vc_client_set_auth_state(vc_auth_state_e state); int vc_client_get_auth_state(vc_auth_state_e* state); -int vc_client_get_before_auth_state(vc_auth_state_e* before, vc_auth_state_e* current); +int vc_client_get_previous_auth_state(vc_auth_state_e* previous, vc_auth_state_e* current); int vc_client_set_mgr_pid(int mgr_pid); diff --git a/client/vc_mgr.c b/client/vc_mgr.c index fcc1c81..295fcf4 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -108,10 +108,10 @@ static const char* __vc_mgr_get_error_code(vc_error_e err) return NULL; } -static void __vc_mgr_lang_changed_cb(const char* before_lang, const char* current_lang) +static void __vc_mgr_lang_changed_cb(const char* previous_lang, const char* current_lang) { - SLOG(LOG_INFO, TAG_VCM, "Lang changed : Before lang(%s) Current lang(%s)", - before_lang, current_lang); + SLOG(LOG_INFO, TAG_VCM, "Lang changed : previous lang(%s) current lang(%s)", + previous_lang, current_lang); vc_current_language_changed_cb callback = NULL; void* lang_user_data; @@ -119,7 +119,7 @@ static void __vc_mgr_lang_changed_cb(const char* before_lang, const char* curren if (NULL != callback) { vc_mgr_client_use_callback(g_vc_m); - callback(before_lang, current_lang, lang_user_data); + callback(previous_lang, current_lang, lang_user_data); vc_mgr_client_not_use_callback(g_vc_m); SLOG(LOG_INFO, TAG_VCM, "Language changed callback is called"); } else { @@ -491,13 +491,13 @@ static Eina_Bool __request_initialize(void *data) vc_mgr_client_get_state_changed_cb(g_vc_m, &changed_callback, &user_data); vc_state_e current_state; - vc_state_e before_state; + vc_state_e previous_state; - vc_mgr_client_get_before_state(g_vc_m, ¤t_state, &before_state); + vc_mgr_client_get_previous_state(g_vc_m, ¤t_state, &previous_state); if (NULL != changed_callback) { vc_mgr_client_use_callback(g_vc_m); - changed_callback(before_state, current_state, user_data); + changed_callback(previous_state, current_state, user_data); vc_mgr_client_not_use_callback(g_vc_m); SLOG(LOG_INFO, TAG_VCM, "State changed callback is called"); } else { @@ -2401,13 +2401,13 @@ static Eina_Bool __vc_mgr_notify_state_changed(void *data) vc_mgr_client_get_state_changed_cb(g_vc_m, &changed_callback, &user_data); vc_state_e current_state; - vc_state_e before_state; + vc_state_e previous_state; - vc_mgr_client_get_before_state(g_vc_m, ¤t_state, &before_state); + vc_mgr_client_get_previous_state(g_vc_m, ¤t_state, &previous_state); if (NULL != changed_callback) { vc_mgr_client_use_callback(g_vc_m); - changed_callback(before_state, current_state, user_data); + changed_callback(previous_state, current_state, user_data); vc_mgr_client_not_use_callback(g_vc_m); SLOG(LOG_INFO, TAG_VCM, "State changed callback is called"); } else { @@ -2466,11 +2466,11 @@ int vc_mgr_unset_state_changed_cb(void) int __vc_mgr_cb_service_state(int state) { vc_service_state_e current_state = (vc_service_state_e)state; - vc_service_state_e before_state; - vc_mgr_client_get_service_state(g_vc_m, &before_state); + vc_service_state_e previous_state; + vc_mgr_client_get_service_state(g_vc_m, &previous_state); - SLOG(LOG_INFO, TAG_VCM, "Service State changed : Before(%d) Current(%d)", - before_state, current_state); + SLOG(LOG_INFO, TAG_VCM, "Service State changed : previous(%d) current(%d)", + previous_state, current_state); vc_internal_state_e internal_state = -1; vc_mgr_client_get_internal_state(g_vc_m, &internal_state); @@ -2485,9 +2485,9 @@ int __vc_mgr_cb_service_state(int state) vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); } - if (current_state == before_state) { - SLOG(LOG_WARN, TAG_VCM, "Service State NOT changed : Before(%d) Current(%d)", - before_state, current_state); + if (current_state == previous_state) { + SLOG(LOG_WARN, TAG_VCM, "Service State NOT changed : previous(%d) current(%d)", + previous_state, current_state); return VC_ERROR_NONE; } @@ -2500,7 +2500,7 @@ int __vc_mgr_cb_service_state(int state) if (NULL != callback) { vc_mgr_client_use_callback(g_vc_m); - callback(before_state, current_state, service_user_data); + callback(previous_state, current_state, service_user_data); vc_mgr_client_not_use_callback(g_vc_m); SLOG(LOG_INFO, TAG_VCM, "Service state changed callback is called"); } else { diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index 9da3025..f10480b 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -75,11 +75,11 @@ typedef struct { vc_internal_state_e internal_state; /* state */ - vc_state_e before_state; + vc_state_e previous_state; vc_state_e current_state; /* language */ - char* before_language; + char* previous_language; char* current_language; /* audio type */ @@ -212,10 +212,10 @@ int vc_mgr_client_create(vc_h* vc) client->internal_state = VC_INTERNAL_STATE_NONE; - client->before_state = VC_STATE_INITIALIZED; + client->previous_state = VC_STATE_INITIALIZED; client->current_state = VC_STATE_INITIALIZED; - client->before_language = NULL; + client->previous_language = NULL; client->current_language = NULL; client->audio_id = NULL; @@ -820,7 +820,7 @@ int vc_mgr_client_set_client_state(vc_h vc, vc_state_e state) if (NULL == client) return VC_ERROR_INVALID_PARAMETER; - client->before_state = client->current_state; + client->previous_state = client->current_state; client->current_state = state; return VC_ERROR_NONE; @@ -860,7 +860,7 @@ int vc_mgr_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) return VC_ERROR_INVALID_PARAMETER; } -int vc_mgr_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) +int vc_mgr_client_get_previous_state(vc_h vc, vc_state_e* state, vc_state_e* previous_state) { vc_mgr_client_s* client = __mgr_client_get(vc); @@ -868,7 +868,7 @@ int vc_mgr_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* befor if (NULL == client) return VC_ERROR_INVALID_PARAMETER; - *before_state = client->before_state; + *previous_state = client->previous_state; *state = client->current_state; return VC_ERROR_NONE; diff --git a/client/vc_mgr_client.h b/client/vc_mgr_client.h index dfcfde1..ffa4e08 100644 --- a/client/vc_mgr_client.h +++ b/client/vc_mgr_client.h @@ -129,7 +129,7 @@ int vc_mgr_client_get_client_state(vc_h vc, vc_state_e* state); int vc_mgr_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state); -int vc_mgr_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state); +int vc_mgr_client_get_previous_state(vc_h vc, vc_state_e* state, vc_state_e* previous_state); int vc_mgr_client_set_error(vc_h vc, int reason); diff --git a/client/vc_setting.c b/client/vc_setting.c index aabd0b8..999c716 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -45,19 +45,19 @@ static void* g_enabled_changed_user_data = NULL; static vc_setting_current_language_changed_cb g_current_language_changed_cb = NULL; static void* g_current_language_changed_user_data = NULL; -void __config_lang_changed_cb(const char* before_lang, const char* current_lang) +void __config_lang_changed_cb(const char* previous_lang, const char* current_lang) { - SLOG(LOG_DEBUG, TAG_VCS, "Lang changed : before(%s) current(%s)", before_lang, current_lang); + SLOG(LOG_DEBUG, TAG_VCS, "Lang changed : previous(%s) current(%s)", previous_lang, current_lang); if (NULL != g_current_language_changed_cb) { - g_current_language_changed_cb(before_lang, current_lang, g_current_language_changed_user_data); + g_current_language_changed_cb(previous_lang, current_lang, g_current_language_changed_user_data); } } -void __vc_setting_state_changed_cb(int before_state, int current_state, void* user_data) +void __vc_setting_state_changed_cb(int previous_state, int current_state, void* user_data) { - SLOG(LOG_DEBUG, TAG_VCS, "Service State changed : Before(%d) Current(%d)", - before_state, current_state); + SLOG(LOG_DEBUG, TAG_VCS, "Service State changed : previous(%d) current(%d)", + previous_state, current_state); return; } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index ac5550f..ed216ea 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -37,7 +37,7 @@ typedef struct { static GList* g_tidl_infos = NULL; -extern int __vc_cb_error_to_app(int pid, int reason, char* msg); +extern int __vc_cb_error(int reason, char* msg); extern void __vc_cb_result(); extern int __vc_cb_service_state(int state); extern int __vc_cb_manager_pid(int manager_pid); @@ -210,7 +210,7 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg); SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", atoi(reason), atoi(pid), err_msg); - __vc_cb_error_to_app(atoi(pid), atoi(reason), err_msg); + __vc_cb_error(atoi(reason), err_msg); } /* VCD_METHOD_ERROR_TO_APP */ else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) { /* signal!!! */ diff --git a/client/vc_widget.c b/client/vc_widget.c index d4816f0..1e3a90e 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -124,10 +124,10 @@ static int __vc_widget_convert_config_error_code(vc_config_error_e code) return VC_ERROR_NONE; } -static void __vc_widget_lang_changed_cb(const char* before_lang, const char* current_lang) +static void __vc_widget_lang_changed_cb(const char* previous_lang, const char* current_lang) { - SLOG(LOG_DEBUG, TAG_VCW, "Lang changed : Before lang(%s) Current lang(%s)", - before_lang, current_lang); + SLOG(LOG_DEBUG, TAG_VCW, "Lang changed : previous lang(%s) Current lang(%s)", + previous_lang, current_lang); vc_current_language_changed_cb callback; void* lang_user_data; @@ -148,7 +148,7 @@ static void __vc_widget_lang_changed_cb(const char* before_lang, const char* cur if (NULL != callback) { vc_widget_client_use_callback(vc_w); - callback(before_lang, current_lang, lang_user_data); + callback(previous_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 { @@ -489,13 +489,13 @@ static Eina_Bool __vc_widget_connect_daemon(void *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_state_e previous_state; - vc_widget_client_get_before_state(vc_w, ¤t_state, &before_state); + vc_widget_client_get_previous_state(vc_w, ¤t_state, &previous_state); if (NULL != changed_callback) { vc_widget_client_use_callback(vc_w); - changed_callback(before_state, current_state, user_data); + changed_callback(previous_state, current_state, user_data); vc_widget_client_not_use_callback(vc_w); SLOG(LOG_DEBUG, TAG_VCW, "State changed callback is called"); } else { @@ -1399,13 +1399,13 @@ static Eina_Bool __vc_widget_notify_state_changed(void *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_state_e previous_state; - vc_widget_client_get_before_state(vc_w, ¤t_state, &before_state); + vc_widget_client_get_previous_state(vc_w, ¤t_state, &previous_state); if (NULL != changed_callback) { vc_widget_client_use_callback(vc_w); - changed_callback(before_state, current_state, user_data); + changed_callback(previous_state, current_state, user_data); vc_widget_client_not_use_callback(vc_w); SLOG(LOG_DEBUG, TAG_VCW, "State changed callback is called"); } else { @@ -1577,15 +1577,15 @@ int __vc_widget_cb_service_state(int state) vc_w = data->vc; 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_e previous_state; + vc_widget_client_get_service_state(vc_w, &previous_state); - if (current_state == before_state) { + if (current_state == previous_state) { continue; } - SLOG(LOG_DEBUG, TAG_VCW, "Service State changed : Before(%d) Current(%d)", - before_state, current_state); + SLOG(LOG_DEBUG, TAG_VCW, "Service State changed : previous(%d) current(%d)", + previous_state, current_state); /* Save service state */ vc_widget_client_set_service_state(vc_w, current_state); @@ -1596,7 +1596,7 @@ int __vc_widget_cb_service_state(int state) 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); + callback((vc_service_state_e)previous_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 { diff --git a/client/vc_widget_client.c b/client/vc_widget_client.c index 891ba75..5607a7a 100644 --- a/client/vc_widget_client.c +++ b/client/vc_widget_client.c @@ -112,7 +112,7 @@ int vc_widget_client_create(vc_h* vc) widget->error_cb = NULL; widget->error_user_data = NULL; - widget->before_state = VC_STATE_INITIALIZED; + widget->previous_state = VC_STATE_INITIALIZED; widget->current_state = VC_STATE_INITIALIZED; widget->conn_timer = NULL; @@ -527,7 +527,7 @@ int vc_widget_client_set_state(vc_h vc, vc_state_e state) if (NULL == widget) return VC_ERROR_INVALID_PARAMETER; - widget->before_state = widget->current_state; + widget->previous_state = widget->current_state; widget->current_state = state; return VC_ERROR_NONE; @@ -570,7 +570,7 @@ int vc_widget_client_get_state_by_uid(unsigned int uid, vc_state_e* state) return VC_ERROR_INVALID_PARAMETER; } -int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) +int vc_widget_client_get_previous_state(vc_h vc, vc_state_e* state, vc_state_e* previous_state) { vc_widget_s* widget = widget_get(vc); @@ -578,7 +578,7 @@ int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* be if (NULL == widget) return VC_ERROR_INVALID_PARAMETER; - *before_state = widget->before_state; + *previous_state = widget->previous_state; *state = widget->current_state; return VC_ERROR_NONE; diff --git a/client/vc_widget_client.h b/client/vc_widget_client.h index 5ef3a55..990007e 100644 --- a/client/vc_widget_client.h +++ b/client/vc_widget_client.h @@ -59,7 +59,7 @@ typedef struct { vc_service_state_e service_state; /* state */ - vc_state_e before_state; + vc_state_e previous_state; vc_state_e current_state; Ecore_Timer* conn_timer; @@ -138,7 +138,7 @@ int vc_widget_client_get_state(vc_h vc, vc_state_e* state); int vc_widget_client_get_state_by_uid(unsigned 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); +int vc_widget_client_get_previous_state(vc_h vc, vc_state_e* state, vc_state_e* previous_state); int vc_widget_client_set_xid(vc_h vc, int xid); -- 2.7.4 From 176ee187d6b6116860d2d021684ed304bfc57fff Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 4 Aug 2022 16:28:51 +0900 Subject: [PATCH 15/16] Replace the name METHOD_ERROR_TO_APP with METHOD_ERROR Change-Id: I6ca381930becc1a6a01be55aa45b0dcac173637d Signed-off-by: sooyeon --- client/vc_tidl.c | 4 ++-- common/vc_defs.h | 2 +- server/vcd_tidl.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/vc_tidl.c b/client/vc_tidl.c index ed216ea..7753589 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -199,7 +199,7 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) __vc_cb_manager_pid(atoi(manager_pid)); } } /* VCD_METHOD_SEND_MANAGER_PID */ - else if (0 == strncmp(VCD_METHOD_ERROR_TO_APP, method, strlen(VCD_METHOD_ERROR_TO_APP))) { + else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR))) { /* signal!!! */ char* pid; char* reason; @@ -211,7 +211,7 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", atoi(reason), atoi(pid), err_msg); __vc_cb_error(atoi(reason), err_msg); - } /* VCD_METHOD_ERROR_TO_APP */ + } /* VCD_METHOD_ERROR */ else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) { /* signal!!! */ char* pid = NULL; diff --git a/common/vc_defs.h b/common/vc_defs.h index 0f09459..6cc4728 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -115,7 +115,7 @@ extern "C" { #define VCD_METHOD_RESULT "vcd_method_result" -#define VCD_METHOD_ERROR_TO_APP "vcd_method_error_to_app" +#define VCD_METHOD_ERROR "vcd_method_error" #define VCD_METHOD_HELLO "vcd_method_hello" #define VCD_METHOD_SET_SERVICE_STATE "vcd_method_set_service_state" #define VCD_METHOD_SEND_MANAGER_PID "vcd_method_send_manager_pid" diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index e4a7426..a881cd7 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -1906,7 +1906,7 @@ int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) snprintf(pid_char, 10, "%d", pid); snprintf(reason_char, 10, "%d", reason); - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_ERROR_TO_APP); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_ERROR); bundle_add_str(msg, VC_BUNDLE_PID, pid_char); bundle_add_str(msg, VC_BUNDLE_REASON, reason_char); bundle_add_str(msg, VC_BUNDLE_ERR_MSG, err_msg); -- 2.7.4 From 1a74c5ca5821e6449c301b47932aa98baab54790 Mon Sep 17 00:00:00 2001 From: ulgal-park Date: Fri, 5 Aug 2022 15:08:52 +0900 Subject: [PATCH 16/16] fix vc_mgr_tidl header guards typo Change-Id: I983f7144dff58f2d62a78a578c2db0204c5c8d17 --- client/vc_mgr_tidl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/vc_mgr_tidl.h b/client/vc_mgr_tidl.h index fd91d7f..8929b13 100644 --- a/client/vc_mgr_tidl.h +++ b/client/vc_mgr_tidl.h @@ -15,8 +15,8 @@ */ -#ifndef __VC_TIDL_H_ -#define __VC_TIDL_H_ +#ifndef __VC_MGR_TIDL_H_ +#define __VC_MGR_TIDL_H_ #include "voice_control_manager_internal.h" @@ -82,4 +82,4 @@ int vc_mgr_tidl_request_set_audio_streaming_mode(int pid, vc_audio_streaming_mod } #endif -#endif /* __VC_TIDL_H_ */ +#endif /* __VC_MGR_TIDL_H_ */ -- 2.7.4