From 0ac5da7b4acc098c2fa8fc68fd34dd07d9738478 Mon Sep 17 00:00:00 2001 From: ulgal-park Date: Thu, 19 May 2022 19:39:58 +0900 Subject: [PATCH 01/16] Change retry logic to match TIDL Change-Id: I50b7ca2aa38904ebbc92bcdf6ba2b3390995ea69 --- client/vc_mgr.c | 323 ++++++++++++------------------------------------ client/vc_mgr_tidl.c | 3 + client/vc_widget.c | 68 +++------- client/vc_widget_tidl.c | 3 + common/vc_defs.h | 1 + 5 files changed, 100 insertions(+), 298 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 9fd7862..6769fa1 100755 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -534,31 +534,31 @@ static Eina_Bool __request_initialize(void *data) static Eina_Bool __send_hello_message(void *data) { /* Send hello */ - // TODO: remove dbus after migrate from dbus to tidl done - if (0 != vc_mgr_dbus_request_hello()) { - if (g_dbus_send_hello_count == 20) { - g_dbus_send_hello_count = 0; + if (0 != vc_mgr_tidl_request_hello()) { + if (g_tidl_send_hello_count == VC_TIDL_RETRY_COUNT) { + g_tidl_send_hello_count = 0; SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request hello !! send error to manager"); __vc_mgr_cb_error(VC_ERROR_TIMED_OUT, -1, "voice_framework.error.vcfw.connect_engine_fail"); g_send_hello_timer = NULL; return EINA_FALSE; } else { - g_dbus_send_hello_count++; + // TODO: discuss when updating connect/reconnect + g_tidl_send_hello_count++; + usleep(200000); return EINA_TRUE; } } - /* Send hello */ - if (0 != vc_mgr_tidl_request_hello()) { - if (g_tidl_send_hello_count == 20) { - g_tidl_send_hello_count = 0; + // TODO: remove dbus after migrate from dbus to tidl done + if (0 != vc_mgr_dbus_request_hello()) { + if (g_dbus_send_hello_count == 20) { + g_dbus_send_hello_count = 0; SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request hello !! send error to manager"); __vc_mgr_cb_error(VC_ERROR_TIMED_OUT, -1, "voice_framework.error.vcfw.connect_engine_fail"); g_send_hello_timer = NULL; return EINA_FALSE; } else { - // TODO: discuss when updating connect/reconnect - g_tidl_send_hello_count++; + g_dbus_send_hello_count++; return EINA_TRUE; } } @@ -881,26 +881,12 @@ int vc_mgr_unset_demandable_client_rule(void) vc_info_parser_set_demandable_client(NULL); - int count = 0; - int ret = -1; - while (0 != ret) { - ret = vc_mgr_tidl_request_demandable_client(g_vc_m->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request unset client rule to daemon : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request unset client rule : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } + int 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)); } + // TODO: check return value correct or not return 0; } @@ -1132,24 +1118,10 @@ int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list) ret = VC_ERROR_INVALID_PARAMETER; SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to save command group : %s", __vc_mgr_get_error_code(ret)); } else { - int count = 0; - do { - ret = vc_mgr_tidl_request_set_command(g_vc_m->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request set command to daemon : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request set command : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } - } while (0 != ret); + ret = vc_mgr_tidl_request_set_command(g_vc_m->handle); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request set command to daemon : %s", __vc_mgr_get_error_code(ret)); + } } SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); @@ -1182,24 +1154,11 @@ int vc_mgr_unset_command_list(void) return VC_ERROR_INVALID_STATE; } - int count = 0; + int ret = -1; - while (0 != ret) { - ret = vc_mgr_tidl_request_unset_command(g_vc_m->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request unset command to daemon : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request unset command : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } + 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)); } int i; @@ -1211,6 +1170,7 @@ int vc_mgr_unset_command_list(void) SLOG(LOG_ERROR, TAG_VCM, "@@@"); + // TODO: check return value correct or not return 0; } @@ -1269,24 +1229,10 @@ int vc_mgr_set_command_list_from_file(const char* file_path, int type) ret = VC_ERROR_INVALID_PARAMETER; SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to save command list (%d)", ret); } else { - int count = 0; - do { - ret = vc_mgr_tidl_request_set_command(g_vc_m->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request set command to daemon : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request set command : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } - } while (0 != ret); + ret = vc_mgr_tidl_request_set_command(g_vc_m->handle); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request set command to daemon : %s", __vc_mgr_get_error_code(ret)); + } } SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); @@ -1385,29 +1331,14 @@ int vc_mgr_set_audio_type(const char* audio_id) } int ret = -1; - int count = 0; - /* Request */ - while (0 != ret) { - ret = vc_mgr_tidl_request_set_audio_type(g_vc_m->handle, audio_id); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set audio type : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry to set audio type : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set audio type"); - /* Save */ - vc_mgr_client_set_audio_type(g_vc_m, audio_id); - } + ret = vc_mgr_tidl_request_set_audio_type(g_vc_m->handle, audio_id); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set audio type : %s", __vc_mgr_get_error_code(ret)); + } else { + SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set audio type"); + /* Save */ + vc_mgr_client_set_audio_type(g_vc_m, audio_id); } SLOG(LOG_ERROR, TAG_VCM, "@@@, ret(%d)", ret); @@ -1463,22 +1394,10 @@ int vc_mgr_get_audio_type(char** audio_id) if (NULL == temp) { /* Not initiallized */ int ret = -1; - int count = 0; while (0 != ret) { ret = vc_mgr_tidl_request_get_audio_type(g_vc_m->handle, &temp); if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get audio type : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry to get audio type : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get audio type : %s", __vc_mgr_get_error_code(ret)); } else { SLOG(LOG_ERROR, TAG_VCM, "[SUCCESS] Get audio type : %s", temp); /* Save */ @@ -1493,6 +1412,7 @@ int vc_mgr_get_audio_type(char** audio_id) temp = NULL; } + // TODO: check return value correct or not return 0; } @@ -1548,7 +1468,6 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) int fg_pid = 0; int mgr_pid = 0; - int count = 0; int ret = -1; /* Get foreground pid */ @@ -1573,26 +1492,11 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) } /* Request */ - ret = -1; - count = 0; - while (0 != ret) { - ret = vc_mgr_tidl_request_set_client_info(g_vc_m->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set client info : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry to set client info : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set client info"); - } + ret = vc_mgr_tidl_request_set_client_info(g_vc_m->handle); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set client info : %s", __vc_mgr_get_error_code(ret)); + } else { + SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set client info"); } GSList *iter = NULL; @@ -1695,6 +1599,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) SLOG(LOG_ERROR, TAG_VCM, "@@@"); + // TODO: check return value correct or not return 0; } @@ -1876,29 +1781,17 @@ int vc_mgr_get_private_data(const char* key, char** data) } int ret = -1; - int count = 0; char* temp = NULL; - while (0 != ret) { - ret = vc_mgr_tidl_request_get_private_data(g_vc_m->handle, key, &temp); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to get private data request : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry get private data request : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Get private data, key(%s), data(%s)", key, temp); - } + + 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)); + } else { + SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Get private data, key(%s), data(%s)", key, temp); } + if (NULL != temp) { *data = strdup(temp); free(temp); @@ -1907,6 +1800,7 @@ int vc_mgr_get_private_data(const char* key, char** data) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); + // TODO: check return value correct or not return 0; } @@ -1952,26 +1846,14 @@ int vc_mgr_set_domain(const char* domain) } int ret = -1; - int count = 0; - while (0 != ret) { - ret = vc_mgr_tidl_request_set_domain(g_vc_m->handle, domain); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to set domain request : %s", __vc_mgr_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry set domain request : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set domain"); - } + + 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)); + } else { + SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set domain"); } + SLOG(LOG_DEBUG, TAG_VCM, "@@@"); return 0; @@ -2153,7 +2035,6 @@ int vc_mgr_start(bool exclusive_command_option) } int ret; - int count = 0; 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"); @@ -2161,29 +2042,13 @@ int vc_mgr_start(bool exclusive_command_option) /* Request */ ret = -1; - count = 0; - while (0 != ret) { - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_STARTING); - ret = vc_mgr_tidl_request_start(g_vc_m->handle, (int)recognition_mode, exclusive_command_option, start_by_client, disabled_cmd_type); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to start request start : %s", __vc_mgr_get_error_code(ret)); - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry start request start : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - vc_mgr_client_set_exclusive_command(g_vc_m, false); - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); - break; - } - } - } else { - SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] start recognition"); - } + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_STARTING); + ret = vc_mgr_tidl_request_start(g_vc_m->handle, (int)recognition_mode, exclusive_command_option, start_by_client, disabled_cmd_type); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to start request start : %s", __vc_mgr_get_error_code(ret)); + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); + } else { + SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] start recognition"); } g_volume_db = 0; @@ -2246,29 +2111,14 @@ int vc_mgr_stop(void) } int ret = -1; - int count = 0; /* do request */ - while (0 != ret) { - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_STOPPING); - ret = vc_mgr_tidl_request_stop(g_vc_m->handle); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to stop request : %s", __vc_mgr_get_error_code(ret)); - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry stop request : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); - break; - } - } - } else { - SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Stop recognition"); - } + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_STOPPING); + ret = vc_mgr_tidl_request_stop(g_vc_m->handle); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to stop request : %s", __vc_mgr_get_error_code(ret)); + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); + } else { + SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Stop recognition"); } SLOG(LOG_DEBUG, TAG_VCM, "@@@"); @@ -2326,28 +2176,13 @@ int vc_mgr_cancel(void) } int ret = -1; - int count = 0; - while (0 != ret) { - 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) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_DEBUG, TAG_VCM, "[ERROR] Fail to cancel request : %s", __vc_mgr_get_error_code(ret)); - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry cancel request : %s", __vc_mgr_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); - break; - } - } - } else { - SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Cancel recognition"); - } + 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) { + SLOG(LOG_DEBUG, TAG_VCM, "[ERROR] Fail to cancel request : %s", __vc_mgr_get_error_code(ret)); + vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); + } else { + SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Cancel recognition"); } vc_mgr_client_set_exclusive_command(g_vc_m, false); diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index a351965..daf53a1 100755 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -348,6 +348,9 @@ static void __on_disconnected(rpc_port_proxy_vc_mgr_h h, void *user_data) g_proxy_tidl_info->register_callback_invoked = false; SLOG(LOG_INFO, TAG_VCM, "Disonnected to server"); + + SLOG(LOG_INFO, TAG_VCM, "Re-connection start"); + __vc_mgr_cb_error(VC_ERROR_SERVICE_RESET, -1, "Server Disconnected, re-launch"); } static void __on_rejected(rpc_port_proxy_vc_mgr_h h, void *user_data) diff --git a/client/vc_widget.c b/client/vc_widget.c index c0d1b1e..f0e3b01 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -527,7 +527,7 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) return; } - if (retry_count == 30) { + if (retry_count == VC_TIDL_RETRY_COUNT) { SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request hello !!"); ecore_main_loop_thread_safe_call_async(__vc_widget_delete_focus_event_handler, NULL); g_w_prepare_thread = NULL; @@ -701,26 +701,13 @@ int vc_widget_enable_asr_result(vc_h vc_w, bool enable) return VC_ERROR_INVALID_STATE; } - int count = 0; int ret = -1; - do { - ret = vc_widget_tidl_request_enable_asr_result(getpid(), enable); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to enable asr result : %s", __vc_widget_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCW, "[WARNING] retry to enable asr result : %s", __vc_widget_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request"); - break; - } - } - } - } while (0 != ret); + ret = vc_widget_tidl_request_enable_asr_result(getpid(), enable); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to enable asr result : %s", __vc_widget_get_error_code(ret)); + return ret; + } vc_widget_client_set_asr_result_enabled(vc_w, enable); @@ -1150,29 +1137,16 @@ int vc_widget_cancel(vc_h vc_w) return VC_ERROR_INVALID_STATE; } - int count = 0; int ret = -1; - do { - ret = vc_widget_tidl_request_cancel(getpid()); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request cancel : %s", __vc_widget_get_error_code(ret)); - break; - } else { - SLOG(LOG_WARN, TAG_VCW, "[WARNING] retry request cancel : %s", __vc_widget_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request"); - break; - } - } - } - } while (0 != ret); + ret = vc_widget_tidl_request_cancel(getpid()); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request cancel : %s", __vc_widget_get_error_code(ret)); + } SLOG(LOG_DEBUG, TAG_VCW, "@@@"); + // TODO: check return value correct or not return 0; } @@ -1311,23 +1285,9 @@ static Eina_Bool __vc_widget_start_recording(void *data) } ret = -1; - count = 0; - while (0 != ret) { - ret = vc_widget_tidl_request_start_recording(getpid(), widget_command); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request start recording to daemon : %s", __vc_widget_get_error_code(ret)); - return EINA_FALSE; - } else { - SLOG(LOG_WARN, TAG_VCW, "[WARNING] retry start recording : %s", __vc_widget_get_error_code(ret)); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request"); - return EINA_FALSE; - } - } - } + ret = vc_widget_tidl_request_start_recording(getpid(), widget_command); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to request start recording to daemon : %s", __vc_widget_get_error_code(ret)); } return EINA_FALSE; diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index da50b61..1210668 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -162,6 +162,9 @@ static void __on_disconnected(rpc_port_proxy_vc_widget_h h, void *user_data) g_proxy_tidl_info->register_callback_invoked = false; SLOG(LOG_INFO, TAG_VCW, "Disonnected to server"); + + SLOG(LOG_INFO, TAG_VCW, "Re-connection start"); + __vc_widget_cb_error(VC_ERROR_SERVICE_RESET, -1, "Server Disconnected, re-launch"); } static void __on_rejected(rpc_port_proxy_vc_widget_h h, void *user_data) diff --git a/common/vc_defs.h b/common/vc_defs.h index 3ba15c5..81226ca 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -266,6 +266,7 @@ extern "C" { #define VC_RUNTIME_INFO_NO_FOREGROUND -1 #define VC_CONNECTION_RETRY_COUNT 10 #define VC_INVALID_TTS_UID 0 +#define VC_TIDL_RETRY_COUNT 100 #define VC_FEATURE_PATH "tizen.org/feature/speech.control" #define VC_MGR_FEATURE_PATH "tizen.org/feature/speech.control_manager" -- 2.7.4 From 90411c6dcdc96e08459f628b88439a4188cd85da Mon Sep 17 00:00:00 2001 From: sooyeon Date: Fri, 3 Jun 2022 18:10:20 +0900 Subject: [PATCH 02/16] Replace IPC (VCC) from dbus to tidl Change-Id: Ief592a9240490c404b756b37cb7b887c3a974321 Signed-off-by: sooyeon --- client/CMakeLists.txt | 3 +- client/vc.c | 51 +- client/vc_proxy.c | 2869 ++++++++++++++++++++++++++++++++++++++++++ client/vc_proxy.h | 819 ++++++++++++ client/vc_tidl.c | 708 +++++++++++ client/vc_tidl.h | 83 ++ common/vc_defs.h | 16 + common/vc_main.h | 28 + packaging/voice-control.spec | 8 +- server/vcd_client_data.c | 220 ++++ server/vcd_client_data.h | 22 + server/vcd_dbus.c | 145 ++- server/vcd_dbus.h | 8 +- server/vcd_stub.c | 2422 +++++++++++++++++++++++++++++++++++ server/vcd_stub.h | 680 ++++++++++ server/vcd_tidl.c | 495 ++++++++ server/vcd_tidl.h | 10 + tidl/vc.tidl | 28 + 18 files changed, 8509 insertions(+), 106 deletions(-) create mode 100755 client/vc_proxy.c create mode 100755 client/vc_proxy.h create mode 100755 client/vc_tidl.c create mode 100755 client/vc_tidl.h create mode 100755 server/vcd_stub.c create mode 100755 server/vcd_stub.h create mode 100755 tidl/vc.tidl diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index ab5f35f..0001ef9 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -2,7 +2,8 @@ SET(SRCS vc.c vc_data.cpp vc_client.c - vc_dbus.c +# vc_dbus.c + vc_tidl.c ../common/vc_cmd_db.c ../common/vc_command.c ../common/vc_command_util.c diff --git a/client/vc.c b/client/vc.c index f42cc66..0688716 100644 --- a/client/vc.c +++ b/client/vc.c @@ -30,7 +30,8 @@ #include "vc_command.h" #include "vc_config_mgr.h" #include "vc_data.h" -#include "vc_dbus.h" +// #include "vc_dbus.h" +#include "vc_tidl.h" #include "vc_info_parser.h" #include "vc_json_parser.h" #include "vc_main.h" @@ -268,7 +269,7 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) int ret; if (ECORE_WL2_EVENT_FOCUS_IN == type) { SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground"); - ret = vc_dbus_set_foreground(getpid(), true); + ret = vc_tidl_request_set_foreground(getpid(), true); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); } @@ -291,7 +292,7 @@ static Eina_Bool __focus_changed_cb(void *data, int type, void *event) } } else if (ECORE_WL2_EVENT_FOCUS_OUT == type) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Set background"); - ret = vc_dbus_set_foreground(getpid(), false); + ret = vc_tidl_request_set_foreground(getpid(), false); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (false) : %d", ret); } @@ -344,7 +345,7 @@ int vc_initialize(void) return VC_ERROR_NONE; //LCOV_EXCL_LINE } - if (0 != vc_dbus_open_connection()) { + if (0 != vc_tidl_open_connection()) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to open connection"); //LCOV_EXCL_LINE return VC_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } @@ -391,7 +392,7 @@ static void __vc_internal_unprepare(void) } } - int ret = vc_dbus_request_finalize(g_vc->handle); + int ret = vc_tidl_request_finalize(g_vc->handle); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } @@ -471,7 +472,7 @@ int vc_deinitialize(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to finalize DB, ret(%d)", ret); //LCOV_EXCL_LINE } - if (0 != vc_dbus_close_connection()) { + if (0 != vc_tidl_close_connection()) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to close connection"); //LCOV_EXCL_LINE } @@ -506,7 +507,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_dbus_request_initialize(g_vc->handle, &mgr_pid, &service_state, &g_daemon_pid); + ret = vc_tidl_request_initialize(g_vc->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)); @@ -565,7 +566,7 @@ static Eina_Bool __vc_connect_daemon(void *data) int status = aul_app_get_status(appid); if (STATUS_FOCUS == status) { SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground"); //LCOV_EXCL_LINE - ret = vc_dbus_set_foreground(getpid(), true); + ret = vc_tidl_request_set_foreground(getpid(), true); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); //LCOV_EXCL_LINE } @@ -614,7 +615,7 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) return; } - ret = vc_dbus_request_hello(); + ret = vc_tidl_request_hello(); if (ret == 0) { SLOG(LOG_DEBUG, TAG_VCC, "Success to request hello. retry count(%d)", retry_count); break; @@ -964,7 +965,7 @@ int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list) int ret = -1; bool is_prepared = false; do { - ret = vc_dbus_request_is_system_command_valid(g_vc->handle, &is_sys_cmd_valid); + ret = vc_tidl_request_is_system_command_valid(g_vc->handle, &is_sys_cmd_valid); if (0 != ret) { //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { @@ -1211,7 +1212,7 @@ int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type) int count = 0; bool is_prepared = false; do { - ret = vc_dbus_request_set_command(g_vc->handle, (vc_cmd_type_e)type); + 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) { @@ -1276,7 +1277,7 @@ int vc_unset_command_list(int type) int ret = -1; bool is_prepared = false; while (0 != ret) { - ret = vc_dbus_request_unset_command(g_vc->handle, (vc_cmd_type_e)type); + ret = vc_tidl_request_unset_command(g_vc->handle, (vc_cmd_type_e)type); if (0 != ret) { //LCOV_EXCL_START if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) { @@ -1366,7 +1367,7 @@ int vc_set_command_list_from_file(const char* file_path, int type) int count = 0; bool is_prepared = false; do { - ret = vc_dbus_request_set_command(g_vc->handle, (vc_cmd_type_e)type); + 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); @@ -2280,7 +2281,7 @@ int vc_set_server_dialog(const char* app_id, const char* credential) int count = 0; bool is_prepared = false; do { - ret = vc_dbus_set_server_dialog(pid, tmp_appid, 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); @@ -2364,7 +2365,7 @@ int vc_unset_server_dialog(const char* app_id) bool is_prepared = false; char* credential = strdup("#NULL"); do { - ret = vc_dbus_set_server_dialog(pid, tmp_appid, 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); @@ -2431,7 +2432,7 @@ int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_sta } 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_dbus_request_dialog(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; @@ -2477,7 +2478,7 @@ int vc_auth_enable(void) return VC_ERROR_OPERATION_FAILED; } - if (0 != vc_dbus_request_auth_enable(g_vc->handle, mgr_pid)) { + if (0 != vc_tidl_request_auth_enable(g_vc->handle, mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to authority enabled"); return VC_ERROR_OPERATION_FAILED; } @@ -2537,14 +2538,14 @@ int vc_auth_disable(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to unset state changed cb"); } - /* request return authority by dbus */ + /* request return authority by tidl */ int mgr_pid = -1; if (0 != vc_client_get_mgr_pid(g_vc, &mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get mgr info"); return VC_ERROR_OPERATION_FAILED; } - if (0 != vc_dbus_request_auth_disable(g_vc->handle, mgr_pid)) { + if (0 != vc_tidl_request_auth_disable(g_vc->handle, mgr_pid)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to authority disable"); return VC_ERROR_OPERATION_FAILED; } @@ -2697,7 +2698,7 @@ int vc_auth_start(void) bool is_prepared = false; /* Request */ while (0 != ret) { - ret = vc_dbus_request_auth_start(g_vc->handle, mgr_pid); + ret = vc_tidl_request_auth_start(g_vc->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); @@ -2778,7 +2779,7 @@ int vc_auth_stop(void) bool is_prepared = false; /* do request */ while (0 != ret) { - ret = vc_dbus_request_auth_stop(g_vc->handle, mgr_pid); + ret = vc_tidl_request_auth_stop(g_vc->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); @@ -2858,7 +2859,7 @@ int vc_auth_cancel(void) int count = 0; bool is_prepared = false; while (0 != ret) { - ret = vc_dbus_request_auth_cancel(g_vc->handle, mgr_pid); + ret = vc_tidl_request_auth_cancel(g_vc->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); @@ -3044,7 +3045,7 @@ int vc_tts_request(const char* text, const char* language, bool to_vc_manager, i int count = 0; bool is_prepared = false; do { - ret = vc_dbus_request_tts(pid, text, language, to_vc_manager, utt_id); + 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); @@ -3119,7 +3120,7 @@ int vc_tts_cancel(int utt_id) int count = 0; bool is_prepared = false; do { - ret = vc_dbus_cancel_tts(pid, 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); @@ -3189,7 +3190,7 @@ int vc_tts_get_synthesized_audio_details(int* rate, vc_audio_channel_e* channel, int count = 0; bool is_prepared = false; do { - ret = vc_dbus_get_tts_audio_format(pid, rate, channel, audio_type); + 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); diff --git a/client/vc_proxy.c b/client/vc_proxy.c new file mode 100755 index 0000000..d55b82d --- /dev/null +++ b/client/vc_proxy.c @@ -0,0 +1,2869 @@ +/* + * Generated by tidlc 1.8.1. + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vc_proxy.h" + +#undef LOG_TAG +#define LOG_TAG "RPC_PORT_PROXY" + +#undef _E +#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#undef _W +#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#undef _I +#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#undef _D +#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#ifndef TIDL_VERSION +#define TIDL_VERSION "1.8.1" +#endif + +#ifndef nullptr +#define nullptr NULL +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + +#ifndef STRING_GET +#define STRING_GET(x) ((x) ? x : "") +#endif + +typedef void (*rpc_port_proxy_delegate_cb)(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id); + +typedef struct rpc_port_proxy_array_char_s { + rpc_port_parcelable_t parcelable; + char *value; + int size; +} rpc_port_proxy_array_char_t; + +typedef struct rpc_port_proxy_vc_notify_cb_s { + rpc_port_parcelable_t parcelable; + int id; + int seq_id; + bool once; + rpc_port_proxy_vc_notify_cb_cb callback; + void *user_data; +} rpc_port_proxy_vc_notify_cb_t; + +typedef struct rpc_port_proxy_vc_feedback_cb_s { + rpc_port_parcelable_t parcelable; + int id; + int seq_id; + bool once; + rpc_port_proxy_vc_feedback_cb_cb callback; + void *user_data; +} rpc_port_proxy_vc_feedback_cb_t; + +typedef struct rpc_port_proxy_vc_s { + char *stub_appid; + rpc_port_proxy_h proxy; + rpc_port_h port; + rpc_port_h callback_port; + rpc_port_proxy_vc_callback_s callback; + void *user_data; + GList *delegates; + GRecMutex mutex; +} rpc_port_proxy_vc_t; + +static void __rpc_port_proxy_array_char_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_proxy_array_char_h h = data; + int i; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, h->size); + + for (i = 0; i < h->size; ++i) + rpc_port_parcel_write_byte(parcel, h->value[i]); +} + +static void __rpc_port_proxy_array_char_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_proxy_array_char_h h = data; + char value; + int ret; + int i; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + ret = rpc_port_parcel_read_array_count(parcel, &h->size); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to read array count. error(%d)", ret); + set_last_result(ret); + return; + } + + h->value = calloc(h->size, sizeof(char)); + if (h->value == nullptr) { + _E("Out of memory"); + set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); + return; + } + + for (i = 0; i < h->size; ++i) { + rpc_port_parcel_read_byte(parcel, &value); + h->value[i] = value; + } + + set_last_result(RPC_PORT_ERROR_NONE); +} + +int rpc_port_proxy_array_char_create(rpc_port_proxy_array_char_h *h) +{ + rpc_port_proxy_array_char_t *handle; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + handle = calloc(1, sizeof(rpc_port_proxy_array_char_t)); + if (handle == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + handle->parcelable.to = __rpc_port_proxy_array_char_to; + handle->parcelable.from = __rpc_port_proxy_array_char_from; + + *h = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_array_char_destroy(rpc_port_proxy_array_char_h h) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (h->value) + free(h->value); + + free(h); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_array_char_clone(rpc_port_proxy_array_char_h h, rpc_port_proxy_array_char_h *clone) +{ + rpc_port_proxy_array_char_h handle; + rpc_port_parcel_h parcel; + int ret; + + if (h == nullptr || clone == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_proxy_array_char_create(&handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret); + return ret; + } + + ret = rpc_port_parcel_create(&parcel); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret); + rpc_port_proxy_array_char_destroy(handle); + return ret; + } + + rpc_port_parcel_write(parcel, &h->parcelable, h); + rpc_port_parcel_read(parcel, &handle->parcelable, handle); + ret = get_last_result(); + rpc_port_parcel_destroy(parcel); + + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to read data. error(%d)", ret); + rpc_port_proxy_array_char_destroy(handle); + return ret; + } + + *clone = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_array_char_set(rpc_port_proxy_array_char_h h, char *value, int size) +{ + rpc_port_proxy_array_char_h handle; + rpc_port_proxy_array_char_h clone; + int ret; + + if (h == nullptr || value == nullptr || size <= 0) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_proxy_array_char_create(&handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret); + return ret; + } + + handle->value = (char *)value; + handle->size = size; + + ret = rpc_port_proxy_array_char_clone(handle, &clone); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to clone handle. error(%d)", ret); + handle->value = nullptr; + handle->size = 0; + rpc_port_proxy_array_char_destroy(handle); + return ret; + } + + handle->value = h->value; + handle->size = h->size; + rpc_port_proxy_array_char_destroy(handle); + + h->value = clone->value; + h->size = clone->size; + + clone->value = nullptr; + clone->size = 0; + rpc_port_proxy_array_char_destroy(clone); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_array_char_get(rpc_port_proxy_array_char_h h, char **value, int *size) +{ + rpc_port_proxy_array_char_h handle; + int ret; + + if (h == nullptr || value == nullptr || size == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_proxy_array_char_clone(h, &handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to clone handle. error(%d)", ret); + return ret; + } + + *value = handle->value; + *size = handle->size; + + handle->value = nullptr; + handle->size = 0; + rpc_port_proxy_array_char_destroy(handle); + + return RPC_PORT_ERROR_NONE; +} + +typedef enum { + RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB = 1, + RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB = 2, +} rpc_port_proxy_vc_delegate_e; + +static void __rpc_port_proxy_vc_notify_cb_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_proxy_vc_notify_cb_h h = data; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, h->id); + + rpc_port_parcel_write_int32(parcel, h->seq_id); + + rpc_port_parcel_write_bool(parcel, h->once); + + _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); +} + +static void __rpc_port_proxy_vc_notify_cb_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_proxy_vc_notify_cb_h h = data; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + rpc_port_parcel_read_int32(parcel, &h->id); + + rpc_port_parcel_read_int32(parcel, &h->seq_id); + + rpc_port_parcel_read_bool(parcel, &h->once); + + _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); + set_last_result(RPC_PORT_ERROR_NONE); +} + +int rpc_port_proxy_vc_notify_cb_create(rpc_port_proxy_vc_notify_cb_h *h) +{ + rpc_port_proxy_vc_notify_cb_t *handle; + static int seq_num; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + handle = calloc(1, sizeof(rpc_port_proxy_vc_notify_cb_t)); + if (handle == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + handle->parcelable.to = __rpc_port_proxy_vc_notify_cb_to; + handle->parcelable.from = __rpc_port_proxy_vc_notify_cb_from; + handle->id = RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + _I("id(%d), seq_id(%d)", handle->id, handle->seq_id); + + *h = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_destroy(rpc_port_proxy_vc_notify_cb_h h) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); + + free(h); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_clone(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_h *clone) +{ + rpc_port_proxy_vc_notify_cb_h handle; + rpc_port_parcel_h parcel; + int ret; + + if (h == nullptr || clone == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_proxy_vc_notify_cb_create(&handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret); + return ret; + } + + ret = rpc_port_parcel_create(&parcel); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret); + rpc_port_proxy_vc_notify_cb_destroy(handle); + return ret; + } + + rpc_port_parcel_write(parcel, &h->parcelable, h); + rpc_port_parcel_read(parcel, &handle->parcelable, handle); + ret = get_last_result(); + rpc_port_parcel_destroy(parcel); + + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to read data. error(%d)", ret); + rpc_port_proxy_vc_notify_cb_destroy(handle); + return ret; + } + + handle->callback = h->callback; + handle->user_data = h->user_data; + + *clone = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_set_callback(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_cb callback, void *user_data) +{ + if (h == nullptr || callback == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + h->callback = callback; + h->user_data = user_data; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_set_once(rpc_port_proxy_vc_notify_cb_h h, bool once) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + h->once = once; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_get_id(rpc_port_proxy_vc_notify_cb_h h, int *id) +{ + if (h == nullptr || id == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *id = h->id; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_get_seq_id(rpc_port_proxy_vc_notify_cb_h h, int *seq_id) +{ + if (h == nullptr || seq_id == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *seq_id = h->seq_id; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_is_once(rpc_port_proxy_vc_notify_cb_h h, bool *once) +{ + if (h == nullptr || once == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *once = h->once; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_get_tag(rpc_port_proxy_vc_notify_cb_h h, char **tag) +{ + char *new_tag; + char buf[128]; + + if (h == nullptr || tag == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id); + new_tag = strdup(buf); + if (new_tag == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + *tag = new_tag; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_notify_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_notify_cb_h h) +{ + GList *found; + + if (proxy == nullptr || h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + found = g_list_find(proxy->delegates, h); + if (found == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + proxy->delegates = g_list_remove_link(proxy->delegates, found); + rpc_port_proxy_vc_notify_cb_destroy(h); + g_list_free(found); + + return RPC_PORT_ERROR_NONE; +} + +static void __rpc_port_proxy_vc_notify_cb_delegate_handler(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id) +{ + rpc_port_proxy_vc_notify_cb_h handle; + GList *iter; + bool once; + int pid = -1; + bundle *msg = nullptr; + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_bundle(parcel, &msg); + if (msg == nullptr) { + _E("Failed to read data"); + goto out; + } + + iter = *delegates; + while (iter) { + handle = iter->data; + iter = g_list_next(iter); + if (handle->id == id && handle->seq_id == seq_id) { + once = handle->once; + _W("Invoke id(%d), seq_id(%d)", id, seq_id); + if (handle->callback) + handle->callback(handle->user_data, pid, msg); + else + _W("The callback function is nullptr"); + + if (once) { + *delegates = g_list_remove(*delegates, handle); + rpc_port_proxy_vc_notify_cb_destroy(handle); + } + + break; + } + } + +out: + + if (msg) + bundle_free(msg); +} + +static void __rpc_port_proxy_vc_feedback_cb_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_proxy_vc_feedback_cb_h h = data; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, h->id); + + rpc_port_parcel_write_int32(parcel, h->seq_id); + + rpc_port_parcel_write_bool(parcel, h->once); + + _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); +} + +static void __rpc_port_proxy_vc_feedback_cb_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_proxy_vc_feedback_cb_h h = data; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + rpc_port_parcel_read_int32(parcel, &h->id); + + rpc_port_parcel_read_int32(parcel, &h->seq_id); + + rpc_port_parcel_read_bool(parcel, &h->once); + + _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); + set_last_result(RPC_PORT_ERROR_NONE); +} + +int rpc_port_proxy_vc_feedback_cb_create(rpc_port_proxy_vc_feedback_cb_h *h) +{ + rpc_port_proxy_vc_feedback_cb_t *handle; + static int seq_num; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + handle = calloc(1, sizeof(rpc_port_proxy_vc_feedback_cb_t)); + if (handle == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + handle->parcelable.to = __rpc_port_proxy_vc_feedback_cb_to; + handle->parcelable.from = __rpc_port_proxy_vc_feedback_cb_from; + handle->id = RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + _I("id(%d), seq_id(%d)", handle->id, handle->seq_id); + + *h = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_destroy(rpc_port_proxy_vc_feedback_cb_h h) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); + + free(h); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_clone(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_h *clone) +{ + rpc_port_proxy_vc_feedback_cb_h handle; + rpc_port_parcel_h parcel; + int ret; + + if (h == nullptr || clone == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_proxy_vc_feedback_cb_create(&handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret); + return ret; + } + + ret = rpc_port_parcel_create(&parcel); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret); + rpc_port_proxy_vc_feedback_cb_destroy(handle); + return ret; + } + + rpc_port_parcel_write(parcel, &h->parcelable, h); + rpc_port_parcel_read(parcel, &handle->parcelable, handle); + ret = get_last_result(); + rpc_port_parcel_destroy(parcel); + + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to read data. error(%d)", ret); + rpc_port_proxy_vc_feedback_cb_destroy(handle); + return ret; + } + + handle->callback = h->callback; + handle->user_data = h->user_data; + + *clone = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_set_callback(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_cb callback, void *user_data) +{ + if (h == nullptr || callback == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + h->callback = callback; + h->user_data = user_data; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_set_once(rpc_port_proxy_vc_feedback_cb_h h, bool once) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + h->once = once; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_get_id(rpc_port_proxy_vc_feedback_cb_h h, int *id) +{ + if (h == nullptr || id == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *id = h->id; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_get_seq_id(rpc_port_proxy_vc_feedback_cb_h h, int *seq_id) +{ + if (h == nullptr || seq_id == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *seq_id = h->seq_id; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_is_once(rpc_port_proxy_vc_feedback_cb_h h, bool *once) +{ + if (h == nullptr || once == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *once = h->once; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_get_tag(rpc_port_proxy_vc_feedback_cb_h h, char **tag) +{ + char *new_tag; + char buf[128]; + + if (h == nullptr || tag == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id); + new_tag = strdup(buf); + if (new_tag == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + *tag = new_tag; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_feedback_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_feedback_cb_h h) +{ + GList *found; + + if (proxy == nullptr || h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + found = g_list_find(proxy->delegates, h); + if (found == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + proxy->delegates = g_list_remove_link(proxy->delegates, found); + rpc_port_proxy_vc_feedback_cb_destroy(h); + g_list_free(found); + + return RPC_PORT_ERROR_NONE; +} + +static void __rpc_port_proxy_vc_feedback_cb_delegate_handler(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id) +{ + rpc_port_proxy_vc_feedback_cb_h handle; + GList *iter; + bool once; + int utt_id = -1; + int event = -1; + rpc_port_proxy_array_char_h pcm_data = nullptr; + int len = -1; + + rpc_port_parcel_read_int32(parcel, &utt_id); + + rpc_port_parcel_read_int32(parcel, &event); + + rpc_port_proxy_array_char_create(&pcm_data); + if (pcm_data == nullptr) { + _E("Failed to create handle"); + goto out; + } + + rpc_port_parcel_read(parcel, &pcm_data->parcelable, pcm_data); + if (get_last_result() != RPC_PORT_ERROR_NONE) { + _E("Failed to read data"); + goto out; + } + + rpc_port_parcel_read_int32(parcel, &len); + + iter = *delegates; + while (iter) { + handle = iter->data; + iter = g_list_next(iter); + if (handle->id == id && handle->seq_id == seq_id) { + once = handle->once; + _W("Invoke id(%d), seq_id(%d)", id, seq_id); + if (handle->callback) + handle->callback(handle->user_data, utt_id, event, pcm_data, len); + else + _W("The callback function is nullptr"); + + if (once) { + *delegates = g_list_remove(*delegates, handle); + rpc_port_proxy_vc_feedback_cb_destroy(handle); + } + + break; + } + } + +out: + + if (pcm_data) + rpc_port_proxy_array_char_destroy(pcm_data); +} + +static rpc_port_proxy_delegate_cb __rpc_port_proxy_vc_delegate_table[] = { + [RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB] = __rpc_port_proxy_vc_notify_cb_delegate_handler, + [RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB] = __rpc_port_proxy_vc_feedback_cb_delegate_handler, +}; + +typedef enum { + RPC_PORT_PROXY_VC_METHOD_RESULT_, + RPC_PORT_PROXY_VC_METHOD_CALLBACK_, + RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB, + RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB_SYNC, + RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB, + RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC, + RPC_PORT_PROXY_VC_METHOD_INITIALIZE, + RPC_PORT_PROXY_VC_METHOD_FINALIZE, + RPC_PORT_PROXY_VC_METHOD_SET_COMMAND, + RPC_PORT_PROXY_VC_METHOD_UNSET_COMMAND, + RPC_PORT_PROXY_VC_METHOD_SET_FOREGROUND, + RPC_PORT_PROXY_VC_METHOD_SET_SERVER_DIALOG, + RPC_PORT_PROXY_VC_METHOD_REQUEST_DIALOG, + RPC_PORT_PROXY_VC_METHOD_IS_SYSTEM_COMMAND_VALID, + RPC_PORT_PROXY_VC_METHOD_AUTH_ENABLE, + RPC_PORT_PROXY_VC_METHOD_AUTH_DISABLE, + RPC_PORT_PROXY_VC_METHOD_AUTH_START, + RPC_PORT_PROXY_VC_METHOD_AUTH_STOP, + RPC_PORT_PROXY_VC_METHOD_AUTH_CANCEL, + RPC_PORT_PROXY_VC_METHOD_REQUEST_TTS, + RPC_PORT_PROXY_VC_METHOD_CANCEL_TTS, + RPC_PORT_PROXY_VC_METHOD_GET_TTS_AUDIO_FORMAT, +} rpc_port_proxy_vc_method_e; + +static void __rpc_port_proxy_vc_process_received_event(GList **delegates, rpc_port_parcel_h parcel) +{ + int id = 0; + int seq_id = 0; + bool once = false; + + rpc_port_parcel_read_int32(parcel, &id); + rpc_port_parcel_read_int32(parcel, &seq_id); + rpc_port_parcel_read_bool(parcel, &once); + _W("id(%d), seq_id(%d)", id, seq_id); + + if (id > 0 && id < ARRAY_SIZE(__rpc_port_proxy_vc_delegate_table)) { + if (__rpc_port_proxy_vc_delegate_table[id]) + __rpc_port_proxy_vc_delegate_table[id](delegates, parcel, id, seq_id); + } else { + _W("Unknown ID(%d)", id); + } +} + +static void __rpc_port_proxy_vc_consume_command(rpc_port_h port, rpc_port_parcel_h *p) +{ + rpc_port_parcel_h parcel; + int cmd = -1; + int ret; + + do { + ret = rpc_port_parcel_create_from_port(&parcel, port); + if (ret != RPC_PORT_ERROR_NONE) + break; + + rpc_port_parcel_read_int32(parcel, &cmd); + if (cmd == RPC_PORT_PROXY_VC_METHOD_RESULT_) { + *p = parcel; + return; + } + + rpc_port_parcel_destroy(parcel); + } while (true); + + *p = nullptr; +} + +static void __rpc_port_proxy_vc_connected(const char *endpoint, const char *port_name, rpc_port_h port, void *data) +{ + rpc_port_proxy_vc_h h = data; + + _I("endpoint(%s), port_name(%s)", endpoint, port_name); + h->port = port; + rpc_port_proxy_get_port(h->proxy, RPC_PORT_PORT_CALLBACK, &h->callback_port); + h->callback.connected(h, h->user_data); +} + +static void __rpc_port_proxy_vc_disconnected(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_vc_h h = data; + + _W("endpoint(%s), port_name(%s)", endpoint, port_name); + h->port = nullptr; + h->callback.disconnected(h, h->user_data); +} + +static void __rpc_port_proxy_vc_rejected(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_vc_h h = data; + + _W("endpoint(%s), port_name(%s)", endpoint, port_name); + h->port = nullptr; + h->callback.rejected(h, h->user_data); +} + +static void __rpc_port_proxy_vc_received(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_vc_h h = data; + rpc_port_parcel_h parcel; + int cmd = -1; + int ret; + + _W("endpoint(%s), port_name(%s)", endpoint, port_name); + ret = rpc_port_parcel_create_from_port(&parcel, h->callback_port); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle from port. error(%d)", ret); + return; + } + + rpc_port_parcel_read_int32(parcel, &cmd); + if (cmd != RPC_PORT_PROXY_VC_METHOD_CALLBACK_) { + _E("Invalid protocol"); + rpc_port_parcel_destroy(parcel); + return; + } + + __rpc_port_proxy_vc_process_received_event(&h->delegates, parcel); + rpc_port_parcel_destroy(parcel); +} + +int rpc_port_proxy_vc_create(const char *stub_appid, rpc_port_proxy_vc_callback_s *callback, void *user_data, rpc_port_proxy_vc_h *h) +{ + rpc_port_proxy_vc_t *handle; + int ret; + + if (stub_appid == nullptr || callback == nullptr || h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (callback->connected == nullptr || callback->disconnected == nullptr || callback->rejected == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + handle = calloc(1, sizeof(rpc_port_proxy_vc_t)); + if (handle == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + g_rec_mutex_init(&handle->mutex); + + handle->stub_appid = strdup(stub_appid); + if (handle->stub_appid == nullptr) { + _E("Failed to duplicate stub appid"); + rpc_port_proxy_vc_destroy(handle); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + ret = rpc_port_proxy_create(&handle->proxy); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create proxy handle. error(%d)", ret); + rpc_port_proxy_vc_destroy(handle); + return ret; + } + + handle->callback = *callback; + handle->user_data = user_data; + + ret = rpc_port_proxy_add_connected_event_cb(handle->proxy, __rpc_port_proxy_vc_connected, handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to add connected event cb. error(%d)", ret); + rpc_port_proxy_vc_destroy(handle); + return ret; + } + + ret = rpc_port_proxy_add_disconnected_event_cb(handle->proxy, __rpc_port_proxy_vc_disconnected, handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to add disconnected event cb. error(%d)", ret); + rpc_port_proxy_vc_destroy(handle); + return ret; + } + + ret = rpc_port_proxy_add_rejected_event_cb(handle->proxy, __rpc_port_proxy_vc_rejected, handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to add rejected event cb. error(%d)", ret); + rpc_port_proxy_vc_destroy(handle); + return ret; + } + + ret = rpc_port_proxy_add_received_event_cb(handle->proxy, __rpc_port_proxy_vc_received, handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to add received event cb. error(%d)", ret); + rpc_port_proxy_vc_destroy(handle); + return ret; + } + + *h = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_destroy(rpc_port_proxy_vc_h h) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + g_rec_mutex_lock(&h->mutex); + g_rec_mutex_unlock(&h->mutex); + g_rec_mutex_clear(&h->mutex); + + if (h->delegates) + g_list_free_full(h->delegates, free); + + if (h->proxy) + rpc_port_proxy_destroy(h->proxy); + + if (h->stub_appid) + free(h->stub_appid); + + free(h); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_connect(rpc_port_proxy_vc_h h) +{ + int ret; + + if (h == nullptr || h->proxy == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_proxy_connect(h->proxy, h->stub_appid, "vc"); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to connect to stub. error(%d)", ret); + return ret; + } + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_connect_sync(rpc_port_proxy_vc_h h) +{ + int ret; + + if (h == nullptr || h->proxy == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_proxy_connect_sync(h->proxy, h->stub_appid, "vc"); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to connect to stub. error(%d)", ret); + return ret; + } + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_proxy_vc_disconnect(rpc_port_proxy_vc_h h) +{ + int ret; + + if (h == nullptr || h->proxy == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_disconnect(h->port); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to disconnect from stub. error(%d)", ret); + return ret; + } + + return RPC_PORT_ERROR_NONE; +} + +void rpc_port_proxy_vc_invoke_register_notify_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int res_; + + if (h == nullptr || callback == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + g_rec_mutex_unlock(&h->mutex); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + return; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write(parcel_, &callback->parcelable, callback); + + h->delegates = g_list_append(h->delegates, callback); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) + _E("Failed to send parcel. error(%d)", res_); + + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); +} + +int rpc_port_proxy_vc_invoke_register_notify_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr || callback == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB_SYNC); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write(parcel_, &callback->parcelable, callback); + + h->delegates = g_list_append(h->delegates, callback); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +void rpc_port_proxy_vc_invoke_register_feedback_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int res_; + + if (h == nullptr || callback == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + g_rec_mutex_unlock(&h->mutex); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + return; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write(parcel_, &callback->parcelable, callback); + + h->delegates = g_list_append(h->delegates, callback); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) + _E("Failed to send parcel. error(%d)", res_); + + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); +} + +int rpc_port_proxy_vc_invoke_register_feedback_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr || callback == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write(parcel_, &callback->parcelable, callback); + + h->delegates = g_list_append(h->delegates, callback); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_initialize(rpc_port_proxy_vc_h h, int pid, int *mgr_pid, int *service_state, int *daemon_pid) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + int new_mgr_pid; + int new_service_state; + int new_daemon_pid; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_INITIALIZE); + + rpc_port_parcel_write_int32(parcel_, pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &new_mgr_pid); + + *mgr_pid = new_mgr_pid; + + rpc_port_parcel_read_int32(parcel_, &new_service_state); + + *service_state = new_service_state; + + rpc_port_parcel_read_int32(parcel_, &new_daemon_pid); + + *daemon_pid = new_daemon_pid; + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_finalize(rpc_port_proxy_vc_h h, int pid) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_FINALIZE); + + rpc_port_parcel_write_int32(parcel_, pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_set_command(rpc_port_proxy_vc_h h, int pid, int cmd_type) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_COMMAND); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_int32(parcel_, cmd_type); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_unset_command(rpc_port_proxy_vc_h h, int pid, int cmd_type) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_UNSET_COMMAND); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_int32(parcel_, cmd_type); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_set_foreground(rpc_port_proxy_vc_h h, int pid, bool value) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_FOREGROUND); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_bool(parcel_, value); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_set_server_dialog(rpc_port_proxy_vc_h h, int pid, const char *app_id, const char *credential) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr || app_id == nullptr || credential == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_SERVER_DIALOG); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_string(parcel_, app_id); + + rpc_port_parcel_write_string(parcel_, credential); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_request_dialog(rpc_port_proxy_vc_h h, int pid, const char *disp_text, const char *utt_text, bool continuous) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr || disp_text == nullptr || utt_text == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REQUEST_DIALOG); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_string(parcel_, disp_text); + + rpc_port_parcel_write_string(parcel_, utt_text); + + rpc_port_parcel_write_bool(parcel_, continuous); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_is_system_command_valid(rpc_port_proxy_vc_h h, int pid, bool *is_sys_cmd_valid) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + bool new_is_sys_cmd_valid; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_IS_SYSTEM_COMMAND_VALID); + + rpc_port_parcel_write_int32(parcel_, pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_bool(parcel_, &new_is_sys_cmd_valid); + + *is_sys_cmd_valid = new_is_sys_cmd_valid; + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_auth_enable(rpc_port_proxy_vc_h h, int pid, int mgr_pid) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_ENABLE); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_int32(parcel_, mgr_pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_auth_disable(rpc_port_proxy_vc_h h, int pid, int mgr_pid) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_DISABLE); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_int32(parcel_, mgr_pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_auth_start(rpc_port_proxy_vc_h h, int pid, int mgr_pid) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_START); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_int32(parcel_, mgr_pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_auth_stop(rpc_port_proxy_vc_h h, int pid, int mgr_pid) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_STOP); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_int32(parcel_, mgr_pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_auth_cancel(rpc_port_proxy_vc_h h, int pid, int mgr_pid) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_CANCEL); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_int32(parcel_, mgr_pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_request_tts(rpc_port_proxy_vc_h h, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + int new_utt_id; + + if (h == nullptr || text == nullptr || lang == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REQUEST_TTS); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_string(parcel_, text); + + rpc_port_parcel_write_string(parcel_, lang); + + rpc_port_parcel_write_bool(parcel_, to_vcm); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &new_utt_id); + + *utt_id = new_utt_id; + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_cancel_tts(rpc_port_proxy_vc_h h, int pid, int utt_id) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_CANCEL_TTS); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_int32(parcel_, utt_id); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} + +int rpc_port_proxy_vc_invoke_get_tts_audio_format(rpc_port_proxy_vc_h h, int pid, int *rate, int *channel, int *audio_type) +{ + rpc_port_parcel_h parcel_; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + int recv_seq_num_ = -1; + char *tag_ = nullptr; + bool done_ = false; + int res_; + int ret_ = -1; + int new_rate; + int new_channel; + int new_audio_type; + + if (h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return ret_; + } + + g_rec_mutex_lock(&h->mutex); + if (h->port == nullptr) { + _E("Not connected"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + res_ = rpc_port_parcel_create(&parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_GET_TTS_AUDIO_FORMAT); + + rpc_port_parcel_write_int32(parcel_, pid); + + res_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + if (res_ != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. error(%d)", res_); + set_last_result(res_); + g_rec_mutex_unlock(&h->mutex); + return ret_; + } + + do { + parcel_ = nullptr; + __rpc_port_proxy_vc_consume_command(h->port, &parcel_); + if (parcel_ == nullptr) { + _E("Invalid protocol"); + res_ = RPC_PORT_ERROR_IO_ERROR; + break; + } + + header_ = nullptr; + rpc_port_parcel_get_header(parcel_, &header_); + tag_ = nullptr; + rpc_port_parcel_header_get_tag(header_, &tag_); + if (tag_ && tag_[0] != '\0') { + _W("[Version] %s", tag_); + rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); + if (recv_seq_num_ != seq_num_) { + _E("Invalid protocol. %d", recv_seq_num_); + free(tag_); + rpc_port_parcel_destroy(parcel_); + continue; + } + } + done_ = true; + free(tag_); + + rpc_port_parcel_read_int32(parcel_, &new_rate); + + *rate = new_rate; + + rpc_port_parcel_read_int32(parcel_, &new_channel); + + *channel = new_channel; + + rpc_port_parcel_read_int32(parcel_, &new_audio_type); + + *audio_type = new_audio_type; + + rpc_port_parcel_read_int32(parcel_, &ret_); + + rpc_port_parcel_destroy(parcel_); + } while (!done_); + g_rec_mutex_unlock(&h->mutex); + set_last_result(res_); + + return ret_; +} diff --git a/client/vc_proxy.h b/client/vc_proxy.h new file mode 100755 index 0000000..5b2fa31 --- /dev/null +++ b/client/vc_proxy.h @@ -0,0 +1,819 @@ +/* + * Generated by tidlc 1.8.1. + */ + +#pragma once + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The rpc_port_proxy_array_char handle. + */ +typedef struct rpc_port_proxy_array_char_s *rpc_port_proxy_array_char_h; + +/** + * @brief The rpc_port_proxy_vc handle. + */ +typedef struct rpc_port_proxy_vc_s *rpc_port_proxy_vc_h; + +/** + * @brief The rpc_port_proxy_vc_notify_cb handle. + */ +typedef struct rpc_port_proxy_vc_notify_cb_s *rpc_port_proxy_vc_notify_cb_h; + +/** + * @brief The rpc_port_proxy_vc_feedback_cb handle. + */ +typedef struct rpc_port_proxy_vc_feedback_cb_s *rpc_port_proxy_vc_feedback_cb_h; + +/** + * @briefs Creates a rpc_port_proxy_array_char handle. + * + * @remarks The @a h should be released using the rpc_port_proxy_array_char_destroy() + * if it's no longer needed. + * @param[out] h The rpc_port_proxy_array_char handle that is newly created + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_proxy_array_char_destroy() + */ +int rpc_port_proxy_array_char_create(rpc_port_proxy_array_char_h *h); + +/** + * @brief Destroys the rpc_port_proxy_array_char handle. + * + * @param[in] h The rpc_port_proxy_array_char handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_proxy_array_char_create() + */ +int rpc_port_proxy_array_char_destroy(rpc_port_proxy_array_char_h h); + +/** + * @brief Creates and returns a copy of the given rpc_port_proxy_array_char handle. + * + * @remarks A new created rpc_port_proxy_array_char should be released using + * the rpc_port_proxy_array_char_destroy() if it's no longer needed. + * @param[in] h The rpc_port_proxy_array_char handle + * @param[out] clone If successful, a new created rpc_port_proxy_array_char handle will be returned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_proxy_array_char_destroy() + */ +int rpc_port_proxy_array_char_clone(rpc_port_proxy_array_char_h h, rpc_port_proxy_array_char_h *clone); + +/** + * @brief Sets the value to the rpc_port_proxy_array_char handle. + * + * @remarks The value is internally copied and stored. + * You should release it if it's allocaed when it's no longer needed, + * @param[in] h The rpc_port_proxy_array_char handle + * @param[in] value The array value + * @param[in] size The size of the array + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_proxy_array_char_get() + */ +int rpc_port_proxy_array_char_set(rpc_port_proxy_array_char_h h, char *value, int size); + +/** + * @brief Gets the value from the rpc_port_proxy_array_char handle. + * + * @remarks A new created value should be released if it's no longer needed. + * @param[in] h The rpc_port_proxy_array_char handle + * @param[out] value The array value + * @param[out] size The size of the array + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_proxy_array_char_set() + */ +int rpc_port_proxy_array_char_get(rpc_port_proxy_array_char_h h, char **value, int *size); + +/** + * @brief Called when the event is received. + * + * @param[in] user_data The user data passed from the callback registration function + * @param[in] ... + * + * @see rpc_port_proxy_vc_notify_cb_create() + */ +typedef void (*rpc_port_proxy_vc_notify_cb_cb)(void *user_data, int pid, bundle *msg); + +/** + * @brief Creates a rpc_port_proxy_vc_notify_cb handle. + * + * @param[out] h The rpc_port_proxy_vc_notify_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memorya + * @see rpc_port_proxy_vc_notify_cb_destroy() + * @see rpc_port_proxy_vc_notify_cb_dispose() + * @see rpc_port_proxy_vc_notify_cb_set_callback() + * @see rpc_port_proxy_vc_notify_cb_set_once() + */ +int rpc_port_proxy_vc_notify_cb_create(rpc_port_proxy_vc_notify_cb_h *h); + +/** + * @brief Destroys the rpc_port_proxy_vc_notify_cb handle. + * + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_proxy_vc_notify_cb_create() + */ +int rpc_port_proxy_vc_notify_cb_destroy(rpc_port_proxy_vc_notify_cb_h h); + +/** + * @brief Creates and returns a copy of the given rpc_port_proxy_vc_notify_cb handle. + * + * @remarks A new created rpc_port_proxy_vc_notify_cb should be released using + * the rpc_port_proxy_vc_notify_cb_destroy() if it's no longer needed. + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @param[out] clone If successful, a new created rpc_port_proxy_vc_notify_cb handle will be returned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_proxy_vc_notify_cb_destroy() + */ +int rpc_port_proxy_vc_notify_cb_clone(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_h *clone); + +/** + * @brief Sets the callback function to the rpc_port_proxy_vc_notify_cb handle. + * + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @param[in] callback The callback function + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_notify_cb_set_callback(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_cb callback, void *user_data); + +/** + * @brief Set the once flag to the rpc_port_proxy_vc_notify_cb handle. + * @details If the once flag is 'true', the delegate handle will be deleted after invocation. + * If the @a h handle is not used using the method, the handle should be released using + * the rpc_port_proxy_vc_notify_cb_destroy() when it's no longer needed. + * If you don't want the delegate callback function to be called after it's used using the method, + * you should release the handle using the rpc_port_proxy_vc_notify_cb_dispose(). + * + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @param[in] once The flag if it's true, the delegate will be deleted after invocation + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_notify_cb_set_once(rpc_port_proxy_vc_notify_cb_h h, bool once); + +/** + * @brief Gets the ID of the rpc_port_proxy_vc_notify_cb handle. + * + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @param[out] id The ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_notify_cb_get_id(rpc_port_proxy_vc_notify_cb_h h, int *id); + +/** + * @brief Gets the sequence ID of the rpc_port_proxy_vc_notify_cb handle. + * + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @param[out] seq_id The Sequence ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_notify_cb_get_seq_id(rpc_port_proxy_vc_notify_cb_h h, int *seq_id); + +/** + * @brief Checks whether the delegate is for one-time or not. + * + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @param[out] once The flag, it's true, the handle is for one-time + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_notify_cb_is_once(rpc_port_proxy_vc_notify_cb_h h, bool *once); + +/** + * @brief Gets the tag from the rpc_port_proxy_vc_notify_cb handle. + * + * @remarks The @a tag should be released using free(). + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @param[out] tag The tag + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + */ +int rpc_port_proxy_vc_notify_cb_get_tag(rpc_port_proxy_vc_notify_cb_h h, char **tag); + +/** + * @brief Disposes the rpc_port_proxy_vc_notify_cb handle from the rpc_port_proxy_vc handle. + * + * @param[in] proxy The rpc_port_proxy_vc handle + * @param[in] h The rpc_port_proxy_vc_notify_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_proxy_vc_notify_cb_create() + */ +int rpc_port_proxy_vc_notify_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_notify_cb_h h); + +/** + * @brief Called when the event is received. + * + * @param[in] user_data The user data passed from the callback registration function + * @param[in] ... + * + * @see rpc_port_proxy_vc_feedback_cb_create() + */ +typedef void (*rpc_port_proxy_vc_feedback_cb_cb)(void *user_data, int utt_id, int event, rpc_port_proxy_array_char_h pcm_data, int len); + +/** + * @brief Creates a rpc_port_proxy_vc_feedback_cb handle. + * + * @param[out] h The rpc_port_proxy_vc_feedback_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memorya + * @see rpc_port_proxy_vc_feedback_cb_destroy() + * @see rpc_port_proxy_vc_feedback_cb_dispose() + * @see rpc_port_proxy_vc_feedback_cb_set_callback() + * @see rpc_port_proxy_vc_feedback_cb_set_once() + */ +int rpc_port_proxy_vc_feedback_cb_create(rpc_port_proxy_vc_feedback_cb_h *h); + +/** + * @brief Destroys the rpc_port_proxy_vc_feedback_cb handle. + * + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_proxy_vc_feedback_cb_create() + */ +int rpc_port_proxy_vc_feedback_cb_destroy(rpc_port_proxy_vc_feedback_cb_h h); + +/** + * @brief Creates and returns a copy of the given rpc_port_proxy_vc_feedback_cb handle. + * + * @remarks A new created rpc_port_proxy_vc_feedback_cb should be released using + * the rpc_port_proxy_vc_feedback_cb_destroy() if it's no longer needed. + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @param[out] clone If successful, a new created rpc_port_proxy_vc_feedback_cb handle will be returned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_proxy_vc_feedback_cb_destroy() + */ +int rpc_port_proxy_vc_feedback_cb_clone(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_h *clone); + +/** + * @brief Sets the callback function to the rpc_port_proxy_vc_feedback_cb handle. + * + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @param[in] callback The callback function + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_feedback_cb_set_callback(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_cb callback, void *user_data); + +/** + * @brief Set the once flag to the rpc_port_proxy_vc_feedback_cb handle. + * @details If the once flag is 'true', the delegate handle will be deleted after invocation. + * If the @a h handle is not used using the method, the handle should be released using + * the rpc_port_proxy_vc_feedback_cb_destroy() when it's no longer needed. + * If you don't want the delegate callback function to be called after it's used using the method, + * you should release the handle using the rpc_port_proxy_vc_feedback_cb_dispose(). + * + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @param[in] once The flag if it's true, the delegate will be deleted after invocation + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_feedback_cb_set_once(rpc_port_proxy_vc_feedback_cb_h h, bool once); + +/** + * @brief Gets the ID of the rpc_port_proxy_vc_feedback_cb handle. + * + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @param[out] id The ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_feedback_cb_get_id(rpc_port_proxy_vc_feedback_cb_h h, int *id); + +/** + * @brief Gets the sequence ID of the rpc_port_proxy_vc_feedback_cb handle. + * + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @param[out] seq_id The Sequence ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_feedback_cb_get_seq_id(rpc_port_proxy_vc_feedback_cb_h h, int *seq_id); + +/** + * @brief Checks whether the delegate is for one-time or not. + * + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @param[out] once The flag, it's true, the handle is for one-time + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_feedback_cb_is_once(rpc_port_proxy_vc_feedback_cb_h h, bool *once); + +/** + * @brief Gets the tag from the rpc_port_proxy_vc_feedback_cb handle. + * + * @remarks The @a tag should be released using free(). + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @param[out] tag The tag + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + */ +int rpc_port_proxy_vc_feedback_cb_get_tag(rpc_port_proxy_vc_feedback_cb_h h, char **tag); + +/** + * @brief Disposes the rpc_port_proxy_vc_feedback_cb handle from the rpc_port_proxy_vc handle. + * + * @param[in] proxy The rpc_port_proxy_vc handle + * @param[in] h The rpc_port_proxy_vc_feedback_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_proxy_vc_feedback_cb_create() + */ +int rpc_port_proxy_vc_feedback_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_feedback_cb_h h); + +/** + * @brief Called when the proxy is connected. + * @details The callback function is called when the proxy is connected to the stub. + * + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] user_data The user data passed from the registeration function + * @see #rpc_port_proxy_vc_callback_s + */ +typedef void (*rpc_port_proxy_vc_connected_cb)(rpc_port_proxy_vc_h h, void *user_data); + +/** + * @brief Called when the proxy is disconnected. + * @details The callback function is called when the proxy is disconnected from the stub. + * + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] user_data The user data passed from the registeration function + * @see #rpc_port_proxy_vc_callback_s + */ +typedef void (*rpc_port_proxy_vc_disconnected_cb)(rpc_port_proxy_vc_h h, void *user_data); + +/** + * @brief Called when the proxy is rejected. + * @details The callback function is called when the proxy is rejected to connect to the stub. + * + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] user_data The user data passed from the registeration function + * @see #rpc_port_proxy_vc_callback_s + */ +typedef void (*rpc_port_proxy_vc_rejected_cb)(rpc_port_proxy_vc_h h, void *user_data); + +/** + * @brief The structure type containing the set of callback functions for handling proxy events. + * @details It is one of the input parameters of the rpc_port_proxy_vc_create() function. + * + * @see rpc_port_proxy_vc_connected_cb + * @see rpc_port_proxy_vc_disconnected_cb + * @see rpc_port_proxy_vc_rejected_cb + */ +typedef struct { + rpc_port_proxy_vc_connected_cb connected; /**< This callback function is called when the proxy is connected to the stub. */ + rpc_port_proxy_vc_disconnected_cb disconnected; /**< This callback function is called when the proxy is disconnected from the stub. */ + rpc_port_proxy_vc_rejected_cb rejected; /**< This callback function is called when the proxy is rejected to connect to the stub. */ +} rpc_port_proxy_vc_callback_s; + +/** + * @brief Creates a rpc_port_proxy_vc handle. + * @remarks The @a h handle should be released using + * the rpc_port_proxy_vc_destroy() if it's no longer needed. + * + * @param[in] stub_appid The application ID of the stub + * @param[in] callback The set of callback functions to handle proxy events + * @param[in] user_data The user data to be passed to the callback function + * @param[out] h The rpc_port_proxy_vc handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_proxy_vc_destroy() + * @see #rpc_port_proxy_vc_callback_s + */ +int rpc_port_proxy_vc_create(const char *stub_appid, rpc_port_proxy_vc_callback_s *callback, void *user_data, rpc_port_proxy_vc_h *h); + +/** + * @brief Destroys the rpc_port_proxy_vc handle. + * + * @param[in] h The rpc_port_proxy_vc handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_proxy_vc_create() + */ +int rpc_port_proxy_vc_destroy(rpc_port_proxy_vc_h h); + +/** + * @brief Connects to the stub. + * + * @param[in] h The rpc_port_proxy_vc handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_IO_ERROR I/O error + * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied + */ +int rpc_port_proxy_vc_connect(rpc_port_proxy_vc_h h); + +/** + * @brief Connects to the stub synchronously. + * + * @param[in] h The rpc_port_proxy_vc handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_IO_ERROR I/O error + * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied + */ +int rpc_port_proxy_vc_connect_sync(rpc_port_proxy_vc_h h); + +/** + * @brief Disconnects from the stub. + * + * @param[in] h The rpc_port_proxy_vc handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_proxy_vc_disconnect(rpc_port_proxy_vc_h h); + +/** + * @brief Calls the register_notify_cb() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +void rpc_port_proxy_vc_invoke_register_notify_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback); + +/** + * @brief Calls the register_notify_cb_sync() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_register_notify_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback); + +/** + * @brief Calls the register_feedback_cb() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +void rpc_port_proxy_vc_invoke_register_feedback_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback); + +/** + * @brief Calls the register_feedback_cb_sync() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_register_feedback_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback); + +/** + * @brief Calls the initialize() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_initialize(rpc_port_proxy_vc_h h, int pid, int *mgr_pid, int *service_state, int *daemon_pid); + +/** + * @brief Calls the finalize() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_finalize(rpc_port_proxy_vc_h h, int pid); + +/** + * @brief Calls the set_command() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_set_command(rpc_port_proxy_vc_h h, int pid, int cmd_type); + +/** + * @brief Calls the unset_command() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_unset_command(rpc_port_proxy_vc_h h, int pid, int cmd_type); + +/** + * @brief Calls the set_foreground() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_set_foreground(rpc_port_proxy_vc_h h, int pid, bool value); + +/** + * @brief Calls the set_server_dialog() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_set_server_dialog(rpc_port_proxy_vc_h h, int pid, const char *app_id, const char *credential); + +/** + * @brief Calls the request_dialog() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_request_dialog(rpc_port_proxy_vc_h h, int pid, const char *disp_text, const char *utt_text, bool continuous); + +/** + * @brief Calls the is_system_command_valid() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_is_system_command_valid(rpc_port_proxy_vc_h h, int pid, bool *is_sys_cmd_valid); + +/** + * @brief Calls the auth_enable() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_auth_enable(rpc_port_proxy_vc_h h, int pid, int mgr_pid); + +/** + * @brief Calls the auth_disable() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_auth_disable(rpc_port_proxy_vc_h h, int pid, int mgr_pid); + +/** + * @brief Calls the auth_start() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_auth_start(rpc_port_proxy_vc_h h, int pid, int mgr_pid); + +/** + * @brief Calls the auth_stop() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_auth_stop(rpc_port_proxy_vc_h h, int pid, int mgr_pid); + +/** + * @brief Calls the auth_cancel() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_auth_cancel(rpc_port_proxy_vc_h h, int pid, int mgr_pid); + +/** + * @brief Calls the request_tts() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_request_tts(rpc_port_proxy_vc_h h, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id); + +/** + * @brief Calls the cancel_tts() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_cancel_tts(rpc_port_proxy_vc_h h, int pid, int utt_id); + +/** + * @brief Calls the get_tts_audio_format() method. + * @details The return value and args are decided by the interface declaration. + * You can get the result using get_last_result(). + * Before returning the function, the function sets the result using set_last_result(). + * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. + * @param[in] h The rpc_port_proxy_vc handle + * @param[in] ... + * @exception #RPC_PORT_ERROR_NONE Successful + * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @exception #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_proxy_vc_invoke_get_tts_audio_format(rpc_port_proxy_vc_h h, int pid, int *rate, int *channel, int *audio_type); + +#ifdef __cplusplus +} +#endif diff --git a/client/vc_tidl.c b/client/vc_tidl.c new file mode 100755 index 0000000..e937f0f --- /dev/null +++ b/client/vc_tidl.c @@ -0,0 +1,708 @@ +/* +* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "vc_command.h" +#include "vc_tidl.h" +#include "vc_proxy.h" +#include "vc_main.h" + +#include + +typedef struct { + int pid; + bool connected; + bool connection_requesting; + bool register_notify_callback_invoked; + bool register_feedback_callback_invoked; + + rpc_port_proxy_vc_h rpc_h; + rpc_port_proxy_vc_notify_cb_h notify_cb_h; + rpc_port_proxy_vc_feedback_cb_h feedback_cb_h; + + char* engine_appid; +} vc_tidl_info_s; + +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); +extern int __vc_cb_manager_pid(int manager_pid); +extern int __vc_cb_tts_streaming(int utt_id, vc_feedback_event_e event, char* buffer, int len); +extern int __vc_cb_utterance_status(int utt_id, int utt_status); + + +static vc_tidl_info_s* __get_tidl_info_s(int pid) +{ + GList* iter = NULL; + vc_tidl_info_s* info = NULL; + + if (g_list_length(g_tidl_infos) > 0) { + /* Get a first item */ + iter = g_list_first(g_tidl_infos); + + while (NULL != iter) { + info = iter->data; + + if (info->pid == pid) { + return info; + } + + /* Next item */ + iter = g_list_next(iter); + } + } + + return NULL; +} + +static char* __get_engine_appid(void) +{ + char* engine_name = vconf_get_str(VC_ENGINE_DB_DEFAULT); + if (NULL == engine_name) { + SLOG(LOG_WARN, TAG_VCC, "[WARNING] Fail to get engine name. Please use default engine name."); + engine_name = strdup("org.tizen.vc-engine-default"); + } + + char* appid = strdup(engine_name); + + return appid; +} + +static void __on_connected(rpc_port_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"); + + info->connected = true; + info->connection_requesting = false; + info->register_notify_callback_invoked = false; + + SLOG(LOG_INFO, TAG_VCC, "[INFO] Connected to server"); +} + +static void __on_disconnected(rpc_port_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"); + + info->connected = false; + info->connection_requesting = false; + info->register_notify_callback_invoked = false; + + /* retry to connect */ + SLOG(LOG_INFO, TAG_VCC, "[INFO] Disconnected to server"); +} + +static void __on_rejected(rpc_port_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"); + + info->connection_requesting = false; + info->register_notify_callback_invoked = false; + + SLOG(LOG_INFO, TAG_VCC, "[INFO] Rejected from server(%d)", pid); +} + + +static rpc_port_proxy_vc_h __create_rpc_port(int pid, const char* engine_app_id) +{ + rpc_port_proxy_vc_callback_s rpc_callback = { + .connected = __on_connected, + .disconnected = __on_disconnected, + .rejected = __on_rejected + }; + + rpc_port_proxy_vc_h handle = NULL; + uintptr_t ptr_pid = pid; + if (0 != rpc_port_proxy_vc_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) { + return NULL; + } + + return handle; +} + +static void __request_tidl_connect(vc_tidl_info_s* info) +{ + if (info->connection_requesting) { + SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_connect()."); + return ; + } + + int ret = rpc_port_proxy_vc_connect(info->rpc_h); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret); + return ; + } + + SLOG(LOG_INFO, TAG_VCC, "[INFO] Request connection to stub. ret(%d)", ret); + info->connection_requesting = true; +} + +static void __notify_cb(void* user_data, int pid, bundle* msg) +{ + // corresponding to listener_event_callback + char* method = NULL; + + SLOG(LOG_DEBUG, TAG_VCC, "__notify_cb is invoked pid(%d)", pid); + + bundle_get_str(msg, VC_BUNDLE_METHOD, &method); + + if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO))) { + } /* VCD_METHOD_HELLO */ + else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) { + /* signal!!! */ + char* state = NULL; + bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &state); + if (state) { + __vc_cb_service_state(atoi(state)); + } + } /* VCD_METHOD_SET_SERVICE_STATE */ + else if (0 == strncmp(VCD_METHOD_RESULT, method, strlen(VCD_METHOD_RESULT))) { + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Client Result"); + + __vc_cb_result(); + } /* VCD_METHOD_RESULT */ + else if (0 == strncmp(VCD_METHOD_SEND_MANAGER_PID, method, strlen(VCD_METHOD_SEND_MANAGER_PID))) { + /* signal!!! */ + char* manager_pid = NULL; + bundle_get_str(msg, VC_BUNDLE_MANAGER_PID, &manager_pid); + if (manager_pid) { + SLOG(LOG_DEBUG, TAG_VCC, "@@ manager pid is changed : %d", atoi(manager_pid)); + __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; + char* daemon_pid; + 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; + char* reason; + char* err_msg = NULL; + + bundle_get_str(msg, VC_BUNDLE_PID, &pid); + bundle_get_str(msg, VC_BUNDLE_REASON, &reason); + 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); + } /* VCD_METHOD_ERROR_TO_APP */ + else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) { + } /* VC_MANAGER_METHOD_UTTERANCE_STATUS */ + else { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg"); + } +} + +void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_array_char_h pcm_data, int len) +{ + // corresponding to listener_event_callback (only for tts_streaming) + SLOG(LOG_DEBUG, TAG_VCC, "__feedback_cb is invoked utt_id(%d) event(%d)", utt_id, event); + + // char* utt_id; + // char* event; + + // bundle_get_str(msg, VC_BUNDLE_UTTID, &utt_id); + // bundle_get_str(msg, VC_BUNDLE_FEEDBACK_EVENT, &event); + // __vc_cb_tts_streaming(utt_id, event, buffer, len); + /* VCD_METHOD_FEEDBACK_STREAMING */ +} + +static int __create_notify_callback_handle(vc_tidl_info_s* info) +{ + if (NULL != info->notify_cb_h) { + rpc_port_proxy_vc_notify_cb_dispose(info->rpc_h, info->notify_cb_h); + info->notify_cb_h = NULL; + } + + if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_notify_cb_create(&info->notify_cb_h)) { + return VC_ERROR_OUT_OF_MEMORY; + } + + rpc_port_proxy_vc_notify_cb_set_callback(info->notify_cb_h, __notify_cb, NULL); + rpc_port_proxy_vc_notify_cb_set_once(info->notify_cb_h, false); + + return VC_ERROR_NONE; +} + +static int __create_feedback_callback_handle(vc_tidl_info_s* info) +{ + if (NULL != info) { + rpc_port_proxy_vc_feedback_cb_dispose(info->rpc_h, info->feedback_cb_h); + info->feedback_cb_h = NULL; + } + + if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_feedback_cb_create(&info->feedback_cb_h)) { + return VC_ERROR_OUT_OF_MEMORY; + } + + rpc_port_proxy_vc_feedback_cb_set_callback(info->feedback_cb_h, __feedback_cb, NULL); + rpc_port_proxy_vc_feedback_cb_set_once(info->feedback_cb_h, false); + + return VC_ERROR_NONE; +} + +static int __invoke_register_notify_callback(int pid, vc_tidl_info_s* info) +{ + if (info->register_notify_callback_invoked) { + SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked"); + return VC_ERROR_NONE; + } + + int ret = __create_notify_callback_handle(info); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret); + return VC_ERROR_OPERATION_FAILED; + } + + rpc_port_proxy_vc_invoke_register_notify_cb(info->rpc_h, pid, info->notify_cb_h); + info->register_notify_callback_invoked = true; + return VC_ERROR_NONE; +} + +static int __invoke_register_feedback_callback(int pid, vc_tidl_info_s* info) +{ + if (info->register_feedback_callback_invoked) { + SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked"); + return VC_ERROR_NONE; + } + + int ret = __create_feedback_callback_handle(info); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret); + return VC_ERROR_OPERATION_FAILED; + } + + rpc_port_proxy_vc_invoke_register_feedback_cb(info->rpc_h, pid, info->feedback_cb_h); + info->register_feedback_callback_invoked = true; + return VC_ERROR_NONE; +} + +int vc_tidl_open_connection() +{ + SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_open_connection"); + + vc_tidl_info_s* info = (vc_tidl_info_s*)calloc(1, sizeof(vc_tidl_info_s)); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create tidl_info_s"); + return VC_ERROR_OUT_OF_MEMORY; + } + + int pid = getpid(); + char* engine_appid = __get_engine_appid(); + + info->rpc_h = __create_rpc_port(pid, engine_appid); + if (NULL == info->rpc_h) { + SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create proxy"); + free(info); + return VC_ERROR_OPERATION_FAILED; + } + + info->pid = pid; + g_tidl_infos = g_list_append(g_tidl_infos, info); + + SLOG(LOG_ERROR, TAG_VCC, "[TIDL] pid(%d) rpc_h(%p), engine_appid(%s)", pid, info->rpc_h, info->engine_appid); + return VC_ERROR_NONE; + +} + +int vc_tidl_close_connection() +{ + SLOG(LOG_INFO, TAG_VCC, "[TIDL] 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"); + + if (0 != rpc_port_proxy_vc_destroy(info->rpc_h)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect"); + return VC_ERROR_OPERATION_FAILED; + } + + info->rpc_h = NULL; + info->notify_cb_h = NULL; + + g_tidl_infos = g_list_remove(g_tidl_infos, info); + free(info); + + return VC_ERROR_NONE; +} + +int vc_tidl_request_hello() +{ + SLOG(LOG_INFO, TAG_VCC, "[TIDL] 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"); + + if (!info->connected) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()"); + __request_tidl_connect(info); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCC, ">>>>> VCC Hello"); + if (VC_ERROR_NONE != __invoke_register_notify_callback(pid, info)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register callback"); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCC, "<<<<"); + return VC_ERROR_NONE; + +} + +static int __covert_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; +} + +int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid) +{ + 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"); + + int ret = rpc_port_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : mgr = %d service = %d daemon_pid = %d", *mgr_pid, *service_state, *daemon_pid); //LCOV_EXCL_LINE + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_finalize(info->rpc_h, pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", ret); + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d), cmd_type(%d)", pid, cmd_type); + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), cmd_type(%d)", pid, cmd_type); + + return VC_ERROR_NONE; +} + +int vc_tidl_request_set_foreground(int pid, bool value) +{ + // method no reply --> async + 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"); + + int ret = rpc_port_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground : pid(%d), value(%d)", pid, value); + + return VC_ERROR_NONE; +} + +int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* credential) +{ + 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"); + + int ret = rpc_port_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s), credential(%s)", pid, app_id, credential); + + return VC_ERROR_NONE; +} + +int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous) +{ + // method no reply --> async + 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"); + + int ret = rpc_port_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message"); + return __covert_unhandled_error(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); + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid); + + return VC_ERROR_NONE; +} + +/* Authority */ +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"); + + int ret = rpc_port_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d), mgr_pid(%d)", pid, mgr_pid); + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d), mgr_pid(%d)", pid, mgr_pid); + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d), mgr_pid(%d)", pid, mgr_pid); + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d), mgr_pid(%d)", pid, mgr_pid); + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d), mgr_pid(%d)", pid, mgr_pid); + + return VC_ERROR_NONE; +} + +/* tts feedback */ +int vc_tidl_request_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id) +{ + 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"); + + if (VC_ERROR_NONE != __invoke_register_feedback_callback(pid, info)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register feedback callback"); + return VC_ERROR_OPERATION_FAILED; + } + + int ret = rpc_port_proxy_vc_invoke_request_tts(info->rpc_h, pid, text, language, to_vcm, utt_id); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts : pid(%d)", pid); + + return VC_ERROR_NONE; +} + +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"); + + int ret = rpc_port_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message"); + return __covert_unhandled_error(ret); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts : pid(%d), utt_id(%d)", pid, utt_id); + + return VC_ERROR_NONE; +} + +int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type) +{ + 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"); + + int ret = rpc_port_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message"); + return __covert_unhandled_error(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); + + return VC_ERROR_NONE; +} diff --git a/client/vc_tidl.h b/client/vc_tidl.h new file mode 100755 index 0000000..7b84703 --- /dev/null +++ b/client/vc_tidl.h @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#ifndef __VC_TIDL_H_ +#define __VC_TIDL_H_ + +#include "voice_control_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int vc_tidl_open_connection(); + +int vc_tidl_close_connection(); + + +int vc_tidl_request_hello(); + +int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid); + +int vc_tidl_request_finalize(int pid); + +int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type); + +int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type); + +int vc_tidl_request_set_foreground(int pid, bool value); + +int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* credential); + +int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous); + +int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid); + +#if 0 +int vc_tidl_request_start(int pid, int silence); + +int vc_tidl_request_stop(int pid); + +int vc_tidl_request_cancel(int pid); + +int vc_tidl_request_set_exclusive_command(int pid, bool value); +#endif + +/* Authority */ +int vc_tidl_request_auth_enable(int pid, int mgr_pid); + +int vc_tidl_request_auth_disable(int pid, int mgr_pid); + +int vc_tidl_request_auth_start(int pid, int mgr_pid); + +int vc_tidl_request_auth_stop(int pid, int mgr_pid); + +int vc_tidl_request_auth_cancel(int pid, int mgr_pid); + +/* tts feedback */ + +int vc_tidl_request_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id); + +int vc_tidl_request_cancel_tts(int pid, int utt_id); + +int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type); + +#ifdef __cplusplus +} +#endif + +#endif /* __VC_TIDL_H_ */ diff --git a/common/vc_defs.h b/common/vc_defs.h index 81226ca..cbe89eb 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -59,6 +59,21 @@ extern "C" { #define VC_ENGINE_DB_DEFAULT "db/voice/vc/engine/default" /****************************************************************************************** +* Message Definitions for Bundle +*******************************************************************************************/ +#define VC_BUNDLE_METHOD "method" +#define VC_BUNDLE_SERVICE_STATE "service_state" +#define VC_BUNDLE_MANAGER_PID "manager_pid" +#define VC_BUNDLE_REASON "reason" +#define VC_BUNDLE_DAEMON_PID "daemon_pid" +#define VC_BUNDLE_ERR_MSG "err_msg" +#define VC_BUNDLE_PID "pid" +#define VC_BUNDLE_UTTID "uttid" +#define VC_BUNDLE_UTTSTATUS "uttstatus" +#define VC_BUNDLE_FEEDBACK_EVENT "feedback_event" +#define VC_BUNDLE_LENGTH "length" + +/****************************************************************************************** * Message Definition for all *******************************************************************************************/ @@ -267,6 +282,7 @@ extern "C" { #define VC_CONNECTION_RETRY_COUNT 10 #define VC_INVALID_TTS_UID 0 #define VC_TIDL_RETRY_COUNT 100 +#define VC_ENGINE_APPID_LEN 256 #define VC_FEATURE_PATH "tizen.org/feature/speech.control" #define VC_MGR_FEATURE_PATH "tizen.org/feature/speech.control_manager" diff --git a/common/vc_main.h b/common/vc_main.h index 15e94f9..00e079a 100644 --- a/common/vc_main.h +++ b/common/vc_main.h @@ -57,6 +57,34 @@ typedef struct vc_s *vc_h; #define FREE(x) { if (NULL != x) { free(x); x = NULL; } } #define G_FREE(x) { if (NULL != x) { g_free(x); x = NULL; } } +#define COLOR_RED "\033[0;31m" +#define COLOR_GREEN "\033[0;32m" +#define COLOR_BROWN "\033[0;33m" +#define COLOR_BLUE "\033[0;34m" +#define COLOR_PURPLE "\033[0;35m" +#define COLOR_CYAN "\033[0;36m" +#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 RETM_IF(expr, fmt, arg...) \ +do { \ + if (expr) { \ + PERR(fmt, ##arg); \ + return; \ + } \ +} while (0) + +#define RETVM_IF(expr, val, fmt, arg...) \ +do { \ + if (expr) { \ + PERR(fmt, ##arg); \ + return (val); \ + } \ +} while (0) + + #ifdef __cplusplus } #endif diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 2498f9c..bbe1861 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -34,12 +34,13 @@ BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(pkgmgr-installer) BuildRequires: pkgconfig(vconf) -BuildRequires: cmake BuildRequires: pkgconfig(gmock) -BuildRequires: tidl BuildRequires: pkgconfig(rpc-port) BuildRequires: pkgconfig(bundle) +BuildRequires: cmake +BuildRequires: tidl + %if 0%{?gcov:1} BuildRequires: lcov BuildRequires: zip @@ -114,6 +115,9 @@ GTest for Voice Control %setup -q -n %{name}-%{version} cp %{SOURCE1001} %{SOURCE1002} . +tidlc -p -l C -i tidl/vc.tidl -o vc_proxy +tidlc -s -l C -i tidl/vc.tidl -o vcd_stub + tidlc -p -l C -i tidl/vc_mgr.tidl -o vc_mgr_proxy tidlc -s -l C -i tidl/vc_mgr.tidl -o vcd_mgr_stub tidlc -s -l C -i tidl/vcd_mgr.tidl -o vc_mgr_stub diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index f9bdec8..8d5136d 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -31,6 +31,9 @@ static GSList* g_widget_list = NULL; static manager_info_s g_manager; +/* Client IPC info list */ +static GSList* g_client_ipc_info_list = NULL; + /* Manager IPC info */ static manager_tidl_info_s* g_mgr_tidl_info = NULL; @@ -1226,6 +1229,223 @@ int vcd_client_delete(int pid) return 0; } +GSList* __get_client_ipc_info_item(const int pid) +{ + GSList *iter = NULL; + client_ipc_info_s *data = NULL; + + int count = g_slist_length(g_client_ipc_info_list); + int i; + + if (0 < count) { + iter = g_slist_nth(g_client_ipc_info_list, 0); + for (i = 0; i < count; i++) { + if (NULL == iter) + break; + + data = iter->data; + if (NULL != data) { + if (pid == data->pid) + return iter; + } + + iter = g_slist_next(iter); + } + } + + return NULL; +} + +client_ipc_info_s* __get_client_ipc_info_element(int pid) +{ + GSList *iter = NULL; + client_ipc_info_s *data = NULL; + + int count = g_slist_length(g_client_ipc_info_list); + int i; + + if (0 < count) { + iter = g_slist_nth(g_client_ipc_info_list, 0); + for (i = 0; i < count; i++) { + if (NULL == iter) + break; + + data = iter->data; + + if (NULL != data) { + if (pid == data->pid) + return data; + } + + iter = g_slist_next(iter); + } + } + + return NULL; +} + +int vcd_client_add_ipc_info(int pid) +{ + /*Check pid is duplicated*/ + client_ipc_info_s* info = NULL; + info = __get_client_ipc_info_element(pid); + + if (NULL != info) { + SLOG(LOG_WARN, TAG_VCD, "[Client Data] Client ipc info pid is already registered"); + return VCD_ERROR_NONE; + } + + SLOG(LOG_INFO, TAG_VCD, "[Client Data] There is no ipc info of pid(%d). Create new one.", pid); + info = (client_ipc_info_s*)calloc(1, sizeof(client_ipc_info_s)); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + info->pid = pid; + info->notify_cb = NULL; + info->notify_cb_user_data = NULL; + info->feedback_cb = NULL; + info->feedback_cb_user_data = NULL; + + g_client_ipc_info_list = g_slist_append(g_client_ipc_info_list, info); + if (NULL == g_client_ipc_info_list) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to add new client ipc info"); + + free(info); + info = NULL; + + return -1; + } else { + SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client ipc info. pid(%d)", pid); + } + + return VCD_ERROR_NONE; +} + +int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vc_notify_cb_h callback, void* user_data) +{ + /*Check pid*/ + client_ipc_info_s* info = NULL; + info = __get_client_ipc_info_element(pid); + + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = rpc_port_stub_vc_notify_cb_clone(callback, &(info->notify_cb)); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone notify callback. ret(%d)", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone notify callback. ret(%d)", ret); + } + info->notify_cb_user_data = user_data; + + return VCD_ERROR_NONE; +} + +int vcd_client_unset_ipc_notify_cb(int pid) +{ + /*Check pid*/ + client_ipc_info_s* info = NULL; + info = __get_client_ipc_info_element(pid); + + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = rpc_port_stub_vc_notify_cb_destroy(info->notify_cb); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy notify callback. ret(%d)", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy notify callback. ret(%d)", ret); + } + info->notify_cb = NULL; + info->notify_cb_user_data = NULL; + + return VCD_ERROR_NONE; +} + +int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vc_feedback_cb_h callback, void* user_data) +{ + /*Check pid*/ + client_ipc_info_s* info = NULL; + info = __get_client_ipc_info_element(pid); + + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = rpc_port_stub_vc_feedback_cb_clone(callback, &(info->feedback_cb)); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone feedback callback. ret(%d)", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone feedback callback. ret(%d)", ret); + } + info->feedback_cb_user_data = user_data; + + return VCD_ERROR_NONE; +} + +int vcd_client_unset_ipc_feedback_cb(int pid) +{ + /*Check pid*/ + client_ipc_info_s* info = NULL; + info = __get_client_ipc_info_element(pid); + + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = rpc_port_stub_vc_feedback_cb_destroy(info->feedback_cb); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy feedback callback. ret(%d)", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy feedback callback. ret(%d)", ret); + } + info->feedback_cb = NULL; + info->feedback_cb_user_data = NULL; + + return VCD_ERROR_NONE; +} + +int vcd_client_delete_ipc_info(int pid) +{ + GSList *tmp = NULL; + client_ipc_info_s* client_ipc_info = NULL; + + /*Get handle*/ + tmp = __get_client_ipc_info_item(pid); + if (NULL == tmp) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + /*Free client structure*/ + client_ipc_info = tmp->data; + if (NULL != client_ipc_info) { + free(client_ipc_info); + } + + /*Remove handle from list*/ + g_client_ipc_info_list = g_slist_remove_link(g_client_ipc_info_list, tmp); + + return 0; +} + +client_ipc_info_s* vcd_client_get_ipc_info(int pid) +{ + return __get_client_ipc_info_element(pid); +} + bool vcd_client_is_available(int pid) { vc_client_info_s* client_info = NULL; diff --git a/server/vcd_client_data.h b/server/vcd_client_data.h index 317e1d5..0620b19 100644 --- a/server/vcd_client_data.h +++ b/server/vcd_client_data.h @@ -21,6 +21,7 @@ #include #include "vc_command.h" #include "vc_info_parser.h" +#include "vcd_stub.h" #include "vcd_mgr_stub.h" #include "vcd_mgr_proxy.h" #include "vcd_widget_stub.h" @@ -71,7 +72,14 @@ typedef struct { typedef struct { int pid; + rpc_port_stub_vc_notify_cb_h notify_cb; + void* notify_cb_user_data; + rpc_port_stub_vc_feedback_cb_h feedback_cb; + void* feedback_cb_user_data; +} client_ipc_info_s; +typedef struct { + int pid; rpc_port_stub_vc_mgr_notify_cb_h notify_cb; void* notify_cb_user_data; rpc_port_stub_vc_mgr_send_buffer_cb_h send_buffer_cb; @@ -182,6 +190,20 @@ int vcd_client_add(int pid); int vcd_client_delete(int pid); +int vcd_client_add_ipc_info(int pid); + +int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vc_notify_cb_h callback, void* user_data); + +int vcd_client_unset_ipc_notify_cb(int pid); + +int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vc_feedback_cb_h callback, void* user_data); + +int vcd_client_unset_ipc_feedback_cb(int pid); + +int vcd_client_delete_ipc_info(int pid); + +client_ipc_info_s* vcd_client_get_ipc_info(int pid); + bool vcd_client_is_available(int pid); int vcd_client_get_ref_count(); diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 54bf596..f7cfc10 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -108,73 +108,71 @@ int vcd_check_dbus_connection() return 0; } -int vcdc_send_hello(int pid, vcd_client_type_e type) -{ - if (0 != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg = NULL; - - if (VCD_CLIENT_TYPE_NORMAL == type) { - msg = __get_message(pid, VCD_METHOD_HELLO, VCD_CLIENT_TYPE_NORMAL); - } else if (VCD_CLIENT_TYPE_WIDGET == type) { - // msg = __get_message(pid, VCD_WIDGET_METHOD_HELLO, VCD_CLIENT_TYPE_WIDGET); - vcdc_tidl_send_hello(pid, type); - return VCD_ERROR_NONE; - } else if (VCD_CLIENT_TYPE_MANAGER == type) { - vcdc_tidl_send_hello(pid, type); - return VCD_ERROR_NONE; - } else { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid"); - return -1; - } - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to create message"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = -1; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] %s", err.message); - if (NULL != err.name) { - if (!strcmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Unknown service. Client is not available"); - dbus_error_free(&err); - return 0; - } - } - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus] Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VCD_ERROR_OPERATION_FAILED; - } - - dbus_message_unref(result_msg); - } else { - SLOG(LOG_WARN, TAG_VCD, "[Dbus] Result message is NULL. Client is not available"); - } - - return result; -} +// int vcdc_send_hello(int pid, vcd_client_type_e type) +// { +// if (0 != __dbus_check()) { +// return VCD_ERROR_OPERATION_FAILED; +// } + +// DBusMessage* msg = NULL; + +// if (VCD_CLIENT_TYPE_NORMAL == type) { +// msg = __get_message(pid, VCD_METHOD_HELLO, VCD_CLIENT_TYPE_NORMAL); +// } else if (VCD_CLIENT_TYPE_WIDGET == type) { +// msg = __get_message(pid, VCD_WIDGET_METHOD_HELLO, VCD_CLIENT_TYPE_WIDGET); +// } else if (VCD_CLIENT_TYPE_MANAGER == type) { +// msg = __get_message(pid, VCD_MANAGER_METHOD_HELLO, VCD_CLIENT_TYPE_MANAGER); +// } else { +// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid"); +// return -1; +// } + +// if (NULL == msg) { +// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to create message"); +// return VCD_ERROR_OUT_OF_MEMORY; +// } + +// dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); + +// DBusError err; +// dbus_error_init(&err); + +// DBusMessage* result_msg; +// int result = -1; + +// result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); +// dbus_message_unref(msg); + +// if (dbus_error_is_set(&err)) { +// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] %s", err.message); +// if (NULL != err.name) { +// if (!strcmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN)) { +// SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Unknown service. Client is not available"); +// dbus_error_free(&err); +// return 0; +// } +// } +// dbus_error_free(&err); +// } + +// if (NULL != result_msg) { +// dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); + +// if (dbus_error_is_set(&err)) { +// SLOG(LOG_ERROR, TAG_VCD, "[Dbus] Get arguments error (%s)", err.message); +// dbus_error_free(&err); +// result = VCD_ERROR_OPERATION_FAILED; +// } + +// dbus_message_unref(result_msg); +// } else { +// SLOG(LOG_WARN, TAG_VCD, "[Dbus] Result message is NULL. Client is not available"); +// } + +// return result; +// } +/* int vcdc_send_result(int pid, int manager_pid, int cmd_type) { if (0 != __dbus_check()) { @@ -204,10 +202,6 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type) case VC_COMMAND_TYPE_SYSTEM: case VC_COMMAND_TYPE_SYSTEM_BACKGROUND: case VC_COMMAND_TYPE_EXCLUSIVE: - // msg = __get_message(pid, VCD_MANAGER_METHOD_RESULT, VCD_CLIENT_TYPE_MANAGER); - // break; - vcdc_tidl_send_result(pid, manager_pid, VCD_CLIENT_TYPE_MANAGER); - return 0; default: SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Command type is NOT valid(%d)", cmd_type); @@ -233,7 +227,7 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type) return 0; } - +*/ int vcdc_send_manager_pid(int manager_pid) { DBusError err; @@ -416,7 +410,7 @@ int vcdc_send_error_signal(int reason, char *err_msg) return 0; } - +/* int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) { if (NULL == err_msg) { @@ -456,7 +450,10 @@ int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) return VCD_ERROR_NONE; } +*/ +/* +>>>>>>> Replace IPC (VCC) from dbus to tidl int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) { SLOG(LOG_INFO, TAG_VCD, "[Dbus] Send TTS feedback streaming : pid(%d), utt_id(%d), feedback event(%d), buffer(%p), length(%d)", pid, utt_id, event, buffer, len); @@ -468,7 +465,7 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, DBusError err; dbus_error_init(&err); - /* make dbus message */ + // make dbus message DBusMessage* msg = NULL; msg = __get_message(pid, VCD_METHOD_FEEDBACK_STREAMING, VCD_CLIENT_TYPE_NORMAL); if (NULL == msg) { @@ -499,7 +496,7 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, return ret; } - +*/ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler) { if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW; diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h index fcfaad3..d6ae86c 100644 --- a/server/vcd_dbus.h +++ b/server/vcd_dbus.h @@ -30,18 +30,18 @@ int vcd_dbus_close_connection(); int vcd_check_dbus_connection(); -int vcdc_send_hello(int pid, vcd_client_type_e type); +// int vcdc_send_hello(int pid, vcd_client_type_e type); -int vcdc_send_result(int pid, int manager_pid, int cmd_type); +//int vcdc_send_result(int pid, int manager_pid, int cmd_type); int vcdc_send_error_signal(int reason, char *err_msg); -int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); +//int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); int vcdc_send_manager_pid(int manager_pid); /* for TTS feedback */ -int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); +//int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); #ifdef __cplusplus } diff --git a/server/vcd_stub.c b/server/vcd_stub.c new file mode 100755 index 0000000..e84a2e3 --- /dev/null +++ b/server/vcd_stub.c @@ -0,0 +1,2422 @@ +/* + * Generated by tidlc 1.8.1. + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vcd_stub.h" + +#undef LOG_TAG +#define LOG_TAG "RPC_PORT_STUB" + +#undef _E +#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#undef _W +#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#undef _I +#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#undef _D +#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#ifndef TIDL_VERSION +#define TIDL_VERSION "1.8.1" +#endif + +#ifndef nullptr +#define nullptr NULL +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + +#ifndef STRING_GET +#define STRING_GET(x) ((x) ? x : "") +#endif + +typedef int (*rpc_port_stub_method_handler)(rpc_port_h port, rpc_port_parcel_h parcel, void *data); + +typedef enum { + RPC_PORT_STUB_VC_METHOD_RESULT_, + RPC_PORT_STUB_VC_METHOD_CALLBACK_, + RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB, + RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB_SYNC, + RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB, + RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC, + RPC_PORT_STUB_VC_METHOD_INITIALIZE, + RPC_PORT_STUB_VC_METHOD_FINALIZE, + RPC_PORT_STUB_VC_METHOD_SET_COMMAND, + RPC_PORT_STUB_VC_METHOD_UNSET_COMMAND, + RPC_PORT_STUB_VC_METHOD_SET_FOREGROUND, + RPC_PORT_STUB_VC_METHOD_SET_SERVER_DIALOG, + RPC_PORT_STUB_VC_METHOD_REQUEST_DIALOG, + RPC_PORT_STUB_VC_METHOD_IS_SYSTEM_COMMAND_VALID, + RPC_PORT_STUB_VC_METHOD_AUTH_ENABLE, + RPC_PORT_STUB_VC_METHOD_AUTH_DISABLE, + RPC_PORT_STUB_VC_METHOD_AUTH_START, + RPC_PORT_STUB_VC_METHOD_AUTH_STOP, + RPC_PORT_STUB_VC_METHOD_AUTH_CANCEL, + RPC_PORT_STUB_VC_METHOD_REQUEST_TTS, + RPC_PORT_STUB_VC_METHOD_CANCEL_TTS, + RPC_PORT_STUB_VC_METHOD_GET_TTS_AUDIO_FORMAT, +} rpc_port_stub_vc_method_e; + +typedef enum { + RPC_PORT_STUB_VC_DELEGATE_NOTIFY_CB = 1, + RPC_PORT_STUB_VC_DELEGATE_FEEDBACK_CB = 2, +} rpc_port_stub_vc_delegate_e; + +typedef struct rpc_port_stub_array_char_s { + rpc_port_parcelable_t parcelable; + char *value; + int size; +} rpc_port_stub_array_char_t; + +typedef struct rpc_port_stub_vc_notify_cb_s { + rpc_port_parcelable_t parcelable; + rpc_port_h port; + int id; + int seq_id; + bool once; + bool valid; +} rpc_port_stub_vc_notify_cb_t; + +typedef struct rpc_port_stub_vc_feedback_cb_s { + rpc_port_parcelable_t parcelable; + rpc_port_h port; + int id; + int seq_id; + bool once; + bool valid; +} rpc_port_stub_vc_feedback_cb_t; + +static bool __rpc_port_stub_vc_exist_callback_port(rpc_port_h callback_port); + +typedef struct rpc_port_stub_vc_context_s { + char *sender; + char *instance; + rpc_port_h port; + rpc_port_h callback_port; + void *tag; + rpc_port_stub_vc_callback_s callback; + void *user_data; +#ifdef TIDL_THREAD_ENABLE + GThread *thread; + GQueue *queue; + GMutex mutex; + GCond cond; + bool done; +#endif /* TIDL_THREAD_ENABLE */ +} rpc_port_stub_vc_context_t; + +typedef struct rpc_port_stub_vc_s { + rpc_port_stub_h stub; + rpc_port_stub_vc_callback_s callback; + void *user_data; + GList* contexts; + GList* callback_ports; + GRecMutex mutex; +} rpc_port_stub_vc_t; + +static rpc_port_stub_vc_t __vc; + +static void __rpc_port_stub_array_char_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_array_char_h h = data; + int i; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, h->size); + + for (i = 0; i < h->size; ++i) + rpc_port_parcel_write_byte(parcel, h->value[i]); +} + +static void __rpc_port_stub_array_char_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_array_char_h h = data; + char value; + int ret; + int i; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + ret = rpc_port_parcel_read_array_count(parcel, &h->size); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to read array count. error(%d)", ret); + set_last_result(ret); + return; + } + + h->value = calloc(h->size, sizeof(char)); + if (h->value == nullptr) { + _E("Out of memory"); + set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); + return; + } + + for (i = 0; i < h->size; ++i) { + rpc_port_parcel_read_byte(parcel, &value); + h->value[i] = value; + } + + set_last_result(RPC_PORT_ERROR_NONE); +} + +int rpc_port_stub_array_char_create(rpc_port_stub_array_char_h *h) +{ + rpc_port_stub_array_char_t *handle; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + handle = calloc(1, sizeof(rpc_port_stub_array_char_t)); + if (handle == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + handle->parcelable.to = __rpc_port_stub_array_char_to; + handle->parcelable.from = __rpc_port_stub_array_char_from; + + *h = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_array_char_destroy(rpc_port_stub_array_char_h h) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (h->value) + free(h->value); + + free(h); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_array_char_clone(rpc_port_stub_array_char_h h, rpc_port_stub_array_char_h *clone) +{ + rpc_port_stub_array_char_h handle; + rpc_port_parcel_h parcel; + int ret; + + if (h == nullptr || clone == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_stub_array_char_create(&handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret); + return ret; + } + + ret = rpc_port_parcel_create(&parcel); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret); + rpc_port_stub_array_char_destroy(handle); + return ret; + } + + rpc_port_parcel_write(parcel, &h->parcelable, h); + rpc_port_parcel_read(parcel, &handle->parcelable, handle); + ret = get_last_result(); + rpc_port_parcel_destroy(parcel); + + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to read data. error(%d)", ret); + rpc_port_stub_array_char_destroy(handle); + return ret; + } + + *clone = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_array_char_set(rpc_port_stub_array_char_h h, char *value, int size) +{ + rpc_port_stub_array_char_h handle; + rpc_port_stub_array_char_h clone; + int ret; + + if (h == nullptr || value == nullptr || size <= 0) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_stub_array_char_create(&handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret); + return ret; + } + + handle->value = (char *)value; + handle->size = size; + + ret = rpc_port_stub_array_char_clone(handle, &clone); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to clone handle. error(%d)", ret); + handle->value = nullptr; + handle->size = 0; + rpc_port_stub_array_char_destroy(handle); + return ret; + } + + handle->value = h->value; + handle->size = h->size; + rpc_port_stub_array_char_destroy(handle); + + h->value = clone->value; + h->size = clone->size; + + clone->value = nullptr; + clone->size = 0; + rpc_port_stub_array_char_destroy(clone); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_array_char_get(rpc_port_stub_array_char_h h, char **value, int *size) +{ + rpc_port_stub_array_char_h handle; + int ret; + + if (h == nullptr || value == nullptr || size == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_stub_array_char_clone(h, &handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to clone handle. error(%d)", ret); + return ret; + } + + *value = handle->value; + *size = handle->size; + + handle->value = nullptr; + handle->size = 0; + rpc_port_stub_array_char_destroy(handle); + + return RPC_PORT_ERROR_NONE; +} + +static void __rpc_port_stub_vc_notify_cb_to(rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_notify_cb_h h = user_data; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, h->id); + + rpc_port_parcel_write_int32(parcel, h->seq_id); + + rpc_port_parcel_write_bool(parcel, h->once); + + _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); +} + +static void __rpc_port_stub_vc_notify_cb_from(rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_notify_cb_h h = user_data; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + rpc_port_parcel_read_int32(parcel, &h->id); + + rpc_port_parcel_read_int32(parcel, &h->seq_id); + + rpc_port_parcel_read_bool(parcel, &h->once); + + _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); + set_last_result(RPC_PORT_ERROR_NONE); +} + +int rpc_port_stub_vc_notify_cb_create(rpc_port_stub_vc_notify_cb_h *h) +{ + rpc_port_stub_vc_notify_cb_t *handle; + static int seq_num; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + handle = calloc(1, sizeof(rpc_port_stub_vc_notify_cb_t)); + if (handle == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + handle->parcelable.to = __rpc_port_stub_vc_notify_cb_to; + handle->parcelable.from = __rpc_port_stub_vc_notify_cb_from; + handle->id = RPC_PORT_STUB_VC_DELEGATE_NOTIFY_CB; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->once = false; + handle->valid = true; + _I("id(%d), seq_id(%d)", handle->id, handle->seq_id); + + *h = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_notify_cb_destroy(rpc_port_stub_vc_notify_cb_h h) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); + + free(h); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_notify_cb_clone(rpc_port_stub_vc_notify_cb_h h, rpc_port_stub_vc_notify_cb_h *clone) +{ + rpc_port_stub_vc_notify_cb_h handle; + int ret; + + if (h == nullptr || clone == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_stub_vc_notify_cb_create(&handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret); + return ret; + } + + handle->port = h->port; + handle->seq_id = h->seq_id; + handle->once = h->once; + handle->valid = h->valid; + + *clone = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_notify_cb_get_id(rpc_port_stub_vc_notify_cb_h h, int *id) +{ + if (h == nullptr || id == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *id = h->id; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_notify_cb_get_seq_id(rpc_port_stub_vc_notify_cb_h h, int *seq_id) +{ + if (h == nullptr || seq_id == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *seq_id = h->seq_id; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_notify_cb_is_once(rpc_port_stub_vc_notify_cb_h h, bool *once) +{ + if (h == nullptr || once == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *once = h->once; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_notify_cb_get_tag(rpc_port_stub_vc_notify_cb_h h, char **tag) +{ + char *value; + char buf[128]; + + if (h == nullptr || tag == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id); + value = strdup(buf); + if (value == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + *tag = value; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_notify_cb_set_port(rpc_port_stub_vc_notify_cb_h h, rpc_port_h port) +{ + if (h == nullptr || port == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + h->port = port; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_notify_cb_invoke(rpc_port_stub_vc_notify_cb_h h, int pid, bundle *msg) +{ + rpc_port_parcel_h parcel_; + int ret_; + + if (h == nullptr || h->port == nullptr || msg == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (!__rpc_port_stub_vc_exist_callback_port(h->port)) { + _E("Not connected"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (h->once && !h->valid) { + _E("The delegate handle is already used"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + return ret_; + } + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_CALLBACK_); + + rpc_port_parcel_write(parcel_, &h->parcelable, h); + + rpc_port_parcel_write_int32(parcel_, pid); + + rpc_port_parcel_write_bundle(parcel_, msg); + + ret_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + h->valid = false; + + return ret_; +} + +static void __rpc_port_stub_vc_feedback_cb_to(rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_feedback_cb_h h = user_data; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, h->id); + + rpc_port_parcel_write_int32(parcel, h->seq_id); + + rpc_port_parcel_write_bool(parcel, h->once); + + _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); +} + +static void __rpc_port_stub_vc_feedback_cb_from(rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_feedback_cb_h h = user_data; + + if (parcel == nullptr || h == nullptr) { + _E("Invalid parameter"); + set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); + return; + } + + rpc_port_parcel_read_int32(parcel, &h->id); + + rpc_port_parcel_read_int32(parcel, &h->seq_id); + + rpc_port_parcel_read_bool(parcel, &h->once); + + _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); + set_last_result(RPC_PORT_ERROR_NONE); +} + +int rpc_port_stub_vc_feedback_cb_create(rpc_port_stub_vc_feedback_cb_h *h) +{ + rpc_port_stub_vc_feedback_cb_t *handle; + static int seq_num; + + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + handle = calloc(1, sizeof(rpc_port_stub_vc_feedback_cb_t)); + if (handle == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + handle->parcelable.to = __rpc_port_stub_vc_feedback_cb_to; + handle->parcelable.from = __rpc_port_stub_vc_feedback_cb_from; + handle->id = RPC_PORT_STUB_VC_DELEGATE_FEEDBACK_CB; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->once = false; + handle->valid = true; + _I("id(%d), seq_id(%d)", handle->id, handle->seq_id); + + *h = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_feedback_cb_destroy(rpc_port_stub_vc_feedback_cb_h h) +{ + if (h == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); + + free(h); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_feedback_cb_clone(rpc_port_stub_vc_feedback_cb_h h, rpc_port_stub_vc_feedback_cb_h *clone) +{ + rpc_port_stub_vc_feedback_cb_h handle; + int ret; + + if (h == nullptr || clone == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret = rpc_port_stub_vc_feedback_cb_create(&handle); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret); + return ret; + } + + handle->port = h->port; + handle->seq_id = h->seq_id; + handle->once = h->once; + handle->valid = h->valid; + + *clone = handle; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_feedback_cb_get_id(rpc_port_stub_vc_feedback_cb_h h, int *id) +{ + if (h == nullptr || id == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *id = h->id; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_feedback_cb_get_seq_id(rpc_port_stub_vc_feedback_cb_h h, int *seq_id) +{ + if (h == nullptr || seq_id == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *seq_id = h->seq_id; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_feedback_cb_is_once(rpc_port_stub_vc_feedback_cb_h h, bool *once) +{ + if (h == nullptr || once == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *once = h->once; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_feedback_cb_get_tag(rpc_port_stub_vc_feedback_cb_h h, char **tag) +{ + char *value; + char buf[128]; + + if (h == nullptr || tag == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id); + value = strdup(buf); + if (value == nullptr) { + _E("Out of memory"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + *tag = value; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_feedback_cb_set_port(rpc_port_stub_vc_feedback_cb_h h, rpc_port_h port) +{ + if (h == nullptr || port == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + h->port = port; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_feedback_cb_invoke(rpc_port_stub_vc_feedback_cb_h h, int utt_id, int event, rpc_port_stub_array_char_h pcm_data, int len) +{ + rpc_port_parcel_h parcel_; + int ret_; + + if (h == nullptr || h->port == nullptr || pcm_data == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (!__rpc_port_stub_vc_exist_callback_port(h->port)) { + _E("Not connected"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (h->once && !h->valid) { + _E("The delegate handle is already used"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + return ret_; + } + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_CALLBACK_); + + rpc_port_parcel_write(parcel_, &h->parcelable, h); + + rpc_port_parcel_write_int32(parcel_, utt_id); + + rpc_port_parcel_write_int32(parcel_, event); + + rpc_port_parcel_write(parcel_, &pcm_data->parcelable, pcm_data); + + rpc_port_parcel_write_int32(parcel_, len); + + ret_ = rpc_port_parcel_send(parcel_, h->port); + rpc_port_parcel_destroy(parcel_); + h->valid = false; + + return ret_; +} + +static int __rpc_port_stub_vc_method_register_notify_cb_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + rpc_port_stub_vc_notify_cb_h callback = nullptr; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + ret_ = rpc_port_stub_vc_notify_cb_create(&callback); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret_); + goto out; + } + + rpc_port_stub_vc_notify_cb_set_port(callback, callback_port_); + rpc_port_parcel_read(parcel, &callback->parcelable, callback); + ret_ = get_last_result(); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to read data. error(%d)", ret_); + goto out; + } + + if (context_->callback.register_notify_cb) + context_->callback.register_notify_cb(context_, pid, callback, context_->user_data); + +out: + if (callback) + rpc_port_stub_vc_notify_cb_destroy(callback); + + return ret_; +} + +static int __rpc_port_stub_vc_method_register_notify_cb_sync_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + rpc_port_stub_vc_notify_cb_h callback = nullptr; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + ret_ = rpc_port_stub_vc_notify_cb_create(&callback); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret_); + goto out; + } + + rpc_port_stub_vc_notify_cb_set_port(callback, callback_port_); + rpc_port_parcel_read(parcel, &callback->parcelable, callback); + ret_ = get_last_result(); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to read data. error(%d)", ret_); + goto out; + } + + if (context_->callback.register_notify_cb_sync) + res_ = context_->callback.register_notify_cb_sync(context_, pid, callback, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + if (callback) + rpc_port_stub_vc_notify_cb_destroy(callback); + + return ret_; +} + +static int __rpc_port_stub_vc_method_register_feedback_cb_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + rpc_port_stub_vc_feedback_cb_h callback = nullptr; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + ret_ = rpc_port_stub_vc_feedback_cb_create(&callback); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret_); + goto out; + } + + rpc_port_stub_vc_feedback_cb_set_port(callback, callback_port_); + rpc_port_parcel_read(parcel, &callback->parcelable, callback); + ret_ = get_last_result(); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to read data. error(%d)", ret_); + goto out; + } + + if (context_->callback.register_feedback_cb) + context_->callback.register_feedback_cb(context_, pid, callback, context_->user_data); + +out: + if (callback) + rpc_port_stub_vc_feedback_cb_destroy(callback); + + return ret_; +} + +static int __rpc_port_stub_vc_method_register_feedback_cb_sync_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + rpc_port_stub_vc_feedback_cb_h callback = nullptr; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + ret_ = rpc_port_stub_vc_feedback_cb_create(&callback); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create handle. error(%d)", ret_); + goto out; + } + + rpc_port_stub_vc_feedback_cb_set_port(callback, callback_port_); + rpc_port_parcel_read(parcel, &callback->parcelable, callback); + ret_ = get_last_result(); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to read data. error(%d)", ret_); + goto out; + } + + if (context_->callback.register_feedback_cb_sync) + res_ = context_->callback.register_feedback_cb_sync(context_, pid, callback, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + if (callback) + rpc_port_stub_vc_feedback_cb_destroy(callback); + + return ret_; +} + +static int __rpc_port_stub_vc_method_initialize_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int mgr_pid = -1; + int service_state = -1; + int daemon_pid = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + if (context_->callback.initialize) + res_ = context_->callback.initialize(context_, pid, &mgr_pid, &service_state, &daemon_pid, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, mgr_pid); + + rpc_port_parcel_write_int32(parcel_, service_state); + + rpc_port_parcel_write_int32(parcel_, daemon_pid); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_finalize_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + if (context_->callback.finalize) + res_ = context_->callback.finalize(context_, pid, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_set_command_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int cmd_type = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_int32(parcel, &cmd_type); + + if (context_->callback.set_command) + res_ = context_->callback.set_command(context_, pid, cmd_type, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_unset_command_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int cmd_type = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_int32(parcel, &cmd_type); + + if (context_->callback.unset_command) + res_ = context_->callback.unset_command(context_, pid, cmd_type, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_set_foreground_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + bool value = false; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_bool(parcel, &value); + + if (context_->callback.set_foreground) + res_ = context_->callback.set_foreground(context_, pid, value, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_set_server_dialog_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + char *app_id = nullptr; + char *credential = nullptr; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_string(parcel, &app_id); + if (app_id == nullptr) { + _E("Failed to read data"); + ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; + goto out; + } + + rpc_port_parcel_read_string(parcel, &credential); + if (credential == nullptr) { + _E("Failed to read data"); + ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; + goto out; + } + + if (context_->callback.set_server_dialog) + res_ = context_->callback.set_server_dialog(context_, pid, app_id, credential, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + if (app_id) + free(app_id); + + if (credential) + free(credential); + + return ret_; +} + +static int __rpc_port_stub_vc_method_request_dialog_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + char *disp_text = nullptr; + char *utt_text = nullptr; + bool continuous = false; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_string(parcel, &disp_text); + if (disp_text == nullptr) { + _E("Failed to read data"); + ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; + goto out; + } + + rpc_port_parcel_read_string(parcel, &utt_text); + if (utt_text == nullptr) { + _E("Failed to read data"); + ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; + goto out; + } + + rpc_port_parcel_read_bool(parcel, &continuous); + + if (context_->callback.request_dialog) + res_ = context_->callback.request_dialog(context_, pid, disp_text, utt_text, continuous, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + if (disp_text) + free(disp_text); + + if (utt_text) + free(utt_text); + + return ret_; +} + +static int __rpc_port_stub_vc_method_is_system_command_valid_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + bool is_sys_cmd_valid = false; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + if (context_->callback.is_system_command_valid) + res_ = context_->callback.is_system_command_valid(context_, pid, &is_sys_cmd_valid, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_bool(parcel_, is_sys_cmd_valid); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_auth_enable_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int mgr_pid = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_int32(parcel, &mgr_pid); + + if (context_->callback.auth_enable) + res_ = context_->callback.auth_enable(context_, pid, mgr_pid, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_auth_disable_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int mgr_pid = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_int32(parcel, &mgr_pid); + + if (context_->callback.auth_disable) + res_ = context_->callback.auth_disable(context_, pid, mgr_pid, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_auth_start_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int mgr_pid = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_int32(parcel, &mgr_pid); + + if (context_->callback.auth_start) + res_ = context_->callback.auth_start(context_, pid, mgr_pid, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_auth_stop_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int mgr_pid = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_int32(parcel, &mgr_pid); + + if (context_->callback.auth_stop) + res_ = context_->callback.auth_stop(context_, pid, mgr_pid, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_auth_cancel_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int mgr_pid = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_int32(parcel, &mgr_pid); + + if (context_->callback.auth_cancel) + res_ = context_->callback.auth_cancel(context_, pid, mgr_pid, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_request_tts_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + char *text = nullptr; + char *lang = nullptr; + bool to_vcm = false; + int utt_id = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_string(parcel, &text); + if (text == nullptr) { + _E("Failed to read data"); + ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; + goto out; + } + + rpc_port_parcel_read_string(parcel, &lang); + if (lang == nullptr) { + _E("Failed to read data"); + ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; + goto out; + } + + rpc_port_parcel_read_bool(parcel, &to_vcm); + + if (context_->callback.request_tts) + res_ = context_->callback.request_tts(context_, pid, text, lang, to_vcm, &utt_id, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, utt_id); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + if (text) + free(text); + + if (lang) + free(lang); + + return ret_; +} + +static int __rpc_port_stub_vc_method_cancel_tts_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int utt_id = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + rpc_port_parcel_read_int32(parcel, &utt_id); + + if (context_->callback.cancel_tts) + res_ = context_->callback.cancel_tts(context_, pid, utt_id, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static int __rpc_port_stub_vc_method_get_tts_audio_format_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) +{ + rpc_port_stub_vc_context_h context_ = user_data; + rpc_port_parcel_header_h header_; + int seq_num_ = -1; + rpc_port_h callback_port_; + int ret_; + int pid = -1; + int rate = -1; + int channel = -1; + int audio_type = -1; + rpc_port_parcel_h parcel_; + int res_ = -1; + + ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel, &header_); + rpc_port_parcel_header_get_seq_num(header_, &seq_num_); + _W("[Sequence] %d", seq_num_); + + rpc_port_parcel_read_int32(parcel, &pid); + + if (context_->callback.get_tts_audio_format) + res_ = context_->callback.get_tts_audio_format(context_, pid, &rate, &channel, &audio_type, context_->user_data); + + ret_ = rpc_port_parcel_create(&parcel_); + if (ret_ != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle. error(%d)", ret_); + goto out; + } + + rpc_port_parcel_get_header(parcel_, &header_); + rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); + rpc_port_parcel_header_set_seq_num(header_, seq_num_); + + rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); + + rpc_port_parcel_write_int32(parcel_, rate); + + rpc_port_parcel_write_int32(parcel_, channel); + + rpc_port_parcel_write_int32(parcel_, audio_type); + + rpc_port_parcel_write_int32(parcel_, res_); + + ret_ = rpc_port_parcel_send(parcel_, port); + rpc_port_parcel_destroy(parcel_); + +out: + + return ret_; +} + +static rpc_port_stub_method_handler __vc_method_table[] = { + [RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB] = __rpc_port_stub_vc_method_register_notify_cb_handler, + [RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB_SYNC] = __rpc_port_stub_vc_method_register_notify_cb_sync_handler, + [RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB] = __rpc_port_stub_vc_method_register_feedback_cb_handler, + [RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC] = __rpc_port_stub_vc_method_register_feedback_cb_sync_handler, + [RPC_PORT_STUB_VC_METHOD_INITIALIZE] = __rpc_port_stub_vc_method_initialize_handler, + [RPC_PORT_STUB_VC_METHOD_FINALIZE] = __rpc_port_stub_vc_method_finalize_handler, + [RPC_PORT_STUB_VC_METHOD_SET_COMMAND] = __rpc_port_stub_vc_method_set_command_handler, + [RPC_PORT_STUB_VC_METHOD_UNSET_COMMAND] = __rpc_port_stub_vc_method_unset_command_handler, + [RPC_PORT_STUB_VC_METHOD_SET_FOREGROUND] = __rpc_port_stub_vc_method_set_foreground_handler, + [RPC_PORT_STUB_VC_METHOD_SET_SERVER_DIALOG] = __rpc_port_stub_vc_method_set_server_dialog_handler, + [RPC_PORT_STUB_VC_METHOD_REQUEST_DIALOG] = __rpc_port_stub_vc_method_request_dialog_handler, + [RPC_PORT_STUB_VC_METHOD_IS_SYSTEM_COMMAND_VALID] = __rpc_port_stub_vc_method_is_system_command_valid_handler, + [RPC_PORT_STUB_VC_METHOD_AUTH_ENABLE] = __rpc_port_stub_vc_method_auth_enable_handler, + [RPC_PORT_STUB_VC_METHOD_AUTH_DISABLE] = __rpc_port_stub_vc_method_auth_disable_handler, + [RPC_PORT_STUB_VC_METHOD_AUTH_START] = __rpc_port_stub_vc_method_auth_start_handler, + [RPC_PORT_STUB_VC_METHOD_AUTH_STOP] = __rpc_port_stub_vc_method_auth_stop_handler, + [RPC_PORT_STUB_VC_METHOD_AUTH_CANCEL] = __rpc_port_stub_vc_method_auth_cancel_handler, + [RPC_PORT_STUB_VC_METHOD_REQUEST_TTS] = __rpc_port_stub_vc_method_request_tts_handler, + [RPC_PORT_STUB_VC_METHOD_CANCEL_TTS] = __rpc_port_stub_vc_method_cancel_tts_handler, + [RPC_PORT_STUB_VC_METHOD_GET_TTS_AUDIO_FORMAT] = __rpc_port_stub_vc_method_get_tts_audio_format_handler, +}; + +static int __rpc_port_stub_vc_context_handle_request(rpc_port_stub_vc_context_h h, rpc_port_parcel_h parcel) +{ + int ret = RPC_PORT_ERROR_NONE; + int cmd = -1; + + rpc_port_parcel_read_int32(parcel, &cmd); + if (cmd > 1 && cmd < ARRAY_SIZE(__vc_method_table)) { + if (__vc_method_table[cmd]) + ret = __vc_method_table[cmd](h->port, parcel, h); + } else { + _W("Invalid protocol. cmd(%d)", cmd); + ret = RPC_PORT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +#ifdef TIDL_THREAD_ENABLE +static int __rpc_port_stub_vc_context_push(rpc_port_stub_vc_context_h h, rpc_port_parcel_h parcel) +{ + g_mutex_lock(&h->mutex); + g_queue_push_tail(h->queue, parcel); + g_cond_signal(&h->cond); + g_mutex_unlock(&h->mutex); + + return 0; +} + +static rpc_port_parcel_h __rpc_port_stub_vc_context_wait_and_pop(rpc_port_stub_vc_context_h h) +{ + rpc_port_parcel_h parcel; + + g_mutex_lock(&h->mutex); + while (g_queue_is_empty(h->queue) && !h->done) + g_cond_wait(&h->cond, &h->mutex); + + parcel = g_queue_pop_head(h->queue); + g_mutex_unlock(&h->mutex); + + return parcel; +} + +static gpointer __rpc_port_stub_vc_context_thread_cb(gpointer user_data) +{ + rpc_port_stub_vc_context_h h = user_data; + rpc_port_parcel_h parcel; + + _W("START"); + while (!h->done) { + parcel = __rpc_port_stub_vc_context_wait_and_pop(h); + if (parcel) { + __rpc_port_stub_vc_context_handle_request(h, parcel); + rpc_port_parcel_destroy(parcel); + } + } + _W("END"); + + return nullptr; +} +#endif /* TIDL_THREAD_ENABLE */ + +static void __rpc_port_stub_vc_context_destroy(gpointer data) +{ + rpc_port_stub_vc_context_h h = data; +#ifdef TIDL_THREAD_ENABLE + rpc_port_parcel_h parcel; +#endif /* TIDL_THREAD_ENABLE */ + + if (h == nullptr) + return; + +#ifdef TIDL_THREAD_ENABLE + g_mutex_lock(&h->mutex); + h->done = true; + g_cond_signal(&h->cond); + g_mutex_unlock(&h->mutex); + + if (h->thread) { + g_thread_join(h->thread); + g_thread_unref(h->thread); + } + + g_mutex_clear(&h->mutex); + g_cond_clear(&h->cond); + + if (h->queue) { + while (!g_queue_is_empty(h->queue)) { + parcel = g_queue_pop_head(h->queue); + rpc_port_parcel_destroy(parcel); + } + + g_queue_free(h->queue); + } +#endif /* TIDL_THREAD_ENABLE */ + + if (h->instance) + free(h->instance); + + if (h->sender) + free(h->sender); + + free(h); +} + +static rpc_port_stub_vc_context_h __rpc_port_stub_vc_context_create(const char *sender, const char *instance, rpc_port_h callback_port) +{ + rpc_port_stub_vc_context_t *handle; + + if (sender == nullptr || instance == nullptr || callback_port == nullptr) { + _E("Invalid parameter"); + return nullptr; + } + + handle = calloc(1, sizeof(rpc_port_stub_vc_context_t)); + if (handle == nullptr) { + _E("Out of memory"); + return nullptr; + } + + handle->sender = strdup(sender); + if (handle->sender == nullptr) { + _E("Failed to duplicate sender"); + __rpc_port_stub_vc_context_destroy(handle); + return nullptr; + } + + handle->instance = strdup(instance); + if (handle->instance == nullptr) { + _E("Failed to duplicate instance"); + __rpc_port_stub_vc_context_destroy(handle); + return nullptr; + } + +#ifdef TIDL_THREAD_ENABLE + g_mutex_init(&handle->mutex); + g_cond_init(&handle->cond); + + handle->queue = g_queue_new(); + if (handle->queue == nullptr) { + _E("Failed to create queue"); + __rpc_port_stub_vc_context_destroy(handle); + return nullptr; + } + + handle->thread = g_thread_new(instance, __rpc_port_stub_vc_context_thread_cb, handle); + if (handle->thread == nullptr) { + _E("Failed to create thread"); + __rpc_port_stub_vc_context_destroy(handle); + return nullptr; + } +#endif /* TIDL_THREAD_ENABLE */ + + handle->callback_port = callback_port; + handle->callback = __vc.callback; + handle->user_data = __vc.user_data; + + return handle; +} + +int rpc_port_stub_vc_context_set_tag(rpc_port_stub_vc_context_h context, void *tag) +{ + if (context == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + context->tag = tag; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_context_get_tag(rpc_port_stub_vc_context_h context, void **tag) +{ + if (context == nullptr || tag == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + *tag = context->tag; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_context_get_sender(rpc_port_stub_vc_context_h context, char **sender) +{ + char *value; + + if (context == nullptr || sender == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + value = strdup(context->sender); + if (value == nullptr) { + _E("Failed to duplicate sender"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + *sender = value; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_context_get_instance(rpc_port_stub_vc_context_h context, char **instance) +{ + char *value; + + if (context == nullptr || instance == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + value = strdup(context->instance); + if (value == nullptr) { + _E("Failed to duplicate instance"); + return RPC_PORT_ERROR_OUT_OF_MEMORY; + } + + *instance = value; + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_context_disconnect(rpc_port_stub_vc_context_h context) +{ + int ret; + + if (context == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + g_rec_mutex_lock(&__vc.mutex); + + ret = rpc_port_disconnect(context->callback_port); + if (ret != RPC_PORT_ERROR_NONE) + _E("Failed to disconnect. error(%d)", ret); + + g_rec_mutex_unlock(&__vc.mutex); + + return ret; +} + +static rpc_port_stub_vc_context_h __rpc_port_stub_vc_find_context(const char *instance) +{ + rpc_port_stub_vc_context_h context; + GList *iter; + + g_rec_mutex_lock(&__vc.mutex); + iter = __vc.contexts; + while (iter) { + context = iter->data; + if (!strcmp(context->instance, instance)) { + g_rec_mutex_unlock(&__vc.mutex); + return context; + } + + iter = g_list_next(iter); + } + g_rec_mutex_unlock(&__vc.mutex); + + return nullptr; +} + +static void __rpc_port_stub_vc_add_context(rpc_port_stub_vc_context_h context) +{ + g_rec_mutex_lock(&__vc.mutex); + __vc.contexts = g_list_append(__vc.contexts, context); + g_rec_mutex_unlock(&__vc.mutex); +} + +static void __rpc_port_stub_vc_remove_context(rpc_port_stub_vc_context_h context) +{ + g_rec_mutex_lock(&__vc.mutex); + __vc.contexts = g_list_remove(__vc.contexts, context); + g_rec_mutex_unlock(&__vc.mutex); +} + +static bool __rpc_port_stub_vc_exist_callback_port(rpc_port_h callback_port) +{ + rpc_port_h port; + GList *iter; + + g_rec_mutex_lock(&__vc.mutex); + iter = __vc.callback_ports; + while (iter) { + port = iter->data; + if (port == callback_port) { + g_rec_mutex_unlock(&__vc.mutex); + return true; + } + + iter = g_list_next(iter); + } + g_rec_mutex_unlock(&__vc.mutex); + + return false; +} + +static void __rpc_port_stub_vc_add_callback_port(rpc_port_h callback_port) +{ + g_rec_mutex_lock(&__vc.mutex); + __vc.callback_ports = g_list_append(__vc.callback_ports, callback_port); + g_rec_mutex_unlock(&__vc.mutex); +} + +static void __rpc_port_stub_vc_remove_callback_port(rpc_port_h callback_port) +{ + g_rec_mutex_lock(&__vc.mutex); + __vc.callback_ports = g_list_remove(__vc.callback_ports, callback_port); + g_rec_mutex_unlock(&__vc.mutex); +} + +static void __rpc_port_stub_vc_connected_event_cb(const char *sender, const char *instance, void *user_data) +{ + rpc_port_stub_vc_context_h context; + rpc_port_h callback_port = nullptr; + int ret; + + _W("sender(%s), instance(%s)", sender, instance); + ret = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, instance, &callback_port); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to get callback port. error(%d)", ret); + return; + } + + context = __rpc_port_stub_vc_context_create(sender, instance, callback_port); + if (context == nullptr) + return; + + __rpc_port_stub_vc_add_context(context); + __rpc_port_stub_vc_add_callback_port(context->callback_port); + context->callback.create(context, context->user_data); +} + +static void __rpc_port_stub_vc_disconnected_event_cb(const char *sender, const char *instance, void *user_data) +{ + rpc_port_stub_vc_context_h context; + + _W("sender(%s), instance(%s)", sender, instance); + context = __rpc_port_stub_vc_find_context(instance); + if (context == nullptr) + return; + + __rpc_port_stub_vc_remove_callback_port(context->callback_port); + context->callback.terminate(context, context->user_data); + __rpc_port_stub_vc_remove_context(context); + __rpc_port_stub_vc_context_destroy(context); +} + +static int __rpc_port_stub_vc_received_event_cb(const char *sender, const char *instance, rpc_port_h port, void *user_data) +{ + rpc_port_stub_vc_context_h context; + rpc_port_parcel_h parcel; + int ret; + + _W("sender(%s), instance(%s)", sender, instance); + context = __rpc_port_stub_vc_find_context(instance); + if (context == nullptr) { + _E("Failed to find context. instance(%s)", instance); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + context->port = port; + ret = rpc_port_parcel_create_from_port(&parcel, port); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create parcel handle from port. error(%d)", ret); + return ret; + } + +#ifdef TIDL_THREAD_ENABLE + ret = __rpc_port_stub_vc_context_push(context, parcel); +#else + ret = __rpc_port_stub_vc_context_handle_request(context, parcel); + rpc_port_parcel_destroy(parcel); +#endif /* TIDL_THREAD_ENABLE */ + + return ret; +} + +static int __rpc_port_stub_vc_set_access_control(void) +{ + int ret = RPC_PORT_ERROR_NONE; + + return ret; +} + +int rpc_port_stub_vc_register(rpc_port_stub_vc_callback_s *callback, void *user_data) +{ + int ret; + + if (callback == nullptr || callback->create == nullptr || callback->terminate == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (__vc.stub) { + _E("Already exists"); + return RPC_PORT_ERROR_NONE; + } + + g_rec_mutex_init(&__vc.mutex); + __vc.callback = *callback; + __vc.user_data = user_data; + + ret = rpc_port_stub_create(&__vc.stub, "vc"); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to create stub handle. error(%d)", ret); + g_rec_mutex_clear(&__vc.mutex); + return ret; + } + + ret = rpc_port_stub_add_received_event_cb(__vc.stub, __rpc_port_stub_vc_received_event_cb, &__vc); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to add received event callback"); + rpc_port_stub_vc_unregister(); + return ret; + } + + ret = rpc_port_stub_add_connected_event_cb(__vc.stub, __rpc_port_stub_vc_connected_event_cb, &__vc); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to add connected event callback"); + rpc_port_stub_vc_unregister(); + return ret; + } + + ret = rpc_port_stub_add_disconnected_event_cb(__vc.stub, __rpc_port_stub_vc_disconnected_event_cb, &__vc); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to add disconnected event callback"); + rpc_port_stub_vc_unregister(); + return ret; + } + + ret = __rpc_port_stub_vc_set_access_control(); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to add privileges"); + rpc_port_stub_vc_unregister(); + return ret; + } + + ret = rpc_port_stub_listen(__vc.stub); + if (ret != RPC_PORT_ERROR_NONE) { + _E("Failed to listen events. error(%d)", ret); + rpc_port_stub_vc_unregister(); + return ret; + } + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_unregister(void) +{ + if (__vc.stub == nullptr) + return RPC_PORT_ERROR_NONE; + + g_rec_mutex_lock(&__vc.mutex); + g_rec_mutex_unlock(&__vc.mutex); + g_rec_mutex_clear(&__vc.mutex); + + if (__vc.contexts) { + g_list_free_full(__vc.contexts, __rpc_port_stub_vc_context_destroy); + __vc.contexts = nullptr; + } + + if (__vc.stub) { + rpc_port_stub_destroy(__vc.stub); + __vc.stub = nullptr; + } + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_foreach_context(rpc_port_stub_vc_context_cb callback, void *user_data) +{ + rpc_port_stub_vc_context_h context; + GList *iter; + + if (callback == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + g_rec_mutex_lock(&__vc.mutex); + iter = __vc.contexts; + while (iter) { + context = iter->data; + if (!callback(context, user_data)) + break; + + iter = g_list_next(iter); + } + g_rec_mutex_unlock(&__vc.mutex); + + return RPC_PORT_ERROR_NONE; +} + +int rpc_port_stub_vc_get_client_number(unsigned int *client_number) +{ + if (client_number == nullptr) { + _E("Invalid parameter"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + if (__vc.stub == nullptr) { + _E("Invalid context"); + return RPC_PORT_ERROR_INVALID_PARAMETER; + } + + g_rec_mutex_lock(&__vc.mutex); + *client_number = g_list_length(__vc.contexts); + g_rec_mutex_unlock(&__vc.mutex); + + return RPC_PORT_ERROR_NONE; +} diff --git a/server/vcd_stub.h b/server/vcd_stub.h new file mode 100755 index 0000000..70c5013 --- /dev/null +++ b/server/vcd_stub.h @@ -0,0 +1,680 @@ +/* + * Generated by tidlc 1.8.1. + */ + +#pragma once + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The rpc_port_stub_array_char handle. + */ +typedef struct rpc_port_stub_array_char_s *rpc_port_stub_array_char_h; + +/** + * @brief The rpc_port_stub_vc_context handle. + */ +typedef struct rpc_port_stub_vc_context_s *rpc_port_stub_vc_context_h; + +/** + * @brief The rpc_port_stub_vc_notify_cb handle. + */ +typedef struct rpc_port_stub_vc_notify_cb_s *rpc_port_stub_vc_notify_cb_h; + +/** + * @brief The rpc_port_stub_vc_feedback_cb handle. + */ +typedef struct rpc_port_stub_vc_feedback_cb_s *rpc_port_stub_vc_feedback_cb_h; + +/** + * @briefs Creates a rpc_port_stub_array_char handle. + * + * @remarks The @a h should be released using the rpc_port_stub_array_char_destroy() + * if it's no longer needed. + * @param[out] h The rpc_port_stub_array_char handle that is newly created + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_stub_array_char_destroy() + */ +int rpc_port_stub_array_char_create(rpc_port_stub_array_char_h *h); + +/** + * @brief Destroys the rpc_port_stub_array_char handle. + * + * @param[in] h The rpc_port_stub_array_char handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_stub_array_char_create() + */ +int rpc_port_stub_array_char_destroy(rpc_port_stub_array_char_h h); + +/** + * @brief Creates and returns a copy of the given rpc_port_stub_array_char handle. + * + * @remarks A new created rpc_port_stub_array_char should be released using + * the rpc_port_stub_array_char_destroy() if it's no longer needed. + * @param[in] h The rpc_port_stub_array_char handle + * @param[out] clone If successful, a new created rpc_port_stub_array_char handle will be returned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_stub_array_char_destroy() + */ +int rpc_port_stub_array_char_clone(rpc_port_stub_array_char_h h, rpc_port_stub_array_char_h *clone); + +/** + * @brief Sets the value to the rpc_port_stub_array_char handle. + * + * @remarks The value is internally copied and stored. + * You should release it if it's allocaed when it's no longer needed, + * @param[in] h The rpc_port_stub_array_char handle + * @param[in] value The array value + * @param[in] size The size of the array + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_stub_array_char_get() + */ +int rpc_port_stub_array_char_set(rpc_port_stub_array_char_h h, char *value, int size); + +/** + * @brief Gets the value from the rpc_port_stub_array_char handle. + * + * @remarks A new created value should be released if it's no longer needed. + * @param[in] h The rpc_port_stub_array_char handle + * @param[out] value The array value + * @param[out] size The size of the array + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_stub_array_char_set() + */ +int rpc_port_stub_array_char_get(rpc_port_stub_array_char_h h, char **value, int *size); + +/** + * @brief Called when the proxy is connected. + * @details The callback function is called when the proxy is connected to the stub. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s + */ +typedef void (*rpc_port_stub_vc_create_cb)(rpc_port_stub_vc_context_h context, void *user_data); + +/** + * @brief Called when the proxy is disconnected. + * @details The callback function is called when the proxy is disconnected from the stub. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s + */ +typedef void (*rpc_port_stub_vc_terminate_cb)(rpc_port_stub_vc_context_h context, void *user_data); + +/** + * @brief Called to get the proxy context once for each connected proxy. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @return @c true to continue with the next iteration of the loop, + * otherwise @c false to break out of the loop + * @pre rpc_port_stub_vc_foreach_context() will invoke this callback. + * @see rpc_port_stub_vc_foreach_context() + */ +typedef bool (*rpc_port_stub_vc_context_cb)(rpc_port_stub_vc_context_h context, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef void (*rpc_port_stub_vc_register_notify_cb_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_register_notify_cb_sync_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef void (*rpc_port_stub_vc_register_feedback_cb_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_register_feedback_cb_sync_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_initialize_cb)(rpc_port_stub_vc_context_h context, int pid, int *mgr_pid, int *service_state, int *daemon_pid, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_finalize_cb)(rpc_port_stub_vc_context_h context, int pid, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_set_command_cb)(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_unset_command_cb)(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_set_foreground_cb)(rpc_port_stub_vc_context_h context, int pid, bool value, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_set_server_dialog_cb)(rpc_port_stub_vc_context_h context, int pid, const char *app_id, const char *credential, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_request_dialog_cb)(rpc_port_stub_vc_context_h context, int pid, const char *disp_text, const char *utt_text, bool continuous, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_is_system_command_valid_cb)(rpc_port_stub_vc_context_h context, int pid, bool *is_sys_cmd_valid, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_auth_enable_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_auth_disable_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_auth_start_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_auth_stop_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_auth_cancel_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_request_tts_cb)(rpc_port_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_cancel_tts_cb)(rpc_port_stub_vc_context_h context, int pid, int utt_id, void *user_data); + +/** + * @brief Called when the request of the proxy is delivered. + * + * @param[in] context The context handle + * @param[in] user_data The user data passed from the registration function + * @see #rpc_port_stub_vc_callback_s; + */ +typedef int (*rpc_port_stub_vc_get_tts_audio_format_cb)(rpc_port_stub_vc_context_h context, int pid, int *rate, int *channel, int *audio_type, void *user_data); + +/** + * @brief Sets the tag to the context handle. + * + * @param[in] context The context handle + * @param[in] tag The tag + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_stub_vc_context_get_tag() + */ +int rpc_port_stub_vc_context_set_tag(rpc_port_stub_vc_context_h context, void *tag); + +/** + * @brief Gets the tag from the context handle. + * + * @param[in] context The context handle + * @param[out] tag The tag + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_stub_vc_context_set_tag() + */ +int rpc_port_stub_vc_context_get_tag(rpc_port_stub_vc_context_h context, void **tag); + +/** + * @brief Gets the sender ID from the context handle. + * @details The @a sender should be released using free(). + * + * @param[in] context The context handle + * @param[out] sender The sender ID of the context handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + */ +int rpc_port_stub_vc_context_get_sender(rpc_port_stub_vc_context_h context, char **sender); + +/** + * @brief Gets the instance ID from the context handle. + * @details The @a instance should be released using free(). + * + * @param[in] context The context handle + * @param[out] instance The instance ID of the context handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + */ +int rpc_port_stub_vc_context_get_instance(rpc_port_stub_vc_context_h context, char **instance); + +/** + * @brief Disconnects from the proxy. + * + * @param[in] context The context handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_stub_vc_context_disconnect(rpc_port_stub_vc_context_h context); + +/** + * @brief Creates a rpc_port_stub_vc_notify_cb handle. + * + * @param[out] h The rpc_port_stub_vc_notify_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_stub_vc_notify_cb_destroy() + */ +int rpc_port_stub_vc_notify_cb_create(rpc_port_stub_vc_notify_cb_h *h); + +/** + * @brief Destroys the rpc_port_stub_vc_notify_cb handle. + * + * @param[in] h The rpc_port_stub_vc_notify_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_stub_vc_notify_cb_clone() + */ +int rpc_port_stub_vc_notify_cb_destroy(rpc_port_stub_vc_notify_cb_h h); + +/** + * @brief Creates and returns a copy of the given rpc_port_stub_vc_notify_cb handle. + * + * @remarks A new created rpc_port_stub_vc_notify_cb should be released using + * the rpc_port_stub_vc_notify_cb_destroy() if it's no longer needed. + * @param[in] h The rpc_port_stub_vc_notify_cb handle + * @param[out] clone If successful, a new created rpc_port_stub_vc_notify_cb handle will be returned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_stub_vc_notify_cb_destroy() + */ +int rpc_port_stub_vc_notify_cb_clone(rpc_port_stub_vc_notify_cb_h h, rpc_port_stub_vc_notify_cb_h *clone); + +/** + * @brief Gets the ID of the rpc_port_stub_vc_notify_cb handle. + * + * @param[in] h The rpc_port_stub_vc_notify_cb handle + * @param[out] id The ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_stub_vc_notify_cb_get_id(rpc_port_stub_vc_notify_cb_h h, int *id); + +/** + * @brief Gets the sequence ID of the rpc_port_stub_vc_notify_cb handle. + * + * @param[in] h The rpc_port_stub_vc_notify_cb handle + * @param[out] seq_id The Sequence ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_stub_vc_notify_cb_get_seq_id(rpc_port_stub_vc_notify_cb_h h, int *seq_id); + +/** + * @brief Checks whether the delegate is for one-time or not. + * + * @param[in] h The rpc_port_stub_vc_notify_cb handle + * @param[out] once The flag, it's true, the handle is for one-time + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_stub_vc_notify_cb_is_once(rpc_port_stub_vc_notify_cb_h h, bool *once); + +/** + * @brief Gets the tag from the rpc_port_stub_vc_notify_cb handle. + * + * @remarks The @a tag should be released using free(). + * @param[in] h The rpc_port_stub_vc_notify_cb handle + * @param[out] tag The tag + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + */ +int rpc_port_stub_vc_notify_cb_get_tag(rpc_port_stub_vc_notify_cb_h h, char **tag); + +/** + * @brief Invokes the callback function of the rpc_port_stub_vc_notify_cb handle. + * + * @param[in] h The rpc_port_stub_vc_notify_cb handle + * @param[in] ... + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_stub_vc_notify_cb_invoke(rpc_port_stub_vc_notify_cb_h h, int pid, bundle *msg); + +/** + * @brief Creates a rpc_port_stub_vc_feedback_cb handle. + * + * @param[out] h The rpc_port_stub_vc_feedback_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_stub_vc_feedback_cb_destroy() + */ +int rpc_port_stub_vc_feedback_cb_create(rpc_port_stub_vc_feedback_cb_h *h); + +/** + * @brief Destroys the rpc_port_stub_vc_feedback_cb handle. + * + * @param[in] h The rpc_port_stub_vc_feedback_cb handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_stub_vc_feedback_cb_clone() + */ +int rpc_port_stub_vc_feedback_cb_destroy(rpc_port_stub_vc_feedback_cb_h h); + +/** + * @brief Creates and returns a copy of the given rpc_port_stub_vc_feedback_cb handle. + * + * @remarks A new created rpc_port_stub_vc_feedback_cb should be released using + * the rpc_port_stub_vc_feedback_cb_destroy() if it's no longer needed. + * @param[in] h The rpc_port_stub_vc_feedback_cb handle + * @param[out] clone If successful, a new created rpc_port_stub_vc_feedback_cb handle will be returned + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @see rpc_port_stub_vc_feedback_cb_destroy() + */ +int rpc_port_stub_vc_feedback_cb_clone(rpc_port_stub_vc_feedback_cb_h h, rpc_port_stub_vc_feedback_cb_h *clone); + +/** + * @brief Gets the ID of the rpc_port_stub_vc_feedback_cb handle. + * + * @param[in] h The rpc_port_stub_vc_feedback_cb handle + * @param[out] id The ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_stub_vc_feedback_cb_get_id(rpc_port_stub_vc_feedback_cb_h h, int *id); + +/** + * @brief Gets the sequence ID of the rpc_port_stub_vc_feedback_cb handle. + * + * @param[in] h The rpc_port_stub_vc_feedback_cb handle + * @param[out] seq_id The Sequence ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_stub_vc_feedback_cb_get_seq_id(rpc_port_stub_vc_feedback_cb_h h, int *seq_id); + +/** + * @brief Checks whether the delegate is for one-time or not. + * + * @param[in] h The rpc_port_stub_vc_feedback_cb handle + * @param[out] once The flag, it's true, the handle is for one-time + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_stub_vc_feedback_cb_is_once(rpc_port_stub_vc_feedback_cb_h h, bool *once); + +/** + * @brief Gets the tag from the rpc_port_stub_vc_feedback_cb handle. + * + * @remarks The @a tag should be released using free(). + * @param[in] h The rpc_port_stub_vc_feedback_cb handle + * @param[out] tag The tag + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + */ +int rpc_port_stub_vc_feedback_cb_get_tag(rpc_port_stub_vc_feedback_cb_h h, char **tag); + +/** + * @brief Invokes the callback function of the rpc_port_stub_vc_feedback_cb handle. + * + * @param[in] h The rpc_port_stub_vc_feedback_cb handle + * @param[in] ... + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #RPC_PORT_ERROR_IO_ERROR I/O error + */ +int rpc_port_stub_vc_feedback_cb_invoke(rpc_port_stub_vc_feedback_cb_h h, int utt_id, int event, rpc_port_stub_array_char_h pcm_data, int len); + +/** + * @brief The structure type containing the set of callback functions for handling stub events. + * @details It is one of the input parameters of the rpc_port_stub_vc_register() function. + * + * @see rpc_port_stub_vc_create_cb + * @see rpc_port_stub_vc_terminate_cb + */ +typedef struct { + rpc_port_stub_vc_create_cb create; /**< This callback function is invoked when the proxy is connected. */ + rpc_port_stub_vc_terminate_cb terminate; /**< This callback function is invoked when the proxy is disconnected. */ + rpc_port_stub_vc_register_notify_cb_cb register_notify_cb; /**< This callback function is invoked when the register_notify_cb request is delivered. */ + rpc_port_stub_vc_register_notify_cb_sync_cb register_notify_cb_sync; /**< This callback function is invoked when the register_notify_cb_sync request is delivered. */ + rpc_port_stub_vc_register_feedback_cb_cb register_feedback_cb; /**< This callback function is invoked when the register_feedback_cb request is delivered. */ + rpc_port_stub_vc_register_feedback_cb_sync_cb register_feedback_cb_sync; /**< This callback function is invoked when the register_feedback_cb_sync request is delivered. */ + rpc_port_stub_vc_initialize_cb initialize; /**< This callback function is invoked when the initialize request is delivered. */ + rpc_port_stub_vc_finalize_cb finalize; /**< This callback function is invoked when the finalize request is delivered. */ + rpc_port_stub_vc_set_command_cb set_command; /**< This callback function is invoked when the set_command request is delivered. */ + rpc_port_stub_vc_unset_command_cb unset_command; /**< This callback function is invoked when the unset_command request is delivered. */ + rpc_port_stub_vc_set_foreground_cb set_foreground; /**< This callback function is invoked when the set_foreground request is delivered. */ + rpc_port_stub_vc_set_server_dialog_cb set_server_dialog; /**< This callback function is invoked when the set_server_dialog request is delivered. */ + rpc_port_stub_vc_request_dialog_cb request_dialog; /**< This callback function is invoked when the request_dialog request is delivered. */ + rpc_port_stub_vc_is_system_command_valid_cb is_system_command_valid; /**< This callback function is invoked when the is_system_command_valid request is delivered. */ + rpc_port_stub_vc_auth_enable_cb auth_enable; /**< This callback function is invoked when the auth_enable request is delivered. */ + rpc_port_stub_vc_auth_disable_cb auth_disable; /**< This callback function is invoked when the auth_disable request is delivered. */ + rpc_port_stub_vc_auth_start_cb auth_start; /**< This callback function is invoked when the auth_start request is delivered. */ + rpc_port_stub_vc_auth_stop_cb auth_stop; /**< This callback function is invoked when the auth_stop request is delivered. */ + rpc_port_stub_vc_auth_cancel_cb auth_cancel; /**< This callback function is invoked when the auth_cancel request is delivered. */ + rpc_port_stub_vc_request_tts_cb request_tts; /**< This callback function is invoked when the request_tts request is delivered. */ + rpc_port_stub_vc_cancel_tts_cb cancel_tts; /**< This callback function is invoked when the cancel_tts request is delivered. */ + rpc_port_stub_vc_get_tts_audio_format_cb get_tts_audio_format; /**< This callback function is invoked when the get_tts_audio_format request is delivered. */ +} rpc_port_stub_vc_callback_s; + +/** + * @brief Registers the set of the callback functions and the port. + * @details This function registers the set of the callback functions to handle stub events. + * And, the rpc_port_stub_listen() is called internally to handle events. + * + * @param[in] callback The set of callback functions to handle stub events + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #RPC_PORT_ERROR_IO_ERROR I/O error + * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied + * @see rpc_port_stub_vc_unregister() + * @see #rpc_port_stub_vc_callback_s + */ +int rpc_port_stub_vc_register(rpc_port_stub_vc_callback_s *callback, void *user_data); + +/** + * @brief Unregisters the registered port. + */ +int rpc_port_stub_vc_unregister(void); + +/** + * @brief Retrieves the connected context handles. + * + * @param[in] callback The callback function + * @param[in] user_data The user data to be passed to the callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + * @see rpc_port_stub_vc_context_cb() + */ +int rpc_port_stub_vc_foreach_context(rpc_port_stub_vc_context_cb callback, void *user_data); + +/** + * @brief Gets the number of connected clients. + * + * @param[out] client_number The client number + * @return @c 0 on success, + * otherwise a negative error value + * @retval #RPC_PORT_ERROR_NONE Successful + * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int rpc_port_stub_vc_get_client_number(unsigned int *client_number); + +#ifdef __cplusplus +} +#endif diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 784f9c0..c81e81c 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -20,11 +20,13 @@ #include "vcd_config.h" #include "vcd_tidl.h" +#include "vcd_stub.h" #include "vcd_mgr_stub.h" #include "vcd_mgr_proxy.h" #include "vcd_widget_stub.h" #include "vcd_widget_proxy.h" + static rpc_port_stub_vc_mgr_callback_s g_mgr_callback; static pthread_mutex_t g_mgr_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -33,6 +35,8 @@ static rpc_port_stub_vc_widget_callback_s g_widget_callback; static pthread_mutex_t g_widget_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; +static rpc_port_stub_vc_callback_s g_vc_callback; + static int g_volume_count = 0; int vcd_mgr_tidl_open_connection(); @@ -309,6 +313,497 @@ void __send_signal(bundle* msg) pthread_mutex_unlock(&g_widget_tidl_info_mutex); } +/** + * TIDL functions for VC client + */ + +static void __vc_create_cb(rpc_port_stub_vc_context_h context, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_create_cb"); + + char *sender = NULL; + + rpc_port_stub_SamsungAIAppPort_context_get_sender(context, &sender); + if (!sender) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); + return ; + } + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] sender(%s)", sender); // sender (app_id) + free(sender); +} + +static void __vc_terminate_cb(rpc_port_stub_vc_context_h context, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_terminate_cb"); +} + +static void __vc_register_notify_cb_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_cb. pid(%d)", pid); + + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return ; + } + + int ret = -1; + ret = vcd_client_add_ipc_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info."); + return ; + } + + ret = vcd_client_set_ipc_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } +} + +static int __vc_register_notify_cb_sync_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_sync_cb. pid(%d)", pid); + + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = vcd_client_add_ipc_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info."); + return ret; + } + + ret = vcd_client_set_ipc_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } + + return ret; +} + +static void __vc_register_feedback_cb_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_cb. pid(%d)", pid); + + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return ; + } + + int ret = -1; + ret = vcd_client_add_ipc_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info."); + return ; + } + + ret = vcd_client_set_ipc_feedback_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set feedback callback."); + } +} + +static int __vc_register_feedback_cb_sync_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_sync_cb. pid(%d)", pid); + + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = vcd_client_add_ipc_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info."); + return ret; + } + + ret = vcd_client_set_ipc_feedback_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set feedback callback."); + } + + return ret; +} + +static int __vc_initialize_cb(rpc_port_stub_vc_context_h context, int pid, int *mgr_pid, int *service_state, int *daemon_pid, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_initialize_cb. pid(%d)", pid); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_initialize(pid); + *service_state = vcd_server_get_service_state(); + *daemon_pid = getpid(); + *mgr_pid = vcd_client_manager_get_pid(); + + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd initialize : pid(%d) daemon_pid(%d)", pid, daemon_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd initialize : pid(%d) daemon_pid(%d) ret(%d)", pid, daemon_pid, ret); + } + + return ret; +} + +static int __vc_finalize_cb(rpc_port_stub_vc_context_h context, int pid, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_finalize_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_finalize(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd finalize : pid(%d)", pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd finalize : pid(%d) ret(%d)", pid, ret); + } + + return ret; +} + +static int __vc_set_command_cb(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_command_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_set_command(pid, (vc_cmd_type_e)cmd_type); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set command : pid(%d), cmd_type(%d)", pid, cmd_type); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret); + } + + return ret; +} + +static int __vc_unset_command_cb(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_unset_command_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_unset_command(pid, (vc_cmd_type_e)cmd_type); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd unset command : pid(%d), cmd_type(%d)", pid, cmd_type); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd unset command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret); + } + + return ret; +} + +static int __vc_set_foreground_cb(rpc_port_stub_vc_context_h context, int pid, bool value, void *user_data) +{ + // check more... + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_foreground_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_set_foreground(pid, value); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d)", pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set foreground : pid(%d) ret(%d)", pid, ret); + } + + return ret; +} + +static int __vc_set_server_dialog_cb(rpc_port_stub_vc_context_h context, int pid, const char *app_id, const char *credential, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_server_dialog_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_set_server_dialog(pid, app_id, credential); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set server dialog : pid(%d), app_id(%s)", pid, app_id); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set server dialog : pid(%d), app_id(%s) ret(%d)", pid, app_id, ret); + } + + return ret; +} + +static int __vc_request_dialog_cb(rpc_port_stub_vc_context_h context, int pid, const char *disp_text, const char *utt_text, bool continuous, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_dialog_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_dialog(pid, disp_text, utt_text, continuous); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous); + } else { + 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(%d)); + } + + return ret; +} + +static int __vc_is_system_command_valid_cb(rpc_port_stub_vc_context_h context, int pid, bool *is_sys_cmd_valid, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_is_system_command_valid_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_is_system_command_valid(pid, &is_sys_cmd_valid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd check system command is valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd check system command is valid : pid(%d), ret(%d)", pid, ret); + } + + return ret; +} + +static int __vc_auth_enable_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_enable_cb"); + +} + +static int __vc_auth_disable_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_disable_cb"); +} + +static int __vc_auth_start_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_start_cb"); +} + +static int __vc_auth_stop_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_stop_cb"); +} + +static int __vc_auth_cancel_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_cancel_cb"); +} + +static int __vc_request_tts_cb(rpc_port_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_tts_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_request_tts(pid, text, lang, to_vcm, &utt_id); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d)", pid, text, lang, to_vcm); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d), ret(%d)", pid, text, lang, to_vcm, ret); + } + + return ret; +} + +static int __vc_cancel_tts_cb(rpc_port_stub_vc_context_h context, int pid, int utt_id, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_cancel_tts_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_cancel_tts(pid, utt_id); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd cancel tts : pid(%d), utt_id(%d)", pid, utt_id); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd cancel tts : pid(%d), utt_id(%d), ret(%d)", pid, utt_id, ret); + } + + return ret; +} + +static int __vc_get_tts_audio_format_cb(rpc_port_stub_vc_context_h context, int pid, int *rate, int *channel, int *audio_type, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_get_tts_audio_format_cb"); + + int ret = VCD_ERROR_OPERATION_FAILED; + + ret = vcd_server_get_tts_audio_format(pid, &rate, &channel, &audio_type); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd get tts audio format : pid(%d) ret(%d)", pid, ret); + } + + return ret; +} + +int vcd_tidl_open_connection() +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_open_connection"); + + g_vc_callback.create = __vc_create_cb; + g_vc_callback.terminate = __vc_terminate_cb; + g_vc_callback.register_notify_cb = __vc_register_notify_cb_cb; + g_vc_callback.register_notify_cb_sync = __vc_register_notify_cb_sync_cb; + g_vc_callback.register_feedback_cb = __vc_register_feedback_cb_cb; + g_vc_callback.register_feedback_cb_sync = __vc_register_feedback_cb_sync_cb; + g_vc_callback.initialize = __vc_initialize_cb; + g_vc_callback.finalize = __vc_finalize_cb; + g_vc_callback.set_command = __vc_set_command_cb; + g_vc_callback.unset_command = __vc_unset_command_cb; + g_vc_callback.set_foreground = __vc_set_foreground_cb; + g_vc_callback.set_server_dialog = __vc_set_server_dialog_cb; + g_vc_callback.request_dialog = __vc_request_dialog_cb; + g_vc_callback.is_system_command_valid = __vc_is_system_command_valid_cb; + g_vc_callback.auth_enable = __vc_auth_enable_cb; + g_vc_callback.auth_disable = __vc_auth_disable_cb; + g_vc_callback.auth_start = __vc_auth_start_cb; + g_vc_callback.auth_stop = __vc_auth_stop_cb; + g_vc_callback.auth_cancel = __vc_auth_cancel_cb; + g_vc_callback.request_tts = __vc_request_tts_cb; + g_vc_callback.cancel_tts = __vc_cancel_tts_cb; + g_vc_callback.get_tts_audio_format = __vc_get_tts_audio_format_cb; + + int ret = -1; + ret = rpc_port_stub_vc_register(&g_vc_callback, NULL); + if (VCD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to register TIDL callbacks. ret(%d)", ret); + return VCD_ERROR_OPERATION_FAILED; + } + + return VCD_ERROR_NONE; +} + +int vcd_tidl_close_connection() +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_close_connection"); + rpc_port_stub_vc_unregister(); + + return VCD_ERROR_NONE; +} + +int vcdc_send_result(int pid, int manager_pid, int cmd_type) +{ + client_ipc_info_s* info = vcd_client_get_ipc_info(pid); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + bundle* bundle_data = bundle_create(); + if (NULL == bundle_data) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Result command type(%d)", cmd_type); + + char pid_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char); + + switch (cmd_type) { + case VC_COMMAND_TYPE_FOREGROUND: + case VC_COMMAND_TYPE_BACKGROUND: + if (pid == manager_pid) { + bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); + } else { + bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_METHOD_RESULT); + } + break; + case VC_COMMAND_TYPE_WIDGET: + bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT); + break; + case VC_COMMAND_TYPE_SYSTEM: + case VC_COMMAND_TYPE_SYSTEM_BACKGROUND: + case VC_COMMAND_TYPE_EXCLUSIVE: + bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); + break; + + default: + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Command type is NOT valid(%d)", cmd_type); + return -1; + } + + rpc_port_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); + + return VCD_ERROR_NONE; +} + +int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) +{ + if (NULL == err_msg) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Input parameter is NULL"); + return VCD_ERROR_INVALID_PARAMETER; + } + + client_ipc_info_s* info = vcd_client_get_ipc_info(pid); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + bundle* bundle_data = bundle_create(); + if (NULL == bundle_data) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send error signal to app(%d)", pid); + + char pid_char[10] = {0}; + char reason_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + snprintf(reason_char, 10, "%d", reason); + + bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_METHOD_ERROR_TO_APP); + bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char); + bundle_add_str(bundle_data, VC_BUNDLE_REASON, reason_char); + bundle_add_str(bundle_data, VC_BUNDLE_ERR_MSG, err_msg); + + rpc_port_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); + + return VCD_ERROR_NONE; +} + +int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) +{ + if (NULL == buffer || 0 >= len) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter"); + return VCD_ERROR_INVALID_PARAMETER; + } + + client_ipc_info_s* info = vcd_client_get_ipc_info(pid); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + bundle* bundle_data = bundle_create(); + if (NULL == bundle_data) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send feedback streaming to app(%d), utt_id(%d), event(%d), length(%d)", pid, utt_id, event, len); + + rpc_port_stub_array_char_h arr_char = NULL; + rpc_port_stub_array_char_create(&arr_char); + rpc_port_stub_array_char_set(arr_char, buffer, len); + + rpc_port_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len); + + return VCD_ERROR_NONE; +} + // TODO: remove _tidl after all dbus removed int vcdc_tidl_send_hello(int pid, vcd_client_type_e type) { diff --git a/server/vcd_tidl.h b/server/vcd_tidl.h index 84e61f8..a4cd96e 100644 --- a/server/vcd_tidl.h +++ b/server/vcd_tidl.h @@ -30,6 +30,7 @@ extern "C" { // VCD_CLIENT_TYPE_MANAGER // } vcd_client_type_e; + int vcd_tidl_open_connection(); int vcd_tidl_close_connection(); @@ -69,9 +70,18 @@ int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_aud int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); +int vcdc_send_result(int pid, int manager_pid, int cmd_type); + +int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); + +int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); #ifdef __cplusplus } #endif +<<<<<<< HEAD +#endif /* __VCD_TIDL_h__ */ +======= #endif /* __VCD_TIDL_h__ */ +>>>>>>> Replace IPC (VCC) from dbus to tidl diff --git a/tidl/vc.tidl b/tidl/vc.tidl new file mode 100755 index 0000000..41348c6 --- /dev/null +++ b/tidl/vc.tidl @@ -0,0 +1,28 @@ +interface vc { + void notify_cb(int pid, bundle msg) delegate; + void feedback_cb(int utt_id, int event, array pcm_data, int len) delegate; + + void register_notify_cb(int pid, notify_cb callback) async; + int register_notify_cb_sync(int pid, notify_cb callback); + void register_feedback_cb(int pid, feedback_cb callback) async; + int register_feedback_cb_sync(int pid, feedback_cb callback); + + int initialize(in int pid, out int mgr_pid, out int service_state, out int daemon_pid); + int finalize(in int pid); + int set_command(in int pid, in int cmd_type); + int unset_command(in int pid, in int cmd_type); + int set_foreground(in int pid, in bool value); + int set_server_dialog(in int pid, in string app_id, in string credential); + int request_dialog(in int pid, in string disp_text, in string utt_text, in bool continuous); + int is_system_command_valid(in int pid, out bool is_sys_cmd_valid); + + int auth_enable(in int pid, in int mgr_pid); + int auth_disable(in int pid, in int mgr_pid); + int auth_start(in int pid, in int mgr_pid); + int auth_stop(in int pid, in int mgr_pid); + int auth_cancel(in int pid, in int mgr_pid); + + int request_tts(in int pid, string text, string lang, bool to_vcm, out int utt_id); + int cancel_tts(in int pid, in int utt_id); + int get_tts_audio_format(in int pid, out int rate, out int channel, out int audio_type); +} -- 2.7.4 From 7ae30a4e89b44df258daf25c74bc2712bca67075 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 13 Jun 2022 21:07:36 +0900 Subject: [PATCH 03/16] Add functions related to auth and stub tidl Change-Id: I1eded5e4c8f419de2925d30019c4c1579d013008 Signed-off-by: sooyeon --- server/CMakeLists.txt | 1 + server/vcd_client_data.c | 40 ++++++++++++++ server/vcd_client_data.h | 2 + server/vcd_dbus.c | 61 +-------------------- server/vcd_dbus.h | 2 +- server/vcd_tidl.c | 135 ++++++++++++++++++++++++++++++++++++++++++----- server/vcd_tidl.h | 6 +-- 7 files changed, 170 insertions(+), 77 deletions(-) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 5fe0268..c269a11 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -12,6 +12,7 @@ SET(SRCS vcd_dbus_server.c vcd_dbus.c vcd_tidl.c + vcd_stub.c vcd_mgr_stub.c vcd_mgr_proxy.c vcd_widget_stub.c diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 8d5136d..8e33a1f 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -1446,6 +1446,46 @@ client_ipc_info_s* vcd_client_get_ipc_info(int pid) return __get_client_ipc_info_element(pid); } +int vcd_client_get_ipc_list(int** pids, int* pid_count) +{ + if (NULL == pids || NULL == pid_count) + return -1; + + int count = g_slist_length(g_client_ipc_info_list); + + if (0 == count) + return -1; + + int *tmp; + tmp = (int*)calloc(count, sizeof(int)); + if (NULL == tmp) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + GSList *iter = NULL; + client_ipc_info_s *data = NULL; + int i = 0; + + iter = g_slist_nth(g_client_ipc_info_list, 0); + + while (NULL != iter) { + data = iter->data; + + if (NULL != data) { + tmp[i] = data->pid; + } + + iter = g_slist_next(iter); + i++; + } + + *pids = tmp; + *pid_count = count; + + return 0; +} + bool vcd_client_is_available(int pid) { vc_client_info_s* client_info = NULL; diff --git a/server/vcd_client_data.h b/server/vcd_client_data.h index 0620b19..789f329 100644 --- a/server/vcd_client_data.h +++ b/server/vcd_client_data.h @@ -204,6 +204,8 @@ int vcd_client_delete_ipc_info(int pid); client_ipc_info_s* vcd_client_get_ipc_info(int pid); +int vcd_client_get_ipc_list(int** pids, int* pid_count); + bool vcd_client_is_available(int pid); int vcd_client_get_ref_count(); diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index f7cfc10..0e67e46 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -227,7 +227,6 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type) return 0; } -*/ int vcdc_send_manager_pid(int manager_pid) { DBusError err; @@ -235,7 +234,7 @@ int vcdc_send_manager_pid(int manager_pid) DBusMessage* msg = NULL; - /* Send to client */ + // Send to client msg = dbus_message_new_signal( VC_CLIENT_SERVICE_OBJECT_PATH, VC_CLIENT_SERVICE_INTERFACE, @@ -260,62 +259,7 @@ int vcdc_send_manager_pid(int manager_pid) return 0; } - -int vcdc_send_error_signal_to_manager(int manager_pid, int reason, char *err_msg) -{ - SLOG(LOG_ERROR, TAG_VCD, "@@ Send error signal to manager"); - - if (0 != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - int daemon_pid; - DBusError err; - dbus_error_init(&err); - - DBusMessage* msg = NULL; - - msg = dbus_message_new_signal( - VC_MANAGER_SERVICE_OBJECT_PATH, - VC_MANAGER_SERVICE_INTERFACE, - VCD_MANAGER_METHOD_ERROR); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - char *temp_msg = NULL; - if (NULL == err_msg) { - SLOG(LOG_WARN, TAG_VCD, "[Dbus ERROR] Input parameter is NULL"); - temp_msg = strdup("#NULL"); - } else { - temp_msg = strdup(err_msg); - } - - daemon_pid = getpid(); - dbus_message_append_args(msg, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INT32, &daemon_pid, DBUS_TYPE_STRING, &temp_msg, DBUS_TYPE_INVALID); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - if (NULL != temp_msg) { - free(temp_msg); - temp_msg = NULL; - } - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "@@ Send error signal to manager : reason(%d), Error Msg(%s)", reason, temp_msg); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - if (NULL != temp_msg) { - free(temp_msg); - temp_msg = NULL; - } - - return 0; -} +*/ int vcdc_send_error_signal(int reason, char *err_msg) { @@ -453,7 +397,6 @@ int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) */ /* ->>>>>>> Replace IPC (VCC) from dbus to tidl int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) { SLOG(LOG_INFO, TAG_VCD, "[Dbus] Send TTS feedback streaming : pid(%d), utt_id(%d), feedback event(%d), buffer(%p), length(%d)", pid, utt_id, event, buffer, len); diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h index d6ae86c..e1abbe3 100644 --- a/server/vcd_dbus.h +++ b/server/vcd_dbus.h @@ -38,7 +38,7 @@ int vcdc_send_error_signal(int reason, char *err_msg); //int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); -int vcdc_send_manager_pid(int manager_pid); +// int vcdc_send_manager_pid(int manager_pid); /* for TTS feedback */ //int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index c81e81c..354cf21 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -316,14 +316,13 @@ void __send_signal(bundle* msg) /** * TIDL functions for VC client */ - static void __vc_create_cb(rpc_port_stub_vc_context_h context, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_create_cb"); char *sender = NULL; - rpc_port_stub_SamsungAIAppPort_context_get_sender(context, &sender); + rpc_port_stub_vc_context_get_sender(context, &sender); if (!sender) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); return ; @@ -450,9 +449,9 @@ static int __vc_initialize_cb(rpc_port_stub_vc_context_h context, int pid, int * *mgr_pid = vcd_client_manager_get_pid(); if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd initialize : pid(%d) daemon_pid(%d)", pid, daemon_pid); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd initialize : pid(%d) daemon_pid(%d)", pid, *daemon_pid); } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd initialize : pid(%d) daemon_pid(%d) ret(%d)", pid, daemon_pid, ret); + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd initialize : pid(%d) daemon_pid(%d) ret(%d)", pid, *daemon_pid, ret); } return ret; @@ -549,7 +548,7 @@ static int __vc_request_dialog_cb(rpc_port_stub_vc_context_h context, int pid, c if (VCD_ERROR_NONE == ret) { SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous); } else { - 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(%d)); + 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; @@ -561,7 +560,7 @@ static int __vc_is_system_command_valid_cb(rpc_port_stub_vc_context_h context, i int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_is_system_command_valid(pid, &is_sys_cmd_valid); + ret = vcd_server_is_system_command_valid(pid, (int*)is_sys_cmd_valid); if (VCD_ERROR_NONE == ret) { SLOG(LOG_INFO, TAG_VCD, "[IN] vcd check system command is valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid); } else { @@ -573,28 +572,87 @@ static int __vc_is_system_command_valid_cb(rpc_port_stub_vc_context_h context, i static int __vc_auth_enable_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_enable_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_enable_cb. Send a request to vc_mgr"); + + // int ret = VCD_ERROR_OPERATION_FAILED; + // ret = vcdc_send_request_auth_enable(pid); + // if (VCD_ERROR_NONE == ret) { + // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth enable. pid(%d), mgr_pid(%d)", pid, mgr_pid); + // } else { + // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth enable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + // } + + // return ret; + return VCD_ERROR_NONE; } static int __vc_auth_disable_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_disable_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_disable_cb. Send a request to vc_mgr"); + + // int ret = VCD_ERROR_OPERATION_FAILED; + // ret = vcdc_send_request_auth_disable(pid); + // if (VCD_ERROR_NONE == ret) { + // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth disable. pid(%d), mgr_pid(%d)", pid, mgr_pid); + // } else { + // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth disable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + // } + + // return ret; + + return VCD_ERROR_NONE; } static int __vc_auth_start_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_start_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_start_cb. Send a request to vc_mgr"); + + // int ret = VCD_ERROR_OPERATION_FAILED; + // ret = vcdc_send_request_auth_start(pid); + // if (VCD_ERROR_NONE == ret) { + // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth start. pid(%d), mgr_pid(%d)", pid, mgr_pid); + // } else { + // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth start. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + // } + + // return ret; + + return VCD_ERROR_NONE; } static int __vc_auth_stop_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_stop_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_stop_cb. Send a request to vc_mgr"); + + // int ret = VCD_ERROR_OPERATION_FAILED; + // ret = vcdc_send_request_auth_stop(pid); + // if (VCD_ERROR_NONE == ret) { + // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth stop. pid(%d), mgr_pid(%d)", pid, mgr_pid); + // } else { + // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth stop. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + // } + + // return ret; + + return VCD_ERROR_NONE; } static int __vc_auth_cancel_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_cancel_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_cancel_cb. Send a request to vc_mgr"); + + // int ret = VCD_ERROR_OPERATION_FAILED; + // ret = vcdc_send_request_auth_cancel(pid); + // if (VCD_ERROR_NONE == ret) { + // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth cancel. pid(%d), mgr_pid(%d)", pid, mgr_pid); + // } else { + // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth cancel. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + // } + + // return ret; + + return VCD_ERROR_NONE; } static int __vc_request_tts_cb(rpc_port_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data) @@ -603,7 +661,7 @@ static int __vc_request_tts_cb(rpc_port_stub_vc_context_h context, int pid, cons int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_request_tts(pid, text, lang, to_vcm, &utt_id); + ret = vcd_server_request_tts(pid, text, lang, to_vcm, utt_id); if (VCD_ERROR_NONE == ret) { SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d)", pid, text, lang, to_vcm); } else { @@ -635,7 +693,7 @@ static int __vc_get_tts_audio_format_cb(rpc_port_stub_vc_context_h context, int int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_get_tts_audio_format(pid, &rate, &channel, &audio_type); + ret = vcd_server_get_tts_audio_format(pid, rate, channel, audio_type); if (VCD_ERROR_NONE == ret) { SLOG(LOG_INFO, TAG_VCD, "[IN] vcd get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type); } else { @@ -774,6 +832,57 @@ int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) return VCD_ERROR_NONE; } +int vcdc_send_manager_pid(int manager_pid) +{ + // send signal to all pid + + // get all pids + int* client_list = NULL; + int client_count = 0; + int ret = -1; + ret = vcd_client_get_ipc_list(&client_list, &client_count); + if (0 != ret || 0 == client_count) { + SLOG(LOG_WARN, TAG_VCD, "[WARNING] There is no client"); + return VCD_ERROR_NONE; + } + + client_ipc_info_s* info; + int pid = -1; + bundle* bundle_data; + char pid_char[10] = {0}; + char mgrpid_char[10] = {0}; + for (int i = 0 ; i < client_count ; i++) { + pid = client_list[i]; + + info = vcd_client_get_ipc_info(pid); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid); + continue; + } + + bundle_data = bundle_create(); + if (NULL == bundle_data) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + continue; + } + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send manager pid(%d) to app(%d)", manager_pid, pid); + + snprintf(pid_char, 10, "%d", pid); + snprintf(mgrpid_char, 10, "%d", manager_pid); + + bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_METHOD_SEND_MANAGER_PID); + bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char); + bundle_add_str(bundle_data, VC_BUNDLE_MANAGER_PID, mgrpid_char); + + rpc_port_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); + + bundle_free(bundle_data); + } + + return VCD_ERROR_NONE; +} + int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) { if (NULL == buffer || 0 >= len) { diff --git a/server/vcd_tidl.h b/server/vcd_tidl.h index a4cd96e..715e3f3 100644 --- a/server/vcd_tidl.h +++ b/server/vcd_tidl.h @@ -74,14 +74,12 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type); int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); +int vcdc_send_manager_pid(int manager_pid); + int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); #ifdef __cplusplus } #endif -<<<<<<< HEAD -#endif /* __VCD_TIDL_h__ */ -======= #endif /* __VCD_TIDL_h__ */ ->>>>>>> Replace IPC (VCC) from dbus to tidl -- 2.7.4 From d41e4834b1e4309b6bb7fbe245dcc6631fcccbba Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 20 Jun 2022 21:05:33 +0900 Subject: [PATCH 04/16] Add namespace(-n) option to build tidlc and Change TIDL apis Change-Id: I1feba522be81db7567081650613e506f085d1906 Signed-off-by: sooyeon --- client/vc_mgr_tidl.c | 122 +- client/vc_proxy.c | 2869 ------------------------------------------ client/vc_proxy.h | 819 ------------ client/vc_tidl.c | 80 +- client/vc_widget_tidl.c | 64 +- packaging/voice-control.spec | 24 +- server/vcd_client_data.c | 32 +- server/vcd_client_data.h | 24 +- server/vcd_dbus.c | 48 +- server/vcd_stub.c | 2422 ----------------------------------- server/vcd_stub.h | 680 ---------- server/vcd_tidl.c | 275 ++-- 12 files changed, 335 insertions(+), 7124 deletions(-) delete mode 100755 client/vc_proxy.c delete mode 100755 client/vc_proxy.h delete mode 100755 server/vcd_stub.c delete mode 100755 server/vcd_stub.h diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index daf53a1..3d98e9c 100755 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -29,9 +29,9 @@ typedef struct { bool connected; bool connection_requesting; bool register_callback_invoked; - rpc_port_proxy_vc_mgr_h rpc_h; - rpc_port_proxy_vc_mgr_notify_cb_h notify_cb_h; - rpc_port_proxy_vc_mgr_send_buffer_cb_h send_buffer_cb_h; + rpc_port_proxy_vc_mgr_proxy_vc_mgr_h rpc_h; + rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_h notify_cb_h; + rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_h send_buffer_cb_h; } vc_mgr_tidl_info_s; typedef struct { @@ -45,7 +45,7 @@ static vcd_mgr_tidl_info_s* g_stub_tidl_info = NULL; static pthread_mutex_t g_tidl_mutex = PTHREAD_MUTEX_INITIALIZER; -static rpc_port_stub_vcd_mgr_callback_s g_mgr_callback; +static rpc_port_stub_vc_mgr_stub_vcd_mgr_callback_s g_mgr_callback; static int g_volume_count = 0; @@ -300,7 +300,7 @@ static void __notify_cb(void *user_data, bundle *msg) } -static void __send_buffer_cb(void *user_data, rpc_port_proxy_array_char_h data_in, bundle *msg) +static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_char_h data_in, bundle *msg) { char *method = NULL; char *val = NULL; @@ -319,7 +319,7 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_array_char_h data_i bundle_get_str(msg, VC_MANAGER_BUNDLE_UTTID, &utt_id); bundle_get_str(msg, VC_MANAGER_BUNDLE_EVENT, &event); - rpc_port_proxy_array_char_get(data_in, &buffer, &len); + rpc_port_proxy_vc_mgr_proxy_array_char_get(data_in, &buffer, &len); __vc_mgr_cb_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len); free(buffer); @@ -332,7 +332,7 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_array_char_h data_i } -static void __on_connected(rpc_port_proxy_vc_mgr_h h, void *user_data) +static void __on_connected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data) { g_proxy_tidl_info->connected = true; g_proxy_tidl_info->connection_requesting = false; @@ -341,7 +341,7 @@ static void __on_connected(rpc_port_proxy_vc_mgr_h h, void *user_data) SLOG(LOG_INFO, TAG_VCM, "Connected to server"); } -static void __on_disconnected(rpc_port_proxy_vc_mgr_h h, void *user_data) +static void __on_disconnected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data) { g_proxy_tidl_info->connected = false; g_proxy_tidl_info->connection_requesting = false; @@ -353,7 +353,7 @@ static void __on_disconnected(rpc_port_proxy_vc_mgr_h h, void *user_data) __vc_mgr_cb_error(VC_ERROR_SERVICE_RESET, -1, "Server Disconnected, re-launch"); } -static void __on_rejected(rpc_port_proxy_vc_mgr_h h, void *user_data) +static void __on_rejected(rpc_port_proxy_vc_mgr_proxy_vc_mgr_h h, void *user_data) { g_proxy_tidl_info->connection_requesting = false; g_proxy_tidl_info->register_callback_invoked = false; @@ -362,17 +362,17 @@ static void __on_rejected(rpc_port_proxy_vc_mgr_h h, void *user_data) } -static rpc_port_proxy_vc_mgr_h __create_rpc_port(const char* engine_app_id) +static rpc_port_proxy_vc_mgr_proxy_vc_mgr_h __create_rpc_port(const char* engine_app_id) { SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] __create_rpc_port"); - rpc_port_proxy_vc_mgr_callback_s rpc_callback = { + rpc_port_proxy_vc_mgr_proxy_vc_mgr_callback_s rpc_callback = { .connected = __on_connected, .disconnected = __on_disconnected, .rejected = __on_rejected }; - rpc_port_proxy_vc_mgr_h handle = NULL; - if (0 != rpc_port_proxy_vc_mgr_create(engine_app_id, &rpc_callback, NULL, &handle)) { + rpc_port_proxy_vc_mgr_proxy_vc_mgr_h handle = NULL; + if (0 != rpc_port_proxy_vc_mgr_proxy_vc_mgr_create(engine_app_id, &rpc_callback, NULL, &handle)) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to create proxy"); return NULL; } @@ -380,7 +380,7 @@ static rpc_port_proxy_vc_mgr_h __create_rpc_port(const char* engine_app_id) return handle; } -static void __vcd_mgr_create_cb(rpc_port_stub_vcd_mgr_context_h context, void *user_data) +static void __vcd_mgr_create_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, void *user_data) { g_stub_tidl_info->connected = true; g_stub_tidl_info->register_callback_requesting = false; @@ -389,7 +389,7 @@ static void __vcd_mgr_create_cb(rpc_port_stub_vcd_mgr_context_h context, void *u char *sender = NULL; - rpc_port_stub_vcd_mgr_context_get_sender(context, &sender); + rpc_port_stub_vc_mgr_stub_vcd_mgr_context_get_sender(context, &sender); if (!sender) { SLOG(LOG_ERROR, TAG_VCM, "@@@ Sender is NULL"); return; @@ -399,15 +399,15 @@ static void __vcd_mgr_create_cb(rpc_port_stub_vcd_mgr_context_h context, void *u free(sender); } -static void __vcd_mgr_terminate_cb(rpc_port_stub_vcd_mgr_context_h context, void *user_data) +static void __vcd_mgr_terminate_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, void *user_data) { g_stub_tidl_info->connected = false; g_stub_tidl_info->register_callback_requesting = false; - rpc_port_stub_vcd_mgr_context_set_tag(context, NULL); + rpc_port_stub_vc_mgr_stub_vcd_mgr_context_set_tag(context, NULL); char *sender = NULL; - rpc_port_stub_vcd_mgr_context_get_sender(context, &sender); + rpc_port_stub_vc_mgr_stub_vcd_mgr_context_get_sender(context, &sender); if (!sender) return; @@ -415,7 +415,7 @@ static void __vcd_mgr_terminate_cb(rpc_port_stub_vcd_mgr_context_h context, void free(sender); } -static void __vcd_mgr_set_foreground_cb(rpc_port_stub_vcd_mgr_context_h context, int pid, int value, void *user_data) +static void __vcd_mgr_set_foreground_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, int value, void *user_data) { SLOG(LOG_INFO, TAG_VCM, "@@@ Set foreground"); SLOG(LOG_INFO, TAG_VCM, "@@ foreground changed : pid(%d) value(%s)", pid, value ? "true" : "false"); @@ -425,7 +425,7 @@ static void __vcd_mgr_set_foreground_cb(rpc_port_stub_vcd_mgr_context_h context, SLOG(LOG_DEBUG, TAG_VCM, "@@@"); } -static int __vcd_mgr_get_private_data_cb(rpc_port_stub_vcd_mgr_context_h context, int pid, const char *key, char **data, void *user_data) +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) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get request get private data"); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request get private data : pid(%d) ", pid); @@ -448,7 +448,7 @@ static int __vcd_mgr_get_private_data_cb(rpc_port_stub_vcd_mgr_context_h context return ret; } -static int __vcd_mgr_auth_enable_cb(rpc_port_stub_vcd_mgr_context_h context, int pid, void *user_data) +static int __vcd_mgr_auth_enable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth enable"); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth enable : pid(%d)", pid); @@ -465,7 +465,7 @@ static int __vcd_mgr_auth_enable_cb(rpc_port_stub_vcd_mgr_context_h context, int return ret; } -static int __vcd_mgr_auth_disable_cb(rpc_port_stub_vcd_mgr_context_h context, int pid, void *user_data) +static int __vcd_mgr_auth_disable_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth disable"); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth disable : pid(%d)", pid); @@ -482,7 +482,7 @@ static int __vcd_mgr_auth_disable_cb(rpc_port_stub_vcd_mgr_context_h context, in return ret; } -static int __vcd_mgr_auth_start_cb(rpc_port_stub_vcd_mgr_context_h context, int pid, void *user_data) +static int __vcd_mgr_auth_start_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth start"); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth start : pid(%d)", pid); @@ -499,7 +499,7 @@ static int __vcd_mgr_auth_start_cb(rpc_port_stub_vcd_mgr_context_h context, int return ret; } -static int __vcd_mgr_auth_stop_cb(rpc_port_stub_vcd_mgr_context_h context, int pid, void *user_data) +static int __vcd_mgr_auth_stop_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth stop"); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth stop : pid(%d)", pid); @@ -516,7 +516,7 @@ static int __vcd_mgr_auth_stop_cb(rpc_port_stub_vcd_mgr_context_h context, int p return ret; } -static int __vcd_mgr_auth_cancel_cb(rpc_port_stub_vcd_mgr_context_h context, int pid, void *user_data) +static int __vcd_mgr_auth_cancel_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h context, int pid, void *user_data) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth cancel"); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth cancel : pid(%d)", pid); @@ -552,7 +552,7 @@ static void __register_stub_callback() g_mgr_callback.auth_cancel = __vcd_mgr_auth_cancel_cb; int ret = -1; - ret = rpc_port_stub_vcd_mgr_register(&g_mgr_callback, NULL); + ret = rpc_port_stub_vc_mgr_stub_vcd_mgr_register(&g_mgr_callback, NULL); if (0 == ret) { SLOG(LOG_DEBUG, TAG_VCM, "register callback"); g_stub_tidl_info->register_callback_requesting = true; @@ -630,7 +630,7 @@ int vc_mgr_tidl_close_connection() return VC_ERROR_OPERATION_FAILED; } - if (0 != rpc_port_proxy_vc_mgr_destroy(g_proxy_tidl_info->rpc_h)) { + if (0 != rpc_port_proxy_vc_mgr_proxy_vc_mgr_destroy(g_proxy_tidl_info->rpc_h)) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Fail to destroy tidl handle"); pthread_mutex_unlock(&g_tidl_mutex); return VC_ERROR_OPERATION_FAILED; @@ -657,7 +657,7 @@ static void __request_tidl_connect() return; } - int ret = rpc_port_proxy_vc_mgr_connect(g_proxy_tidl_info->rpc_h); + int ret = rpc_port_proxy_vc_mgr_proxy_vc_mgr_connect(g_proxy_tidl_info->rpc_h); SLOG(LOG_INFO, TAG_VCM, "[INFO] Request connection to stub. ret(%d)", ret); if (0 == ret) { @@ -668,30 +668,30 @@ static void __request_tidl_connect() static int __create_callback_handles() { if (NULL != g_proxy_tidl_info->notify_cb_h) { - rpc_port_proxy_vc_mgr_notify_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->notify_cb_h); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->notify_cb_h); g_proxy_tidl_info->notify_cb_h = NULL; } - if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_mgr_notify_cb_create(&g_proxy_tidl_info->notify_cb_h)) { + if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_create(&g_proxy_tidl_info->notify_cb_h)) { return VC_ERROR_OUT_OF_MEMORY; } - rpc_port_proxy_vc_mgr_notify_cb_set_callback(g_proxy_tidl_info->notify_cb_h, __notify_cb, NULL); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_set_callback(g_proxy_tidl_info->notify_cb_h, __notify_cb, NULL); - rpc_port_proxy_vc_mgr_notify_cb_set_once(g_proxy_tidl_info->notify_cb_h, false); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_notify_cb_set_once(g_proxy_tidl_info->notify_cb_h, false); if (NULL != g_proxy_tidl_info->send_buffer_cb_h) { - rpc_port_proxy_vc_mgr_send_buffer_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->send_buffer_cb_h); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->send_buffer_cb_h); g_proxy_tidl_info->send_buffer_cb_h = NULL; } - if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_mgr_send_buffer_cb_create(&g_proxy_tidl_info->send_buffer_cb_h)) { + if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_create(&g_proxy_tidl_info->send_buffer_cb_h)) { return VC_ERROR_OUT_OF_MEMORY; } - rpc_port_proxy_vc_mgr_send_buffer_cb_set_callback(g_proxy_tidl_info->send_buffer_cb_h, __send_buffer_cb, NULL); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_set_callback(g_proxy_tidl_info->send_buffer_cb_h, __send_buffer_cb, NULL); - rpc_port_proxy_vc_mgr_send_buffer_cb_set_once(g_proxy_tidl_info->send_buffer_cb_h, false); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_send_buffer_cb_set_once(g_proxy_tidl_info->send_buffer_cb_h, false); return VC_ERROR_NONE; } @@ -709,7 +709,7 @@ static int __invoke_register_callback() return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_mgr_invoke_register_cb(g_proxy_tidl_info->rpc_h, getpid(), g_proxy_tidl_info->notify_cb_h, g_proxy_tidl_info->send_buffer_cb_h); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_register_cb(g_proxy_tidl_info->rpc_h, getpid(), g_proxy_tidl_info->notify_cb_h, g_proxy_tidl_info->send_buffer_cb_h); g_proxy_tidl_info->register_callback_invoked = true; return VC_ERROR_NONE; } @@ -770,7 +770,7 @@ int vc_mgr_tidl_request_initialize(int pid, int audio_streaming_mode, int* servi return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, audio_streaming_mode, &tmp_service_state, &tmp_forground, &tmp_daemon_pid); + 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager initialize : Fail to invoke message, error(%d)", ret); return ret; @@ -799,7 +799,7 @@ int vc_mgr_tidl_request_finalize(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_finalize(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager finalize : Fail to invoke message, error(%d)", ret); return ret; @@ -822,7 +822,7 @@ int vc_mgr_tidl_request_set_command(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_set_command(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set command : Fail to invoke message, error(%d)", ret); return ret; @@ -845,7 +845,7 @@ int vc_mgr_tidl_request_unset_command(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_unset_command(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager unset command : Fail to invoke message, error(%d)", ret); return ret; @@ -868,7 +868,7 @@ int vc_mgr_tidl_request_demandable_client(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_demandable_client(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager demandable client : Fail to invoke message, error(%d)", ret); return ret; @@ -891,7 +891,7 @@ int vc_mgr_tidl_request_set_audio_type(int pid, const char* audio_type) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_set_audio_type(g_proxy_tidl_info->rpc_h, pid, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set audio type : Fail to invoke message, error(%d)", ret); return ret; @@ -915,7 +915,7 @@ int vc_mgr_tidl_request_get_audio_type(int pid, char** audio_type) } char *tmp = NULL; - int ret = rpc_port_proxy_vc_mgr_invoke_get_audio_type(g_proxy_tidl_info->rpc_h, pid, &tmp); + 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get audio type : Fail to invoke message, error(%d)", ret); return ret; @@ -941,7 +941,7 @@ int vc_mgr_tidl_request_set_private_data(int pid, const char* key, const char* d return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_mgr_invoke_set_private_data(g_proxy_tidl_info->rpc_h, pid, key, data); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_private_data(g_proxy_tidl_info->rpc_h, pid, key, data); return VC_ERROR_NONE; } @@ -961,7 +961,7 @@ 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_invoke_get_private_data(g_proxy_tidl_info->rpc_h, pid, key, &tmp); + 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager get private data : Fail to invoke message, error(%d)", ret); return ret; @@ -987,7 +987,7 @@ int vc_mgr_tidl_request_set_client_info(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_set_client_info(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set client info : Fail to invoke message, error(%d)", ret); return ret; @@ -1010,7 +1010,7 @@ int vc_mgr_tidl_request_set_domain(int pid, const char* domain) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_set_domain(g_proxy_tidl_info->rpc_h, pid, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager set domain : Fail to invoke message, error(%d)", ret); return ret; @@ -1033,7 +1033,7 @@ int vc_mgr_tidl_request_do_action(int pid, vc_send_event_type_e type, char* send return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_mgr_invoke_do_action(g_proxy_tidl_info->rpc_h, pid, type, send_event); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_do_action(g_proxy_tidl_info->rpc_h, pid, type, send_event); return VC_ERROR_NONE; } @@ -1052,7 +1052,7 @@ int vc_mgr_tidl_request_start(int pid, int recognition_mode, bool exclusive_comm return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_start(g_proxy_tidl_info->rpc_h, pid, recognition_mode, exclusive_command_option, start_by_client, disabled_cmd_type); + 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager start : Fail to invoke message, error(%d)", ret); return ret; @@ -1075,7 +1075,7 @@ int vc_mgr_tidl_request_stop(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_stop(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager stop : Fail to invoke message, error(%d)", ret); return ret; @@ -1098,7 +1098,7 @@ int vc_mgr_tidl_request_cancel(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_mgr_invoke_cancel(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCM, "[TIDL ERROR] Request vc manager cancel : Fail to invoke message, error(%d)", ret); return ret; @@ -1121,7 +1121,7 @@ int vc_mgr_tidl_request_set_audio_streaming_mode(int pid, vc_audio_streaming_mod return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_mgr_invoke_set_audio_streaming_mode(g_proxy_tidl_info->rpc_h, pid, mode); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_set_audio_streaming_mode(g_proxy_tidl_info->rpc_h, pid, mode); return VC_ERROR_NONE; } @@ -1140,7 +1140,7 @@ int vc_mgr_tidl_send_result_selection(int pid) return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_mgr_invoke_send_result_selection(g_proxy_tidl_info->rpc_h, pid); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_result_selection(g_proxy_tidl_info->rpc_h, pid); return VC_ERROR_NONE; } @@ -1161,7 +1161,7 @@ int vc_mgr_tidl_send_specific_engine_request(int pid, const char* engine_app_id, gchar *gEncodedRequest = g_base64_encode((const guchar*)request, strlen(request)); - rpc_port_proxy_vc_mgr_invoke_send_specific_engine_request(g_proxy_tidl_info->rpc_h, pid, engine_app_id, event, gEncodedRequest); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_specific_engine_request(g_proxy_tidl_info->rpc_h, pid, engine_app_id, event, gEncodedRequest); if (gEncodedRequest) g_free(gEncodedRequest); @@ -1183,7 +1183,7 @@ int vc_mgr_tidl_send_utterance_status(int pid, int utt_id, vc_tts_utterance_stat return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_mgr_invoke_send_utterance_status(g_proxy_tidl_info->rpc_h, utt_id, utt_status); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_utterance_status(g_proxy_tidl_info->rpc_h, utt_id, utt_status); return VC_ERROR_NONE; } @@ -1202,21 +1202,21 @@ int vc_mgr_tidl_send_audio_streaming(int pid, vc_audio_streaming_event_e event, return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_array_char_h data = NULL; - rpc_port_proxy_array_char_create(&data); + rpc_port_proxy_vc_mgr_proxy_array_char_h data = NULL; + rpc_port_proxy_vc_mgr_proxy_array_char_create(&data); if (NULL == data) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to create data handle"); return VC_ERROR_OUT_OF_MEMORY; } if (NULL != buffer && 0 < len) { - rpc_port_proxy_array_char_set(data, (char*)buffer, len); + rpc_port_proxy_vc_mgr_proxy_array_char_set(data, (char*)buffer, len); } else { SLOG(LOG_ERROR, TAG_VCM, "[TIDL] buffer is empty"); } - rpc_port_proxy_vc_mgr_invoke_send_audio_streaming(g_proxy_tidl_info->rpc_h, pid, event, data); - rpc_port_proxy_array_char_destroy(data); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_audio_streaming(g_proxy_tidl_info->rpc_h, pid, event, data); + rpc_port_proxy_vc_mgr_proxy_array_char_destroy(data); return VC_ERROR_NONE; } diff --git a/client/vc_proxy.c b/client/vc_proxy.c deleted file mode 100755 index d55b82d..0000000 --- a/client/vc_proxy.c +++ /dev/null @@ -1,2869 +0,0 @@ -/* - * Generated by tidlc 1.8.1. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "vc_proxy.h" - -#undef LOG_TAG -#define LOG_TAG "RPC_PORT_PROXY" - -#undef _E -#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#undef _W -#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#undef _I -#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#undef _D -#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#ifndef TIDL_VERSION -#define TIDL_VERSION "1.8.1" -#endif - -#ifndef nullptr -#define nullptr NULL -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -#ifndef STRING_GET -#define STRING_GET(x) ((x) ? x : "") -#endif - -typedef void (*rpc_port_proxy_delegate_cb)(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id); - -typedef struct rpc_port_proxy_array_char_s { - rpc_port_parcelable_t parcelable; - char *value; - int size; -} rpc_port_proxy_array_char_t; - -typedef struct rpc_port_proxy_vc_notify_cb_s { - rpc_port_parcelable_t parcelable; - int id; - int seq_id; - bool once; - rpc_port_proxy_vc_notify_cb_cb callback; - void *user_data; -} rpc_port_proxy_vc_notify_cb_t; - -typedef struct rpc_port_proxy_vc_feedback_cb_s { - rpc_port_parcelable_t parcelable; - int id; - int seq_id; - bool once; - rpc_port_proxy_vc_feedback_cb_cb callback; - void *user_data; -} rpc_port_proxy_vc_feedback_cb_t; - -typedef struct rpc_port_proxy_vc_s { - char *stub_appid; - rpc_port_proxy_h proxy; - rpc_port_h port; - rpc_port_h callback_port; - rpc_port_proxy_vc_callback_s callback; - void *user_data; - GList *delegates; - GRecMutex mutex; -} rpc_port_proxy_vc_t; - -static void __rpc_port_proxy_array_char_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_proxy_array_char_h h = data; - int i; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_array_count(parcel, h->size); - - for (i = 0; i < h->size; ++i) - rpc_port_parcel_write_byte(parcel, h->value[i]); -} - -static void __rpc_port_proxy_array_char_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_proxy_array_char_h h = data; - char value; - int ret; - int i; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - ret = rpc_port_parcel_read_array_count(parcel, &h->size); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to read array count. error(%d)", ret); - set_last_result(ret); - return; - } - - h->value = calloc(h->size, sizeof(char)); - if (h->value == nullptr) { - _E("Out of memory"); - set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); - return; - } - - for (i = 0; i < h->size; ++i) { - rpc_port_parcel_read_byte(parcel, &value); - h->value[i] = value; - } - - set_last_result(RPC_PORT_ERROR_NONE); -} - -int rpc_port_proxy_array_char_create(rpc_port_proxy_array_char_h *h) -{ - rpc_port_proxy_array_char_t *handle; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - handle = calloc(1, sizeof(rpc_port_proxy_array_char_t)); - if (handle == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - handle->parcelable.to = __rpc_port_proxy_array_char_to; - handle->parcelable.from = __rpc_port_proxy_array_char_from; - - *h = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_array_char_destroy(rpc_port_proxy_array_char_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (h->value) - free(h->value); - - free(h); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_array_char_clone(rpc_port_proxy_array_char_h h, rpc_port_proxy_array_char_h *clone) -{ - rpc_port_proxy_array_char_h handle; - rpc_port_parcel_h parcel; - int ret; - - if (h == nullptr || clone == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_proxy_array_char_create(&handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret); - return ret; - } - - ret = rpc_port_parcel_create(&parcel); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret); - rpc_port_proxy_array_char_destroy(handle); - return ret; - } - - rpc_port_parcel_write(parcel, &h->parcelable, h); - rpc_port_parcel_read(parcel, &handle->parcelable, handle); - ret = get_last_result(); - rpc_port_parcel_destroy(parcel); - - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to read data. error(%d)", ret); - rpc_port_proxy_array_char_destroy(handle); - return ret; - } - - *clone = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_array_char_set(rpc_port_proxy_array_char_h h, char *value, int size) -{ - rpc_port_proxy_array_char_h handle; - rpc_port_proxy_array_char_h clone; - int ret; - - if (h == nullptr || value == nullptr || size <= 0) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_proxy_array_char_create(&handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret); - return ret; - } - - handle->value = (char *)value; - handle->size = size; - - ret = rpc_port_proxy_array_char_clone(handle, &clone); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to clone handle. error(%d)", ret); - handle->value = nullptr; - handle->size = 0; - rpc_port_proxy_array_char_destroy(handle); - return ret; - } - - handle->value = h->value; - handle->size = h->size; - rpc_port_proxy_array_char_destroy(handle); - - h->value = clone->value; - h->size = clone->size; - - clone->value = nullptr; - clone->size = 0; - rpc_port_proxy_array_char_destroy(clone); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_array_char_get(rpc_port_proxy_array_char_h h, char **value, int *size) -{ - rpc_port_proxy_array_char_h handle; - int ret; - - if (h == nullptr || value == nullptr || size == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_proxy_array_char_clone(h, &handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to clone handle. error(%d)", ret); - return ret; - } - - *value = handle->value; - *size = handle->size; - - handle->value = nullptr; - handle->size = 0; - rpc_port_proxy_array_char_destroy(handle); - - return RPC_PORT_ERROR_NONE; -} - -typedef enum { - RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB = 1, - RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB = 2, -} rpc_port_proxy_vc_delegate_e; - -static void __rpc_port_proxy_vc_notify_cb_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_proxy_vc_notify_cb_h h = data; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_int32(parcel, h->id); - - rpc_port_parcel_write_int32(parcel, h->seq_id); - - rpc_port_parcel_write_bool(parcel, h->once); - - _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); -} - -static void __rpc_port_proxy_vc_notify_cb_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_proxy_vc_notify_cb_h h = data; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - rpc_port_parcel_read_int32(parcel, &h->id); - - rpc_port_parcel_read_int32(parcel, &h->seq_id); - - rpc_port_parcel_read_bool(parcel, &h->once); - - _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); - set_last_result(RPC_PORT_ERROR_NONE); -} - -int rpc_port_proxy_vc_notify_cb_create(rpc_port_proxy_vc_notify_cb_h *h) -{ - rpc_port_proxy_vc_notify_cb_t *handle; - static int seq_num; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - handle = calloc(1, sizeof(rpc_port_proxy_vc_notify_cb_t)); - if (handle == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - handle->parcelable.to = __rpc_port_proxy_vc_notify_cb_to; - handle->parcelable.from = __rpc_port_proxy_vc_notify_cb_from; - handle->id = RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB; - handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; - _I("id(%d), seq_id(%d)", handle->id, handle->seq_id); - - *h = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_destroy(rpc_port_proxy_vc_notify_cb_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); - - free(h); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_clone(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_h *clone) -{ - rpc_port_proxy_vc_notify_cb_h handle; - rpc_port_parcel_h parcel; - int ret; - - if (h == nullptr || clone == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_proxy_vc_notify_cb_create(&handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret); - return ret; - } - - ret = rpc_port_parcel_create(&parcel); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret); - rpc_port_proxy_vc_notify_cb_destroy(handle); - return ret; - } - - rpc_port_parcel_write(parcel, &h->parcelable, h); - rpc_port_parcel_read(parcel, &handle->parcelable, handle); - ret = get_last_result(); - rpc_port_parcel_destroy(parcel); - - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to read data. error(%d)", ret); - rpc_port_proxy_vc_notify_cb_destroy(handle); - return ret; - } - - handle->callback = h->callback; - handle->user_data = h->user_data; - - *clone = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_set_callback(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_cb callback, void *user_data) -{ - if (h == nullptr || callback == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - h->callback = callback; - h->user_data = user_data; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_set_once(rpc_port_proxy_vc_notify_cb_h h, bool once) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - h->once = once; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_get_id(rpc_port_proxy_vc_notify_cb_h h, int *id) -{ - if (h == nullptr || id == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *id = h->id; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_get_seq_id(rpc_port_proxy_vc_notify_cb_h h, int *seq_id) -{ - if (h == nullptr || seq_id == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *seq_id = h->seq_id; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_is_once(rpc_port_proxy_vc_notify_cb_h h, bool *once) -{ - if (h == nullptr || once == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *once = h->once; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_get_tag(rpc_port_proxy_vc_notify_cb_h h, char **tag) -{ - char *new_tag; - char buf[128]; - - if (h == nullptr || tag == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id); - new_tag = strdup(buf); - if (new_tag == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - *tag = new_tag; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_notify_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_notify_cb_h h) -{ - GList *found; - - if (proxy == nullptr || h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - found = g_list_find(proxy->delegates, h); - if (found == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - proxy->delegates = g_list_remove_link(proxy->delegates, found); - rpc_port_proxy_vc_notify_cb_destroy(h); - g_list_free(found); - - return RPC_PORT_ERROR_NONE; -} - -static void __rpc_port_proxy_vc_notify_cb_delegate_handler(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id) -{ - rpc_port_proxy_vc_notify_cb_h handle; - GList *iter; - bool once; - int pid = -1; - bundle *msg = nullptr; - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_bundle(parcel, &msg); - if (msg == nullptr) { - _E("Failed to read data"); - goto out; - } - - iter = *delegates; - while (iter) { - handle = iter->data; - iter = g_list_next(iter); - if (handle->id == id && handle->seq_id == seq_id) { - once = handle->once; - _W("Invoke id(%d), seq_id(%d)", id, seq_id); - if (handle->callback) - handle->callback(handle->user_data, pid, msg); - else - _W("The callback function is nullptr"); - - if (once) { - *delegates = g_list_remove(*delegates, handle); - rpc_port_proxy_vc_notify_cb_destroy(handle); - } - - break; - } - } - -out: - - if (msg) - bundle_free(msg); -} - -static void __rpc_port_proxy_vc_feedback_cb_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_proxy_vc_feedback_cb_h h = data; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_int32(parcel, h->id); - - rpc_port_parcel_write_int32(parcel, h->seq_id); - - rpc_port_parcel_write_bool(parcel, h->once); - - _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); -} - -static void __rpc_port_proxy_vc_feedback_cb_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_proxy_vc_feedback_cb_h h = data; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - rpc_port_parcel_read_int32(parcel, &h->id); - - rpc_port_parcel_read_int32(parcel, &h->seq_id); - - rpc_port_parcel_read_bool(parcel, &h->once); - - _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); - set_last_result(RPC_PORT_ERROR_NONE); -} - -int rpc_port_proxy_vc_feedback_cb_create(rpc_port_proxy_vc_feedback_cb_h *h) -{ - rpc_port_proxy_vc_feedback_cb_t *handle; - static int seq_num; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - handle = calloc(1, sizeof(rpc_port_proxy_vc_feedback_cb_t)); - if (handle == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - handle->parcelable.to = __rpc_port_proxy_vc_feedback_cb_to; - handle->parcelable.from = __rpc_port_proxy_vc_feedback_cb_from; - handle->id = RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB; - handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; - _I("id(%d), seq_id(%d)", handle->id, handle->seq_id); - - *h = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_destroy(rpc_port_proxy_vc_feedback_cb_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); - - free(h); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_clone(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_h *clone) -{ - rpc_port_proxy_vc_feedback_cb_h handle; - rpc_port_parcel_h parcel; - int ret; - - if (h == nullptr || clone == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_proxy_vc_feedback_cb_create(&handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret); - return ret; - } - - ret = rpc_port_parcel_create(&parcel); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret); - rpc_port_proxy_vc_feedback_cb_destroy(handle); - return ret; - } - - rpc_port_parcel_write(parcel, &h->parcelable, h); - rpc_port_parcel_read(parcel, &handle->parcelable, handle); - ret = get_last_result(); - rpc_port_parcel_destroy(parcel); - - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to read data. error(%d)", ret); - rpc_port_proxy_vc_feedback_cb_destroy(handle); - return ret; - } - - handle->callback = h->callback; - handle->user_data = h->user_data; - - *clone = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_set_callback(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_cb callback, void *user_data) -{ - if (h == nullptr || callback == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - h->callback = callback; - h->user_data = user_data; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_set_once(rpc_port_proxy_vc_feedback_cb_h h, bool once) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - h->once = once; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_get_id(rpc_port_proxy_vc_feedback_cb_h h, int *id) -{ - if (h == nullptr || id == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *id = h->id; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_get_seq_id(rpc_port_proxy_vc_feedback_cb_h h, int *seq_id) -{ - if (h == nullptr || seq_id == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *seq_id = h->seq_id; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_is_once(rpc_port_proxy_vc_feedback_cb_h h, bool *once) -{ - if (h == nullptr || once == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *once = h->once; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_get_tag(rpc_port_proxy_vc_feedback_cb_h h, char **tag) -{ - char *new_tag; - char buf[128]; - - if (h == nullptr || tag == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id); - new_tag = strdup(buf); - if (new_tag == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - *tag = new_tag; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_feedback_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_feedback_cb_h h) -{ - GList *found; - - if (proxy == nullptr || h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - found = g_list_find(proxy->delegates, h); - if (found == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - proxy->delegates = g_list_remove_link(proxy->delegates, found); - rpc_port_proxy_vc_feedback_cb_destroy(h); - g_list_free(found); - - return RPC_PORT_ERROR_NONE; -} - -static void __rpc_port_proxy_vc_feedback_cb_delegate_handler(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id) -{ - rpc_port_proxy_vc_feedback_cb_h handle; - GList *iter; - bool once; - int utt_id = -1; - int event = -1; - rpc_port_proxy_array_char_h pcm_data = nullptr; - int len = -1; - - rpc_port_parcel_read_int32(parcel, &utt_id); - - rpc_port_parcel_read_int32(parcel, &event); - - rpc_port_proxy_array_char_create(&pcm_data); - if (pcm_data == nullptr) { - _E("Failed to create handle"); - goto out; - } - - rpc_port_parcel_read(parcel, &pcm_data->parcelable, pcm_data); - if (get_last_result() != RPC_PORT_ERROR_NONE) { - _E("Failed to read data"); - goto out; - } - - rpc_port_parcel_read_int32(parcel, &len); - - iter = *delegates; - while (iter) { - handle = iter->data; - iter = g_list_next(iter); - if (handle->id == id && handle->seq_id == seq_id) { - once = handle->once; - _W("Invoke id(%d), seq_id(%d)", id, seq_id); - if (handle->callback) - handle->callback(handle->user_data, utt_id, event, pcm_data, len); - else - _W("The callback function is nullptr"); - - if (once) { - *delegates = g_list_remove(*delegates, handle); - rpc_port_proxy_vc_feedback_cb_destroy(handle); - } - - break; - } - } - -out: - - if (pcm_data) - rpc_port_proxy_array_char_destroy(pcm_data); -} - -static rpc_port_proxy_delegate_cb __rpc_port_proxy_vc_delegate_table[] = { - [RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB] = __rpc_port_proxy_vc_notify_cb_delegate_handler, - [RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB] = __rpc_port_proxy_vc_feedback_cb_delegate_handler, -}; - -typedef enum { - RPC_PORT_PROXY_VC_METHOD_RESULT_, - RPC_PORT_PROXY_VC_METHOD_CALLBACK_, - RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB, - RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB_SYNC, - RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB, - RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC, - RPC_PORT_PROXY_VC_METHOD_INITIALIZE, - RPC_PORT_PROXY_VC_METHOD_FINALIZE, - RPC_PORT_PROXY_VC_METHOD_SET_COMMAND, - RPC_PORT_PROXY_VC_METHOD_UNSET_COMMAND, - RPC_PORT_PROXY_VC_METHOD_SET_FOREGROUND, - RPC_PORT_PROXY_VC_METHOD_SET_SERVER_DIALOG, - RPC_PORT_PROXY_VC_METHOD_REQUEST_DIALOG, - RPC_PORT_PROXY_VC_METHOD_IS_SYSTEM_COMMAND_VALID, - RPC_PORT_PROXY_VC_METHOD_AUTH_ENABLE, - RPC_PORT_PROXY_VC_METHOD_AUTH_DISABLE, - RPC_PORT_PROXY_VC_METHOD_AUTH_START, - RPC_PORT_PROXY_VC_METHOD_AUTH_STOP, - RPC_PORT_PROXY_VC_METHOD_AUTH_CANCEL, - RPC_PORT_PROXY_VC_METHOD_REQUEST_TTS, - RPC_PORT_PROXY_VC_METHOD_CANCEL_TTS, - RPC_PORT_PROXY_VC_METHOD_GET_TTS_AUDIO_FORMAT, -} rpc_port_proxy_vc_method_e; - -static void __rpc_port_proxy_vc_process_received_event(GList **delegates, rpc_port_parcel_h parcel) -{ - int id = 0; - int seq_id = 0; - bool once = false; - - rpc_port_parcel_read_int32(parcel, &id); - rpc_port_parcel_read_int32(parcel, &seq_id); - rpc_port_parcel_read_bool(parcel, &once); - _W("id(%d), seq_id(%d)", id, seq_id); - - if (id > 0 && id < ARRAY_SIZE(__rpc_port_proxy_vc_delegate_table)) { - if (__rpc_port_proxy_vc_delegate_table[id]) - __rpc_port_proxy_vc_delegate_table[id](delegates, parcel, id, seq_id); - } else { - _W("Unknown ID(%d)", id); - } -} - -static void __rpc_port_proxy_vc_consume_command(rpc_port_h port, rpc_port_parcel_h *p) -{ - rpc_port_parcel_h parcel; - int cmd = -1; - int ret; - - do { - ret = rpc_port_parcel_create_from_port(&parcel, port); - if (ret != RPC_PORT_ERROR_NONE) - break; - - rpc_port_parcel_read_int32(parcel, &cmd); - if (cmd == RPC_PORT_PROXY_VC_METHOD_RESULT_) { - *p = parcel; - return; - } - - rpc_port_parcel_destroy(parcel); - } while (true); - - *p = nullptr; -} - -static void __rpc_port_proxy_vc_connected(const char *endpoint, const char *port_name, rpc_port_h port, void *data) -{ - rpc_port_proxy_vc_h h = data; - - _I("endpoint(%s), port_name(%s)", endpoint, port_name); - h->port = port; - rpc_port_proxy_get_port(h->proxy, RPC_PORT_PORT_CALLBACK, &h->callback_port); - h->callback.connected(h, h->user_data); -} - -static void __rpc_port_proxy_vc_disconnected(const char *endpoint, const char *port_name, void *data) -{ - rpc_port_proxy_vc_h h = data; - - _W("endpoint(%s), port_name(%s)", endpoint, port_name); - h->port = nullptr; - h->callback.disconnected(h, h->user_data); -} - -static void __rpc_port_proxy_vc_rejected(const char *endpoint, const char *port_name, void *data) -{ - rpc_port_proxy_vc_h h = data; - - _W("endpoint(%s), port_name(%s)", endpoint, port_name); - h->port = nullptr; - h->callback.rejected(h, h->user_data); -} - -static void __rpc_port_proxy_vc_received(const char *endpoint, const char *port_name, void *data) -{ - rpc_port_proxy_vc_h h = data; - rpc_port_parcel_h parcel; - int cmd = -1; - int ret; - - _W("endpoint(%s), port_name(%s)", endpoint, port_name); - ret = rpc_port_parcel_create_from_port(&parcel, h->callback_port); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle from port. error(%d)", ret); - return; - } - - rpc_port_parcel_read_int32(parcel, &cmd); - if (cmd != RPC_PORT_PROXY_VC_METHOD_CALLBACK_) { - _E("Invalid protocol"); - rpc_port_parcel_destroy(parcel); - return; - } - - __rpc_port_proxy_vc_process_received_event(&h->delegates, parcel); - rpc_port_parcel_destroy(parcel); -} - -int rpc_port_proxy_vc_create(const char *stub_appid, rpc_port_proxy_vc_callback_s *callback, void *user_data, rpc_port_proxy_vc_h *h) -{ - rpc_port_proxy_vc_t *handle; - int ret; - - if (stub_appid == nullptr || callback == nullptr || h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (callback->connected == nullptr || callback->disconnected == nullptr || callback->rejected == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - handle = calloc(1, sizeof(rpc_port_proxy_vc_t)); - if (handle == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - g_rec_mutex_init(&handle->mutex); - - handle->stub_appid = strdup(stub_appid); - if (handle->stub_appid == nullptr) { - _E("Failed to duplicate stub appid"); - rpc_port_proxy_vc_destroy(handle); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - ret = rpc_port_proxy_create(&handle->proxy); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create proxy handle. error(%d)", ret); - rpc_port_proxy_vc_destroy(handle); - return ret; - } - - handle->callback = *callback; - handle->user_data = user_data; - - ret = rpc_port_proxy_add_connected_event_cb(handle->proxy, __rpc_port_proxy_vc_connected, handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to add connected event cb. error(%d)", ret); - rpc_port_proxy_vc_destroy(handle); - return ret; - } - - ret = rpc_port_proxy_add_disconnected_event_cb(handle->proxy, __rpc_port_proxy_vc_disconnected, handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to add disconnected event cb. error(%d)", ret); - rpc_port_proxy_vc_destroy(handle); - return ret; - } - - ret = rpc_port_proxy_add_rejected_event_cb(handle->proxy, __rpc_port_proxy_vc_rejected, handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to add rejected event cb. error(%d)", ret); - rpc_port_proxy_vc_destroy(handle); - return ret; - } - - ret = rpc_port_proxy_add_received_event_cb(handle->proxy, __rpc_port_proxy_vc_received, handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to add received event cb. error(%d)", ret); - rpc_port_proxy_vc_destroy(handle); - return ret; - } - - *h = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_destroy(rpc_port_proxy_vc_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - g_rec_mutex_lock(&h->mutex); - g_rec_mutex_unlock(&h->mutex); - g_rec_mutex_clear(&h->mutex); - - if (h->delegates) - g_list_free_full(h->delegates, free); - - if (h->proxy) - rpc_port_proxy_destroy(h->proxy); - - if (h->stub_appid) - free(h->stub_appid); - - free(h); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_connect(rpc_port_proxy_vc_h h) -{ - int ret; - - if (h == nullptr || h->proxy == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_proxy_connect(h->proxy, h->stub_appid, "vc"); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to connect to stub. error(%d)", ret); - return ret; - } - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_connect_sync(rpc_port_proxy_vc_h h) -{ - int ret; - - if (h == nullptr || h->proxy == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_proxy_connect_sync(h->proxy, h->stub_appid, "vc"); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to connect to stub. error(%d)", ret); - return ret; - } - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_proxy_vc_disconnect(rpc_port_proxy_vc_h h) -{ - int ret; - - if (h == nullptr || h->proxy == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_disconnect(h->port); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to disconnect from stub. error(%d)", ret); - return ret; - } - - return RPC_PORT_ERROR_NONE; -} - -void rpc_port_proxy_vc_invoke_register_notify_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int res_; - - if (h == nullptr || callback == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - g_rec_mutex_unlock(&h->mutex); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - return; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write(parcel_, &callback->parcelable, callback); - - h->delegates = g_list_append(h->delegates, callback); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) - _E("Failed to send parcel. error(%d)", res_); - - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); -} - -int rpc_port_proxy_vc_invoke_register_notify_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr || callback == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB_SYNC); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write(parcel_, &callback->parcelable, callback); - - h->delegates = g_list_append(h->delegates, callback); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -void rpc_port_proxy_vc_invoke_register_feedback_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int res_; - - if (h == nullptr || callback == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - g_rec_mutex_unlock(&h->mutex); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - return; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write(parcel_, &callback->parcelable, callback); - - h->delegates = g_list_append(h->delegates, callback); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) - _E("Failed to send parcel. error(%d)", res_); - - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); -} - -int rpc_port_proxy_vc_invoke_register_feedback_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr || callback == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write(parcel_, &callback->parcelable, callback); - - h->delegates = g_list_append(h->delegates, callback); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_initialize(rpc_port_proxy_vc_h h, int pid, int *mgr_pid, int *service_state, int *daemon_pid) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - int new_mgr_pid; - int new_service_state; - int new_daemon_pid; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_INITIALIZE); - - rpc_port_parcel_write_int32(parcel_, pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &new_mgr_pid); - - *mgr_pid = new_mgr_pid; - - rpc_port_parcel_read_int32(parcel_, &new_service_state); - - *service_state = new_service_state; - - rpc_port_parcel_read_int32(parcel_, &new_daemon_pid); - - *daemon_pid = new_daemon_pid; - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_finalize(rpc_port_proxy_vc_h h, int pid) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_FINALIZE); - - rpc_port_parcel_write_int32(parcel_, pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_set_command(rpc_port_proxy_vc_h h, int pid, int cmd_type) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_COMMAND); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_int32(parcel_, cmd_type); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_unset_command(rpc_port_proxy_vc_h h, int pid, int cmd_type) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_UNSET_COMMAND); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_int32(parcel_, cmd_type); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_set_foreground(rpc_port_proxy_vc_h h, int pid, bool value) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_FOREGROUND); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_bool(parcel_, value); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_set_server_dialog(rpc_port_proxy_vc_h h, int pid, const char *app_id, const char *credential) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr || app_id == nullptr || credential == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_SERVER_DIALOG); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_string(parcel_, app_id); - - rpc_port_parcel_write_string(parcel_, credential); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_request_dialog(rpc_port_proxy_vc_h h, int pid, const char *disp_text, const char *utt_text, bool continuous) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr || disp_text == nullptr || utt_text == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REQUEST_DIALOG); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_string(parcel_, disp_text); - - rpc_port_parcel_write_string(parcel_, utt_text); - - rpc_port_parcel_write_bool(parcel_, continuous); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_is_system_command_valid(rpc_port_proxy_vc_h h, int pid, bool *is_sys_cmd_valid) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - bool new_is_sys_cmd_valid; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_IS_SYSTEM_COMMAND_VALID); - - rpc_port_parcel_write_int32(parcel_, pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_bool(parcel_, &new_is_sys_cmd_valid); - - *is_sys_cmd_valid = new_is_sys_cmd_valid; - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_auth_enable(rpc_port_proxy_vc_h h, int pid, int mgr_pid) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_ENABLE); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_int32(parcel_, mgr_pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_auth_disable(rpc_port_proxy_vc_h h, int pid, int mgr_pid) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_DISABLE); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_int32(parcel_, mgr_pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_auth_start(rpc_port_proxy_vc_h h, int pid, int mgr_pid) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_START); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_int32(parcel_, mgr_pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_auth_stop(rpc_port_proxy_vc_h h, int pid, int mgr_pid) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_STOP); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_int32(parcel_, mgr_pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_auth_cancel(rpc_port_proxy_vc_h h, int pid, int mgr_pid) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_CANCEL); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_int32(parcel_, mgr_pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_request_tts(rpc_port_proxy_vc_h h, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - int new_utt_id; - - if (h == nullptr || text == nullptr || lang == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REQUEST_TTS); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_string(parcel_, text); - - rpc_port_parcel_write_string(parcel_, lang); - - rpc_port_parcel_write_bool(parcel_, to_vcm); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &new_utt_id); - - *utt_id = new_utt_id; - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_cancel_tts(rpc_port_proxy_vc_h h, int pid, int utt_id) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_CANCEL_TTS); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_int32(parcel_, utt_id); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} - -int rpc_port_proxy_vc_invoke_get_tts_audio_format(rpc_port_proxy_vc_h h, int pid, int *rate, int *channel, int *audio_type) -{ - rpc_port_parcel_h parcel_; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - int recv_seq_num_ = -1; - char *tag_ = nullptr; - bool done_ = false; - int res_; - int ret_ = -1; - int new_rate; - int new_channel; - int new_audio_type; - - if (h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return ret_; - } - - g_rec_mutex_lock(&h->mutex); - if (h->port == nullptr) { - _E("Not connected"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - res_ = rpc_port_parcel_create(&parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_GET_TTS_AUDIO_FORMAT); - - rpc_port_parcel_write_int32(parcel_, pid); - - res_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - if (res_ != RPC_PORT_ERROR_NONE) { - _E("Failed to send parcel. error(%d)", res_); - set_last_result(res_); - g_rec_mutex_unlock(&h->mutex); - return ret_; - } - - do { - parcel_ = nullptr; - __rpc_port_proxy_vc_consume_command(h->port, &parcel_); - if (parcel_ == nullptr) { - _E("Invalid protocol"); - res_ = RPC_PORT_ERROR_IO_ERROR; - break; - } - - header_ = nullptr; - rpc_port_parcel_get_header(parcel_, &header_); - tag_ = nullptr; - rpc_port_parcel_header_get_tag(header_, &tag_); - if (tag_ && tag_[0] != '\0') { - _W("[Version] %s", tag_); - rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_); - if (recv_seq_num_ != seq_num_) { - _E("Invalid protocol. %d", recv_seq_num_); - free(tag_); - rpc_port_parcel_destroy(parcel_); - continue; - } - } - done_ = true; - free(tag_); - - rpc_port_parcel_read_int32(parcel_, &new_rate); - - *rate = new_rate; - - rpc_port_parcel_read_int32(parcel_, &new_channel); - - *channel = new_channel; - - rpc_port_parcel_read_int32(parcel_, &new_audio_type); - - *audio_type = new_audio_type; - - rpc_port_parcel_read_int32(parcel_, &ret_); - - rpc_port_parcel_destroy(parcel_); - } while (!done_); - g_rec_mutex_unlock(&h->mutex); - set_last_result(res_); - - return ret_; -} diff --git a/client/vc_proxy.h b/client/vc_proxy.h deleted file mode 100755 index 5b2fa31..0000000 --- a/client/vc_proxy.h +++ /dev/null @@ -1,819 +0,0 @@ -/* - * Generated by tidlc 1.8.1. - */ - -#pragma once - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The rpc_port_proxy_array_char handle. - */ -typedef struct rpc_port_proxy_array_char_s *rpc_port_proxy_array_char_h; - -/** - * @brief The rpc_port_proxy_vc handle. - */ -typedef struct rpc_port_proxy_vc_s *rpc_port_proxy_vc_h; - -/** - * @brief The rpc_port_proxy_vc_notify_cb handle. - */ -typedef struct rpc_port_proxy_vc_notify_cb_s *rpc_port_proxy_vc_notify_cb_h; - -/** - * @brief The rpc_port_proxy_vc_feedback_cb handle. - */ -typedef struct rpc_port_proxy_vc_feedback_cb_s *rpc_port_proxy_vc_feedback_cb_h; - -/** - * @briefs Creates a rpc_port_proxy_array_char handle. - * - * @remarks The @a h should be released using the rpc_port_proxy_array_char_destroy() - * if it's no longer needed. - * @param[out] h The rpc_port_proxy_array_char handle that is newly created - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_proxy_array_char_destroy() - */ -int rpc_port_proxy_array_char_create(rpc_port_proxy_array_char_h *h); - -/** - * @brief Destroys the rpc_port_proxy_array_char handle. - * - * @param[in] h The rpc_port_proxy_array_char handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_proxy_array_char_create() - */ -int rpc_port_proxy_array_char_destroy(rpc_port_proxy_array_char_h h); - -/** - * @brief Creates and returns a copy of the given rpc_port_proxy_array_char handle. - * - * @remarks A new created rpc_port_proxy_array_char should be released using - * the rpc_port_proxy_array_char_destroy() if it's no longer needed. - * @param[in] h The rpc_port_proxy_array_char handle - * @param[out] clone If successful, a new created rpc_port_proxy_array_char handle will be returned - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_proxy_array_char_destroy() - */ -int rpc_port_proxy_array_char_clone(rpc_port_proxy_array_char_h h, rpc_port_proxy_array_char_h *clone); - -/** - * @brief Sets the value to the rpc_port_proxy_array_char handle. - * - * @remarks The value is internally copied and stored. - * You should release it if it's allocaed when it's no longer needed, - * @param[in] h The rpc_port_proxy_array_char handle - * @param[in] value The array value - * @param[in] size The size of the array - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_proxy_array_char_get() - */ -int rpc_port_proxy_array_char_set(rpc_port_proxy_array_char_h h, char *value, int size); - -/** - * @brief Gets the value from the rpc_port_proxy_array_char handle. - * - * @remarks A new created value should be released if it's no longer needed. - * @param[in] h The rpc_port_proxy_array_char handle - * @param[out] value The array value - * @param[out] size The size of the array - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_proxy_array_char_set() - */ -int rpc_port_proxy_array_char_get(rpc_port_proxy_array_char_h h, char **value, int *size); - -/** - * @brief Called when the event is received. - * - * @param[in] user_data The user data passed from the callback registration function - * @param[in] ... - * - * @see rpc_port_proxy_vc_notify_cb_create() - */ -typedef void (*rpc_port_proxy_vc_notify_cb_cb)(void *user_data, int pid, bundle *msg); - -/** - * @brief Creates a rpc_port_proxy_vc_notify_cb handle. - * - * @param[out] h The rpc_port_proxy_vc_notify_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memorya - * @see rpc_port_proxy_vc_notify_cb_destroy() - * @see rpc_port_proxy_vc_notify_cb_dispose() - * @see rpc_port_proxy_vc_notify_cb_set_callback() - * @see rpc_port_proxy_vc_notify_cb_set_once() - */ -int rpc_port_proxy_vc_notify_cb_create(rpc_port_proxy_vc_notify_cb_h *h); - -/** - * @brief Destroys the rpc_port_proxy_vc_notify_cb handle. - * - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_proxy_vc_notify_cb_create() - */ -int rpc_port_proxy_vc_notify_cb_destroy(rpc_port_proxy_vc_notify_cb_h h); - -/** - * @brief Creates and returns a copy of the given rpc_port_proxy_vc_notify_cb handle. - * - * @remarks A new created rpc_port_proxy_vc_notify_cb should be released using - * the rpc_port_proxy_vc_notify_cb_destroy() if it's no longer needed. - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @param[out] clone If successful, a new created rpc_port_proxy_vc_notify_cb handle will be returned - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_proxy_vc_notify_cb_destroy() - */ -int rpc_port_proxy_vc_notify_cb_clone(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_h *clone); - -/** - * @brief Sets the callback function to the rpc_port_proxy_vc_notify_cb handle. - * - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @param[in] callback The callback function - * @param[in] user_data The user data to be passed to the callback function - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_notify_cb_set_callback(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_cb callback, void *user_data); - -/** - * @brief Set the once flag to the rpc_port_proxy_vc_notify_cb handle. - * @details If the once flag is 'true', the delegate handle will be deleted after invocation. - * If the @a h handle is not used using the method, the handle should be released using - * the rpc_port_proxy_vc_notify_cb_destroy() when it's no longer needed. - * If you don't want the delegate callback function to be called after it's used using the method, - * you should release the handle using the rpc_port_proxy_vc_notify_cb_dispose(). - * - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @param[in] once The flag if it's true, the delegate will be deleted after invocation - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_notify_cb_set_once(rpc_port_proxy_vc_notify_cb_h h, bool once); - -/** - * @brief Gets the ID of the rpc_port_proxy_vc_notify_cb handle. - * - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @param[out] id The ID - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_notify_cb_get_id(rpc_port_proxy_vc_notify_cb_h h, int *id); - -/** - * @brief Gets the sequence ID of the rpc_port_proxy_vc_notify_cb handle. - * - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @param[out] seq_id The Sequence ID - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_notify_cb_get_seq_id(rpc_port_proxy_vc_notify_cb_h h, int *seq_id); - -/** - * @brief Checks whether the delegate is for one-time or not. - * - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @param[out] once The flag, it's true, the handle is for one-time - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_notify_cb_is_once(rpc_port_proxy_vc_notify_cb_h h, bool *once); - -/** - * @brief Gets the tag from the rpc_port_proxy_vc_notify_cb handle. - * - * @remarks The @a tag should be released using free(). - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @param[out] tag The tag - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int rpc_port_proxy_vc_notify_cb_get_tag(rpc_port_proxy_vc_notify_cb_h h, char **tag); - -/** - * @brief Disposes the rpc_port_proxy_vc_notify_cb handle from the rpc_port_proxy_vc handle. - * - * @param[in] proxy The rpc_port_proxy_vc handle - * @param[in] h The rpc_port_proxy_vc_notify_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_proxy_vc_notify_cb_create() - */ -int rpc_port_proxy_vc_notify_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_notify_cb_h h); - -/** - * @brief Called when the event is received. - * - * @param[in] user_data The user data passed from the callback registration function - * @param[in] ... - * - * @see rpc_port_proxy_vc_feedback_cb_create() - */ -typedef void (*rpc_port_proxy_vc_feedback_cb_cb)(void *user_data, int utt_id, int event, rpc_port_proxy_array_char_h pcm_data, int len); - -/** - * @brief Creates a rpc_port_proxy_vc_feedback_cb handle. - * - * @param[out] h The rpc_port_proxy_vc_feedback_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memorya - * @see rpc_port_proxy_vc_feedback_cb_destroy() - * @see rpc_port_proxy_vc_feedback_cb_dispose() - * @see rpc_port_proxy_vc_feedback_cb_set_callback() - * @see rpc_port_proxy_vc_feedback_cb_set_once() - */ -int rpc_port_proxy_vc_feedback_cb_create(rpc_port_proxy_vc_feedback_cb_h *h); - -/** - * @brief Destroys the rpc_port_proxy_vc_feedback_cb handle. - * - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_proxy_vc_feedback_cb_create() - */ -int rpc_port_proxy_vc_feedback_cb_destroy(rpc_port_proxy_vc_feedback_cb_h h); - -/** - * @brief Creates and returns a copy of the given rpc_port_proxy_vc_feedback_cb handle. - * - * @remarks A new created rpc_port_proxy_vc_feedback_cb should be released using - * the rpc_port_proxy_vc_feedback_cb_destroy() if it's no longer needed. - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @param[out] clone If successful, a new created rpc_port_proxy_vc_feedback_cb handle will be returned - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_proxy_vc_feedback_cb_destroy() - */ -int rpc_port_proxy_vc_feedback_cb_clone(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_h *clone); - -/** - * @brief Sets the callback function to the rpc_port_proxy_vc_feedback_cb handle. - * - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @param[in] callback The callback function - * @param[in] user_data The user data to be passed to the callback function - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_feedback_cb_set_callback(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_cb callback, void *user_data); - -/** - * @brief Set the once flag to the rpc_port_proxy_vc_feedback_cb handle. - * @details If the once flag is 'true', the delegate handle will be deleted after invocation. - * If the @a h handle is not used using the method, the handle should be released using - * the rpc_port_proxy_vc_feedback_cb_destroy() when it's no longer needed. - * If you don't want the delegate callback function to be called after it's used using the method, - * you should release the handle using the rpc_port_proxy_vc_feedback_cb_dispose(). - * - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @param[in] once The flag if it's true, the delegate will be deleted after invocation - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_feedback_cb_set_once(rpc_port_proxy_vc_feedback_cb_h h, bool once); - -/** - * @brief Gets the ID of the rpc_port_proxy_vc_feedback_cb handle. - * - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @param[out] id The ID - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_feedback_cb_get_id(rpc_port_proxy_vc_feedback_cb_h h, int *id); - -/** - * @brief Gets the sequence ID of the rpc_port_proxy_vc_feedback_cb handle. - * - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @param[out] seq_id The Sequence ID - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_feedback_cb_get_seq_id(rpc_port_proxy_vc_feedback_cb_h h, int *seq_id); - -/** - * @brief Checks whether the delegate is for one-time or not. - * - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @param[out] once The flag, it's true, the handle is for one-time - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_feedback_cb_is_once(rpc_port_proxy_vc_feedback_cb_h h, bool *once); - -/** - * @brief Gets the tag from the rpc_port_proxy_vc_feedback_cb handle. - * - * @remarks The @a tag should be released using free(). - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @param[out] tag The tag - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int rpc_port_proxy_vc_feedback_cb_get_tag(rpc_port_proxy_vc_feedback_cb_h h, char **tag); - -/** - * @brief Disposes the rpc_port_proxy_vc_feedback_cb handle from the rpc_port_proxy_vc handle. - * - * @param[in] proxy The rpc_port_proxy_vc handle - * @param[in] h The rpc_port_proxy_vc_feedback_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_proxy_vc_feedback_cb_create() - */ -int rpc_port_proxy_vc_feedback_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_feedback_cb_h h); - -/** - * @brief Called when the proxy is connected. - * @details The callback function is called when the proxy is connected to the stub. - * - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] user_data The user data passed from the registeration function - * @see #rpc_port_proxy_vc_callback_s - */ -typedef void (*rpc_port_proxy_vc_connected_cb)(rpc_port_proxy_vc_h h, void *user_data); - -/** - * @brief Called when the proxy is disconnected. - * @details The callback function is called when the proxy is disconnected from the stub. - * - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] user_data The user data passed from the registeration function - * @see #rpc_port_proxy_vc_callback_s - */ -typedef void (*rpc_port_proxy_vc_disconnected_cb)(rpc_port_proxy_vc_h h, void *user_data); - -/** - * @brief Called when the proxy is rejected. - * @details The callback function is called when the proxy is rejected to connect to the stub. - * - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] user_data The user data passed from the registeration function - * @see #rpc_port_proxy_vc_callback_s - */ -typedef void (*rpc_port_proxy_vc_rejected_cb)(rpc_port_proxy_vc_h h, void *user_data); - -/** - * @brief The structure type containing the set of callback functions for handling proxy events. - * @details It is one of the input parameters of the rpc_port_proxy_vc_create() function. - * - * @see rpc_port_proxy_vc_connected_cb - * @see rpc_port_proxy_vc_disconnected_cb - * @see rpc_port_proxy_vc_rejected_cb - */ -typedef struct { - rpc_port_proxy_vc_connected_cb connected; /**< This callback function is called when the proxy is connected to the stub. */ - rpc_port_proxy_vc_disconnected_cb disconnected; /**< This callback function is called when the proxy is disconnected from the stub. */ - rpc_port_proxy_vc_rejected_cb rejected; /**< This callback function is called when the proxy is rejected to connect to the stub. */ -} rpc_port_proxy_vc_callback_s; - -/** - * @brief Creates a rpc_port_proxy_vc handle. - * @remarks The @a h handle should be released using - * the rpc_port_proxy_vc_destroy() if it's no longer needed. - * - * @param[in] stub_appid The application ID of the stub - * @param[in] callback The set of callback functions to handle proxy events - * @param[in] user_data The user data to be passed to the callback function - * @param[out] h The rpc_port_proxy_vc handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_proxy_vc_destroy() - * @see #rpc_port_proxy_vc_callback_s - */ -int rpc_port_proxy_vc_create(const char *stub_appid, rpc_port_proxy_vc_callback_s *callback, void *user_data, rpc_port_proxy_vc_h *h); - -/** - * @brief Destroys the rpc_port_proxy_vc handle. - * - * @param[in] h The rpc_port_proxy_vc handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_proxy_vc_create() - */ -int rpc_port_proxy_vc_destroy(rpc_port_proxy_vc_h h); - -/** - * @brief Connects to the stub. - * - * @param[in] h The rpc_port_proxy_vc handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_IO_ERROR I/O error - * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied - */ -int rpc_port_proxy_vc_connect(rpc_port_proxy_vc_h h); - -/** - * @brief Connects to the stub synchronously. - * - * @param[in] h The rpc_port_proxy_vc handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_IO_ERROR I/O error - * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied - */ -int rpc_port_proxy_vc_connect_sync(rpc_port_proxy_vc_h h); - -/** - * @brief Disconnects from the stub. - * - * @param[in] h The rpc_port_proxy_vc handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_proxy_vc_disconnect(rpc_port_proxy_vc_h h); - -/** - * @brief Calls the register_notify_cb() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -void rpc_port_proxy_vc_invoke_register_notify_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback); - -/** - * @brief Calls the register_notify_cb_sync() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_register_notify_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback); - -/** - * @brief Calls the register_feedback_cb() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -void rpc_port_proxy_vc_invoke_register_feedback_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback); - -/** - * @brief Calls the register_feedback_cb_sync() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_register_feedback_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback); - -/** - * @brief Calls the initialize() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_initialize(rpc_port_proxy_vc_h h, int pid, int *mgr_pid, int *service_state, int *daemon_pid); - -/** - * @brief Calls the finalize() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_finalize(rpc_port_proxy_vc_h h, int pid); - -/** - * @brief Calls the set_command() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_set_command(rpc_port_proxy_vc_h h, int pid, int cmd_type); - -/** - * @brief Calls the unset_command() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_unset_command(rpc_port_proxy_vc_h h, int pid, int cmd_type); - -/** - * @brief Calls the set_foreground() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_set_foreground(rpc_port_proxy_vc_h h, int pid, bool value); - -/** - * @brief Calls the set_server_dialog() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_set_server_dialog(rpc_port_proxy_vc_h h, int pid, const char *app_id, const char *credential); - -/** - * @brief Calls the request_dialog() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_request_dialog(rpc_port_proxy_vc_h h, int pid, const char *disp_text, const char *utt_text, bool continuous); - -/** - * @brief Calls the is_system_command_valid() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_is_system_command_valid(rpc_port_proxy_vc_h h, int pid, bool *is_sys_cmd_valid); - -/** - * @brief Calls the auth_enable() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_auth_enable(rpc_port_proxy_vc_h h, int pid, int mgr_pid); - -/** - * @brief Calls the auth_disable() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_auth_disable(rpc_port_proxy_vc_h h, int pid, int mgr_pid); - -/** - * @brief Calls the auth_start() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_auth_start(rpc_port_proxy_vc_h h, int pid, int mgr_pid); - -/** - * @brief Calls the auth_stop() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_auth_stop(rpc_port_proxy_vc_h h, int pid, int mgr_pid); - -/** - * @brief Calls the auth_cancel() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_auth_cancel(rpc_port_proxy_vc_h h, int pid, int mgr_pid); - -/** - * @brief Calls the request_tts() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_request_tts(rpc_port_proxy_vc_h h, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id); - -/** - * @brief Calls the cancel_tts() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_cancel_tts(rpc_port_proxy_vc_h h, int pid, int utt_id); - -/** - * @brief Calls the get_tts_audio_format() method. - * @details The return value and args are decided by the interface declaration. - * You can get the result using get_last_result(). - * Before returning the function, the function sets the result using set_last_result(). - * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section. - * @param[in] h The rpc_port_proxy_vc handle - * @param[in] ... - * @exception #RPC_PORT_ERROR_NONE Successful - * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @exception #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_proxy_vc_invoke_get_tts_audio_format(rpc_port_proxy_vc_h h, int pid, int *rate, int *channel, int *audio_type); - -#ifdef __cplusplus -} -#endif diff --git a/client/vc_tidl.c b/client/vc_tidl.c index e937f0f..77ddc1d 100755 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -28,9 +28,9 @@ typedef struct { bool register_notify_callback_invoked; bool register_feedback_callback_invoked; - rpc_port_proxy_vc_h rpc_h; - rpc_port_proxy_vc_notify_cb_h notify_cb_h; - rpc_port_proxy_vc_feedback_cb_h feedback_cb_h; + rpc_port_proxy_vc_proxy_vc_h rpc_h; + rpc_port_proxy_vc_proxy_vc_notify_cb_h notify_cb_h; + rpc_port_proxy_vc_proxy_vc_feedback_cb_h feedback_cb_h; char* engine_appid; } vc_tidl_info_s; @@ -83,7 +83,7 @@ static char* __get_engine_appid(void) return appid; } -static void __on_connected(rpc_port_proxy_vc_h h, void* user_data) +static void __on_connected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) { unsigned int pid = (uintptr_t)user_data; @@ -97,7 +97,7 @@ static void __on_connected(rpc_port_proxy_vc_h h, void* user_data) SLOG(LOG_INFO, TAG_VCC, "[INFO] Connected to server"); } -static void __on_disconnected(rpc_port_proxy_vc_h h, void* user_data) +static void __on_disconnected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) { unsigned int pid = (uintptr_t)user_data; @@ -112,7 +112,7 @@ static void __on_disconnected(rpc_port_proxy_vc_h h, void* user_data) SLOG(LOG_INFO, TAG_VCC, "[INFO] Disconnected to server"); } -static void __on_rejected(rpc_port_proxy_vc_h h, void* user_data) +static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) { unsigned int pid = (uintptr_t)user_data; @@ -126,17 +126,17 @@ static void __on_rejected(rpc_port_proxy_vc_h h, void* user_data) } -static rpc_port_proxy_vc_h __create_rpc_port(int pid, const char* engine_app_id) +static rpc_port_proxy_vc_proxy_vc_h __create_rpc_port(int pid, const char* engine_app_id) { - rpc_port_proxy_vc_callback_s rpc_callback = { + rpc_port_proxy_vc_proxy_vc_callback_s rpc_callback = { .connected = __on_connected, .disconnected = __on_disconnected, .rejected = __on_rejected }; - rpc_port_proxy_vc_h handle = NULL; + rpc_port_proxy_vc_proxy_vc_h handle = NULL; uintptr_t ptr_pid = pid; - if (0 != rpc_port_proxy_vc_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) { + if (0 != rpc_port_proxy_vc_proxy_vc_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) { return NULL; } @@ -146,11 +146,11 @@ static rpc_port_proxy_vc_h __create_rpc_port(int pid, const char* engine_app_id) static void __request_tidl_connect(vc_tidl_info_s* info) { if (info->connection_requesting) { - SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_connect()."); + SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_proxy_vc_connect()."); return ; } - int ret = rpc_port_proxy_vc_connect(info->rpc_h); + int ret = rpc_port_proxy_vc_proxy_vc_connect(info->rpc_h); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret); return ; @@ -226,7 +226,7 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) } } -void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_array_char_h pcm_data, int len) +void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_vc_proxy_array_char_h pcm_data, int len) { // corresponding to listener_event_callback (only for tts_streaming) SLOG(LOG_DEBUG, TAG_VCC, "__feedback_cb is invoked utt_id(%d) event(%d)", utt_id, event); @@ -243,16 +243,16 @@ void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_array_ static int __create_notify_callback_handle(vc_tidl_info_s* info) { if (NULL != info->notify_cb_h) { - rpc_port_proxy_vc_notify_cb_dispose(info->rpc_h, info->notify_cb_h); + rpc_port_proxy_vc_proxy_vc_notify_cb_dispose(info->rpc_h, info->notify_cb_h); info->notify_cb_h = NULL; } - if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_notify_cb_create(&info->notify_cb_h)) { + if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_proxy_vc_notify_cb_create(&info->notify_cb_h)) { return VC_ERROR_OUT_OF_MEMORY; } - rpc_port_proxy_vc_notify_cb_set_callback(info->notify_cb_h, __notify_cb, NULL); - rpc_port_proxy_vc_notify_cb_set_once(info->notify_cb_h, false); + rpc_port_proxy_vc_proxy_vc_notify_cb_set_callback(info->notify_cb_h, __notify_cb, NULL); + rpc_port_proxy_vc_proxy_vc_notify_cb_set_once(info->notify_cb_h, false); return VC_ERROR_NONE; } @@ -260,16 +260,16 @@ static int __create_notify_callback_handle(vc_tidl_info_s* info) static int __create_feedback_callback_handle(vc_tidl_info_s* info) { if (NULL != info) { - rpc_port_proxy_vc_feedback_cb_dispose(info->rpc_h, info->feedback_cb_h); + rpc_port_proxy_vc_proxy_vc_feedback_cb_dispose(info->rpc_h, info->feedback_cb_h); info->feedback_cb_h = NULL; } - if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_feedback_cb_create(&info->feedback_cb_h)) { + if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_proxy_vc_feedback_cb_create(&info->feedback_cb_h)) { return VC_ERROR_OUT_OF_MEMORY; } - rpc_port_proxy_vc_feedback_cb_set_callback(info->feedback_cb_h, __feedback_cb, NULL); - rpc_port_proxy_vc_feedback_cb_set_once(info->feedback_cb_h, false); + rpc_port_proxy_vc_proxy_vc_feedback_cb_set_callback(info->feedback_cb_h, __feedback_cb, NULL); + rpc_port_proxy_vc_proxy_vc_feedback_cb_set_once(info->feedback_cb_h, false); return VC_ERROR_NONE; } @@ -287,7 +287,7 @@ static int __invoke_register_notify_callback(int pid, vc_tidl_info_s* info) return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_invoke_register_notify_cb(info->rpc_h, pid, info->notify_cb_h); + rpc_port_proxy_vc_proxy_vc_invoke_register_notify_cb(info->rpc_h, pid, info->notify_cb_h); info->register_notify_callback_invoked = true; return VC_ERROR_NONE; } @@ -305,7 +305,7 @@ static int __invoke_register_feedback_callback(int pid, vc_tidl_info_s* info) return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_invoke_register_feedback_cb(info->rpc_h, pid, info->feedback_cb_h); + rpc_port_proxy_vc_proxy_vc_invoke_register_feedback_cb(info->rpc_h, pid, info->feedback_cb_h); info->register_feedback_callback_invoked = true; return VC_ERROR_NONE; } @@ -346,7 +346,7 @@ int vc_tidl_close_connection() vc_tidl_info_s* info = __get_tidl_info_s(pid); RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info"); - if (0 != rpc_port_proxy_vc_destroy(info->rpc_h)) { + if (0 != rpc_port_proxy_vc_proxy_vc_destroy(info->rpc_h)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect"); return VC_ERROR_OPERATION_FAILED; } @@ -402,7 +402,7 @@ int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* d 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"); - int ret = rpc_port_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid); + 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) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -421,7 +421,7 @@ int vc_tidl_request_finalize(int 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"); - int ret = rpc_port_proxy_vc_invoke_finalize(info->rpc_h, pid); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_finalize(info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -440,7 +440,7 @@ int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type) 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"); - int ret = rpc_port_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -459,7 +459,7 @@ int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type) 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"); - int ret = rpc_port_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -479,7 +479,7 @@ int vc_tidl_request_set_foreground(int pid, bool value) 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"); - int ret = rpc_port_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -498,7 +498,7 @@ int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* c 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"); - int ret = rpc_port_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential); + 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) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -518,7 +518,7 @@ int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* u 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"); - int ret = rpc_port_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous); + 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) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -537,7 +537,7 @@ int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) 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"); - int ret = rpc_port_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid); + 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) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -557,7 +557,7 @@ int vc_tidl_request_auth_enable(int pid, int mgr_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"); - int ret = rpc_port_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -576,7 +576,7 @@ int vc_tidl_request_auth_disable(int pid, int mgr_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"); - int ret = rpc_port_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -595,7 +595,7 @@ int vc_tidl_request_auth_start(int pid, int mgr_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"); - int ret = rpc_port_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -614,7 +614,7 @@ int vc_tidl_request_auth_stop(int pid, int mgr_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"); - int ret = rpc_port_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -633,7 +633,7 @@ int vc_tidl_request_auth_cancel(int pid, int mgr_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"); - int ret = rpc_port_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -658,7 +658,7 @@ int vc_tidl_request_request_tts(int pid, const char* text, const char* language, return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_invoke_request_tts(info->rpc_h, pid, text, language, to_vcm, utt_id); + 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) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -677,7 +677,7 @@ int vc_tidl_request_cancel_tts(int pid, int utt_id) 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"); - int ret = rpc_port_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id); + int ret = rpc_port_proxy_vc_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message"); return __covert_unhandled_error(ret); @@ -696,7 +696,7 @@ int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* 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"); - int ret = rpc_port_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type); + 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) { SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message"); return __covert_unhandled_error(ret); diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index 1210668..dc2b84b 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -27,8 +27,8 @@ typedef struct { bool connected; bool connection_requesting; bool register_callback_invoked; - rpc_port_proxy_vc_widget_h rpc_h; - rpc_port_proxy_vc_widget_notify_cb_h notify_cb_h; + rpc_port_proxy_vc_widget_proxy_vc_widget_h rpc_h; + rpc_port_proxy_vc_widget_proxy_vc_widget_notify_cb_h notify_cb_h; } vc_widget_tidl_info_s; typedef struct { @@ -43,7 +43,7 @@ static vcd_widget_tidl_info_s* g_stub_tidl_info = NULL; static pthread_mutex_t g_w_tidl_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t g_w_init_mutex = PTHREAD_MUTEX_INITIALIZER; -static rpc_port_stub_vcd_widget_callback_s g_widget_callback; +static rpc_port_stub_vc_widget_stub_vcd_widget_callback_s g_widget_callback; extern int __vc_widget_cb_error(int reason, int daemon_pid, char* msg); @@ -146,7 +146,7 @@ static void __notify_cb(void *user_data, bundle *msg) } } -static void __on_connected(rpc_port_proxy_vc_widget_h h, void *user_data) +static void __on_connected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data) { g_proxy_tidl_info->connected = true; g_proxy_tidl_info->connection_requesting = false; @@ -155,7 +155,7 @@ static void __on_connected(rpc_port_proxy_vc_widget_h h, void *user_data) SLOG(LOG_INFO, TAG_VCW, "Connected to server"); } -static void __on_disconnected(rpc_port_proxy_vc_widget_h h, void *user_data) +static void __on_disconnected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data) { g_proxy_tidl_info->connected = false; g_proxy_tidl_info->connection_requesting = false; @@ -167,7 +167,7 @@ static void __on_disconnected(rpc_port_proxy_vc_widget_h h, void *user_data) __vc_widget_cb_error(VC_ERROR_SERVICE_RESET, -1, "Server Disconnected, re-launch"); } -static void __on_rejected(rpc_port_proxy_vc_widget_h h, void *user_data) +static void __on_rejected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data) { g_proxy_tidl_info->connection_requesting = false; g_proxy_tidl_info->register_callback_invoked = false; @@ -176,17 +176,17 @@ static void __on_rejected(rpc_port_proxy_vc_widget_h h, void *user_data) } -static rpc_port_proxy_vc_widget_h __create_rpc_port(const char* engine_app_id) +static rpc_port_proxy_vc_widget_proxy_vc_widget_h __create_rpc_port(const char* engine_app_id) { SLOG(LOG_DEBUG, TAG_VCW, "[TIDL] __create_rpc_port"); - rpc_port_proxy_vc_widget_callback_s rpc_callback = { + rpc_port_proxy_vc_widget_proxy_vc_widget_callback_s rpc_callback = { .connected = __on_connected, .disconnected = __on_disconnected, .rejected = __on_rejected }; - rpc_port_proxy_vc_widget_h handle = NULL; - if (0 != rpc_port_proxy_vc_widget_create(engine_app_id, &rpc_callback, NULL, &handle)) { + rpc_port_proxy_vc_widget_proxy_vc_widget_h handle = NULL; + if (0 != rpc_port_proxy_vc_widget_proxy_vc_widget_create(engine_app_id, &rpc_callback, NULL, &handle)) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to create proxy"); return NULL; } @@ -194,7 +194,7 @@ static rpc_port_proxy_vc_widget_h __create_rpc_port(const char* engine_app_id) return handle; } -static void __vcd_widget_create_cb(rpc_port_stub_vcd_widget_context_h context, void *user_data) +static void __vcd_widget_create_cb(rpc_port_stub_vc_widget_stub_vcd_widget_context_h context, void *user_data) { g_stub_tidl_info->connected = true; g_stub_tidl_info->register_callback_requesting = false; @@ -203,7 +203,7 @@ static void __vcd_widget_create_cb(rpc_port_stub_vcd_widget_context_h context, v char *sender = NULL; - rpc_port_stub_vcd_widget_context_get_sender(context, &sender); + rpc_port_stub_vc_widget_stub_vcd_widget_context_get_sender(context, &sender); if (!sender) { SLOG(LOG_ERROR, TAG_VCW, "@@@ Sender is NULL"); return; @@ -213,15 +213,15 @@ static void __vcd_widget_create_cb(rpc_port_stub_vcd_widget_context_h context, v free(sender); } -static void __vcd_widget_terminate_cb(rpc_port_stub_vcd_widget_context_h context, void *user_data) +static void __vcd_widget_terminate_cb(rpc_port_stub_vc_widget_stub_vcd_widget_context_h context, void *user_data) { g_stub_tidl_info->connected = false; g_stub_tidl_info->register_callback_requesting = false; - rpc_port_stub_vcd_widget_context_set_tag(context, NULL); + rpc_port_stub_vc_widget_stub_vcd_widget_context_set_tag(context, NULL); char *sender = NULL; - rpc_port_stub_vcd_widget_context_get_sender(context, &sender); + rpc_port_stub_vc_widget_stub_vcd_widget_context_get_sender(context, &sender); if (!sender) return; @@ -229,7 +229,7 @@ static void __vcd_widget_terminate_cb(rpc_port_stub_vcd_widget_context_h context free(sender); } -static int __vcd_widget_asr_result_cb(rpc_port_stub_vcd_widget_context_h context, int pid, int event, const char *asr_result, bool *is_consumed, void *user_data) +static int __vcd_widget_asr_result_cb(rpc_port_stub_vc_widget_stub_vcd_widget_context_h context, int pid, int event, const char *asr_result, bool *is_consumed, void *user_data) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Get widget asr result"); @@ -253,7 +253,7 @@ static void __register_stub_callback() g_widget_callback.send_asr_result = __vcd_widget_asr_result_cb; int ret = -1; - ret = rpc_port_stub_vcd_widget_register(&g_widget_callback, NULL); + ret = rpc_port_stub_vc_widget_stub_vcd_widget_register(&g_widget_callback, NULL); if (0 == ret) { SLOG(LOG_DEBUG, TAG_VCW, "register callback"); g_stub_tidl_info->register_callback_requesting = true; @@ -331,7 +331,7 @@ int vc_widget_tidl_close_connection() return VC_ERROR_OPERATION_FAILED; } - if (0 != rpc_port_proxy_vc_widget_destroy(g_proxy_tidl_info->rpc_h)) { + if (0 != rpc_port_proxy_vc_widget_proxy_vc_widget_destroy(g_proxy_tidl_info->rpc_h)) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Fail to destroy tidl handle"); pthread_mutex_unlock(&g_w_tidl_mutex); return VC_ERROR_OPERATION_FAILED; @@ -357,7 +357,7 @@ static void __request_tidl_connect() return; } - int ret = rpc_port_proxy_vc_widget_connect(g_proxy_tidl_info->rpc_h); + int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_connect(g_proxy_tidl_info->rpc_h); SLOG(LOG_INFO, TAG_VCW, "[INFO] Request connection to stub. ret(%d)", ret); if (0 == ret) { @@ -368,17 +368,17 @@ static void __request_tidl_connect() static int __create_callback_handles() { if (NULL != g_proxy_tidl_info->notify_cb_h) { - rpc_port_proxy_vc_widget_notify_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->notify_cb_h); + rpc_port_proxy_vc_widget_proxy_vc_widget_notify_cb_dispose(g_proxy_tidl_info->rpc_h, g_proxy_tidl_info->notify_cb_h); g_proxy_tidl_info->notify_cb_h = NULL; } - if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_widget_notify_cb_create(&g_proxy_tidl_info->notify_cb_h)) { + if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_widget_proxy_vc_widget_notify_cb_create(&g_proxy_tidl_info->notify_cb_h)) { return VC_ERROR_OUT_OF_MEMORY; } - rpc_port_proxy_vc_widget_notify_cb_set_callback(g_proxy_tidl_info->notify_cb_h, __notify_cb, NULL); + rpc_port_proxy_vc_widget_proxy_vc_widget_notify_cb_set_callback(g_proxy_tidl_info->notify_cb_h, __notify_cb, NULL); - rpc_port_proxy_vc_widget_notify_cb_set_once(g_proxy_tidl_info->notify_cb_h, false); + rpc_port_proxy_vc_widget_proxy_vc_widget_notify_cb_set_once(g_proxy_tidl_info->notify_cb_h, false); return VC_ERROR_NONE; } @@ -396,7 +396,7 @@ static int __invoke_register_callback() return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_widget_invoke_register_cb(g_proxy_tidl_info->rpc_h, getpid(), g_proxy_tidl_info->notify_cb_h); + rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_register_cb(g_proxy_tidl_info->rpc_h, getpid(), g_proxy_tidl_info->notify_cb_h); g_proxy_tidl_info->register_callback_invoked = true; return VC_ERROR_NONE; } @@ -452,7 +452,7 @@ 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_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, &temp_service_state, &temp_daemon_pid); + 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) { 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); @@ -485,7 +485,7 @@ int vc_widget_tidl_request_finalize(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_widget_invoke_finalize(g_proxy_tidl_info->rpc_h, 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) { 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); @@ -510,7 +510,7 @@ int vc_widget_tidl_request_start_recording(int pid, bool command) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_widget_invoke_start_recording(g_proxy_tidl_info->rpc_h, pid, (int)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) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start recording : Fail to invoke message, error(%d)", ret); return ret; @@ -534,7 +534,7 @@ int vc_widget_tidl_set_foreground(int pid, bool value) } // TODO: Error tolerance cannot be applied because this function is asynchronous. - rpc_port_proxy_vc_widget_invoke_set_foreground(g_proxy_tidl_info->rpc_h, pid, (int)value); + rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_set_foreground(g_proxy_tidl_info->rpc_h, pid, (int)value); return VC_ERROR_NONE; } @@ -553,7 +553,7 @@ int vc_widget_tidl_request_enable_asr_result(int pid, bool enable) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_widget_invoke_enable_asr_result(g_proxy_tidl_info->rpc_h, pid, (int)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) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget enable asr result : Fail to invoke message, error(%d)", ret); return ret; @@ -576,7 +576,7 @@ int vc_widget_tidl_request_start(int pid, int silence) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_widget_invoke_start(g_proxy_tidl_info->rpc_h, pid, 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) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start : Fail to invoke message, error(%d)", ret); return ret; @@ -599,7 +599,7 @@ int vc_widget_tidl_request_stop(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_widget_invoke_stop(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget stop : Fail to invoke message, error(%d)", ret); return ret; @@ -622,7 +622,7 @@ int vc_widget_tidl_request_cancel(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vc_widget_invoke_cancel(g_proxy_tidl_info->rpc_h, 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) { SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget cancel : Fail to invoke message, error(%d)", ret); return ret; diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index bbe1861..30bfc62 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -115,18 +115,18 @@ GTest for Voice Control %setup -q -n %{name}-%{version} cp %{SOURCE1001} %{SOURCE1002} . -tidlc -p -l C -i tidl/vc.tidl -o vc_proxy -tidlc -s -l C -i tidl/vc.tidl -o vcd_stub - -tidlc -p -l C -i tidl/vc_mgr.tidl -o vc_mgr_proxy -tidlc -s -l C -i tidl/vc_mgr.tidl -o vcd_mgr_stub -tidlc -s -l C -i tidl/vcd_mgr.tidl -o vc_mgr_stub -tidlc -p -l C -i tidl/vcd_mgr.tidl -o vcd_mgr_proxy - -tidlc -p -l C -i tidl/vc_widget.tidl -o vc_widget_proxy -tidlc -s -l C -i tidl/vc_widget.tidl -o vcd_widget_stub -tidlc -s -l C -i tidl/vcd_widget.tidl -o vc_widget_stub -tidlc -p -l C -i tidl/vcd_widget.tidl -o vcd_widget_proxy +tidlc -p -l C -i tidl/vc.tidl -o vc_proxy -n +tidlc -s -l C -i tidl/vc.tidl -o vcd_stub -n + +tidlc -p -l C -i tidl/vc_mgr.tidl -o vc_mgr_proxy -n +tidlc -s -l C -i tidl/vc_mgr.tidl -o vcd_mgr_stub -n +tidlc -s -l C -i tidl/vcd_mgr.tidl -o vc_mgr_stub -n +tidlc -p -l C -i tidl/vcd_mgr.tidl -o vcd_mgr_proxy -n + +tidlc -p -l C -i tidl/vc_widget.tidl -o vc_widget_proxy -n +tidlc -s -l C -i tidl/vc_widget.tidl -o vcd_widget_stub -n +tidlc -s -l C -i tidl/vcd_widget.tidl -o vc_widget_stub -n +tidlc -p -l C -i tidl/vcd_widget.tidl -o vcd_widget_proxy -n mv vc_* client mv vcd_* server diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 8e33a1f..4a05082 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -296,7 +296,7 @@ int vcd_client_manager_create_tidl_info(int pid) return VCD_ERROR_NONE; } -int vcd_client_manager_set_tidl_notify_cb(rpc_port_stub_vc_mgr_notify_cb_h callback, void* user_data) +int vcd_client_manager_set_tidl_notify_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h callback, void* user_data) { if (NULL == g_mgr_tidl_info) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no manager tidl info"); @@ -304,7 +304,7 @@ int vcd_client_manager_set_tidl_notify_cb(rpc_port_stub_vc_mgr_notify_cb_h callb } int ret = -1; - ret = rpc_port_stub_vc_mgr_notify_cb_clone(callback, &(g_mgr_tidl_info->notify_cb)); + ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_clone(callback, &(g_mgr_tidl_info->notify_cb)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone notify callback. ret(%d)", ret); } else { @@ -323,7 +323,7 @@ int vcd_client_manager_unset_tidl_notify_cb() } int ret = -1; - ret = rpc_port_stub_vc_mgr_notify_cb_destroy(g_mgr_tidl_info->notify_cb); + ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_destroy(g_mgr_tidl_info->notify_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy notify callback. ret(%d)", ret); } else { @@ -335,7 +335,7 @@ int vcd_client_manager_unset_tidl_notify_cb() return VCD_ERROR_NONE; } -int vcd_client_manager_set_tidl_send_buffer_cb(rpc_port_stub_vc_mgr_send_buffer_cb_h callback, void* user_data) +int vcd_client_manager_set_tidl_send_buffer_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h callback, void* user_data) { if (NULL == g_mgr_tidl_info) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no manager tidl info"); @@ -343,7 +343,7 @@ int vcd_client_manager_set_tidl_send_buffer_cb(rpc_port_stub_vc_mgr_send_buffer_ } int ret = -1; - ret = rpc_port_stub_vc_mgr_send_buffer_cb_clone(callback, &(g_mgr_tidl_info->send_buffer_cb)); + ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_clone(callback, &(g_mgr_tidl_info->send_buffer_cb)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone feedback callback. ret(%d)", ret); } else { @@ -362,7 +362,7 @@ int vcd_client_manager_unset_tidl_send_buffer_cb() } int ret = -1; - ret = rpc_port_stub_vc_mgr_send_buffer_cb_destroy(g_mgr_tidl_info->send_buffer_cb); + ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_destroy(g_mgr_tidl_info->send_buffer_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy feedback callback. ret(%d)", ret); } else { @@ -381,7 +381,7 @@ int vcd_client_manager_delete_tidl_info() return VCD_ERROR_INVALID_PARAMETER; } - if (0 != rpc_port_proxy_vcd_mgr_destroy(g_mgr_tidl_info->rpc_h)) { + if (0 != rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_destroy(g_mgr_tidl_info->rpc_h)) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to destroy tidl handle"); } @@ -1323,7 +1323,7 @@ int vcd_client_add_ipc_info(int pid) return VCD_ERROR_NONE; } -int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vc_notify_cb_h callback, void* user_data) +int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void* user_data) { /*Check pid*/ client_ipc_info_s* info = NULL; @@ -1335,7 +1335,7 @@ int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vc_notify_cb_h callback, } int ret = -1; - ret = rpc_port_stub_vc_notify_cb_clone(callback, &(info->notify_cb)); + ret = rpc_port_stub_vcd_stub_vc_notify_cb_clone(callback, &(info->notify_cb)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone notify callback. ret(%d)", ret); } else { @@ -1358,7 +1358,7 @@ int vcd_client_unset_ipc_notify_cb(int pid) } int ret = -1; - ret = rpc_port_stub_vc_notify_cb_destroy(info->notify_cb); + ret = rpc_port_stub_vcd_stub_vc_notify_cb_destroy(info->notify_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy notify callback. ret(%d)", ret); } else { @@ -1370,7 +1370,7 @@ int vcd_client_unset_ipc_notify_cb(int pid) return VCD_ERROR_NONE; } -int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vc_feedback_cb_h callback, void* user_data) +int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void* user_data) { /*Check pid*/ client_ipc_info_s* info = NULL; @@ -1382,7 +1382,7 @@ int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vc_feedback_cb_h callb } int ret = -1; - ret = rpc_port_stub_vc_feedback_cb_clone(callback, &(info->feedback_cb)); + ret = rpc_port_stub_vcd_stub_vc_feedback_cb_clone(callback, &(info->feedback_cb)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone feedback callback. ret(%d)", ret); } else { @@ -1405,7 +1405,7 @@ int vcd_client_unset_ipc_feedback_cb(int pid) } int ret = -1; - ret = rpc_port_stub_vc_feedback_cb_destroy(info->feedback_cb); + ret = rpc_port_stub_vcd_stub_vc_feedback_cb_destroy(info->feedback_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy feedback callback. ret(%d)", ret); } else { @@ -2023,7 +2023,7 @@ int vcd_client_widget_add_tidl_info(int pid) return VCD_ERROR_NONE; } -int vcd_client_widget_set_tidl_notify_cb(int pid, rpc_port_stub_vc_widget_notify_cb_h callback, void* user_data) +int vcd_client_widget_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h callback, void* user_data) { /*Check pid*/ widget_tidl_info_s* info = NULL; @@ -2035,7 +2035,7 @@ int vcd_client_widget_set_tidl_notify_cb(int pid, rpc_port_stub_vc_widget_notify } int ret = -1; - ret = rpc_port_stub_vc_widget_notify_cb_clone(callback, &(info->notify_cb)); + ret = rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_clone(callback, &(info->notify_cb)); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone notify callback. ret(%d)", ret); } else { @@ -2058,7 +2058,7 @@ int vcd_client_widget_unset_tidl_notify_cb(int pid) } int ret = -1; - ret = rpc_port_stub_vc_widget_notify_cb_destroy(info->notify_cb); + ret = rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_destroy(info->notify_cb); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy notify callback. ret(%d)", ret); } else { diff --git a/server/vcd_client_data.h b/server/vcd_client_data.h index 789f329..2071bd1 100644 --- a/server/vcd_client_data.h +++ b/server/vcd_client_data.h @@ -72,35 +72,35 @@ typedef struct { typedef struct { int pid; - rpc_port_stub_vc_notify_cb_h notify_cb; + rpc_port_stub_vcd_stub_vc_notify_cb_h notify_cb; void* notify_cb_user_data; - rpc_port_stub_vc_feedback_cb_h feedback_cb; + rpc_port_stub_vcd_stub_vc_feedback_cb_h feedback_cb; void* feedback_cb_user_data; } client_ipc_info_s; typedef struct { int pid; - rpc_port_stub_vc_mgr_notify_cb_h notify_cb; + rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h notify_cb; void* notify_cb_user_data; - rpc_port_stub_vc_mgr_send_buffer_cb_h send_buffer_cb; + rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h send_buffer_cb; void* send_buffer_cb_user_data; bool connected; bool connection_requesting; - rpc_port_proxy_vcd_mgr_h rpc_h; + rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h rpc_h; } manager_tidl_info_s; typedef struct { int pid; - rpc_port_stub_vc_widget_notify_cb_h notify_cb; + rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h notify_cb; void* notify_cb_user_data; bool connected; bool connection_requesting; - rpc_port_proxy_vcd_widget_h rpc_h; + rpc_port_proxy_vcd_widget_proxy_vcd_widget_h rpc_h; } widget_tidl_info_s; typedef enum { @@ -171,11 +171,11 @@ bool vcd_client_manager_is_system_command_valid(int pid); int vcd_client_manager_create_tidl_info(int pid); -int vcd_client_manager_set_tidl_notify_cb(rpc_port_stub_vc_mgr_notify_cb_h callback, void* user_data); +int vcd_client_manager_set_tidl_notify_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h callback, void* user_data); int vcd_client_manager_unset_tidl_notify_cb(); -int vcd_client_manager_set_tidl_send_buffer_cb(rpc_port_stub_vc_mgr_send_buffer_cb_h callback, void* user_data); +int vcd_client_manager_set_tidl_send_buffer_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h callback, void* user_data); int vcd_client_manager_unset_tidl_send_buffer_cb(); @@ -192,11 +192,11 @@ int vcd_client_delete(int pid); int vcd_client_add_ipc_info(int pid); -int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vc_notify_cb_h callback, void* user_data); +int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void* user_data); int vcd_client_unset_ipc_notify_cb(int pid); -int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vc_feedback_cb_h callback, void* user_data); +int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void* user_data); int vcd_client_unset_ipc_feedback_cb(int pid); @@ -255,7 +255,7 @@ int vcd_client_widget_get_waiting_for_recording(int pid, bool* waiting); int vcd_client_widget_add_tidl_info(int pid); -int vcd_client_widget_set_tidl_notify_cb(int pid, rpc_port_stub_vc_widget_notify_cb_h callback, void* user_data); +int vcd_client_widget_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h callback, void* user_data); int vcd_client_widget_unset_tidl_notify_cb(int pid); diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 0e67e46..d16ce39 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -27,35 +27,35 @@ static DBusConnection* g_conn_listener = NULL; static Ecore_Fd_Handler* g_dbus_fd_handler = NULL; -static int g_waiting_time = 3000; +// static int g_waiting_time = 3000; // static int g_volume_count = 0; -static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e type) -{ - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - if (VCD_CLIENT_TYPE_NORMAL == type) { - snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - snprintf(object_path, 64, "%s", VC_CLIENT_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s", VC_CLIENT_SERVICE_INTERFACE); - } else if (VCD_CLIENT_TYPE_WIDGET == type) { - snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); - snprintf(object_path, 64, "%s", VC_WIDGET_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s", VC_WIDGET_SERVICE_INTERFACE); - } else if (VCD_CLIENT_TYPE_MANAGER == type) { - snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s", VC_MANAGER_SERVICE_INTERFACE); - } else { - return NULL; - } +// static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e type) +// { +// char service_name[64] = {0,}; +// char object_path[64] = {0,}; +// char target_if_name[128] = {0,}; - return dbus_message_new_method_call(service_name, object_path, target_if_name, method); -} +// if (VCD_CLIENT_TYPE_NORMAL == type) { +// snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); +// snprintf(object_path, 64, "%s", VC_CLIENT_SERVICE_OBJECT_PATH); +// snprintf(target_if_name, 128, "%s", VC_CLIENT_SERVICE_INTERFACE); +// } else if (VCD_CLIENT_TYPE_WIDGET == type) { +// snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); +// snprintf(object_path, 64, "%s", VC_WIDGET_SERVICE_OBJECT_PATH); +// snprintf(target_if_name, 128, "%s", VC_WIDGET_SERVICE_INTERFACE); +// } else if (VCD_CLIENT_TYPE_MANAGER == type) { +// snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); +// snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); +// snprintf(target_if_name, 128, "%s", VC_MANAGER_SERVICE_INTERFACE); +// } else { +// return NULL; +// } + +// return dbus_message_new_method_call(service_name, object_path, target_if_name, method); +// } int vcd_dbus_reconnect() { diff --git a/server/vcd_stub.c b/server/vcd_stub.c deleted file mode 100755 index e84a2e3..0000000 --- a/server/vcd_stub.c +++ /dev/null @@ -1,2422 +0,0 @@ -/* - * Generated by tidlc 1.8.1. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "vcd_stub.h" - -#undef LOG_TAG -#define LOG_TAG "RPC_PORT_STUB" - -#undef _E -#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#undef _W -#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#undef _I -#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#undef _D -#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#ifndef TIDL_VERSION -#define TIDL_VERSION "1.8.1" -#endif - -#ifndef nullptr -#define nullptr NULL -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -#ifndef STRING_GET -#define STRING_GET(x) ((x) ? x : "") -#endif - -typedef int (*rpc_port_stub_method_handler)(rpc_port_h port, rpc_port_parcel_h parcel, void *data); - -typedef enum { - RPC_PORT_STUB_VC_METHOD_RESULT_, - RPC_PORT_STUB_VC_METHOD_CALLBACK_, - RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB, - RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB_SYNC, - RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB, - RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC, - RPC_PORT_STUB_VC_METHOD_INITIALIZE, - RPC_PORT_STUB_VC_METHOD_FINALIZE, - RPC_PORT_STUB_VC_METHOD_SET_COMMAND, - RPC_PORT_STUB_VC_METHOD_UNSET_COMMAND, - RPC_PORT_STUB_VC_METHOD_SET_FOREGROUND, - RPC_PORT_STUB_VC_METHOD_SET_SERVER_DIALOG, - RPC_PORT_STUB_VC_METHOD_REQUEST_DIALOG, - RPC_PORT_STUB_VC_METHOD_IS_SYSTEM_COMMAND_VALID, - RPC_PORT_STUB_VC_METHOD_AUTH_ENABLE, - RPC_PORT_STUB_VC_METHOD_AUTH_DISABLE, - RPC_PORT_STUB_VC_METHOD_AUTH_START, - RPC_PORT_STUB_VC_METHOD_AUTH_STOP, - RPC_PORT_STUB_VC_METHOD_AUTH_CANCEL, - RPC_PORT_STUB_VC_METHOD_REQUEST_TTS, - RPC_PORT_STUB_VC_METHOD_CANCEL_TTS, - RPC_PORT_STUB_VC_METHOD_GET_TTS_AUDIO_FORMAT, -} rpc_port_stub_vc_method_e; - -typedef enum { - RPC_PORT_STUB_VC_DELEGATE_NOTIFY_CB = 1, - RPC_PORT_STUB_VC_DELEGATE_FEEDBACK_CB = 2, -} rpc_port_stub_vc_delegate_e; - -typedef struct rpc_port_stub_array_char_s { - rpc_port_parcelable_t parcelable; - char *value; - int size; -} rpc_port_stub_array_char_t; - -typedef struct rpc_port_stub_vc_notify_cb_s { - rpc_port_parcelable_t parcelable; - rpc_port_h port; - int id; - int seq_id; - bool once; - bool valid; -} rpc_port_stub_vc_notify_cb_t; - -typedef struct rpc_port_stub_vc_feedback_cb_s { - rpc_port_parcelable_t parcelable; - rpc_port_h port; - int id; - int seq_id; - bool once; - bool valid; -} rpc_port_stub_vc_feedback_cb_t; - -static bool __rpc_port_stub_vc_exist_callback_port(rpc_port_h callback_port); - -typedef struct rpc_port_stub_vc_context_s { - char *sender; - char *instance; - rpc_port_h port; - rpc_port_h callback_port; - void *tag; - rpc_port_stub_vc_callback_s callback; - void *user_data; -#ifdef TIDL_THREAD_ENABLE - GThread *thread; - GQueue *queue; - GMutex mutex; - GCond cond; - bool done; -#endif /* TIDL_THREAD_ENABLE */ -} rpc_port_stub_vc_context_t; - -typedef struct rpc_port_stub_vc_s { - rpc_port_stub_h stub; - rpc_port_stub_vc_callback_s callback; - void *user_data; - GList* contexts; - GList* callback_ports; - GRecMutex mutex; -} rpc_port_stub_vc_t; - -static rpc_port_stub_vc_t __vc; - -static void __rpc_port_stub_array_char_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_stub_array_char_h h = data; - int i; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_array_count(parcel, h->size); - - for (i = 0; i < h->size; ++i) - rpc_port_parcel_write_byte(parcel, h->value[i]); -} - -static void __rpc_port_stub_array_char_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_stub_array_char_h h = data; - char value; - int ret; - int i; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - ret = rpc_port_parcel_read_array_count(parcel, &h->size); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to read array count. error(%d)", ret); - set_last_result(ret); - return; - } - - h->value = calloc(h->size, sizeof(char)); - if (h->value == nullptr) { - _E("Out of memory"); - set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY); - return; - } - - for (i = 0; i < h->size; ++i) { - rpc_port_parcel_read_byte(parcel, &value); - h->value[i] = value; - } - - set_last_result(RPC_PORT_ERROR_NONE); -} - -int rpc_port_stub_array_char_create(rpc_port_stub_array_char_h *h) -{ - rpc_port_stub_array_char_t *handle; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - handle = calloc(1, sizeof(rpc_port_stub_array_char_t)); - if (handle == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - handle->parcelable.to = __rpc_port_stub_array_char_to; - handle->parcelable.from = __rpc_port_stub_array_char_from; - - *h = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_array_char_destroy(rpc_port_stub_array_char_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (h->value) - free(h->value); - - free(h); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_array_char_clone(rpc_port_stub_array_char_h h, rpc_port_stub_array_char_h *clone) -{ - rpc_port_stub_array_char_h handle; - rpc_port_parcel_h parcel; - int ret; - - if (h == nullptr || clone == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_stub_array_char_create(&handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret); - return ret; - } - - ret = rpc_port_parcel_create(&parcel); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret); - rpc_port_stub_array_char_destroy(handle); - return ret; - } - - rpc_port_parcel_write(parcel, &h->parcelable, h); - rpc_port_parcel_read(parcel, &handle->parcelable, handle); - ret = get_last_result(); - rpc_port_parcel_destroy(parcel); - - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to read data. error(%d)", ret); - rpc_port_stub_array_char_destroy(handle); - return ret; - } - - *clone = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_array_char_set(rpc_port_stub_array_char_h h, char *value, int size) -{ - rpc_port_stub_array_char_h handle; - rpc_port_stub_array_char_h clone; - int ret; - - if (h == nullptr || value == nullptr || size <= 0) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_stub_array_char_create(&handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret); - return ret; - } - - handle->value = (char *)value; - handle->size = size; - - ret = rpc_port_stub_array_char_clone(handle, &clone); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to clone handle. error(%d)", ret); - handle->value = nullptr; - handle->size = 0; - rpc_port_stub_array_char_destroy(handle); - return ret; - } - - handle->value = h->value; - handle->size = h->size; - rpc_port_stub_array_char_destroy(handle); - - h->value = clone->value; - h->size = clone->size; - - clone->value = nullptr; - clone->size = 0; - rpc_port_stub_array_char_destroy(clone); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_array_char_get(rpc_port_stub_array_char_h h, char **value, int *size) -{ - rpc_port_stub_array_char_h handle; - int ret; - - if (h == nullptr || value == nullptr || size == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_stub_array_char_clone(h, &handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to clone handle. error(%d)", ret); - return ret; - } - - *value = handle->value; - *size = handle->size; - - handle->value = nullptr; - handle->size = 0; - rpc_port_stub_array_char_destroy(handle); - - return RPC_PORT_ERROR_NONE; -} - -static void __rpc_port_stub_vc_notify_cb_to(rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_notify_cb_h h = user_data; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_int32(parcel, h->id); - - rpc_port_parcel_write_int32(parcel, h->seq_id); - - rpc_port_parcel_write_bool(parcel, h->once); - - _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); -} - -static void __rpc_port_stub_vc_notify_cb_from(rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_notify_cb_h h = user_data; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - rpc_port_parcel_read_int32(parcel, &h->id); - - rpc_port_parcel_read_int32(parcel, &h->seq_id); - - rpc_port_parcel_read_bool(parcel, &h->once); - - _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); - set_last_result(RPC_PORT_ERROR_NONE); -} - -int rpc_port_stub_vc_notify_cb_create(rpc_port_stub_vc_notify_cb_h *h) -{ - rpc_port_stub_vc_notify_cb_t *handle; - static int seq_num; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - handle = calloc(1, sizeof(rpc_port_stub_vc_notify_cb_t)); - if (handle == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - handle->parcelable.to = __rpc_port_stub_vc_notify_cb_to; - handle->parcelable.from = __rpc_port_stub_vc_notify_cb_from; - handle->id = RPC_PORT_STUB_VC_DELEGATE_NOTIFY_CB; - handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; - handle->once = false; - handle->valid = true; - _I("id(%d), seq_id(%d)", handle->id, handle->seq_id); - - *h = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_notify_cb_destroy(rpc_port_stub_vc_notify_cb_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); - - free(h); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_notify_cb_clone(rpc_port_stub_vc_notify_cb_h h, rpc_port_stub_vc_notify_cb_h *clone) -{ - rpc_port_stub_vc_notify_cb_h handle; - int ret; - - if (h == nullptr || clone == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_stub_vc_notify_cb_create(&handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret); - return ret; - } - - handle->port = h->port; - handle->seq_id = h->seq_id; - handle->once = h->once; - handle->valid = h->valid; - - *clone = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_notify_cb_get_id(rpc_port_stub_vc_notify_cb_h h, int *id) -{ - if (h == nullptr || id == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *id = h->id; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_notify_cb_get_seq_id(rpc_port_stub_vc_notify_cb_h h, int *seq_id) -{ - if (h == nullptr || seq_id == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *seq_id = h->seq_id; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_notify_cb_is_once(rpc_port_stub_vc_notify_cb_h h, bool *once) -{ - if (h == nullptr || once == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *once = h->once; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_notify_cb_get_tag(rpc_port_stub_vc_notify_cb_h h, char **tag) -{ - char *value; - char buf[128]; - - if (h == nullptr || tag == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id); - value = strdup(buf); - if (value == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - *tag = value; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_notify_cb_set_port(rpc_port_stub_vc_notify_cb_h h, rpc_port_h port) -{ - if (h == nullptr || port == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - h->port = port; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_notify_cb_invoke(rpc_port_stub_vc_notify_cb_h h, int pid, bundle *msg) -{ - rpc_port_parcel_h parcel_; - int ret_; - - if (h == nullptr || h->port == nullptr || msg == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (!__rpc_port_stub_vc_exist_callback_port(h->port)) { - _E("Not connected"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (h->once && !h->valid) { - _E("The delegate handle is already used"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - return ret_; - } - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_CALLBACK_); - - rpc_port_parcel_write(parcel_, &h->parcelable, h); - - rpc_port_parcel_write_int32(parcel_, pid); - - rpc_port_parcel_write_bundle(parcel_, msg); - - ret_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - h->valid = false; - - return ret_; -} - -static void __rpc_port_stub_vc_feedback_cb_to(rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_feedback_cb_h h = user_data; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_int32(parcel, h->id); - - rpc_port_parcel_write_int32(parcel, h->seq_id); - - rpc_port_parcel_write_bool(parcel, h->once); - - _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); -} - -static void __rpc_port_stub_vc_feedback_cb_from(rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_feedback_cb_h h = user_data; - - if (parcel == nullptr || h == nullptr) { - _E("Invalid parameter"); - set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER); - return; - } - - rpc_port_parcel_read_int32(parcel, &h->id); - - rpc_port_parcel_read_int32(parcel, &h->seq_id); - - rpc_port_parcel_read_bool(parcel, &h->once); - - _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); - set_last_result(RPC_PORT_ERROR_NONE); -} - -int rpc_port_stub_vc_feedback_cb_create(rpc_port_stub_vc_feedback_cb_h *h) -{ - rpc_port_stub_vc_feedback_cb_t *handle; - static int seq_num; - - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - handle = calloc(1, sizeof(rpc_port_stub_vc_feedback_cb_t)); - if (handle == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - handle->parcelable.to = __rpc_port_stub_vc_feedback_cb_to; - handle->parcelable.from = __rpc_port_stub_vc_feedback_cb_from; - handle->id = RPC_PORT_STUB_VC_DELEGATE_FEEDBACK_CB; - handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; - handle->once = false; - handle->valid = true; - _I("id(%d), seq_id(%d)", handle->id, handle->seq_id); - - *h = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_feedback_cb_destroy(rpc_port_stub_vc_feedback_cb_h h) -{ - if (h == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false"); - - free(h); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_feedback_cb_clone(rpc_port_stub_vc_feedback_cb_h h, rpc_port_stub_vc_feedback_cb_h *clone) -{ - rpc_port_stub_vc_feedback_cb_h handle; - int ret; - - if (h == nullptr || clone == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret = rpc_port_stub_vc_feedback_cb_create(&handle); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret); - return ret; - } - - handle->port = h->port; - handle->seq_id = h->seq_id; - handle->once = h->once; - handle->valid = h->valid; - - *clone = handle; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_feedback_cb_get_id(rpc_port_stub_vc_feedback_cb_h h, int *id) -{ - if (h == nullptr || id == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *id = h->id; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_feedback_cb_get_seq_id(rpc_port_stub_vc_feedback_cb_h h, int *seq_id) -{ - if (h == nullptr || seq_id == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *seq_id = h->seq_id; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_feedback_cb_is_once(rpc_port_stub_vc_feedback_cb_h h, bool *once) -{ - if (h == nullptr || once == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *once = h->once; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_feedback_cb_get_tag(rpc_port_stub_vc_feedback_cb_h h, char **tag) -{ - char *value; - char buf[128]; - - if (h == nullptr || tag == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id); - value = strdup(buf); - if (value == nullptr) { - _E("Out of memory"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - *tag = value; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_feedback_cb_set_port(rpc_port_stub_vc_feedback_cb_h h, rpc_port_h port) -{ - if (h == nullptr || port == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - h->port = port; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_feedback_cb_invoke(rpc_port_stub_vc_feedback_cb_h h, int utt_id, int event, rpc_port_stub_array_char_h pcm_data, int len) -{ - rpc_port_parcel_h parcel_; - int ret_; - - if (h == nullptr || h->port == nullptr || pcm_data == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (!__rpc_port_stub_vc_exist_callback_port(h->port)) { - _E("Not connected"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (h->once && !h->valid) { - _E("The delegate handle is already used"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - return ret_; - } - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_CALLBACK_); - - rpc_port_parcel_write(parcel_, &h->parcelable, h); - - rpc_port_parcel_write_int32(parcel_, utt_id); - - rpc_port_parcel_write_int32(parcel_, event); - - rpc_port_parcel_write(parcel_, &pcm_data->parcelable, pcm_data); - - rpc_port_parcel_write_int32(parcel_, len); - - ret_ = rpc_port_parcel_send(parcel_, h->port); - rpc_port_parcel_destroy(parcel_); - h->valid = false; - - return ret_; -} - -static int __rpc_port_stub_vc_method_register_notify_cb_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - rpc_port_stub_vc_notify_cb_h callback = nullptr; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - ret_ = rpc_port_stub_vc_notify_cb_create(&callback); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret_); - goto out; - } - - rpc_port_stub_vc_notify_cb_set_port(callback, callback_port_); - rpc_port_parcel_read(parcel, &callback->parcelable, callback); - ret_ = get_last_result(); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to read data. error(%d)", ret_); - goto out; - } - - if (context_->callback.register_notify_cb) - context_->callback.register_notify_cb(context_, pid, callback, context_->user_data); - -out: - if (callback) - rpc_port_stub_vc_notify_cb_destroy(callback); - - return ret_; -} - -static int __rpc_port_stub_vc_method_register_notify_cb_sync_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - rpc_port_stub_vc_notify_cb_h callback = nullptr; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - ret_ = rpc_port_stub_vc_notify_cb_create(&callback); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret_); - goto out; - } - - rpc_port_stub_vc_notify_cb_set_port(callback, callback_port_); - rpc_port_parcel_read(parcel, &callback->parcelable, callback); - ret_ = get_last_result(); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to read data. error(%d)", ret_); - goto out; - } - - if (context_->callback.register_notify_cb_sync) - res_ = context_->callback.register_notify_cb_sync(context_, pid, callback, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - if (callback) - rpc_port_stub_vc_notify_cb_destroy(callback); - - return ret_; -} - -static int __rpc_port_stub_vc_method_register_feedback_cb_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - rpc_port_stub_vc_feedback_cb_h callback = nullptr; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - ret_ = rpc_port_stub_vc_feedback_cb_create(&callback); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret_); - goto out; - } - - rpc_port_stub_vc_feedback_cb_set_port(callback, callback_port_); - rpc_port_parcel_read(parcel, &callback->parcelable, callback); - ret_ = get_last_result(); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to read data. error(%d)", ret_); - goto out; - } - - if (context_->callback.register_feedback_cb) - context_->callback.register_feedback_cb(context_, pid, callback, context_->user_data); - -out: - if (callback) - rpc_port_stub_vc_feedback_cb_destroy(callback); - - return ret_; -} - -static int __rpc_port_stub_vc_method_register_feedback_cb_sync_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - rpc_port_stub_vc_feedback_cb_h callback = nullptr; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - ret_ = rpc_port_stub_vc_feedback_cb_create(&callback); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create handle. error(%d)", ret_); - goto out; - } - - rpc_port_stub_vc_feedback_cb_set_port(callback, callback_port_); - rpc_port_parcel_read(parcel, &callback->parcelable, callback); - ret_ = get_last_result(); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to read data. error(%d)", ret_); - goto out; - } - - if (context_->callback.register_feedback_cb_sync) - res_ = context_->callback.register_feedback_cb_sync(context_, pid, callback, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - if (callback) - rpc_port_stub_vc_feedback_cb_destroy(callback); - - return ret_; -} - -static int __rpc_port_stub_vc_method_initialize_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int mgr_pid = -1; - int service_state = -1; - int daemon_pid = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - if (context_->callback.initialize) - res_ = context_->callback.initialize(context_, pid, &mgr_pid, &service_state, &daemon_pid, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, mgr_pid); - - rpc_port_parcel_write_int32(parcel_, service_state); - - rpc_port_parcel_write_int32(parcel_, daemon_pid); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_finalize_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - if (context_->callback.finalize) - res_ = context_->callback.finalize(context_, pid, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_set_command_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int cmd_type = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_int32(parcel, &cmd_type); - - if (context_->callback.set_command) - res_ = context_->callback.set_command(context_, pid, cmd_type, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_unset_command_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int cmd_type = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_int32(parcel, &cmd_type); - - if (context_->callback.unset_command) - res_ = context_->callback.unset_command(context_, pid, cmd_type, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_set_foreground_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - bool value = false; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_bool(parcel, &value); - - if (context_->callback.set_foreground) - res_ = context_->callback.set_foreground(context_, pid, value, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_set_server_dialog_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - char *app_id = nullptr; - char *credential = nullptr; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_string(parcel, &app_id); - if (app_id == nullptr) { - _E("Failed to read data"); - ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; - goto out; - } - - rpc_port_parcel_read_string(parcel, &credential); - if (credential == nullptr) { - _E("Failed to read data"); - ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; - goto out; - } - - if (context_->callback.set_server_dialog) - res_ = context_->callback.set_server_dialog(context_, pid, app_id, credential, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - if (app_id) - free(app_id); - - if (credential) - free(credential); - - return ret_; -} - -static int __rpc_port_stub_vc_method_request_dialog_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - char *disp_text = nullptr; - char *utt_text = nullptr; - bool continuous = false; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_string(parcel, &disp_text); - if (disp_text == nullptr) { - _E("Failed to read data"); - ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; - goto out; - } - - rpc_port_parcel_read_string(parcel, &utt_text); - if (utt_text == nullptr) { - _E("Failed to read data"); - ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; - goto out; - } - - rpc_port_parcel_read_bool(parcel, &continuous); - - if (context_->callback.request_dialog) - res_ = context_->callback.request_dialog(context_, pid, disp_text, utt_text, continuous, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - if (disp_text) - free(disp_text); - - if (utt_text) - free(utt_text); - - return ret_; -} - -static int __rpc_port_stub_vc_method_is_system_command_valid_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - bool is_sys_cmd_valid = false; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - if (context_->callback.is_system_command_valid) - res_ = context_->callback.is_system_command_valid(context_, pid, &is_sys_cmd_valid, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_bool(parcel_, is_sys_cmd_valid); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_auth_enable_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int mgr_pid = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_int32(parcel, &mgr_pid); - - if (context_->callback.auth_enable) - res_ = context_->callback.auth_enable(context_, pid, mgr_pid, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_auth_disable_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int mgr_pid = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_int32(parcel, &mgr_pid); - - if (context_->callback.auth_disable) - res_ = context_->callback.auth_disable(context_, pid, mgr_pid, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_auth_start_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int mgr_pid = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_int32(parcel, &mgr_pid); - - if (context_->callback.auth_start) - res_ = context_->callback.auth_start(context_, pid, mgr_pid, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_auth_stop_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int mgr_pid = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_int32(parcel, &mgr_pid); - - if (context_->callback.auth_stop) - res_ = context_->callback.auth_stop(context_, pid, mgr_pid, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_auth_cancel_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int mgr_pid = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_int32(parcel, &mgr_pid); - - if (context_->callback.auth_cancel) - res_ = context_->callback.auth_cancel(context_, pid, mgr_pid, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_request_tts_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - char *text = nullptr; - char *lang = nullptr; - bool to_vcm = false; - int utt_id = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_string(parcel, &text); - if (text == nullptr) { - _E("Failed to read data"); - ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; - goto out; - } - - rpc_port_parcel_read_string(parcel, &lang); - if (lang == nullptr) { - _E("Failed to read data"); - ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY; - goto out; - } - - rpc_port_parcel_read_bool(parcel, &to_vcm); - - if (context_->callback.request_tts) - res_ = context_->callback.request_tts(context_, pid, text, lang, to_vcm, &utt_id, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, utt_id); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - if (text) - free(text); - - if (lang) - free(lang); - - return ret_; -} - -static int __rpc_port_stub_vc_method_cancel_tts_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int utt_id = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - rpc_port_parcel_read_int32(parcel, &utt_id); - - if (context_->callback.cancel_tts) - res_ = context_->callback.cancel_tts(context_, pid, utt_id, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static int __rpc_port_stub_vc_method_get_tts_audio_format_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data) -{ - rpc_port_stub_vc_context_h context_ = user_data; - rpc_port_parcel_header_h header_; - int seq_num_ = -1; - rpc_port_h callback_port_; - int ret_; - int pid = -1; - int rate = -1; - int channel = -1; - int audio_type = -1; - rpc_port_parcel_h parcel_; - int res_ = -1; - - ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel, &header_); - rpc_port_parcel_header_get_seq_num(header_, &seq_num_); - _W("[Sequence] %d", seq_num_); - - rpc_port_parcel_read_int32(parcel, &pid); - - if (context_->callback.get_tts_audio_format) - res_ = context_->callback.get_tts_audio_format(context_, pid, &rate, &channel, &audio_type, context_->user_data); - - ret_ = rpc_port_parcel_create(&parcel_); - if (ret_ != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle. error(%d)", ret_); - goto out; - } - - rpc_port_parcel_get_header(parcel_, &header_); - rpc_port_parcel_header_set_tag(header_, TIDL_VERSION); - rpc_port_parcel_header_set_seq_num(header_, seq_num_); - - rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_); - - rpc_port_parcel_write_int32(parcel_, rate); - - rpc_port_parcel_write_int32(parcel_, channel); - - rpc_port_parcel_write_int32(parcel_, audio_type); - - rpc_port_parcel_write_int32(parcel_, res_); - - ret_ = rpc_port_parcel_send(parcel_, port); - rpc_port_parcel_destroy(parcel_); - -out: - - return ret_; -} - -static rpc_port_stub_method_handler __vc_method_table[] = { - [RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB] = __rpc_port_stub_vc_method_register_notify_cb_handler, - [RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB_SYNC] = __rpc_port_stub_vc_method_register_notify_cb_sync_handler, - [RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB] = __rpc_port_stub_vc_method_register_feedback_cb_handler, - [RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC] = __rpc_port_stub_vc_method_register_feedback_cb_sync_handler, - [RPC_PORT_STUB_VC_METHOD_INITIALIZE] = __rpc_port_stub_vc_method_initialize_handler, - [RPC_PORT_STUB_VC_METHOD_FINALIZE] = __rpc_port_stub_vc_method_finalize_handler, - [RPC_PORT_STUB_VC_METHOD_SET_COMMAND] = __rpc_port_stub_vc_method_set_command_handler, - [RPC_PORT_STUB_VC_METHOD_UNSET_COMMAND] = __rpc_port_stub_vc_method_unset_command_handler, - [RPC_PORT_STUB_VC_METHOD_SET_FOREGROUND] = __rpc_port_stub_vc_method_set_foreground_handler, - [RPC_PORT_STUB_VC_METHOD_SET_SERVER_DIALOG] = __rpc_port_stub_vc_method_set_server_dialog_handler, - [RPC_PORT_STUB_VC_METHOD_REQUEST_DIALOG] = __rpc_port_stub_vc_method_request_dialog_handler, - [RPC_PORT_STUB_VC_METHOD_IS_SYSTEM_COMMAND_VALID] = __rpc_port_stub_vc_method_is_system_command_valid_handler, - [RPC_PORT_STUB_VC_METHOD_AUTH_ENABLE] = __rpc_port_stub_vc_method_auth_enable_handler, - [RPC_PORT_STUB_VC_METHOD_AUTH_DISABLE] = __rpc_port_stub_vc_method_auth_disable_handler, - [RPC_PORT_STUB_VC_METHOD_AUTH_START] = __rpc_port_stub_vc_method_auth_start_handler, - [RPC_PORT_STUB_VC_METHOD_AUTH_STOP] = __rpc_port_stub_vc_method_auth_stop_handler, - [RPC_PORT_STUB_VC_METHOD_AUTH_CANCEL] = __rpc_port_stub_vc_method_auth_cancel_handler, - [RPC_PORT_STUB_VC_METHOD_REQUEST_TTS] = __rpc_port_stub_vc_method_request_tts_handler, - [RPC_PORT_STUB_VC_METHOD_CANCEL_TTS] = __rpc_port_stub_vc_method_cancel_tts_handler, - [RPC_PORT_STUB_VC_METHOD_GET_TTS_AUDIO_FORMAT] = __rpc_port_stub_vc_method_get_tts_audio_format_handler, -}; - -static int __rpc_port_stub_vc_context_handle_request(rpc_port_stub_vc_context_h h, rpc_port_parcel_h parcel) -{ - int ret = RPC_PORT_ERROR_NONE; - int cmd = -1; - - rpc_port_parcel_read_int32(parcel, &cmd); - if (cmd > 1 && cmd < ARRAY_SIZE(__vc_method_table)) { - if (__vc_method_table[cmd]) - ret = __vc_method_table[cmd](h->port, parcel, h); - } else { - _W("Invalid protocol. cmd(%d)", cmd); - ret = RPC_PORT_ERROR_INVALID_PARAMETER; - } - - return ret; -} - -#ifdef TIDL_THREAD_ENABLE -static int __rpc_port_stub_vc_context_push(rpc_port_stub_vc_context_h h, rpc_port_parcel_h parcel) -{ - g_mutex_lock(&h->mutex); - g_queue_push_tail(h->queue, parcel); - g_cond_signal(&h->cond); - g_mutex_unlock(&h->mutex); - - return 0; -} - -static rpc_port_parcel_h __rpc_port_stub_vc_context_wait_and_pop(rpc_port_stub_vc_context_h h) -{ - rpc_port_parcel_h parcel; - - g_mutex_lock(&h->mutex); - while (g_queue_is_empty(h->queue) && !h->done) - g_cond_wait(&h->cond, &h->mutex); - - parcel = g_queue_pop_head(h->queue); - g_mutex_unlock(&h->mutex); - - return parcel; -} - -static gpointer __rpc_port_stub_vc_context_thread_cb(gpointer user_data) -{ - rpc_port_stub_vc_context_h h = user_data; - rpc_port_parcel_h parcel; - - _W("START"); - while (!h->done) { - parcel = __rpc_port_stub_vc_context_wait_and_pop(h); - if (parcel) { - __rpc_port_stub_vc_context_handle_request(h, parcel); - rpc_port_parcel_destroy(parcel); - } - } - _W("END"); - - return nullptr; -} -#endif /* TIDL_THREAD_ENABLE */ - -static void __rpc_port_stub_vc_context_destroy(gpointer data) -{ - rpc_port_stub_vc_context_h h = data; -#ifdef TIDL_THREAD_ENABLE - rpc_port_parcel_h parcel; -#endif /* TIDL_THREAD_ENABLE */ - - if (h == nullptr) - return; - -#ifdef TIDL_THREAD_ENABLE - g_mutex_lock(&h->mutex); - h->done = true; - g_cond_signal(&h->cond); - g_mutex_unlock(&h->mutex); - - if (h->thread) { - g_thread_join(h->thread); - g_thread_unref(h->thread); - } - - g_mutex_clear(&h->mutex); - g_cond_clear(&h->cond); - - if (h->queue) { - while (!g_queue_is_empty(h->queue)) { - parcel = g_queue_pop_head(h->queue); - rpc_port_parcel_destroy(parcel); - } - - g_queue_free(h->queue); - } -#endif /* TIDL_THREAD_ENABLE */ - - if (h->instance) - free(h->instance); - - if (h->sender) - free(h->sender); - - free(h); -} - -static rpc_port_stub_vc_context_h __rpc_port_stub_vc_context_create(const char *sender, const char *instance, rpc_port_h callback_port) -{ - rpc_port_stub_vc_context_t *handle; - - if (sender == nullptr || instance == nullptr || callback_port == nullptr) { - _E("Invalid parameter"); - return nullptr; - } - - handle = calloc(1, sizeof(rpc_port_stub_vc_context_t)); - if (handle == nullptr) { - _E("Out of memory"); - return nullptr; - } - - handle->sender = strdup(sender); - if (handle->sender == nullptr) { - _E("Failed to duplicate sender"); - __rpc_port_stub_vc_context_destroy(handle); - return nullptr; - } - - handle->instance = strdup(instance); - if (handle->instance == nullptr) { - _E("Failed to duplicate instance"); - __rpc_port_stub_vc_context_destroy(handle); - return nullptr; - } - -#ifdef TIDL_THREAD_ENABLE - g_mutex_init(&handle->mutex); - g_cond_init(&handle->cond); - - handle->queue = g_queue_new(); - if (handle->queue == nullptr) { - _E("Failed to create queue"); - __rpc_port_stub_vc_context_destroy(handle); - return nullptr; - } - - handle->thread = g_thread_new(instance, __rpc_port_stub_vc_context_thread_cb, handle); - if (handle->thread == nullptr) { - _E("Failed to create thread"); - __rpc_port_stub_vc_context_destroy(handle); - return nullptr; - } -#endif /* TIDL_THREAD_ENABLE */ - - handle->callback_port = callback_port; - handle->callback = __vc.callback; - handle->user_data = __vc.user_data; - - return handle; -} - -int rpc_port_stub_vc_context_set_tag(rpc_port_stub_vc_context_h context, void *tag) -{ - if (context == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - context->tag = tag; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_context_get_tag(rpc_port_stub_vc_context_h context, void **tag) -{ - if (context == nullptr || tag == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - *tag = context->tag; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_context_get_sender(rpc_port_stub_vc_context_h context, char **sender) -{ - char *value; - - if (context == nullptr || sender == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - value = strdup(context->sender); - if (value == nullptr) { - _E("Failed to duplicate sender"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - *sender = value; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_context_get_instance(rpc_port_stub_vc_context_h context, char **instance) -{ - char *value; - - if (context == nullptr || instance == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - value = strdup(context->instance); - if (value == nullptr) { - _E("Failed to duplicate instance"); - return RPC_PORT_ERROR_OUT_OF_MEMORY; - } - - *instance = value; - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_context_disconnect(rpc_port_stub_vc_context_h context) -{ - int ret; - - if (context == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - g_rec_mutex_lock(&__vc.mutex); - - ret = rpc_port_disconnect(context->callback_port); - if (ret != RPC_PORT_ERROR_NONE) - _E("Failed to disconnect. error(%d)", ret); - - g_rec_mutex_unlock(&__vc.mutex); - - return ret; -} - -static rpc_port_stub_vc_context_h __rpc_port_stub_vc_find_context(const char *instance) -{ - rpc_port_stub_vc_context_h context; - GList *iter; - - g_rec_mutex_lock(&__vc.mutex); - iter = __vc.contexts; - while (iter) { - context = iter->data; - if (!strcmp(context->instance, instance)) { - g_rec_mutex_unlock(&__vc.mutex); - return context; - } - - iter = g_list_next(iter); - } - g_rec_mutex_unlock(&__vc.mutex); - - return nullptr; -} - -static void __rpc_port_stub_vc_add_context(rpc_port_stub_vc_context_h context) -{ - g_rec_mutex_lock(&__vc.mutex); - __vc.contexts = g_list_append(__vc.contexts, context); - g_rec_mutex_unlock(&__vc.mutex); -} - -static void __rpc_port_stub_vc_remove_context(rpc_port_stub_vc_context_h context) -{ - g_rec_mutex_lock(&__vc.mutex); - __vc.contexts = g_list_remove(__vc.contexts, context); - g_rec_mutex_unlock(&__vc.mutex); -} - -static bool __rpc_port_stub_vc_exist_callback_port(rpc_port_h callback_port) -{ - rpc_port_h port; - GList *iter; - - g_rec_mutex_lock(&__vc.mutex); - iter = __vc.callback_ports; - while (iter) { - port = iter->data; - if (port == callback_port) { - g_rec_mutex_unlock(&__vc.mutex); - return true; - } - - iter = g_list_next(iter); - } - g_rec_mutex_unlock(&__vc.mutex); - - return false; -} - -static void __rpc_port_stub_vc_add_callback_port(rpc_port_h callback_port) -{ - g_rec_mutex_lock(&__vc.mutex); - __vc.callback_ports = g_list_append(__vc.callback_ports, callback_port); - g_rec_mutex_unlock(&__vc.mutex); -} - -static void __rpc_port_stub_vc_remove_callback_port(rpc_port_h callback_port) -{ - g_rec_mutex_lock(&__vc.mutex); - __vc.callback_ports = g_list_remove(__vc.callback_ports, callback_port); - g_rec_mutex_unlock(&__vc.mutex); -} - -static void __rpc_port_stub_vc_connected_event_cb(const char *sender, const char *instance, void *user_data) -{ - rpc_port_stub_vc_context_h context; - rpc_port_h callback_port = nullptr; - int ret; - - _W("sender(%s), instance(%s)", sender, instance); - ret = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, instance, &callback_port); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to get callback port. error(%d)", ret); - return; - } - - context = __rpc_port_stub_vc_context_create(sender, instance, callback_port); - if (context == nullptr) - return; - - __rpc_port_stub_vc_add_context(context); - __rpc_port_stub_vc_add_callback_port(context->callback_port); - context->callback.create(context, context->user_data); -} - -static void __rpc_port_stub_vc_disconnected_event_cb(const char *sender, const char *instance, void *user_data) -{ - rpc_port_stub_vc_context_h context; - - _W("sender(%s), instance(%s)", sender, instance); - context = __rpc_port_stub_vc_find_context(instance); - if (context == nullptr) - return; - - __rpc_port_stub_vc_remove_callback_port(context->callback_port); - context->callback.terminate(context, context->user_data); - __rpc_port_stub_vc_remove_context(context); - __rpc_port_stub_vc_context_destroy(context); -} - -static int __rpc_port_stub_vc_received_event_cb(const char *sender, const char *instance, rpc_port_h port, void *user_data) -{ - rpc_port_stub_vc_context_h context; - rpc_port_parcel_h parcel; - int ret; - - _W("sender(%s), instance(%s)", sender, instance); - context = __rpc_port_stub_vc_find_context(instance); - if (context == nullptr) { - _E("Failed to find context. instance(%s)", instance); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - context->port = port; - ret = rpc_port_parcel_create_from_port(&parcel, port); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create parcel handle from port. error(%d)", ret); - return ret; - } - -#ifdef TIDL_THREAD_ENABLE - ret = __rpc_port_stub_vc_context_push(context, parcel); -#else - ret = __rpc_port_stub_vc_context_handle_request(context, parcel); - rpc_port_parcel_destroy(parcel); -#endif /* TIDL_THREAD_ENABLE */ - - return ret; -} - -static int __rpc_port_stub_vc_set_access_control(void) -{ - int ret = RPC_PORT_ERROR_NONE; - - return ret; -} - -int rpc_port_stub_vc_register(rpc_port_stub_vc_callback_s *callback, void *user_data) -{ - int ret; - - if (callback == nullptr || callback->create == nullptr || callback->terminate == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (__vc.stub) { - _E("Already exists"); - return RPC_PORT_ERROR_NONE; - } - - g_rec_mutex_init(&__vc.mutex); - __vc.callback = *callback; - __vc.user_data = user_data; - - ret = rpc_port_stub_create(&__vc.stub, "vc"); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to create stub handle. error(%d)", ret); - g_rec_mutex_clear(&__vc.mutex); - return ret; - } - - ret = rpc_port_stub_add_received_event_cb(__vc.stub, __rpc_port_stub_vc_received_event_cb, &__vc); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to add received event callback"); - rpc_port_stub_vc_unregister(); - return ret; - } - - ret = rpc_port_stub_add_connected_event_cb(__vc.stub, __rpc_port_stub_vc_connected_event_cb, &__vc); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to add connected event callback"); - rpc_port_stub_vc_unregister(); - return ret; - } - - ret = rpc_port_stub_add_disconnected_event_cb(__vc.stub, __rpc_port_stub_vc_disconnected_event_cb, &__vc); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to add disconnected event callback"); - rpc_port_stub_vc_unregister(); - return ret; - } - - ret = __rpc_port_stub_vc_set_access_control(); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to add privileges"); - rpc_port_stub_vc_unregister(); - return ret; - } - - ret = rpc_port_stub_listen(__vc.stub); - if (ret != RPC_PORT_ERROR_NONE) { - _E("Failed to listen events. error(%d)", ret); - rpc_port_stub_vc_unregister(); - return ret; - } - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_unregister(void) -{ - if (__vc.stub == nullptr) - return RPC_PORT_ERROR_NONE; - - g_rec_mutex_lock(&__vc.mutex); - g_rec_mutex_unlock(&__vc.mutex); - g_rec_mutex_clear(&__vc.mutex); - - if (__vc.contexts) { - g_list_free_full(__vc.contexts, __rpc_port_stub_vc_context_destroy); - __vc.contexts = nullptr; - } - - if (__vc.stub) { - rpc_port_stub_destroy(__vc.stub); - __vc.stub = nullptr; - } - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_foreach_context(rpc_port_stub_vc_context_cb callback, void *user_data) -{ - rpc_port_stub_vc_context_h context; - GList *iter; - - if (callback == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - g_rec_mutex_lock(&__vc.mutex); - iter = __vc.contexts; - while (iter) { - context = iter->data; - if (!callback(context, user_data)) - break; - - iter = g_list_next(iter); - } - g_rec_mutex_unlock(&__vc.mutex); - - return RPC_PORT_ERROR_NONE; -} - -int rpc_port_stub_vc_get_client_number(unsigned int *client_number) -{ - if (client_number == nullptr) { - _E("Invalid parameter"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - if (__vc.stub == nullptr) { - _E("Invalid context"); - return RPC_PORT_ERROR_INVALID_PARAMETER; - } - - g_rec_mutex_lock(&__vc.mutex); - *client_number = g_list_length(__vc.contexts); - g_rec_mutex_unlock(&__vc.mutex); - - return RPC_PORT_ERROR_NONE; -} diff --git a/server/vcd_stub.h b/server/vcd_stub.h deleted file mode 100755 index 70c5013..0000000 --- a/server/vcd_stub.h +++ /dev/null @@ -1,680 +0,0 @@ -/* - * Generated by tidlc 1.8.1. - */ - -#pragma once - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The rpc_port_stub_array_char handle. - */ -typedef struct rpc_port_stub_array_char_s *rpc_port_stub_array_char_h; - -/** - * @brief The rpc_port_stub_vc_context handle. - */ -typedef struct rpc_port_stub_vc_context_s *rpc_port_stub_vc_context_h; - -/** - * @brief The rpc_port_stub_vc_notify_cb handle. - */ -typedef struct rpc_port_stub_vc_notify_cb_s *rpc_port_stub_vc_notify_cb_h; - -/** - * @brief The rpc_port_stub_vc_feedback_cb handle. - */ -typedef struct rpc_port_stub_vc_feedback_cb_s *rpc_port_stub_vc_feedback_cb_h; - -/** - * @briefs Creates a rpc_port_stub_array_char handle. - * - * @remarks The @a h should be released using the rpc_port_stub_array_char_destroy() - * if it's no longer needed. - * @param[out] h The rpc_port_stub_array_char handle that is newly created - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_stub_array_char_destroy() - */ -int rpc_port_stub_array_char_create(rpc_port_stub_array_char_h *h); - -/** - * @brief Destroys the rpc_port_stub_array_char handle. - * - * @param[in] h The rpc_port_stub_array_char handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_stub_array_char_create() - */ -int rpc_port_stub_array_char_destroy(rpc_port_stub_array_char_h h); - -/** - * @brief Creates and returns a copy of the given rpc_port_stub_array_char handle. - * - * @remarks A new created rpc_port_stub_array_char should be released using - * the rpc_port_stub_array_char_destroy() if it's no longer needed. - * @param[in] h The rpc_port_stub_array_char handle - * @param[out] clone If successful, a new created rpc_port_stub_array_char handle will be returned - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_stub_array_char_destroy() - */ -int rpc_port_stub_array_char_clone(rpc_port_stub_array_char_h h, rpc_port_stub_array_char_h *clone); - -/** - * @brief Sets the value to the rpc_port_stub_array_char handle. - * - * @remarks The value is internally copied and stored. - * You should release it if it's allocaed when it's no longer needed, - * @param[in] h The rpc_port_stub_array_char handle - * @param[in] value The array value - * @param[in] size The size of the array - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_stub_array_char_get() - */ -int rpc_port_stub_array_char_set(rpc_port_stub_array_char_h h, char *value, int size); - -/** - * @brief Gets the value from the rpc_port_stub_array_char handle. - * - * @remarks A new created value should be released if it's no longer needed. - * @param[in] h The rpc_port_stub_array_char handle - * @param[out] value The array value - * @param[out] size The size of the array - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_stub_array_char_set() - */ -int rpc_port_stub_array_char_get(rpc_port_stub_array_char_h h, char **value, int *size); - -/** - * @brief Called when the proxy is connected. - * @details The callback function is called when the proxy is connected to the stub. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s - */ -typedef void (*rpc_port_stub_vc_create_cb)(rpc_port_stub_vc_context_h context, void *user_data); - -/** - * @brief Called when the proxy is disconnected. - * @details The callback function is called when the proxy is disconnected from the stub. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s - */ -typedef void (*rpc_port_stub_vc_terminate_cb)(rpc_port_stub_vc_context_h context, void *user_data); - -/** - * @brief Called to get the proxy context once for each connected proxy. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @return @c true to continue with the next iteration of the loop, - * otherwise @c false to break out of the loop - * @pre rpc_port_stub_vc_foreach_context() will invoke this callback. - * @see rpc_port_stub_vc_foreach_context() - */ -typedef bool (*rpc_port_stub_vc_context_cb)(rpc_port_stub_vc_context_h context, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef void (*rpc_port_stub_vc_register_notify_cb_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_register_notify_cb_sync_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef void (*rpc_port_stub_vc_register_feedback_cb_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_register_feedback_cb_sync_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_initialize_cb)(rpc_port_stub_vc_context_h context, int pid, int *mgr_pid, int *service_state, int *daemon_pid, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_finalize_cb)(rpc_port_stub_vc_context_h context, int pid, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_set_command_cb)(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_unset_command_cb)(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_set_foreground_cb)(rpc_port_stub_vc_context_h context, int pid, bool value, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_set_server_dialog_cb)(rpc_port_stub_vc_context_h context, int pid, const char *app_id, const char *credential, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_request_dialog_cb)(rpc_port_stub_vc_context_h context, int pid, const char *disp_text, const char *utt_text, bool continuous, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_is_system_command_valid_cb)(rpc_port_stub_vc_context_h context, int pid, bool *is_sys_cmd_valid, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_auth_enable_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_auth_disable_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_auth_start_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_auth_stop_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_auth_cancel_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_request_tts_cb)(rpc_port_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_cancel_tts_cb)(rpc_port_stub_vc_context_h context, int pid, int utt_id, void *user_data); - -/** - * @brief Called when the request of the proxy is delivered. - * - * @param[in] context The context handle - * @param[in] user_data The user data passed from the registration function - * @see #rpc_port_stub_vc_callback_s; - */ -typedef int (*rpc_port_stub_vc_get_tts_audio_format_cb)(rpc_port_stub_vc_context_h context, int pid, int *rate, int *channel, int *audio_type, void *user_data); - -/** - * @brief Sets the tag to the context handle. - * - * @param[in] context The context handle - * @param[in] tag The tag - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_stub_vc_context_get_tag() - */ -int rpc_port_stub_vc_context_set_tag(rpc_port_stub_vc_context_h context, void *tag); - -/** - * @brief Gets the tag from the context handle. - * - * @param[in] context The context handle - * @param[out] tag The tag - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_stub_vc_context_set_tag() - */ -int rpc_port_stub_vc_context_get_tag(rpc_port_stub_vc_context_h context, void **tag); - -/** - * @brief Gets the sender ID from the context handle. - * @details The @a sender should be released using free(). - * - * @param[in] context The context handle - * @param[out] sender The sender ID of the context handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int rpc_port_stub_vc_context_get_sender(rpc_port_stub_vc_context_h context, char **sender); - -/** - * @brief Gets the instance ID from the context handle. - * @details The @a instance should be released using free(). - * - * @param[in] context The context handle - * @param[out] instance The instance ID of the context handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int rpc_port_stub_vc_context_get_instance(rpc_port_stub_vc_context_h context, char **instance); - -/** - * @brief Disconnects from the proxy. - * - * @param[in] context The context handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_stub_vc_context_disconnect(rpc_port_stub_vc_context_h context); - -/** - * @brief Creates a rpc_port_stub_vc_notify_cb handle. - * - * @param[out] h The rpc_port_stub_vc_notify_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_stub_vc_notify_cb_destroy() - */ -int rpc_port_stub_vc_notify_cb_create(rpc_port_stub_vc_notify_cb_h *h); - -/** - * @brief Destroys the rpc_port_stub_vc_notify_cb handle. - * - * @param[in] h The rpc_port_stub_vc_notify_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_stub_vc_notify_cb_clone() - */ -int rpc_port_stub_vc_notify_cb_destroy(rpc_port_stub_vc_notify_cb_h h); - -/** - * @brief Creates and returns a copy of the given rpc_port_stub_vc_notify_cb handle. - * - * @remarks A new created rpc_port_stub_vc_notify_cb should be released using - * the rpc_port_stub_vc_notify_cb_destroy() if it's no longer needed. - * @param[in] h The rpc_port_stub_vc_notify_cb handle - * @param[out] clone If successful, a new created rpc_port_stub_vc_notify_cb handle will be returned - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_stub_vc_notify_cb_destroy() - */ -int rpc_port_stub_vc_notify_cb_clone(rpc_port_stub_vc_notify_cb_h h, rpc_port_stub_vc_notify_cb_h *clone); - -/** - * @brief Gets the ID of the rpc_port_stub_vc_notify_cb handle. - * - * @param[in] h The rpc_port_stub_vc_notify_cb handle - * @param[out] id The ID - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_stub_vc_notify_cb_get_id(rpc_port_stub_vc_notify_cb_h h, int *id); - -/** - * @brief Gets the sequence ID of the rpc_port_stub_vc_notify_cb handle. - * - * @param[in] h The rpc_port_stub_vc_notify_cb handle - * @param[out] seq_id The Sequence ID - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_stub_vc_notify_cb_get_seq_id(rpc_port_stub_vc_notify_cb_h h, int *seq_id); - -/** - * @brief Checks whether the delegate is for one-time or not. - * - * @param[in] h The rpc_port_stub_vc_notify_cb handle - * @param[out] once The flag, it's true, the handle is for one-time - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_stub_vc_notify_cb_is_once(rpc_port_stub_vc_notify_cb_h h, bool *once); - -/** - * @brief Gets the tag from the rpc_port_stub_vc_notify_cb handle. - * - * @remarks The @a tag should be released using free(). - * @param[in] h The rpc_port_stub_vc_notify_cb handle - * @param[out] tag The tag - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int rpc_port_stub_vc_notify_cb_get_tag(rpc_port_stub_vc_notify_cb_h h, char **tag); - -/** - * @brief Invokes the callback function of the rpc_port_stub_vc_notify_cb handle. - * - * @param[in] h The rpc_port_stub_vc_notify_cb handle - * @param[in] ... - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_stub_vc_notify_cb_invoke(rpc_port_stub_vc_notify_cb_h h, int pid, bundle *msg); - -/** - * @brief Creates a rpc_port_stub_vc_feedback_cb handle. - * - * @param[out] h The rpc_port_stub_vc_feedback_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_stub_vc_feedback_cb_destroy() - */ -int rpc_port_stub_vc_feedback_cb_create(rpc_port_stub_vc_feedback_cb_h *h); - -/** - * @brief Destroys the rpc_port_stub_vc_feedback_cb handle. - * - * @param[in] h The rpc_port_stub_vc_feedback_cb handle - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_stub_vc_feedback_cb_clone() - */ -int rpc_port_stub_vc_feedback_cb_destroy(rpc_port_stub_vc_feedback_cb_h h); - -/** - * @brief Creates and returns a copy of the given rpc_port_stub_vc_feedback_cb handle. - * - * @remarks A new created rpc_port_stub_vc_feedback_cb should be released using - * the rpc_port_stub_vc_feedback_cb_destroy() if it's no longer needed. - * @param[in] h The rpc_port_stub_vc_feedback_cb handle - * @param[out] clone If successful, a new created rpc_port_stub_vc_feedback_cb handle will be returned - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @see rpc_port_stub_vc_feedback_cb_destroy() - */ -int rpc_port_stub_vc_feedback_cb_clone(rpc_port_stub_vc_feedback_cb_h h, rpc_port_stub_vc_feedback_cb_h *clone); - -/** - * @brief Gets the ID of the rpc_port_stub_vc_feedback_cb handle. - * - * @param[in] h The rpc_port_stub_vc_feedback_cb handle - * @param[out] id The ID - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_stub_vc_feedback_cb_get_id(rpc_port_stub_vc_feedback_cb_h h, int *id); - -/** - * @brief Gets the sequence ID of the rpc_port_stub_vc_feedback_cb handle. - * - * @param[in] h The rpc_port_stub_vc_feedback_cb handle - * @param[out] seq_id The Sequence ID - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_stub_vc_feedback_cb_get_seq_id(rpc_port_stub_vc_feedback_cb_h h, int *seq_id); - -/** - * @brief Checks whether the delegate is for one-time or not. - * - * @param[in] h The rpc_port_stub_vc_feedback_cb handle - * @param[out] once The flag, it's true, the handle is for one-time - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_stub_vc_feedback_cb_is_once(rpc_port_stub_vc_feedback_cb_h h, bool *once); - -/** - * @brief Gets the tag from the rpc_port_stub_vc_feedback_cb handle. - * - * @remarks The @a tag should be released using free(). - * @param[in] h The rpc_port_stub_vc_feedback_cb handle - * @param[out] tag The tag - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - */ -int rpc_port_stub_vc_feedback_cb_get_tag(rpc_port_stub_vc_feedback_cb_h h, char **tag); - -/** - * @brief Invokes the callback function of the rpc_port_stub_vc_feedback_cb handle. - * - * @param[in] h The rpc_port_stub_vc_feedback_cb handle - * @param[in] ... - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #RPC_PORT_ERROR_IO_ERROR I/O error - */ -int rpc_port_stub_vc_feedback_cb_invoke(rpc_port_stub_vc_feedback_cb_h h, int utt_id, int event, rpc_port_stub_array_char_h pcm_data, int len); - -/** - * @brief The structure type containing the set of callback functions for handling stub events. - * @details It is one of the input parameters of the rpc_port_stub_vc_register() function. - * - * @see rpc_port_stub_vc_create_cb - * @see rpc_port_stub_vc_terminate_cb - */ -typedef struct { - rpc_port_stub_vc_create_cb create; /**< This callback function is invoked when the proxy is connected. */ - rpc_port_stub_vc_terminate_cb terminate; /**< This callback function is invoked when the proxy is disconnected. */ - rpc_port_stub_vc_register_notify_cb_cb register_notify_cb; /**< This callback function is invoked when the register_notify_cb request is delivered. */ - rpc_port_stub_vc_register_notify_cb_sync_cb register_notify_cb_sync; /**< This callback function is invoked when the register_notify_cb_sync request is delivered. */ - rpc_port_stub_vc_register_feedback_cb_cb register_feedback_cb; /**< This callback function is invoked when the register_feedback_cb request is delivered. */ - rpc_port_stub_vc_register_feedback_cb_sync_cb register_feedback_cb_sync; /**< This callback function is invoked when the register_feedback_cb_sync request is delivered. */ - rpc_port_stub_vc_initialize_cb initialize; /**< This callback function is invoked when the initialize request is delivered. */ - rpc_port_stub_vc_finalize_cb finalize; /**< This callback function is invoked when the finalize request is delivered. */ - rpc_port_stub_vc_set_command_cb set_command; /**< This callback function is invoked when the set_command request is delivered. */ - rpc_port_stub_vc_unset_command_cb unset_command; /**< This callback function is invoked when the unset_command request is delivered. */ - rpc_port_stub_vc_set_foreground_cb set_foreground; /**< This callback function is invoked when the set_foreground request is delivered. */ - rpc_port_stub_vc_set_server_dialog_cb set_server_dialog; /**< This callback function is invoked when the set_server_dialog request is delivered. */ - rpc_port_stub_vc_request_dialog_cb request_dialog; /**< This callback function is invoked when the request_dialog request is delivered. */ - rpc_port_stub_vc_is_system_command_valid_cb is_system_command_valid; /**< This callback function is invoked when the is_system_command_valid request is delivered. */ - rpc_port_stub_vc_auth_enable_cb auth_enable; /**< This callback function is invoked when the auth_enable request is delivered. */ - rpc_port_stub_vc_auth_disable_cb auth_disable; /**< This callback function is invoked when the auth_disable request is delivered. */ - rpc_port_stub_vc_auth_start_cb auth_start; /**< This callback function is invoked when the auth_start request is delivered. */ - rpc_port_stub_vc_auth_stop_cb auth_stop; /**< This callback function is invoked when the auth_stop request is delivered. */ - rpc_port_stub_vc_auth_cancel_cb auth_cancel; /**< This callback function is invoked when the auth_cancel request is delivered. */ - rpc_port_stub_vc_request_tts_cb request_tts; /**< This callback function is invoked when the request_tts request is delivered. */ - rpc_port_stub_vc_cancel_tts_cb cancel_tts; /**< This callback function is invoked when the cancel_tts request is delivered. */ - rpc_port_stub_vc_get_tts_audio_format_cb get_tts_audio_format; /**< This callback function is invoked when the get_tts_audio_format request is delivered. */ -} rpc_port_stub_vc_callback_s; - -/** - * @brief Registers the set of the callback functions and the port. - * @details This function registers the set of the callback functions to handle stub events. - * And, the rpc_port_stub_listen() is called internally to handle events. - * - * @param[in] callback The set of callback functions to handle stub events - * @param[in] user_data The user data to be passed to the callback function - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory - * @retval #RPC_PORT_ERROR_IO_ERROR I/O error - * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied - * @see rpc_port_stub_vc_unregister() - * @see #rpc_port_stub_vc_callback_s - */ -int rpc_port_stub_vc_register(rpc_port_stub_vc_callback_s *callback, void *user_data); - -/** - * @brief Unregisters the registered port. - */ -int rpc_port_stub_vc_unregister(void); - -/** - * @brief Retrieves the connected context handles. - * - * @param[in] callback The callback function - * @param[in] user_data The user data to be passed to the callback function - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - * @see rpc_port_stub_vc_context_cb() - */ -int rpc_port_stub_vc_foreach_context(rpc_port_stub_vc_context_cb callback, void *user_data); - -/** - * @brief Gets the number of connected clients. - * - * @param[out] client_number The client number - * @return @c 0 on success, - * otherwise a negative error value - * @retval #RPC_PORT_ERROR_NONE Successful - * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int rpc_port_stub_vc_get_client_number(unsigned int *client_number); - -#ifdef __cplusplus -} -#endif diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 354cf21..8d6f305 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -27,23 +27,26 @@ #include "vcd_widget_proxy.h" -static rpc_port_stub_vc_mgr_callback_s g_mgr_callback; +static rpc_port_stub_vcd_mgr_stub_vc_mgr_callback_s g_mgr_callback; static pthread_mutex_t g_mgr_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; -static rpc_port_stub_vc_widget_callback_s g_widget_callback; +static rpc_port_stub_vcd_widget_stub_vc_widget_callback_s g_widget_callback; static pthread_mutex_t g_widget_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; -static rpc_port_stub_vc_callback_s g_vc_callback; +static rpc_port_stub_vcd_stub_vc_callback_s g_vc_callback; static int g_volume_count = 0; +int vcd_client_tidl_open_connection(); +int vcd_client_tidl_close_connection(); int vcd_mgr_tidl_open_connection(); int vcd_mgr_tidl_close_connection(); int vcd_widget_tidl_open_connection(); int vcd_widget_tidl_close_connection(); + /* for common request */ static void __request_tidl_connect(vcd_client_type_e type, int pid) { @@ -61,7 +64,7 @@ static void __request_tidl_connect(vcd_client_type_e type, int pid) return; } - ret = rpc_port_proxy_vcd_mgr_connect(mgr_tidl_info->rpc_h); + ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_connect(mgr_tidl_info->rpc_h); if (0 == ret) { mgr_tidl_info->connection_requesting = true; @@ -97,7 +100,7 @@ static void __request_tidl_connect(vcd_client_type_e type, int pid) return; } - ret = rpc_port_proxy_vcd_widget_connect(widget_tidl_info->rpc_h); + ret = rpc_port_proxy_vcd_widget_proxy_vcd_widget_connect(widget_tidl_info->rpc_h); if (0 == ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); @@ -131,14 +134,14 @@ void __send_msg(bundle* msg, vcd_client_type_e type, int pid) return; } - rpc_port_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; + 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_vc_mgr_notify_cb_invoke(handle, msg)) { + 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; @@ -180,14 +183,14 @@ void __send_msg(bundle* msg, vcd_client_type_e type, int pid) return; } - rpc_port_stub_vc_widget_notify_cb_h handle = widget_tidl_info->notify_cb; + rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h handle = widget_tidl_info->notify_cb; if (NULL == handle) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); pthread_mutex_unlock(&g_widget_tidl_info_mutex); return; } - if (0 != rpc_port_stub_vc_widget_notify_cb_invoke(handle, msg)) { + if (0 != rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_invoke(handle, msg)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); pthread_mutex_unlock(&g_widget_tidl_info_mutex); return; @@ -213,14 +216,14 @@ void __send_signal(bundle* msg) return; } - rpc_port_stub_vc_mgr_notify_cb_h handle = mgr_tidl_info->notify_cb; + 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_vc_mgr_notify_cb_invoke(handle, msg)) { + 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; @@ -296,13 +299,13 @@ void __send_signal(bundle* msg) SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to widget"); - rpc_port_stub_vc_widget_notify_cb_h handle = widget_tidl_info->notify_cb; + rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h handle = widget_tidl_info->notify_cb; if (NULL == handle) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); break; } - if (0 != rpc_port_stub_vc_widget_notify_cb_invoke(handle, msg)) { + if (0 != rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_invoke(handle, msg)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); break; } @@ -316,13 +319,13 @@ void __send_signal(bundle* msg) /** * TIDL functions for VC client */ -static void __vc_create_cb(rpc_port_stub_vc_context_h context, void *user_data) +static void __vc_create_cb(rpc_port_stub_vcd_stub_vc_context_h context, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_create_cb"); char *sender = NULL; - rpc_port_stub_vc_context_get_sender(context, &sender); + rpc_port_stub_vcd_stub_vc_context_get_sender(context, &sender); if (!sender) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); return ; @@ -332,12 +335,12 @@ static void __vc_create_cb(rpc_port_stub_vc_context_h context, void *user_data) free(sender); } -static void __vc_terminate_cb(rpc_port_stub_vc_context_h context, void *user_data) +static void __vc_terminate_cb(rpc_port_stub_vcd_stub_vc_context_h context, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_terminate_cb"); } -static void __vc_register_notify_cb_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data) +static void __vc_register_notify_cb_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_cb. pid(%d)", pid); @@ -361,7 +364,7 @@ static void __vc_register_notify_cb_cb(rpc_port_stub_vc_context_h context, int p } } -static int __vc_register_notify_cb_sync_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data) +static int __vc_register_notify_cb_sync_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_sync_cb. pid(%d)", pid); @@ -387,7 +390,7 @@ static int __vc_register_notify_cb_sync_cb(rpc_port_stub_vc_context_h context, i return ret; } -static void __vc_register_feedback_cb_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data) +static void __vc_register_feedback_cb_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_cb. pid(%d)", pid); @@ -411,7 +414,7 @@ static void __vc_register_feedback_cb_cb(rpc_port_stub_vc_context_h context, int } } -static int __vc_register_feedback_cb_sync_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data) +static int __vc_register_feedback_cb_sync_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_sync_cb. pid(%d)", pid); @@ -437,7 +440,7 @@ static int __vc_register_feedback_cb_sync_cb(rpc_port_stub_vc_context_h context, return ret; } -static int __vc_initialize_cb(rpc_port_stub_vc_context_h context, int pid, int *mgr_pid, int *service_state, int *daemon_pid, void *user_data) +static int __vc_initialize_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int *mgr_pid, int *service_state, int *daemon_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_initialize_cb. pid(%d)", pid); @@ -457,7 +460,7 @@ static int __vc_initialize_cb(rpc_port_stub_vc_context_h context, int pid, int * return ret; } -static int __vc_finalize_cb(rpc_port_stub_vc_context_h context, int pid, void *user_data) +static int __vc_finalize_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_finalize_cb"); @@ -473,7 +476,7 @@ static int __vc_finalize_cb(rpc_port_stub_vc_context_h context, int pid, void *u return ret; } -static int __vc_set_command_cb(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data) +static int __vc_set_command_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int cmd_type, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_command_cb"); @@ -489,7 +492,7 @@ static int __vc_set_command_cb(rpc_port_stub_vc_context_h context, int pid, int return ret; } -static int __vc_unset_command_cb(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data) +static int __vc_unset_command_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int cmd_type, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_unset_command_cb"); @@ -505,7 +508,7 @@ static int __vc_unset_command_cb(rpc_port_stub_vc_context_h context, int pid, in return ret; } -static int __vc_set_foreground_cb(rpc_port_stub_vc_context_h context, int pid, bool value, void *user_data) +static int __vc_set_foreground_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, bool value, void *user_data) { // check more... SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_foreground_cb"); @@ -522,7 +525,7 @@ static int __vc_set_foreground_cb(rpc_port_stub_vc_context_h context, int pid, b return ret; } -static int __vc_set_server_dialog_cb(rpc_port_stub_vc_context_h context, int pid, const char *app_id, const char *credential, void *user_data) +static int __vc_set_server_dialog_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, const char *app_id, const char *credential, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_server_dialog_cb"); @@ -538,7 +541,7 @@ static int __vc_set_server_dialog_cb(rpc_port_stub_vc_context_h context, int pid return ret; } -static int __vc_request_dialog_cb(rpc_port_stub_vc_context_h context, int pid, const char *disp_text, const char *utt_text, bool continuous, void *user_data) +static int __vc_request_dialog_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, const char *disp_text, const char *utt_text, bool continuous, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_dialog_cb"); @@ -554,7 +557,7 @@ static int __vc_request_dialog_cb(rpc_port_stub_vc_context_h context, int pid, c return ret; } -static int __vc_is_system_command_valid_cb(rpc_port_stub_vc_context_h context, int pid, bool *is_sys_cmd_valid, void *user_data) +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) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_is_system_command_valid_cb"); @@ -570,7 +573,7 @@ static int __vc_is_system_command_valid_cb(rpc_port_stub_vc_context_h context, i return ret; } -static int __vc_auth_enable_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +static int __vc_auth_enable_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_enable_cb. Send a request to vc_mgr"); @@ -587,7 +590,7 @@ static int __vc_auth_enable_cb(rpc_port_stub_vc_context_h context, int pid, int return VCD_ERROR_NONE; } -static int __vc_auth_disable_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +static int __vc_auth_disable_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_disable_cb. Send a request to vc_mgr"); @@ -604,7 +607,7 @@ static int __vc_auth_disable_cb(rpc_port_stub_vc_context_h context, int pid, int return VCD_ERROR_NONE; } -static int __vc_auth_start_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +static int __vc_auth_start_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_start_cb. Send a request to vc_mgr"); @@ -621,7 +624,7 @@ static int __vc_auth_start_cb(rpc_port_stub_vc_context_h context, int pid, int m return VCD_ERROR_NONE; } -static int __vc_auth_stop_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +static int __vc_auth_stop_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_stop_cb. Send a request to vc_mgr"); @@ -638,7 +641,7 @@ static int __vc_auth_stop_cb(rpc_port_stub_vc_context_h context, int pid, int mg return VCD_ERROR_NONE; } -static int __vc_auth_cancel_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) +static int __vc_auth_cancel_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_cancel_cb. Send a request to vc_mgr"); @@ -655,7 +658,7 @@ static int __vc_auth_cancel_cb(rpc_port_stub_vc_context_h context, int pid, int return VCD_ERROR_NONE; } -static int __vc_request_tts_cb(rpc_port_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data) +static int __vc_request_tts_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_tts_cb"); @@ -671,7 +674,7 @@ static int __vc_request_tts_cb(rpc_port_stub_vc_context_h context, int pid, cons return ret; } -static int __vc_cancel_tts_cb(rpc_port_stub_vc_context_h context, int pid, int utt_id, void *user_data) +static int __vc_cancel_tts_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int utt_id, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_cancel_tts_cb"); @@ -687,7 +690,7 @@ static int __vc_cancel_tts_cb(rpc_port_stub_vc_context_h context, int pid, int u return ret; } -static int __vc_get_tts_audio_format_cb(rpc_port_stub_vc_context_h context, int pid, int *rate, int *channel, int *audio_type, void *user_data) +static int __vc_get_tts_audio_format_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int *rate, int *channel, int *audio_type, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_get_tts_audio_format_cb"); @@ -703,9 +706,9 @@ static int __vc_get_tts_audio_format_cb(rpc_port_stub_vc_context_h context, int return ret; } -int vcd_tidl_open_connection() +int vcd_client_tidl_open_connection() { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_open_connection"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_client_tidl_open_connection"); g_vc_callback.create = __vc_create_cb; g_vc_callback.terminate = __vc_terminate_cb; @@ -731,7 +734,7 @@ int vcd_tidl_open_connection() g_vc_callback.get_tts_audio_format = __vc_get_tts_audio_format_cb; int ret = -1; - ret = rpc_port_stub_vc_register(&g_vc_callback, NULL); + ret = rpc_port_stub_vcd_stub_vc_register(&g_vc_callback, NULL); if (VCD_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to register TIDL callbacks. ret(%d)", ret); return VCD_ERROR_OPERATION_FAILED; @@ -740,10 +743,10 @@ int vcd_tidl_open_connection() return VCD_ERROR_NONE; } -int vcd_tidl_close_connection() +int vcd_client_tidl_close_connection() { SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_close_connection"); - rpc_port_stub_vc_unregister(); + rpc_port_stub_vcd_stub_vc_unregister(); return VCD_ERROR_NONE; } @@ -791,7 +794,7 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type) return -1; } - rpc_port_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); return VCD_ERROR_NONE; } @@ -827,7 +830,7 @@ int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) bundle_add_str(bundle_data, VC_BUNDLE_REASON, reason_char); bundle_add_str(bundle_data, VC_BUNDLE_ERR_MSG, err_msg); - rpc_port_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); return VCD_ERROR_NONE; } @@ -875,7 +878,7 @@ int vcdc_send_manager_pid(int manager_pid) bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char); bundle_add_str(bundle_data, VC_BUNDLE_MANAGER_PID, mgrpid_char); - rpc_port_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); bundle_free(bundle_data); } @@ -904,11 +907,11 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send feedback streaming to app(%d), utt_id(%d), event(%d), length(%d)", pid, utt_id, event, len); - rpc_port_stub_array_char_h arr_char = NULL; - rpc_port_stub_array_char_create(&arr_char); - rpc_port_stub_array_char_set(arr_char, buffer, len); + rpc_port_stub_vcd_stub_array_char_h arr_char = NULL; + rpc_port_stub_vcd_stub_array_char_create(&arr_char); + rpc_port_stub_vcd_stub_array_char_set(arr_char, buffer, len); - rpc_port_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len); + rpc_port_stub_vcd_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len); return VCD_ERROR_NONE; } @@ -955,11 +958,10 @@ int vcd_tidl_open_connection() return VCD_ERROR_OPERATION_FAILED; } - // TODO: uncomment after client done - // if (0 != vcd_client_tidl_open_connection()) { - // SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to client"); - // return VCD_ERROR_OPERATION_FAILED; - // } + if (0 != vcd_client_tidl_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to client"); + return VCD_ERROR_OPERATION_FAILED; + } if (0 != vcd_widget_tidl_open_connection()) { SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to widget"); @@ -978,11 +980,10 @@ int vcd_tidl_close_connection() return VCD_ERROR_OPERATION_FAILED; } - // TODO: uncomment after client done - // if (0 != vcd_client_tidl_close_connection()) { - // SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to client"); - // return VCD_ERROR_OPERATION_FAILED; - // } + if (0 != vcd_client_tidl_close_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to client"); + return VCD_ERROR_OPERATION_FAILED; + } if (0 != vcd_widget_tidl_close_connection()) { SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to widget"); @@ -1360,15 +1361,15 @@ int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id bundle_add_str(msg, VC_MANAGER_BUNDLE_UTTID, tmp_utt_id); bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); - rpc_port_stub_array_char_h streaming_data = NULL; - rpc_port_stub_array_char_create(&streaming_data); + rpc_port_stub_vcd_mgr_stub_array_char_h streaming_data = NULL; + rpc_port_stub_vcd_mgr_stub_array_char_create(&streaming_data); if (NULL == streaming_data) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create data handle"); return VCD_ERROR_OUT_OF_MEMORY; } if (NULL != buffer && 0 < len) { - rpc_port_stub_array_char_set(streaming_data, (char*)buffer, len); + rpc_port_stub_vcd_mgr_stub_array_char_set(streaming_data, (char*)buffer, len); } else { SLOG(LOG_ERROR, TAG_VCD, "[TIDL] buffer is empty"); } @@ -1382,29 +1383,29 @@ int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id if (NULL == mgr_tidl_info) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info. pid(%d)", pid); pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - rpc_port_stub_array_char_destroy(streaming_data); + rpc_port_stub_vcd_mgr_stub_array_char_destroy(streaming_data); bundle_free(msg); return VCD_ERROR_OPERATION_FAILED; } - rpc_port_stub_vc_mgr_send_buffer_cb_h handle = mgr_tidl_info->send_buffer_cb; + rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h handle = mgr_tidl_info->send_buffer_cb; if (NULL == handle) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - rpc_port_stub_array_char_destroy(streaming_data); + rpc_port_stub_vcd_mgr_stub_array_char_destroy(streaming_data); bundle_free(msg); return VCD_ERROR_OPERATION_FAILED; } - if (0 != rpc_port_stub_vc_mgr_send_buffer_cb_invoke(handle, streaming_data, msg)) { + if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_invoke(handle, streaming_data, msg)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - rpc_port_stub_array_char_destroy(streaming_data); + rpc_port_stub_vcd_mgr_stub_array_char_destroy(streaming_data); bundle_free(msg); return VCD_ERROR_OPERATION_FAILED; } pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - rpc_port_stub_array_char_destroy(streaming_data); + rpc_port_stub_vcd_mgr_stub_array_char_destroy(streaming_data); bundle_free(msg); return VCD_ERROR_NONE; @@ -1426,7 +1427,7 @@ void vcdc_send_request_set_foreground(int pid, int value) return; } - rpc_port_proxy_vcd_mgr_invoke_set_foreground(mgr_tidl_info->rpc_h, pid, value); + rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_set_foreground(mgr_tidl_info->rpc_h, pid, value); SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request set foreground"); } @@ -1448,7 +1449,7 @@ int vcdc_send_request_get_private_data(int pid, const char* key, char** data) } char *tmp = NULL; - int ret = rpc_port_proxy_vcd_mgr_invoke_get_private_data(mgr_tidl_info->rpc_h, pid, key, &tmp); + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_get_private_data(mgr_tidl_info->rpc_h, pid, key, &tmp); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request vcd manager get private data : Fail to invoke message, error(%d)", ret); return ret; @@ -1476,7 +1477,7 @@ int vcdc_send_request_auth_enable(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vcd_mgr_invoke_auth_enable(mgr_tidl_info->rpc_h, pid); + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_enable(mgr_tidl_info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth enable : Fail to invoke message, error(%d)", ret); return ret; @@ -1502,7 +1503,7 @@ int vcdc_send_request_auth_disable(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vcd_mgr_invoke_auth_disable(mgr_tidl_info->rpc_h, pid); + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_disable(mgr_tidl_info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth disable : Fail to invoke message, error(%d)", ret); return ret; @@ -1528,7 +1529,7 @@ int vcdc_send_request_auth_start(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vcd_mgr_invoke_auth_start(mgr_tidl_info->rpc_h, pid); + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_start(mgr_tidl_info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth start : Fail to invoke message, error(%d)", ret); return ret; @@ -1554,7 +1555,7 @@ int vcdc_send_request_auth_stop(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vcd_mgr_invoke_auth_stop(mgr_tidl_info->rpc_h, pid); + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_stop(mgr_tidl_info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth stop : Fail to invoke message, error(%d)", ret); return ret; @@ -1580,7 +1581,7 @@ int vcdc_send_request_auth_cancel(int pid) return VC_ERROR_OPERATION_FAILED; } - int ret = rpc_port_proxy_vcd_mgr_invoke_auth_cancel(mgr_tidl_info->rpc_h, pid); + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_cancel(mgr_tidl_info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth cancel : Fail to invoke message, error(%d)", ret); return ret; @@ -1607,7 +1608,7 @@ int vcdc_send_asr_result(int pid, int event, const char* asr_result, int cmd_typ } bool temp; - int ret = rpc_port_proxy_vcd_widget_invoke_send_asr_result(widget_tidl_info->rpc_h, pid, event, asr_result, &temp); + int ret = rpc_port_proxy_vcd_widget_proxy_vcd_widget_invoke_send_asr_result(widget_tidl_info->rpc_h, pid, event, asr_result, &temp); if (RPC_PORT_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request vcd widget send asr result : Fail to invoke message, error(%d)", ret); return ret; @@ -1622,7 +1623,7 @@ int vcdc_send_asr_result(int pid, int event, const char* asr_result, int cmd_typ /* * Tidl for manager */ -static void __mgr_on_connected(rpc_port_proxy_vcd_mgr_h h, void *user_data) +static void __mgr_on_connected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) { manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); @@ -1637,7 +1638,7 @@ static void __mgr_on_connected(rpc_port_proxy_vcd_mgr_h h, void *user_data) SLOG(LOG_INFO, TAG_VCD, "Connected to manager"); } -static void __mgr_on_disconnected(rpc_port_proxy_vcd_mgr_h h, void *user_data) +static void __mgr_on_disconnected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) { manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); @@ -1652,7 +1653,7 @@ static void __mgr_on_disconnected(rpc_port_proxy_vcd_mgr_h h, void *user_data) SLOG(LOG_INFO, TAG_VCD, "Disonnected to manager"); } -static void __mgr_on_rejected(rpc_port_proxy_vcd_mgr_h h, void *user_data) +static void __mgr_on_rejected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) { manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); @@ -1666,17 +1667,17 @@ static void __mgr_on_rejected(rpc_port_proxy_vcd_mgr_h h, void *user_data) SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Rejected from manager"); } -static rpc_port_proxy_vcd_mgr_h __mgr_create_rpc_port(const char* engine_app_id) +static rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h __mgr_create_rpc_port(const char* engine_app_id) { SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] __mgr_create_rpc_port"); - rpc_port_proxy_vcd_mgr_callback_s rpc_callback = { + rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_callback_s rpc_callback = { .connected = __mgr_on_connected, .disconnected = __mgr_on_disconnected, .rejected = __mgr_on_rejected }; - rpc_port_proxy_vcd_mgr_h handle = NULL; - if (0 != rpc_port_proxy_vcd_mgr_create(engine_app_id, &rpc_callback, NULL, &handle)) { + rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h handle = NULL; + if (0 != rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_create(engine_app_id, &rpc_callback, NULL, &handle)) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create proxy"); return NULL; } @@ -1684,11 +1685,11 @@ static rpc_port_proxy_vcd_mgr_h __mgr_create_rpc_port(const char* engine_app_id) return handle; } -static void __vc_mgr_create_cb(rpc_port_stub_vc_mgr_context_h context, void *user_data) +static void __vc_mgr_create_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, void *user_data) { char *sender = NULL; - rpc_port_stub_vc_mgr_context_get_sender(context, &sender); + rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); if (!sender){ SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); return; @@ -1699,7 +1700,7 @@ static void __vc_mgr_create_cb(rpc_port_stub_vc_mgr_context_h context, void *use free(sender); } -static void __vc_mgr_terminate_cb(rpc_port_stub_vc_mgr_context_h context, void *user_data) +static void __vc_mgr_terminate_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, void *user_data) { pthread_mutex_lock(&g_mgr_tidl_info_mutex); manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); @@ -1730,7 +1731,7 @@ static void __vc_mgr_terminate_cb(rpc_port_stub_vc_mgr_context_h context, void * char *sender = NULL; - rpc_port_stub_vc_mgr_context_get_sender(context, &sender); + rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); if (!sender) return; @@ -1739,7 +1740,7 @@ static void __vc_mgr_terminate_cb(rpc_port_stub_vc_mgr_context_h context, void * free(sender); } -static void __vc_mgr_register_cb_cb(rpc_port_stub_vc_mgr_context_h context, int pid, rpc_port_stub_vc_mgr_notify_cb_h notify_callback, rpc_port_stub_vc_mgr_send_buffer_cb_h send_buffer_callback, void *user_data) +static void __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h notify_callback, rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h send_buffer_callback, void *user_data) { pthread_mutex_lock(&g_mgr_tidl_info_mutex); SLOG(LOG_INFO, TAG_VCD, "@@@ VC MANAGER REGISTER CALLBACK"); @@ -1762,7 +1763,7 @@ static void __vc_mgr_register_cb_cb(rpc_port_stub_vc_mgr_context_h context, int } char *sender = NULL; - rpc_port_stub_vc_mgr_context_get_sender(context, &sender); + rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); if (!sender){ SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); @@ -1799,7 +1800,7 @@ static void __vc_mgr_register_cb_cb(rpc_port_stub_vc_mgr_context_h context, int SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static int __vc_mgr_initialize_cb(rpc_port_stub_vc_mgr_context_h context, int pid, int audio_streaming_mode, int *service_state, int *foreground, int *daemon_pid, void *user_data) +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"); @@ -1820,7 +1821,7 @@ static int __vc_mgr_initialize_cb(rpc_port_stub_vc_mgr_context_h context, int p return ret; } -static int __vc_mgr_finalize_cb(rpc_port_stub_vc_mgr_context_h context, int pid, void *user_data) +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); @@ -1837,7 +1838,7 @@ static int __vc_mgr_finalize_cb(rpc_port_stub_vc_mgr_context_h context, int pid return ret; } -static int __vc_mgr_set_command_cb(rpc_port_stub_vc_mgr_context_h context, int pid, void *user_data) +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); @@ -1855,7 +1856,7 @@ static int __vc_mgr_set_command_cb(rpc_port_stub_vc_mgr_context_h context, int return ret; } -static int __vc_mgr_unset_command_cb(rpc_port_stub_vc_mgr_context_h context, int pid, void *user_data) +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); @@ -1873,7 +1874,7 @@ static int __vc_mgr_unset_command_cb(rpc_port_stub_vc_mgr_context_h context, in return ret; } -static int __vc_mgr_set_demandable_client_cb(rpc_port_stub_vc_mgr_context_h context, int pid, void *user_data) +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); @@ -1891,7 +1892,7 @@ static int __vc_mgr_set_demandable_client_cb(rpc_port_stub_vc_mgr_context_h con return ret; } -static int __vc_mgr_set_audio_type_cb(rpc_port_stub_vc_mgr_context_h context, int pid, const char *audio_type, void *user_data) +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); @@ -1909,7 +1910,7 @@ static int __vc_mgr_set_audio_type_cb(rpc_port_stub_vc_mgr_context_h context, i return ret; } -static int __vc_mgr_get_audio_type_cb(rpc_port_stub_vc_mgr_context_h context, int pid, char **audio_type, void *user_data) +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); @@ -1932,7 +1933,7 @@ static int __vc_mgr_get_audio_type_cb(rpc_port_stub_vc_mgr_context_h context, i return ret; } -static void __vc_mgr_set_private_data_cb(rpc_port_stub_vc_mgr_context_h context, int pid, const char *key, const char *data, void *user_data) +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); @@ -1948,7 +1949,7 @@ static void __vc_mgr_set_private_data_cb(rpc_port_stub_vc_mgr_context_h context SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static int __vc_mgr_get_private_data_cb(rpc_port_stub_vc_mgr_context_h context, int pid, const char *key, char **data, void *user_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); @@ -1974,7 +1975,7 @@ static int __vc_mgr_get_private_data_cb(rpc_port_stub_vc_mgr_context_h context, return ret; } -static int __vc_mgr_set_client_info_cb(rpc_port_stub_vc_mgr_context_h context, int pid, void *user_data) +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); @@ -1992,7 +1993,7 @@ static int __vc_mgr_set_client_info_cb(rpc_port_stub_vc_mgr_context_h context, return ret; } -static int __vc_mgr_set_domain_cb(rpc_port_stub_vc_mgr_context_h context, int pid, const char *domain, void *user_data) +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); @@ -2010,7 +2011,7 @@ static int __vc_mgr_set_domain_cb(rpc_port_stub_vc_mgr_context_h context, int p return ret; } -static void __vc_mgr_do_action_cb(rpc_port_stub_vc_mgr_context_h context, int pid, int type, const char *send_event, void *user_data) +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); @@ -2025,7 +2026,7 @@ static void __vc_mgr_do_action_cb(rpc_port_stub_vc_mgr_context_h context, int p SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static int __vc_mgr_start_cb(rpc_port_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) +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) { SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager start"); SLOG(LOG_INFO, TAG_VCD, "[IN] vcd check enabled or disabled command types. disabled cmd type(%d)", disabled_cmd_type); @@ -2046,7 +2047,7 @@ static int __vc_mgr_start_cb(rpc_port_stub_vc_mgr_context_h context, int pid, i return ret; } -static int __vc_mgr_stop_cb(rpc_port_stub_vc_mgr_context_h context, int pid, void *user_data) +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); @@ -2065,7 +2066,7 @@ static int __vc_mgr_stop_cb(rpc_port_stub_vc_mgr_context_h context, int pid, vo return ret; } -static int __vc_mgr_cancel_cb(rpc_port_stub_vc_mgr_context_h context, int pid, void *user_data) +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); @@ -2083,7 +2084,7 @@ static int __vc_mgr_cancel_cb(rpc_port_stub_vc_mgr_context_h context, int pid, return ret; } -static void __vc_mgr_set_audio_streaming_mode_cb(rpc_port_stub_vc_mgr_context_h context, int pid, int mode, void *user_data) +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); @@ -2093,7 +2094,7 @@ static void __vc_mgr_set_audio_streaming_mode_cb(rpc_port_stub_vc_mgr_context_h SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static void __vc_mgr_send_specific_engine_request_cb(rpc_port_stub_vc_mgr_context_h context, int pid, const char *engine_app_id, const char *event, const char *request, void *user_data) +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"); @@ -2114,7 +2115,7 @@ static void __vc_mgr_send_specific_engine_request_cb(rpc_port_stub_vc_mgr_conte SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static void __vc_mgr_send_result_selection_cb(rpc_port_stub_vc_mgr_context_h context, int pid, void *user_data) +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); @@ -2124,7 +2125,7 @@ static void __vc_mgr_send_result_selection_cb(rpc_port_stub_vc_mgr_context_h co SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vc_mgr_context_h context, int utt_id, int utt_status, void *user_data) +static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, 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 : utt_id(%d), utt_status(%d)", utt_id, utt_status); @@ -2133,14 +2134,14 @@ static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vc_mgr_context_h co SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static void __vc_mgr_send_audio_streaming_cb(rpc_port_stub_vc_mgr_context_h context, int pid, int event, rpc_port_stub_array_char_h data, void *user_data) +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"); char* buffer = NULL; int len = 0; int ret = -1; - rpc_port_stub_array_char_get(data, &buffer, &len); + rpc_port_stub_vcd_mgr_stub_array_char_get(data, &buffer, &len); SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send audio streaming : pid(%d), event(%d), buffer(%p), len(%d)", pid, event, buffer, len); @@ -2183,7 +2184,7 @@ int vcd_mgr_tidl_open_connection() int ret = -1; int count = 0; while (VC_RETRY_MIN_COUNT >= count) { - ret = rpc_port_stub_vc_mgr_register(&g_mgr_callback, NULL); + ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_register(&g_mgr_callback, NULL); if (0 == ret) { SLOG(LOG_DEBUG, TAG_VCD, "register callback"); return VCD_ERROR_NONE; @@ -2199,7 +2200,7 @@ int vcd_mgr_tidl_open_connection() int vcd_mgr_tidl_close_connection() { SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Close connection"); - rpc_port_stub_vc_mgr_unregister(); + rpc_port_stub_vcd_mgr_stub_vc_mgr_unregister(); return VCD_ERROR_NONE; } @@ -2207,7 +2208,7 @@ int vcd_mgr_tidl_close_connection() /* * Tidl for widget */ -static void __widget_on_connected(rpc_port_proxy_vcd_widget_h h, void *user_data) +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); @@ -2217,7 +2218,7 @@ static void __widget_on_connected(rpc_port_proxy_vcd_widget_h h, void *user_data SLOG(LOG_INFO, TAG_VCD, "Connected to widget"); } -static void __widget_on_disconnected(rpc_port_proxy_vcd_widget_h h, void *user_data) +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); @@ -2227,7 +2228,7 @@ static void __widget_on_disconnected(rpc_port_proxy_vcd_widget_h h, void *user_d SLOG(LOG_INFO, TAG_VCD, "Disonnected to widget"); } -static void __widget_on_rejected(rpc_port_proxy_vcd_widget_h h, void *user_data) +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); @@ -2236,17 +2237,17 @@ static void __widget_on_rejected(rpc_port_proxy_vcd_widget_h h, void *user_data) SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Rejected from widget"); } -static rpc_port_proxy_vcd_widget_h __widget_create_rpc_port(const char* engine_app_id, int pid) +static rpc_port_proxy_vcd_widget_proxy_vcd_widget_h __widget_create_rpc_port(const char* engine_app_id, int pid) { SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] __widget_create_rpc_port"); - rpc_port_proxy_vcd_widget_callback_s rpc_callback = { + rpc_port_proxy_vcd_widget_proxy_vcd_widget_callback_s rpc_callback = { .connected = __widget_on_connected, .disconnected = __widget_on_disconnected, .rejected = __widget_on_rejected }; - rpc_port_proxy_vcd_widget_h handle = NULL; - if (0 != rpc_port_proxy_vcd_widget_create(engine_app_id, &rpc_callback, (void *)pid, &handle)) { + 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)) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create proxy"); return NULL; } @@ -2254,11 +2255,11 @@ static rpc_port_proxy_vcd_widget_h __widget_create_rpc_port(const char* engine_a return handle; } -static void __vc_widget_create_cb(rpc_port_stub_vc_widget_context_h context, void *user_data) +static void __vc_widget_create_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, void *user_data) { char *sender = NULL; - rpc_port_stub_vc_widget_context_get_sender(context, &sender); + rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); if (!sender) { SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); return; @@ -2268,10 +2269,10 @@ static void __vc_widget_create_cb(rpc_port_stub_vc_widget_context_h context, voi free(sender); } -static void __vc_widget_terminate_cb(rpc_port_stub_vc_widget_context_h context, void *user_data) +static void __vc_widget_terminate_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, void *user_data) { void* tag = NULL; - rpc_port_stub_vc_widget_context_get_tag(context, &tag); + rpc_port_stub_vcd_widget_stub_vc_widget_context_get_tag(context, &tag); if (NULL != tag) { int pid = (intptr_t)tag; @@ -2299,7 +2300,7 @@ static void __vc_widget_terminate_cb(rpc_port_stub_vc_widget_context_h context, pthread_mutex_unlock(&g_widget_tidl_info_mutex); char *sender = NULL; - rpc_port_stub_vc_widget_context_get_sender(context, &sender); + rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); if (!sender) return; @@ -2307,10 +2308,10 @@ static void __vc_widget_terminate_cb(rpc_port_stub_vc_widget_context_h context, free(sender); } - rpc_port_stub_vc_widget_context_set_tag(context, NULL); + rpc_port_stub_vcd_widget_stub_vc_widget_context_set_tag(context, NULL); } -static void __vc_widget_register_cb_cb(rpc_port_stub_vc_widget_context_h context, int pid, rpc_port_stub_vc_widget_notify_cb_h notify_callback, void *user_data) +static void __vc_widget_register_cb_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h notify_callback, void *user_data) { pthread_mutex_lock(&g_widget_tidl_info_mutex); SLOG(LOG_INFO, TAG_VCD, "@@@ VC WIDGET REGISTER CALLBACK"); @@ -2332,7 +2333,7 @@ static void __vc_widget_register_cb_cb(rpc_port_stub_vc_widget_context_h contex } char *sender = NULL; - rpc_port_stub_vc_widget_context_get_sender(context, &sender); + rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); if (!sender){ SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); @@ -2363,14 +2364,14 @@ static void __vc_widget_register_cb_cb(rpc_port_stub_vc_widget_context_h contex SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static int __vc_widget_initialize_cb(rpc_port_stub_vc_widget_context_h context, int pid, int *service_state, int *daemon_pid, void *user_data) +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) { SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Initialize"); uintptr_t ptr_pid = pid; int ret = -1; - rpc_port_stub_vc_widget_context_set_tag(context, (void*)ptr_pid); + rpc_port_stub_vcd_widget_stub_vc_widget_context_set_tag(context, (void*)ptr_pid); ret = vcd_server_widget_initialize(pid); if (0 != ret) { @@ -2385,7 +2386,7 @@ static int __vc_widget_initialize_cb(rpc_port_stub_vc_widget_context_h context, return ret; } -static int __vc_widget_finalize_cb(rpc_port_stub_vc_widget_context_h context, int pid, void *user_data) +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); @@ -2403,7 +2404,7 @@ static int __vc_widget_finalize_cb(rpc_port_stub_vc_widget_context_h context, i return ret; } -static int __vc_widget_start_recording_cb(rpc_port_stub_vc_widget_context_h context, int pid, int command, void *user_data) +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); @@ -2421,7 +2422,7 @@ static int __vc_widget_start_recording_cb(rpc_port_stub_vc_widget_context_h cont return ret; } -static int __vc_widget_start_cb(rpc_port_stub_vc_widget_context_h context, int pid, int silence, void *user_data) +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); @@ -2439,7 +2440,7 @@ static int __vc_widget_start_cb(rpc_port_stub_vc_widget_context_h context, int p return ret; } -static int __vc_widget_stop_cb(rpc_port_stub_vc_widget_context_h context, int pid, void *user_data) +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); @@ -2457,7 +2458,7 @@ static int __vc_widget_stop_cb(rpc_port_stub_vc_widget_context_h context, int pi return ret; } -static int __vc_widget_cancel_cb(rpc_port_stub_vc_widget_context_h context, int pid, void *user_data) +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); @@ -2475,7 +2476,7 @@ static int __vc_widget_cancel_cb(rpc_port_stub_vc_widget_context_h context, int return ret; } -static int __vc_widget_enable_asr_result_cb(rpc_port_stub_vc_widget_context_h context, int pid, int enable, void *user_data) +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); @@ -2493,7 +2494,7 @@ static int __vc_widget_enable_asr_result_cb(rpc_port_stub_vc_widget_context_h co return ret; } -static void __vc_widget_set_foreground_cb(rpc_port_stub_vc_widget_context_h context, int pid, int value, void *user_data) +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); @@ -2533,7 +2534,7 @@ int vcd_widget_tidl_open_connection() int ret = -1; int count = 0; while (VC_RETRY_MIN_COUNT >= count) { - ret = rpc_port_stub_vc_widget_register(&g_widget_callback, NULL); + ret = rpc_port_stub_vcd_widget_stub_vc_widget_register(&g_widget_callback, NULL); if (0 == ret) { SLOG(LOG_DEBUG, TAG_VCD, "register callback"); return VCD_ERROR_NONE; @@ -2549,7 +2550,7 @@ int vcd_widget_tidl_open_connection() int vcd_widget_tidl_close_connection() { SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Close connection"); - rpc_port_stub_vc_widget_unregister(); + rpc_port_stub_vcd_widget_stub_vc_widget_unregister(); return VCD_ERROR_NONE; } -- 2.7.4 From 8541ccbde5c5a4cdf3ce45b94278e0fbc34d28fc Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 22 Jun 2022 18:32:41 +0900 Subject: [PATCH 05/16] Rename functions and Implement some TODOs Change-Id: Ic517b7bd84168c53d06dd5b752bee91d418e94a2 Signed-off-by: sooyeon --- server/vcd_client_data.c | 96 ++++++------- server/vcd_client_data.h | 18 +-- server/vcd_dbus.c | 137 ++---------------- server/vcd_dbus.h | 6 +- server/vcd_main.h | 6 - server/vcd_tidl.c | 351 +++++++++++++++++++++-------------------------- server/vcd_tidl.h | 16 +-- 7 files changed, 233 insertions(+), 397 deletions(-) diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 4a05082..25b8882 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -32,7 +32,7 @@ static GSList* g_widget_list = NULL; static manager_info_s g_manager; /* Client IPC info list */ -static GSList* g_client_ipc_info_list = NULL; +static GSList* g_client_tidl_info_list = NULL; /* Manager IPC info */ static manager_tidl_info_s* g_mgr_tidl_info = NULL; @@ -1229,16 +1229,16 @@ int vcd_client_delete(int pid) return 0; } -GSList* __get_client_ipc_info_item(const int pid) +GSList* __get_client_tidl_info_item(const int pid) { GSList *iter = NULL; - client_ipc_info_s *data = NULL; + client_tidl_info_s *data = NULL; - int count = g_slist_length(g_client_ipc_info_list); + int count = g_slist_length(g_client_tidl_info_list); int i; if (0 < count) { - iter = g_slist_nth(g_client_ipc_info_list, 0); + iter = g_slist_nth(g_client_tidl_info_list, 0); for (i = 0; i < count; i++) { if (NULL == iter) break; @@ -1256,16 +1256,16 @@ GSList* __get_client_ipc_info_item(const int pid) return NULL; } -client_ipc_info_s* __get_client_ipc_info_element(int pid) +client_tidl_info_s* __get_client_tidl_info_element(int pid) { GSList *iter = NULL; - client_ipc_info_s *data = NULL; + client_tidl_info_s *data = NULL; - int count = g_slist_length(g_client_ipc_info_list); + int count = g_slist_length(g_client_tidl_info_list); int i; if (0 < count) { - iter = g_slist_nth(g_client_ipc_info_list, 0); + iter = g_slist_nth(g_client_tidl_info_list, 0); for (i = 0; i < count; i++) { if (NULL == iter) break; @@ -1284,19 +1284,19 @@ client_ipc_info_s* __get_client_ipc_info_element(int pid) return NULL; } -int vcd_client_add_ipc_info(int pid) +int vcd_client_add_tidl_info(int pid) { /*Check pid is duplicated*/ - client_ipc_info_s* info = NULL; - info = __get_client_ipc_info_element(pid); + client_tidl_info_s* info = NULL; + info = __get_client_tidl_info_element(pid); if (NULL != info) { - SLOG(LOG_WARN, TAG_VCD, "[Client Data] Client ipc info pid is already registered"); + SLOG(LOG_WARN, TAG_VCD, "[Client Data] Client tidl info pid is already registered"); return VCD_ERROR_NONE; } - SLOG(LOG_INFO, TAG_VCD, "[Client Data] There is no ipc info of pid(%d). Create new one.", pid); - info = (client_ipc_info_s*)calloc(1, sizeof(client_ipc_info_s)); + SLOG(LOG_INFO, TAG_VCD, "[Client Data] There is no tidl info of pid(%d). Create new one.", pid); + info = (client_tidl_info_s*)calloc(1, sizeof(client_tidl_info_s)); if (NULL == info) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory"); return VCD_ERROR_OUT_OF_MEMORY; @@ -1308,29 +1308,29 @@ int vcd_client_add_ipc_info(int pid) info->feedback_cb = NULL; info->feedback_cb_user_data = NULL; - g_client_ipc_info_list = g_slist_append(g_client_ipc_info_list, info); - if (NULL == g_client_ipc_info_list) { - SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to add new client ipc info"); + g_client_tidl_info_list = g_slist_append(g_client_tidl_info_list, info); + if (NULL == g_client_tidl_info_list) { + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to add new client tidl info"); free(info); info = NULL; return -1; } else { - SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client ipc info. pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client tidl info. pid(%d)", pid); } return VCD_ERROR_NONE; } -int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void* user_data) +int vcd_client_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void* user_data) { /*Check pid*/ - client_ipc_info_s* info = NULL; - info = __get_client_ipc_info_element(pid); + client_tidl_info_s* info = NULL; + info = __get_client_tidl_info_element(pid); if (NULL == info) { - SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid); return VCD_ERROR_INVALID_PARAMETER; } @@ -1346,14 +1346,14 @@ int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h return VCD_ERROR_NONE; } -int vcd_client_unset_ipc_notify_cb(int pid) +int vcd_client_unset_tidl_notify_cb(int pid) { /*Check pid*/ - client_ipc_info_s* info = NULL; - info = __get_client_ipc_info_element(pid); + client_tidl_info_s* info = NULL; + info = __get_client_tidl_info_element(pid); if (NULL == info) { - SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid); return VCD_ERROR_INVALID_PARAMETER; } @@ -1370,14 +1370,14 @@ int vcd_client_unset_ipc_notify_cb(int pid) return VCD_ERROR_NONE; } -int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void* user_data) +int vcd_client_set_tidl_feedback_cb(int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void* user_data) { /*Check pid*/ - client_ipc_info_s* info = NULL; - info = __get_client_ipc_info_element(pid); + client_tidl_info_s* info = NULL; + info = __get_client_tidl_info_element(pid); if (NULL == info) { - SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid); return VCD_ERROR_INVALID_PARAMETER; } @@ -1393,14 +1393,14 @@ int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vcd_stub_vc_feedback_c return VCD_ERROR_NONE; } -int vcd_client_unset_ipc_feedback_cb(int pid) +int vcd_client_unset_tidl_feedback_cb(int pid) { /*Check pid*/ - client_ipc_info_s* info = NULL; - info = __get_client_ipc_info_element(pid); + client_tidl_info_s* info = NULL; + info = __get_client_tidl_info_element(pid); if (NULL == info) { - SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no tidl info in the list. pid(%d)", pid); return VCD_ERROR_INVALID_PARAMETER; } @@ -1417,41 +1417,41 @@ int vcd_client_unset_ipc_feedback_cb(int pid) return VCD_ERROR_NONE; } -int vcd_client_delete_ipc_info(int pid) +int vcd_client_delete_tidl_info(int pid) { GSList *tmp = NULL; - client_ipc_info_s* client_ipc_info = NULL; + client_tidl_info_s* client_tidl_info = NULL; /*Get handle*/ - tmp = __get_client_ipc_info_item(pid); + tmp = __get_client_tidl_info_item(pid); if (NULL == tmp) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid); return VCD_ERROR_INVALID_PARAMETER; } /*Free client structure*/ - client_ipc_info = tmp->data; - if (NULL != client_ipc_info) { - free(client_ipc_info); + client_tidl_info = tmp->data; + if (NULL != client_tidl_info) { + free(client_tidl_info); } /*Remove handle from list*/ - g_client_ipc_info_list = g_slist_remove_link(g_client_ipc_info_list, tmp); + g_client_tidl_info_list = g_slist_remove_link(g_client_tidl_info_list, tmp); return 0; } -client_ipc_info_s* vcd_client_get_ipc_info(int pid) +client_tidl_info_s* vcd_client_get_tidl_info(int pid) { - return __get_client_ipc_info_element(pid); + return __get_client_tidl_info_element(pid); } -int vcd_client_get_ipc_list(int** pids, int* pid_count) +int vcd_client_get_tidl_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) return -1; - int count = g_slist_length(g_client_ipc_info_list); + int count = g_slist_length(g_client_tidl_info_list); if (0 == count) return -1; @@ -1464,10 +1464,10 @@ int vcd_client_get_ipc_list(int** pids, int* pid_count) } GSList *iter = NULL; - client_ipc_info_s *data = NULL; + client_tidl_info_s *data = NULL; int i = 0; - iter = g_slist_nth(g_client_ipc_info_list, 0); + iter = g_slist_nth(g_client_tidl_info_list, 0); while (NULL != iter) { data = iter->data; diff --git a/server/vcd_client_data.h b/server/vcd_client_data.h index 2071bd1..3b2f55c 100644 --- a/server/vcd_client_data.h +++ b/server/vcd_client_data.h @@ -76,7 +76,7 @@ typedef struct { void* notify_cb_user_data; rpc_port_stub_vcd_stub_vc_feedback_cb_h feedback_cb; void* feedback_cb_user_data; -} client_ipc_info_s; +} client_tidl_info_s; typedef struct { int pid; @@ -190,21 +190,21 @@ int vcd_client_add(int pid); int vcd_client_delete(int pid); -int vcd_client_add_ipc_info(int pid); +int vcd_client_add_tidl_info(int pid); -int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void* user_data); +int vcd_client_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void* user_data); -int vcd_client_unset_ipc_notify_cb(int pid); +int vcd_client_unset_tidl_notify_cb(int pid); -int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void* user_data); +int vcd_client_set_tidl_feedback_cb(int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void* user_data); -int vcd_client_unset_ipc_feedback_cb(int pid); +int vcd_client_unset_tidl_feedback_cb(int pid); -int vcd_client_delete_ipc_info(int pid); +int vcd_client_delete_tidl_info(int pid); -client_ipc_info_s* vcd_client_get_ipc_info(int pid); +client_tidl_info_s* vcd_client_get_tidl_info(int pid); -int vcd_client_get_ipc_list(int** pids, int* pid_count); +int vcd_client_get_tidl_list(int** pids, int* pid_count); bool vcd_client_is_available(int pid); diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index d16ce39..a00d8bc 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -90,14 +90,14 @@ int vcd_dbus_reconnect() return 0; } -static int __dbus_check() -{ - if (NULL == g_conn_sender || NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection"); - return vcd_dbus_reconnect(); - } - return 0; -} +// static int __dbus_check() +// { +// if (NULL == g_conn_sender || NULL == g_conn_listener) { +// SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection"); +// return vcd_dbus_reconnect(); +// } +// return 0; +// } int vcd_check_dbus_connection() { @@ -108,125 +108,7 @@ int vcd_check_dbus_connection() return 0; } -// int vcdc_send_hello(int pid, vcd_client_type_e type) -// { -// if (0 != __dbus_check()) { -// return VCD_ERROR_OPERATION_FAILED; -// } - -// DBusMessage* msg = NULL; - -// if (VCD_CLIENT_TYPE_NORMAL == type) { -// msg = __get_message(pid, VCD_METHOD_HELLO, VCD_CLIENT_TYPE_NORMAL); -// } else if (VCD_CLIENT_TYPE_WIDGET == type) { -// msg = __get_message(pid, VCD_WIDGET_METHOD_HELLO, VCD_CLIENT_TYPE_WIDGET); -// } else if (VCD_CLIENT_TYPE_MANAGER == type) { -// msg = __get_message(pid, VCD_MANAGER_METHOD_HELLO, VCD_CLIENT_TYPE_MANAGER); -// } else { -// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid"); -// return -1; -// } - -// if (NULL == msg) { -// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to create message"); -// return VCD_ERROR_OUT_OF_MEMORY; -// } - -// dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - -// DBusError err; -// dbus_error_init(&err); - -// DBusMessage* result_msg; -// int result = -1; - -// result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); -// dbus_message_unref(msg); - -// if (dbus_error_is_set(&err)) { -// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] %s", err.message); -// if (NULL != err.name) { -// if (!strcmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN)) { -// SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Unknown service. Client is not available"); -// dbus_error_free(&err); -// return 0; -// } -// } -// dbus_error_free(&err); -// } - -// if (NULL != result_msg) { -// dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID); - -// if (dbus_error_is_set(&err)) { -// SLOG(LOG_ERROR, TAG_VCD, "[Dbus] Get arguments error (%s)", err.message); -// dbus_error_free(&err); -// result = VCD_ERROR_OPERATION_FAILED; -// } - -// dbus_message_unref(result_msg); -// } else { -// SLOG(LOG_WARN, TAG_VCD, "[Dbus] Result message is NULL. Client is not available"); -// } - -// return result; -// } - /* -int vcdc_send_result(int pid, int manager_pid, int cmd_type) -{ - if (0 != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg = NULL; - - SLOG(LOG_INFO, TAG_VCD, "[Dbus] Result command type(%d)", cmd_type); - - switch (cmd_type) { - case VC_COMMAND_TYPE_FOREGROUND: - case VC_COMMAND_TYPE_BACKGROUND: - if (pid == manager_pid) { - // msg = __get_message(pid, VCD_MANAGER_METHOD_RESULT, VCD_CLIENT_TYPE_MANAGER); - vcdc_tidl_send_result(pid, manager_pid, VCD_CLIENT_TYPE_MANAGER); - return 0; - } else { - msg = __get_message(pid, VCD_METHOD_RESULT, VCD_CLIENT_TYPE_NORMAL); - } - break; - case VC_COMMAND_TYPE_WIDGET: - // msg = __get_message(pid, VCD_WIDGET_METHOD_RESULT, VCD_CLIENT_TYPE_WIDGET); - // break; - vcdc_tidl_send_result(pid, manager_pid, VCD_CLIENT_TYPE_WIDGET); - return 0; - case VC_COMMAND_TYPE_SYSTEM: - case VC_COMMAND_TYPE_SYSTEM_BACKGROUND: - case VC_COMMAND_TYPE_EXCLUSIVE: - - default: - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Command type is NOT valid(%d)", cmd_type); - return -1; - } - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_set_no_reply(msg, TRUE); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[Dbus] SUCCESS Send"); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return 0; -} int vcdc_send_manager_pid(int manager_pid) { DBusError err; @@ -259,7 +141,6 @@ int vcdc_send_manager_pid(int manager_pid) return 0; } -*/ int vcdc_send_error_signal(int reason, char *err_msg) { @@ -354,7 +235,7 @@ int vcdc_send_error_signal(int reason, char *err_msg) return 0; } -/* + int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) { if (NULL == err_msg) { diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h index e1abbe3..c4c4ad9 100644 --- a/server/vcd_dbus.h +++ b/server/vcd_dbus.h @@ -30,11 +30,7 @@ int vcd_dbus_close_connection(); int vcd_check_dbus_connection(); -// int vcdc_send_hello(int pid, vcd_client_type_e type); - -//int vcdc_send_result(int pid, int manager_pid, int cmd_type); - -int vcdc_send_error_signal(int reason, char *err_msg); +// int vcdc_send_error_signal(int reason, char *err_msg); // No call in anywhere.. //int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); diff --git a/server/vcd_main.h b/server/vcd_main.h index 7636495..70bcd18 100644 --- a/server/vcd_main.h +++ b/server/vcd_main.h @@ -98,12 +98,6 @@ struct vce_cmd_s { int index; }; -// TODO: move vcd_client_type_e to vcd_tidl.h after migrate from dbus to tidl done -typedef enum { - VCD_CLIENT_TYPE_NORMAL, - VCD_CLIENT_TYPE_WIDGET, - VCD_CLIENT_TYPE_MANAGER -} vcd_client_type_e; #ifdef __cplusplus } diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 8d6f305..d45260d 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -35,7 +35,9 @@ static rpc_port_stub_vcd_widget_stub_vc_widget_callback_s g_widget_callback; static pthread_mutex_t g_widget_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; -static rpc_port_stub_vcd_stub_vc_callback_s g_vc_callback; +static rpc_port_stub_vcd_stub_vc_callback_s g_client_callback; + +static pthread_mutex_t g_client_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; static int g_volume_count = 0; @@ -47,6 +49,8 @@ int vcd_widget_tidl_open_connection(); int vcd_widget_tidl_close_connection(); + + /* for common request */ static void __request_tidl_connect(vcd_client_type_e type, int pid) { @@ -147,31 +151,30 @@ void __send_msg(bundle* msg, vcd_client_type_e type, int pid) return; } pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - // TODO: uncomment after client done - // } else if (VCD_CLIENT_TYPE_NORMAL == type) { - // pthread_mutex_lock(&g_client_tidl_info_mutex); - - // SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); - // client_tidl_info_s* client_tidl_info = vcd_client_client_get_tidl_info(pid); - // if (NULL == client_tidl_info) { - // SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - // pthread_mutex_unlock(&g_client_tidl_info_mutex); - // return; - // } - - // rpc_port_stub_vc_client_notify_cb_h handle = client_tidl_info->notify_cb; - // if (NULL == handle) { - // SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - // pthread_mutex_unlock(&g_client_tidl_info_mutex); - // return; - // } - - // if (0 != rpc_port_stub_vc_client_notify_cb_invoke(handle, msg)) { - // SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - // pthread_mutex_unlock(&g_client_tidl_info_mutex); - // return; - // } - // pthread_mutex_unlock(&g_client_tidl_info_mutex); + } else if (VCD_CLIENT_TYPE_NORMAL == type) { + pthread_mutex_lock(&g_client_tidl_info_mutex); + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); + client_tidl_info_s* client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + rpc_port_stub_vcd_stub_vc_notify_cb_h handle = client_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(handle, pid, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + pthread_mutex_unlock(&g_client_tidl_info_mutex); } else if (VCD_CLIENT_TYPE_WIDGET == type) { pthread_mutex_lock(&g_widget_tidl_info_mutex); @@ -230,51 +233,36 @@ void __send_signal(bundle* msg) } pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - GSList *iter = NULL; - - // TODO: uncomment after client done - // pthread_mutex_lock(&g_client_tidl_info_mutex); - // GSList* client_list = vcd_client_client_get_tidl_info_list(); - - // int count = g_slist_length(g_client_ipc_info_list); - // int i; - - // client_tidl_info_s *client_tidl_info = NULL; - - // if (0 < count) { - // iter = g_slist_nth(client_list, 0); - // for (i = 0; i < count; i++) { - // if (NULL == iter) { - // SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] client list iterator broken"); - // break; - // } - - // client_tidl_info = iter->data; - - // if (NULL == client_tidl_info) { - // SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] client list data broken"); - // break; - // } + pthread_mutex_lock(&g_client_tidl_info_mutex); + // get all pids + int* client_list = NULL; + int client_count = 0; + int ret = -1; + ret = vcd_client_get_tidl_list(&client_list, &client_count); - // SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); + client_tidl_info_s* client_tidl_info; + int pid = -1; - // rpc_port_stub_vc_client_notify_cb_h handle = client_tidl_info->notify_cb; - // if (NULL == handle) { - // SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - // break; - // } + if (0 == ret && 0 < client_count) { + for (int i = 0 ; i < client_count ; i++) { + pid = client_list[i]; - // if (0 != rpc_port_stub_vc_client_notify_cb_invoke(handle, msg)) { - // SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - // break; - // } + client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); + continue; + } - // iter = g_slist_next(iter); - // } - // } - // pthread_mutex_unlock(&g_client_tidl_info_mutex); + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(client_tidl_info->notify_cb, pid, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + continue; + } + } + } + pthread_mutex_unlock(&g_client_tidl_info_mutex); pthread_mutex_lock(&g_widget_tidl_info_mutex); + GSList *iter = NULL; GSList* widget_list = vcd_client_widget_get_tidl_info_list(); int count = g_slist_length(widget_list); @@ -350,13 +338,13 @@ static void __vc_register_notify_cb_cb(rpc_port_stub_vcd_stub_vc_context_h conte } int ret = -1; - ret = vcd_client_add_ipc_info(pid); + ret = vcd_client_add_tidl_info(pid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info."); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); return ; } - ret = vcd_client_set_ipc_notify_cb(pid, callback, user_data); + ret = vcd_client_set_tidl_notify_cb(pid, callback, user_data); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); } else { @@ -374,13 +362,13 @@ static int __vc_register_notify_cb_sync_cb(rpc_port_stub_vcd_stub_vc_context_h c } int ret = -1; - ret = vcd_client_add_ipc_info(pid); + ret = vcd_client_add_tidl_info(pid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info."); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); return ret; } - ret = vcd_client_set_ipc_notify_cb(pid, callback, user_data); + ret = vcd_client_set_tidl_notify_cb(pid, callback, user_data); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); } else { @@ -400,13 +388,13 @@ static void __vc_register_feedback_cb_cb(rpc_port_stub_vcd_stub_vc_context_h con } int ret = -1; - ret = vcd_client_add_ipc_info(pid); + ret = vcd_client_add_tidl_info(pid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info."); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); return ; } - ret = vcd_client_set_ipc_feedback_cb(pid, callback, user_data); + ret = vcd_client_set_tidl_feedback_cb(pid, callback, user_data); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback."); } else { @@ -424,13 +412,13 @@ static int __vc_register_feedback_cb_sync_cb(rpc_port_stub_vcd_stub_vc_context_h } int ret = -1; - ret = vcd_client_add_ipc_info(pid); + ret = vcd_client_add_tidl_info(pid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info."); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); return ret; } - ret = vcd_client_set_ipc_feedback_cb(pid, callback, user_data); + ret = vcd_client_set_tidl_feedback_cb(pid, callback, user_data); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback."); } else { @@ -710,31 +698,31 @@ int vcd_client_tidl_open_connection() { SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_client_tidl_open_connection"); - g_vc_callback.create = __vc_create_cb; - g_vc_callback.terminate = __vc_terminate_cb; - g_vc_callback.register_notify_cb = __vc_register_notify_cb_cb; - g_vc_callback.register_notify_cb_sync = __vc_register_notify_cb_sync_cb; - g_vc_callback.register_feedback_cb = __vc_register_feedback_cb_cb; - g_vc_callback.register_feedback_cb_sync = __vc_register_feedback_cb_sync_cb; - g_vc_callback.initialize = __vc_initialize_cb; - g_vc_callback.finalize = __vc_finalize_cb; - g_vc_callback.set_command = __vc_set_command_cb; - g_vc_callback.unset_command = __vc_unset_command_cb; - g_vc_callback.set_foreground = __vc_set_foreground_cb; - g_vc_callback.set_server_dialog = __vc_set_server_dialog_cb; - g_vc_callback.request_dialog = __vc_request_dialog_cb; - g_vc_callback.is_system_command_valid = __vc_is_system_command_valid_cb; - g_vc_callback.auth_enable = __vc_auth_enable_cb; - g_vc_callback.auth_disable = __vc_auth_disable_cb; - g_vc_callback.auth_start = __vc_auth_start_cb; - g_vc_callback.auth_stop = __vc_auth_stop_cb; - g_vc_callback.auth_cancel = __vc_auth_cancel_cb; - g_vc_callback.request_tts = __vc_request_tts_cb; - g_vc_callback.cancel_tts = __vc_cancel_tts_cb; - g_vc_callback.get_tts_audio_format = __vc_get_tts_audio_format_cb; + g_client_callback.create = __vc_create_cb; + g_client_callback.terminate = __vc_terminate_cb; + g_client_callback.register_notify_cb = __vc_register_notify_cb_cb; + g_client_callback.register_notify_cb_sync = __vc_register_notify_cb_sync_cb; + g_client_callback.register_feedback_cb = __vc_register_feedback_cb_cb; + g_client_callback.register_feedback_cb_sync = __vc_register_feedback_cb_sync_cb; + g_client_callback.initialize = __vc_initialize_cb; + g_client_callback.finalize = __vc_finalize_cb; + g_client_callback.set_command = __vc_set_command_cb; + g_client_callback.unset_command = __vc_unset_command_cb; + g_client_callback.set_foreground = __vc_set_foreground_cb; + g_client_callback.set_server_dialog = __vc_set_server_dialog_cb; + g_client_callback.request_dialog = __vc_request_dialog_cb; + g_client_callback.is_system_command_valid = __vc_is_system_command_valid_cb; + g_client_callback.auth_enable = __vc_auth_enable_cb; + g_client_callback.auth_disable = __vc_auth_disable_cb; + g_client_callback.auth_start = __vc_auth_start_cb; + g_client_callback.auth_stop = __vc_auth_stop_cb; + g_client_callback.auth_cancel = __vc_auth_cancel_cb; + g_client_callback.request_tts = __vc_request_tts_cb; + g_client_callback.cancel_tts = __vc_cancel_tts_cb; + g_client_callback.get_tts_audio_format = __vc_get_tts_audio_format_cb; int ret = -1; - ret = rpc_port_stub_vcd_stub_vc_register(&g_vc_callback, NULL); + ret = rpc_port_stub_vcd_stub_vc_register(&g_client_callback, NULL); if (VCD_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to register TIDL callbacks. ret(%d)", ret); return VCD_ERROR_OPERATION_FAILED; @@ -751,54 +739,6 @@ int vcd_client_tidl_close_connection() return VCD_ERROR_NONE; } -int vcdc_send_result(int pid, int manager_pid, int cmd_type) -{ - client_ipc_info_s* info = vcd_client_get_ipc_info(pid); - if (NULL == info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid); - return VCD_ERROR_INVALID_PARAMETER; - } - - bundle* bundle_data = bundle_create(); - if (NULL == bundle_data) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Result command type(%d)", cmd_type); - - char pid_char[10] = {0}; - snprintf(pid_char, 10, "%d", pid); - bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char); - - switch (cmd_type) { - case VC_COMMAND_TYPE_FOREGROUND: - case VC_COMMAND_TYPE_BACKGROUND: - if (pid == manager_pid) { - bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); - } else { - bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_METHOD_RESULT); - } - break; - case VC_COMMAND_TYPE_WIDGET: - bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT); - break; - case VC_COMMAND_TYPE_SYSTEM: - case VC_COMMAND_TYPE_SYSTEM_BACKGROUND: - case VC_COMMAND_TYPE_EXCLUSIVE: - bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); - break; - - default: - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Command type is NOT valid(%d)", cmd_type); - return -1; - } - - rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); - - return VCD_ERROR_NONE; -} - int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) { if (NULL == err_msg) { @@ -806,14 +746,14 @@ int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) return VCD_ERROR_INVALID_PARAMETER; } - client_ipc_info_s* info = vcd_client_get_ipc_info(pid); + client_tidl_info_s* info = vcd_client_get_tidl_info(pid); if (NULL == info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); return VCD_ERROR_INVALID_PARAMETER; } - bundle* bundle_data = bundle_create(); - if (NULL == bundle_data) { + 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; } @@ -825,12 +765,12 @@ 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(bundle_data, VC_BUNDLE_METHOD, VCD_METHOD_ERROR_TO_APP); - bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char); - bundle_add_str(bundle_data, VC_BUNDLE_REASON, reason_char); - bundle_add_str(bundle_data, VC_BUNDLE_ERR_MSG, err_msg); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_ERROR_TO_APP); + 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); - rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); return VCD_ERROR_NONE; } @@ -843,28 +783,28 @@ int vcdc_send_manager_pid(int manager_pid) int* client_list = NULL; int client_count = 0; int ret = -1; - ret = vcd_client_get_ipc_list(&client_list, &client_count); + 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"); return VCD_ERROR_NONE; } - client_ipc_info_s* info; + client_tidl_info_s* info; int pid = -1; - bundle* bundle_data; + bundle* msg; char pid_char[10] = {0}; char mgrpid_char[10] = {0}; for (int i = 0 ; i < client_count ; i++) { pid = client_list[i]; - info = vcd_client_get_ipc_info(pid); + info = vcd_client_get_tidl_info(pid); if (NULL == info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); continue; } - bundle_data = bundle_create(); - if (NULL == bundle_data) { + msg = bundle_create(); + if (NULL == msg) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); continue; } @@ -874,13 +814,13 @@ int vcdc_send_manager_pid(int manager_pid) snprintf(pid_char, 10, "%d", pid); snprintf(mgrpid_char, 10, "%d", manager_pid); - bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_METHOD_SEND_MANAGER_PID); - bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char); - bundle_add_str(bundle_data, VC_BUNDLE_MANAGER_PID, mgrpid_char); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SEND_MANAGER_PID); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_MANAGER_PID, mgrpid_char); - rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data); + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); - bundle_free(bundle_data); + bundle_free(msg); } return VCD_ERROR_NONE; @@ -893,14 +833,14 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, return VCD_ERROR_INVALID_PARAMETER; } - client_ipc_info_s* info = vcd_client_get_ipc_info(pid); + client_tidl_info_s* info = vcd_client_get_tidl_info(pid); if (NULL == info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); return VCD_ERROR_INVALID_PARAMETER; } - bundle* bundle_data = bundle_create(); - if (NULL == bundle_data) { + 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; } @@ -916,8 +856,7 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, return VCD_ERROR_NONE; } -// TODO: remove _tidl after all dbus removed -int vcdc_tidl_send_hello(int pid, vcd_client_type_e type) +int vcdc_send_hello(int pid, vcd_client_type_e type) { SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send hello"); @@ -927,8 +866,8 @@ int vcdc_tidl_send_hello(int pid, vcd_client_type_e type) snprintf(tmp_pid, 10, "%d", pid); if (VCD_CLIENT_TYPE_NORMAL == type) { - // bundle_add_str(msg, VC_CLIENT_BUNDLE_METHOD, VCD_CLIENT_METHOD_HELLO); - // bundle_add_str(msg, VC_CLIENT_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_HELLO); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); } else if (VCD_CLIENT_TYPE_MANAGER == type) { bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_HELLO); bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); @@ -943,6 +882,7 @@ int vcdc_tidl_send_hello(int pid, vcd_client_type_e type) SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] VCD SEND MESSAGE"); + // TODO: VCD_CLIENT_TYPE_MANAGER?? type?? __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, pid); bundle_free(msg); @@ -1043,22 +983,46 @@ int vcdc_send_show_tooltip(int pid, bool show) return VCD_ERROR_NONE; } -// TODO: remove tidl after all dbus migrate to tidl -int vcdc_tidl_send_result(int pid, int manager_pid, vcd_client_type_e type) +int vcdc_send_result(int pid, int manager_pid, int cmd_type) { SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send result"); + vcd_client_type_e type; 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; + } - if (VCD_CLIENT_TYPE_MANAGER == type) { - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); - // TODO: uncomment after client done - // } else if (VCD_CLIENT_TYPE_NORMAL == type) { - // // bundle_add_str(msg, VC_CLIENT_BUNDLE_METHOD, VCD_METHOD_RESULT); - } else if (VCD_CLIENT_TYPE_WIDGET == type) { - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] client type is NOT valid(%d)", type); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Result command type(%d)", cmd_type); + + switch (cmd_type) { + case VC_COMMAND_TYPE_FOREGROUND: + case VC_COMMAND_TYPE_BACKGROUND: + if (pid == manager_pid) { + type = VCD_CLIENT_TYPE_MANAGER; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); + } else { + type = VCD_CLIENT_TYPE_NORMAL; + char pid_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_RESULT); + } + break; + case VC_COMMAND_TYPE_WIDGET: + type = VCD_CLIENT_TYPE_WIDGET; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT); + break; + case VC_COMMAND_TYPE_SYSTEM: + case VC_COMMAND_TYPE_SYSTEM_BACKGROUND: + case VC_COMMAND_TYPE_EXCLUSIVE: + type = VCD_CLIENT_TYPE_MANAGER; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); + break; + + default: + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Command type is NOT valid(%d)", cmd_type); bundle_free(msg); return VCD_ERROR_INVALID_PARAMETER; } @@ -1165,9 +1129,8 @@ int vcdc_send_service_state(vcd_state_e state) bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_SERVICE_STATE); bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_state); - // TODO: uncomment after client done - // bundle_add_str(msg, VC_CLIENT_BUNDLE_METHOD, VCD_METHOD_SET_SERVICE_STATE); - // bundle_add_str(msg, VC_CLIENT_BUNDLE_MESSAGE, tmp_state); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SET_SERVICE_STATE); + bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SET_SERVICE_STATE); bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_state); @@ -1254,8 +1217,10 @@ int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg) return VCD_ERROR_NONE; } +/* // TODO: remove _tidl after remove dbus // TODO: make client, widget error signal +// But... it seems there is no call of this function.. Need to check. int vcdc_tidl_send_error(int reason, char *err_msg) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL] Send error signal"); @@ -1296,7 +1261,7 @@ int vcdc_tidl_send_error(int reason, char *err_msg) return VCD_ERROR_NONE; } - +*/ int vcdc_send_request_set_private_data(int pid, const char* key, const char* data) { SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Set private data"); @@ -2129,7 +2094,7 @@ static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr { SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send utterance status"); SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send utterance status : utt_id(%d), utt_status(%d)", utt_id, utt_status); - // TODO: send parameter to client + // TODO: send parameter to client?? It seems to send method (no reply) to mgr. Need to check. SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } diff --git a/server/vcd_tidl.h b/server/vcd_tidl.h index 715e3f3..7881923 100644 --- a/server/vcd_tidl.h +++ b/server/vcd_tidl.h @@ -24,24 +24,24 @@ extern "C" { #endif -// typedef enum { -// VCD_CLIENT_TYPE_NORMAL, -// VCD_CLIENT_TYPE_WIDGET, -// VCD_CLIENT_TYPE_MANAGER -// } vcd_client_type_e; +typedef enum { + VCD_CLIENT_TYPE_NORMAL, + VCD_CLIENT_TYPE_WIDGET, + VCD_CLIENT_TYPE_MANAGER +} vcd_client_type_e; int vcd_tidl_open_connection(); int vcd_tidl_close_connection(); -int vcdc_tidl_send_hello(int pid, vcd_client_type_e type); +int vcdc_send_hello(int pid, vcd_client_type_e type); int vcdc_send_set_volume(int manger_pid, float volume); int vcdc_send_show_tooltip(int pid, bool show); -int vcdc_tidl_send_result(int pid, int manager_pid, vcd_client_type_e type); +int vcdc_send_result(int pid, int manager_pid, int cmd_type); int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_result); @@ -51,7 +51,7 @@ int vcdc_send_result_to_manager(int manger_pid, int result_type); int vcdc_send_speech_detected(int manger_pid); -int vcdc_tidl_send_error(int reason, char *err_msg); +// int vcdc_tidl_send_error(int reason, char *err_msg); int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg); -- 2.7.4 From 5debf3afb46e8f70660fde04bfb7a93ec27c7c3d Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 22 Jun 2022 18:45:50 +0900 Subject: [PATCH 06/16] Disconnection dbus relationship Change-Id: Ia8bfdf75fb6b8aad8bbcd49968e3185434cdfe1e Signed-off-by: sooyeon --- server/CMakeLists.txt | 4 ++-- server/vcd_dbus.c | 4 ++-- server/vcd_dbus.h | 8 -------- server/vcd_dbus_server.c | 4 ++-- server/vcd_engine_agent.c | 2 +- server/vcd_recorder.c | 1 - server/vcd_server.c | 24 +++++++++++++----------- server/vce.c | 2 +- 8 files changed, 21 insertions(+), 28 deletions(-) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index c269a11..2cda660 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -9,8 +9,8 @@ SET(SRCS vcd_client_data.c vcd_server_data.cpp vcd_config.c - vcd_dbus_server.c - vcd_dbus.c +# vcd_dbus_server.c +# vcd_dbus.c vcd_tidl.c vcd_stub.c vcd_mgr_stub.c diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index a00d8bc..29b6d75 100755 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -16,8 +16,8 @@ #include #include "vcd_client_data.h" -#include "vcd_dbus.h" -#include "vcd_dbus_server.h" +// #include "vcd_dbus.h" +// #include "vcd_dbus_server.h" #include "vcd_tidl.h" #include "vcd_main.h" diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h index c4c4ad9..88fd974 100644 --- a/server/vcd_dbus.h +++ b/server/vcd_dbus.h @@ -30,14 +30,6 @@ int vcd_dbus_close_connection(); int vcd_check_dbus_connection(); -// int vcdc_send_error_signal(int reason, char *err_msg); // No call in anywhere.. - -//int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); - -// int vcdc_send_manager_pid(int manager_pid); - -/* for TTS feedback */ -//int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); #ifdef __cplusplus } diff --git a/server/vcd_dbus_server.c b/server/vcd_dbus_server.c index d5d4ac1..4556102 100755 --- a/server/vcd_dbus_server.c +++ b/server/vcd_dbus_server.c @@ -16,9 +16,9 @@ #include "vcd_client_data.h" -#include "vcd_dbus.h" +// #include "vcd_dbus.h" #include "vcd_tidl.h" -#include "vcd_dbus_server.h" +// #include "vcd_dbus_server.h" #include "vcd_main.h" #include "vcd_server.h" #include "vcd_config.h" diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 6e45a4d..7b89164 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -23,7 +23,7 @@ #include "vcd_engine_agent.h" #include "vcd_main.h" #include "vcd_recorder.h" -#include "vcd_dbus.h" +// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vce_internal.h" diff --git a/server/vcd_recorder.c b/server/vcd_recorder.c index 9c4845f..0dd1394 100644 --- a/server/vcd_recorder.c +++ b/server/vcd_recorder.c @@ -21,7 +21,6 @@ #include "vcd_client_data.h" #include "vcd_config.h" -#include "vcd_dbus.h" #include "vcd_tidl.h" #include "vcd_engine_agent.h" #include "vcd_recorder.h" diff --git a/server/vcd_server.c b/server/vcd_server.c index ae36531..a9beceb 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -28,7 +28,7 @@ #include "vcd_engine_agent.h" #include "vcd_config.h" #include "vcd_recorder.h" -#include "vcd_dbus.h" +// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vce_internal.h" @@ -1341,13 +1341,14 @@ int vcd_initialize(vce_request_callback_s *callback) // if (TRUE == __is_default_engine()) { /* Open dbus connection */ - if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to open connection"); - if (TRUE != vcd_finalize()) { - SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); - } - return VCD_ERROR_OPERATION_FAILED; - } + // TODO: remove + // if (0 != vcd_dbus_open_connection()) { + // SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to open connection"); + // if (TRUE != vcd_finalize()) { + // SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); + // } + // return VCD_ERROR_OPERATION_FAILED; + // } /* Open tidl connection */ if (0 != vcd_tidl_open_connection()) { @@ -1437,9 +1438,10 @@ bool vcd_finalize() } /* Close dbus connection */ - if (0 != vcd_dbus_close_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to close connection"); - } + // TODO: remove + // if (0 != vcd_dbus_close_connection()) { + // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to close connection"); + // } /* Close tidl connection */ if (0 != vcd_tidl_close_connection()) { diff --git a/server/vce.c b/server/vce.c index 5353ea0..e4b359b 100644 --- a/server/vce.c +++ b/server/vce.c @@ -19,7 +19,7 @@ #include #include #include -#include "vcd_dbus.h" +// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vcd_main.h" #include "vcd_server.h" -- 2.7.4 From 74ed32b827f73b53356317b0e9ece9cd7e0dd356 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 23 Jun 2022 10:47:28 +0900 Subject: [PATCH 07/16] Implement functions related to auth, set_foreground, send_utterance_status Change-Id: Ieddc83ffd9e76e75eedf28416dd21e952a6419ba Signed-off-by: sooyeon --- client/vc_mgr.c | 24 --------- client/vc_mgr_tidl.c | 3 +- client/vc_tidl.c | 11 ++++ server/vcd_server.c | 16 ------ server/vcd_tidl.c | 149 ++++++++++++++++++++++++++++++++------------------- server/vcd_tidl.h | 14 +++++ tidl/vc_mgr.tidl | 2 +- 7 files changed, 121 insertions(+), 98 deletions(-) diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 6769fa1..2a31598 100755 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -278,12 +278,6 @@ int vc_mgr_initialize(void) return VC_ERROR_NONE; } - // TODO: remove dbus after migrate from dbus to tidl done - if (0 != vc_mgr_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to open dbus connection"); - return VC_ERROR_OPERATION_FAILED; - } - if (0 != vc_mgr_tidl_open_connection()) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to open tidl connection"); return VC_ERROR_OPERATION_FAILED; @@ -416,10 +410,6 @@ int vc_mgr_deinitialize(void) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to release VC mgr player(%d)", ret); } */ - // TODO: remove dbus after migrate from dbus to tidl done - if (0 != vc_mgr_dbus_close_connection()) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to close connection"); - } if (0 != vc_mgr_tidl_close_connection()) { SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to close connection"); @@ -549,20 +539,6 @@ static Eina_Bool __send_hello_message(void *data) } } - // TODO: remove dbus after migrate from dbus to tidl done - if (0 != vc_mgr_dbus_request_hello()) { - if (g_dbus_send_hello_count == 20) { - g_dbus_send_hello_count = 0; - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request hello !! send error to manager"); - __vc_mgr_cb_error(VC_ERROR_TIMED_OUT, -1, "voice_framework.error.vcfw.connect_engine_fail"); - g_send_hello_timer = NULL; - return EINA_FALSE; - } else { - g_dbus_send_hello_count++; - return EINA_TRUE; - } - } - SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Connect daemon"); if (NULL == g_request_init_timer) { diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index 3d98e9c..7376fd5 100755 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -276,6 +276,7 @@ static void __notify_cb(void *user_data, bundle *msg) } /* VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT */ // TODO: uncomment this line after vcc done + // NEED2CHECK: when vcc send 'set_foreground', __vcd_mgr_set_foreground_cb will be invoked... // else if (0 == strncmp(VCC_MANAGER_METHOD_SET_FOREGROUND, method, strlen(VCC_MANAGER_METHOD_SET_FOREGROUND))) { // SLOG(LOG_INFO, TAG_VCM, "@@@ Set foreground"); // char* temp_pid = NULL; @@ -1183,7 +1184,7 @@ int vc_mgr_tidl_send_utterance_status(int pid, int utt_id, vc_tts_utterance_stat return VC_ERROR_OPERATION_FAILED; } - rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_utterance_status(g_proxy_tidl_info->rpc_h, utt_id, utt_status); + rpc_port_proxy_vc_mgr_proxy_vc_mgr_invoke_send_utterance_status(g_proxy_tidl_info->rpc_h, pid, utt_id, utt_status); return VC_ERROR_NONE; } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 77ddc1d..9e85e9a 100755 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -220,6 +220,17 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) __vc_cb_error_to_app(atoi(pid), 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!!! */ + char* pid; + char* utt_id; + char* utt_status = NULL; + + bundle_get_str(msg, VC_BUNDLE_PID, &pid); + bundle_get_str(msg, VC_BUNDLE_UTTID, &utt_id); + bundle_get_str(msg, VC_BUNDLE_UTTSTATUS, &utt_status); + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get utterance status : pid(%d), utt_id(%d), utt_status(%d)", atoi(pid), atoi(utt_id), atoi(utt_status)); + __vc_cb_utterance_status(atoi(utt_id), atoi(utt_status)); } /* VC_MANAGER_METHOD_UTTERANCE_STATUS */ else { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg"); diff --git a/server/vcd_server.c b/server/vcd_server.c index a9beceb..a4badcf 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -1340,16 +1340,6 @@ int vcd_initialize(vce_request_callback_s *callback) vcd_client_manager_unset(); // if (TRUE == __is_default_engine()) { - /* Open dbus connection */ - // TODO: remove - // if (0 != vcd_dbus_open_connection()) { - // SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to open connection"); - // if (TRUE != vcd_finalize()) { - // SLOG(LOG_ERROR, TAG_VCD, "[Server Error] Fail to finalize"); - // } - // return VCD_ERROR_OPERATION_FAILED; - // } - /* Open tidl connection */ if (0 != vcd_tidl_open_connection()) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to open tidl connection"); @@ -1437,12 +1427,6 @@ bool vcd_finalize() vcdc_send_service_state(VCD_STATE_NONE); } - /* Close dbus connection */ - // TODO: remove - // if (0 != vcd_dbus_close_connection()) { - // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to close connection"); - // } - /* Close tidl connection */ if (0 != vcd_tidl_close_connection()) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to close connection"); diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index d45260d..6a67e3b 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -504,12 +504,14 @@ static int __vc_set_foreground_cb(rpc_port_stub_vcd_stub_vc_context_h context, i int ret = VCD_ERROR_OPERATION_FAILED; ret = vcd_server_set_foreground(pid, value); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d)", pid); - } else { + if (VCD_ERROR_NONE != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set foreground : pid(%d) ret(%d)", pid, ret); + return ret; } + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d)", pid); + vcdc_send_request_set_foreground(pid, value); + return ret; } @@ -565,85 +567,75 @@ static int __vc_auth_enable_cb(rpc_port_stub_vcd_stub_vc_context_h context, int { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_enable_cb. Send a request to vc_mgr"); - // int ret = VCD_ERROR_OPERATION_FAILED; - // ret = vcdc_send_request_auth_enable(pid); - // if (VCD_ERROR_NONE == ret) { - // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth enable. pid(%d), mgr_pid(%d)", pid, mgr_pid); - // } else { - // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth enable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - // } - - // return ret; + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_enable(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth enable. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth enable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return VCD_ERROR_NONE; + return ret; } static int __vc_auth_disable_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_disable_cb. Send a request to vc_mgr"); - // int ret = VCD_ERROR_OPERATION_FAILED; - // ret = vcdc_send_request_auth_disable(pid); - // if (VCD_ERROR_NONE == ret) { - // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth disable. pid(%d), mgr_pid(%d)", pid, mgr_pid); - // } else { - // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth disable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - // } - - // return ret; + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_disable(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth disable. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth disable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return VCD_ERROR_NONE; + return ret; } static int __vc_auth_start_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_start_cb. Send a request to vc_mgr"); - // int ret = VCD_ERROR_OPERATION_FAILED; - // ret = vcdc_send_request_auth_start(pid); - // if (VCD_ERROR_NONE == ret) { - // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth start. pid(%d), mgr_pid(%d)", pid, mgr_pid); - // } else { - // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth start. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - // } - - // return ret; + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_start(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth start. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth start. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return VCD_ERROR_NONE; + return ret; } static int __vc_auth_stop_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_stop_cb. Send a request to vc_mgr"); - // int ret = VCD_ERROR_OPERATION_FAILED; - // ret = vcdc_send_request_auth_stop(pid); - // if (VCD_ERROR_NONE == ret) { - // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth stop. pid(%d), mgr_pid(%d)", pid, mgr_pid); - // } else { - // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth stop. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - // } - - // return ret; + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_stop(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth stop. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth stop. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return VCD_ERROR_NONE; + return ret; } static int __vc_auth_cancel_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_cancel_cb. Send a request to vc_mgr"); - // int ret = VCD_ERROR_OPERATION_FAILED; - // ret = vcdc_send_request_auth_cancel(pid); - // if (VCD_ERROR_NONE == ret) { - // SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth cancel. pid(%d), mgr_pid(%d)", pid, mgr_pid); - // } else { - // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth cancel. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - // } - - // return ret; + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_cancel(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth cancel. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth cancel. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return VCD_ERROR_NONE; + return ret; } static int __vc_request_tts_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data) @@ -2090,11 +2082,56 @@ static void __vc_mgr_send_result_selection_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int utt_id, int utt_status, void *user_data) +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 : utt_id(%d), utt_status(%d)", utt_id, utt_status); - // TODO: send parameter to client?? It seems to send method (no reply) to mgr. Need to check. + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); + + pthread_mutex_lock(&g_client_tidl_info_mutex); + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); + client_tidl_info_s* client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + rpc_port_stub_vcd_stub_vc_notify_cb_h handle = client_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + bundle* msg = bundle_create(); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + char pid_char[10] = {0}; + char uttid_char[10] = {0}; + char uttstatus_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + snprintf(uttid_char, 10, "%d", utt_id); + snprintf(uttstatus_char, 10, "%d", utt_status); + + bundle_add_str(msg, VC_BUNDLE_METHOD, VC_MANAGER_METHOD_UTTERANCE_STATUS); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_REASON, uttid_char); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, uttstatus_char); + + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(handle, pid, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + bundle_free(msg); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + bundle_free(msg); + pthread_mutex_unlock(&g_client_tidl_info_mutex); SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } diff --git a/server/vcd_tidl.h b/server/vcd_tidl.h index 7881923..e62c242 100644 --- a/server/vcd_tidl.h +++ b/server/vcd_tidl.h @@ -65,6 +65,20 @@ int vcdc_send_request_get_private_data(int pid, const char* key, char** data); int vcdc_send_asr_result(int pid, int event, const char* asr_result, int cmd_type, bool* is_consumed); +void vcdc_send_request_set_foreground(int pid, int value); + + +/* for auth */ +int vcdc_send_request_auth_enable(int pid); + +int vcdc_send_request_auth_disable(int pid); + +int vcdc_send_request_auth_start(int pid); + +int vcdc_send_request_auth_stop(int pid); + +int vcdc_send_request_auth_cancel(int pid); + /* for TTS feedback */ int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_audio_channel_e channel, vce_audio_type_e audio_type); diff --git a/tidl/vc_mgr.tidl b/tidl/vc_mgr.tidl index f790247..b20a6a3 100644 --- a/tidl/vc_mgr.tidl +++ b/tidl/vc_mgr.tidl @@ -22,5 +22,5 @@ interface vc_mgr { void send_specific_engine_request(in int pid, in string engine_app_id, in string event, in string request) async; void send_result_selection(in int pid) async; void send_audio_streaming(in int pid, in int event, array data_in) async; - void send_utterance_status(in int utt_id, in int utt_status) async; + void send_utterance_status(in int pid, in int utt_id, in int utt_status) async; } \ No newline at end of file -- 2.7.4 From de3ba6f6a4bf0e8ac56d89fb832dfdcf96455fcf Mon Sep 17 00:00:00 2001 From: sooyeon Date: Sun, 26 Jun 2022 15:15:35 +0900 Subject: [PATCH 08/16] Add a missing file in CMakeLists and a code to handle TTS feedback data Change-Id: I9e8ef00e6e88a363cfc47578b9e19e7335f3f4c1 Signed-off-by: sooyeon --- client/CMakeLists.txt | 1 + client/vc.c | 1 + client/vc_tidl.c | 21 +++++++++++++++------ server/vcd_tidl.c | 4 ++++ tests/org.tizen.vc-unittests.xml | 2 ++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 0001ef9..63ced4a 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -4,6 +4,7 @@ SET(SRCS vc_client.c # vc_dbus.c vc_tidl.c + vc_proxy.c ../common/vc_cmd_db.c ../common/vc_command.c ../common/vc_command_util.c diff --git a/client/vc.c b/client/vc.c index 0688716..4dbb113 100644 --- a/client/vc.c +++ b/client/vc.c @@ -621,6 +621,7 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread) break; } else { retry_count++; + usleep(200000); } } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 9e85e9a..110440a 100755 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -80,6 +80,8 @@ static char* __get_engine_appid(void) char* appid = strdup(engine_name); + SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); + return appid; } @@ -128,6 +130,8 @@ static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) static rpc_port_proxy_vc_proxy_vc_h __create_rpc_port(int pid, const char* engine_app_id) { + SLOG(LOG_INFO, TAG_VCC, "[INFO] vc __create_rpc_port"); + rpc_port_proxy_vc_proxy_vc_callback_s rpc_callback = { .connected = __on_connected, .disconnected = __on_disconnected, @@ -139,6 +143,7 @@ static rpc_port_proxy_vc_proxy_vc_h __create_rpc_port(int pid, const char* engin if (0 != rpc_port_proxy_vc_proxy_vc_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) { return NULL; } + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Succeed rpc_port_proxy_vc_proxy_vc_create"); return handle; } @@ -240,15 +245,19 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_vc_proxy_array_char_h pcm_data, int len) { // corresponding to listener_event_callback (only for tts_streaming) - SLOG(LOG_DEBUG, TAG_VCC, "__feedback_cb is invoked utt_id(%d) event(%d)", utt_id, event); + SLOG(LOG_DEBUG, TAG_VCC, "__feedback_cb is invoked. utt_id(%d), event(%d), pcm_len(%d)", utt_id, event, len); - // char* utt_id; - // char* event; + char* data_char = NULL; + rpc_port_proxy_vc_proxy_array_char_get(pcm_data, &data_char, &len); - // bundle_get_str(msg, VC_BUNDLE_UTTID, &utt_id); - // bundle_get_str(msg, VC_BUNDLE_FEEDBACK_EVENT, &event); - // __vc_cb_tts_streaming(utt_id, event, buffer, len); /* VCD_METHOD_FEEDBACK_STREAMING */ + __vc_cb_tts_streaming(utt_id, event, data_char, len); + + if (NULL != data_char) { + free(data_char); + data_char = NULL; + } + } static int __create_notify_callback_handle(vc_tidl_info_s* info) diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 6a67e3b..e5905ba 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -845,6 +845,10 @@ int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, rpc_port_stub_vcd_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len); + rpc_port_stub_vcd_stub_array_char_destroy(arr_char); + + bundle_free(msg); + return VCD_ERROR_NONE; } diff --git a/tests/org.tizen.vc-unittests.xml b/tests/org.tizen.vc-unittests.xml index 571a9e9..86f8b8f 100644 --- a/tests/org.tizen.vc-unittests.xml +++ b/tests/org.tizen.vc-unittests.xml @@ -11,5 +11,7 @@ http://tizen.org/privilege/recorder http://tizen.org/privilege/voicecontrol.manager + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/datasharing -- 2.7.4 From d1f51c35b4ec554a34fc4fa2101b26bd6254825d Mon Sep 17 00:00:00 2001 From: sooyeon Date: Mon, 27 Jun 2022 17:12:33 +0900 Subject: [PATCH 09/16] Replace IPC of vc_setting Change-Id: I58f30103efd851762c01e6f2730087364c1b8cf8 Signed-off-by: sooyeon --- client/CMakeLists.txt | 4 +- client/vc_setting.c | 12 +- client/vc_setting_tidl.c | 323 +++++++++++++++++++++++++++++++++++++++++++ client/vc_setting_tidl.h | 41 ++++++ packaging/voice-control.spec | 3 + server/CMakeLists.txt | 1 + server/vcd_client_data.c | 214 ++++++++++++++++++++++++++++ server/vcd_client_data.h | 23 +++ server/vcd_tidl.c | 210 ++++++++++++++++++++++++++++ tidl/vc_setting.tidl | 8 ++ 10 files changed, 833 insertions(+), 6 deletions(-) create mode 100755 client/vc_setting_tidl.c create mode 100755 client/vc_setting_tidl.h create mode 100755 tidl/vc_setting.tidl diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 63ced4a..b5ddb82 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -15,7 +15,9 @@ SET(SRCS ) SET(SETTING_SRCS - vc_setting_dbus.c +# vc_setting_dbus.c + vc_setting_tidl.c + vc_setting_proxy.c vc_setting.c ../common/vc_config_mgr.c ../common/vc_config_parser.c diff --git a/client/vc_setting.c b/client/vc_setting.c index 238480f..c415a77 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -17,7 +17,8 @@ #include "vc_config_mgr.h" #include "vc_main.h" -#include "vc_setting_dbus.h" +// #include "vc_setting_dbus.h" +#include "vc_setting_tidl.h" #include "voice_control_common.h" #include "voice_control_setting.h" @@ -319,19 +320,20 @@ int vc_setting_set_language(const char* language) if (0 != ret) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Result : %d", ret); } else { - if (0 != vc_setting_dbus_open_connection()) { + // TODO: Need to reorder. + if (0 != vc_setting_tidl_open_connection()) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to open connection"); return VC_ERROR_OPERATION_FAILED; } - if (0 != vc_setting_dbus_request_hello()) { + if (0 != vc_setting_tidl_request_hello()) { SLOG(LOG_DEBUG, TAG_VCS, "[DEBUG] Daemon is not available"); } else { - ret = vc_setting_dbus_request_set_language(getpid(), language); + ret = vc_setting_tidl_request_set_language(getpid(), language); SLOG(LOG_DEBUG, TAG_VCS, "[DEBUG] Set default language (%d)", ret); } - if (0 != vc_setting_dbus_close_connection()) { + if (0 != vc_setting_tidl_close_connection()) { SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to close connection"); return VC_ERROR_OPERATION_FAILED; } diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c new file mode 100755 index 0000000..240ef70 --- /dev/null +++ b/client/vc_setting_tidl.c @@ -0,0 +1,323 @@ +/* +* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "vc_command.h" +#include "vc_setting_tidl.h" +#include "vc_setting_proxy.h" +#include "vc_main.h" + +#include + +typedef struct { + int pid; + bool connected; + bool connection_requesting; + bool register_notify_callback_invoked; + + rpc_port_proxy_vc_setting_proxy_vc_setting_h rpc_h; + rpc_port_proxy_vc_setting_proxy_vc_setting_notify_cb_h notify_cb_h; + + char* engine_appid; +} vc_setting_tidl_info_s; + +static GList* g_tidl_infos = NULL; + +extern int __vc_cb_service_state(int state); + + +static vc_setting_tidl_info_s* __get_tidl_info_s(int pid) +{ + // TODO: Hmm.... is this necessary...?? + GList* iter = NULL; + vc_setting_tidl_info_s* info = NULL; + + if (g_list_length(g_tidl_infos) > 0) { + /* Get a first item */ + iter = g_list_first(g_tidl_infos); + + while (NULL != iter) { + info = iter->data; + + if (info->pid == pid) { + return info; + } + + /* Next item */ + iter = g_list_next(iter); + } + } + + return NULL; +} + +static char* __get_engine_appid(void) +{ + char* engine_name = vconf_get_str(VC_ENGINE_DB_DEFAULT); + if (NULL == engine_name) { + SLOG(LOG_WARN, TAG_VCC, "[WARNING] Fail to get engine name. Please use default engine name."); + engine_name = strdup("org.tizen.vc-engine-default"); + } + + char* appid = strdup(engine_name); + + SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid); + + return appid; +} + +static void __on_connected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* user_data) +{ + 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"); + + info->connected = true; + info->connection_requesting = false; + info->register_notify_callback_invoked = false; + + SLOG(LOG_INFO, TAG_VCC, "[INFO] Connected to server"); +} + +static void __on_disconnected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* user_data) +{ + 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"); + + info->connected = false; + info->connection_requesting = false; + info->register_notify_callback_invoked = false; + + /* retry to connect */ + SLOG(LOG_INFO, TAG_VCC, "[INFO] Disconnected to server"); +} + +static void __on_rejected(rpc_port_proxy_vc_setting_proxy_vc_setting_h h, void* user_data) +{ + 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"); + + info->connection_requesting = false; + info->register_notify_callback_invoked = false; + + SLOG(LOG_INFO, TAG_VCC, "[INFO] Rejected from server(%d)", pid); +} + + +static rpc_port_proxy_vc_setting_proxy_vc_setting_h __create_rpc_port(int pid, const char* engine_app_id) +{ + SLOG(LOG_INFO, TAG_VCC, "[INFO] vc setting __create_rpc_port"); + + rpc_port_proxy_vc_setting_proxy_vc_setting_callback_s rpc_callback = { + .connected = __on_connected, + .disconnected = __on_disconnected, + .rejected = __on_rejected + }; + + rpc_port_proxy_vc_setting_proxy_vc_setting_h handle = NULL; + uintptr_t ptr_pid = pid; + if (0 != rpc_port_proxy_vc_setting_proxy_vc_setting_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail rpc_port_proxy_vc_setting_proxy_vc_setting_create"); + return NULL; + } + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Succeed rpc_port_proxy_vc_setting_proxy_vc_setting_create"); + + return handle; +} + +static void __request_tidl_connect(vc_setting_tidl_info_s* info) +{ + if (info->connection_requesting) { + SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_setting_proxy_vc_setting_connect()."); + return ; + } + + int ret = rpc_port_proxy_vc_setting_proxy_vc_setting_connect(info->rpc_h); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret); + return ; + } + + SLOG(LOG_INFO, TAG_VCC, "[INFO] Request connection to stub. ret(%d)", ret); + info->connection_requesting = true; +} + +static void __notify_cb(void* user_data, int pid, bundle* msg) +{ + // corresponding to listener_event_callback + char* method = NULL; + + SLOG(LOG_DEBUG, TAG_VCC, "__notify_cb is invoked pid(%d)", pid); + + bundle_get_str(msg, VC_BUNDLE_METHOD, &method); + + if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO))) { + } /* VCD_METHOD_HELLO */ + else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) { + /* signal!!! */ + char* state = NULL; + bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &state); + if (state) { + __vc_cb_service_state(atoi(state)); + } + } /* VCD_METHOD_SET_SERVICE_STATE */ + else { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg"); + } +} + +static int __create_notify_callback_handle(vc_setting_tidl_info_s* info) +{ + if (NULL != info->notify_cb_h) { + rpc_port_proxy_vc_setting_proxy_vc_setting_notify_cb_dispose(info->rpc_h, info->notify_cb_h); + info->notify_cb_h = NULL; + } + + if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_setting_proxy_vc_setting_notify_cb_create(&info->notify_cb_h)) { + return VC_ERROR_OUT_OF_MEMORY; + } + + rpc_port_proxy_vc_setting_proxy_vc_setting_notify_cb_set_callback(info->notify_cb_h, __notify_cb, NULL); + rpc_port_proxy_vc_setting_proxy_vc_setting_notify_cb_set_once(info->notify_cb_h, false); + + return VC_ERROR_NONE; +} + +static int __invoke_register_notify_callback(int pid, vc_setting_tidl_info_s* info) +{ + if (info->register_notify_callback_invoked) { + SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked"); + return VC_ERROR_NONE; + } + + int ret = __create_notify_callback_handle(info); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret); + return VC_ERROR_OPERATION_FAILED; + } + + rpc_port_proxy_vc_setting_proxy_vc_setting_invoke_register_notify_cb(info->rpc_h, pid, info->notify_cb_h); + info->register_notify_callback_invoked = true; + return VC_ERROR_NONE; +} + +int vc_setting_tidl_open_connection() +{ + SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_setting_tidl_open_connection"); + + vc_setting_tidl_info_s* info = (vc_setting_tidl_info_s*)calloc(1, sizeof(vc_setting_tidl_info_s)); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create tidl_info_s"); + return VC_ERROR_OUT_OF_MEMORY; + } + + int pid = getpid(); + char* engine_appid = __get_engine_appid(); + + info->rpc_h = __create_rpc_port(pid, engine_appid); + if (NULL == info->rpc_h) { + SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create proxy"); + free(info); + return VC_ERROR_OPERATION_FAILED; + } + + info->pid = pid; + g_tidl_infos = g_list_append(g_tidl_infos, info); + + SLOG(LOG_ERROR, TAG_VCC, "[TIDL] pid(%d) rpc_h(%p), engine_appid(%s)", pid, info->rpc_h, info->engine_appid); + return VC_ERROR_NONE; + +} + +int vc_setting_tidl_close_connection() +{ + SLOG(LOG_INFO, TAG_VCC, "[TIDL] 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"); + + if (0 != rpc_port_proxy_vc_setting_proxy_vc_setting_destroy(info->rpc_h)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect"); + return VC_ERROR_OPERATION_FAILED; + } + + info->rpc_h = NULL; + info->notify_cb_h = NULL; + + g_tidl_infos = g_list_remove(g_tidl_infos, info); + free(info); + + return VC_ERROR_NONE; +} + +int vc_setting_tidl_request_hello() +{ + SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_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"); + + if (!info->connected) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()"); + __request_tidl_connect(info); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCC, ">>>>> VCC Hello"); + if (VC_ERROR_NONE != __invoke_register_notify_callback(pid, info)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register callback"); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCC, "<<<<"); + return VC_ERROR_NONE; + +} + +static int __covert_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; +} + +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"); + + 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); + } + + SLOG(LOG_DEBUG, TAG_VCC, "@@ vc setting set language : pid(%d), language(%s)", pid, language); + + return VC_ERROR_NONE; +} + diff --git a/client/vc_setting_tidl.h b/client/vc_setting_tidl.h new file mode 100755 index 0000000..7cd3cd4 --- /dev/null +++ b/client/vc_setting_tidl.h @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#ifndef __VC_SETTING_TIDL_H_ +#define __VC_SETTING_TIDL_H_ + +#include "voice_control_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int vc_setting_tidl_open_connection(); + +int vc_setting_tidl_close_connection(); + + +int vc_setting_tidl_request_hello(); + +int vc_setting_tidl_request_set_language(int pid, const char* language); + + +#ifdef __cplusplus +} +#endif + +#endif /* __VC_SETTING_TIDL_H_ */ diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 30bfc62..7ee6ece 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -118,6 +118,9 @@ cp %{SOURCE1001} %{SOURCE1002} . tidlc -p -l C -i tidl/vc.tidl -o vc_proxy -n tidlc -s -l C -i tidl/vc.tidl -o vcd_stub -n +tidlc -p -l C -i tidl/vc_setting.tidl -o vc_setting_proxy -n +tidlc -s -l C -i tidl/vc_setting.tidl -o vcd_setting_stub -n + tidlc -p -l C -i tidl/vc_mgr.tidl -o vc_mgr_proxy -n tidlc -s -l C -i tidl/vc_mgr.tidl -o vcd_mgr_stub -n tidlc -s -l C -i tidl/vcd_mgr.tidl -o vc_mgr_stub -n diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 2cda660..65e8713 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -17,6 +17,7 @@ SET(SRCS vcd_mgr_proxy.c vcd_widget_stub.c vcd_widget_proxy.c + vcd_setting_stub.c vcd_engine_agent.c # vcd_main.c vcd_recorder.c diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 25b8882..31332db 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -40,6 +40,9 @@ static manager_tidl_info_s* g_mgr_tidl_info = NULL; /* Widget IPC info */ static GSList* g_widget_tidl_info_list = NULL; +/* Setting IPC info list */ +static GSList* g_setting_tidl_info_list = NULL; + /* Command list */ static current_commands_list_s g_cur_cmd_list; @@ -2180,3 +2183,214 @@ void vcd_client_update_foreground_pid() vcd_config_set_foreground(VC_RUNTIME_INFO_NO_FOREGROUND, true); return; } + +/* +* setting API +*/ +GSList* __get_setting_tidl_info_item(const int pid) +{ + GSList *iter = NULL; + setting_tidl_info_s *data = NULL; + + int count = g_slist_length(g_setting_tidl_info_list); + int i; + + if (0 < count) { + iter = g_slist_nth(g_setting_tidl_info_list, 0); + for (i = 0; i < count; i++) { + if (NULL == iter) + break; + + data = iter->data; + if (NULL != data) { + if (pid == data->pid) + return iter; + } + + iter = g_slist_next(iter); + } + } + + return NULL; +} + +setting_tidl_info_s* __get_setting_tidl_info_element(int pid) +{ + GSList *iter = NULL; + setting_tidl_info_s *data = NULL; + + int count = g_slist_length(g_setting_tidl_info_list); + int i; + + if (0 < count) { + iter = g_slist_nth(g_setting_tidl_info_list, 0); + for (i = 0; i < count; i++) { + if (NULL == iter) + break; + + data = iter->data; + + if (NULL != data) { + if (pid == data->pid) + return data; + } + + iter = g_slist_next(iter); + } + } + + return NULL; +} + +int vcd_client_setting_add_tidl_info(int pid) +{ + /*Check pid is duplicated*/ + setting_tidl_info_s* info = NULL; + info = __get_setting_tidl_info_element(pid); + + if (NULL != info) { + SLOG(LOG_WARN, TAG_VCD, "[Setting Data] Setting tidl info pid is already registered"); + return VCD_ERROR_NONE; + } + + SLOG(LOG_INFO, TAG_VCD, "[Setting Data] There is no tidl info of pid(%d). Create new one.", pid); + info = (setting_tidl_info_s*)calloc(1, sizeof(setting_tidl_info_s)); + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + info->pid = pid; + info->notify_cb = NULL; + info->notify_cb_user_data = NULL; + + g_setting_tidl_info_list = g_slist_append(g_setting_tidl_info_list, info); + if (NULL == g_setting_tidl_info_list) { + SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] Fail to add new setting client tidl info"); + + free(info); + info = NULL; + + return -1; + } else { + SLOG(LOG_INFO, TAG_VCD, "[Setting Data SUCCESS] Add new setting client tidl info. pid(%d)", pid); + } + + return VCD_ERROR_NONE; +} + +int vcd_client_setting_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void* user_data) +{ + /*Check pid*/ + setting_tidl_info_s* info = NULL; + info = __get_setting_tidl_info_element(pid); + + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] There is no tidl info in the list. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_clone(callback, &(info->notify_cb)); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] Fail to clone notify callback. ret(%d)", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[Setting Data] Succeed to clone notify callback. ret(%d)", ret); + } + info->notify_cb_user_data = user_data; + + return VCD_ERROR_NONE; +} + +int vcd_client_setting_unset_tidl_notify_cb(int pid) +{ + /*Check pid*/ + setting_tidl_info_s* info = NULL; + info = __get_setting_tidl_info_element(pid); + + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] There is no tidl info in the list. pid(%d)", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_destroy(info->notify_cb); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] Fail to destroy notify callback. ret(%d)", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[Setting Data] Succeed to destroy notify callback. ret(%d)", ret); + } + info->notify_cb = NULL; + info->notify_cb_user_data = NULL; + + return VCD_ERROR_NONE; +} + +int vcd_client_setting_delete_tidl_info(int pid) +{ + GSList *tmp = NULL; + setting_tidl_info_s* setting_tidl_info = NULL; + + /*Get handle*/ + tmp = __get_setting_tidl_info_item(pid); + if (NULL == tmp) { + SLOG(LOG_ERROR, TAG_VCD, "[Setting Data ERROR] pid(%d) is NOT valid", pid); + return VCD_ERROR_INVALID_PARAMETER; + } + + /*Free setting client structure*/ + setting_tidl_info = tmp->data; + if (NULL != setting_tidl_info) { + free(setting_tidl_info); + } + + /*Remove handle from list*/ + g_setting_tidl_info_list = g_slist_remove_link(g_setting_tidl_info_list, tmp); + + return 0; +} + +setting_tidl_info_s* vcd_client_setting_get_tidl_info(int pid) +{ + return __get_setting_tidl_info_element(pid); +} + +int vcd_client_setting_get_tidl_list(int** pids, int* pid_count) +{ + if (NULL == pids || NULL == pid_count) + return -1; + + int count = g_slist_length(g_setting_tidl_info_list); + + if (0 == count) + return -1; + + int *tmp; + tmp = (int*)calloc(count, sizeof(int)); + if (NULL == tmp) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory"); + return VCD_ERROR_OUT_OF_MEMORY; + } + + GSList *iter = NULL; + setting_tidl_info_s *data = NULL; + int i = 0; + + iter = g_slist_nth(g_setting_tidl_info_list, 0); + + while (NULL != iter) { + data = iter->data; + + if (NULL != data) { + tmp[i] = data->pid; + } + + iter = g_slist_next(iter); + i++; + } + + *pids = tmp; + *pid_count = count; + + return 0; +} diff --git a/server/vcd_client_data.h b/server/vcd_client_data.h index 3b2f55c..4c7fbdc 100644 --- a/server/vcd_client_data.h +++ b/server/vcd_client_data.h @@ -22,6 +22,7 @@ #include "vc_command.h" #include "vc_info_parser.h" #include "vcd_stub.h" +#include "vcd_setting_stub.h" #include "vcd_mgr_stub.h" #include "vcd_mgr_proxy.h" #include "vcd_widget_stub.h" @@ -103,6 +104,13 @@ typedef struct { rpc_port_proxy_vcd_widget_proxy_vcd_widget_h rpc_h; } widget_tidl_info_s; +typedef struct { + int pid; + rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h notify_cb; + void* notify_cb_user_data; +} setting_tidl_info_s; + + typedef enum { VCD_RECOGNITION_MODE_STOP_BY_SILENCE, /**< Default mode */ VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT, /**< Restart recognition after rejected result */ @@ -265,6 +273,21 @@ widget_tidl_info_s* vcd_client_widget_get_tidl_info(int pid); GSList* vcd_client_widget_get_tidl_info_list(); +/* +* setting API +*/ +int vcd_client_setting_add_tidl_info(int pid); + +int vcd_client_setting_set_tidl_notify_cb(int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void* user_data); + +int vcd_client_setting_unset_tidl_notify_cb(int pid); + +int vcd_client_setting_delete_tidl_info(int pid); + +setting_tidl_info_s* vcd_client_setting_get_tidl_info(int pid); + +int vcd_client_setting_get_tidl_list(int** pids, int* pid_count); + #ifdef __cplusplus } #endif diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index e5905ba..f9b43c9 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -21,6 +21,7 @@ #include "vcd_tidl.h" #include "vcd_stub.h" +#include "vcd_setting_stub.h" #include "vcd_mgr_stub.h" #include "vcd_mgr_proxy.h" #include "vcd_widget_stub.h" @@ -39,6 +40,10 @@ static rpc_port_stub_vcd_stub_vc_callback_s g_client_callback; static pthread_mutex_t g_client_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; +static rpc_port_stub_vcd_setting_stub_vc_setting_callback_s g_setting_callback; + +static pthread_mutex_t g_setting_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; + static int g_volume_count = 0; int vcd_client_tidl_open_connection(); @@ -47,6 +52,8 @@ int vcd_mgr_tidl_open_connection(); int vcd_mgr_tidl_close_connection(); int vcd_widget_tidl_open_connection(); int vcd_widget_tidl_close_connection(); +int vcd_setting_tidl_open_connection(); +int vcd_setting_tidl_close_connection(); @@ -326,6 +333,40 @@ static void __vc_create_cb(rpc_port_stub_vcd_stub_vc_context_h context, void *us static void __vc_terminate_cb(rpc_port_stub_vcd_stub_vc_context_h context, void *user_data) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_terminate_cb"); + + void* tag = NULL; + rpc_port_stub_vcd_stub_vc_context_get_tag(context, &tag); + + if (NULL != tag) { + int pid = (uintptr_t)tag; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC FINALIZE. pid(%u)", pid); + + pthread_mutex_lock(&g_client_tidl_info_mutex); + client_tidl_info_s* tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get client tidl info."); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + if (0 != vcd_client_unset_tidl_notify_cb(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback"); + } + if (0 != vcd_client_unset_tidl_feedback_cb(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset feedback callback"); + } + + if (0 != vcd_client_delete_tidl_info(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to delete client tidl info"); + } + tidl_info = NULL; + + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + + pthread_mutex_unlock(&g_client_tidl_info_mutex); + + } + rpc_port_stub_vcd_stub_vc_context_set_tag(context, NULL); } static void __vc_register_notify_cb_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void *user_data) @@ -434,6 +475,9 @@ static int __vc_initialize_cb(rpc_port_stub_vcd_stub_vc_context_h context, int p int ret = VCD_ERROR_OPERATION_FAILED; + uintptr_t ptr_pid = pid; + rpc_port_stub_vcd_stub_vc_context_set_tag(context, (void*)ptr_pid); + ret = vcd_server_initialize(pid); *service_state = vcd_server_get_service_state(); *daemon_pid = getpid(); @@ -904,6 +948,11 @@ int vcd_tidl_open_connection() return VCD_ERROR_OPERATION_FAILED; } + if (0 != vcd_setting_tidl_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to setting"); + return VCD_ERROR_OPERATION_FAILED; + } + return VCD_ERROR_NONE; } @@ -926,6 +975,11 @@ int vcd_tidl_close_connection() return VCD_ERROR_OPERATION_FAILED; } + if (0 != vcd_setting_tidl_close_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to setting"); + return VCD_ERROR_OPERATION_FAILED; + } + return VCD_ERROR_NONE; } @@ -2560,3 +2614,159 @@ int vcd_widget_tidl_close_connection() return VCD_ERROR_NONE; } + +/** + * TIDL functions for VC setting client + */ +static void __vc_setting_create_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_create_cb"); + + char *sender = NULL; + + rpc_port_stub_vcd_setting_stub_vc_setting_context_get_sender(context, &sender); + if (!sender) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); + return ; + } + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] sender(%s)", sender); // sender (app_id) + free(sender); +} + +static void __vc_setting_terminate_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_terminate_cb"); + void* tag = NULL; + rpc_port_stub_vcd_setting_stub_vc_setting_context_get_tag(context, &tag); + + if (NULL != tag) { + int pid = (intptr_t)tag; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC SETTING FINALIZE. pid(%u)", pid); + + pthread_mutex_lock(&g_setting_tidl_info_mutex); + setting_tidl_info_s* setting_tidl_info = vcd_client_setting_get_tidl_info(pid); + if (NULL == setting_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get setting tidl info."); + pthread_mutex_unlock(&g_setting_tidl_info_mutex); + return; + } + + if (0 != vcd_client_setting_unset_tidl_notify_cb(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback"); + } + + if (0 != vcd_client_setting_delete_tidl_info(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to delete setting tidl info"); + } + 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); +} + +static void __vc_setting_register_notify_cb_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_register_notify_cb_cb. pid(%d)", pid); + + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return ; + } + + int ret = -1; + ret = vcd_client_setting_add_tidl_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return ; + } + + ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } +} + +static int __vc_setting_register_notify_cb_sync_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void *user_data) +{ + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_register_notify_cb_sync_cb. pid(%d)", pid); + + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return VCD_ERROR_INVALID_PARAMETER; + } + + int ret = -1; + ret = vcd_client_setting_add_tidl_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return ret; + } + + ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } + + return ret; +} + +int __vc_setting_set_language_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, const char *language, void *user_data) +{ + if (NULL == language) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter"); + return VCD_ERROR_INVALID_PARAMETER; + } + + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd server set language : language(%s)", language); + + int ret = vcd_server_set_language(language); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set language(%d).", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set language."); + } + + return ret; +} + +int vcd_setting_tidl_open_connection() +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] vcd_setting_tidl_open_connection"); + + g_setting_callback.create = __vc_setting_create_cb; + g_setting_callback.terminate = __vc_setting_terminate_cb; + g_setting_callback.register_notify_cb = __vc_setting_register_notify_cb_cb; + g_setting_callback.register_notify_cb_sync = __vc_setting_register_notify_cb_sync_cb; + g_setting_callback.set_language = __vc_setting_set_language_cb; + + int ret = -1; + int count = 0; + while (VC_RETRY_MIN_COUNT >= count) { + ret = rpc_port_stub_vcd_setting_stub_vc_setting_register(&g_setting_callback, NULL); + if (0 == ret) { + SLOG(LOG_DEBUG, TAG_VCD, "register callback"); + return VCD_ERROR_NONE; + } + usleep(100000); + count++; + } + + SLOG(LOG_ERROR, TAG_VCD, "Fail to register callback(%d)", ret); + return VCD_ERROR_OPERATION_FAILED; +} + +int vcd_setting_tidl_close_connection() +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Close connection"); + rpc_port_stub_vcd_setting_stub_vc_setting_unregister(); + + return VCD_ERROR_NONE; +} diff --git a/tidl/vc_setting.tidl b/tidl/vc_setting.tidl new file mode 100755 index 0000000..bb46f65 --- /dev/null +++ b/tidl/vc_setting.tidl @@ -0,0 +1,8 @@ +interface vc_setting { + void notify_cb(int pid, bundle msg) delegate; + + void register_notify_cb(int pid, notify_cb callback) async; + int register_notify_cb_sync(int pid, notify_cb callback); + + int set_language(in int pid, in string language); +} -- 2.7.4 From 3fea72b9eff6517ea2253a0b2bae03224b1d059d Mon Sep 17 00:00:00 2001 From: sooyeon Date: Tue, 28 Jun 2022 11:02:03 +0900 Subject: [PATCH 10/16] Fix minor issues (indentation, filemod, add a checker of return values, etc) Change-Id: I0f34be3b3fdfd659e7f47bca5d82f0c5333c1840 Signed-off-by: sooyeon --- client/vc_mgr.c | 0 client/vc_mgr_dbus.c | 0 client/vc_mgr_tidl.c | 0 client/vc_setting_tidl.c | 4 +- client/vc_setting_tidl.h | 0 client/vc_tidl.c | 44 +- client/vc_tidl.h | 0 server/vcd_client_data.c | 12 +- server/vcd_dbus.c | 0 server/vcd_dbus_server.c | 0 server/vcd_tidl.c | 1012 +++++++++++++++++++++++----------------------- 11 files changed, 538 insertions(+), 534 deletions(-) mode change 100755 => 100644 client/vc_mgr.c mode change 100755 => 100644 client/vc_mgr_dbus.c mode change 100755 => 100644 client/vc_mgr_tidl.c mode change 100755 => 100644 client/vc_setting_tidl.c mode change 100755 => 100644 client/vc_setting_tidl.h mode change 100755 => 100644 client/vc_tidl.c mode change 100755 => 100644 client/vc_tidl.h mode change 100755 => 100644 server/vcd_dbus.c mode change 100755 => 100644 server/vcd_dbus_server.c diff --git a/client/vc_mgr.c b/client/vc_mgr.c old mode 100755 new mode 100644 diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c old mode 100755 new mode 100644 diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c old mode 100755 new mode 100644 diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c old mode 100755 new mode 100644 index 240ef70..6f687c3 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -146,13 +146,13 @@ static void __request_tidl_connect(vc_setting_tidl_info_s* info) { if (info->connection_requesting) { SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_setting_proxy_vc_setting_connect()."); - return ; + return; } int ret = rpc_port_proxy_vc_setting_proxy_vc_setting_connect(info->rpc_h); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret); - return ; + return; } SLOG(LOG_INFO, TAG_VCC, "[INFO] Request connection to stub. ret(%d)", ret); diff --git a/client/vc_setting_tidl.h b/client/vc_setting_tidl.h old mode 100755 new mode 100644 diff --git a/client/vc_tidl.c b/client/vc_tidl.c old mode 100755 new mode 100644 index 110440a..6a6caef --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -152,13 +152,13 @@ static void __request_tidl_connect(vc_tidl_info_s* info) { if (info->connection_requesting) { SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_proxy_vc_connect()."); - return ; + return; } int ret = rpc_port_proxy_vc_proxy_vc_connect(info->rpc_h); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret); - return ; + return; } SLOG(LOG_INFO, TAG_VCC, "[INFO] Request connection to stub. ret(%d)", ret); @@ -267,7 +267,9 @@ static int __create_notify_callback_handle(vc_tidl_info_s* info) info->notify_cb_h = NULL; } - if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_proxy_vc_notify_cb_create(&info->notify_cb_h)) { + int ret = rpc_port_proxy_vc_proxy_vc_notify_cb_create(&info->notify_cb_h); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke rpc_port_proxy_vc_proxy_vc_notify_cb_create(). err(%d)", ret); return VC_ERROR_OUT_OF_MEMORY; } @@ -284,7 +286,9 @@ static int __create_feedback_callback_handle(vc_tidl_info_s* info) info->feedback_cb_h = NULL; } - if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_proxy_vc_feedback_cb_create(&info->feedback_cb_h)) { + int ret = rpc_port_proxy_vc_proxy_vc_feedback_cb_create(&info->feedback_cb_h); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke rpc_port_proxy_vc_proxy_vc_feedback_cb_create(). err(%d)", ret); return VC_ERROR_OUT_OF_MEMORY; } @@ -424,7 +428,7 @@ int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* d 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) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -443,7 +447,7 @@ int vc_tidl_request_finalize(int pid) int ret = rpc_port_proxy_vc_proxy_vc_invoke_finalize(info->rpc_h, pid); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -462,7 +466,7 @@ int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type) int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -481,7 +485,7 @@ int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type) int ret = rpc_port_proxy_vc_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -501,7 +505,7 @@ int vc_tidl_request_set_foreground(int pid, bool value) int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -520,7 +524,7 @@ int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* c 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) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -540,7 +544,7 @@ int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* u 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) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -559,7 +563,7 @@ int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) 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) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -579,7 +583,7 @@ int vc_tidl_request_auth_enable(int pid, int mgr_pid) int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -598,7 +602,7 @@ int vc_tidl_request_auth_disable(int pid, int mgr_pid) int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -617,7 +621,7 @@ int vc_tidl_request_auth_start(int pid, int mgr_pid) int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -636,7 +640,7 @@ int vc_tidl_request_auth_stop(int pid, int mgr_pid) int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -655,7 +659,7 @@ int vc_tidl_request_auth_cancel(int pid, int mgr_pid) int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -680,7 +684,7 @@ 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) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -699,7 +703,7 @@ int vc_tidl_request_cancel_tts(int pid, int utt_id) int ret = rpc_port_proxy_vc_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id); if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } @@ -718,7 +722,7 @@ int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* 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) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message"); + SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message. err(%d)", ret); return __covert_unhandled_error(ret); } diff --git a/client/vc_tidl.h b/client/vc_tidl.h old mode 100755 new mode 100644 diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 31332db..267c7c6 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -1438,8 +1438,8 @@ int vcd_client_delete_tidl_info(int pid) free(client_tidl_info); } - /*Remove handle from list*/ - g_client_tidl_info_list = g_slist_remove_link(g_client_tidl_info_list, tmp); + /*Delete handle from list*/ + g_client_tidl_info_list = g_slist_delete_link(g_client_tidl_info_list, tmp); return 0; } @@ -2091,8 +2091,8 @@ int vcd_client_widget_delete_tidl_info(int pid) free(widget_tidl_info); } - /*Remove handle from list*/ - g_widget_tidl_info_list = g_slist_remove_link(g_widget_tidl_info_list, tmp); + /*Delete handle from list*/ + g_widget_tidl_info_list = g_slist_delete_link(g_widget_tidl_info_list, tmp); return 0; } @@ -2344,8 +2344,8 @@ int vcd_client_setting_delete_tidl_info(int pid) free(setting_tidl_info); } - /*Remove handle from list*/ - g_setting_tidl_info_list = g_slist_remove_link(g_setting_tidl_info_list, tmp); + /*Delete handle from list*/ + g_setting_tidl_info_list = g_slist_delete_link(g_setting_tidl_info_list, tmp); return 0; } diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c old mode 100755 new mode 100644 diff --git a/server/vcd_dbus_server.c b/server/vcd_dbus_server.c old mode 100755 new mode 100644 diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index f9b43c9..2b78f91 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -158,30 +158,30 @@ void __send_msg(bundle* msg, vcd_client_type_e type, int pid) return; } pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - } else if (VCD_CLIENT_TYPE_NORMAL == type) { - pthread_mutex_lock(&g_client_tidl_info_mutex); - - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); - client_tidl_info_s* client_tidl_info = vcd_client_get_tidl_info(pid); - if (NULL == client_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } - - rpc_port_stub_vcd_stub_vc_notify_cb_h handle = client_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } - - if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(handle, pid, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } - pthread_mutex_unlock(&g_client_tidl_info_mutex); + } else if (VCD_CLIENT_TYPE_NORMAL == type) { + pthread_mutex_lock(&g_client_tidl_info_mutex); + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); + client_tidl_info_s* client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + rpc_port_stub_vcd_stub_vc_notify_cb_h handle = client_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(handle, pid, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + pthread_mutex_unlock(&g_client_tidl_info_mutex); } else if (VCD_CLIENT_TYPE_WIDGET == type) { pthread_mutex_lock(&g_widget_tidl_info_mutex); @@ -241,31 +241,31 @@ void __send_signal(bundle* msg) pthread_mutex_unlock(&g_mgr_tidl_info_mutex); pthread_mutex_lock(&g_client_tidl_info_mutex); - // get all pids - int* client_list = NULL; + // get all pids + int* client_list = NULL; int client_count = 0; - int ret = -1; - ret = vcd_client_get_tidl_list(&client_list, &client_count); + int ret = -1; + ret = vcd_client_get_tidl_list(&client_list, &client_count); - client_tidl_info_s* client_tidl_info; - int pid = -1; + client_tidl_info_s* client_tidl_info = NULL; + int pid = -1; if (0 == ret && 0 < client_count) { - for (int i = 0 ; i < client_count ; i++) { - pid = client_list[i]; + for (int i = 0 ; i < client_count ; i++) { + pid = client_list[i]; - client_tidl_info = vcd_client_get_tidl_info(pid); - if (NULL == client_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); - continue; - } + client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); + continue; + } - if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(client_tidl_info->notify_cb, pid, msg)) { + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(client_tidl_info->notify_cb, pid, msg)) { SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); continue; - } - } - } + } + } + } pthread_mutex_unlock(&g_client_tidl_info_mutex); pthread_mutex_lock(&g_widget_tidl_info_mutex); @@ -316,23 +316,23 @@ void __send_signal(bundle* msg) */ static void __vc_create_cb(rpc_port_stub_vcd_stub_vc_context_h context, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_create_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_create_cb"); char *sender = NULL; rpc_port_stub_vcd_stub_vc_context_get_sender(context, &sender); if (!sender) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); - return ; - } + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); + return; + } SLOG(LOG_INFO, TAG_VCD, "[TIDL] sender(%s)", sender); // sender (app_id) - free(sender); + free(sender); } static void __vc_terminate_cb(rpc_port_stub_vcd_stub_vc_context_h context, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_terminate_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_terminate_cb"); void* tag = NULL; rpc_port_stub_vcd_stub_vc_context_get_tag(context, &tag); @@ -371,529 +371,529 @@ static void __vc_terminate_cb(rpc_port_stub_vcd_stub_vc_context_h context, void static void __vc_register_notify_cb_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_cb. pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_cb. pid(%d)", pid); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); - return ; - } + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return; + } - int ret = -1; - ret = vcd_client_add_tidl_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); - return ; - } + int ret = -1; + ret = vcd_client_add_tidl_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return; + } - ret = vcd_client_set_tidl_notify_cb(pid, callback, user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); - } + ret = vcd_client_set_tidl_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } } static int __vc_register_notify_cb_sync_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_notify_cb_h callback, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_sync_cb. pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_sync_cb. pid(%d)", pid); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); - return VCD_ERROR_INVALID_PARAMETER; - } + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return VCD_ERROR_INVALID_PARAMETER; + } - int ret = -1; - ret = vcd_client_add_tidl_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); - return ret; - } - - ret = vcd_client_set_tidl_notify_cb(pid, callback, user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); - } + int ret = -1; + ret = vcd_client_add_tidl_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return ret; + } + + ret = vcd_client_set_tidl_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } - return ret; + return ret; } static void __vc_register_feedback_cb_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_cb. pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_cb. pid(%d)", pid); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); - return ; - } + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return; + } - int ret = -1; - ret = vcd_client_add_tidl_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); - return ; - } + int ret = -1; + ret = vcd_client_add_tidl_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return; + } - ret = vcd_client_set_tidl_feedback_cb(pid, callback, user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback."); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set feedback callback."); - } + ret = vcd_client_set_tidl_feedback_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set feedback callback."); + } } static int __vc_register_feedback_cb_sync_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, rpc_port_stub_vcd_stub_vc_feedback_cb_h callback, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_sync_cb. pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_sync_cb. pid(%d)", pid); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); - return VCD_ERROR_INVALID_PARAMETER; - } + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return VCD_ERROR_INVALID_PARAMETER; + } - int ret = -1; - ret = vcd_client_add_tidl_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); - return ret; - } - - ret = vcd_client_set_tidl_feedback_cb(pid, callback, user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback."); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set feedback callback."); - } + int ret = -1; + ret = vcd_client_add_tidl_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return ret; + } + + ret = vcd_client_set_tidl_feedback_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set feedback callback."); + } - return ret; + return ret; } static int __vc_initialize_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int *mgr_pid, int *service_state, int *daemon_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_initialize_cb. pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_initialize_cb. pid(%d)", pid); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; uintptr_t ptr_pid = pid; rpc_port_stub_vcd_stub_vc_context_set_tag(context, (void*)ptr_pid); - ret = vcd_server_initialize(pid); - *service_state = vcd_server_get_service_state(); - *daemon_pid = getpid(); - *mgr_pid = vcd_client_manager_get_pid(); + ret = vcd_server_initialize(pid); + *service_state = vcd_server_get_service_state(); + *daemon_pid = getpid(); + *mgr_pid = vcd_client_manager_get_pid(); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd initialize : pid(%d) daemon_pid(%d)", pid, *daemon_pid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd initialize : pid(%d) daemon_pid(%d) ret(%d)", pid, *daemon_pid, ret); - } + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd initialize : pid(%d) daemon_pid(%d)", pid, *daemon_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd initialize : pid(%d) daemon_pid(%d) ret(%d)", pid, *daemon_pid, ret); + } - return ret; + return ret; } static int __vc_finalize_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_finalize_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_finalize_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_finalize(pid); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd finalize : pid(%d)", pid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd finalize : pid(%d) ret(%d)", pid, ret); - } + ret = vcd_server_finalize(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd finalize : pid(%d)", pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd finalize : pid(%d) ret(%d)", pid, ret); + } - return ret; + return ret; } static int __vc_set_command_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int cmd_type, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_command_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_command_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_set_command(pid, (vc_cmd_type_e)cmd_type); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set command : pid(%d), cmd_type(%d)", pid, cmd_type); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret); - } + ret = vcd_server_set_command(pid, (vc_cmd_type_e)cmd_type); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set command : pid(%d), cmd_type(%d)", pid, cmd_type); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret); + } - return ret; + return ret; } static int __vc_unset_command_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int cmd_type, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_unset_command_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_unset_command_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_unset_command(pid, (vc_cmd_type_e)cmd_type); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd unset command : pid(%d), cmd_type(%d)", pid, cmd_type); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd unset command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret); - } - - return ret; + ret = vcd_server_unset_command(pid, (vc_cmd_type_e)cmd_type); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd unset command : pid(%d), cmd_type(%d)", pid, cmd_type); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd unset command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret); + } + + return ret; } static int __vc_set_foreground_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, bool value, void *user_data) { - // check more... - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_foreground_cb"); + // check more... + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_foreground_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_set_foreground(pid, value); - if (VCD_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set foreground : pid(%d) ret(%d)", pid, ret); - return ret; - } - - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d)", pid); - vcdc_send_request_set_foreground(pid, value); + ret = vcd_server_set_foreground(pid, value); + if (VCD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set foreground : pid(%d) ret(%d)", pid, ret); + return ret; + } + + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d)", pid); + vcdc_send_request_set_foreground(pid, value); - return ret; + return ret; } static int __vc_set_server_dialog_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, const char *app_id, const char *credential, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_server_dialog_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_server_dialog_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_set_server_dialog(pid, app_id, credential); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set server dialog : pid(%d), app_id(%s)", pid, app_id); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set server dialog : pid(%d), app_id(%s) ret(%d)", pid, app_id, ret); - } - - return ret; + ret = vcd_server_set_server_dialog(pid, app_id, credential); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set server dialog : pid(%d), app_id(%s)", pid, app_id); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set server dialog : pid(%d), app_id(%s) ret(%d)", pid, app_id, ret); + } + + return ret; } static int __vc_request_dialog_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, const char *disp_text, const char *utt_text, bool continuous, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_dialog_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_dialog_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_dialog(pid, disp_text, utt_text, continuous); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous); - } else { - 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; + ret = vcd_server_dialog(pid, disp_text, utt_text, continuous); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous); + } else { + 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; } 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) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_is_system_command_valid_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_is_system_command_valid_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_is_system_command_valid(pid, (int*)is_sys_cmd_valid); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd check system command is valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd check system command is valid : pid(%d), ret(%d)", pid, ret); - } - - return ret; + ret = vcd_server_is_system_command_valid(pid, (int*)is_sys_cmd_valid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd check system command is valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd check system command is valid : pid(%d), ret(%d)", pid, ret); + } + + return ret; } static int __vc_auth_enable_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_enable_cb. Send a request to vc_mgr"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_enable_cb. Send a request to vc_mgr"); - int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcdc_send_request_auth_enable(pid); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth enable. pid(%d), mgr_pid(%d)", pid, mgr_pid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth enable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - } + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_enable(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth enable. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth enable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return ret; + return ret; } static int __vc_auth_disable_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_disable_cb. Send a request to vc_mgr"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_disable_cb. Send a request to vc_mgr"); - int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcdc_send_request_auth_disable(pid); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth disable. pid(%d), mgr_pid(%d)", pid, mgr_pid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth disable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - } + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_disable(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth disable. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth disable. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return ret; + return ret; } static int __vc_auth_start_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_start_cb. Send a request to vc_mgr"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_start_cb. Send a request to vc_mgr"); - int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcdc_send_request_auth_start(pid); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth start. pid(%d), mgr_pid(%d)", pid, mgr_pid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth start. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - } + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_start(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth start. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth start. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return ret; + return ret; } static int __vc_auth_stop_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_stop_cb. Send a request to vc_mgr"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_stop_cb. Send a request to vc_mgr"); - int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcdc_send_request_auth_stop(pid); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth stop. pid(%d), mgr_pid(%d)", pid, mgr_pid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth stop. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - } + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_stop(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth stop. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth stop. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return ret; + return ret; } static int __vc_auth_cancel_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int mgr_pid, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_cancel_cb. Send a request to vc_mgr"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_cancel_cb. Send a request to vc_mgr"); - int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcdc_send_request_auth_cancel(pid); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth cancel. pid(%d), mgr_pid(%d)", pid, mgr_pid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth cancel. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); - } + int ret = VCD_ERROR_OPERATION_FAILED; + ret = vcdc_send_request_auth_cancel(pid); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Send request auth cancel. pid(%d), mgr_pid(%d)", pid, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to send request auth cancel. ret(%d), pid(%d), mgr_pid(%d)", ret, pid, mgr_pid); + } - return ret; + return ret; } static int __vc_request_tts_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_tts_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_tts_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_request_tts(pid, text, lang, to_vcm, utt_id); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d)", pid, text, lang, to_vcm); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d), ret(%d)", pid, text, lang, to_vcm, ret); - } - - return ret; + ret = vcd_server_request_tts(pid, text, lang, to_vcm, utt_id); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d)", pid, text, lang, to_vcm); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d), ret(%d)", pid, text, lang, to_vcm, ret); + } + + return ret; } static int __vc_cancel_tts_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int utt_id, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_cancel_tts_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_cancel_tts_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_cancel_tts(pid, utt_id); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd cancel tts : pid(%d), utt_id(%d)", pid, utt_id); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd cancel tts : pid(%d), utt_id(%d), ret(%d)", pid, utt_id, ret); - } - - return ret; + ret = vcd_server_cancel_tts(pid, utt_id); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd cancel tts : pid(%d), utt_id(%d)", pid, utt_id); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd cancel tts : pid(%d), utt_id(%d), ret(%d)", pid, utt_id, ret); + } + + return ret; } static int __vc_get_tts_audio_format_cb(rpc_port_stub_vcd_stub_vc_context_h context, int pid, int *rate, int *channel, int *audio_type, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_get_tts_audio_format_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_get_tts_audio_format_cb"); - int ret = VCD_ERROR_OPERATION_FAILED; + int ret = VCD_ERROR_OPERATION_FAILED; - ret = vcd_server_get_tts_audio_format(pid, rate, channel, audio_type); - if (VCD_ERROR_NONE == ret) { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd get tts audio format : pid(%d) ret(%d)", pid, ret); - } - - return ret; + ret = vcd_server_get_tts_audio_format(pid, rate, channel, audio_type); + if (VCD_ERROR_NONE == ret) { + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd get tts audio format : pid(%d) ret(%d)", pid, ret); + } + + return ret; } int vcd_client_tidl_open_connection() { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_client_tidl_open_connection"); - - g_client_callback.create = __vc_create_cb; - g_client_callback.terminate = __vc_terminate_cb; - g_client_callback.register_notify_cb = __vc_register_notify_cb_cb; - g_client_callback.register_notify_cb_sync = __vc_register_notify_cb_sync_cb; - g_client_callback.register_feedback_cb = __vc_register_feedback_cb_cb; - g_client_callback.register_feedback_cb_sync = __vc_register_feedback_cb_sync_cb; - g_client_callback.initialize = __vc_initialize_cb; - g_client_callback.finalize = __vc_finalize_cb; - g_client_callback.set_command = __vc_set_command_cb; - g_client_callback.unset_command = __vc_unset_command_cb; - g_client_callback.set_foreground = __vc_set_foreground_cb; - g_client_callback.set_server_dialog = __vc_set_server_dialog_cb; - g_client_callback.request_dialog = __vc_request_dialog_cb; - g_client_callback.is_system_command_valid = __vc_is_system_command_valid_cb; - g_client_callback.auth_enable = __vc_auth_enable_cb; - g_client_callback.auth_disable = __vc_auth_disable_cb; - g_client_callback.auth_start = __vc_auth_start_cb; - g_client_callback.auth_stop = __vc_auth_stop_cb; - g_client_callback.auth_cancel = __vc_auth_cancel_cb; - g_client_callback.request_tts = __vc_request_tts_cb; - g_client_callback.cancel_tts = __vc_cancel_tts_cb; - g_client_callback.get_tts_audio_format = __vc_get_tts_audio_format_cb; - - int ret = -1; - ret = rpc_port_stub_vcd_stub_vc_register(&g_client_callback, NULL); - if (VCD_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to register TIDL callbacks. ret(%d)", ret); - return VCD_ERROR_OPERATION_FAILED; - } - - return VCD_ERROR_NONE; + SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_client_tidl_open_connection"); + + g_client_callback.create = __vc_create_cb; + g_client_callback.terminate = __vc_terminate_cb; + g_client_callback.register_notify_cb = __vc_register_notify_cb_cb; + g_client_callback.register_notify_cb_sync = __vc_register_notify_cb_sync_cb; + g_client_callback.register_feedback_cb = __vc_register_feedback_cb_cb; + g_client_callback.register_feedback_cb_sync = __vc_register_feedback_cb_sync_cb; + g_client_callback.initialize = __vc_initialize_cb; + g_client_callback.finalize = __vc_finalize_cb; + g_client_callback.set_command = __vc_set_command_cb; + g_client_callback.unset_command = __vc_unset_command_cb; + g_client_callback.set_foreground = __vc_set_foreground_cb; + g_client_callback.set_server_dialog = __vc_set_server_dialog_cb; + g_client_callback.request_dialog = __vc_request_dialog_cb; + g_client_callback.is_system_command_valid = __vc_is_system_command_valid_cb; + g_client_callback.auth_enable = __vc_auth_enable_cb; + g_client_callback.auth_disable = __vc_auth_disable_cb; + g_client_callback.auth_start = __vc_auth_start_cb; + g_client_callback.auth_stop = __vc_auth_stop_cb; + g_client_callback.auth_cancel = __vc_auth_cancel_cb; + g_client_callback.request_tts = __vc_request_tts_cb; + g_client_callback.cancel_tts = __vc_cancel_tts_cb; + g_client_callback.get_tts_audio_format = __vc_get_tts_audio_format_cb; + + int ret = -1; + ret = rpc_port_stub_vcd_stub_vc_register(&g_client_callback, NULL); + if (VCD_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to register TIDL callbacks. ret(%d)", ret); + return VCD_ERROR_OPERATION_FAILED; + } + + return VCD_ERROR_NONE; } int vcd_client_tidl_close_connection() { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_close_connection"); - rpc_port_stub_vcd_stub_vc_unregister(); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_close_connection"); + rpc_port_stub_vcd_stub_vc_unregister(); - return VCD_ERROR_NONE; + return VCD_ERROR_NONE; } int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) { - if (NULL == err_msg) { + if (NULL == err_msg) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Input parameter is NULL"); return VCD_ERROR_INVALID_PARAMETER; - } + } - 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; - } + 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; - } + 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; + } SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send error signal to app(%d)", pid); - char pid_char[10] = {0}; - char reason_char[10] = {0}; - snprintf(pid_char, 10, "%d", pid); - snprintf(reason_char, 10, "%d", reason); + char pid_char[10] = {0}; + char reason_char[10] = {0}; + 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_PID, pid_char); - bundle_add_str(msg, VC_BUNDLE_REASON, reason_char); - bundle_add_str(msg, VC_BUNDLE_ERR_MSG, err_msg); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_ERROR_TO_APP); + 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); - rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); - return VCD_ERROR_NONE; + return VCD_ERROR_NONE; } int vcdc_send_manager_pid(int manager_pid) { - // send signal to all pid + // send signal to all pid - // get all pids - int* client_list = NULL; + // get all pids + int* client_list = NULL; int client_count = 0; - int ret = -1; - 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"); - return VCD_ERROR_NONE; - } - - client_tidl_info_s* info; - int pid = -1; - bundle* msg; - char pid_char[10] = {0}; - char mgrpid_char[10] = {0}; - for (int i = 0 ; i < client_count ; i++) { - pid = client_list[i]; - - 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); - continue; - } + int ret = -1; + 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"); + return VCD_ERROR_NONE; + } + + client_tidl_info_s* info; + int pid = -1; + bundle* msg; + char pid_char[10] = {0}; + char mgrpid_char[10] = {0}; + for (int i = 0 ; i < client_count ; i++) { + pid = client_list[i]; + + 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); + continue; + } - msg = bundle_create(); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); - continue; - } + msg = bundle_create(); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + continue; + } - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send manager pid(%d) to app(%d)", manager_pid, pid); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send manager pid(%d) to app(%d)", manager_pid, pid); - snprintf(pid_char, 10, "%d", pid); - snprintf(mgrpid_char, 10, "%d", manager_pid); + snprintf(pid_char, 10, "%d", pid); + snprintf(mgrpid_char, 10, "%d", manager_pid); - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SEND_MANAGER_PID); - bundle_add_str(msg, VC_BUNDLE_PID, pid_char); - bundle_add_str(msg, VC_BUNDLE_MANAGER_PID, mgrpid_char); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SEND_MANAGER_PID); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_MANAGER_PID, mgrpid_char); - rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); - bundle_free(msg); - } + bundle_free(msg); + } - return VCD_ERROR_NONE; + return VCD_ERROR_NONE; } int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) { - if (NULL == buffer || 0 >= len) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter"); - return VCD_ERROR_INVALID_PARAMETER; - } + if (NULL == buffer || 0 >= len) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter"); + return VCD_ERROR_INVALID_PARAMETER; + } - 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; - } + 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; - } + 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; + } SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send feedback streaming to app(%d), utt_id(%d), event(%d), length(%d)", pid, utt_id, event, len); - rpc_port_stub_vcd_stub_array_char_h arr_char = NULL; - rpc_port_stub_vcd_stub_array_char_create(&arr_char); - rpc_port_stub_vcd_stub_array_char_set(arr_char, buffer, len); + rpc_port_stub_vcd_stub_array_char_h arr_char = NULL; + rpc_port_stub_vcd_stub_array_char_create(&arr_char); + rpc_port_stub_vcd_stub_array_char_set(arr_char, buffer, len); - rpc_port_stub_vcd_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len); + rpc_port_stub_vcd_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len); - rpc_port_stub_vcd_stub_array_char_destroy(arr_char); + rpc_port_stub_vcd_stub_array_char_destroy(arr_char); - bundle_free(msg); + bundle_free(msg); - return VCD_ERROR_NONE; + return VCD_ERROR_NONE; } int vcdc_send_hello(int pid, vcd_client_type_e type) @@ -922,7 +922,7 @@ int vcdc_send_hello(int pid, vcd_client_type_e type) SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] VCD SEND MESSAGE"); - // TODO: VCD_CLIENT_TYPE_MANAGER?? type?? + // TODO: VCD_CLIENT_TYPE_MANAGER?? type?? __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, pid); bundle_free(msg); @@ -1037,12 +1037,12 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type) { SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send result"); - vcd_client_type_e type; + vcd_client_type_e type; 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; - } + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + return VCD_ERROR_OUT_OF_MEMORY; + } SLOG(LOG_INFO, TAG_VCD, "[TIDL] Result command type(%d)", cmd_type); @@ -1050,25 +1050,25 @@ int vcdc_send_result(int pid, int manager_pid, int cmd_type) case VC_COMMAND_TYPE_FOREGROUND: case VC_COMMAND_TYPE_BACKGROUND: if (pid == manager_pid) { - type = VCD_CLIENT_TYPE_MANAGER; - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); + type = VCD_CLIENT_TYPE_MANAGER; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); } else { - type = VCD_CLIENT_TYPE_NORMAL; - char pid_char[10] = {0}; - snprintf(pid_char, 10, "%d", pid); - bundle_add_str(msg, VC_BUNDLE_PID, pid_char); - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_RESULT); + type = VCD_CLIENT_TYPE_NORMAL; + char pid_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_RESULT); } break; case VC_COMMAND_TYPE_WIDGET: - type = VCD_CLIENT_TYPE_WIDGET; - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT); + type = VCD_CLIENT_TYPE_WIDGET; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT); break; case VC_COMMAND_TYPE_SYSTEM: case VC_COMMAND_TYPE_SYSTEM_BACKGROUND: case VC_COMMAND_TYPE_EXCLUSIVE: - type = VCD_CLIENT_TYPE_MANAGER; - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); + type = VCD_CLIENT_TYPE_MANAGER; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); break; default: @@ -1766,7 +1766,7 @@ static void __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create manager tidl info."); pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; + return; } manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); @@ -1774,7 +1774,7 @@ static void __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h if (NULL == mgr_tidl_info) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info. pid(%d)", pid); pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; + return; } char *sender = NULL; @@ -2145,51 +2145,51 @@ static void __vc_mgr_send_utterance_status_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr 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); - pthread_mutex_lock(&g_client_tidl_info_mutex); - - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); - client_tidl_info_s* client_tidl_info = vcd_client_get_tidl_info(pid); - if (NULL == client_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } - - rpc_port_stub_vcd_stub_vc_notify_cb_h handle = client_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } - - bundle* msg = bundle_create(); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } - - char pid_char[10] = {0}; - char uttid_char[10] = {0}; - char uttstatus_char[10] = {0}; - snprintf(pid_char, 10, "%d", pid); - snprintf(uttid_char, 10, "%d", utt_id); - snprintf(uttstatus_char, 10, "%d", utt_status); - - bundle_add_str(msg, VC_BUNDLE_METHOD, VC_MANAGER_METHOD_UTTERANCE_STATUS); - bundle_add_str(msg, VC_BUNDLE_PID, pid_char); - bundle_add_str(msg, VC_BUNDLE_REASON, uttid_char); - bundle_add_str(msg, VC_BUNDLE_ERR_MSG, uttstatus_char); - - if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(handle, pid, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - bundle_free(msg); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } - - bundle_free(msg); - pthread_mutex_unlock(&g_client_tidl_info_mutex); + pthread_mutex_lock(&g_client_tidl_info_mutex); + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); + client_tidl_info_s* client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + rpc_port_stub_vcd_stub_vc_notify_cb_h handle = client_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + bundle* msg = bundle_create(); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + char pid_char[10] = {0}; + char uttid_char[10] = {0}; + char uttstatus_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + snprintf(uttid_char, 10, "%d", utt_id); + snprintf(uttstatus_char, 10, "%d", utt_status); + + bundle_add_str(msg, VC_BUNDLE_METHOD, VC_MANAGER_METHOD_UTTERANCE_STATUS); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_REASON, uttid_char); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, uttstatus_char); + + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(handle, pid, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + bundle_free(msg); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + bundle_free(msg); + pthread_mutex_unlock(&g_client_tidl_info_mutex); SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } @@ -2382,14 +2382,14 @@ static void __vc_widget_register_cb_cb(rpc_port_stub_vcd_widget_stub_vc_widget_ if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add widget tidl info."); pthread_mutex_unlock(&g_widget_tidl_info_mutex); - return; + return; } widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); if (NULL == widget_tidl_info) { SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get widget tidl info. pid(%d)", pid); pthread_mutex_unlock(&g_widget_tidl_info_mutex); - return; + return; } char *sender = NULL; @@ -2620,23 +2620,23 @@ int vcd_widget_tidl_close_connection() */ static void __vc_setting_create_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_create_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_create_cb"); char *sender = NULL; rpc_port_stub_vcd_setting_stub_vc_setting_context_get_sender(context, &sender); if (!sender) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); - return ; - } + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); + return; + } SLOG(LOG_INFO, TAG_VCD, "[TIDL] sender(%s)", sender); // sender (app_id) - free(sender); + free(sender); } static void __vc_setting_terminate_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_terminate_cb"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_terminate_cb"); void* tag = NULL; rpc_port_stub_vcd_setting_stub_vc_setting_context_get_tag(context, &tag); @@ -2670,52 +2670,52 @@ static void __vc_setting_terminate_cb(rpc_port_stub_vcd_setting_stub_vc_setting_ static void __vc_setting_register_notify_cb_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_register_notify_cb_cb. pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_register_notify_cb_cb. pid(%d)", pid); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); - return ; - } + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return; + } - int ret = -1; - ret = vcd_client_setting_add_tidl_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); - return ; - } + int ret = -1; + ret = vcd_client_setting_add_tidl_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return; + } - ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); - } + ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } } static int __vc_setting_register_notify_cb_sync_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_register_notify_cb_sync_cb. pid(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_register_notify_cb_sync_cb. pid(%d)", pid); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); - return VCD_ERROR_INVALID_PARAMETER; - } + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return VCD_ERROR_INVALID_PARAMETER; + } - int ret = -1; - ret = vcd_client_setting_add_tidl_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); - return ret; - } - - ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); - } + int ret = -1; + ret = vcd_client_setting_add_tidl_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return ret; + } + + ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } - return ret; + return ret; } int __vc_setting_set_language_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, const char *language, void *user_data) @@ -2725,13 +2725,13 @@ int __vc_setting_set_language_cb(rpc_port_stub_vcd_setting_stub_vc_setting_cont return VCD_ERROR_INVALID_PARAMETER; } - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd server set language : language(%s)", language); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd server set language : language(%s)", language); - int ret = vcd_server_set_language(language); + int ret = vcd_server_set_language(language); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set language(%d).", ret); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set language."); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set language(%d).", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set language."); } return ret; -- 2.7.4 From 7b7c9adf38b7f96ce12c379b3d67bf5069f9a561 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Tue, 28 Jun 2022 11:22:34 +0900 Subject: [PATCH 11/16] Rename extern functions and Rearrange codes Change-Id: I3da3d9e9a46b6126af91b9ddcc16b4f00ef4123f Signed-off-by: sooyeon --- common/vc_defs.h | 2 +- server/vcd_dbus.c | 1 - server/vcd_tidl.c | 2783 +++++++++++++++++++++++++++-------------------------- server/vcd_tidl.h | 15 +- 4 files changed, 1400 insertions(+), 1401 deletions(-) diff --git a/common/vc_defs.h b/common/vc_defs.h index cbe89eb..2a74a03 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -281,8 +281,8 @@ extern "C" { #define VC_RUNTIME_INFO_NO_FOREGROUND -1 #define VC_CONNECTION_RETRY_COUNT 10 #define VC_INVALID_TTS_UID 0 -#define VC_TIDL_RETRY_COUNT 100 #define VC_ENGINE_APPID_LEN 256 +#define VC_TIDL_RETRY_COUNT 100 #define VC_FEATURE_PATH "tizen.org/feature/speech.control" #define VC_MGR_FEATURE_PATH "tizen.org/feature/speech.control_manager" diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c index 29b6d75..b03d102 100644 --- a/server/vcd_dbus.c +++ b/server/vcd_dbus.c @@ -276,7 +276,6 @@ int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) return VCD_ERROR_NONE; } */ - /* int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) { diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index 2b78f91..f64dc51 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "vcd_client_data.h" #include "vcd_main.h" #include "vcd_server.h" @@ -27,7 +29,6 @@ #include "vcd_widget_stub.h" #include "vcd_widget_proxy.h" - static rpc_port_stub_vcd_mgr_stub_vc_mgr_callback_s g_mgr_callback; static pthread_mutex_t g_mgr_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -46,19 +47,17 @@ static pthread_mutex_t g_setting_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER; static int g_volume_count = 0; -int vcd_client_tidl_open_connection(); -int vcd_client_tidl_close_connection(); -int vcd_mgr_tidl_open_connection(); -int vcd_mgr_tidl_close_connection(); -int vcd_widget_tidl_open_connection(); -int vcd_widget_tidl_close_connection(); -int vcd_setting_tidl_open_connection(); -int vcd_setting_tidl_close_connection(); - - +extern int __client_tidl_open_connection(); +extern int __client_tidl_close_connection(); +extern int __mgr_tidl_open_connection(); +extern int __mgr_tidl_close_connection(); +extern int __widget_tidl_open_connection(); +extern int __widget_tidl_close_connection(); +extern int __setting_tidl_open_connection(); +extern int __setting_tidl_close_connection(); -/* for common request */ +/* For common request */ static void __request_tidl_connect(vcd_client_type_e type, int pid) { char* type_str = NULL; @@ -311,8 +310,9 @@ void __send_signal(bundle* msg) pthread_mutex_unlock(&g_widget_tidl_info_mutex); } + /** - * TIDL functions for VC client + * TIDL callback functions for VC client */ static void __vc_create_cb(rpc_port_stub_vcd_stub_vc_context_h context, void *user_data) { @@ -730,9 +730,9 @@ static int __vc_get_tts_audio_format_cb(rpc_port_stub_vcd_stub_vc_context_h cont return ret; } -int vcd_client_tidl_open_connection() +int __client_tidl_open_connection() { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_client_tidl_open_connection"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __client_tidl_open_connection"); g_client_callback.create = __vc_create_cb; g_client_callback.terminate = __vc_terminate_cb; @@ -767,2006 +767,2009 @@ int vcd_client_tidl_open_connection() return VCD_ERROR_NONE; } -int vcd_client_tidl_close_connection() +int __client_tidl_close_connection() { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_close_connection"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __client_tidl_close_connection"); rpc_port_stub_vcd_stub_vc_unregister(); return VCD_ERROR_NONE; } -int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) +/** + * TIDL callback functions for VC manager + */ +static void __mgr_on_connected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) { - if (NULL == err_msg) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Input parameter is NULL"); - return VCD_ERROR_INVALID_PARAMETER; - } + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - 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; + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + return; } - 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; - } + mgr_tidl_info->connected = true; + mgr_tidl_info->connection_requesting = false; - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send error signal to app(%d)", pid); + SLOG(LOG_INFO, TAG_VCD, "Connected to manager"); +} - char pid_char[10] = {0}; - char reason_char[10] = {0}; - snprintf(pid_char, 10, "%d", pid); - snprintf(reason_char, 10, "%d", reason); +static void __mgr_on_disconnected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) +{ + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_ERROR_TO_APP); - 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); + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + return; + } - rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); + mgr_tidl_info->connected = false; + mgr_tidl_info->connection_requesting = false; - return VCD_ERROR_NONE; + SLOG(LOG_INFO, TAG_VCD, "Disonnected to manager"); } -int vcdc_send_manager_pid(int manager_pid) +static void __mgr_on_rejected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) { - // send signal to all pid + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - // get all pids - int* client_list = NULL; - int client_count = 0; - int ret = -1; - 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"); - return VCD_ERROR_NONE; + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + return; } - client_tidl_info_s* info; - int pid = -1; - bundle* msg; - char pid_char[10] = {0}; - char mgrpid_char[10] = {0}; - for (int i = 0 ; i < client_count ; i++) { - pid = client_list[i]; - - 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); - continue; - } + mgr_tidl_info->connection_requesting = false; - msg = bundle_create(); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); - continue; - } + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Rejected from manager"); +} - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send manager pid(%d) to app(%d)", manager_pid, pid); +static rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h __mgr_create_rpc_port(const char* engine_app_id) +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] __mgr_create_rpc_port"); + rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_callback_s rpc_callback = { + .connected = __mgr_on_connected, + .disconnected = __mgr_on_disconnected, + .rejected = __mgr_on_rejected + }; - snprintf(pid_char, 10, "%d", pid); - snprintf(mgrpid_char, 10, "%d", manager_pid); + rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h handle = NULL; + if (0 != rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_create(engine_app_id, &rpc_callback, NULL, &handle)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create proxy"); + return NULL; + } - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SEND_MANAGER_PID); - bundle_add_str(msg, VC_BUNDLE_PID, pid_char); - bundle_add_str(msg, VC_BUNDLE_MANAGER_PID, mgrpid_char); + return handle; +} - rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); +static void __vc_mgr_create_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, void *user_data) +{ + char *sender = NULL; - bundle_free(msg); + rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); + if (!sender){ + SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); + return; } - return VCD_ERROR_NONE; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Manager connect. appid(%s)", sender); + + free(sender); } -int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) +static void __vc_mgr_terminate_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, void *user_data) { - if (NULL == buffer || 0 >= len) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter"); - return VCD_ERROR_INVALID_PARAMETER; + pthread_mutex_lock(&g_mgr_tidl_info_mutex); + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info."); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; } - 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; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC MANAGER FINALIZE. pid(%u)", mgr_tidl_info->pid); + + if (0 != vcd_client_manager_unset_tidl_notify_cb()) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback"); } - 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; + if (0 != vcd_client_manager_unset_tidl_send_buffer_cb()) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset send buffer callback"); } - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send feedback streaming to app(%d), utt_id(%d), event(%d), length(%d)", pid, utt_id, event, len); + if (0 != vcd_client_manager_delete_tidl_info()) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to delete manager tidl info"); + } + mgr_tidl_info = NULL; - rpc_port_stub_vcd_stub_array_char_h arr_char = NULL; - rpc_port_stub_vcd_stub_array_char_create(&arr_char); - rpc_port_stub_vcd_stub_array_char_set(arr_char, buffer, len); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - rpc_port_stub_vcd_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - rpc_port_stub_vcd_stub_array_char_destroy(arr_char); - bundle_free(msg); + char *sender = NULL; + rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); + if (!sender) + return; - return VCD_ERROR_NONE; + SLOG(LOG_INFO, TAG_VCD, "@@@ Manager disconnect. appid(%s)", sender); + + free(sender); } -int vcdc_send_hello(int pid, vcd_client_type_e type) +static void __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h notify_callback, rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h send_buffer_callback, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send hello"); - - char tmp_pid[10] = {0, }; + pthread_mutex_lock(&g_mgr_tidl_info_mutex); + SLOG(LOG_INFO, TAG_VCD, "@@@ VC MANAGER REGISTER CALLBACK"); - bundle* msg = bundle_create(); - snprintf(tmp_pid, 10, "%d", pid); + int ret = -1; + ret = vcd_client_manager_create_tidl_info(pid); - if (VCD_CLIENT_TYPE_NORMAL == type) { - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_HELLO); - bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); - } else if (VCD_CLIENT_TYPE_MANAGER == type) { - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_HELLO); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - } else if (VCD_CLIENT_TYPE_WIDGET == type) { - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_HELLO); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_pid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid"); - bundle_free(msg); - return VCD_ERROR_INVALID_PARAMETER; + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create manager tidl info."); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; } - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] VCD SEND MESSAGE"); - - // TODO: VCD_CLIENT_TYPE_MANAGER?? type?? - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, pid); - bundle_free(msg); + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - return VCD_ERROR_NONE; -} + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info. pid(%d)", pid); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; + } -int vcd_tidl_open_connection() -{ - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] vcd_tidl_open_connection"); + char *sender = NULL; + rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); - if (0 != vcd_mgr_tidl_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to manager"); - return VCD_ERROR_OPERATION_FAILED; + if (!sender){ + SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + return; } - if (0 != vcd_client_tidl_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to client"); - return VCD_ERROR_OPERATION_FAILED; + mgr_tidl_info->rpc_h = __mgr_create_rpc_port(sender); + + if (NULL == mgr_tidl_info->rpc_h) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create server proxy"); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] rpc_h(%p), engine_app_id(%s)", mgr_tidl_info->rpc_h, sender); } - if (0 != vcd_widget_tidl_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to widget"); - return VCD_ERROR_OPERATION_FAILED; + free(sender); + + if (0 != vcd_client_manager_set_tidl_notify_cb(notify_callback, user_data)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback"); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); } - if (0 != vcd_setting_tidl_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to setting"); - return VCD_ERROR_OPERATION_FAILED; + if (0 != vcd_client_manager_set_tidl_send_buffer_cb(send_buffer_callback, user_data)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set send buffer callback"); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set send buffer callback."); } - return VCD_ERROR_NONE; + pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + + __request_tidl_connect(VCD_CLIENT_TYPE_MANAGER, pid); + + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -int vcd_tidl_close_connection() +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_DEBUG, TAG_VCD, "[TIDL] vcd_tidl_close_connection"); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Initialize"); - if (0 != vcd_mgr_tidl_close_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to manager"); - return VCD_ERROR_OPERATION_FAILED; - } + int ret = -1; - if (0 != vcd_client_tidl_close_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to client"); - return VCD_ERROR_OPERATION_FAILED; - } - - if (0 != vcd_widget_tidl_close_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to widget"); - return VCD_ERROR_OPERATION_FAILED; - } - - if (0 != vcd_setting_tidl_close_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to setting"); - return VCD_ERROR_OPERATION_FAILED; + vcd_config_set_audio_streaming_mode((vcd_audio_streaming_mode_e)audio_streaming_mode); + ret = vcd_server_mgr_initialize(pid, audio_streaming_mode); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } + *service_state = vcd_server_get_service_state(); + *foreground = vcd_server_get_foreground(); + *daemon_pid = getpid(); - return VCD_ERROR_NONE; + 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; } -int vcdc_send_set_volume(int manager_pid, float volume) +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, "[TIDL] Set volume"); - - char tmp_volume[20] = {0, }; - - bundle* msg = bundle_create(); - - snprintf(tmp_volume, 20, "%.6f", volume); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_VOLUME); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_volume); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Finalize"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr finalize : pid(%d)", pid); + int ret = -1; - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); - if (20 == g_volume_count) { - SLOG(LOG_INFO, TAG_VCD, "@@ Send set volume : pid(%d), volume(%f)", manager_pid, volume); - g_volume_count = 0; + ret = vcd_server_mgr_finalize(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - g_volume_count++; - bundle_free(msg); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return VCD_ERROR_NONE; + return ret; } -int vcdc_send_show_tooltip(int pid, bool show) +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, "[TIDL] Send pre result to manager"); - - char tmp_pid[10] = {0, }; - char tmp_show[10] = {0, }; - - bundle* msg = bundle_create(); - - snprintf(tmp_pid, 10, "%d", pid); - snprintf(tmp_show, 10, "%d", (int)show); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Set command"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set command : pid(%d)", pid); - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SHOW_TOOLTIP); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_WIDGET_BUNDLE_SHOW, tmp_show); + int ret = -1; - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + ret = vcd_server_mgr_set_command(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; + } - __send_msg(msg, VCD_CLIENT_TYPE_WIDGET, pid); - bundle_free(msg); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return VCD_ERROR_NONE; + return ret; } -int vcdc_send_result(int pid, int manager_pid, int cmd_type) +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, "[TIDL] Send result"); - - vcd_client_type_e type; - 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; - } - - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Result command type(%d)", cmd_type); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager unset command"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr unset command : pid(%d)", pid); - switch (cmd_type) { - case VC_COMMAND_TYPE_FOREGROUND: - case VC_COMMAND_TYPE_BACKGROUND: - if (pid == manager_pid) { - type = VCD_CLIENT_TYPE_MANAGER; - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); - } else { - type = VCD_CLIENT_TYPE_NORMAL; - char pid_char[10] = {0}; - snprintf(pid_char, 10, "%d", pid); - bundle_add_str(msg, VC_BUNDLE_PID, pid_char); - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_RESULT); - } - break; - case VC_COMMAND_TYPE_WIDGET: - type = VCD_CLIENT_TYPE_WIDGET; - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT); - break; - case VC_COMMAND_TYPE_SYSTEM: - case VC_COMMAND_TYPE_SYSTEM_BACKGROUND: - case VC_COMMAND_TYPE_EXCLUSIVE: - type = VCD_CLIENT_TYPE_MANAGER; - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); - break; + int ret = -1; - default: - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Command type is NOT valid(%d)", cmd_type); - bundle_free(msg); - return VCD_ERROR_INVALID_PARAMETER; + ret = vcd_server_mgr_unset_command(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - - __send_msg(msg, type, pid); - bundle_free(msg); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return VCD_ERROR_NONE; + return ret; } -int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_result) +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, "[TIDL] Send pre result to manager"); - - char tmp_event[10] = {0, }; - - bundle* msg = bundle_create(); - snprintf(tmp_event, 10, "%d", event); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager Set demandable client"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set demandable client : pid(%d)", pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_PRE_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_PRE_RESULT, pre_result); + int ret = -1; - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + ret = vcd_server_mgr_set_demandable_client(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; + } - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); - bundle_free(msg); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return VCD_ERROR_NONE; + return ret; } -int vcdc_send_specific_engine_result_to_manager(int manager_pid, const char* engine_app_id, const char* event, const char* result) +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, "[TIDL] Send specific engine result to manager"); - - bundle* msg = bundle_create(); - - gchar *gEncodedResult = g_base64_encode((const guchar*)result, strlen(result)); - - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ENGINE_APP_ID, engine_app_id); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_RESULT, gEncodedResult); + 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_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + int ret = -1; - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); - bundle_free(msg); + ret = vcd_server_mgr_set_audio_type(pid, audio_type); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; + } - if (gEncodedResult) - g_free(gEncodedResult); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return VCD_ERROR_NONE; + return ret; } -int vcdc_send_result_to_manager(int manager_pid, int result_type) +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, "[TIDL] Send result to manager"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager get audio type"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio type : pid(%d)", pid); - char tmp_result[10] = {0, }; + int ret = -1; + char* tmp_audio_type = NULL; - bundle* msg = bundle_create(); - snprintf(tmp_result, 10, "%d", result_type); + ret = vcd_server_mgr_get_audio_type(pid, &tmp_audio_type); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + free(tmp_audio_type); + return ret; + } - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ALL_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_result); + *audio_type = strdup(tmp_audio_type); + free(tmp_audio_type); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + return ret; +} - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); - bundle_free(msg); +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); - return VCD_ERROR_NONE; + int ret = -1; + + ret = vcd_server_mgr_set_private_data(pid, key, data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data"); + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + } + + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -int vcdc_send_speech_detected(int manager_pid) +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, "[TIDL] Send speech detected"); + 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); - bundle* msg = bundle_create(); + int ret = -1; + char *temp_data = NULL; - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPEECH_DETECTED); + ret = vcd_server_mgr_get_private_data(pid, key, &temp_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; + } + if (NULL == temp_data) { + SLOG(LOG_INFO, TAG_VCD, "data parameter is NULL"); + temp_data = strdup("#NULL"); + } - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + *data = strdup(temp_data); + free(temp_data); - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); - bundle_free(msg); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return VCD_ERROR_NONE; + return ret; } -int vcdc_send_service_state(vcd_state_e state) +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, "[TIDL] Send service state"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set client info"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set client info : pid(%d)", pid); - char tmp_state[10] = {0, }; + int ret = -1; - bundle* msg = bundle_create(); - snprintf(tmp_state, 10, "%d", (int)state); + ret = vcd_server_mgr_set_client_info(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; + } - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_SERVICE_STATE); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_state); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SET_SERVICE_STATE); - bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); + return ret; +} - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SET_SERVICE_STATE); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_state); +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_DEBUG, TAG_VCD, ">>>> VCD SEND SIGNAL"); - __send_signal(msg); - bundle_free(msg); + int ret = -1; - return VCD_ERROR_NONE; + ret = vcd_server_mgr_set_domain(pid, domain); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; + } + + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + + return ret; } -int vcdc_send_dialog(int manager_pid, int pid, const char* disp_text, const char* utt_text, int continuous) +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, "[TIDL] Send dialog"); + 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); - char tmp_pid[10] = {0, }; - char tmp_continuous[10] = {0, }; - char* tmp_disp_text = NULL; - char* tmp_utt_text = NULL; - bundle* msg = bundle_create(); - snprintf(tmp_pid, 10, "%d", pid); - snprintf(tmp_continuous, 10, "%d", continuous); + int ret = -1; - if (NULL == disp_text) { - tmp_disp_text = strdup("#NULL"); - } else { - tmp_disp_text = strdup(disp_text); + ret = vcd_server_mgr_do_action(pid, type, send_event); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); } - if (NULL == utt_text) { - tmp_utt_text = strdup("#NULL"); - } else { - tmp_utt_text = strdup(utt_text); - } + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); +} - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_DIALOG); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DISP_TEXT, tmp_disp_text); - bundle_add_str(msg, VC_MANAGER_BUNDLE_UTT_TEXT, tmp_utt_text); - bundle_add_str(msg, VC_MANAGER_BUNDLE_CONTINUOUS, tmp_continuous); +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) +{ + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager start"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd check enabled or disabled command types. disabled cmd type(%d)", disabled_cmd_type); - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + int ret = -1; - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); - bundle_free(msg); - free(tmp_disp_text); - free(tmp_utt_text); + vcd_server_mgr_set_disabled_command_type(pid, disabled_cmd_type); - return VCD_ERROR_NONE; + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr start : pid(%d) recognition_mode(%d) exclusive(%d) start by client(%d)", pid, recognition_mode, exclusive_command_option, start_by_client); + ret = vcd_server_mgr_start((vcd_recognition_mode_e)recognition_mode, exclusive_command_option, start_by_client); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; + } + + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + + return ret; } -int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg) +static int __vc_mgr_stop_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] Send error signal to manager"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager stop"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr stop : pid(%d)", pid); - char tmp_reason[10] = {0, }; - char tmp_daemon_pid[10] = {0, }; - char *temp_msg = NULL; + int ret = -1; - if (NULL == err_msg) { - SLOG(LOG_WARN, TAG_VCD, "[TIDL ERROR] Input parameter is NULL"); - temp_msg = strdup("#NULL"); - } else { - temp_msg = strdup(err_msg); + ret = vcd_server_mgr_stop(); + + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } - bundle* msg = bundle_create(); - snprintf(tmp_reason, 10, "%d", reason); - snprintf(tmp_daemon_pid, 10, "%d", getpid()); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_MANAGER_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, temp_msg); + return ret; +} - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); +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); - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); - bundle_free(msg); + int ret = -1; - free(temp_msg); - temp_msg = NULL; + ret = vcd_server_mgr_cancel(); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; + } - return VCD_ERROR_NONE; + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + + return ret; } -/* -// TODO: remove _tidl after remove dbus -// TODO: make client, widget error signal -// But... it seems there is no call of this function.. Need to check. -int vcdc_tidl_send_error(int reason, char *err_msg) +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_ERROR, TAG_VCD, "[TIDL] Send error signal"); + 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); - char tmp_reason[10] = {0, }; - char tmp_daemon_pid[10] = {0, }; - char *temp_msg = NULL; + vcd_config_set_audio_streaming_mode((vcd_audio_streaming_mode_e)mode); - if (NULL == err_msg) { - SLOG(LOG_WARN, TAG_VCD, "[TIDL ERROR] Input parameter is NULL"); - temp_msg = strdup("#NULL"); - } else { - temp_msg = strdup(err_msg); - } + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); +} - bundle* msg = bundle_create(); - snprintf(tmp_reason, 10, "%d", reason); - snprintf(tmp_daemon_pid, 10, "%d", getpid()); +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"); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_MANAGER_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, temp_msg); + int ret = -1; + gsize decodingSize = 0; + gchar *gDecodedRequest = (gchar *)g_base64_decode((const gchar *)request, &decodingSize); - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_WIDGET_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_WIDGET_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_WIDGET_BUNDLE_ERROR_MESSAGE, temp_msg); + if (gDecodedRequest) { + ret = vcd_server_mgr_send_specific_engine_request(pid, engine_app_id, event, gDecodedRequest); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + } - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND SIGNAL"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr specific engine request : pid(%d), engine_app_id(%s), event(%s), request(%s), ret(%d)", pid, engine_app_id, event, gDecodedRequest, ret); + g_free(gDecodedRequest); + } - __send_signal(msg); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); +} - bundle_free(msg); +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); - free(temp_msg); - temp_msg = NULL; + vcd_server_mgr_result_select(); - return VCD_ERROR_NONE; + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -*/ -int vcdc_send_request_set_private_data(int pid, const char* key, const char* data) + +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, "[TIDL] Set private 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); - char tmp_pid[10] = { 0, }; + pthread_mutex_lock(&g_client_tidl_info_mutex); + + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); + client_tidl_info_s* client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } + + rpc_port_stub_vcd_stub_vc_notify_cb_h handle = client_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } bundle* msg = bundle_create(); - snprintf(tmp_pid, 10, "%d", pid); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_PRIVATE_DATA); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_KEY, key); - bundle_add_str(msg, VC_MANAGER_BUNDLE_PRIVATE_DATA, data); + char pid_char[10] = {0}; + char uttid_char[10] = {0}; + char uttstatus_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + snprintf(uttid_char, 10, "%d", utt_id); + snprintf(uttstatus_char, 10, "%d", utt_status); - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + bundle_add_str(msg, VC_BUNDLE_METHOD, VC_MANAGER_METHOD_UTTERANCE_STATUS); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_REASON, uttid_char); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, uttstatus_char); + + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(handle, pid, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + bundle_free(msg); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + return; + } - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, pid); bundle_free(msg); + pthread_mutex_unlock(&g_client_tidl_info_mutex); - return VCD_ERROR_NONE; + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_audio_channel_e channel, vce_audio_type_e audio_type) +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, "[TIDL] Send feedback audio format to manager"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send audio streaming"); - char tmp_rate[10] = {0, }; - char tmp_channel[10] = {0, }; - char tmp_audio_type[10] = {0, }; - - bundle* msg = bundle_create(); - snprintf(tmp_rate, 10, "%d", rate); - snprintf(tmp_channel, 10, "%d", (int)channel); - snprintf(tmp_audio_type, 10, "%d", (int)audio_type); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_RATE, tmp_rate); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_CHANNEL, tmp_channel); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_TYPE, tmp_audio_type); + char* buffer = NULL; + int len = 0; + int ret = -1; + rpc_port_stub_vcd_mgr_stub_array_char_get(data, &buffer, &len); - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send audio streaming : pid(%d), event(%d), buffer(%p), len(%d)", pid, event, buffer, len); - __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); - bundle_free(msg); + ret = vcd_server_mgr_send_audio_streaming(pid, event, buffer, (unsigned int)len); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + } - return VCD_ERROR_NONE; + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) +int __mgr_tidl_open_connection() { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send feedback streaming to manager"); - - char tmp_pid[10] = {0, }; - char tmp_utt_id[10] = {0, }; - char tmp_event[10] = {0, }; - - bundle* msg = bundle_create(); - snprintf(tmp_pid, 10, "%d", pid); - snprintf(tmp_utt_id, 10, "%d", utt_id); - snprintf(tmp_event, 10, "%d", (int)event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_STREAMING); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_UTTID, tmp_utt_id); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] __mgr_tidl_open_connection"); - rpc_port_stub_vcd_mgr_stub_array_char_h streaming_data = NULL; - rpc_port_stub_vcd_mgr_stub_array_char_create(&streaming_data); - if (NULL == streaming_data) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create data handle"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - if (NULL != buffer && 0 < len) { - rpc_port_stub_vcd_mgr_stub_array_char_set(streaming_data, (char*)buffer, len); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] buffer is empty"); - } - - SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - - 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(); + g_mgr_callback.create = __vc_mgr_create_cb; + g_mgr_callback.terminate = __vc_mgr_terminate_cb; + g_mgr_callback.register_cb = __vc_mgr_register_cb_cb; + g_mgr_callback.initialize = __vc_mgr_initialize_cb; + g_mgr_callback.finalize = __vc_mgr_finalize_cb; + g_mgr_callback.set_command = __vc_mgr_set_command_cb; + g_mgr_callback.unset_command = __vc_mgr_unset_command_cb; + g_mgr_callback.demandable_client = __vc_mgr_set_demandable_client_cb; + g_mgr_callback.set_audio_type = __vc_mgr_set_audio_type_cb; + g_mgr_callback.get_audio_type = __vc_mgr_get_audio_type_cb; + g_mgr_callback.set_private_data = __vc_mgr_set_private_data_cb; + g_mgr_callback.get_private_data = __vc_mgr_get_private_data_cb; + g_mgr_callback.set_client_info = __vc_mgr_set_client_info_cb; + g_mgr_callback.set_domain = __vc_mgr_set_domain_cb; + g_mgr_callback.do_action = __vc_mgr_do_action_cb; + g_mgr_callback.start = __vc_mgr_start_cb; + g_mgr_callback.stop = __vc_mgr_stop_cb; + g_mgr_callback.cancel = __vc_mgr_cancel_cb; + g_mgr_callback.set_audio_streaming_mode = __vc_mgr_set_audio_streaming_mode_cb; + g_mgr_callback.send_specific_engine_request = __vc_mgr_send_specific_engine_request_cb; + g_mgr_callback.send_result_selection = __vc_mgr_send_result_selection_cb; + g_mgr_callback.send_utterance_status = __vc_mgr_send_utterance_status_cb; + g_mgr_callback.send_audio_streaming = __vc_mgr_send_audio_streaming_cb; - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info. pid(%d)", pid); - 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; + int ret = -1; + int count = 0; + while (VC_RETRY_MIN_COUNT >= count) { + ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_register(&g_mgr_callback, NULL); + if (0 == ret) { + SLOG(LOG_DEBUG, TAG_VCD, "register callback"); + return VCD_ERROR_NONE; + } + usleep(100000); + count++; } - rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h handle = mgr_tidl_info->send_buffer_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - 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; - } + SLOG(LOG_ERROR, TAG_VCD, "Fail to register callback(%d)", ret); + return VCD_ERROR_OPERATION_FAILED; +} - if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_invoke(handle, streaming_data, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - 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; - } - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - rpc_port_stub_vcd_mgr_stub_array_char_destroy(streaming_data); - bundle_free(msg); +int __mgr_tidl_close_connection() +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Close connection"); + rpc_port_stub_vcd_mgr_stub_vc_mgr_unregister(); return VCD_ERROR_NONE; } -void vcdc_send_request_set_foreground(int pid, int value) +/** + * TIDL callback functions for VC widget + */ +static void __widget_on_connected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Set foreground"); + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + widget_tidl_info->connected = true; + widget_tidl_info->connection_requesting = false; - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); - return; - } + SLOG(LOG_INFO, TAG_VCD, "Connected to widget"); +} - if (!mgr_tidl_info->connected) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); - return; - } +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); - rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_set_foreground(mgr_tidl_info->rpc_h, pid, value); + widget_tidl_info->connected = false; + widget_tidl_info->connection_requesting = false; - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request set foreground"); + SLOG(LOG_INFO, TAG_VCD, "Disonnected to widget"); } -int vcdc_send_request_get_private_data(int pid, const char* key, char** data) +static void __widget_on_rejected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Get private data"); + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + widget_tidl_info->connection_requesting = false; - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); - return VC_ERROR_OPERATION_FAILED; - } + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Rejected from widget"); +} - if (!mgr_tidl_info->connected) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); - return VC_ERROR_OPERATION_FAILED; - } +static rpc_port_proxy_vcd_widget_proxy_vcd_widget_h __widget_create_rpc_port(const char* engine_app_id, int pid) +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] __widget_create_rpc_port"); + rpc_port_proxy_vcd_widget_proxy_vcd_widget_callback_s rpc_callback = { + .connected = __widget_on_connected, + .disconnected = __widget_on_disconnected, + .rejected = __widget_on_rejected + }; - char *tmp = NULL; - int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_get_private_data(mgr_tidl_info->rpc_h, pid, key, &tmp); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request vcd manager get private data : Fail to invoke message, error(%d)", ret); - return ret; + 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)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create proxy"); + return NULL; } - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request vcd manager get private data : Success"); - *data = tmp; - - return VC_ERROR_NONE; + return handle; } -int vcdc_send_request_auth_enable(int pid) +static void __vc_widget_create_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth enable"); - - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); - return VC_ERROR_OPERATION_FAILED; - } - - if (!mgr_tidl_info->connected) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); - return VC_ERROR_OPERATION_FAILED; - } + char *sender = NULL; - int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_enable(mgr_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth enable : Fail to invoke message, error(%d)", ret); - return ret; + rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); + if (!sender) { + SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); + return; } - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth enable : Success"); - return VC_ERROR_NONE; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ Widget connect. appid(%s)", sender); + free(sender); } -int vcdc_send_request_auth_disable(int pid) +static void __vc_widget_terminate_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth disable"); - - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + void* tag = NULL; + rpc_port_stub_vcd_widget_stub_vc_widget_context_get_tag(context, &tag); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); - return VC_ERROR_OPERATION_FAILED; - } + if (NULL != tag) { + int pid = (intptr_t)tag; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC WIDGET FINALIZE. pid(%u)", pid); - if (!mgr_tidl_info->connected) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); - return VC_ERROR_OPERATION_FAILED; - } + pthread_mutex_lock(&g_widget_tidl_info_mutex); + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); + if (NULL == widget_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get widget tidl info."); + pthread_mutex_unlock(&g_widget_tidl_info_mutex); + return; + } - int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_disable(mgr_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth disable : Fail to invoke message, error(%d)", ret); - return ret; - } - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth disable : Success"); + if (0 != vcd_client_widget_unset_tidl_notify_cb(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback"); + } - return VC_ERROR_NONE; -} + if (0 != vcd_client_widget_delete_tidl_info(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to delete widget tidl info"); + } + widget_tidl_info = NULL; -int vcdc_send_request_auth_start(int pid) -{ - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth start"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + pthread_mutex_unlock(&g_widget_tidl_info_mutex); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); - return VC_ERROR_OPERATION_FAILED; - } + char *sender = NULL; + rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); + if (!sender) + return; - if (!mgr_tidl_info->connected) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); - return VC_ERROR_OPERATION_FAILED; - } + SLOG(LOG_INFO, TAG_VCD, "@@@ Manager disconnect. appid(%s)", sender); - int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_start(mgr_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth start : Fail to invoke message, error(%d)", ret); - return ret; + free(sender); } - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth start : Success"); - - return VC_ERROR_NONE; + rpc_port_stub_vcd_widget_stub_vc_widget_context_set_tag(context, NULL); } -int vcdc_send_request_auth_stop(int pid) +static void __vc_widget_register_cb_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h notify_callback, void *user_data) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth stop"); + pthread_mutex_lock(&g_widget_tidl_info_mutex); + SLOG(LOG_INFO, TAG_VCD, "@@@ VC WIDGET REGISTER CALLBACK"); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + int ret = -1; + ret = vcd_client_widget_add_tidl_info(pid); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); - return VC_ERROR_OPERATION_FAILED; + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add widget tidl info."); + pthread_mutex_unlock(&g_widget_tidl_info_mutex); + return; } + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); - if (!mgr_tidl_info->connected) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); - return VC_ERROR_OPERATION_FAILED; + if (NULL == widget_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get widget tidl info. pid(%d)", pid); + pthread_mutex_unlock(&g_widget_tidl_info_mutex); + return; } - int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_stop(mgr_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth stop : Fail to invoke message, error(%d)", ret); - return ret; + char *sender = NULL; + rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); + + if (!sender){ + SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); + pthread_mutex_unlock(&g_widget_tidl_info_mutex); + return; } - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth stop : Success"); - return VC_ERROR_NONE; -} + widget_tidl_info->rpc_h = __widget_create_rpc_port(sender, pid); -int vcdc_send_request_auth_cancel(int pid) -{ - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth cancel"); + if (NULL == widget_tidl_info->rpc_h) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create server proxy"); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] rpc_h(%p), engine_app_id(%s)", widget_tidl_info->rpc_h, sender); + } - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + free(sender); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); - return VC_ERROR_OPERATION_FAILED; + if (0 != vcd_client_widget_set_tidl_notify_cb(pid, notify_callback, user_data)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback"); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); } - if (!mgr_tidl_info->connected) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); - return VC_ERROR_OPERATION_FAILED; - } + pthread_mutex_unlock(&g_widget_tidl_info_mutex); - int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_cancel(mgr_tidl_info->rpc_h, pid); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth cancel : Fail to invoke message, error(%d)", ret); - return ret; - } - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth cancel : Success"); + __request_tidl_connect(VCD_CLIENT_TYPE_WIDGET, pid); - return VC_ERROR_NONE; + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); } -int vcdc_send_asr_result(int pid, int event, const char* asr_result, int cmd_type, bool* is_consumed) +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) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send asr result"); - - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); + SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Initialize"); - if (NULL == widget_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); - return VC_ERROR_OPERATION_FAILED; - } + uintptr_t ptr_pid = pid; + int ret = -1; - if (!widget_tidl_info->connected) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); - return VC_ERROR_OPERATION_FAILED; - } + rpc_port_stub_vcd_widget_stub_vc_widget_context_set_tag(context, (void*)ptr_pid); - bool temp; - int ret = rpc_port_proxy_vcd_widget_proxy_vcd_widget_invoke_send_asr_result(widget_tidl_info->rpc_h, pid, event, asr_result, &temp); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request vcd widget send asr result : Fail to invoke message, error(%d)", ret); + ret = vcd_server_widget_initialize(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request vcd widget send asr result : Success"); - - *is_consumed = temp; + *service_state = vcd_server_get_service_state(); + *daemon_pid = getpid(); - return VC_ERROR_NONE; + 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; } -/* -* Tidl for manager -*/ -static void __mgr_on_connected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) +static int __vc_widget_finalize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - 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"); - return; - } - - mgr_tidl_info->connected = true; - mgr_tidl_info->connection_requesting = false; - - SLOG(LOG_INFO, TAG_VCD, "Connected to manager"); -} + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Finalize"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget finalize : pid(%d)", pid); -static void __mgr_on_disconnected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) -{ - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + int ret = -1; - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - return; + ret = vcd_server_widget_finalize(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } - mgr_tidl_info->connected = false; - mgr_tidl_info->connection_requesting = false; + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - SLOG(LOG_INFO, TAG_VCD, "Disonnected to manager"); + return ret; } -static void __mgr_on_rejected(rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h h, void *user_data) +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) { - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + 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); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - return; + int ret = -1; + + ret = vcd_server_widget_start_recording(pid, command); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } - mgr_tidl_info->connection_requesting = false; + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Rejected from manager"); + return ret; } -static rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h __mgr_create_rpc_port(const char* engine_app_id) +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, "[TIDL] __mgr_create_rpc_port"); - rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_callback_s rpc_callback = { - .connected = __mgr_on_connected, - .disconnected = __mgr_on_disconnected, - .rejected = __mgr_on_rejected - }; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Start"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start : pid(%d) silence(%d)", pid, silence); - rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_h handle = NULL; - if (0 != rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_create(engine_app_id, &rpc_callback, NULL, &handle)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create proxy"); - return NULL; + int ret = -1; + + ret = vcd_server_widget_start(pid, (bool)silence); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } - return handle; + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + + return ret; } -static void __vc_mgr_create_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, void *user_data) +static int __vc_widget_stop_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - char *sender = NULL; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Stop"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget stop : pid(%d)", pid); - rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); - if (!sender){ - SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); - return; + int ret = -1; + + ret = vcd_server_widget_stop(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@ Manager connect. appid(%s)", sender); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - free(sender); + return ret; } -static void __vc_mgr_terminate_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, void *user_data) +static int __vc_widget_cancel_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) { - pthread_mutex_lock(&g_mgr_tidl_info_mutex); - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info."); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC MANAGER FINALIZE. pid(%u)", mgr_tidl_info->pid); - - if (0 != vcd_client_manager_unset_tidl_notify_cb()) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback"); - } + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Cancel"); + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget cancel : pid(%d)", pid); - if (0 != vcd_client_manager_unset_tidl_send_buffer_cb()) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset send buffer callback"); - } + int ret = -1; - if (0 != vcd_client_manager_delete_tidl_info()) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to delete manager tidl info"); + ret = vcd_server_widget_cancel(pid); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } - mgr_tidl_info = NULL; SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - - - char *sender = NULL; - rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); - if (!sender) - return; - - SLOG(LOG_INFO, TAG_VCD, "@@@ Manager disconnect. appid(%s)", sender); - - free(sender); + return ret; } -static void __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h notify_callback, rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h send_buffer_callback, void *user_data) +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) { - pthread_mutex_lock(&g_mgr_tidl_info_mutex); - SLOG(LOG_INFO, TAG_VCD, "@@@ VC MANAGER REGISTER CALLBACK"); + 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); int ret = -1; - ret = vcd_client_manager_create_tidl_info(pid); + ret = vcd_server_widget_enable_asr_result(pid, enable); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create manager tidl info."); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + return ret; } - manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - if (NULL == mgr_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info. pid(%d)", pid); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - return; - } + return ret; +} - char *sender = NULL; - rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender); +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); - if (!sender){ - SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + int ret = -1; + + ret = vcd_server_set_foreground(pid, value); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); return; } - mgr_tidl_info->rpc_h = __mgr_create_rpc_port(sender); + SLOG(LOG_DEBUG, TAG_VCD, "@@@ send request set foreground to manager"); + vcdc_send_request_set_foreground(pid, value); - if (NULL == mgr_tidl_info->rpc_h) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create server proxy"); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] rpc_h(%p), engine_app_id(%s)", mgr_tidl_info->rpc_h, sender); - } + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - free(sender); + return; +} - if (0 != vcd_client_manager_set_tidl_notify_cb(notify_callback, user_data)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback"); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); - } +int __widget_tidl_open_connection() +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] __widget_tidl_open_connection"); - if (0 != vcd_client_manager_set_tidl_send_buffer_cb(send_buffer_callback, user_data)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set send buffer callback"); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set send buffer callback."); + g_widget_callback.create = __vc_widget_create_cb; + g_widget_callback.terminate = __vc_widget_terminate_cb; + g_widget_callback.register_cb = __vc_widget_register_cb_cb; + g_widget_callback.initialize = __vc_widget_initialize_cb; + g_widget_callback.finalize = __vc_widget_finalize_cb; + g_widget_callback.start_recording = __vc_widget_start_recording_cb; + g_widget_callback.start = __vc_widget_start_cb; + g_widget_callback.stop = __vc_widget_stop_cb; + g_widget_callback.cancel = __vc_widget_cancel_cb; + g_widget_callback.enable_asr_result = __vc_widget_enable_asr_result_cb; + g_widget_callback.set_foreground = __vc_widget_set_foreground_cb; + + int ret = -1; + int count = 0; + while (VC_RETRY_MIN_COUNT >= count) { + ret = rpc_port_stub_vcd_widget_stub_vc_widget_register(&g_widget_callback, NULL); + if (0 == ret) { + SLOG(LOG_DEBUG, TAG_VCD, "register callback"); + return VCD_ERROR_NONE; + } + usleep(100000); + count++; } - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); + SLOG(LOG_ERROR, TAG_VCD, "Fail to register callback(%d)", ret); + return VCD_ERROR_OPERATION_FAILED; +} - __request_tidl_connect(VCD_CLIENT_TYPE_MANAGER, pid); +int __widget_tidl_close_connection() +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Close connection"); + rpc_port_stub_vcd_widget_stub_vc_widget_unregister(); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + return VCD_ERROR_NONE; } -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) +/** + * TIDL callback functions for VC setting client + */ +static void __vc_setting_create_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, void *user_data) { - SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Manager Initialize"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_create_cb"); - int ret = -1; + char *sender = NULL; - vcd_config_set_audio_streaming_mode((vcd_audio_streaming_mode_e)audio_streaming_mode); - ret = vcd_server_mgr_initialize(pid, audio_streaming_mode); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + rpc_port_stub_vcd_setting_stub_vc_setting_context_get_sender(context, &sender); + if (!sender) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); + return; } - *service_state = vcd_server_get_service_state(); - *foreground = vcd_server_get_foreground(); - *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; + SLOG(LOG_INFO, TAG_VCD, "[TIDL] sender(%s)", sender); // sender (app_id) + free(sender); } -static int __vc_mgr_finalize_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) +static void __vc_setting_terminate_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, 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, "[TIDL] __vc_setting_terminate_cb"); + void* tag = NULL; + rpc_port_stub_vcd_setting_stub_vc_setting_context_get_tag(context, &tag); - int ret = -1; + if (NULL != tag) { + int pid = (intptr_t)tag; + SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC SETTING FINALIZE. pid(%u)", pid); - ret = vcd_server_mgr_finalize(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } + pthread_mutex_lock(&g_setting_tidl_info_mutex); + setting_tidl_info_s* setting_tidl_info = vcd_client_setting_get_tidl_info(pid); + if (NULL == setting_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get setting tidl info."); + pthread_mutex_unlock(&g_setting_tidl_info_mutex); + return; + } + + if (0 != vcd_client_setting_unset_tidl_notify_cb(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback"); + } + + if (0 != vcd_client_setting_delete_tidl_info(pid)) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to delete setting tidl info"); + } + setting_tidl_info = NULL; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return ret; + pthread_mutex_unlock(&g_setting_tidl_info_mutex); + } + rpc_port_stub_vcd_setting_stub_vc_setting_context_set_tag(context, NULL); } -static int __vc_mgr_set_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) +static void __vc_setting_register_notify_cb_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, 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, "[TIDL] __vc_setting_register_notify_cb_cb. pid(%d)", pid); - int ret = -1; + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return; + } - ret = vcd_server_mgr_set_command(pid); + int ret = -1; + ret = vcd_client_setting_add_tidl_info(pid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + return; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return ret; + ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } } -static int __vc_mgr_unset_command_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) +static int __vc_setting_register_notify_cb_sync_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, 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, "[TIDL] __vc_setting_register_notify_cb_sync_cb. pid(%d)", pid); - int ret = -1; + if (NULL == callback) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); + return VCD_ERROR_INVALID_PARAMETER; + } - ret = vcd_server_mgr_unset_command(pid); + int ret = -1; + ret = vcd_client_setting_add_tidl_info(pid); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); return ret; } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + + ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + } 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) +int __vc_setting_set_language_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, const char *language, 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); + if (NULL == language) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter"); + return VCD_ERROR_INVALID_PARAMETER; + } - int ret = -1; + SLOG(LOG_INFO, TAG_VCD, "[IN] vcd server set language : language(%s)", language); - ret = vcd_server_mgr_set_demandable_client(pid); + int ret = vcd_server_set_language(language); if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set language(%d).", ret); + } else { + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set language."); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - 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) +int __setting_tidl_open_connection() { - 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_DEBUG, TAG_VCD, "[TIDL] __setting_tidl_open_connection"); - int ret = -1; + g_setting_callback.create = __vc_setting_create_cb; + g_setting_callback.terminate = __vc_setting_terminate_cb; + g_setting_callback.register_notify_cb = __vc_setting_register_notify_cb_cb; + g_setting_callback.register_notify_cb_sync = __vc_setting_register_notify_cb_sync_cb; + g_setting_callback.set_language = __vc_setting_set_language_cb; - ret = vcd_server_mgr_set_audio_type(pid, audio_type); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + int ret = -1; + int count = 0; + while (VC_RETRY_MIN_COUNT >= count) { + ret = rpc_port_stub_vcd_setting_stub_vc_setting_register(&g_setting_callback, NULL); + if (0 == ret) { + SLOG(LOG_DEBUG, TAG_VCD, "register callback"); + return VCD_ERROR_NONE; + } + usleep(100000); + count++; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return ret; + SLOG(LOG_ERROR, TAG_VCD, "Fail to register callback(%d)", ret); + return VCD_ERROR_OPERATION_FAILED; } -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) +int __setting_tidl_close_connection() { - 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_DEBUG, TAG_VCD, "[TIDL] Close connection"); + rpc_port_stub_vcd_setting_stub_vc_setting_unregister(); - int ret = -1; - char* tmp_audio_type = NULL; + return VCD_ERROR_NONE; +} - ret = vcd_server_mgr_get_audio_type(pid, &tmp_audio_type); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - free(tmp_audio_type); - return ret; + + +int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) +{ + if (NULL == err_msg) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Input parameter is NULL"); + return VCD_ERROR_INVALID_PARAMETER; } - *audio_type = strdup(tmp_audio_type); - free(tmp_audio_type); + 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; + } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + 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 ret; -} + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send error signal to app(%d)", pid); -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); + char pid_char[10] = {0}; + char reason_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + snprintf(reason_char, 10, "%d", reason); - int ret = -1; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_ERROR_TO_APP); + 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); - ret = vcd_server_mgr_set_private_data(pid, key, data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data"); - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + return VCD_ERROR_NONE; } -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) +int vcdc_send_manager_pid(int manager_pid) { - 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); + // send signal to all pid + // get all pids + int* client_list = NULL; + int client_count = 0; int ret = -1; - char *temp_data = NULL; - - ret = vcd_server_mgr_get_private_data(pid, key, &temp_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; - } - if (NULL == temp_data) { - SLOG(LOG_INFO, TAG_VCD, "data parameter is NULL"); - temp_data = strdup("#NULL"); + 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"); + return VCD_ERROR_NONE; } - *data = strdup(temp_data); - free(temp_data); + client_tidl_info_s* info; + int pid = -1; + bundle* msg; + char pid_char[10] = {0}; + char mgrpid_char[10] = {0}; + for (int i = 0 ; i < client_count ; i++) { + pid = client_list[i]; - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + 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); + continue; + } - return ret; -} + msg = bundle_create(); + if (NULL == msg) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); + continue; + } -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, "[TIDL] Send manager pid(%d) to app(%d)", manager_pid, pid); - int ret = -1; + snprintf(pid_char, 10, "%d", pid); + snprintf(mgrpid_char, 10, "%d", manager_pid); - ret = vcd_server_mgr_set_client_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; - } + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SEND_MANAGER_PID); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_MANAGER_PID, mgrpid_char); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + rpc_port_stub_vcd_stub_vc_notify_cb_invoke(info->notify_cb, pid, msg); - return ret; + bundle_free(msg); + } + + return VCD_ERROR_NONE; } -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) +int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) { - 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); + if (NULL == buffer || 0 >= len) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter"); + return VCD_ERROR_INVALID_PARAMETER; + } - int ret = -1; + 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; + } - ret = vcd_server_mgr_set_domain(pid, domain); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + 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; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send feedback streaming to app(%d), utt_id(%d), event(%d), length(%d)", pid, utt_id, event, len); - return ret; -} + rpc_port_stub_vcd_stub_array_char_h arr_char = NULL; + rpc_port_stub_vcd_stub_array_char_create(&arr_char); + rpc_port_stub_vcd_stub_array_char_set(arr_char, buffer, len); -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); + rpc_port_stub_vcd_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len); - int ret = -1; + rpc_port_stub_vcd_stub_array_char_destroy(arr_char); - ret = vcd_server_mgr_do_action(pid, type, send_event); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } + bundle_free(msg); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + return VCD_ERROR_NONE; } -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) +int vcdc_send_hello(int pid, vcd_client_type_e type) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager start"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd check enabled or disabled command types. disabled cmd type(%d)", disabled_cmd_type); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send hello"); - int ret = -1; + char tmp_pid[10] = {0, }; - vcd_server_mgr_set_disabled_command_type(pid, disabled_cmd_type); + bundle* msg = bundle_create(); + snprintf(tmp_pid, 10, "%d", pid); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr start : pid(%d) recognition_mode(%d) exclusive(%d) start by client(%d)", pid, recognition_mode, exclusive_command_option, start_by_client); - ret = vcd_server_mgr_start((vcd_recognition_mode_e)recognition_mode, exclusive_command_option, start_by_client); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + if (VCD_CLIENT_TYPE_NORMAL == type) { + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_HELLO); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + } else if (VCD_CLIENT_TYPE_MANAGER == type) { + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_HELLO); + bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); + } else if (VCD_CLIENT_TYPE_WIDGET == type) { + bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_HELLO); + bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_pid); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid"); + bundle_free(msg); + return VCD_ERROR_INVALID_PARAMETER; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] VCD SEND MESSAGE"); - return ret; + // TODO: VCD_CLIENT_TYPE_MANAGER?? type?? + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, pid); + bundle_free(msg); + + return VCD_ERROR_NONE; } -static int __vc_mgr_stop_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) +int vcd_tidl_open_connection() { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager stop"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr stop : pid(%d)", pid); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] vcd_tidl_open_connection"); - int ret = -1; + if (0 != __mgr_tidl_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to manager"); + return VCD_ERROR_OPERATION_FAILED; + } - ret = vcd_server_mgr_stop(); + if (0 != __client_tidl_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to client"); + return VCD_ERROR_OPERATION_FAILED; + } - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + if (0 != __widget_tidl_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to widget"); + return VCD_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + if (0 != __setting_tidl_open_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to open connection to setting"); + return VCD_ERROR_OPERATION_FAILED; + } - return ret; + return VCD_ERROR_NONE; } -static int __vc_mgr_cancel_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, int pid, void *user_data) +int vcd_tidl_close_connection() { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager cancel"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr cancel : pid(%d)", pid); - - int ret = -1; + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] vcd_tidl_close_connection"); - ret = vcd_server_mgr_cancel(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + if (0 != __mgr_tidl_close_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to manager"); + return VCD_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return ret; -} + if (0 != __client_tidl_close_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to client"); + return VCD_ERROR_OPERATION_FAILED; + } -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); + if (0 != __widget_tidl_close_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to widget"); + return VCD_ERROR_OPERATION_FAILED; + } - vcd_config_set_audio_streaming_mode((vcd_audio_streaming_mode_e)mode); + if (0 != __setting_tidl_close_connection()) { + SLOG(LOG_ERROR, TAG_VCD, "Fail to close connection to setting"); + return VCD_ERROR_OPERATION_FAILED; + } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + return VCD_ERROR_NONE; } -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) +int vcdc_send_set_volume(int manager_pid, float volume) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager specific engine request"); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Set volume"); - int ret = -1; - gsize decodingSize = 0; - gchar *gDecodedRequest = (gchar *)g_base64_decode((const gchar *)request, &decodingSize); + char tmp_volume[20] = {0, }; - if (gDecodedRequest) { - ret = vcd_server_mgr_send_specific_engine_request(pid, engine_app_id, event, gDecodedRequest); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } + bundle* msg = bundle_create(); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr specific engine request : pid(%d), engine_app_id(%s), event(%s), request(%s), ret(%d)", pid, engine_app_id, event, gDecodedRequest, ret); - g_free(gDecodedRequest); - } + snprintf(tmp_volume, 20, "%.6f", volume); + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_VOLUME); + bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_volume); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); -} -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_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); + if (20 == g_volume_count) { + SLOG(LOG_INFO, TAG_VCD, "@@ Send set volume : pid(%d), volume(%f)", manager_pid, volume); + g_volume_count = 0; + } + g_volume_count++; - vcd_server_mgr_result_select(); + bundle_free(msg); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + return VCD_ERROR_NONE; } -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) +int vcdc_send_show_tooltip(int pid, bool show) { - 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); - - pthread_mutex_lock(&g_client_tidl_info_mutex); - - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to client"); - client_tidl_info_s* client_tidl_info = vcd_client_get_tidl_info(pid); - if (NULL == client_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] tidl proxy info not allocated"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send pre result to manager"); - rpc_port_stub_vcd_stub_vc_notify_cb_h handle = client_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } + char tmp_pid[10] = {0, }; + char tmp_show[10] = {0, }; bundle* msg = bundle_create(); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data"); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } - char pid_char[10] = {0}; - char uttid_char[10] = {0}; - char uttstatus_char[10] = {0}; - snprintf(pid_char, 10, "%d", pid); - snprintf(uttid_char, 10, "%d", utt_id); - snprintf(uttstatus_char, 10, "%d", utt_status); + snprintf(tmp_pid, 10, "%d", pid); + snprintf(tmp_show, 10, "%d", (int)show); - bundle_add_str(msg, VC_BUNDLE_METHOD, VC_MANAGER_METHOD_UTTERANCE_STATUS); - bundle_add_str(msg, VC_BUNDLE_PID, pid_char); - bundle_add_str(msg, VC_BUNDLE_REASON, uttid_char); - bundle_add_str(msg, VC_BUNDLE_ERR_MSG, uttstatus_char); + bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SHOW_TOOLTIP); + bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_WIDGET_BUNDLE_SHOW, tmp_show); - if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(handle, pid, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - bundle_free(msg); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - return; - } + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + __send_msg(msg, VCD_CLIENT_TYPE_WIDGET, pid); bundle_free(msg); - pthread_mutex_unlock(&g_client_tidl_info_mutex); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + return VCD_ERROR_NONE; } -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) +int vcdc_send_result(int pid, int manager_pid, int cmd_type) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send audio streaming"); - - char* buffer = NULL; - int len = 0; - int ret = -1; - rpc_port_stub_vcd_mgr_stub_array_char_get(data, &buffer, &len); - - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send audio streaming : pid(%d), event(%d), buffer(%p), len(%d)", pid, event, buffer, len); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send result"); - ret = vcd_server_mgr_send_audio_streaming(pid, event, buffer, (unsigned int)len); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); + vcd_client_type_e type; + 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; } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); -} - -int vcd_mgr_tidl_open_connection() -{ - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] vcd_mgr_tidl_open_connection"); - - g_mgr_callback.create = __vc_mgr_create_cb; - g_mgr_callback.terminate = __vc_mgr_terminate_cb; - g_mgr_callback.register_cb = __vc_mgr_register_cb_cb; - g_mgr_callback.initialize = __vc_mgr_initialize_cb; - g_mgr_callback.finalize = __vc_mgr_finalize_cb; - g_mgr_callback.set_command = __vc_mgr_set_command_cb; - g_mgr_callback.unset_command = __vc_mgr_unset_command_cb; - g_mgr_callback.demandable_client = __vc_mgr_set_demandable_client_cb; - g_mgr_callback.set_audio_type = __vc_mgr_set_audio_type_cb; - g_mgr_callback.get_audio_type = __vc_mgr_get_audio_type_cb; - g_mgr_callback.set_private_data = __vc_mgr_set_private_data_cb; - g_mgr_callback.get_private_data = __vc_mgr_get_private_data_cb; - g_mgr_callback.set_client_info = __vc_mgr_set_client_info_cb; - g_mgr_callback.set_domain = __vc_mgr_set_domain_cb; - g_mgr_callback.do_action = __vc_mgr_do_action_cb; - g_mgr_callback.start = __vc_mgr_start_cb; - g_mgr_callback.stop = __vc_mgr_stop_cb; - g_mgr_callback.cancel = __vc_mgr_cancel_cb; - g_mgr_callback.set_audio_streaming_mode = __vc_mgr_set_audio_streaming_mode_cb; - g_mgr_callback.send_specific_engine_request = __vc_mgr_send_specific_engine_request_cb; - g_mgr_callback.send_result_selection = __vc_mgr_send_result_selection_cb; - g_mgr_callback.send_utterance_status = __vc_mgr_send_utterance_status_cb; - g_mgr_callback.send_audio_streaming = __vc_mgr_send_audio_streaming_cb; + SLOG(LOG_INFO, TAG_VCD, "[TIDL] Result command type(%d)", cmd_type); - int ret = -1; - int count = 0; - while (VC_RETRY_MIN_COUNT >= count) { - ret = rpc_port_stub_vcd_mgr_stub_vc_mgr_register(&g_mgr_callback, NULL); - if (0 == ret) { - SLOG(LOG_DEBUG, TAG_VCD, "register callback"); - return VCD_ERROR_NONE; + switch (cmd_type) { + case VC_COMMAND_TYPE_FOREGROUND: + case VC_COMMAND_TYPE_BACKGROUND: + if (pid == manager_pid) { + type = VCD_CLIENT_TYPE_MANAGER; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); + } else { + type = VCD_CLIENT_TYPE_NORMAL; + char pid_char[10] = {0}; + snprintf(pid_char, 10, "%d", pid); + bundle_add_str(msg, VC_BUNDLE_PID, pid_char); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_RESULT); } - usleep(100000); - count++; + break; + case VC_COMMAND_TYPE_WIDGET: + type = VCD_CLIENT_TYPE_WIDGET; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT); + break; + case VC_COMMAND_TYPE_SYSTEM: + case VC_COMMAND_TYPE_SYSTEM_BACKGROUND: + case VC_COMMAND_TYPE_EXCLUSIVE: + type = VCD_CLIENT_TYPE_MANAGER; + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT); + break; + + default: + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Command type is NOT valid(%d)", cmd_type); + bundle_free(msg); + return VCD_ERROR_INVALID_PARAMETER; } - SLOG(LOG_ERROR, TAG_VCD, "Fail to register callback(%d)", ret); - return VCD_ERROR_OPERATION_FAILED; -} + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); -int vcd_mgr_tidl_close_connection() -{ - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Close connection"); - rpc_port_stub_vcd_mgr_stub_vc_mgr_unregister(); + __send_msg(msg, type, pid); + bundle_free(msg); return VCD_ERROR_NONE; } -/* -* Tidl for widget -*/ -static void __widget_on_connected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) +int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_result) { - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send pre result to manager"); - widget_tidl_info->connected = true; - widget_tidl_info->connection_requesting = false; + char tmp_event[10] = {0, }; - SLOG(LOG_INFO, TAG_VCD, "Connected to widget"); -} + bundle* msg = bundle_create(); + snprintf(tmp_event, 10, "%d", event); -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); + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_PRE_RESULT); + bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); + bundle_add_str(msg, VC_MANAGER_BUNDLE_PRE_RESULT, pre_result); - widget_tidl_info->connected = false; - widget_tidl_info->connection_requesting = false; + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - SLOG(LOG_INFO, TAG_VCD, "Disonnected to widget"); + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); + bundle_free(msg); + + return VCD_ERROR_NONE; } -static void __widget_on_rejected(rpc_port_proxy_vcd_widget_proxy_vcd_widget_h h, void *user_data) +int vcdc_send_specific_engine_result_to_manager(int manager_pid, const char* engine_app_id, const char* event, const char* result) { - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info((int)user_data); - - widget_tidl_info->connection_requesting = false; + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send specific engine result to manager"); - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Rejected from widget"); -} + bundle* msg = bundle_create(); -static rpc_port_proxy_vcd_widget_proxy_vcd_widget_h __widget_create_rpc_port(const char* engine_app_id, int pid) -{ - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] __widget_create_rpc_port"); - rpc_port_proxy_vcd_widget_proxy_vcd_widget_callback_s rpc_callback = { - .connected = __widget_on_connected, - .disconnected = __widget_on_disconnected, - .rejected = __widget_on_rejected - }; + gchar *gEncodedResult = g_base64_encode((const guchar*)result, strlen(result)); - 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)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create proxy"); - return NULL; - } + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT); + bundle_add_str(msg, VC_MANAGER_BUNDLE_ENGINE_APP_ID, engine_app_id); + bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, event); + bundle_add_str(msg, VC_MANAGER_BUNDLE_RESULT, gEncodedResult); - return handle; -} + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); -static void __vc_widget_create_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, void *user_data) -{ - char *sender = NULL; + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); + bundle_free(msg); - rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); - if (!sender) { - SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); - return; - } + if (gEncodedResult) + g_free(gEncodedResult); - SLOG(LOG_DEBUG, TAG_VCD, "@@@ Widget connect. appid(%s)", sender); - free(sender); + return VCD_ERROR_NONE; } -static void __vc_widget_terminate_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, void *user_data) +int vcdc_send_result_to_manager(int manager_pid, int result_type) { - void* tag = NULL; - rpc_port_stub_vcd_widget_stub_vc_widget_context_get_tag(context, &tag); - - if (NULL != tag) { - int pid = (intptr_t)tag; - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC WIDGET FINALIZE. pid(%u)", pid); - - pthread_mutex_lock(&g_widget_tidl_info_mutex); - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); - if (NULL == widget_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get widget tidl info."); - pthread_mutex_unlock(&g_widget_tidl_info_mutex); - return; - } + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send result to manager"); - if (0 != vcd_client_widget_unset_tidl_notify_cb(pid)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback"); - } + char tmp_result[10] = {0, }; - if (0 != vcd_client_widget_delete_tidl_info(pid)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to delete widget tidl info"); - } - widget_tidl_info = NULL; + bundle* msg = bundle_create(); + snprintf(tmp_result, 10, "%d", result_type); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ALL_RESULT); + bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_result); - pthread_mutex_unlock(&g_widget_tidl_info_mutex); - char *sender = NULL; - rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); - if (!sender) - return; + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - SLOG(LOG_INFO, TAG_VCD, "@@@ Manager disconnect. appid(%s)", sender); + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); + bundle_free(msg); - free(sender); - } - rpc_port_stub_vcd_widget_stub_vc_widget_context_set_tag(context, NULL); + return VCD_ERROR_NONE; } -static void __vc_widget_register_cb_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h notify_callback, void *user_data) +int vcdc_send_speech_detected(int manager_pid) { - pthread_mutex_lock(&g_widget_tidl_info_mutex); - SLOG(LOG_INFO, TAG_VCD, "@@@ VC WIDGET REGISTER CALLBACK"); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send speech detected"); - int ret = -1; - ret = vcd_client_widget_add_tidl_info(pid); + bundle* msg = bundle_create(); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add widget tidl info."); - pthread_mutex_unlock(&g_widget_tidl_info_mutex); - return; - } - widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPEECH_DETECTED); - if (NULL == widget_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get widget tidl info. pid(%d)", pid); - pthread_mutex_unlock(&g_widget_tidl_info_mutex); - return; - } + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - char *sender = NULL; - rpc_port_stub_vcd_widget_stub_vc_widget_context_get_sender(context, &sender); + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); + bundle_free(msg); - if (!sender){ - SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL"); - pthread_mutex_unlock(&g_widget_tidl_info_mutex); - return; - } + return VCD_ERROR_NONE; +} - widget_tidl_info->rpc_h = __widget_create_rpc_port(sender, pid); +int vcdc_send_service_state(vcd_state_e state) +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send service state"); - if (NULL == widget_tidl_info->rpc_h) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create server proxy"); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] rpc_h(%p), engine_app_id(%s)", widget_tidl_info->rpc_h, sender); - } + char tmp_state[10] = {0, }; - free(sender); + bundle* msg = bundle_create(); + snprintf(tmp_state, 10, "%d", (int)state); - if (0 != vcd_client_widget_set_tidl_notify_cb(pid, notify_callback, user_data)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback"); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); - } + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_SERVICE_STATE); + bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_state); - pthread_mutex_unlock(&g_widget_tidl_info_mutex); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SET_SERVICE_STATE); + bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); - __request_tidl_connect(VCD_CLIENT_TYPE_WIDGET, pid); + bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SET_SERVICE_STATE); + bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_state); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND SIGNAL"); + __send_signal(msg); + bundle_free(msg); + + return VCD_ERROR_NONE; } -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) +int vcdc_send_dialog(int manager_pid, int pid, const char* disp_text, const char* utt_text, int continuous) { - SLOG(LOG_INFO, TAG_VCD, "@@@ VCD Widget Initialize"); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send dialog"); - uintptr_t ptr_pid = pid; - int ret = -1; + char tmp_pid[10] = {0, }; + char tmp_continuous[10] = {0, }; + char* tmp_disp_text = NULL; + char* tmp_utt_text = NULL; + bundle* msg = bundle_create(); + snprintf(tmp_pid, 10, "%d", pid); + snprintf(tmp_continuous, 10, "%d", continuous); - rpc_port_stub_vcd_widget_stub_vc_widget_context_set_tag(context, (void*)ptr_pid); + if (NULL == disp_text) { + tmp_disp_text = strdup("#NULL"); + } else { + tmp_disp_text = strdup(disp_text); + } - ret = vcd_server_widget_initialize(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + if (NULL == utt_text) { + tmp_utt_text = strdup("#NULL"); + } else { + tmp_utt_text = strdup(utt_text); } - *service_state = vcd_server_get_service_state(); - *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; + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_DIALOG); + bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_MANAGER_BUNDLE_DISP_TEXT, tmp_disp_text); + bundle_add_str(msg, VC_MANAGER_BUNDLE_UTT_TEXT, tmp_utt_text); + bundle_add_str(msg, VC_MANAGER_BUNDLE_CONTINUOUS, tmp_continuous); + + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); + bundle_free(msg); + free(tmp_disp_text); + free(tmp_utt_text); + + return VCD_ERROR_NONE; } -static int __vc_widget_finalize_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) +int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Finalize"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget finalize : pid(%d)", pid); + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] Send error signal to manager"); - int ret = -1; + char tmp_reason[10] = {0, }; + char tmp_daemon_pid[10] = {0, }; + char *temp_msg = NULL; - ret = vcd_server_widget_finalize(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + if (NULL == err_msg) { + SLOG(LOG_WARN, TAG_VCD, "[TIDL ERROR] Input parameter is NULL"); + temp_msg = strdup("#NULL"); + } else { + temp_msg = strdup(err_msg); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return ret; -} + bundle* msg = bundle_create(); + snprintf(tmp_reason, 10, "%d", reason); + snprintf(tmp_daemon_pid, 10, "%d", getpid()); -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); + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); + bundle_add_str(msg, VC_MANAGER_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, temp_msg); - int ret = -1; + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - ret = vcd_server_widget_start_recording(pid, command); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; - } + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); + bundle_free(msg); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + free(temp_msg); + temp_msg = NULL; - return ret; + return VCD_ERROR_NONE; } -static int __vc_widget_start_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, int silence, void *user_data) +/* +// TODO: remove _tidl after remove dbus +// TODO: make client, widget error signal +// But... it seems there is no call of this function.. Need to check. +int vcdc_tidl_send_error(int reason, char *err_msg) { - 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_ERROR, TAG_VCD, "[TIDL] Send error signal"); - int ret = -1; + char tmp_reason[10] = {0, }; + char tmp_daemon_pid[10] = {0, }; + char *temp_msg = NULL; - ret = vcd_server_widget_start(pid, (bool)silence); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; + if (NULL == err_msg) { + SLOG(LOG_WARN, TAG_VCD, "[TIDL ERROR] Input parameter is NULL"); + temp_msg = strdup("#NULL"); + } else { + temp_msg = strdup(err_msg); } - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + bundle* msg = bundle_create(); + snprintf(tmp_reason, 10, "%d", reason); + snprintf(tmp_daemon_pid, 10, "%d", getpid()); - return ret; -} + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); + bundle_add_str(msg, VC_MANAGER_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, temp_msg); -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); + bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); + bundle_add_str(msg, VC_WIDGET_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_WIDGET_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_WIDGET_BUNDLE_ERROR_MESSAGE, temp_msg); - int ret = -1; + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND SIGNAL"); - ret = vcd_server_widget_stop(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; - } + __send_signal(msg); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + bundle_free(msg); - return ret; -} + free(temp_msg); + temp_msg = NULL; -static int __vc_widget_cancel_cb(rpc_port_stub_vcd_widget_stub_vc_widget_context_h context, int pid, void *user_data) + return VCD_ERROR_NONE; +} +*/ +int vcdc_send_request_set_private_data(int pid, const char* key, const char* data) { - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Cancel"); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget cancel : pid(%d)", pid); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Set private data"); - int ret = -1; + char tmp_pid[10] = { 0, }; - ret = vcd_server_widget_cancel(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; - } + bundle* msg = bundle_create(); + snprintf(tmp_pid, 10, "%d", pid); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_PRIVATE_DATA); + bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_MANAGER_BUNDLE_KEY, key); + bundle_add_str(msg, VC_MANAGER_BUNDLE_PRIVATE_DATA, data); - return ret; + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); + + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, pid); + bundle_free(msg); + + return VCD_ERROR_NONE; } -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) +int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_audio_channel_e channel, vce_audio_type_e audio_type) { - 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_DEBUG, TAG_VCD, "[TIDL] Send feedback audio format to manager"); - int ret = -1; + char tmp_rate[10] = {0, }; + char tmp_channel[10] = {0, }; + char tmp_audio_type[10] = {0, }; - ret = vcd_server_widget_enable_asr_result(pid, enable); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return ret; - } + bundle* msg = bundle_create(); + snprintf(tmp_rate, 10, "%d", rate); + snprintf(tmp_channel, 10, "%d", (int)channel); + snprintf(tmp_audio_type, 10, "%d", (int)audio_type); + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT); + bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_RATE, tmp_rate); + bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_CHANNEL, tmp_channel); + bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_TYPE, tmp_audio_type); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - return ret; + __send_msg(msg, VCD_CLIENT_TYPE_MANAGER, manager_pid); + bundle_free(msg); + + return VCD_ERROR_NONE; } -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) +int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) { - 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); - - int ret = -1; + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send feedback streaming to manager"); - ret = vcd_server_set_foreground(pid, value); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - return; - } + char tmp_pid[10] = {0, }; + char tmp_utt_id[10] = {0, }; + char tmp_event[10] = {0, }; - SLOG(LOG_DEBUG, TAG_VCD, "@@@ send request set foreground to manager"); - vcdc_send_request_set_foreground(pid, value); + bundle* msg = bundle_create(); + snprintf(tmp_pid, 10, "%d", pid); + snprintf(tmp_utt_id, 10, "%d", utt_id); + snprintf(tmp_event, 10, "%d", (int)event); + bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_STREAMING); + bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_MANAGER_BUNDLE_UTTID, tmp_utt_id); + bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + rpc_port_stub_vcd_mgr_stub_array_char_h streaming_data = NULL; + rpc_port_stub_vcd_mgr_stub_array_char_create(&streaming_data); + if (NULL == streaming_data) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create data handle"); + return VCD_ERROR_OUT_OF_MEMORY; + } - return; -} + if (NULL != buffer && 0 < len) { + rpc_port_stub_vcd_mgr_stub_array_char_set(streaming_data, (char*)buffer, len); + } else { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] buffer is empty"); + } -int vcd_widget_tidl_open_connection() -{ - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] vcd_widget_tidl_open_connection"); + SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); - g_widget_callback.create = __vc_widget_create_cb; - g_widget_callback.terminate = __vc_widget_terminate_cb; - g_widget_callback.register_cb = __vc_widget_register_cb_cb; - g_widget_callback.initialize = __vc_widget_initialize_cb; - g_widget_callback.finalize = __vc_widget_finalize_cb; - g_widget_callback.start_recording = __vc_widget_start_recording_cb; - g_widget_callback.start = __vc_widget_start_cb; - g_widget_callback.stop = __vc_widget_stop_cb; - g_widget_callback.cancel = __vc_widget_cancel_cb; - g_widget_callback.enable_asr_result = __vc_widget_enable_asr_result_cb; - g_widget_callback.set_foreground = __vc_widget_set_foreground_cb; + 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(); - int ret = -1; - int count = 0; - while (VC_RETRY_MIN_COUNT >= count) { - ret = rpc_port_stub_vcd_widget_stub_vc_widget_register(&g_widget_callback, NULL); - if (0 == ret) { - SLOG(LOG_DEBUG, TAG_VCD, "register callback"); - return VCD_ERROR_NONE; - } - usleep(100000); - count++; + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info. pid(%d)", pid); + 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; } - SLOG(LOG_ERROR, TAG_VCD, "Fail to register callback(%d)", ret); - return VCD_ERROR_OPERATION_FAILED; -} + rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h handle = mgr_tidl_info->send_buffer_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + 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; + } -int vcd_widget_tidl_close_connection() -{ - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Close connection"); - rpc_port_stub_vcd_widget_stub_vc_widget_unregister(); + if (0 != rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_invoke(handle, streaming_data, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + 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; + } + 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_NONE; } -/** - * TIDL functions for VC setting client - */ -static void __vc_setting_create_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, void *user_data) +void vcdc_send_request_set_foreground(int pid, int value) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_create_cb"); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Set foreground"); - char *sender = NULL; + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - rpc_port_stub_vcd_setting_stub_vc_setting_context_get_sender(context, &sender); - if (!sender) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL"); + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); return; } - SLOG(LOG_INFO, TAG_VCD, "[TIDL] sender(%s)", sender); // sender (app_id) - free(sender); + if (!mgr_tidl_info->connected) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); + return; + } + + rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_set_foreground(mgr_tidl_info->rpc_h, pid, value); + + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request set foreground"); } -static void __vc_setting_terminate_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, void *user_data) +int vcdc_send_request_get_private_data(int pid, const char* key, char** data) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_terminate_cb"); - void* tag = NULL; - rpc_port_stub_vcd_setting_stub_vc_setting_context_get_tag(context, &tag); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Get private data"); - if (NULL != tag) { - int pid = (intptr_t)tag; - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC SETTING FINALIZE. pid(%u)", pid); + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - pthread_mutex_lock(&g_setting_tidl_info_mutex); - setting_tidl_info_s* setting_tidl_info = vcd_client_setting_get_tidl_info(pid); - if (NULL == setting_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get setting tidl info."); - pthread_mutex_unlock(&g_setting_tidl_info_mutex); - return; - } + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); + return VC_ERROR_OPERATION_FAILED; + } - if (0 != vcd_client_setting_unset_tidl_notify_cb(pid)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback"); - } + if (!mgr_tidl_info->connected) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); + return VC_ERROR_OPERATION_FAILED; + } - if (0 != vcd_client_setting_delete_tidl_info(pid)) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to delete setting tidl info"); - } - setting_tidl_info = NULL; + char *tmp = NULL; + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_get_private_data(mgr_tidl_info->rpc_h, pid, key, &tmp); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request vcd manager get private data : Fail to invoke message, error(%d)", ret); + return ret; + } + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request vcd manager get private data : Success"); - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); + *data = tmp; - pthread_mutex_unlock(&g_setting_tidl_info_mutex); - } - rpc_port_stub_vcd_setting_stub_vc_setting_context_set_tag(context, NULL); + return VC_ERROR_NONE; } -static void __vc_setting_register_notify_cb_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void *user_data) +int vcdc_send_request_auth_enable(int pid) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_register_notify_cb_cb. pid(%d)", pid); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth enable"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); - return; + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); + return VC_ERROR_OPERATION_FAILED; } - int ret = -1; - ret = vcd_client_setting_add_tidl_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); - return; + if (!mgr_tidl_info->connected) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); + return VC_ERROR_OPERATION_FAILED; } - ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_enable(mgr_tidl_info->rpc_h, pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth enable : Fail to invoke message, error(%d)", ret); + return ret; } + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth enable : Success"); + + return VC_ERROR_NONE; } -static int __vc_setting_register_notify_cb_sync_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, rpc_port_stub_vcd_setting_stub_vc_setting_notify_cb_h callback, void *user_data) +int vcdc_send_request_auth_disable(int pid) { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_setting_register_notify_cb_sync_cb. pid(%d)", pid); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth disable"); - if (NULL == callback) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null."); - return VCD_ERROR_INVALID_PARAMETER; + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); + return VC_ERROR_OPERATION_FAILED; } - int ret = -1; - ret = vcd_client_setting_add_tidl_info(pid); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add tidl info."); + if (!mgr_tidl_info->connected) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); + return VC_ERROR_OPERATION_FAILED; + } + + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_disable(mgr_tidl_info->rpc_h, pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth disable : Fail to invoke message, error(%d)", ret); return ret; } - - ret = vcd_client_setting_set_tidl_notify_cb(pid, callback, user_data); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback."); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback."); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth disable : Success"); + + return VC_ERROR_NONE; +} + +int vcdc_send_request_auth_start(int pid) +{ + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth start"); + + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); + return VC_ERROR_OPERATION_FAILED; } - return ret; + if (!mgr_tidl_info->connected) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); + return VC_ERROR_OPERATION_FAILED; + } + + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_start(mgr_tidl_info->rpc_h, pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth start : Fail to invoke message, error(%d)", ret); + return ret; + } + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth start : Success"); + + return VC_ERROR_NONE; } -int __vc_setting_set_language_cb(rpc_port_stub_vcd_setting_stub_vc_setting_context_h context, int pid, const char *language, void *user_data) +int vcdc_send_request_auth_stop(int pid) { - if (NULL == language) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter"); - return VCD_ERROR_INVALID_PARAMETER; + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth stop"); + + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); + + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); + return VC_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd server set language : language(%s)", language); + if (!mgr_tidl_info->connected) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); + return VC_ERROR_OPERATION_FAILED; + } - int ret = vcd_server_set_language(language); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set language(%d).", ret); - } else { - SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set language."); + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_stop(mgr_tidl_info->rpc_h, pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth stop : Fail to invoke message, error(%d)", ret); + return ret; } + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth stop : Success"); - return ret; + return VC_ERROR_NONE; } -int vcd_setting_tidl_open_connection() +int vcdc_send_request_auth_cancel(int pid) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] vcd_setting_tidl_open_connection"); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] auth cancel"); - g_setting_callback.create = __vc_setting_create_cb; - g_setting_callback.terminate = __vc_setting_terminate_cb; - g_setting_callback.register_notify_cb = __vc_setting_register_notify_cb_cb; - g_setting_callback.register_notify_cb_sync = __vc_setting_register_notify_cb_sync_cb; - g_setting_callback.set_language = __vc_setting_set_language_cb; + manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info(); - int ret = -1; - int count = 0; - while (VC_RETRY_MIN_COUNT >= count) { - ret = rpc_port_stub_vcd_setting_stub_vc_setting_register(&g_setting_callback, NULL); - if (0 == ret) { - SLOG(LOG_DEBUG, TAG_VCD, "register callback"); - return VCD_ERROR_NONE; - } - usleep(100000); - count++; + if (NULL == mgr_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); + return VC_ERROR_OPERATION_FAILED; } - SLOG(LOG_ERROR, TAG_VCD, "Fail to register callback(%d)", ret); - return VCD_ERROR_OPERATION_FAILED; + if (!mgr_tidl_info->connected) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); + return VC_ERROR_OPERATION_FAILED; + } + + int ret = rpc_port_proxy_vcd_mgr_proxy_vcd_mgr_invoke_auth_cancel(mgr_tidl_info->rpc_h, pid); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request auth cancel : Fail to invoke message, error(%d)", ret); + return ret; + } + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request auth cancel : Success"); + + return VC_ERROR_NONE; } -int vcd_setting_tidl_close_connection() +int vcdc_send_asr_result(int pid, int event, const char* asr_result, int cmd_type, bool* is_consumed) { - SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Close connection"); - rpc_port_stub_vcd_setting_stub_vc_setting_unregister(); + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Send asr result"); - return VCD_ERROR_NONE; + widget_tidl_info_s* widget_tidl_info = vcd_client_widget_get_tidl_info(pid); + + if (NULL == widget_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to get tidl info"); + return VC_ERROR_OPERATION_FAILED; + } + + if (!widget_tidl_info->connected) { + SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Not Connected"); + return VC_ERROR_OPERATION_FAILED; + } + + bool temp; + int ret = rpc_port_proxy_vcd_widget_proxy_vcd_widget_invoke_send_asr_result(widget_tidl_info->rpc_h, pid, event, asr_result, &temp); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Request vcd widget send asr result : Fail to invoke message, error(%d)", ret); + return ret; + } + SLOG(LOG_DEBUG, TAG_VCD, "[TIDL] Request vcd widget send asr result : Success"); + + *is_consumed = temp; + + return VC_ERROR_NONE; } + diff --git a/server/vcd_tidl.h b/server/vcd_tidl.h index e62c242..839258b 100644 --- a/server/vcd_tidl.h +++ b/server/vcd_tidl.h @@ -30,7 +30,6 @@ typedef enum { VCD_CLIENT_TYPE_MANAGER } vcd_client_type_e; - int vcd_tidl_open_connection(); int vcd_tidl_close_connection(); @@ -55,6 +54,10 @@ int vcdc_send_speech_detected(int manger_pid); int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg); +int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); + +int vcdc_send_manager_pid(int manager_pid); + int vcdc_send_service_state(vcd_state_e state); int vcdc_send_dialog(int manger_pid, int pid, const char* disp_text, const char* utt_text, int continuous); @@ -67,7 +70,6 @@ int vcdc_send_asr_result(int pid, int event, const char* asr_result, int cmd_typ void vcdc_send_request_set_foreground(int pid, int value); - /* for auth */ int vcdc_send_request_auth_enable(int pid); @@ -82,15 +84,10 @@ int vcdc_send_request_auth_cancel(int pid); /* for TTS feedback */ int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_audio_channel_e channel, vce_audio_type_e audio_type); -int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); - -int vcdc_send_result(int pid, int manager_pid, int cmd_type); - -int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg); +int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); -int vcdc_send_manager_pid(int manager_pid); +int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); -int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); #ifdef __cplusplus } -- 2.7.4 From 672dd50b7fa93846c204ee0c54e0ccd60556c410 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 29 Jun 2022 10:51:11 +0900 Subject: [PATCH 12/16] Remove files and codes related to DBus Change-Id: I48d11a36f6551c9169d576218b9b56660de85489 Signed-off-by: sooyeon --- CMakeLists.txt | 6 +- client/CMakeLists.txt | 3 - client/vc.c | 1 - client/vc_dbus.c | 1998 ----------------------------------- client/vc_dbus.h | 83 -- client/vc_mgr.c | 10 +- client/vc_mgr_dbus.c | 794 -------------- client/vc_mgr_dbus.h | 43 - client/vc_setting.c | 1 - client/vc_setting_dbus.c | 384 ------- client/vc_setting_dbus.h | 38 - common/vc_main.h | 1 - include/voice-control-engine.pc.in | 2 +- include/voice-control-manager.pc.in | 2 +- include/voice-control-widget.pc.in | 2 +- include/voice-control.pc.in | 2 +- org.tizen.voice.vcserver.service | 5 - org.tizen.voice.vcserver.tv.service | 4 - packaging/voice-control.spec | 3 - server/CMakeLists.txt | 2 - server/vcd_dbus.c | 546 ---------- server/vcd_dbus.h | 38 - server/vcd_dbus_server.c | 1469 ------------------------- server/vcd_dbus_server.h | 105 -- server/vcd_engine_agent.c | 1 - server/vcd_server.c | 1 - server/vce.c | 7 - vc-server.conf | 19 - 28 files changed, 6 insertions(+), 5564 deletions(-) delete mode 100644 client/vc_dbus.c delete mode 100644 client/vc_dbus.h delete mode 100644 client/vc_mgr_dbus.c delete mode 100644 client/vc_mgr_dbus.h delete mode 100644 client/vc_setting_dbus.c delete mode 100644 client/vc_setting_dbus.h delete mode 100644 org.tizen.voice.vcserver.service delete mode 100644 org.tizen.voice.vcserver.tv.service delete mode 100644 server/vcd_dbus.c delete mode 100644 server/vcd_dbus.h delete mode 100644 server/vcd_dbus_server.c delete mode 100644 server/vcd_dbus_server.h delete mode 100644 vc-server.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index aca3b41..daa639f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED aul buxton2 capi-appfw-app-control capi-appfw-app-manager capi-base-common capi-media-audio-io capi-media-sound-manager ecore-wl2 - capi-system-info cynara-client cynara-session dbus-1 db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf gmock bundle rpc-port + capi-system-info cynara-client cynara-session db-util dlog ecore glib-2.0 json-glib-1.0 libgum libtzplatform-config libxml-2.0 sqlite3 vconf gmock bundle rpc-port ) @@ -71,10 +71,6 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/voice-control.info DESTINATION ${TZ_SYS_RO_SHA ## config ## INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-config.xml DESTINATION ${TZ_SYS_RO_SHARE}/voice/vc/1.0) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.vcserver.service DESTINATION ${TZ_SYS_RO_SHARE}/dbus-1/services) - -INSTALL(FILES ${CMAKE_SOURCE_DIR}/vc-server.conf DESTINATION /etc/dbus-1/session.d) - ## vc_getengine ## IF("${ARCH}" MATCHES "^arm.*") INSTALL(PROGRAMS ${CMAKE_SOURCE_DIR}/bin/armv7l/vc_getengine DESTINATION ${TZ_SYS_BIN}) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index b5ddb82..17a0edd 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -2,7 +2,6 @@ SET(SRCS vc.c vc_data.cpp vc_client.c -# vc_dbus.c vc_tidl.c vc_proxy.c ../common/vc_cmd_db.c @@ -15,7 +14,6 @@ SET(SRCS ) SET(SETTING_SRCS -# vc_setting_dbus.c vc_setting_tidl.c vc_setting_proxy.c vc_setting.c @@ -46,7 +44,6 @@ SET(MANAGER_SRCS vc_mgr_tidl.c vc_mgr_proxy.c vc_mgr_stub.c - vc_mgr_dbus.c ../common/vc_cmd_db.c ../common/vc_command.c ../common/vc_command_util.c diff --git a/client/vc.c b/client/vc.c index 4dbb113..dd7be5a 100644 --- a/client/vc.c +++ b/client/vc.c @@ -30,7 +30,6 @@ #include "vc_command.h" #include "vc_config_mgr.h" #include "vc_data.h" -// #include "vc_dbus.h" #include "vc_tidl.h" #include "vc_info_parser.h" #include "vc_json_parser.h" diff --git a/client/vc_dbus.c b/client/vc_dbus.c deleted file mode 100644 index 05e5bed..0000000 --- a/client/vc_dbus.c +++ /dev/null @@ -1,1998 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "vc_command.h" -#include "vc_dbus.h" -#include "vc_main.h" - -static pthread_mutex_t g_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; - -static int g_waiting_time = 3000; -static int g_waiting_short_time = 200; -static bool g_is_connection_opened = false; - -static Ecore_Fd_Handler* g_fd_handler = NULL; - -static DBusConnection* g_conn_sender = NULL; -static DBusConnection* g_conn_listener = 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); - -extern int __vc_cb_manager_pid(int manager_pid); - -extern int __vc_cb_tts_streaming(int utt_id, vc_feedback_event_e event, char* buffer, int len); - -extern int __vc_cb_utterance_status(int utt_id, int utt_status); - -//LCOV_EXCL_START -static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler) -{ - if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW; - - dbus_connection_read_write_dispatch(g_conn_listener, 50); - - while (1) { - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_conn_listener); - - /* loop again if we haven't read a message */ - if (NULL == msg) { - break; - } - - DBusError err; - dbus_error_init(&err); - - char if_name[64] = {0, }; - snprintf(if_name, 64, "%s", VC_CLIENT_SERVICE_INTERFACE); - - if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_HELLO)) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Hello"); - int pid = 0; - int response = -1; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (pid > 0) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get hello : pid(%d) ", pid); - response = 1; - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get hello : invalid pid "); - } - - DBusMessage* reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID); - - if (!dbus_connection_send(g_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get hello : fail to send reply"); - else - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get hello : result(%d)", response); - - dbus_connection_flush(g_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get hello : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - } /* VCD_METHOD_HELLO */ - - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_SET_SERVICE_STATE)) { - int state = 0; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Get arguments error (%s)", err.message); - dbus_error_free(&err); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@ state changed : %d", state); - - __vc_cb_service_state(state); - - } /* VCD_METHOD_SET_SERVICE_STATE */ - - else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_RESULT)) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Client Result"); - - __vc_cb_result(); - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - - } /* VCD_METHOD_RESULT */ - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_SEND_MANAGER_PID)) { - int manager_pid = 0; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &manager_pid, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Get arguments error (%s)", err.message); - dbus_error_free(&err); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@ manager pid is changed : %d", manager_pid); - - __vc_cb_manager_pid(manager_pid); - - } /* VCD_METHOD_SEND_MANAGER_PID */ - - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR)) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Error"); - int reason; - int daemon_pid; - char* err_msg; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &reason, - DBUS_TYPE_INT32, &daemon_pid, - DBUS_TYPE_STRING, &err_msg, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc Get Error message : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), daemon_pid(%d), msg(%s)", reason, daemon_pid, err_msg); - __vc_cb_error(reason, daemon_pid, err_msg); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - } /* VCD_METHOD_ERROR */ - - else if (dbus_message_is_signal(msg, if_name, VCD_METHOD_ERROR_TO_APP)) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Error and send to client app"); - int pid; - int reason; - char* err_msg; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &reason, - DBUS_TYPE_STRING, &err_msg, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc Get Error message : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", reason, pid, err_msg); - __vc_cb_error_to_app(pid, reason, err_msg); - } - - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - } /* VCD_METHOD_ERROR_TO_APP */ - - else if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_FEEDBACK_STREAMING)) { - SLOG(LOG_INFO, TAG_VCC, "@@@ Get TTS feedback streaming"); - int utt_id; - vc_feedback_event_e event; - char* buffer = NULL; - int len; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INT32, &event, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &buffer, &len, - DBUS_TYPE_INVALID); - - __vc_cb_tts_streaming(utt_id, event, buffer, len); - - SLOG(LOG_INFO, TAG_VCC, "@@@"); - } /* VCD_METHOD_FEEDBACK_STREAMING */ - - else if (dbus_message_is_method_call(msg, if_name, VC_MANAGER_METHOD_UTTERANCE_STATUS)) { - SLOG(LOG_INFO, TAG_VCC, "@@@ Get TTS utterance status streaming"); - int utt_id; - int utt_status; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INT32, &utt_status, - DBUS_TYPE_INVALID); - - __vc_cb_utterance_status(utt_id, utt_status); - - SLOG(LOG_INFO, TAG_VCC, "@@@"); - } /* VC_MANAGER_METHOD_UTTERANCE_STATUS */ - - else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Owner Changed"); - DBusError err; - dbus_error_init(&err); - /* remove a rule for daemon error */ - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_remove_match(g_conn_listener, rule_err, &err); - dbus_connection_flush(g_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); - dbus_error_free(&err); - } - - __vc_cb_error(VC_ERROR_SERVICE_RESET, -1, "Daemon Reset"); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - } /* NameOwnerChanged */ - - else { - const char* sender = dbus_message_get_sender(msg); - const char* destination = dbus_message_get_destination(msg); - const char* path = dbus_message_get_path(msg); - const char* interf = dbus_message_get_interface(msg); - const char* member = dbus_message_get_member(msg); - int type = dbus_message_get_type(msg); - SLOG(LOG_ERROR, TAG_VCC, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); - dbus_message_unref(msg); - break; - } - - /* free the message */ - dbus_message_unref(msg); - } /* while(1) */ - - return ECORE_CALLBACK_PASS_ON; -} -//LCOV_EXCL_STOP - -static void __vc_dbus_connection_free() -{ - if (NULL != g_conn_listener) { - dbus_connection_close(g_conn_listener); - dbus_connection_unref(g_conn_listener); - g_conn_listener = NULL; - } - if (NULL != g_conn_sender) { - dbus_connection_close(g_conn_sender); - dbus_connection_unref(g_conn_sender); - g_conn_sender = NULL; - } -} - -int vc_dbus_open_connection() -{ - pthread_mutex_lock(&g_dbus_mutex); - - if (NULL != g_conn_sender && NULL != g_conn_listener) { - SLOG(LOG_WARN, TAG_VCC, "already existed connection "); //LCOV_EXCL_LINE - pthread_mutex_unlock(&g_dbus_mutex); - return 0; - } - - DBusError err; - int ret; - - /* initialize the error value */ - dbus_error_init(&err); - - /* connect to the DBUS system bus, and check for errors */ - g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Dbus Connection Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection "); //LCOV_EXCL_LINE - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_conn_sender, false); - - g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Dbus Connection Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCC, "Fail to get dbus connection "); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_conn_listener, false); - - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - - SLOG(LOG_DEBUG, TAG_VCC, "service name is %s", service_name); - - /* register our name on the bus, and check for errors */ - ret = dbus_bus_request_name(g_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Name Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - SLOG(LOG_ERROR, TAG_VCC, "fail dbus_bus_request_name()"); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - if (NULL != g_fd_handler) { - SLOG(LOG_WARN, TAG_VCC, "The handler already exists."); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_NONE; - } - - char rule[256] = {0, }; - snprintf(rule, 256, "type='signal',interface='%s'", VC_CLIENT_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_conn_listener, rule, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - int fd = 0; - if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) { - SLOG(LOG_ERROR, TAG_VCC, "fail to get fd from dbus "); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "Get fd from dbus : %d", fd); - } - - g_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL); - if (NULL == g_fd_handler) { - SLOG(LOG_ERROR, TAG_VCC, "fail to get fd handler from ecore "); //LCOV_EXCL_LINE - __vc_dbus_connection_free(); - pthread_mutex_unlock(&g_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - g_is_connection_opened = true; - - pthread_mutex_unlock(&g_dbus_mutex); - - SLOG(LOG_INFO, TAG_VCC, "[INFO] vc client dbus connection is opened"); - - return VC_ERROR_NONE; -} - -int vc_dbus_close_connection() -{ - pthread_mutex_lock(&g_dbus_mutex); - - DBusError err; - dbus_error_init(&err); - - if (NULL != g_fd_handler) { - ecore_main_fd_handler_del(g_fd_handler); - g_fd_handler = NULL; - } - - if (NULL != g_conn_listener) { - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - - dbus_bus_release_name(g_conn_listener, service_name, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - } - - __vc_dbus_connection_free(); - - g_is_connection_opened = false; - - pthread_mutex_unlock(&g_dbus_mutex); - - SLOG(LOG_INFO, TAG_VCC, "[INFO] vc client dbus connection is closed"); - - return 0; -} - -int vc_dbus_reconnect() -{ - if (!g_conn_sender || !g_conn_listener) { - vc_dbus_close_connection(); - - if (0 != vc_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); //LCOV_EXCL_LINE - return -1; - } - - SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Reconnect"); //LCOV_EXCL_LINE - return 0; - } - - bool sender_connected = dbus_connection_get_is_connected(g_conn_sender); - bool listener_connected = dbus_connection_get_is_connected(g_conn_listener); - SLOG(LOG_WARN, TAG_VCC, "[DBUS] Sender(%s) Listener(%s)", - sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); //LCOV_EXCL_LINE - - if (false == sender_connected || false == listener_connected) { - vc_dbus_close_connection(); - - if (0 != vc_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); //LCOV_EXCL_LINE - return -1; - } - - SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Reconnect"); //LCOV_EXCL_LINE - } - - return 0; -} - -static int __dbus_check() -{ - if (NULL == g_conn_sender || NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); //LCOV_EXCL_LINE - return vc_dbus_reconnect(); - } - return 0; -} - -int vc_dbus_request_hello() -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - SLOG(LOG_DEBUG, TAG_VCC, "[DBUS] Request vc hello"); //LCOV_EXCL_LINE - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_HELLO); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Request vc hello : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg = NULL; - int result = 0; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_short_time, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_DEBUG, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - dbus_message_unref(msg); - - if (NULL != result_msg) { - dbus_message_unref(result_msg); - result = 0; - } else { - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - - -int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_INITIALIZE); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc initialize : Fail to make message "); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Receive the reply for initializing"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - return VC_ERROR_OPERATION_FAILED; - } - - if (NULL != result_msg) { - int tmp = -1; - int tmp_service_state = 0; - int tmp_daemon_pid = 0; - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &tmp, - DBUS_TYPE_INT32, &tmp_service_state, - DBUS_TYPE_INT32, &tmp_daemon_pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - - dbus_message_unref(result_msg); - - if (0 == result) { - *mgr_pid = tmp; - *service_state = tmp_service_state; - *daemon_pid = tmp_daemon_pid; - - SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Get arguments for initializing"); - - /* add a rule for daemon error */ - char rule[256] = {0, }; - snprintf(rule, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - if (NULL == g_conn_listener) { - if (g_is_connection_opened) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] g_conn_listener is NULL abnormally"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCC, "[INFO] g_conn_listener is NULL and DBUS connection was closed"); - return VC_ERROR_NONE; - } - } - dbus_bus_add_match(g_conn_listener, rule, NULL); - - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : result = %d mgr = %d service = %d daemon_pid = %d", result, *mgr_pid, *service_state, *daemon_pid); //LCOV_EXCL_LINE - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc initialize : result = %d", result); //LCOV_EXCL_LINE - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL "); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_finalize(int pid) -{ - DBusError err; - dbus_error_init(&err); - - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - /* remove a rule for daemon error */ - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_remove_match(g_conn_listener, rule_err, &err); - dbus_connection_flush(g_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "Match Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_FINALIZE); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc finalize : Fail to make message "); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : pid(%d)", pid); - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc finalize : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL "); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -//LCOV_EXCL_START -int vc_dbus_request_set_exclusive_command(int pid, bool value) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_SET_EXCLUSIVE_CMD); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set exclusive command : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : pid(%d)", pid); - } - - int temp = value; - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &temp, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : result = %d", result); - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set exclusive command : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} -//LCOV_EXCL_STOP - -int vc_dbus_request_set_command(int pid, vc_cmd_type_e cmd_type) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_SET_COMMAND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &cmd_type, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_unset_command(int pid, vc_cmd_type_e cmd_type) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_UNSET_COMMAND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc unset command : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), type(%d)", pid, cmd_type); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &cmd_type, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc unset command : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_set_foreground(int pid, bool value) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg = NULL; - int tmp_value = 0; - - tmp_value = (int)value; - - msg = dbus_message_new_signal( - VC_MANAGER_SERVICE_OBJECT_PATH, - VC_MANAGER_SERVICE_INTERFACE, - VCC_MANAGER_METHOD_SET_FOREGROUND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set foreground to manager : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground to manager : client pid(%d), value(%s)", pid, tmp_value ? "true" : "false"); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &tmp_value, - DBUS_TYPE_INVALID); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE - dbus_message_unref(msg); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_message_unref(msg); - - msg = NULL; - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_SET_FOREGROUND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set foreground to daemon : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground to daemon : client pid(%d), value(%s)", pid, tmp_value ? "true" : "false"); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &tmp_value, - DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE - dbus_message_unref(msg); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCC, "[Dbus DEBUG] Success to Send"); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - return 0; -} - -//LCOV_EXCL_START -int vc_dbus_set_server_dialog(int pid, const char* app_id, const char* credential) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); - } - } - - DBusMessage* msg; - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_SET_SERVER_DIALOG); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set server dialog : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s)", pid, app_id); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &app_id, - DBUS_TYPE_STRING, &credential, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set server dialog : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} -//LCOV_EXCL_STOP - -int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); //LCOV_EXCL_LINE - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); //LCOV_EXCL_LINE - } - } - - DBusMessage* msg; - int tmp_continue = 0; - - tmp_continue = (int)continuous; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_DIALOG); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc request dialog to manager : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request dialog to manager : client pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", getpid(), disp_text, utt_text, continuous); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &disp_text, - DBUS_TYPE_STRING, &utt_text, - DBUS_TYPE_INT32, &tmp_continue, - DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE - dbus_message_unref(msg); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCC, "[Dbus DEBUG] Success to Send"); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return 0; - -//LCOV_EXCL_START -/* - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc set command : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -*/ -//LCOV_EXCL_STOP -} - -int vc_dbus_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); //LCOV_EXCL_LINE - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); //LCOV_EXCL_LINE - } - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_IS_SYS_COMMAND_VALID); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc is system command valid : Fail to make message"); //LCOV_EXCL_LINE - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - int tmp_sys_cmd = 0; - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &tmp_sys_cmd, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); //LCOV_EXCL_LINE - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - *is_sys_cmd_valid = (bool)tmp_sys_cmd; - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : result = %d, is_sys_cmd_valid = %d", result, *is_sys_cmd_valid); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc is system command valid : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); //LCOV_EXCL_LINE - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -//LCOV_EXCL_START -#if 0 -int vc_dbus_request_start(int pid, int silence) -{ - DBusMessage* msg; - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_REQUEST_START); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc start : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc start : pid(%d), silence(%d)", pid, silence); - } - - DBusMessageIter args; - dbus_message_iter_init_append(msg, &args); - - /* Append result*/ - dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(pid)); - dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(silence)); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc start : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc start : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_stop(int pid) -{ - DBusMessage* msg; - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_REQUEST_STOP); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc stop : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc stop : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc stop : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc stop : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_cancel(int pid) -{ - DBusMessage* msg; - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */ - VC_SERVER_SERVICE_INTERFACE, /* interface name of the signal */ - VC_METHOD_REQUEST_CANCEL); /* name of the signal */ - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} -#endif -//LCOV_EXCL_STOP - -//LCOV_EXCL_START -/* Authority */ -int vc_dbus_request_auth_enable(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, /* object name of the signal */ - target_if_name, /* interface name of the signal */ - VC_METHOD_AUTH_ENABLE); /* name of the signal */ - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth enable : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth enable : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_auth_disable(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, /* object name of the signal */ - target_if_name, /* interface name of the signal */ - VC_METHOD_AUTH_DISABLE); /* name of the signal */ - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth disable : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth disable : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_auth_start(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, - target_if_name, - VC_METHOD_AUTH_START); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth start : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d)", pid); - } - - DBusMessageIter args; - dbus_message_iter_init_append(msg, &args); - - /* Append result*/ - dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(pid)); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth start : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_auth_stop(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, - target_if_name, - VC_METHOD_AUTH_STOP); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth stop : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth stop : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_dbus_request_auth_cancel(int pid, int mgr_pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - char service_name[64] = {0,}; - char object_path[64] = {0,}; - char target_if_name[128] = {0,}; - - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, mgr_pid); - snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_MANAGER_SERVICE_INTERFACE, mgr_pid); - - /* create a signal & check for errors */ - msg = dbus_message_new_method_call( - service_name, - object_path, /* object name of the signal */ - target_if_name, /* interface name of the signal */ - VC_METHOD_AUTH_CANCEL); /* name of the signal */ - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth cancel : Fail to make message "); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc auth cancel : result = %d", result); - } - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ Result Message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} -//LCOV_EXCL_STOP - -int vc_dbus_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); - } - } - - DBusMessage* msg; - int tmp_to_vcm = 0; - - tmp_to_vcm = (int)to_vcm; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_REQUEST_TTS); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc request tts to manager : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts to manager : client pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, text, language, to_vcm); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &text, - DBUS_TYPE_STRING, &language, - DBUS_TYPE_INT32, &tmp_to_vcm, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - int tmp_utt_id = -1; - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &tmp_utt_id, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - *utt_id = tmp_utt_id; - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts : result = %d, utt_id = %d", result, *utt_id); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc request tts : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; - - return 0; -} - -int vc_dbus_cancel_tts(int pid, int utt_id) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); - } - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_CANCEL_TTS); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel tts to manager : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts to manager : client pid(%d), utt_id(%d)", pid, utt_id); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc cancel tts : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; - - return 0; -} - -int vc_dbus_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type) -{ - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] NULL connection"); - if (0 != vc_dbus_reconnect()) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to reconnect"); - } - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_GET_TTS_AUDIO_FORMAT); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get tts audio format : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : client pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - int tmp_rate; - int tmp_channel; - int tmp_audio_type; - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &tmp_rate, - DBUS_TYPE_INT32, &tmp_channel, - DBUS_TYPE_INT32, &tmp_audio_type, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCC, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - if (0 == result) { - *rate = tmp_rate; - *channel = tmp_channel; - *audio_type = tmp_audio_type; - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : result = %d, rate = %d, channel = %d, audio_type = %d", result, *rate, *channel, *audio_type); - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ vc get tts audio format : result = %d", result); - } - } else { - SLOG(LOG_ERROR, TAG_VCC, "@@ Result message is NULL"); - vc_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; - - return 0; -} - diff --git a/client/vc_dbus.h b/client/vc_dbus.h deleted file mode 100644 index 5d13712..0000000 --- a/client/vc_dbus.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VC_DBUS_H_ -#define __VC_DBUS_H_ - -#include "voice_control_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int vc_dbus_open_connection(); - -int vc_dbus_close_connection(); - - -int vc_dbus_request_hello(); - -int vc_dbus_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid); - -int vc_dbus_request_finalize(int pid); - -int vc_dbus_request_set_exclusive_command(int pid, bool value); - -int vc_dbus_request_set_command(int pid, vc_cmd_type_e cmd_type); - -int vc_dbus_request_unset_command(int pid, vc_cmd_type_e cmd_type); - -int vc_dbus_set_foreground(int pid, bool value); - -int vc_dbus_set_server_dialog(int pid, const char* app_id, const char* credential); - -int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous); - -int vc_dbus_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid); - -#if 0 -int vc_dbus_request_start(int pid, int silence); - -int vc_dbus_request_stop(int pid); - -int vc_dbus_request_cancel(int pid); -#endif - -/* Authority */ -int vc_dbus_request_auth_enable(int pid, int mgr_pid); - -int vc_dbus_request_auth_disable(int pid, int mgr_pid); - -int vc_dbus_request_auth_start(int pid, int mgr_pid); - -int vc_dbus_request_auth_stop(int pid, int mgr_pid); - -int vc_dbus_request_auth_cancel(int pid, int mgr_pid); - -/* tts feedback */ - -int vc_dbus_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id); - -int vc_dbus_cancel_tts(int pid, int utt_id); - -int vc_dbus_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type); - -#ifdef __cplusplus -} -#endif - -#endif /* __VC_DBUS_H_ */ diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 2a31598..1203bf6 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -32,7 +32,6 @@ #include "vc_main.h" #include "vc_mgr_client.h" #include "vc_mgr_tidl.h" -#include "vc_mgr_dbus.h" #include "vc_mgr_data.h" #include "vc_mgr_player.h" #include "voice_control.h" @@ -47,7 +46,6 @@ static Ecore_Timer* g_send_hello_timer = NULL; static Ecore_Timer* g_request_init_timer = NULL; -static int g_dbus_send_hello_count = 0; static int g_tidl_send_hello_count = 0; static Ecore_Timer* g_m_set_volume_timer = NULL; @@ -331,11 +329,6 @@ static void __vc_mgr_internal_unprepare() SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request finalize : %s", __vc_mgr_get_error_code(ret)); } - ret = vc_mgr_dbus_request_finalize(g_vc_m->handle); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request dbus finalize : %s", __vc_mgr_get_error_code(ret)); - } - vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); return; } @@ -580,7 +573,6 @@ int vc_mgr_prepare(void) } if (NULL == g_send_hello_timer) { - g_dbus_send_hello_count = 0; g_tidl_send_hello_count = 0; SLOG(LOG_INFO, TAG_VCM, "[DEBUG] Create a new timer for preparation"); ecore_thread_main_loop_begin(); @@ -4251,7 +4243,7 @@ int vc_mgr_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e return VC_ERROR_INVALID_STATE; } - int ret = vc_mgr_dbus_send_utterance_status(pid, utt_id, utt_status); + int 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 diff --git a/client/vc_mgr_dbus.c b/client/vc_mgr_dbus.c deleted file mode 100644 index c59a3d9..0000000 --- a/client/vc_mgr_dbus.c +++ /dev/null @@ -1,794 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#include "vc_main.h" -#include "vc_mgr_client.h" -#include "vc_mgr_dbus.h" -#include "vc_command.h" - - -static pthread_mutex_t g_m_dbus_mutex = PTHREAD_MUTEX_INITIALIZER; - -static int g_m_waiting_short_time = 200; -static bool g_is_connection_opened = false; - -static Ecore_Fd_Handler* g_m_fd_handler = NULL; - -static DBusConnection* g_m_conn_sender = NULL; -static DBusConnection* g_m_conn_listener = NULL; - -extern int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg); - -extern int __vc_mgr_cb_set_foreground(int pid, bool value); - -extern int __vc_mgr_cb_private_data_requested(const char* key, char** data); - -/* for TTS feedback */ -extern int __vc_mgr_cb_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len); - -/* Authority */ -extern int __vc_mgr_request_auth_enable(int pid); - -extern int __vc_mgr_request_auth_disable(int pid); - -extern int __vc_mgr_request_auth_start(int pid); - -extern int __vc_mgr_request_auth_stop(int pid); - -extern int __vc_mgr_request_auth_cancel(int pid); - -// TODO: remove listener event callback -static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler) -{ - if (NULL == g_m_conn_listener) return ECORE_CALLBACK_RENEW; - - dbus_connection_read_write_dispatch(g_m_conn_listener, 50); - - while (1) { - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_m_conn_listener); - - /* loop again if we haven't read a message */ - if (NULL == msg) { - break; - } - - /* SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] Message is arrived"); */ - - DBusError err; - dbus_error_init(&err); - - char if_name[64] = {0, }; - snprintf(if_name, 64, "%s", VC_MANAGER_SERVICE_INTERFACE); - - if (dbus_message_is_signal(msg, if_name, VCC_MANAGER_METHOD_SET_FOREGROUND)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Set foreground"); - int pid = 0; - int value = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &value, - DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Get arguments error (%s)", err.message); - dbus_error_free(&err); - } - - 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 if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_GET_PRIVATE_DATA)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request get private data"); - int pid = 0; - int ret = -1; - char* key = NULL; - char* temp = NULL; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &key, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (pid > 0) { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request get private data : pid(%d) ", pid); - ret = __vc_mgr_cb_private_data_requested(key, &temp); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr get request get private data : invalid pid "); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_STRING, &temp, DBUS_TYPE_INVALID); - - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc get request get private data : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc get request get private data : result(%d)", ret); - - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr get request get private data : fail to create reply message"); - } - - if (NULL != temp) free(temp); - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VCD_MANAGER_METHOD_GET_PRIVATE_DATA */ - - /* Authority */ - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_ENABLE)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth enable"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth enable : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth enable : pid(%d)", pid); - ret = __vc_mgr_request_auth_enable(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth enable : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth enable : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth enable : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_ENABLE */ - - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_DISABLE)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth disable"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth disable : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth disable : pid(%d)", pid); - ret = __vc_mgr_request_auth_disable(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth disable : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth disable : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth disable : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_DISABLE */ - - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_START)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth start"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth start : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth start : pid(%d)", pid); - ret = __vc_mgr_request_auth_start(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth start : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth start : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth start : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_START */ - - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_STOP)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth stop"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth stop : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth stop : pid(%d)", pid); - ret = __vc_mgr_request_auth_stop(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth stop : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth stop : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth stop : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_STOP */ - - else if (dbus_message_is_method_call(msg, if_name, VC_METHOD_AUTH_CANCEL)) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Get request auth cancel"); - int pid; - int ret = 0; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth cancel : Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr request auth cancel : pid(%d)", pid); - ret = __vc_mgr_request_auth_cancel(pid); - } - - DBusMessage *reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - if (!dbus_connection_send(g_m_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCM, "@@ vc request auth cancel : fail to send reply"); - else - SLOG(LOG_INFO, TAG_VCM, "@@ vc request auth cancel : ret(%d)", ret); - dbus_connection_flush(g_m_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr request auth cancel : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* VC_METHOD_AUTH_CANCEL */ - - else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) { - SLOG(LOG_INFO, TAG_VCM, "@@@ Owner Changed"); - /* remove a rule for daemon error */ - DBusError err; - /* initialize the error value */ - dbus_error_init(&err); - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_remove_match(g_m_conn_listener, rule_err, &err); - dbus_connection_flush(g_m_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); - dbus_error_free(&err); - } - __vc_mgr_cb_error(VC_ERROR_SERVICE_RESET, -1, "Daemon Reset"); - SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - } /* NameOwnerChanged */ - - else { - const char* sender = dbus_message_get_sender(msg); - const char* destination = dbus_message_get_destination(msg); - const char* path = dbus_message_get_path(msg); - const char* interf = dbus_message_get_interface(msg); - const char* member = dbus_message_get_member(msg); - int type = dbus_message_get_type(msg); - SLOG(LOG_ERROR, TAG_VCM, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); - dbus_message_unref(msg); - break; - } - - /* free the message */ - dbus_message_unref(msg); - } /* while(1) */ - - return ECORE_CALLBACK_PASS_ON; -} - -static void __vc_mgr_dbus_connection_free() -{ - if (NULL != g_m_conn_listener) { - dbus_connection_close(g_m_conn_listener); - dbus_connection_unref(g_m_conn_listener); - g_m_conn_listener = NULL; - } - if (NULL != g_m_conn_sender) { - dbus_connection_close(g_m_conn_sender); - dbus_connection_unref(g_m_conn_sender); - g_m_conn_sender = NULL; - } -} - -int vc_mgr_dbus_open_connection() -{ - pthread_mutex_lock(&g_m_dbus_mutex); - - if (NULL != g_m_conn_sender && NULL != g_m_conn_listener) { - SLOG(LOG_WARN, TAG_VCM, "already existed connection "); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_NONE; - } - - DBusError err; - int ret; - - /* initialize the error value */ - dbus_error_init(&err); - - /* connect to the DBUS system bus, and check for errors */ - g_m_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Dbus Connection Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL == g_m_conn_sender) { - SLOG(LOG_ERROR, TAG_VCM, "Fail to get dbus connection "); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_m_conn_sender, false); - - /* connect to the DBUS system bus, and check for errors */ - g_m_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Dbus Connection Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL == g_m_conn_listener) { - SLOG(LOG_ERROR, TAG_VCM, "Fail to get dbus connection "); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_m_conn_listener, false); - - SLOG(LOG_INFO, TAG_VCM, "service name is %s", VC_MANAGER_SERVICE_NAME); - - /* register our name on the bus, and check for errors */ - ret = dbus_bus_request_name(g_m_conn_listener, VC_MANAGER_SERVICE_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Name Error (%s)", err.message); - dbus_error_free(&err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - SLOG(LOG_ERROR, TAG_VCM, "fail dbus_bus_request_name()"); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - if (NULL != g_m_fd_handler) { - SLOG(LOG_WARN, TAG_VCM, "The handler already exists."); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_NONE; - } - - char rule[128] = {0, }; - snprintf(rule, 128, "type='signal',interface='%s'", VC_MANAGER_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_m_conn_listener, rule, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); - dbus_error_free(&err); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - int fd = 0; - if (1 != dbus_connection_get_unix_fd(g_m_conn_listener, &fd)) { - SLOG(LOG_ERROR, TAG_VCM, "fail to get fd from dbus "); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCM, "Get fd from dbus : %d", fd); - } - - g_m_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)vc_mgr_listener_event_callback, g_m_conn_listener, NULL, NULL); - - if (NULL == g_m_fd_handler) { - SLOG(LOG_ERROR, TAG_VCM, "fail to get fd handler from ecore "); - __vc_mgr_dbus_connection_free(); - pthread_mutex_unlock(&g_m_dbus_mutex); - return VC_ERROR_OPERATION_FAILED; - } - - g_is_connection_opened = true; - - pthread_mutex_unlock(&g_m_dbus_mutex); - - SLOG(LOG_INFO, TAG_VCM, "[INFO] manager dbus connection is opened"); - - return VC_ERROR_NONE; -} - -int vc_mgr_dbus_close_connection() -{ - pthread_mutex_lock(&g_m_dbus_mutex); - - DBusError err; - dbus_error_init(&err); - - if (NULL != g_m_fd_handler) { - ecore_main_fd_handler_del(g_m_fd_handler); - g_m_fd_handler = NULL; - } - - if (NULL != g_m_conn_listener) { - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_MANAGER_SERVICE_NAME, pid); - - dbus_bus_release_name(g_m_conn_listener, service_name, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - } - - __vc_mgr_dbus_connection_free(); - - g_is_connection_opened = false; - - pthread_mutex_unlock(&g_m_dbus_mutex); - - SLOG(LOG_INFO, TAG_VCM, "[INFO] manager dbus connection is closed"); - - return VC_ERROR_NONE; -} - -int vc_mgr_dbus_reconnect() -{ - if (!g_m_conn_sender || !g_m_conn_listener) { - vc_mgr_dbus_close_connection(); - - if (0 != vc_mgr_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_INFO, TAG_VCM, "[DBUS] Reconnect"); - return 0; - } - - bool sender_connected = dbus_connection_get_is_connected(g_m_conn_sender); - bool listener_connected = dbus_connection_get_is_connected(g_m_conn_listener); - - SLOG(LOG_INFO, TAG_VCM, "[DBUS] Sender(%s) Listener(%s)", - sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); - - if (false == sender_connected || false == listener_connected) { - vc_mgr_dbus_close_connection(); - - if (0 != vc_mgr_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_INFO, TAG_VCM, "[DBUS] Reconnect"); - } - - return 0; -} - -static int __dbus_check() -{ - if (NULL == g_m_conn_sender || NULL == g_m_conn_listener) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] NULL connection"); //LCOV_EXCL_LINE - return vc_mgr_dbus_reconnect(); - } - return 0; -} - -int vc_mgr_dbus_request_hello() -{ - SLOG(LOG_DEBUG, TAG_VCM, "@@ Request vc hello start"); - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_HELLO); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCM, "@@ Request vc hello : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg = NULL; - int result = 0; - - result_msg = dbus_connection_send_with_reply_and_block(g_m_conn_sender, msg, g_m_waiting_short_time, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - dbus_message_unref(msg); - - if (NULL != result_msg) { - dbus_message_unref(result_msg); - result = 0; - } else { - result = VC_ERROR_TIMED_OUT; - } - - SLOG(LOG_DEBUG, TAG_VCM, "@@ Request vc hello end"); - return result; -} - -static int __dbus_restore_daemon() -{ - int ret = -1; - int count = 0; - while (0 != ret) { - ret = vc_mgr_dbus_request_hello(); - if (0 != ret) { - if (VC_ERROR_TIMED_OUT != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to restore daemon"); - break; - } else { - SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry restore daemon"); - usleep(10000); - count++; - if (VC_RETRY_COUNT == count) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request"); - break; - } - } - } else { - SLOG(LOG_ERROR, TAG_VCM, "[SUCCESS] restore daemon"); - } - } - return ret; -} - -int vc_mgr_dbus_request_finalize(int pid) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - bool exist = dbus_bus_name_has_owner(g_m_conn_sender, VC_SERVER_SERVICE_NAME, &err); - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - int ret; - if (false == exist) { - ret = __dbus_restore_daemon(); - if (VC_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to restore daemon"); - return VC_ERROR_TIMED_OUT; - } - return VC_ERROR_OPERATION_FAILED; - } - - /* remove a rule for daemon error */ - char rule_err[256] = {0, }; - snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", VC_SERVER_SERVICE_INTERFACE); - dbus_bus_remove_match(g_m_conn_listener, rule_err, &err); - dbus_connection_flush(g_m_conn_listener); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCM, "Match Error (%s)", err.message); - dbus_error_free(&err); - return VC_ERROR_OPERATION_FAILED; - } - - return VC_ERROR_NONE; -} - -static DBusMessage* __get_message(int pid, const char* method, int type) -{ - char service_name[64]; - char object_path[64]; - char target_if_name[128]; - - memset(service_name, '\0', 64); - memset(object_path, '\0', 64); - memset(target_if_name, '\0', 128); - - if (VC_COMMAND_TYPE_FOREGROUND == type || VC_COMMAND_TYPE_BACKGROUND == type) { - snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - snprintf(object_path, 64, "%s", VC_CLIENT_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_CLIENT_SERVICE_NAME, pid); - } else if (VC_COMMAND_TYPE_WIDGET == type) { - snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); - snprintf(object_path, 64, "%s", VC_WIDGET_SERVICE_OBJECT_PATH); - snprintf(target_if_name, 128, "%s%d", VC_WIDGET_SERVICE_INTERFACE, pid); - } else { - return NULL; - } - - SLOG(LOG_INFO, TAG_VCM, "[Dbus] Service(%s) object(%s) if(%s)", service_name, object_path, target_if_name); - - return dbus_message_new_method_call(service_name, object_path, target_if_name, method); -} - -// int vc_mgr_dbus_send_result(int pid, int cmd_type, int result_id) -// { -// if (0 != __dbus_check()) { -// return VC_ERROR_OPERATION_FAILED; -// } - -// DBusMessage* msg = NULL; - -// switch (cmd_type) { -// case VC_COMMAND_TYPE_FOREGROUND: -// case VC_COMMAND_TYPE_BACKGROUND: -// msg = __get_message(pid, VCD_METHOD_RESULT, cmd_type); -// break; -// case VC_COMMAND_TYPE_WIDGET: -// msg = __get_message(pid, VCD_WIDGET_METHOD_RESULT, cmd_type); -// break; -// default: -// SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Command type is NOT valid(%d)", cmd_type); -// return -1; -// } - -// if (NULL == msg) -// SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Message is NULL"); - -// dbus_message_append_args(msg, DBUS_TYPE_INT32, &result_id, DBUS_TYPE_INVALID); - -// dbus_message_set_no_reply(msg, TRUE); - -// /* send the message and flush the connection */ -// if (1 != dbus_connection_send(g_m_conn_sender, msg, NULL)) { -// SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Fail to Send"); -// dbus_message_unref(msg); -// return VC_ERROR_OPERATION_FAILED; -// } else { -// SLOG(LOG_INFO, TAG_VCM, "[Dbus] SUCCESS Send"); -// dbus_connection_flush(g_m_conn_sender); -// } - -// dbus_message_unref(msg); -// return 0; -// } - -int vc_mgr_dbus_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e utt_status) -{ - if (0 != __dbus_check()) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - msg = __get_message(pid, VC_MANAGER_METHOD_UTTERANCE_STATUS, VC_COMMAND_TYPE_FOREGROUND); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCM, "@@ vc send utterance status : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCM, "@@ vc send utterance status : pid(%d), utt_id(%d), utt_status(%d)", pid, utt_id, utt_status); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INT32, &utt_status, - DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - /* send the message and flush the connection */ - if (1 != dbus_connection_send(g_m_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Fail to Send"); - dbus_message_unref(msg); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCM, "[Dbus] SUCCESS Send"); - dbus_connection_flush(g_m_conn_sender); - } - - dbus_message_unref(msg); - return 0; -} \ No newline at end of file diff --git a/client/vc_mgr_dbus.h b/client/vc_mgr_dbus.h deleted file mode 100644 index 4c82e19..0000000 --- a/client/vc_mgr_dbus.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VC_DBUS_H_ -#define __VC_DBUS_H_ - -#include "voice_control_manager_internal.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -int vc_mgr_dbus_open_connection(); - -int vc_mgr_dbus_close_connection(); - - -int vc_mgr_dbus_request_hello(); - -int vc_mgr_dbus_request_finalize(int pid); - -int vc_mgr_dbus_send_utterance_status(int pid, int utt_id, vc_tts_utterance_status_e utt_status); - -#ifdef __cplusplus -} -#endif - -#endif /* __VC_DBUS_H_ */ diff --git a/client/vc_setting.c b/client/vc_setting.c index c415a77..1e99383 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -17,7 +17,6 @@ #include "vc_config_mgr.h" #include "vc_main.h" -// #include "vc_setting_dbus.h" #include "vc_setting_tidl.h" #include "voice_control_common.h" #include "voice_control_setting.h" diff --git a/client/vc_setting_dbus.c b/client/vc_setting_dbus.c deleted file mode 100644 index c249d40..0000000 --- a/client/vc_setting_dbus.c +++ /dev/null @@ -1,384 +0,0 @@ -/* -* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "vc_setting_dbus.h" -#include "vc_main.h" - - -static int g_s_waiting_time = 3000; - -static Ecore_Fd_Handler* g_s_fd_handler = NULL; - -static DBusConnection* g_s_conn_sender = NULL; -static DBusConnection* g_s_conn_listener = NULL; - - -static Eina_Bool listener_setting_event_callback(void* data, Ecore_Fd_Handler *fd_handler) -{ - if (NULL == g_s_conn_listener) return ECORE_CALLBACK_RENEW; - - dbus_connection_read_write_dispatch(g_s_conn_listener, 50); - - while (1) { - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_s_conn_listener); - - /* loop again if we haven't read a message */ - if (NULL == msg) { - break; - } - - DBusError err; - dbus_error_init(&err); - - char if_name[64] = {0, }; - snprintf(if_name, 64, "%s", VC_SETTING_SERVICE_INTERFACE); - - if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_HELLO)) { - SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get Hello"); - int pid = 0; - int response = -1; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (pid > 0) { - SLOG(LOG_DEBUG, TAG_VCS, "@@ vc get hello : pid(%d) ", pid); - response = 1; - } else { - SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : invalid pid "); - } - - DBusMessage* reply = NULL; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID); - - if (!dbus_connection_send(g_s_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : fail to send reply"); - else - SLOG(LOG_DEBUG, TAG_VCS, "@@ vc get hello : result(%d)", response); - - dbus_connection_flush(g_s_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - } /* VCD_METHOD_HELLO */ - - else { - SLOG(LOG_DEBUG, TAG_VCS, "Message is NOT valid"); - dbus_message_unref(msg); - break; - } - - /* free the message */ - dbus_message_unref(msg); - } /* while(1) */ - - return ECORE_CALLBACK_PASS_ON; -} - -static void __vc_setting_dbus_connection_free() -{ - if (NULL != g_s_conn_listener) { - dbus_connection_close(g_s_conn_listener); - dbus_connection_unref(g_s_conn_listener); - g_s_conn_listener = NULL; - } - if (NULL != g_s_conn_sender) { - dbus_connection_close(g_s_conn_sender); - dbus_connection_unref(g_s_conn_sender); - g_s_conn_sender = NULL; - } -} - -int vc_setting_dbus_open_connection() -{ - if (NULL != g_s_conn_sender && NULL != g_s_conn_listener) { - SLOG(LOG_WARN, TAG_VCS, "already existed connection "); - return 0; - } - - DBusError err; - int ret; - - /* initialize the error value */ - dbus_error_init(&err); - - /* connect to the DBUS system bus, and check for errors */ - g_s_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "Dbus Connection Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL == g_s_conn_sender) { - SLOG(LOG_ERROR, TAG_VCS, "Fail to get dbus connection "); - return VC_ERROR_OPERATION_FAILED; - } - - g_s_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "Dbus Connection Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL == g_s_conn_listener) { - SLOG(LOG_ERROR, TAG_VCS, "Fail to get dbus connection "); - __vc_setting_dbus_connection_free(); - return VC_ERROR_OPERATION_FAILED; - } - - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_SETTING_SERVICE_NAME, pid); - - SLOG(LOG_DEBUG, TAG_VCS, "service name is %s", service_name); - - /* register our name on the bus, and check for errors */ - ret = dbus_bus_request_name(g_s_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "Name Error (%s)", err.message); - dbus_error_free(&err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - SLOG(LOG_ERROR, TAG_VCS, "fail dbus_bus_request_name()"); - __vc_setting_dbus_connection_free(); - return -2; - } - - if (NULL != g_s_fd_handler) { - SLOG(LOG_WARN, TAG_VCS, "The handler already exists."); - __vc_setting_dbus_connection_free(); - return 0; - } - - char rule[128] = {0, }; - snprintf(rule, 128, "type='signal',interface='%s'", VC_SETTING_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_s_conn_listener, rule, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "Match Error (%s)", err.message); - dbus_error_free(&err); - __vc_setting_dbus_connection_free(); - return VC_ERROR_OPERATION_FAILED; - } - - int fd = 0; - if (1 != dbus_connection_get_unix_fd(g_s_conn_listener, &fd)) { - SLOG(LOG_ERROR, TAG_VCS, "fail to get fd from dbus "); - __vc_setting_dbus_connection_free(); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCS, "Get fd from dbus : %d", fd); - } - - g_s_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_setting_event_callback, g_s_conn_listener, NULL, NULL); - if (NULL == g_s_fd_handler) { - SLOG(LOG_ERROR, TAG_VCS, "fail to get fd handler from ecore "); - __vc_setting_dbus_connection_free(); - return VC_ERROR_OPERATION_FAILED; - } - - return 0; -} - -int vc_setting_dbus_close_connection() -{ - DBusError err; - dbus_error_init(&err); - - if (NULL != g_s_fd_handler) { - ecore_main_fd_handler_del(g_s_fd_handler); - g_s_fd_handler = NULL; - } - - int pid = getpid(); - - char service_name[64]; - memset(service_name, '\0', 64); - snprintf(service_name, 64, "%s%d", VC_SETTING_SERVICE_NAME, pid); - - char rule[128] = {0, }; - snprintf(rule, 128, "type='signal',interface='%s'", VC_SETTING_SERVICE_INTERFACE); - dbus_bus_remove_match(g_s_conn_listener, rule, NULL); - - dbus_bus_release_name(g_s_conn_listener, service_name, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - __vc_setting_dbus_connection_free(); - - return 0; -} - -int vc_setting_dbus_reconnect() -{ - if (!g_s_conn_sender || !g_s_conn_listener) { - vc_setting_dbus_close_connection(); - - if (0 != vc_setting_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_DEBUG, TAG_VCS, "[DBUS] Reconnect"); - return 0; - } - - bool sender_connected = dbus_connection_get_is_connected(g_s_conn_sender); - bool listener_connected = dbus_connection_get_is_connected(g_s_conn_listener); - SLOG(LOG_WARN, TAG_VCS, "[DBUS] Sender(%s) Listener(%s)", - sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); - - if (false == sender_connected || false == listener_connected) { - vc_setting_dbus_close_connection(); - - if (0 != vc_setting_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_DEBUG, TAG_VCS, "[DBUS] Reconnect"); - } - - return 0; -} - -int vc_setting_dbus_request_hello() -{ - if (NULL == g_s_conn_sender) { - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_METHOD_HELLO); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCS, "@@ Request vc hello : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg = NULL; - int result = 0; - - result_msg = dbus_connection_send_with_reply_and_block(g_s_conn_sender, msg, 500, &err); - - if (dbus_error_is_set(&err)) { - dbus_error_free(&err); - } - - dbus_message_unref(msg); - - if (NULL != result_msg) { - dbus_message_unref(result_msg); - result = 0; - } else { - result = VC_ERROR_TIMED_OUT; - } - - return result; -} - -int vc_setting_dbus_request_set_language(int pid, const char* language) -{ - if (NULL == g_s_conn_sender) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus does not open"); - return VC_ERROR_OPERATION_FAILED; - } - - DBusMessage* msg; - - msg = dbus_message_new_method_call( - VC_SERVER_SERVICE_NAME, - VC_SERVER_SERVICE_OBJECT_PATH, - VC_SERVER_SERVICE_INTERFACE, - VC_SETTING_METHOD_SET_LANGUAGE); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCS, "@@ vc set language : Fail to make message"); - return VC_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCS, "@@ vc set language : pid(%d)", pid); - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &language, - DBUS_TYPE_INVALID); - - DBusError err; - dbus_error_init(&err); - - DBusMessage* result_msg; - int result = VC_ERROR_OPERATION_FAILED; - - result_msg = dbus_connection_send_with_reply_and_block(g_s_conn_sender, msg, g_s_waiting_time, &err); - dbus_message_unref(msg); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus Error (%s)", err.message); - dbus_error_free(&err); - } - - if (NULL != result_msg) { - dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCS, "@@ Get arguments error (%s)", err.message); - dbus_error_free(&err); - result = VC_ERROR_OPERATION_FAILED; - } - dbus_message_unref(result_msg); - - SLOG(LOG_DEBUG, TAG_VCS, "@@ vcd set language : result = %d", result); - } else { - SLOG(LOG_ERROR, TAG_VCS, "@@ Result message is NULL"); - vc_setting_dbus_reconnect(); - result = VC_ERROR_TIMED_OUT; - } - - return result; -} diff --git a/client/vc_setting_dbus.h b/client/vc_setting_dbus.h deleted file mode 100644 index 3404d4f..0000000 --- a/client/vc_setting_dbus.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VC_SETTING_DBUS_H_ -#define __VC_SETTING_DBUS_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -int vc_setting_dbus_open_connection(); - -int vc_setting_dbus_close_connection(); - -int vc_setting_dbus_request_hello(); - -int vc_setting_dbus_request_set_language(int pid, const char* language); - -#ifdef __cplusplus -} -#endif - -#endif /* __VC_SETTING_DBUS_H_ */ diff --git a/common/vc_main.h b/common/vc_main.h index 00e079a..6b6d400 100644 --- a/common/vc_main.h +++ b/common/vc_main.h @@ -18,7 +18,6 @@ #ifndef __VC_MAIN_H_ #define __VC_MAIN_H_ -#include #include #include #include diff --git a/include/voice-control-engine.pc.in b/include/voice-control-engine.pc.in index d089851..6dd2e26 100644 --- a/include/voice-control-engine.pc.in +++ b/include/voice-control-engine.pc.in @@ -5,7 +5,7 @@ includedir=@INCLUDEDIR@ Name: lib@PROJECT_NAME@_engine Description: Voice control engine header -Requires: glib-2.0 dbus-1 capi-base-common +Requires: glib-2.0 capi-base-common Version: @VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@_engine Cflags: -I${includedir} diff --git a/include/voice-control-manager.pc.in b/include/voice-control-manager.pc.in index 5165ffe..547af8e 100644 --- a/include/voice-control-manager.pc.in +++ b/include/voice-control-manager.pc.in @@ -5,7 +5,7 @@ includedir=@INCLUDEDIR@ Name: lib@PROJECT_NAME@_manager Description: Voice control manager client library -Requires: glib-2.0 dbus-1 capi-base-common +Requires: glib-2.0 capi-base-common Version: @VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@_manager Cflags: -I${includedir} diff --git a/include/voice-control-widget.pc.in b/include/voice-control-widget.pc.in index 308394a..4af9614 100644 --- a/include/voice-control-widget.pc.in +++ b/include/voice-control-widget.pc.in @@ -5,7 +5,7 @@ includedir=@INCLUDEDIR@ Name: lib@PROJECT_NAME@_widget Description: Voice control library for widget -Requires: glib-2.0 dbus-1 capi-base-common +Requires: glib-2.0 capi-base-common Version: @VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@_widget Cflags: -I${includedir} diff --git a/include/voice-control.pc.in b/include/voice-control.pc.in index 8396172..1f96496 100644 --- a/include/voice-control.pc.in +++ b/include/voice-control.pc.in @@ -5,7 +5,7 @@ includedir=@INCLUDEDIR@ Name: lib@PROJECT_NAME@ Description: Voice control client library -Requires: glib-2.0 dbus-1 capi-base-common +Requires: glib-2.0 capi-base-common Version: @VERSION@ Libs: -L${libdir} -l@PROJECT_NAME@ Cflags: -I${includedir} diff --git a/org.tizen.voice.vcserver.service b/org.tizen.voice.vcserver.service deleted file mode 100644 index aa51fd1..0000000 --- a/org.tizen.voice.vcserver.service +++ /dev/null @@ -1,5 +0,0 @@ -[D-BUS Service] -Name=org.tizen.voice.vcserver -#Exec=/usr/bin/vc-daemon -#Exec=/bin/sh -c "launch_app org.tizen.vc-engine-default" -Exec=/bin/sh -c "vc_getengine get system db/voice/vc/engine/default | awk '{print$5}' | xargs -t -i launch_app {}" diff --git a/org.tizen.voice.vcserver.tv.service b/org.tizen.voice.vcserver.tv.service deleted file mode 100644 index 22b0781..0000000 --- a/org.tizen.voice.vcserver.tv.service +++ /dev/null @@ -1,4 +0,0 @@ -[D-BUS Service] -Name=org.tizen.voice.vcserver -#Exec=/usr/bin/vc-daemon -Exec=/bin/sh -c "launch_app org.tizen.voice-client" diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 7ee6ece..952b983 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -20,7 +20,6 @@ BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(cynara-client) BuildRequires: pkgconfig(cynara-session) -BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(ecore) @@ -231,10 +230,8 @@ mkdir -p %{_libdir}/voice/vc %{_bindir}/vc_getengine %{TZ_SYS_RO_SHARE}/voice/vc/1.0/vc-config.xml %{TZ_SYS_RO_SHARE}/voice/vc/1.0/dependency-audio-manager/libvc-audio-manager.so -%{TZ_SYS_RO_SHARE}/dbus-1/services/org.tizen.voice* %{TZ_SYS_RO_SHARE}/parser-plugins/voice-control.info %{TZ_SYS_RO_ETC}/package-manager/parserlib/metadata/libvc-engine-parser.so* -/etc/dbus-1/session.d/vc-server.conf %files devel %manifest %{name}-devel.manifest diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 65e8713..399781c 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -9,8 +9,6 @@ SET(SRCS vcd_client_data.c vcd_server_data.cpp vcd_config.c -# vcd_dbus_server.c -# vcd_dbus.c vcd_tidl.c vcd_stub.c vcd_mgr_stub.c diff --git a/server/vcd_dbus.c b/server/vcd_dbus.c deleted file mode 100644 index b03d102..0000000 --- a/server/vcd_dbus.c +++ /dev/null @@ -1,546 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include -#include "vcd_client_data.h" -// #include "vcd_dbus.h" -// #include "vcd_dbus_server.h" -#include "vcd_tidl.h" -#include "vcd_main.h" - - -static DBusConnection* g_conn_sender = NULL; -static DBusConnection* g_conn_listener = NULL; - -static Ecore_Fd_Handler* g_dbus_fd_handler = NULL; - -// static int g_waiting_time = 3000; - -// static int g_volume_count = 0; - - -// static DBusMessage* __get_message(int pid, const char* method, vcd_client_type_e type) -// { -// char service_name[64] = {0,}; -// char object_path[64] = {0,}; -// char target_if_name[128] = {0,}; - -// if (VCD_CLIENT_TYPE_NORMAL == type) { -// snprintf(service_name, 64, "%s%d", VC_CLIENT_SERVICE_NAME, pid); -// snprintf(object_path, 64, "%s", VC_CLIENT_SERVICE_OBJECT_PATH); -// snprintf(target_if_name, 128, "%s", VC_CLIENT_SERVICE_INTERFACE); -// } else if (VCD_CLIENT_TYPE_WIDGET == type) { -// snprintf(service_name, 64, "%s%d", VC_WIDGET_SERVICE_NAME, pid); -// snprintf(object_path, 64, "%s", VC_WIDGET_SERVICE_OBJECT_PATH); -// snprintf(target_if_name, 128, "%s", VC_WIDGET_SERVICE_INTERFACE); -// } else if (VCD_CLIENT_TYPE_MANAGER == type) { -// snprintf(service_name, 64, "%s", VC_MANAGER_SERVICE_NAME); -// snprintf(object_path, 64, "%s", VC_MANAGER_SERVICE_OBJECT_PATH); -// snprintf(target_if_name, 128, "%s", VC_MANAGER_SERVICE_INTERFACE); -// } else { -// return NULL; -// } - -// return dbus_message_new_method_call(service_name, object_path, target_if_name, method); -// } - -int vcd_dbus_reconnect() -{ - if (!g_conn_sender || !g_conn_listener) { - vcd_dbus_close_connection(); - - if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_INFO, TAG_VCD, "[DBUS] Reconnect"); - return 0; - } - - bool sender_connected = dbus_connection_get_is_connected(g_conn_sender); - bool listener_connected = dbus_connection_get_is_connected(g_conn_listener); - SLOG(LOG_WARN, TAG_VCD, "[DBUS] Sender(%s) Listener(%s)", - sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected"); - - if (false == sender_connected || false == listener_connected) { - vcd_dbus_close_connection(); - - if (0 != vcd_dbus_open_connection()) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to reconnect"); - return -1; - } - - SLOG(LOG_INFO, TAG_VCD, "[DBUS] Reconnect"); - } - - return 0; -} - -// static int __dbus_check() -// { -// if (NULL == g_conn_sender || NULL == g_conn_listener) { -// SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection"); -// return vcd_dbus_reconnect(); -// } -// return 0; -// } - -int vcd_check_dbus_connection() -{ - if (NULL == g_conn_sender || NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] NULL connection sender(%p), listener(%p)", g_conn_sender, g_conn_listener); - return -1; - } - return 0; -} - -/* -int vcdc_send_manager_pid(int manager_pid) -{ - DBusError err; - dbus_error_init(&err); - - DBusMessage* msg = NULL; - - // Send to client - msg = dbus_message_new_signal( - VC_CLIENT_SERVICE_OBJECT_PATH, - VC_CLIENT_SERVICE_INTERFACE, - VCD_METHOD_SEND_MANAGER_PID); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &manager_pid, DBUS_TYPE_INVALID); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "@@ Send manager pid to client : pid(%d)", manager_pid); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return 0; -} - -int vcdc_send_error_signal(int reason, char *err_msg) -{ - SLOG(LOG_ERROR, TAG_VCD, "@@ Send error signal"); - - if (NULL == err_msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Input parameter is NULL"); - return VCD_ERROR_INVALID_PARAMETER; - } - - if (0 != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - int daemon_pid; - DBusError err; - dbus_error_init(&err); - - DBusMessage* msg = NULL; - - // msg = dbus_message_new_signal( - // VC_MANAGER_SERVICE_OBJECT_PATH, - // VC_MANAGER_SERVICE_INTERFACE, - // VCD_MANAGER_METHOD_ERROR); - - // if (NULL == msg) { - // SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - // return VCD_ERROR_OUT_OF_MEMORY; - // } - - // daemon_pid = getpid(); - // dbus_message_append_args(msg, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INT32, &daemon_pid, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - - // if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - // SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - // return VCD_ERROR_OPERATION_FAILED; - // } else { - // SLOG(LOG_INFO, TAG_VCD, "@@ Send error signal to manager: reason(%d), daemon_pid(%d), Error Msg(%s)", reason, daemon_pid, err_msg); - // dbus_connection_flush(g_conn_sender); - // } - - // dbus_message_unref(msg); - - // msg = NULL; - - vcdc_tidl_send_error(reason, err_msg); - - msg = dbus_message_new_signal( - VC_CLIENT_SERVICE_OBJECT_PATH, - VC_CLIENT_SERVICE_INTERFACE, - VCD_METHOD_ERROR); - - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INT32, &daemon_pid, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "@@ Send error signal : reason(%d), daemon_pid(%d), Error Msg(%s)", reason, daemon_pid, err_msg); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - // msg = NULL; - // msg = dbus_message_new_signal( - // VC_WIDGET_SERVICE_OBJECT_PATH, - // VC_WIDGET_SERVICE_INTERFACE, - // VCD_WIDGET_METHOD_ERROR); - - // if (NULL == msg) { - // SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - // return VCD_ERROR_OUT_OF_MEMORY; - // } - - // dbus_message_append_args(msg, DBUS_TYPE_INT32, &reason, DBUS_TYPE_INT32, &daemon_pid, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - - // if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - // SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - // return VCD_ERROR_OPERATION_FAILED; - // } else { - // SLOG(LOG_INFO, TAG_VCD, "@@ Send error signal to widget : reason(%d), daemon_pid(%d), Error Msg(%s)", reason, daemon_pid, err_msg); - // dbus_connection_flush(g_conn_sender); - // } - - // dbus_message_unref(msg); - - return 0; -} - -int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg) -{ - if (NULL == err_msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Input parameter is NULL"); - return VCD_ERROR_INVALID_PARAMETER; - } - - if (VCD_ERROR_NONE != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - SLOG(LOG_ERROR, TAG_VCD, "@@ Send error to app(%d)", pid); - - DBusMessage* msg = __get_message(pid, VCD_METHOD_ERROR_TO_APP, VCD_CLIENT_TYPE_NORMAL); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &reason, DBUS_TYPE_STRING, &err_msg, DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - if (TRUE != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - dbus_message_unref(msg); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "@@ Send error to app: pid(%d), reason(%d), Error Msg(%s)", pid, reason, err_msg); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return VCD_ERROR_NONE; -} -*/ -/* -int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len) -{ - SLOG(LOG_INFO, TAG_VCD, "[Dbus] Send TTS feedback streaming : pid(%d), utt_id(%d), feedback event(%d), buffer(%p), length(%d)", pid, utt_id, event, buffer, len); - - if (0 != __dbus_check()) { - return VCD_ERROR_OPERATION_FAILED; - } - - DBusError err; - dbus_error_init(&err); - - // make dbus message - DBusMessage* msg = NULL; - msg = __get_message(pid, VCD_METHOD_FEEDBACK_STREAMING, VCD_CLIENT_TYPE_NORMAL); - if (NULL == msg) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Message is NULL"); - return VCD_ERROR_OUT_OF_MEMORY; - } - - dbus_message_append_args(msg, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INT32, &event, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &buffer, len, - DBUS_TYPE_INVALID); - - dbus_message_set_no_reply(msg, TRUE); - - int ret = VCD_ERROR_NONE; - - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to Send"); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[Dbus] SUCCESS Send"); - dbus_connection_flush(g_conn_sender); - } - - dbus_message_unref(msg); - - return ret; -} -*/ -static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler) -{ - if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW; - - dbus_connection_read_write_dispatch(g_conn_listener, 50); - - while (1) { - DBusMessage* msg = NULL; - msg = dbus_connection_pop_message(g_conn_listener); - - /* loop again if we haven't read a message */ - if (NULL == msg) { - SLOG(LOG_INFO, TAG_VCD, "@@@ no Dbus message anymore"); - break; - } - - /* Common event */ - if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_HELLO)) - vcd_dbus_server_hello(g_conn_listener, msg); - - /* client event */ - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_INITIALIZE)) - vcd_dbus_server_initialize(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_FINALIZE)) - vcd_dbus_server_finalize(g_conn_listener, msg); -#if 0 - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_EXCLUSIVE_CMD)) - vcd_dbus_server_set_exclusive_command(g_conn_listener, msg); -#endif - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_COMMAND)) - vcd_dbus_server_set_command(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_UNSET_COMMAND)) - vcd_dbus_server_unset_command(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_FOREGROUND)) - vcd_dbus_server_set_foreground(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_SET_SERVER_DIALOG)) - vcd_dbus_server_set_server_dialog(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_DIALOG)) - vcd_dbus_server_dialog(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_IS_SYS_COMMAND_VALID)) - vcd_dbus_server_is_system_command_valid(g_conn_listener, msg); - -#if 0 - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_REQUEST_START)) - vcd_dbus_server_start_request(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_REQUEST_STOP)) - vcd_dbus_server_stop_request(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_REQUEST_CANCEL)) - vcd_dbus_server_cancel_request(g_conn_listener, msg); -#endif - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_SETTING_METHOD_SET_LANGUAGE)) - vcd_dbus_server_set_language(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_REQUEST_TTS)) - vcd_dbus_server_request_tts(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_CANCEL_TTS)) - vcd_dbus_server_cancel_tts(g_conn_listener, msg); - - else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_GET_TTS_AUDIO_FORMAT)) - vcd_dbus_server_get_tts_audio_format(g_conn_listener, msg); - - else { - const char* sender = dbus_message_get_sender(msg); - const char* destination = dbus_message_get_destination(msg); - const char* path = dbus_message_get_path(msg); - const char* interf = dbus_message_get_interface(msg); - const char* member = dbus_message_get_member(msg); - int type = dbus_message_get_type(msg); - SLOG(LOG_ERROR, TAG_VCD, "[INFO] Message is NOT valid, sender(%s), destination(%s), path(%s), interface(%s), member(%s), type(%d)", sender, destination, path, interf, member, type); - dbus_message_unref(msg); - break; - } - - /* free the message */ - dbus_message_unref(msg); - } - - return ECORE_CALLBACK_RENEW; -} - -static void __vcd_dbus_connection_free() -{ - if (NULL != g_conn_listener) { - dbus_connection_close(g_conn_listener); - dbus_connection_unref(g_conn_listener); - g_conn_listener = NULL; - } - if (NULL != g_conn_sender) { - dbus_connection_close(g_conn_sender); - dbus_connection_unref(g_conn_sender); - g_conn_sender = NULL; - } -} - -int vcd_dbus_open_connection() -{ - DBusError err; - dbus_error_init(&err); - - int ret; - - /* Create connection for sender */ - g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); - dbus_error_free(&err); - } - - if (NULL == g_conn_sender) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to get dbus connection"); - return VCD_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_conn_sender, false); - - /* connect to the bus and check for errors */ - g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message); - dbus_error_free(&err); - } - - if (NULL == g_conn_listener) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to get dbus connection"); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - dbus_connection_set_exit_on_disconnect(g_conn_listener, false); - - /* request our name on the bus and check for errors */ - ret = dbus_bus_request_name(g_conn_listener, VC_SERVER_SERVICE_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - printf("Fail to be primary owner in dbus request."); - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to be primary owner"); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_request_name() : %s", err.message); - dbus_error_free(&err); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - /* Flush messages which are received before fd event handler registration */ - while (DBUS_DISPATCH_COMPLETE != dbus_connection_get_dispatch_status(g_conn_listener)) { - SLOG(LOG_INFO, TAG_VCD, "Dbus data is remained, g_conn_listener(%p)", g_conn_listener); - listener_event_callback(NULL, NULL); - } - - /* add fd handler to receive dbus metohd */ - int fd = 0; - if (1 != dbus_connection_get_unix_fd(g_conn_listener, &fd)) { - SLOG(LOG_ERROR, TAG_VCD, "fail to get fd from dbus "); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "Get fd from dbus : %d", fd); - } - - g_dbus_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL); - - if (NULL == g_dbus_fd_handler) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to get fd handler"); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - /* add a rule for getting signal */ - char rule[128]; - snprintf(rule, 128, "type='signal',interface='%s'", VC_SERVER_SERVICE_INTERFACE); - - /* add a rule for which messages we want to see */ - dbus_bus_add_match(g_conn_listener, rule, &err);/* see signals from the given interface */ - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_add_match() : %s", err.message); - dbus_error_free(&err); - __vcd_dbus_connection_free(); - return VCD_ERROR_OPERATION_FAILED; - } - - SLOG(LOG_INFO, TAG_VCD, "[INFO] Success to open dbus connection"); - - return 0; -} - -int vcd_dbus_close_connection() -{ - DBusError err; - dbus_error_init(&err); - - if (NULL != g_dbus_fd_handler) { - ecore_main_fd_handler_del(g_dbus_fd_handler); - g_dbus_fd_handler = NULL; - } - - if (NULL != g_conn_listener) { - dbus_bus_release_name(g_conn_listener, VC_SERVER_SERVICE_NAME, &err); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] dbus_bus_release_name() : %s", err.message); - dbus_error_free(&err); - } - } - __vcd_dbus_connection_free(); - - return 0; -} diff --git a/server/vcd_dbus.h b/server/vcd_dbus.h deleted file mode 100644 index 88fd974..0000000 --- a/server/vcd_dbus.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VCD_DBUS_h__ -#define __VCD_DBUS_h__ - -#include "vcd_main.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int vcd_dbus_open_connection(); - -int vcd_dbus_close_connection(); - -int vcd_check_dbus_connection(); - - -#ifdef __cplusplus -} -#endif - -#endif /* __VCD_DBUS_h__ */ diff --git a/server/vcd_dbus_server.c b/server/vcd_dbus_server.c deleted file mode 100644 index 4556102..0000000 --- a/server/vcd_dbus_server.c +++ /dev/null @@ -1,1469 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#include "vcd_client_data.h" -// #include "vcd_dbus.h" -#include "vcd_tidl.h" -// #include "vcd_dbus_server.h" -#include "vcd_main.h" -#include "vcd_server.h" -#include "vcd_config.h" - -vc_cmd_type_e vc_command_types[7] = {VC_COMMAND_TYPE_NONE, - VC_COMMAND_TYPE_FOREGROUND, - VC_COMMAND_TYPE_BACKGROUND, - VC_COMMAND_TYPE_WIDGET, - VC_COMMAND_TYPE_SYSTEM, - VC_COMMAND_TYPE_SYSTEM_BACKGROUND, - VC_COMMAND_TYPE_EXCLUSIVE}; - - -int __dbus_error_return(DBusConnection* conn, DBusMessage* msg, int ret) -{ - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg) -{ - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Hello"); - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -/* for TTS feedback */ -int vcd_dbus_server_mgr_start_feedback(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = 0; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager start TTS feedback"); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] vcd mgr start TTS feedback : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[DEBUG] vcd mgr start TTS feedback : pid(%d)", pid); - ret = vcd_server_mgr_start_feedback(); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Out of Memory"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_mgr_stop_feedback(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = 0; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager stop TTS feedback"); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] vcd mgr stop TTS feedback : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[DEBUG] vcd mgr stop TTS feedback : pid(%d)", pid); - ret = vcd_server_mgr_stop_feedback(); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Out of Memory"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_mgr_send_audio_streaming(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = 0; - int event = 0; - char* buffer = NULL; - unsigned int len = 0; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager send audio streaming"); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &event, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &buffer, &len, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr send audio streaming : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr send audio streaming : pid(%d), event(%d), buffer(%p), len(%d)", pid, event, buffer, len); - ret = vcd_server_mgr_send_audio_streaming(pid, event, buffer, len); - } - - return ret; -} - -int vcd_dbus_server_mgr_change_system_volume(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = 0; - int volume_event = 0; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager change system volume"); - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &volume_event, - DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr disable command type : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr change system volume: pid(%d), volume_event(%d)", pid, volume_event); - ret = vcd_server_mgr_change_system_volume(pid, volume_event); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; - -} - -int vcd_dbus_server_mgr_set_audio_streaming_mode(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int mode; - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &mode, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Manager set audio streaming mode"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr set audio streaming mode : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd mgr set audio streaming mode : pid(%d) mode(%d)", pid, mode); - vcd_config_set_audio_streaming_mode((vcd_audio_streaming_mode_e)mode); - } - return 0; -} - -/* -* Dbus Server functions for client -*/ -int vcd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int service_state = 0; - int daemon_pid; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Initialize"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd initialize : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - ret = vcd_server_initialize(pid); - service_state = vcd_server_get_service_state(); - daemon_pid = getpid(); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd initialize : pid(%d) daemon_pid(%d)", pid, daemon_pid); - } - - int mgr_pid = vcd_client_manager_get_pid(); - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &mgr_pid, - DBUS_TYPE_INT32, &service_state, - DBUS_TYPE_INT32, &daemon_pid, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Finalize"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd finalize : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd finalize : pid(%d)", pid); - ret = vcd_server_finalize(pid); - } - - DBusMessage* reply; - - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -#if 0 -int vcd_dbus_server_set_exclusive_command(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int value; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &value, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set exclusive command"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd unset command : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd unset command : pid(%d) value(%d)", pid, value); - ret = vcd_server_set_exclusive_command(pid, (bool)value); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} -#endif - -int vcd_dbus_server_set_command(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int cmd_type; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &cmd_type, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set command"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd set command : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set command : pid(%d), cmd_type(%d)", pid, cmd_type); - ret = vcd_server_set_command(pid, (vc_cmd_type_e)cmd_type); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_unset_command(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int cmd_type; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &cmd_type, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD unset command"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd unset command : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd unset command : pid(%d), cmd_type(%d)", pid, cmd_type); - ret = vcd_server_unset_command(pid, (vc_cmd_type_e)cmd_type); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_set_foreground(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int value; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &value, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set foreground"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd set foreground : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - bool tmp_value; - tmp_value = (bool)value; - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d), value(%s)", pid, value ? "true" : "false"); - vcd_server_set_foreground(pid, tmp_value); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_set_server_dialog(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid = -1; - char* app_id = NULL; - char* credential = NULL; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &app_id, - DBUS_TYPE_STRING, &credential, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD set server dialog"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd set server dialog : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set server dialog : pid(%d), app_id(%s)", pid, app_id); - ret = vcd_server_set_server_dialog(pid, app_id, credential); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; - -} - -int vcd_dbus_server_dialog(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - char* disp_text = NULL; - char* utt_text = NULL; - int continuous; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &disp_text, - DBUS_TYPE_STRING, &utt_text, - DBUS_TYPE_INT32, &continuous, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD request dialog"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd request dialog : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous); - ret = vcd_server_dialog(pid, disp_text, utt_text, continuous); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to dialog"); - } - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_is_system_command_valid(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int is_sys_cmd_valid; - - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD request to check system command is valid"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd request to check system command is valid : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd dialog : pid(%d)", pid); - ret = vcd_server_is_system_command_valid(pid, &is_sys_cmd_valid); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &is_sys_cmd_valid, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d), is_sys_cmd_valid (%d)", ret, is_sys_cmd_valid); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -#if 0 -int vcd_dbus_server_start_request(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int silence; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Request Start"); - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &silence, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd start : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd request start : pid(%d), silence(%d)", pid, silence); - ret = vcd_server_request_start(pid, (bool)silence); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_stop_request(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Request Stop"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd stop : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd request stop : pid(%d)", pid); - ret = vcd_server_request_stop(pid); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_cancel_request(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Request Cancel"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd cancel : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd request cancel : pid(%d)", pid); - ret = vcd_server_request_cancel(pid); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} -#endif - -/* -* Dbus Widget-Daemon Server -*/ -int vcd_dbus_server_widget_initialize(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int service_state = 0; - int daemon_pid; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Initialize"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget initialize : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - ret = vcd_server_widget_initialize(pid); - service_state = vcd_server_get_service_state(); - daemon_pid = getpid(); - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget initialize : pid(%d) daemon_pid(%d)", pid, daemon_pid); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &service_state, - DBUS_TYPE_INT32, &daemon_pid, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_finalize(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD Widget Finalize"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget finalize : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget finalize : pid(%d)", pid); - ret = vcd_server_widget_finalize(pid); - } - - DBusMessage* reply; - - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_start_recording(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - int widget_command; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &widget_command, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget start recording"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget start recording : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start recording : pid(%d)", pid); - ret = vcd_server_widget_start_recording(pid, widget_command); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - if (0 == ret) { - /* Append result and language */ - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_start(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int silence; - - int ret = VCD_ERROR_OPERATION_FAILED; - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget start"); - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &silence, DBUS_TYPE_INVALID); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd start : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget start : pid(%d), silence(%d)", pid, silence); - ret = vcd_server_widget_start(pid, (bool)silence); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_stop(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget stop"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget stop : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget stop : pid(%d)", pid); - ret = vcd_server_widget_stop(pid); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_cancel(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget cancel"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget cancel : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget cancel : pid(%d)", pid); - ret = vcd_server_widget_cancel(pid); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_widget_enable_asr_result(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int enable; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INT32, &enable, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD widget enable asr result"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd widget enable asr result : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd widget enable asr result : pid(%d) enable(%d)", pid, enable); - ret = vcd_server_widget_enable_asr_result(pid, enable); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_set_language(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - char* language; - int ret = VCD_ERROR_OPERATION_FAILED; - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_STRING, &language, DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD server set language"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd server set language : get arguments error (%s)", err.message); - dbus_error_free(&err); - ret = VCD_ERROR_OPERATION_FAILED; - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd server set language : language(%s)", language); - ret = vcd_server_set_language(language); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_request_tts(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - char* text = NULL; - char* language = NULL; - int to_vcm; - int utt_id = -1; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_STRING, &text, - DBUS_TYPE_STRING, &language, - DBUS_TYPE_INT32, &to_vcm, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD request tts"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd request tts : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d)", pid, text, language, to_vcm); - ret = vcd_server_request_tts(pid, text, language, to_vcm, &utt_id); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d), utt_id(%d)", ret, utt_id); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_cancel_tts(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int utt_id; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INT32, &utt_id, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD cancel tts"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd cancel tts : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd cancel tts : pid(%d), utt_id(%d)", pid, utt_id); - ret = vcd_server_cancel_tts(pid, utt_id); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} - -int vcd_dbus_server_get_tts_audio_format(DBusConnection* conn, DBusMessage* msg) -{ - DBusError err; - dbus_error_init(&err); - - int pid; - int rate; - int channel; - int audio_type; - int ret = VCD_ERROR_OPERATION_FAILED; - - dbus_message_get_args(msg, &err, - DBUS_TYPE_INT32, &pid, - DBUS_TYPE_INVALID); - - SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD request tts"); - - if (dbus_error_is_set(&err)) { - SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd get tts audio format : get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { - SLOG(LOG_INFO, TAG_VCD, "[IN] vcd get tts audio format : pid(%d)", pid); - ret = vcd_server_get_tts_audio_format(pid, &rate, &channel, &audio_type); - } - - DBusMessage* reply; - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, - DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &rate, - DBUS_TYPE_INT32, &channel, - DBUS_TYPE_INT32, &audio_type, - DBUS_TYPE_INVALID); - - if (0 == ret) { - SLOG(LOG_INFO, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret); - } - - if (!dbus_connection_send(conn, reply, NULL)) { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!"); - } - - dbus_connection_flush(conn); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!"); - } - - SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - - return 0; -} diff --git a/server/vcd_dbus_server.h b/server/vcd_dbus_server.h deleted file mode 100644 index 0d0ec0a..0000000 --- a/server/vcd_dbus_server.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved -* -* Licensed under the Apache License, Version 2.0 (the License); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an AS IS BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - - -#ifndef __VCD_DBUS_SERVER_h__ -#define __VCD_DBUS_SERVER_h__ - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -int vcd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg); - -/* -* Dbus Server functions for manager -*/ -/* for TTS feedback */ -int vcd_dbus_server_mgr_start_feedback(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_mgr_stop_feedback(DBusConnection* conn, DBusMessage* msg); - -/* for Multi-assistant */ -int vcd_dbus_server_mgr_send_audio_streaming(DBusConnection* conn, DBusMessage* msg); - - -/* -* Dbus Server functions for client -*/ - -int vcd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg); - -#if 0 -int vcd_dbus_server_set_exclusive_command(DBusConnection* conn, DBusMessage* msg); -#endif - -int vcd_dbus_server_set_command(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_unset_command(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_set_foreground(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_set_server_dialog(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_dialog(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_is_system_command_valid(DBusConnection* conn, DBusMessage* msg); - -#if 0 -int vcd_dbus_server_start_request(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_stop_request(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_cancel_request(DBusConnection* conn, DBusMessage* msg); -#endif - -/* -* Dbus Server functions for widget -*/ -int vcd_dbus_server_widget_initialize(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_finalize(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_start_recording(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_start(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_stop(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_cancel(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_widget_enable_asr_result(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_set_language(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_request_tts(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_cancel_tts(DBusConnection* conn, DBusMessage* msg); - -int vcd_dbus_server_get_tts_audio_format(DBusConnection* conn, DBusMessage* msg); - - -#ifdef __cplusplus -} -#endif - - -#endif /* __VCD_DBUS_SERVER_h__ */ diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 7b89164..2d5bcf2 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -23,7 +23,6 @@ #include "vcd_engine_agent.h" #include "vcd_main.h" #include "vcd_recorder.h" -// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vce_internal.h" diff --git a/server/vcd_server.c b/server/vcd_server.c index a4badcf..d82b10b 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -28,7 +28,6 @@ #include "vcd_engine_agent.h" #include "vcd_config.h" #include "vcd_recorder.h" -// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vce_internal.h" diff --git a/server/vce.c b/server/vce.c index e4b359b..9a66d2d 100644 --- a/server/vce.c +++ b/server/vce.c @@ -19,7 +19,6 @@ #include #include #include -// #include "vcd_dbus.h" #include "vcd_tidl.h" #include "vcd_main.h" #include "vcd_server.h" @@ -165,12 +164,6 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback) return VCE_ERROR_OPERATION_FAILED; } - // if (0 != vcd_dbus_open_connection()) { - // SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to open connection"); - // ecore_shutdown(); - // return VCE_ERROR_OPERATION_FAILED; - // } - ret = vcd_initialize(callback); if (0 != ret) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to initialize"); diff --git a/vc-server.conf b/vc-server.conf deleted file mode 100644 index 60a1d1b..0000000 --- a/vc-server.conf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - -- 2.7.4 From c339d4f5c648a60152d1bc82d8e5b3fefac2d428 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 29 Jun 2022 15:44:11 +0900 Subject: [PATCH 13/16] Change return values and Fix minor issues Change-Id: I1d10d83f58b3ec36ed3308b8906a5151b7571875 Signed-off-by: sooyeon --- client/vc.c | 50 +++++++-------- client/vc_client.c | 94 ++++++++++++++-------------- client/vc_data.cpp | 2 +- client/vc_mgr.c | 132 +++++++++++++++++++------------------- client/vc_mgr_client.c | 153 +++++++++++++++++++++++---------------------- client/vc_mgr_data.cpp | 2 +- client/vc_mgr_player.c | 16 ++--- client/vc_setting.c | 14 ++--- client/vc_tidl.c | 20 ++++-- client/vc_widget.c | 48 +++++++------- client/vc_widget_client.c | 78 +++++++++++------------ common/vc_cmd_db.c | 8 +-- common/vc_command.c | 50 +++++++-------- common/vc_config_mgr.c | 64 +++++++++---------- server/vcd_client_data.c | 146 +++++++++++++++++++++--------------------- server/vcd_config.c | 26 ++++---- server/vcd_engine_agent.c | 58 ++++++++--------- server/vcd_server.c | 46 +++++++------- server/vcd_server_data.cpp | 4 +- server/vce.c | 4 +- 20 files changed, 513 insertions(+), 502 deletions(-) diff --git a/client/vc.c b/client/vc.c index dd7be5a..4fed631 100644 --- a/client/vc.c +++ b/client/vc.c @@ -94,7 +94,7 @@ static int __vc_get_feature_enabled() } } - return 0; + return VC_ERROR_NONE; } static int __check_privilege_initialize() @@ -1682,17 +1682,17 @@ 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)) { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid client"); - return -1; + 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"); - return -1; + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] not connected client yet(%d)", reason); + return VC_ERROR_INVALID_STATE; } - return 0; + return VC_ERROR_NONE; } if (VC_ERROR_SERVICE_RESET == reason) { @@ -1711,7 +1711,7 @@ int __vc_cb_error(int reason, int daemon_pid, char* msg) vc_client_set_error(g_vc, reason); ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); - return 0; + return VC_ERROR_NONE; } int __vc_cb_error_to_app(int pid, int reason, const char* msg) @@ -1896,7 +1896,7 @@ int vc_set_result_cb(vc_result_cb callback, void* user_data) vc_client_set_result_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_result_cb(void) @@ -1922,7 +1922,7 @@ int vc_unset_result_cb(void) vc_client_set_result_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -1933,7 +1933,7 @@ int __vc_cb_service_state(int state) vc_client_get_service_state(g_vc, &before_state); if (current_state == before_state) { - return 0; + return VC_ERROR_NONE; } SLOG(LOG_DEBUG, TAG_VCC, "Service State changed : Before(%d) Current(%d)", @@ -1955,7 +1955,7 @@ int __vc_cb_service_state(int state) SLOG(LOG_WARN, TAG_VCC, "[WARNING] Service state changed callback is null"); } - return 0; + return VC_ERROR_NONE; } int __vc_cb_manager_pid(int manager_pid) @@ -1965,7 +1965,7 @@ int __vc_cb_manager_pid(int manager_pid) /* Save service state */ vc_client_set_mgr_pid(g_vc, manager_pid); - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -1995,7 +1995,7 @@ int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* vc_client_set_service_state_changed_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_service_state_changed_cb(void) @@ -2021,7 +2021,7 @@ int vc_unset_service_state_changed_cb(void) vc_client_set_service_state_changed_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) @@ -2050,7 +2050,7 @@ int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) vc_client_set_state_changed_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_state_changed_cb(void) @@ -2076,7 +2076,7 @@ int vc_unset_state_changed_cb(void) vc_client_set_state_changed_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) @@ -2105,7 +2105,7 @@ int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, vc_client_set_current_lang_changed_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_current_language_changed_cb(void) @@ -2131,7 +2131,7 @@ int vc_unset_current_language_changed_cb(void) vc_client_set_current_lang_changed_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_set_error_cb(vc_error_cb callback, void* user_data) @@ -2160,7 +2160,7 @@ int vc_set_error_cb(vc_error_cb callback, void* user_data) vc_client_set_error_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_unset_error_cb(void) @@ -2186,7 +2186,7 @@ int vc_unset_error_cb(void) vc_client_set_error_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_set_invocation_name(const char* name) @@ -3244,7 +3244,7 @@ int vc_tts_set_streaming_cb(vc_tts_streaming_cb callback, void* user_data) vc_client_set_tts_streaming_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_tts_unset_streaming_cb(void) @@ -3270,7 +3270,7 @@ int vc_tts_unset_streaming_cb(void) vc_client_set_tts_streaming_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_cb_utterance_status(int utt_id, int utt_status) @@ -3281,7 +3281,7 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) 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 -1; + return VC_ERROR_INVALID_PARAMETER; } SLOG(LOG_DEBUG, TAG_VCC, "Utterance status callback is called"); @@ -3289,7 +3289,7 @@ int __vc_cb_utterance_status(int utt_id, int utt_status) callback(utt_id, (vc_tts_utterance_status_e)utt_status, user_data); vc_client_not_use_callback(g_vc); - return 0; + return VC_ERROR_NONE; } int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* user_data) @@ -3318,7 +3318,7 @@ int vc_tts_set_utterance_status_cb(vc_tts_utterance_status_cb callback, void* us vc_client_set_tts_utterance_status_cb(g_vc, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_tts_unset_utterance_status_cb(void) @@ -3344,6 +3344,6 @@ int vc_tts_unset_utterance_status_cb(void) vc_client_set_tts_utterance_status_cb(g_vc, NULL, NULL); - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP diff --git a/client/vc_client.c b/client/vc_client.c index fe116b0..03e0908 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -170,14 +170,14 @@ int vc_client_create(vc_h* vc) *vc = temp; - return 0; + return VC_ERROR_NONE; } int vc_client_destroy(vc_h vc) { if (vc == NULL) { SLOG(LOG_ERROR, TAG_VCC, "Input parameter is NULL"); //LCOV_EXCL_LINE - return 0; + return VC_ERROR_NONE; } vc_client_s *data = NULL; @@ -203,14 +203,14 @@ int vc_client_destroy(vc_h vc) free(vc); data = NULL; vc = NULL; - return 0; + return VC_ERROR_NONE; } } } SLOG(LOG_ERROR, TAG_VCC, "[ERROR] client Not found"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } bool vc_client_is_valid(vc_h vc) @@ -264,12 +264,12 @@ int vc_client_get_handle(int pid, vc_h* vc) SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] pid(%d), handle(%d)", pid, data->vc->handle); if (pid == data->vc->handle) { *vc = data->vc; - return 0; + return VC_ERROR_NONE; } } } - return -1; + return VC_ERROR_INVALID_PARAMETER; } //LCOV_EXCL_STOP @@ -285,7 +285,7 @@ int vc_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data) client->result_cb = callback; client->result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -300,7 +300,7 @@ int vc_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data) *callback = client->result_cb; *user_data = client->result_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -315,7 +315,7 @@ int vc_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb client->service_state_changed_cb = callback; client->service_state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -330,7 +330,7 @@ int vc_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* *callback = client->service_state_changed_cb; *user_data = client->service_state_changed_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -345,7 +345,7 @@ int vc_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* client->state_changed_cb = callback; client->state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -360,7 +360,7 @@ int vc_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void* *callback = client->state_changed_cb; *user_data = client->state_changed_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -375,7 +375,7 @@ int vc_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_c client->current_lang_changed_cb = callback; client->current_lang_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -390,7 +390,7 @@ int vc_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_c *callback = client->current_lang_changed_cb; *user_data = client->current_lang_changed_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -405,7 +405,7 @@ int vc_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) client->error_cb = callback; client->error_user_data = user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -420,7 +420,7 @@ int vc_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) *callback = client->error_cb; *user_data = client->error_user_data; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -435,7 +435,7 @@ int vc_client_set_service_state(vc_h vc, vc_service_state_e state) client->service_state = state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_service_state(vc_h vc, vc_service_state_e* state) @@ -448,7 +448,7 @@ int vc_client_get_service_state(vc_h vc, vc_service_state_e* state) *state = client->service_state; - return 0; + return VC_ERROR_NONE; } int vc_client_set_client_state(vc_h vc, vc_state_e state) @@ -462,7 +462,7 @@ int vc_client_set_client_state(vc_h vc, vc_state_e state) client->before_state = client->current_state; client->current_state = state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_client_state(vc_h vc, vc_state_e* state) @@ -475,7 +475,7 @@ int vc_client_get_client_state(vc_h vc, vc_state_e* state) *state = client->current_state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) @@ -491,12 +491,12 @@ int vc_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) if (NULL != data) { if (uid == data->vc->handle) { *state = data->current_state; - return 0; + return VC_ERROR_NONE; } } } - return -1; + return VC_ERROR_INVALID_PARAMETER; } int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) @@ -510,7 +510,7 @@ int vc_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_st *before_state = client->before_state; *state = client->current_state; - return 0; + return VC_ERROR_NONE; } int vc_client_set_invocation_name(vc_h vc, const char* invocation_name) @@ -529,7 +529,7 @@ int vc_client_set_invocation_name(vc_h vc, const char* invocation_name) if (NULL != invocation_name) { client->invocation_name = strdup(invocation_name); } - return 0; + return VC_ERROR_NONE; } int vc_client_get_invocation_name(vc_h vc, char** invocation_name) @@ -542,7 +542,7 @@ int vc_client_get_invocation_name(vc_h vc, char** invocation_name) if (NULL != client->invocation_name) *invocation_name = strdup(client->invocation_name); - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -556,7 +556,7 @@ int vc_client_set_xid(vc_h vc, int xid) client->xid = xid; - return 0; + return VC_ERROR_NONE; } int vc_client_get_xid(vc_h vc, int* xid) @@ -569,7 +569,7 @@ int vc_client_get_xid(vc_h vc, int* xid) *xid = client->xid; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -582,7 +582,7 @@ int vc_client_set_is_foreground(vc_h vc, bool value) return VC_ERROR_INVALID_PARAMETER; client->is_foreground = value; - return 0; + return VC_ERROR_NONE; } int vc_client_get_is_foreground(vc_h vc, bool* value) @@ -595,7 +595,7 @@ int vc_client_get_is_foreground(vc_h vc, bool* value) *value = client->is_foreground; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -610,7 +610,7 @@ int vc_client_set_exclusive_cmd(vc_h vc, bool value) client->exclusive_cmd = value; - return 0; + return VC_ERROR_NONE; } int vc_client_get_exclusive_cmd(vc_h vc, bool* value) @@ -623,7 +623,7 @@ int vc_client_get_exclusive_cmd(vc_h vc, bool* value) *value = client->exclusive_cmd; - return 0; + return VC_ERROR_NONE; } #endif //LCOV_EXCL_STOP @@ -638,7 +638,7 @@ int vc_client_set_error(vc_h vc, int reason) client->reason = reason; - return 0; + return VC_ERROR_NONE; } int vc_client_get_error(vc_h vc, int* reason) @@ -651,7 +651,7 @@ int vc_client_get_error(vc_h vc, int* reason) *reason = client->reason; - return 0; + return VC_ERROR_NONE; } @@ -670,7 +670,7 @@ int vc_client_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; client->cb_ref_count++; - return 0; + return VC_ERROR_NONE; } int vc_client_not_use_callback(vc_h vc) @@ -682,7 +682,7 @@ int vc_client_not_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; client->cb_ref_count--; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_START @@ -698,7 +698,7 @@ int vc_client_set_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb callba client->auth_state_changed_cb = callback; client->auth_state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_get_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb* callback, void** user_data) @@ -712,7 +712,7 @@ int vc_client_get_auth_state_changed_cb(vc_h vc, vc_auth_state_changed_cb* callb *callback = client->auth_state_changed_cb; *user_data = client->auth_state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_unset_auth_state_changed_cb(vc_h vc) @@ -726,7 +726,7 @@ int vc_client_unset_auth_state_changed_cb(vc_h vc) client->auth_state_changed_cb = NULL; client->auth_state_changed_user_data = NULL; - return 0; + return VC_ERROR_NONE; } int vc_client_set_auth_state(vc_h vc, vc_auth_state_e state) @@ -740,7 +740,7 @@ int vc_client_set_auth_state(vc_h vc, vc_auth_state_e state) client->auth_before_state = client->auth_current_state; client->auth_current_state = state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_auth_state(vc_h vc, vc_auth_state_e* state) @@ -753,7 +753,7 @@ int vc_client_get_auth_state(vc_h vc, vc_auth_state_e* state) *state = client->auth_current_state; - return 0; + return VC_ERROR_NONE; } int vc_client_get_before_auth_state(vc_h vc, vc_auth_state_e* before, vc_auth_state_e* current) @@ -767,7 +767,7 @@ int vc_client_get_before_auth_state(vc_h vc, vc_auth_state_e* before, vc_auth_st *before = client->auth_before_state; *current = client->auth_current_state; - return 0; + return VC_ERROR_NONE; } //LCOV_EXCL_STOP @@ -781,7 +781,7 @@ int vc_client_set_mgr_pid(vc_h vc, int mgr_pid) client->mgr_pid = mgr_pid; - return 0; + return VC_ERROR_NONE; } int vc_client_get_mgr_pid(vc_h vc, int* mgr_pid) @@ -794,7 +794,7 @@ int vc_client_get_mgr_pid(vc_h vc, int* mgr_pid) *mgr_pid = client->mgr_pid; - return 0; + return VC_ERROR_NONE; } int vc_client_set_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb callback, void* user_data) @@ -808,7 +808,7 @@ int vc_client_set_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb callback, void* client->tts_streaming_cb = callback; client->tts_streaming_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_get_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb* callback, void** user_data) @@ -822,7 +822,7 @@ int vc_client_get_tts_streaming_cb(vc_h vc, vc_tts_streaming_cb* callback, void* *callback = client->tts_streaming_cb; *user_data = client->tts_streaming_user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_set_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb callback, void* user_data) @@ -836,7 +836,7 @@ int vc_client_set_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb ca client->tts_utterance_status_cb = callback; client->tts_utterance_status_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_client_get_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb* callback, void** user_data) @@ -850,5 +850,5 @@ int vc_client_get_tts_utterance_status_cb(vc_h vc, vc_tts_utterance_status_cb* c *callback = client->tts_utterance_status_cb; *user_data = client->tts_utterance_status_user_data; - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_data.cpp b/client/vc_data.cpp index afc475d..d66cab3 100644 --- a/client/vc_data.cpp +++ b/client/vc_data.cpp @@ -127,7 +127,7 @@ int vc_data_clear_tts_data_by_uttid(int utt_id) if (g_tts_data.empty()) { SLOG(LOG_ERROR, TAG_VCC, "[DATA ERROR] There is no tts data"); pthread_mutex_unlock(&g_tts_data_mutex); - return -1; + return VC_ERROR_EMPTY; } std::list::iterator iter; diff --git a/client/vc_mgr.c b/client/vc_mgr.c index 1203bf6..5019344 100644 --- a/client/vc_mgr.c +++ b/client/vc_mgr.c @@ -151,7 +151,7 @@ static int __vc_mgr_get_feature_enabled() } } - return 0; + return VC_ERROR_NONE; } static int __check_privilege_initialize() @@ -831,7 +831,7 @@ int vc_mgr_set_demandable_client_rule(const char* rule) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_demandable_client_rule(void) @@ -855,7 +855,7 @@ int vc_mgr_unset_demandable_client_rule(void) } // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_is_command_format_supported(int format, bool* support) @@ -1139,7 +1139,7 @@ int vc_mgr_unset_command_list(void) SLOG(LOG_ERROR, TAG_VCM, "@@@"); // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_command_list_from_file(const char* file_path, int type) @@ -1381,7 +1381,7 @@ int vc_mgr_get_audio_type(char** audio_id) } // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) @@ -1474,7 +1474,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) if (0 != vc_info_parser_get_client_info(&client_info_list)) { SLOG(LOG_INFO, TAG_VCM, "[DEBUG] No client"); - return 0; + return VC_ERROR_NONE; } if (VC_NO_FOREGROUND_PID != fg_pid) { @@ -1533,7 +1533,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } } else { SLOG(LOG_INFO, TAG_VCM, "[Manager] No foreground app"); @@ -1568,7 +1568,7 @@ int vc_mgr_get_current_commands(vc_cmd_list_h* vc_cmd_list) SLOG(LOG_ERROR, TAG_VCM, "@@@"); // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) @@ -1614,7 +1614,7 @@ int vc_mgr_set_recognition_mode(vc_recognition_mode_e mode) } vc_mgr_client_set_recognition_mode(g_vc_m, mode); - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) @@ -1649,7 +1649,7 @@ int vc_mgr_get_recognition_mode(vc_recognition_mode_e* mode) } SLOG(LOG_INFO, TAG_VCM, "@@@ [Manager] Get recognition mode = %d", *mode); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_private_data(const char* key, const char* data) @@ -1704,7 +1704,7 @@ int vc_mgr_set_private_data(const char* key, const char* data) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_private_data(const char* key, char** data) @@ -1769,7 +1769,7 @@ int vc_mgr_get_private_data(const char* key, char** data) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_domain(const char* domain) @@ -1824,7 +1824,7 @@ int vc_mgr_set_domain(const char* domain) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) @@ -1883,7 +1883,7 @@ int vc_mgr_do_action(vc_send_event_type_e type, char* send_event) } SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* event, const char* request) @@ -1943,7 +1943,7 @@ int vc_mgr_send_specific_engine_request(const char* engine_app_id, const char* e } SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_start(bool exclusive_command_option) @@ -2189,7 +2189,7 @@ int __vc_mgr_cb_set_volume(float volume) g_cnt = 1; g_m_set_volume_timer = ecore_timer_add(0.05, __vc_mgr_set_volume_timer_cb, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_mgr_set_volume(float volume) @@ -2197,7 +2197,7 @@ int __vc_mgr_set_volume(float volume) // called by app directly g_volume_db = volume; - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_recording_volume(float* volume) @@ -2230,7 +2230,7 @@ int vc_mgr_get_recording_volume(float* volume) *volume = g_volume_db; - return 0; + return VC_ERROR_NONE; } int __vc_mgr_cb_set_foreground(int pid, bool value) @@ -2265,7 +2265,7 @@ int __vc_mgr_cb_set_foreground(int pid, bool value) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) @@ -2324,7 +2324,7 @@ int vc_mgr_set_selected_results(vc_cmd_list_h vc_cmd_list) SLOG(LOG_DEBUG, TAG_VCM, "@@@"); - return 0; + return VC_ERROR_NONE; } static Eina_Bool __vc_mgr_set_select_result(void *data) @@ -2577,7 +2577,7 @@ int vc_mgr_set_all_result_cb(vc_mgr_all_result_cb callback, void* user_data) SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set all result callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_all_result_cb(void) @@ -2605,7 +2605,7 @@ int vc_mgr_unset_all_result_cb(void) vc_mgr_client_set_all_result_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) @@ -2636,7 +2636,7 @@ int vc_mgr_set_result_cb(vc_result_cb callback, void* user_data) vc_mgr_client_set_result_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_result_cb(void) @@ -2664,7 +2664,7 @@ int vc_mgr_unset_result_cb(void) vc_mgr_client_set_result_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) @@ -2695,7 +2695,7 @@ int vc_mgr_set_pre_result_cb(vc_mgr_pre_result_cb callback, void* user_data) vc_mgr_client_set_pre_result_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_pre_result_cb(void) @@ -2723,7 +2723,7 @@ int vc_mgr_unset_pre_result_cb(void) vc_mgr_client_set_pre_result_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_get_error_message(char** err_msg) @@ -2795,13 +2795,13 @@ int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg) vc_state_e state; if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) { SLOG(LOG_ERROR, TAG_VCM, "[WARNING] Invalid client"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } /* check state */ if (state != VC_STATE_INITIALIZED && state != VC_STATE_READY) { SLOG(LOG_ERROR, TAG_VCM, "[WARNING] not connected client yet"); - return -1; + return VC_ERROR_INVALID_STATE; } vc_mgr_client_set_internal_state(g_vc_m, VC_INTERNAL_STATE_NONE); @@ -2813,7 +2813,7 @@ int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg) vc_mgr_client_get_service_state(g_vc_m, &service_state); if (VC_SERVICE_STATE_UPDATING == service_state) { SLOG(LOG_INFO, TAG_VCM, "[INFO] VC daemon is terminated by update manager"); - return 0; + return VC_ERROR_NONE; } vc_mgr_client_set_client_state(g_vc_m, VC_STATE_INITIALIZED); @@ -2830,7 +2830,7 @@ int __vc_mgr_cb_error(int reason, int daemon_pid, char* msg) vc_mgr_client_set_error_message(g_vc_m, msg); __vc_mgr_notify_error(g_vc_m); - return 0; + return VC_ERROR_NONE; } static Eina_Bool __vc_mgr_notify_state_changed(void *data) @@ -2886,7 +2886,7 @@ int vc_mgr_set_state_changed_cb(vc_state_changed_cb callback, void* user_data) vc_mgr_client_set_state_changed_cb(g_vc_m, callback, user_data); SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set state changed callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_state_changed_cb(void) @@ -2914,7 +2914,7 @@ int vc_mgr_unset_state_changed_cb(void) vc_mgr_client_set_state_changed_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_mgr_cb_service_state(int state) @@ -2942,7 +2942,7 @@ int __vc_mgr_cb_service_state(int state) if (current_state == before_state) { SLOG(LOG_WARN, TAG_VCM, "Service State NOT changed : Before(%d) Current(%d)", before_state, current_state); - return 0; + return VC_ERROR_NONE; } /* Save service state */ @@ -2961,7 +2961,7 @@ int __vc_mgr_cb_service_state(int state) SLOG(LOG_WARN, TAG_VCM, "[WARNING] Service state changed callback is null"); } - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data) @@ -2993,7 +2993,7 @@ int vc_mgr_set_service_state_changed_cb(vc_service_state_changed_cb callback, vo vc_mgr_client_set_service_state_changed_cb(g_vc_m, callback, user_data); SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set service state changed callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_service_state_changed_cb(void) @@ -3020,7 +3020,7 @@ int vc_mgr_unset_service_state_changed_cb(void) } vc_mgr_client_set_service_state_changed_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void* user_data) @@ -3052,7 +3052,7 @@ int vc_mgr_set_speech_detected_cb(vc_mgr_begin_speech_detected_cb callback, void vc_mgr_client_set_speech_detected_cb(g_vc_m, callback, user_data); SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set speech detected callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_speech_detected_cb(void) @@ -3079,7 +3079,7 @@ int vc_mgr_unset_speech_detected_cb(void) } vc_mgr_client_set_speech_detected_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data) @@ -3111,7 +3111,7 @@ int vc_mgr_set_current_language_changed_cb(vc_current_language_changed_cb callba vc_mgr_client_set_current_lang_changed_cb(g_vc_m, callback, user_data); SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set current language changed callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_current_language_changed_cb(void) @@ -3139,7 +3139,7 @@ int vc_mgr_unset_current_language_changed_cb(void) vc_mgr_client_set_current_lang_changed_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) @@ -3170,7 +3170,7 @@ int vc_mgr_set_error_cb(vc_error_cb callback, void* user_data) vc_mgr_client_set_error_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_error_cb(void) @@ -3198,7 +3198,7 @@ int vc_mgr_unset_error_cb(void) vc_mgr_client_set_error_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_mgr_cb_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous) @@ -3217,7 +3217,7 @@ int __vc_mgr_cb_dialog(int pid, const char* disp_text, const char* utt_text, boo SLOG(LOG_WARN, TAG_VCM, "[WARNING] Error callback is null"); } - return 0; + return VC_ERROR_NONE; } int __vc_mgr_cb_private_data_set(const char* key, const char* data) @@ -3367,7 +3367,7 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d vc_mgr_client_set_dialog_request_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_dialog_request_cb(void) @@ -3395,7 +3395,7 @@ int vc_mgr_unset_dialog_request_cb(void) vc_mgr_client_set_dialog_request_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* user_data) @@ -3426,7 +3426,7 @@ int vc_mgr_set_private_data_set_cb(vc_mgr_private_data_set_cb callback, void* us vc_mgr_client_set_private_data_set_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_private_data_set_cb(void) @@ -3454,7 +3454,7 @@ int vc_mgr_unset_private_data_set_cb(void) vc_mgr_client_set_private_data_set_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callback, void* user_data) @@ -3485,7 +3485,7 @@ int vc_mgr_set_private_data_requested_cb(vc_mgr_private_data_requested_cb callba vc_mgr_client_set_private_data_requested_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_private_data_requested_cb(void) @@ -3513,7 +3513,7 @@ int vc_mgr_unset_private_data_requested_cb(void) vc_mgr_client_set_private_data_requested_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } static bool __vc_mgr_check_demandable_client(int pid) @@ -3583,7 +3583,7 @@ int __vc_mgr_request_auth_enable(int pid) vc_mgr_client_set_valid_authorized_client(g_vc_m, pid); } - return 0; + return VC_ERROR_NONE; } int __vc_mgr_request_auth_disable(int pid) @@ -3609,7 +3609,7 @@ int __vc_mgr_request_auth_disable(int pid) } } - return 0; + return VC_ERROR_NONE; } static Eina_Bool __request_auth_start(void* data) @@ -3644,7 +3644,7 @@ int __vc_mgr_request_auth_start(int pid) /* add timer for start recording */ ecore_timer_add(0, __request_auth_start, NULL); - return 0; + return VC_ERROR_NONE; } static Eina_Bool __request_auth_stop(void* data) @@ -3670,7 +3670,7 @@ int __vc_mgr_request_auth_stop(int pid) /* add timer for start recording */ ecore_timer_add(0, __request_auth_stop, NULL); - return 0; + return VC_ERROR_NONE; } static Eina_Bool __request_auth_cancel(void* data) @@ -3696,7 +3696,7 @@ int __vc_mgr_request_auth_cancel(int pid) /* add timer for start recording */ ecore_timer_add(0, __request_auth_cancel, NULL); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callback, void* user_data) @@ -3726,7 +3726,7 @@ int vc_mgr_set_specific_engine_result_cb(vc_mgr_specific_engine_result_cb callba vc_mgr_client_set_specific_engine_result_cb(g_vc_m, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_specific_engine_result_cb(void) { @@ -3748,7 +3748,7 @@ int vc_mgr_unset_specific_engine_result_cb(void) vc_mgr_client_set_specific_engine_result_cb(g_vc_m, NULL, NULL); - return 0; + return VC_ERROR_NONE; } void __vc_mgr_cb_specific_engine_result(const char* engine_app_id, const char* event, const char* result) @@ -3802,7 +3802,7 @@ int vc_mgr_set_feedback_audio_format_cb(vc_mgr_feedback_audio_format_cb callback SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set feedback audio format callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_feedback_audio_format_cb() @@ -3833,7 +3833,7 @@ int vc_mgr_unset_feedback_audio_format_cb() SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Unset feedback audio format callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void* user_data) @@ -3873,7 +3873,7 @@ int vc_mgr_set_feedback_streaming_cb(vc_mgr_feedback_streaming_cb callback, void SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set feedback streaming callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_feedback_streaming_cb() @@ -3910,7 +3910,7 @@ int vc_mgr_unset_feedback_streaming_cb() SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Unset feedback streaming callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* user_data) @@ -3951,7 +3951,7 @@ int vc_mgr_set_vc_tts_streaming_cb(vc_mgr_vc_tts_streaming_cb callback, void* us SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Set feedback streaming callback"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_unset_vc_tts_streaming_cb() @@ -3989,7 +3989,7 @@ int vc_mgr_unset_vc_tts_streaming_cb() SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Unset feedback streaming callback"); - return 0; + return VC_ERROR_NONE; } static void __tts_feedback_thread(void* data, Ecore_Thread* thread) @@ -4143,7 +4143,7 @@ int vc_mgr_start_feedback(void) SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to player play, ret(%d)", ret); } #endif - return 0; + return VC_ERROR_NONE; } int vc_mgr_stop_feedback(void) @@ -4183,7 +4183,7 @@ int vc_mgr_stop_feedback(void) if (0 != ret || NULL == feedback_data) { /* empty queue */ SLOG(LOG_INFO, TAG_VCM, "[INFO] No feedback data to stop any more"); - return 0; + return VC_ERROR_NONE; } ret = vc_mgr_data_clear_feedback_data(&feedback_data); if (0 != ret) { @@ -4489,7 +4489,7 @@ int __vc_change_system_volume(vc_system_volume_event_e volume_event) } SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Change system volume"); - return 0; + return VC_ERROR_NONE; } int __vc_recover_system_volume() @@ -4521,7 +4521,7 @@ int __vc_recover_system_volume() } SLOG(LOG_INFO, TAG_VCM, "[SUCCESS] Recover system volume"); - return 0; + return VC_ERROR_NONE; } int vc_mgr_change_system_volume(vc_system_volume_event_e event) diff --git a/client/vc_mgr_client.c b/client/vc_mgr_client.c index f463c48..9da3025 100644 --- a/client/vc_mgr_client.c +++ b/client/vc_mgr_client.c @@ -241,14 +241,14 @@ int vc_mgr_client_create(vc_h* vc) *vc = temp; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_destroy(vc_h vc) { if (vc == NULL) { SLOG(LOG_ERROR, TAG_VCM, "Input parameter is NULL"); - return 0; + return VC_ERROR_NONE; } vc_mgr_client_s *data = NULL; @@ -285,14 +285,14 @@ int vc_mgr_client_destroy(vc_h vc) data = NULL; vc = NULL; - return 0; + return VC_ERROR_NONE; } } } SLOG(LOG_ERROR, TAG_VCM, "[ERROR] client Not found"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } bool vc_mgr_client_is_valid(vc_h vc) @@ -342,12 +342,13 @@ int vc_mgr_client_get_handle(unsigned int uid, vc_h* vc) if (NULL != data) { if (uid == data->vc->handle) { *vc = data->vc; - return 0; + return VC_ERROR_NONE; } } } - return -1; + SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to find the corresponding handle."); + return VC_ERROR_INVALID_PARAMETER; } int vc_mgr_client_get_pid(vc_h vc, int* pid) @@ -357,11 +358,11 @@ int vc_mgr_client_get_pid(vc_h vc, int* pid) /* check handle */ if (NULL == client) { SLOG(LOG_DEBUG, TAG_VCM, "[DEBUG] vc is not valid"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } *pid = client->pid; - return 0; + return VC_ERROR_NONE; } /* set/get callback function */ @@ -376,7 +377,7 @@ int vc_mgr_client_set_all_result_cb(vc_h vc, vc_mgr_all_result_cb callback, void client->all_result_cb = callback; client->all_result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_all_result_cb(vc_h vc, vc_mgr_all_result_cb* callback, void** user_data) @@ -390,7 +391,7 @@ int vc_mgr_client_get_all_result_cb(vc_h vc, vc_mgr_all_result_cb* callback, voi *callback = client->all_result_cb; *user_data = client->all_result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data) @@ -404,7 +405,7 @@ int vc_mgr_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_data) client->result_cb = callback; client->result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data) @@ -418,7 +419,7 @@ int vc_mgr_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_dat *callback = client->result_cb; *user_data = client->result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_pre_result_cb(vc_h vc, vc_mgr_pre_result_cb callback, void* user_data) @@ -432,7 +433,7 @@ int vc_mgr_client_set_pre_result_cb(vc_h vc, vc_mgr_pre_result_cb callback, void client->pre_result_cb = callback; client->pre_result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_pre_result_cb(vc_h vc, vc_mgr_pre_result_cb* callback, void** user_data) @@ -446,7 +447,7 @@ int vc_mgr_client_get_pre_result_cb(vc_h vc, vc_mgr_pre_result_cb* callback, voi *callback = client->pre_result_cb; *user_data = client->pre_result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data) @@ -460,7 +461,7 @@ int vc_mgr_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed client->service_state_changed_cb = callback; client->service_state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* callback, void** user_data) @@ -474,7 +475,7 @@ int vc_mgr_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed *callback = client->service_state_changed_cb; *user_data = client->service_state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* user_data) @@ -488,7 +489,7 @@ int vc_mgr_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, vo client->state_changed_cb = callback; client->state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void** user_data) @@ -502,7 +503,7 @@ int vc_mgr_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, v *callback = client->state_changed_cb; *user_data = client->state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_speech_detected_cb(vc_h vc, vc_mgr_begin_speech_detected_cb callback, void* user_data) @@ -516,7 +517,7 @@ int vc_mgr_client_set_speech_detected_cb(vc_h vc, vc_mgr_begin_speech_detected_c client->speech_detected_cb = callback; client->speech_detected_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_speech_detected_cb(vc_h vc, vc_mgr_begin_speech_detected_cb* callback, void** user_data) @@ -530,7 +531,7 @@ int vc_mgr_client_get_speech_detected_cb(vc_h vc, vc_mgr_begin_speech_detected_c *callback = client->speech_detected_cb; *user_data = client->speech_detected_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb callback, void* user_data) @@ -544,7 +545,7 @@ int vc_mgr_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_chang client->current_lang_changed_cb = callback; client->current_lang_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb* callback, void** user_data) @@ -558,7 +559,7 @@ int vc_mgr_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_chang *callback = client->current_lang_changed_cb; *user_data = client->current_lang_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) @@ -572,7 +573,7 @@ int vc_mgr_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) client->error_cb = callback; client->error_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) @@ -586,7 +587,7 @@ int vc_mgr_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) *callback = client->error_cb; *user_data = client->error_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_dialog_request_cb(vc_h vc, vc_mgr_dialog_request_cb callback, void* user_data) @@ -600,7 +601,7 @@ int vc_mgr_client_set_dialog_request_cb(vc_h vc, vc_mgr_dialog_request_cb callba client->diaglog_requst_cb = callback; client->dialog_request_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_dialog_request_cb(vc_h vc, vc_mgr_dialog_request_cb* callback, void** user_data) @@ -614,7 +615,7 @@ int vc_mgr_client_get_dialog_request_cb(vc_h vc, vc_mgr_dialog_request_cb* callb *callback = client->diaglog_requst_cb; *user_data = client->dialog_request_user_data; - return 0; + return VC_ERROR_NONE; } @@ -629,7 +630,7 @@ int vc_mgr_client_set_private_data_set_cb(vc_h vc, vc_mgr_private_data_set_cb ca client->private_data_set_cb = callback; client->private_data_set_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_private_data_set_cb(vc_h vc, vc_mgr_private_data_set_cb* callback, void** user_data) @@ -643,7 +644,7 @@ int vc_mgr_client_get_private_data_set_cb(vc_h vc, vc_mgr_private_data_set_cb* c *callback = client->private_data_set_cb; *user_data = client->private_data_set_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_private_data_requested_cb(vc_h vc, vc_mgr_private_data_requested_cb callback, void* user_data) @@ -657,7 +658,7 @@ int vc_mgr_client_set_private_data_requested_cb(vc_h vc, vc_mgr_private_data_req client->private_data_requested_cb = callback; client->private_data_requested_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_private_data_requested_cb(vc_h vc, vc_mgr_private_data_requested_cb* callback, void** user_data) @@ -671,7 +672,7 @@ int vc_mgr_client_get_private_data_requested_cb(vc_h vc, vc_mgr_private_data_req *callback = client->private_data_requested_cb; *user_data = client->private_data_requested_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_format_cb callback, void* user_data) @@ -685,7 +686,7 @@ int vc_mgr_client_set_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_fo client->feedback_audio_format_cb = callback; client->feedback_audio_format_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_format_cb* callback, void** user_data) @@ -699,7 +700,7 @@ int vc_mgr_client_get_feedback_audio_format_cb(vc_h vc, vc_mgr_feedback_audio_fo *callback = client->feedback_audio_format_cb; *user_data = client->feedback_audio_format_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_cb callback, void* user_data) @@ -713,7 +714,7 @@ int vc_mgr_client_set_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_c client->feedback_streaming_cb = callback; client->feedback_streaming_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_cb* callback, void** user_data) @@ -727,7 +728,7 @@ int vc_mgr_client_get_feedback_streaming_cb(vc_h vc, vc_mgr_feedback_streaming_c *callback = client->feedback_streaming_cb; *user_data = client->feedback_streaming_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_vc_tts_streaming_cb(vc_h vc, vc_mgr_vc_tts_streaming_cb callback, void* user_data) @@ -741,7 +742,7 @@ int vc_mgr_client_set_vc_tts_streaming_cb(vc_h vc, vc_mgr_vc_tts_streaming_cb ca client->vc_tts_streaming_cb = callback; client->vc_tts_streaming_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_vc_tts_streaming_cb(vc_h vc, vc_mgr_vc_tts_streaming_cb* callback, void** user_data) @@ -755,7 +756,7 @@ int vc_mgr_client_get_vc_tts_streaming_cb(vc_h vc, vc_mgr_vc_tts_streaming_cb* c *callback = client->vc_tts_streaming_cb; *user_data = client->vc_tts_streaming_user_data; - return 0; + return VC_ERROR_NONE; } /* set/get option */ @@ -769,7 +770,7 @@ int vc_mgr_client_set_service_state(vc_h vc, vc_service_state_e state) client->service_state = state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_service_state(vc_h vc, vc_service_state_e* state) @@ -782,7 +783,7 @@ int vc_mgr_client_get_service_state(vc_h vc, vc_service_state_e* state) *state = client->service_state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_internal_state(vc_h vc, vc_internal_state_e state) @@ -795,7 +796,7 @@ int vc_mgr_client_set_internal_state(vc_h vc, vc_internal_state_e state) client->internal_state = state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_internal_state(vc_h vc, vc_internal_state_e* state) @@ -808,7 +809,7 @@ int vc_mgr_client_get_internal_state(vc_h vc, vc_internal_state_e* state) *state = client->internal_state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_client_state(vc_h vc, vc_state_e state) @@ -822,7 +823,7 @@ int vc_mgr_client_set_client_state(vc_h vc, vc_state_e state) client->before_state = client->current_state; client->current_state = state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_client_state(vc_h vc, vc_state_e* state) @@ -835,7 +836,7 @@ int vc_mgr_client_get_client_state(vc_h vc, vc_state_e* state) *state = client->current_state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) @@ -851,12 +852,12 @@ int vc_mgr_client_get_client_state_by_uid(unsigned int uid, vc_state_e* state) if (NULL != data) { if (uid == data->vc->handle) { *state = data->current_state; - return 0; + return VC_ERROR_NONE; } } } - return -1; + return VC_ERROR_INVALID_PARAMETER; } int vc_mgr_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) @@ -870,7 +871,7 @@ int vc_mgr_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* befor *before_state = client->before_state; *state = client->current_state; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_error(vc_h vc, int reason) @@ -883,7 +884,7 @@ int vc_mgr_client_set_error(vc_h vc, int reason) client->reason = reason; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_error(vc_h vc, int* reason) @@ -896,7 +897,7 @@ int vc_mgr_client_get_error(vc_h vc, int* reason) *reason = client->reason; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_error_message(vc_h vc, const char* err_msg) @@ -919,7 +920,7 @@ int vc_mgr_client_set_error_message(vc_h vc, const char* err_msg) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_error_message(vc_h vc, char** err_msg) @@ -937,7 +938,7 @@ int vc_mgr_client_get_error_message(vc_h vc, char** err_msg) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_enable_command_type(vc_h vc, vc_cmd_type_e cmd_type) @@ -952,7 +953,7 @@ int vc_mgr_client_enable_command_type(vc_h vc, vc_cmd_type_e cmd_type) client->disabled_cmd_type &= ~(1 << cmd_type); - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_disable_command_type(vc_h vc, vc_cmd_type_e cmd_type) @@ -967,7 +968,7 @@ int vc_mgr_client_disable_command_type(vc_h vc, vc_cmd_type_e cmd_type) client->disabled_cmd_type |= (1 << cmd_type); - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_disabled_command_type(vc_h vc, int* disabled_cmd_type) @@ -982,7 +983,7 @@ int vc_mgr_client_get_disabled_command_type(vc_h vc, int* disabled_cmd_type) *disabled_cmd_type = client->disabled_cmd_type; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_exclusive_command(vc_h vc, bool value) @@ -995,7 +996,7 @@ int vc_mgr_client_set_exclusive_command(vc_h vc, bool value) client->exclusive_cmd_option = value; - return 0; + return VC_ERROR_NONE; } bool vc_mgr_client_get_exclusive_command(vc_h vc) @@ -1027,7 +1028,7 @@ int vc_mgr_client_set_all_result(vc_h vc, int event, const char* result_text) client->all_result_text = strdup(result_text); } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_all_result(vc_h vc, int* event, char** result_text) @@ -1045,7 +1046,7 @@ int vc_mgr_client_get_all_result(vc_h vc, int* event, char** result_text) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_unset_all_result(vc_h vc) @@ -1063,7 +1064,7 @@ int vc_mgr_client_unset_all_result(vc_h vc) client->all_result_text = NULL; } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_audio_type(vc_h vc, const char* audio_id) @@ -1082,13 +1083,13 @@ int vc_mgr_client_set_audio_type(vc_h vc, const char* audio_id) client->audio_id = strdup(audio_id); } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_audio_type(vc_h vc, char** audio_id) { if (NULL == audio_id) { - return -1; + return VC_ERROR_INVALID_PARAMETER; } vc_mgr_client_s* client = __mgr_client_get(vc); @@ -1102,7 +1103,7 @@ int vc_mgr_client_get_audio_type(vc_h vc, char** audio_id) else *audio_id = NULL; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_recognition_mode(vc_h vc, vc_recognition_mode_e mode) @@ -1115,13 +1116,13 @@ int vc_mgr_client_set_recognition_mode(vc_h vc, vc_recognition_mode_e mode) client->recognition_mode = mode; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_recognition_mode(vc_h vc, vc_recognition_mode_e* mode) { if (NULL == mode) { - return -1; + return VC_ERROR_INVALID_PARAMETER; } vc_mgr_client_s* client = __mgr_client_get(vc); @@ -1131,7 +1132,7 @@ int vc_mgr_client_get_recognition_mode(vc_h vc, vc_recognition_mode_e* mode) return VC_ERROR_INVALID_PARAMETER; *mode = client->recognition_mode; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_foreground(vc_h vc, int pid, bool value) @@ -1150,7 +1151,7 @@ int vc_mgr_client_set_foreground(vc_h vc, int pid, bool value) } } - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_foreground(vc_h vc, int* pid) @@ -1162,7 +1163,7 @@ int vc_mgr_client_get_foreground(vc_h vc, int* pid) return VC_ERROR_INVALID_PARAMETER; *pid = client->foreground_pid; - return 0; + return VC_ERROR_NONE; } /* utils */ @@ -1180,7 +1181,7 @@ int vc_mgr_client_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; client->cb_ref_count++; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_not_use_callback(vc_h vc) @@ -1192,7 +1193,7 @@ int vc_mgr_client_not_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; client->cb_ref_count--; - return 0; + return VC_ERROR_NONE; } /* Authority */ @@ -1218,7 +1219,7 @@ int vc_mgr_client_add_authorized_client(vc_h vc, int pid) SLOG(LOG_DEBUG, TAG_VCM, "Add authorized client - %d", pid); - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_remove_authorized_client(vc_h vc, int pid) @@ -1245,7 +1246,7 @@ int vc_mgr_client_remove_authorized_client(vc_h vc, int pid) data = NULL; SLOG(LOG_DEBUG, TAG_VCM, "Remove authorized client - %d", pid); - return 0; + return VC_ERROR_NONE; } } } @@ -1294,7 +1295,7 @@ int vc_mgr_client_set_valid_authorized_client(vc_h vc, int pid) client->valid_authorized_pid = pid; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_valid_authorized_client(vc_h vc, int* pid) @@ -1307,7 +1308,7 @@ int vc_mgr_client_get_valid_authorized_client(vc_h vc, int* pid) *pid = client->valid_authorized_pid; - return 0; + return VC_ERROR_NONE; } bool vc_mgr_client_is_valid_authorized_client(vc_h vc, int pid) @@ -1334,7 +1335,7 @@ int vc_mgr_client_set_start_by_client(vc_h vc, bool option) client->start_by_client = option; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_start_by_client(vc_h vc, bool* option) @@ -1347,7 +1348,7 @@ int vc_mgr_client_get_start_by_client(vc_h vc, bool* option) *option = client->start_by_client; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_result_cb callback, void* user_data) @@ -1361,7 +1362,7 @@ int vc_mgr_client_set_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_ client->specific_engine_result_cb = callback; client->specific_engine_result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_result_cb* callback, void** user_data) @@ -1375,7 +1376,7 @@ int vc_mgr_client_get_specific_engine_result_cb(vc_h vc, vc_mgr_specific_engine_ *callback = client->specific_engine_result_cb; *user_data = client->specific_engine_result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_set_audio_streaming_mode(vc_h vc, vc_audio_streaming_mode_e streaming_mode) @@ -1388,7 +1389,7 @@ int vc_mgr_client_set_audio_streaming_mode(vc_h vc, vc_audio_streaming_mode_e st client->streaming_mode = streaming_mode; - return 0; + return VC_ERROR_NONE; } int vc_mgr_client_get_audio_streaming_mode(vc_h vc, vc_audio_streaming_mode_e* streaming_mode) @@ -1401,5 +1402,5 @@ int vc_mgr_client_get_audio_streaming_mode(vc_h vc, vc_audio_streaming_mode_e* s *streaming_mode = client->streaming_mode; - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_mgr_data.cpp b/client/vc_mgr_data.cpp index 8301fcd..27c96a2 100644 --- a/client/vc_mgr_data.cpp +++ b/client/vc_mgr_data.cpp @@ -66,7 +66,7 @@ int vc_mgr_data_get_feedback_data(vc_feedback_data_s** data) *data = NULL; pthread_mutex_unlock(&g_feedback_data_mutex); - return -1; + return VC_ERROR_EMPTY; } std::list::iterator iter; diff --git a/client/vc_mgr_player.c b/client/vc_mgr_player.c index 06915f9..5bfd5be 100644 --- a/client/vc_mgr_player.c +++ b/client/vc_mgr_player.c @@ -78,7 +78,7 @@ static int __create_audio_out(int rate, vc_audio_channel_e channel, vc_audio_typ if (AUDIO_IO_ERROR_NONE != ret) { g_audio_state = AUDIO_STATE_NONE; g_audio_h = NULL; - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio"); + SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio. ret(%d)", ret); return -1; } else { SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Create audio"); @@ -103,7 +103,7 @@ static int __destroy_audio_out() int ret = -1; ret = audio_out_destroy(g_audio_h); if (AUDIO_IO_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to destroy audio"); + SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to destroy audio. ret(%d)", ret); return -1; } else { SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Destroy audio"); @@ -131,12 +131,12 @@ int vc_mgr_player_init(int rate, vc_audio_channel_e channel, vc_audio_type_e aud ret = __create_audio_out(rate, channel, audio_type); if (0 != ret) { - return -1; + return VC_ERROR_OPERATION_FAILED; } g_player_init = true; - return 0; + return VC_ERROR_NONE; } int vc_mgr_player_release() @@ -167,12 +167,12 @@ int vc_mgr_player_release() ret = __destroy_audio_out(); if (0 != ret) { - return -1; + return VC_ERROR_OPERATION_FAILED; } g_player_init = false; - return 0; + return VC_ERROR_NONE; } static void __play_feedback_thread(void* data, Ecore_Thread* thread) @@ -377,7 +377,7 @@ int vc_mgr_player_play() ecore_thread_run(__play_feedback_thread, __end_play_feedback_thread, NULL, NULL); } - return 0; + return VC_ERROR_NONE; } int vc_mgr_player_stop() @@ -409,5 +409,5 @@ int vc_mgr_player_stop() thread_count = ecore_thread_active_get(); } - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_setting.c b/client/vc_setting.c index 1e99383..5f26cbe 100644 --- a/client/vc_setting.c +++ b/client/vc_setting.c @@ -396,7 +396,7 @@ int vc_setting_get_auto_language(bool* value) SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_set_enabled(bool value) @@ -477,7 +477,7 @@ int vc_setting_set_enabled_changed_cb(vc_setting_enabled_changed_cb callback, vo SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_unset_enabled_changed_cb() @@ -495,7 +495,7 @@ int vc_setting_unset_enabled_changed_cb() SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_set_current_language_changed_cb(vc_setting_current_language_changed_cb callback, void* user_data) @@ -519,7 +519,7 @@ int vc_setting_set_current_language_changed_cb(vc_setting_current_language_chang SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_unset_current_language_changed_cb() @@ -537,7 +537,7 @@ int vc_setting_unset_current_language_changed_cb() SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_set_engine_changed_cb(vc_setting_engine_changed_cb callback, void *user_data) @@ -553,7 +553,7 @@ int vc_setting_set_engine_changed_cb(vc_setting_engine_changed_cb callback, void g_engine_changed_user_data = user_data; SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_setting_unset_engine_changed_cb() @@ -570,5 +570,5 @@ int vc_setting_unset_engine_changed_cb() g_engine_changed_user_data = NULL; SLOG(LOG_DEBUG, TAG_VCS, "@@@"); - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 6a6caef..dbfed0d 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -200,8 +200,8 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) } /* VCD_METHOD_SEND_MANAGER_PID */ else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR))) { /* signal!!! */ - char* reason; - char* daemon_pid; + char* reason = NULL; + char* daemon_pid = NULL; char* err_msg = NULL; bundle_get_str(msg, VC_BUNDLE_REASON, &reason); @@ -226,8 +226,8 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) } /* VCD_METHOD_ERROR_TO_APP */ else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) { /* signal!!! */ - char* pid; - char* utt_id; + char* pid = NULL; + char* utt_id = NULL; char* utt_status = NULL; bundle_get_str(msg, VC_BUNDLE_PID, &pid); @@ -262,6 +262,11 @@ void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_vc_pro static int __create_notify_callback_handle(vc_tidl_info_s* info) { + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid parameter"); + return VC_ERROR_INVALID_PARAMETER; + } + if (NULL != info->notify_cb_h) { rpc_port_proxy_vc_proxy_vc_notify_cb_dispose(info->rpc_h, info->notify_cb_h); info->notify_cb_h = NULL; @@ -281,7 +286,12 @@ static int __create_notify_callback_handle(vc_tidl_info_s* info) static int __create_feedback_callback_handle(vc_tidl_info_s* info) { - if (NULL != info) { + if (NULL == info) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid parameter"); + return VC_ERROR_INVALID_PARAMETER; + } + + if (NULL != info->feedback_cb_h) { rpc_port_proxy_vc_proxy_vc_feedback_cb_dispose(info->rpc_h, info->feedback_cb_h); info->feedback_cb_h = NULL; } diff --git a/client/vc_widget.c b/client/vc_widget.c index f0e3b01..5161784 100644 --- a/client/vc_widget.c +++ b/client/vc_widget.c @@ -86,7 +86,7 @@ static int __vc_widget_get_feature_enabled() } } - return 0; + return VC_ERROR_NONE; } const char* vc_tag() @@ -270,7 +270,7 @@ static int _vc_widget_wait_to_end_thread(void) count++; } SLOG(LOG_WARN, TAG_VCW, "[Widget] prepare_thread is terminated"); - return 0; + return VC_ERROR_NONE; } int vc_widget_deinitialize(vc_h vc_w) @@ -1101,7 +1101,7 @@ int vc_widget_stop() } } while (0 != ret); - return 0; + return VC_ERROR_NONE; } #endif @@ -1147,7 +1147,7 @@ int vc_widget_cancel(vc_h vc_w) SLOG(LOG_DEBUG, TAG_VCW, "@@@"); // TODO: check return value correct or not - return 0; + return VC_ERROR_NONE; } static void __vc_widget_notify_error(void *data) @@ -1194,13 +1194,13 @@ int __vc_widget_cb_error(int reason, int daemon_pid, char* msg) if (0 != vc_widget_client_get_state(vc_w, &state)) { SLOG(LOG_ERROR, TAG_VCW, "[WARNING] Invalid client"); - return -1; + return VC_ERROR_INVALID_PARAMETER; } /* check state */ if (state != VC_STATE_READY) { SLOG(LOG_ERROR, TAG_VCW, "[WARNING] not connected client yet"); - return -1; + return VC_ERROR_INVALID_STATE; } if (VC_ERROR_SERVICE_RESET == reason) { @@ -1221,7 +1221,7 @@ int __vc_widget_cb_error(int reason, int daemon_pid, char* msg) } } - return 0; + return VC_ERROR_NONE; } static Eina_Bool __vc_widget_start_recording(void *data) @@ -1504,7 +1504,7 @@ int vc_widget_set_result_cb(vc_h vc_w, vc_result_cb callback, void* user_data) vc_widget_client_set_result_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_result_cb(vc_h vc_w) @@ -1534,7 +1534,7 @@ int vc_widget_unset_result_cb(vc_h vc_w) vc_widget_client_set_result_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, void* user_data) @@ -1567,7 +1567,7 @@ int vc_widget_set_show_tooltip_cb(vc_h vc_w, vc_widget_show_tooltip_cb callback, vc_widget_client_set_show_tooltip_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_show_tooltip_cb(vc_h vc_w) @@ -1597,7 +1597,7 @@ int vc_widget_unset_show_tooltip_cb(vc_h vc_w) vc_widget_client_set_show_tooltip_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current_command_list_cb callback, void* user_data) @@ -1627,7 +1627,7 @@ int vc_widget_set_send_current_command_list_cb(vc_h vc_w, vc_widget_send_current vc_widget_client_set_send_command_list_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) @@ -1657,7 +1657,7 @@ int vc_widget_unset_send_current_command_list_cb(vc_h vc_w) vc_widget_client_set_send_command_list_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int __vc_widget_cb_service_state(int state) @@ -1703,7 +1703,7 @@ int __vc_widget_cb_service_state(int state) } } - return 0; + return VC_ERROR_NONE; } int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_cb callback, void* user_data) @@ -1733,7 +1733,7 @@ int vc_widget_set_service_state_changed_cb(vc_h vc_w, vc_service_state_changed_c vc_widget_client_set_service_state_changed_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_service_state_changed_cb(vc_h vc_w) @@ -1763,7 +1763,7 @@ int vc_widget_unset_service_state_changed_cb(vc_h vc_w) vc_widget_client_set_service_state_changed_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void* user_data) @@ -1796,7 +1796,7 @@ int vc_widget_set_state_changed_cb(vc_h vc_w, vc_state_changed_cb callback, void vc_widget_client_set_state_changed_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_state_changed_cb(vc_h vc_w) @@ -1826,7 +1826,7 @@ int vc_widget_unset_state_changed_cb(vc_h vc_w) vc_widget_client_set_state_changed_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user_data) @@ -1859,7 +1859,7 @@ int vc_widget_set_asr_result_cb(vc_h vc_w, vc_asr_result_cb callback, void* user vc_widget_client_set_asr_result_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_asr_result_cb(vc_h vc_w) @@ -1889,7 +1889,7 @@ int vc_widget_unset_asr_result_cb(vc_h vc_w) vc_widget_client_set_asr_result_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_changed_cb callback, void* user_data) @@ -1922,7 +1922,7 @@ int vc_widget_set_current_language_changed_cb(vc_h vc_w, vc_current_language_cha vc_widget_client_set_current_lang_changed_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_current_language_changed_cb(vc_h vc_w) @@ -1952,7 +1952,7 @@ int vc_widget_unset_current_language_changed_cb(vc_h vc_w) vc_widget_client_set_current_lang_changed_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) @@ -1985,7 +1985,7 @@ int vc_widget_set_error_cb(vc_h vc_w, vc_error_cb callback, void* user_data) vc_widget_client_set_error_cb(vc_w, callback, user_data); - return 0; + return VC_ERROR_NONE; } int vc_widget_unset_error_cb(vc_h vc_w) @@ -2015,6 +2015,6 @@ int vc_widget_unset_error_cb(vc_h vc_w) vc_widget_client_set_error_cb(vc_w, NULL, NULL); - return 0; + return VC_ERROR_NONE; } diff --git a/client/vc_widget_client.c b/client/vc_widget_client.c index c18036e..891ba75 100644 --- a/client/vc_widget_client.c +++ b/client/vc_widget_client.c @@ -125,14 +125,14 @@ int vc_widget_client_create(vc_h* vc) *vc = temp; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_destroy(vc_h vc) { if (vc == NULL) { SLOG(LOG_ERROR, TAG_VCW, "Input parameter is NULL"); - return 0; + return VC_ERROR_NONE; } vc_widget_s *data = NULL; @@ -158,7 +158,7 @@ int vc_widget_client_destroy(vc_h vc) vc = NULL; pthread_mutex_unlock(&g_widget_list_mutex); - return 0; + return VC_ERROR_NONE; } } } @@ -166,7 +166,7 @@ int vc_widget_client_destroy(vc_h vc) SLOG(LOG_ERROR, TAG_VCW, "[ERROR] widget Not found"); pthread_mutex_unlock(&g_widget_list_mutex); - return -1; + return VC_ERROR_INVALID_PARAMETER; } GSList* vc_widget_client_get_client_list() @@ -230,13 +230,13 @@ int vc_widget_client_get_handle(unsigned int uid, vc_h* vc) if (uid == data->vc->handle) { *vc = data->vc; pthread_mutex_unlock(&g_widget_list_mutex); - return 0; + return VC_ERROR_NONE; } } } pthread_mutex_unlock(&g_widget_list_mutex); - return -1; + return VC_ERROR_INVALID_PARAMETER; } /* set/get callback function */ @@ -251,7 +251,7 @@ int vc_widget_client_set_result_cb(vc_h vc, vc_result_cb callback, void* user_da widget->result_cb = callback; widget->result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_data) @@ -265,7 +265,7 @@ int vc_widget_client_get_result_cb(vc_h vc, vc_result_cb* callback, void** user_ *callback = widget->result_cb; *user_data = widget->result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_asr_result_enabled(vc_h vc, bool enabled) @@ -278,7 +278,7 @@ int vc_widget_client_set_asr_result_enabled(vc_h vc, bool enabled) widget->asr_result_enabled = enabled; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_asr_result_enabled(vc_h vc, bool* enabled) @@ -291,7 +291,7 @@ int vc_widget_client_get_asr_result_enabled(vc_h vc, bool* enabled) *enabled = widget->asr_result_enabled; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* user_data) @@ -305,7 +305,7 @@ int vc_widget_client_set_asr_result_cb(vc_h vc, vc_asr_result_cb callback, void* widget->asr_result_cb = callback; widget->asr_result_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_asr_result_cb(vc_h vc, vc_asr_result_cb* callback, void** user_data) @@ -319,7 +319,7 @@ int vc_widget_client_get_asr_result_cb(vc_h vc, vc_asr_result_cb* callback, void *callback = widget->asr_result_cb; *user_data = widget->asr_result_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb callback, void* user_data) @@ -333,7 +333,7 @@ int vc_widget_client_set_service_state_changed_cb(vc_h vc, vc_service_state_chan widget->service_state_changed_cb = callback; widget->service_state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_service_state_changed_cb(vc_h vc, vc_service_state_changed_cb* callback, void** user_data) @@ -347,7 +347,7 @@ int vc_widget_client_get_service_state_changed_cb(vc_h vc, vc_service_state_chan *callback = widget->service_state_changed_cb; *user_data = widget->service_state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, void* user_data) @@ -361,7 +361,7 @@ int vc_widget_client_set_state_changed_cb(vc_h vc, vc_state_changed_cb callback, widget->state_changed_cb = callback; widget->state_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback, void** user_data) @@ -375,7 +375,7 @@ int vc_widget_client_get_state_changed_cb(vc_h vc, vc_state_changed_cb* callback *callback = widget->state_changed_cb; *user_data = widget->state_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb callback, void* user_data) @@ -389,7 +389,7 @@ int vc_widget_client_set_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb call widget->show_tooltip_cb = callback; widget->show_tooltip_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb* callback, void** user_data) @@ -403,7 +403,7 @@ int vc_widget_client_get_show_tooltip_cb(vc_h vc, vc_widget_show_tooltip_cb* cal *callback = widget->show_tooltip_cb; *user_data = widget->show_tooltip_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb callback, void* user_data) @@ -417,7 +417,7 @@ int vc_widget_client_set_current_lang_changed_cb(vc_h vc, vc_current_language_ch widget->current_lang_changed_cb = callback; widget->current_lang_changed_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_changed_cb* callback, void** user_data) @@ -431,7 +431,7 @@ int vc_widget_client_get_current_lang_changed_cb(vc_h vc, vc_current_language_ch *callback = widget->current_lang_changed_cb; *user_data = widget->current_lang_changed_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data) @@ -445,7 +445,7 @@ int vc_widget_client_set_error_cb(vc_h vc, vc_error_cb callback, void* user_data widget->error_cb = callback; widget->error_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_data) @@ -459,7 +459,7 @@ int vc_widget_client_get_error_cb(vc_h vc, vc_error_cb* callback, void** user_da *callback = widget->error_cb; *user_data = widget->error_user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_send_command_list_cb(vc_h vc, vc_widget_send_current_command_list_cb callback, void* user_data) @@ -473,7 +473,7 @@ int vc_widget_client_set_send_command_list_cb(vc_h vc, vc_widget_send_current_co widget->send_command_list_cb = callback; widget->send_command_list_user_data = user_data; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_send_command_list_cb(vc_h vc, vc_widget_send_current_command_list_cb* callback, void** user_data) @@ -487,7 +487,7 @@ int vc_widget_client_get_send_command_list_cb(vc_h vc, vc_widget_send_current_co *callback = widget->send_command_list_cb; *user_data = widget->send_command_list_user_data; - return 0; + return VC_ERROR_NONE; } @@ -502,7 +502,7 @@ int vc_widget_client_set_service_state(vc_h vc, vc_service_state_e state) widget->service_state = state; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_service_state(vc_h vc, vc_service_state_e* state) @@ -515,7 +515,7 @@ int vc_widget_client_get_service_state(vc_h vc, vc_service_state_e* state) *state = widget->service_state; - return 0; + return VC_ERROR_NONE; } @@ -530,7 +530,7 @@ int vc_widget_client_set_state(vc_h vc, vc_state_e state) widget->before_state = widget->current_state; widget->current_state = state; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_state(vc_h vc, vc_state_e* state) @@ -543,7 +543,7 @@ int vc_widget_client_get_state(vc_h vc, vc_state_e* state) *state = widget->current_state; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_state_by_uid(unsigned int uid, vc_state_e* state) @@ -561,13 +561,13 @@ int vc_widget_client_get_state_by_uid(unsigned int uid, vc_state_e* state) if (uid == data->vc->handle) { *state = data->current_state; pthread_mutex_unlock(&g_widget_list_mutex); - return 0; + return VC_ERROR_NONE; } } } pthread_mutex_unlock(&g_widget_list_mutex); - return -1; + return VC_ERROR_INVALID_PARAMETER; } int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* before_state) @@ -581,7 +581,7 @@ int vc_widget_client_get_before_state(vc_h vc, vc_state_e* state, vc_state_e* be *before_state = widget->before_state; *state = widget->current_state; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_xid(vc_h vc, int xid) @@ -594,7 +594,7 @@ int vc_widget_client_set_xid(vc_h vc, int xid) widget->xid = xid; - return 0; + return VC_ERROR_NONE; } int vc_widget_cilent_get_xid(vc_h vc, int* xid) @@ -607,7 +607,7 @@ int vc_widget_cilent_get_xid(vc_h vc, int* xid) *xid = widget->xid; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_error(vc_h vc, int reason) @@ -620,7 +620,7 @@ int vc_widget_client_set_error(vc_h vc, int reason) widget->reason = reason; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_error(vc_h vc, int* reason) @@ -633,7 +633,7 @@ int vc_widget_client_get_error(vc_h vc, int* reason) *reason = widget->reason; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_set_show_tooltip(vc_h vc, bool show) @@ -646,7 +646,7 @@ int vc_widget_client_set_show_tooltip(vc_h vc, bool show) widget->show_tooltip = show; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_show_tooltip(vc_h vc, bool* show) @@ -659,7 +659,7 @@ int vc_widget_client_get_show_tooltip(vc_h vc, bool* show) *show = widget->show_tooltip; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_get_count() @@ -679,7 +679,7 @@ int vc_widget_client_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; widget->cb_ref_count++; - return 0; + return VC_ERROR_NONE; } int vc_widget_client_not_use_callback(vc_h vc) @@ -691,6 +691,6 @@ int vc_widget_client_not_use_callback(vc_h vc) return VC_ERROR_INVALID_PARAMETER; widget->cb_ref_count--; - return 0; + return VC_ERROR_NONE; } diff --git a/common/vc_cmd_db.c b/common/vc_cmd_db.c index 54c1df0..8db3d37 100644 --- a/common/vc_cmd_db.c +++ b/common/vc_cmd_db.c @@ -79,7 +79,7 @@ int __vc_db_reset_handle(void) vc_db_finalize(); vc_db_initialize(); } - return 0; + return VC_DB_ERROR_NONE; } static int __vc_db_transaction(sqlite3* db_handle, const char* transaction) @@ -1731,7 +1731,7 @@ int vc_db_initialize_for_daemon(void) g_ref_cnt++; SLOG(LOG_INFO, vc_db_tag(), "[SUCCESS] DB initialization after restore for daemon"); - return 0; + return VC_DB_ERROR_NONE; } is_connect = __vc_db_connect_db_for_daemon(&g_backup_path, &g_db_backup_handle); @@ -1889,12 +1889,12 @@ int vc_db_finalize(void) } if (!g_db_handle) - return 0; + return VC_DB_ERROR_NONE; db_util_close(g_db_handle); g_db_handle = NULL; if (!g_db_backup_handle) - return 0; + return VC_DB_ERROR_NONE; db_util_close(g_db_backup_handle); g_db_backup_handle = NULL; diff --git a/common/vc_command.c b/common/vc_command.c index 9d7f9d6..3f1b32b 100644 --- a/common/vc_command.c +++ b/common/vc_command.c @@ -87,7 +87,7 @@ static int __vc_cmd_get_feature_enabled() } } - return 0; + return VC_ERROR_NONE; } static int __check_privilege_initialize() @@ -798,7 +798,7 @@ int vc_cmd_set_id(vc_cmd_h vc_command, int id) cmd->id = id; SLOG(LOG_DEBUG, TAG_VCCMD, "[Set id][%p] id(%d)", vc_command, cmd->id); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_id(vc_cmd_h vc_command, int* id) @@ -821,7 +821,7 @@ int vc_cmd_get_id(vc_cmd_h vc_command, int* id) *id = cmd->id; SLOG(LOG_DEBUG, TAG_VCCMD, "[Get id][%p] id(%d)", vc_command, *id); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_appid(vc_cmd_h vc_command, const char* appid) @@ -849,7 +849,7 @@ int vc_cmd_set_appid(vc_cmd_h vc_command, const char* appid) cmd->appid = strdup(appid); SLOG(LOG_DEBUG, TAG_VCCMD, "[Set appid][%p] appid(%s)", vc_command, cmd->appid); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_appid(vc_cmd_h vc_command, char** appid) @@ -873,7 +873,7 @@ int vc_cmd_get_appid(vc_cmd_h vc_command, char** appid) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get appid][%p] appid(%s)", vc_command, *appid); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_command(vc_cmd_h vc_command, const char* command) @@ -900,7 +900,7 @@ int vc_cmd_set_command(vc_cmd_h vc_command, const char* command) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set command][%p] Command(%s)", vc_command, cmd->command); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_command(vc_cmd_h vc_command, char** command) @@ -927,7 +927,7 @@ int vc_cmd_get_command(vc_cmd_h vc_command, char** command) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get command][%p] Command(%s)", vc_command, *command); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command) @@ -953,7 +953,7 @@ int vc_cmd_set_unfixed_command(vc_cmd_h vc_command, const char* command) cmd->parameter = strdup(command); SLOG(LOG_DEBUG, TAG_VCCMD, "[Set unfixed command][%p] unfixed command(%s)", vc_command, cmd->parameter); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command) @@ -977,7 +977,7 @@ int vc_cmd_get_unfixed_command(vc_cmd_h vc_command, char** command) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get unfixed command][%p] unfixed command(%s)", vc_command, *command); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_fixed_command(vc_cmd_h vc_command, const char* fixed) @@ -1005,7 +1005,7 @@ int vc_cmd_set_fixed_command(vc_cmd_h vc_command, const char* fixed) cmd->fixed = strdup(fixed); SLOG(LOG_DEBUG, TAG_VCCMD, "[Set parameter][%p] fixed command(%s)", vc_command, cmd->fixed); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_fixed_command(vc_cmd_h vc_command, char** fixed) @@ -1029,7 +1029,7 @@ int vc_cmd_get_fixed_command(vc_cmd_h vc_command, char** fixed) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get fixed command][%p] fixed command(%s)", vc_command, *fixed); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_invocation_name(vc_cmd_h vc_command, const char* invocation_name) @@ -1057,7 +1057,7 @@ int vc_cmd_set_invocation_name(vc_cmd_h vc_command, const char* invocation_name) cmd->invocation_name = strdup(invocation_name); SLOG(LOG_DEBUG, TAG_VCCMD, "[Set invocation name][%p] invocation_name(%s)", vc_command, cmd->invocation_name); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_invocation_name(vc_cmd_h vc_command, char** invocation_name) @@ -1080,7 +1080,7 @@ int vc_cmd_get_invocation_name(vc_cmd_h vc_command, char** invocation_name) *invocation_name = NULL; SLOG(LOG_DEBUG, TAG_VCCMD, "[Get invocation name][%p] invocation_name(%s)", vc_command, *invocation_name); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_type(vc_cmd_h vc_command, int type) @@ -1104,7 +1104,7 @@ int vc_cmd_set_type(vc_cmd_h vc_command, int type) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set type][%p] type(%d)", vc_command, cmd->type); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_type(vc_cmd_h vc_command, int* type) @@ -1128,7 +1128,7 @@ int vc_cmd_get_type(vc_cmd_h vc_command, int* type) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get type][%p] type(%d)", vc_command, *type); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_format(vc_cmd_h vc_command, int format) @@ -1149,7 +1149,7 @@ int vc_cmd_set_format(vc_cmd_h vc_command, int format) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set format][%p] format(%d)", vc_command, format); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_format(vc_cmd_h vc_command, int* format) @@ -1170,7 +1170,7 @@ int vc_cmd_get_format(vc_cmd_h vc_command, int* format) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get format][%p] format(%d)", vc_command, *format); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_pid(vc_cmd_h vc_command, int pid) @@ -1194,7 +1194,7 @@ int vc_cmd_set_pid(vc_cmd_h vc_command, int pid) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set pid][%p] pid(%d)", vc_command, cmd->pid); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid) @@ -1218,7 +1218,7 @@ int vc_cmd_get_pid(vc_cmd_h vc_command, int* pid) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get pid][%p] pid(%d)", vc_command, *pid); - return 0; + return VC_ERROR_NONE; } int vc_cmd_set_domain(vc_cmd_h vc_command, int domain) @@ -1242,7 +1242,7 @@ int vc_cmd_set_domain(vc_cmd_h vc_command, int domain) SLOG(LOG_DEBUG, TAG_VCCMD, "[Set domain] domain : %d", domain); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_domain(vc_cmd_h vc_command, int* domain) @@ -1266,7 +1266,7 @@ int vc_cmd_get_domain(vc_cmd_h vc_command, int* domain) SLOG(LOG_DEBUG, TAG_VCCMD, "[Get domain] domain : %d", *domain); - return 0; + return VC_ERROR_NONE; } /** @@ -1301,7 +1301,7 @@ int vc_cmd_set_result_key(vc_cmd_h vc_command, int key, int modifier) SLOG(LOG_DEBUG, TAG_VCCMD, "@@@"); - return 0; + return VC_ERROR_NONE; } /** @@ -1334,7 +1334,7 @@ int vc_cmd_get_result_key(vc_cmd_h vc_command, int* key, int* modifier) SLOG(LOG_DEBUG, TAG_VCCMD, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_cmd_print_list(vc_cmd_list_h vc_cmd_list) @@ -1367,7 +1367,7 @@ int vc_cmd_print_list(vc_cmd_list_h vc_cmd_list) SLOG(LOG_DEBUG, TAG_VCCMD, "@@@"); - return 0; + return VC_ERROR_NONE; } int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json) @@ -1394,7 +1394,7 @@ int vc_cmd_get_nlu_json(vc_cmd_h vc_cmd, char** json) return VC_ERROR_OPERATION_FAILED; } - return 0; + return VC_ERROR_NONE; } static void __vc_cmd_regex_deinit(int num_regex) diff --git a/common/vc_config_mgr.c b/common/vc_config_mgr.c index 5436e46..aa391d3 100644 --- a/common/vc_config_mgr.c +++ b/common/vc_config_mgr.c @@ -124,7 +124,7 @@ int __vc_config_mgr_check_engine_is_valid(const char* engine_id) if (!strcmp(engine_id, engine_info->uuid)) { SLOG(LOG_DEBUG, vc_config_tag(), "Default engine is valid : %s", engine_id); - return 0; + return VC_ERROR_NONE; } iter = g_slist_next(iter); @@ -164,7 +164,7 @@ int __vc_config_mgr_check_engine_is_valid(const char* engine_id) return -1; } - return 0; + return VC_ERROR_NONE; } bool __vc_config_mgr_check_lang_is_valid(const char* engine_id, const char* language) @@ -425,7 +425,7 @@ int __vc_config_mgr_get_engine_info() return -1; } - return 0; + return VC_ERROR_NONE; } static Eina_Bool __vc_config_mgr_engine_config_inotify_event_callback(void* data, Ecore_Fd_Handler *fd_handler) @@ -540,7 +540,7 @@ static int __vc_config_mgr_register_engine_config_updated_event(const char* path g_ino_list = g_list_append(g_ino_list, ino); pthread_mutex_unlock(&vc_config_engine_mutex); - return 0; + return VC_ERROR_NONE; } static int __vc_config_mgr_unregister_engine_config_updated_event() @@ -569,7 +569,7 @@ static int __vc_config_mgr_unregister_engine_config_updated_event() } } pthread_mutex_unlock(&vc_config_engine_mutex); - return 0; + return VC_ERROR_NONE; } Eina_Bool vc_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler) @@ -725,7 +725,7 @@ int __vc_config_set_auto_language() if (0 == strncmp(g_config_info->language, candidate_lang, 5)) { SLOG(LOG_DEBUG, vc_config_tag(), "[Config] VC language(%s) is same with display language", g_config_info->language); - return 0; + return VC_ERROR_NONE; } if (true == __vc_config_mgr_check_lang_is_valid(g_config_info->engine_id, candidate_lang)) { @@ -813,7 +813,7 @@ int __vc_config_set_auto_language() if (NULL != before_lang) free(before_lang); } - return 0; + return VC_ERROR_NONE; } void __vc_config_language_changed_cb(keynode_t *key, void *data) @@ -850,7 +850,7 @@ int vc_config_mgr_initialize(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); - return 0; + return VC_ERROR_NONE; } iter = g_slist_next(iter); @@ -878,7 +878,7 @@ int vc_config_mgr_initialize(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); - return 0; + return VC_ERROR_NONE; } /* Get file name from default engine directory */ @@ -1041,7 +1041,7 @@ int vc_config_mgr_initialize(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_finalize(unsigned int uid) @@ -1054,7 +1054,7 @@ int vc_config_mgr_finalize(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); - return 0; + return VC_ERROR_NONE; } __vc_config_release_engine(); @@ -1070,7 +1070,7 @@ int vc_config_mgr_finalize(unsigned int uid) SLOG(LOG_DEBUG, vc_config_tag(), "[WARNING] Leave critical section"); SLOG(LOG_DEBUG, vc_config_tag(), "[Success] Finalize config"); - return 0; + return VC_ERROR_NONE; } @@ -1108,7 +1108,7 @@ int __vc_config_mgr_register_lang_event() } g_lang_ref_count++; - return 0; + return VC_ERROR_NONE; } int __vc_config_mgr_unregister_config_event() @@ -1130,7 +1130,7 @@ int __vc_config_mgr_unregister_config_event() vconf_ignore_key_changed(VCONFKEY_LANGSET, __vc_config_language_changed_cb); } - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_engine_cb(unsigned int uid, vc_config_engine_changed_cb engine_cb) @@ -1162,7 +1162,7 @@ int vc_config_mgr_set_engine_cb(unsigned int uid, vc_config_engine_changed_cb en pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_unset_engine_cb(unsigned int uid) @@ -1190,7 +1190,7 @@ int vc_config_mgr_unset_engine_cb(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); - return 0; + return VC_ERROR_NONE; } @@ -1223,7 +1223,7 @@ int vc_config_mgr_set_lang_cb(unsigned int uid, vc_config_lang_changed_cb lang_c pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_unset_lang_cb(unsigned int uid) @@ -1251,7 +1251,7 @@ int vc_config_mgr_unset_lang_cb(unsigned int uid) pthread_mutex_unlock(&vc_config_mgr_mutex); ecore_thread_main_loop_end(); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_enabled_cb(unsigned int uid, vc_config_enabled_cb enabled_cb) @@ -1303,7 +1303,7 @@ int vc_config_mgr_unset_enabled_cb(unsigned int uid) if (uid == temp_client->uid) { temp_client->enabled_cb = NULL; pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } } iter = g_slist_next(iter); @@ -1331,7 +1331,7 @@ int vc_config_mgr_get_auto_language(bool* value) *value = g_config_info->auto_lang; pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_auto_language(bool value) @@ -1360,7 +1360,7 @@ int vc_config_mgr_set_auto_language(bool value) } pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_get_engine_list(vc_config_supported_engine_cb callback, void* user_data) @@ -1516,7 +1516,7 @@ int vc_config_mgr_set_engine(const char* engine) /* Check current engine id with new engine id */ if (0 == strncmp(g_config_info->engine_id, engine, strlen(g_config_info->engine_id))) { pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } SLOG(LOG_DEBUG, vc_config_tag(), "New engine id : %s", engine); @@ -1683,7 +1683,7 @@ int vc_config_mgr_get_language_list(vc_supported_language_cb callback, void* use } pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_get_default_language(char** language) @@ -1709,7 +1709,7 @@ int vc_config_mgr_get_default_language(char** language) } pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } static int __vc_config_mgr_set_default_language(const char* language) @@ -1736,7 +1736,7 @@ static int __vc_config_mgr_set_default_language(const char* language) return -1; } - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_default_language(const char* language) @@ -1765,7 +1765,7 @@ int vc_config_mgr_get_enabled(bool* value) *value = g_config_info->enabled; pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_set_enabled(bool value) @@ -1786,7 +1786,7 @@ int vc_config_mgr_set_enabled(bool value) g_config_info->enabled = value; pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } int vc_config_mgr_get_nonfixed_support(bool* value) @@ -1836,7 +1836,7 @@ int vc_config_mgr_get_nonfixed_support(bool* value) } pthread_mutex_unlock(&vc_config_mgr_mutex); - return 0; + return VC_ERROR_NONE; } bool vc_config_check_default_engine_is_valid(const char* engine) @@ -1980,7 +1980,7 @@ int __vc_config_mgr_print_engine_info() SLOG(LOG_DEBUG, vc_config_tag(), "@ engine list @"); SLOG(LOG_DEBUG, vc_config_tag(), " No Engine in engine directory"); SLOG(LOG_DEBUG, vc_config_tag(), "@@@@"); - return 0; + return VC_ERROR_NONE; } /* Get a first item */ @@ -2023,7 +2023,7 @@ int __vc_config_mgr_print_engine_info() } SLOG(LOG_DEBUG, vc_config_tag(), "@@@@"); - return 0; + return VC_ERROR_NONE; } int __vc_config_mgr_print_client_info() @@ -2035,7 +2035,7 @@ int __vc_config_mgr_print_client_info() SLOG(LOG_DEBUG, vc_config_tag(), "@ Client list @"); SLOG(LOG_DEBUG, vc_config_tag(), " No Client"); SLOG(LOG_DEBUG, vc_config_tag(), "@@@@"); - return 0; + return VC_ERROR_NONE; } /* Get a first item */ @@ -2054,5 +2054,5 @@ int __vc_config_mgr_print_client_info() } SLOG(LOG_DEBUG, vc_config_tag(), "@@@@"); - return 0; + return VC_ERROR_NONE; } diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 267c7c6..404d52f 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -69,14 +69,14 @@ int vcd_client_manager_set(int pid) int ret = app_manager_get_app_id(pid, &appid); if (0 != ret || NULL == appid) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] fail to get app id, ret(%d), pid(%d)", ret, pid); - return -1; + return VCD_ERROR_OPERATION_FAILED; } if (-1 != g_manager.pid && NULL != g_manager.appid && 0 == strncmp(g_manager.appid, appid, strlen(g_manager.appid))) { SLOG(LOG_WARN, TAG_VCD, "Same manager has already registered. It doesn't need to set manager again."); if (appid) free(appid); - return 0; + return VCD_ERROR_NONE; } g_manager.pid = pid; @@ -88,7 +88,7 @@ int vcd_client_manager_set(int pid) free(appid); appid = NULL; - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_unset() @@ -97,7 +97,7 @@ int vcd_client_manager_unset() g_manager.manager_cmd = false; g_manager.exclusive_cmd_option = false; - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_unset_appid() @@ -106,7 +106,7 @@ int vcd_client_manager_unset_appid() free(g_manager.appid); g_manager.appid = NULL; } - return 0; + return VCD_ERROR_NONE; } bool vcd_client_manager_is_valid(int pid) @@ -121,20 +121,20 @@ int vcd_client_manager_set_command(int pid) { if (pid != g_manager.pid) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } g_manager.manager_cmd = true; - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_unset_command(int pid) { if (pid != g_manager.pid) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } g_manager.manager_cmd = false; - return 0; + return VCD_ERROR_NONE; } bool vcd_client_manager_is_system_command_valid(int pid) @@ -173,7 +173,7 @@ int vcd_client_manager_set_demandable_client(int pid, GSList* client_list) g_demandable_client = client_list; - return 0; + return VCD_ERROR_NONE; } bool vcd_client_manager_check_demandable_client(int pid) @@ -230,7 +230,7 @@ bool vcd_client_manager_get_exclusive() int vcd_client_manager_set_exclusive(bool value) { g_manager.exclusive_cmd_option = value; - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_get_pid() @@ -243,7 +243,7 @@ int vcd_client_manager_get_appid(char** appid) if (NULL != g_manager.appid) *appid = strdup(g_manager.appid); - return 0; + return VCD_ERROR_NONE; } int vcd_client_manager_set_result_text(const char* result) @@ -257,7 +257,7 @@ int vcd_client_manager_set_result_text(const char* result) g_result_text = strdup(result); } - return 0; + return VCD_ERROR_NONE; } char* vcd_client_manager_get_result_text() @@ -392,7 +392,7 @@ int vcd_client_manager_delete_tidl_info() free(g_mgr_tidl_info); g_mgr_tidl_info = NULL; - return 0; + return VCD_ERROR_NONE; } manager_tidl_info_s* vcd_client_manager_get_tidl_info() @@ -454,7 +454,7 @@ int __vcd_client_release_commands() __vcd_client_release_each_commands(&(g_cur_cmd_list.foreground_cmds)); __vcd_client_release_each_commands(&(g_cur_cmd_list.background_cmds)); - return 0; + return VCD_ERROR_NONE; } int vcd_client_command_collect_command() @@ -488,7 +488,7 @@ int vcd_client_command_collect_command() SLOG(LOG_INFO, TAG_VCD, "[Client Data] No exclusive system commands"); } - return 0; + return VCD_ERROR_NONE; } /* 3. Set system command */ @@ -572,7 +572,7 @@ int vcd_client_command_collect_command() g_cur_cmd_list.background_cmds = bg_cmd_list; } } - return 0; + return VCD_ERROR_NONE; } int vcd_client_get_length() @@ -707,7 +707,7 @@ int vcd_client_foreach_command(client_foreach_command_cb callback, void* user_da } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data] No background commands"); } - return 0; + return VCD_ERROR_NONE; } static vc_cmd_s* __command_copy(vc_cmd_s* src_cmd) @@ -783,7 +783,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -806,7 +806,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */ *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -826,7 +826,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */ *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -846,7 +846,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */ *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -866,7 +866,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) /*SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Find result pid(%d) type(%d)", *pid, *cmd_type); */ *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -885,7 +885,7 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) if (result_id == temp_cmd->id) { *result = __command_copy(temp_cmd); - return 0; + return VCD_ERROR_NONE; } iter = g_slist_next(iter); @@ -895,13 +895,13 @@ int vcd_client_get_cmd_from_result_id(int result_id, vc_cmd_s** result) } SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Not find matched result"); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } int vcd_client_set_slience_detection(bool value) { g_silence_detection = value; - return 0; + return VCD_ERROR_NONE; } bool vcd_client_get_slience_detection() @@ -912,7 +912,7 @@ bool vcd_client_get_slience_detection() int vcd_client_set_recognition_mode(vcd_recognition_mode_e mode) { g_recognition_mode = mode; - return 0; + return VCD_ERROR_NONE; } vcd_recognition_mode_e vcd_client_get_recognition_mode() @@ -933,7 +933,7 @@ int vcd_client_set_server_dialog(int pid, bool is_server_dialog) client_info->server_dialog = is_server_dialog; SLOG(LOG_INFO, TAG_VCD, "[Client Data] Set server dialog, client pid(%d), server_dialog(%d)", pid, client_info->server_dialog); - return 0; + return VCD_ERROR_NONE; } int vcd_client_get_server_dialog(int pid, bool* is_server_dialog) @@ -949,7 +949,7 @@ int vcd_client_get_server_dialog(int pid, bool* is_server_dialog) *is_server_dialog = client_info->server_dialog; SLOG(LOG_INFO, TAG_VCD, "[Client Data] Get server dialog, client pid(%d), server_dialog(%d)", pid, *is_server_dialog); - return 0; + return VCD_ERROR_NONE; } int vcd_client_append_cmd_from_type(int type, vc_cmd_list_h list) @@ -1009,7 +1009,7 @@ int vcd_client_append_cmd_from_type(int type, vc_cmd_list_h list) item = item->next; } - return 0; + return VCD_ERROR_NONE; } int __show_client_list() @@ -1066,7 +1066,7 @@ int __show_client_list() SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return 0; + return VCD_ERROR_NONE; } int __show_command_list(GSList* cmd_group) @@ -1101,7 +1101,7 @@ int __show_command_list(GSList* cmd_group) SLOG(LOG_DEBUG, TAG_VCD, "@@@"); - return 0; + return VCD_ERROR_NONE; } GSList* __client_get_item(const int pid) @@ -1192,7 +1192,7 @@ int vcd_client_add(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client"); } @@ -1200,7 +1200,7 @@ int vcd_client_add(int pid) #ifdef CLIENT_DATA_DEBUG __show_client_list(); #endif - return 0; + return VCD_ERROR_NONE; } int vcd_client_delete(int pid) @@ -1229,7 +1229,7 @@ int vcd_client_delete(int pid) __show_client_list(); #endif - return 0; + return VCD_ERROR_NONE; } GSList* __get_client_tidl_info_item(const int pid) @@ -1318,7 +1318,7 @@ int vcd_client_add_tidl_info(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client tidl info. pid(%d)", pid); } @@ -1441,7 +1441,7 @@ int vcd_client_delete_tidl_info(int pid) /*Delete handle from list*/ g_client_tidl_info_list = g_slist_delete_link(g_client_tidl_info_list, tmp); - return 0; + return VCD_ERROR_NONE; } client_tidl_info_s* vcd_client_get_tidl_info(int pid) @@ -1452,12 +1452,12 @@ client_tidl_info_s* vcd_client_get_tidl_info(int pid) int vcd_client_get_tidl_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) - return -1; + return VCD_ERROR_INVALID_PARAMETER; int count = g_slist_length(g_client_tidl_info_list); if (0 == count) - return -1; + return VCD_ERROR_OUT_OF_MEMORY; int *tmp; tmp = (int*)calloc(count, sizeof(int)); @@ -1486,7 +1486,7 @@ int vcd_client_get_tidl_list(int** pids, int* pid_count) *pids = tmp; *pid_count = count; - return 0; + return VCD_ERROR_NONE; } bool vcd_client_is_available(int pid) @@ -1519,12 +1519,12 @@ int vcd_client_get_ref_count() int vcd_client_get_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) - return -1; + return VCD_ERROR_INVALID_PARAMETER; int count = g_slist_length(g_client_list); if (0 == count) - return -1; + return VCD_ERROR_OUT_OF_MEMORY; int *tmp; tmp = (int*)calloc(count, sizeof(int)); @@ -1553,7 +1553,7 @@ int vcd_client_get_list(int** pids, int* pid_count) *pids = tmp; *pid_count = count; - return 0; + return VCD_ERROR_NONE; } int vcd_client_set_command_type(int pid, int type) @@ -1575,10 +1575,10 @@ int vcd_client_set_command_type(int pid, int type) break; default: SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] not supported command type(%d)", type); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } - return 0; + return VCD_ERROR_NONE; } int vcd_client_unset_command_type(int pid, int type) @@ -1600,10 +1600,10 @@ int vcd_client_unset_command_type(int pid, int type) break; default: SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] not supported command type(%d)", type); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } - return 0; + return VCD_ERROR_NONE; } int vcd_client_set_exclusive_command(int pid) @@ -1618,7 +1618,7 @@ int vcd_client_set_exclusive_command(int pid) client_info->exclusive_cmd = true; - return 0; + return VCD_ERROR_NONE; } int vcd_client_unset_exclusive_command(int pid) @@ -1633,17 +1633,17 @@ int vcd_client_unset_exclusive_command(int pid) client_info->exclusive_cmd = false; - return 0; + return VCD_ERROR_NONE; } int vcd_client_save_client_info() { if (0 != vc_info_parser_set_client_info(g_client_list)) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to save client info"); - return -1; + return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } /* @@ -1709,12 +1709,12 @@ widget_info_s* __widget_get_element(int pid) int vcd_client_widget_get_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) - return -1; + return VCD_ERROR_INVALID_PARAMETER; int count = g_slist_length(g_widget_list); if (0 == count) - return -1; + return VCD_ERROR_OUT_OF_MEMORY; int *tmp; tmp = (int*)calloc(count, sizeof(int)); @@ -1742,7 +1742,7 @@ int vcd_client_widget_get_list(int** pids, int* pid_count) *pids = tmp; *pid_count = count; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_add(int pid) @@ -1774,7 +1774,7 @@ int vcd_client_widget_add(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new widget"); } @@ -1782,7 +1782,7 @@ int vcd_client_widget_add(int pid) #ifdef CLIENT_DATA_DEBUG __show_client_list(); #endif - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_delete(int pid) @@ -1811,7 +1811,7 @@ int vcd_client_widget_delete(int pid) __show_client_list(); #endif - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_get_foreground_pid() @@ -1828,7 +1828,7 @@ int vcd_client_widget_get_foreground_pid() widget = __widget_get_element(fg_pid); if (NULL == widget) { SLOG(LOG_WARN, TAG_VCD, "[Client Data] Not found foreground pid of widget"); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } return widget->pid; @@ -1859,7 +1859,7 @@ int vcd_client_widget_set_command(int pid) info->widget_cmd = true; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_unset_command(int pid) @@ -1873,7 +1873,7 @@ int vcd_client_widget_unset_command(int pid) info->widget_cmd = false; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_set_asr_result_enabled(int pid, bool enable) @@ -1887,7 +1887,7 @@ int vcd_client_widget_set_asr_result_enabled(int pid, bool enable) info->asr_result_enabled = enable; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable) @@ -1901,7 +1901,7 @@ int vcd_client_widget_get_asr_result_enabled(int pid, bool* enable) *enable = info->asr_result_enabled; - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_set_waiting_for_recording(int pid, bool waiting) @@ -1909,25 +1909,25 @@ int vcd_client_widget_set_waiting_for_recording(int pid, bool waiting) if (TRUE == waiting && pid != vcd_client_widget_get_foreground_pid()) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT foreground pid", pid); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } g_is_waiting_recording = waiting; g_waiting_recording_pid = pid; SLOG(LOG_ERROR, TAG_VCD, "[INFO] Success to set waiting for recording, pid(%d), waiting(%d)", pid, waiting); - return 0; + return VCD_ERROR_NONE; } int vcd_client_widget_get_waiting_for_recording(int pid, bool* waiting) { if (pid != g_waiting_recording_pid) { SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT waiting pid", pid); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } *waiting = g_is_waiting_recording; SLOG(LOG_ERROR, TAG_VCD, "[INFO] Success to get waiting for recording, waiting(%d)", *waiting); - return 0; + return VCD_ERROR_NONE; } GSList* __get_widget_tidl_info_item(const int pid) @@ -2018,7 +2018,7 @@ int vcd_client_widget_add_tidl_info(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new widget tidl info. pid(%d)", pid); } @@ -2094,7 +2094,7 @@ int vcd_client_widget_delete_tidl_info(int pid) /*Delete handle from list*/ g_widget_tidl_info_list = g_slist_delete_link(g_widget_tidl_info_list, tmp); - return 0; + return VCD_ERROR_NONE; } widget_tidl_info_s* vcd_client_widget_get_tidl_info(int pid) @@ -2271,7 +2271,7 @@ int vcd_client_setting_add_tidl_info(int pid) free(info); info = NULL; - return -1; + return VCD_ERROR_OUT_OF_MEMORY; } else { SLOG(LOG_INFO, TAG_VCD, "[Setting Data SUCCESS] Add new setting client tidl info. pid(%d)", pid); } @@ -2347,7 +2347,7 @@ int vcd_client_setting_delete_tidl_info(int pid) /*Delete handle from list*/ g_setting_tidl_info_list = g_slist_delete_link(g_setting_tidl_info_list, tmp); - return 0; + return VCD_ERROR_NONE; } setting_tidl_info_s* vcd_client_setting_get_tidl_info(int pid) @@ -2358,12 +2358,12 @@ setting_tidl_info_s* vcd_client_setting_get_tidl_info(int pid) int vcd_client_setting_get_tidl_list(int** pids, int* pid_count) { if (NULL == pids || NULL == pid_count) - return -1; + return VCD_ERROR_INVALID_PARAMETER; int count = g_slist_length(g_setting_tidl_info_list); if (0 == count) - return -1; + return VCD_ERROR_OUT_OF_MEMORY; int *tmp; tmp = (int*)calloc(count, sizeof(int)); @@ -2392,5 +2392,5 @@ int vcd_client_setting_get_tidl_list(int** pids, int* pid_count) *pids = tmp; *pid_count = count; - return 0; + return VCD_ERROR_NONE; } diff --git a/server/vcd_config.c b/server/vcd_config.c index cdf2f3d..2cfa477 100644 --- a/server/vcd_config.c +++ b/server/vcd_config.c @@ -69,7 +69,7 @@ int vcd_config_initialize(vcd_config_lang_changed_cb lang_cb, vcd_config_foregro g_foreground_pid = VC_RUNTIME_INFO_NO_FOREGROUND; - return 0; + return VCD_ERROR_NONE; } int vcd_config_finalize() @@ -77,7 +77,7 @@ int vcd_config_finalize() vc_config_mgr_unset_lang_cb(getpid()); vc_config_mgr_finalize(getpid()); - return 0; + return VCD_ERROR_NONE; } int vcd_config_get_default_language(char** language) @@ -90,7 +90,7 @@ int vcd_config_get_default_language(char** language) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_default_language(const char* language) @@ -103,7 +103,7 @@ int vcd_config_set_default_language(const char* language) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_service_state(vcd_state_e state) @@ -112,7 +112,7 @@ int vcd_config_set_service_state(vcd_state_e state) SLOG(LOG_INFO, TAG_VCD, "[Config] Config is changed : %d", g_state); - return 0; + return VCD_ERROR_NONE; } vcd_state_e vcd_config_get_service_state() @@ -123,7 +123,7 @@ vcd_state_e vcd_config_get_service_state() int vcd_config_get_foreground(int* pid) { *pid = g_foreground_pid; - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_foreground(int pid, bool value) @@ -135,7 +135,7 @@ int vcd_config_set_foreground(int pid, bool value) g_foreground_pid = VC_RUNTIME_INFO_NO_FOREGROUND; } } - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_disabled_command_type(int disabled_cmd_type) @@ -144,35 +144,35 @@ int vcd_config_set_disabled_command_type(int disabled_cmd_type) g_disabled_command_type = disabled_cmd_type; - return 0; + return VCD_ERROR_NONE; } int vcd_config_get_command_type_enabled(int cmd_type) { if (cmd_type <= 0 || cmd_type >= COMMAND_TYPE_MAX) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid command type"); - return 0; + return VCD_ERROR_NONE; } if (~(g_disabled_command_type) & (1 << cmd_type)) return 1; else - return 0; + return VCD_ERROR_NONE; } int vcd_config_get_audio_streaming_mode(vcd_audio_streaming_mode_e* streaming_mode) { *streaming_mode = g_audio_streaming_mode; - return 0; + return VCD_ERROR_NONE; } int vcd_config_set_audio_streaming_mode(vcd_audio_streaming_mode_e streaming_mode) { if (streaming_mode < VCD_AUDIO_STREAMING_MODE_VC_SERVICE || streaming_mode > VCD_AUDIO_STREAMING_MODE_OUTSIDE) { SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid streaming mode(%d)", streaming_mode); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } g_audio_streaming_mode = streaming_mode; - return 0; + return VCD_ERROR_NONE; } diff --git a/server/vcd_engine_agent.c b/server/vcd_engine_agent.c index 2d5bcf2..9c3c9c1 100644 --- a/server/vcd_engine_agent.c +++ b/server/vcd_engine_agent.c @@ -122,7 +122,7 @@ int vcd_engine_agent_init() SLOG(LOG_INFO, TAG_VCD, "[Engine Agent SUCCESS] Engine Agent Initialize"); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_release() @@ -160,7 +160,7 @@ int vcd_engine_agent_release() SLOG(LOG_INFO, TAG_VCD, "[Engine Agent SUCCESS] Engine Agent release"); - return 0; + return VCD_ERROR_NONE; } bool vcd_engine_is_available_engine() @@ -249,7 +249,7 @@ static int __internal_get_engine_info(vce_request_callback_s* callback) SLOG(LOG_INFO, TAG_VCD, "Engine setting : %s", g_dynamic_engine.engine_setting_path); SLOG(LOG_INFO, TAG_VCD, "@@@"); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) @@ -268,7 +268,7 @@ int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) if (true == g_dynamic_engine.is_loaded) { SLOG(LOG_ERROR, TAG_VCD, "[Engine Agent] Engine has already been loaded"); - return 0; + return VCD_ERROR_NONE; } /* Get current engine info */ @@ -329,7 +329,7 @@ int vcd_engine_agent_load_current_engine(vce_request_callback_s* callback) SLOG(LOG_INFO, TAG_VCD, "[Engine Agent] load current engine FINISH"); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_unload_current_engine() @@ -354,7 +354,7 @@ int vcd_engine_agent_unload_current_engine() /* reset current engine data */ g_dynamic_engine.is_loaded = false; - return 0; + return VCD_ERROR_NONE; } @@ -386,7 +386,7 @@ int vcd_engine_set_commands() SLOG(LOG_INFO, TAG_VCD, "[Engine Agent] Dynamic engine is not available"); } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_recognize_start(bool silence) @@ -411,7 +411,7 @@ int vcd_engine_recognize_start(bool silence) } SLOG(LOG_INFO, TAG_VCD, "[Engine Agent SUCCESS] Engine start"); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_recognize_audio(const void* data, unsigned int length, vce_speech_detect_e* speech_detected) @@ -439,7 +439,7 @@ int vcd_engine_recognize_audio(const void* data, unsigned int length, vce_speech } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_recognize_stop() @@ -461,7 +461,7 @@ int vcd_engine_recognize_stop() return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_recognize_cancel() @@ -480,7 +480,7 @@ int vcd_engine_recognize_cancel() } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_audio_type(const char* audio) @@ -499,7 +499,7 @@ int vcd_engine_set_audio_type(const char* audio) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_server_dialog(const char* app_id, const char* credential) @@ -518,7 +518,7 @@ int vcd_engine_set_server_dialog(const char* app_id, const char* credential) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_domain(int pid, const char* domain) @@ -537,7 +537,7 @@ int vcd_engine_set_domain(int pid, const char* domain) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_get_nlu_base_info(int pid, const char* key, char** value) @@ -564,7 +564,7 @@ int vcd_engine_get_nlu_base_info(int pid, const char* key, char** value) return VCD_ERROR_NONE; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_private_data(int pid, const char* key, const char* data) @@ -589,7 +589,7 @@ int vcd_engine_set_private_data(int pid, const char* key, const char* data) return VCD_ERROR_NONE; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_get_private_data(int pid, const char* key, char** data) @@ -616,7 +616,7 @@ int vcd_engine_get_private_data(int pid, const char* key, char** data) return VCD_ERROR_NONE; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_send_specific_engine_request(const char* engine_app_id, const char* event, const char* request) @@ -638,7 +638,7 @@ int vcd_engine_send_specific_engine_request(const char* engine_app_id, const cha return VCD_ERROR_NONE; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_process_text(int pid, const char* text) @@ -657,7 +657,7 @@ int vcd_engine_process_text(int pid, const char* text) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_process_list_event(int pid, const char* event) @@ -676,7 +676,7 @@ int vcd_engine_process_list_event(int pid, const char* event) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_process_haptic_event(int pid, const char* event) @@ -695,7 +695,7 @@ int vcd_engine_process_haptic_event(int pid, const char* event) } } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_request_tts(int pid, int utt_id, const char* text, const char* language) @@ -719,7 +719,7 @@ int vcd_engine_request_tts(int pid, int utt_id, const char* text, const char* la return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_cancel_tts(int pid, int utt_id) @@ -741,7 +741,7 @@ int vcd_engine_cancel_tts(int pid, int utt_id) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_get_tts_audio_format(int* rate, int* channel, int* audio_type) @@ -763,7 +763,7 @@ int vcd_engine_get_tts_audio_format(int* rate, int* channel, int* audio_type) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } @@ -788,7 +788,7 @@ int vcd_engine_get_audio_format(const char* audio_id, vce_audio_type_e* types, i return ret; } - return 0; + return VCD_ERROR_NONE; } static bool __supported_language_cb(const char* language, void* user_data) @@ -826,7 +826,7 @@ int vcd_engine_supported_langs(GList** lang_list) return ret; } - return 0; + return VCD_ERROR_NONE; } @@ -845,7 +845,7 @@ int vcd_engine_get_current_language(char** lang) /* get default language */ *lang = g_strdup(g_default_lang); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_set_current_language(const char* language) @@ -873,7 +873,7 @@ int vcd_engine_set_current_language(const char* language) SLOG(LOG_INFO, TAG_VCD, "[Engine Agent] Dynamic engine is not available (Cannot start)"); } - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data) @@ -887,7 +887,7 @@ int vcd_engine_agent_get_command_count(vce_cmd_h vce_command, int* count) SLOG(LOG_INFO, TAG_VCD, "[Engine Agent] Request command length from engine"); *count = vcd_client_get_length(); - return 0; + return VCD_ERROR_NONE; } int vcd_engine_agent_get_audio_type(char** audio_type) diff --git a/server/vcd_server.c b/server/vcd_server.c index d82b10b..16717a5 100644 --- a/server/vcd_server.c +++ b/server/vcd_server.c @@ -131,7 +131,7 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt if (VCD_STATE_READY == state) { SLOG(LOG_DEBUG, TAG_VCD, "[Server] Ready state, but recording"); } else if (VCD_STATE_PROCESSING == state) { - return 0; + return VCD_ERROR_NONE; } vce_speech_detect_e speech_detected = VCE_SPEECH_DETECT_NONE; @@ -149,7 +149,7 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt } else { vcdc_tidl_send_error_to_manager(vcd_client_manager_get_pid(), ret, "voice_framework.error.engine.set_recording_fail"); } - return 0; + return VCD_ERROR_NONE; } if (VCE_SPEECH_DETECT_BEGIN == speech_detected) { @@ -182,7 +182,7 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt } } - return 0; + return VCD_ERROR_NONE; } void __server_recorder_interrupt_callback() @@ -1363,7 +1363,7 @@ int vcd_initialize(vce_request_callback_s *callback) SLOG(LOG_ERROR, TAG_VCD, "[Server SUCCESS] initialize"); - return 0; + return VCD_ERROR_NONE; } bool vcd_finalize() @@ -1844,7 +1844,7 @@ static int __reset_waiting_for_widget_recording(void) } // Reset flag to wait for recording from widget client vcd_client_widget_set_waiting_for_recording(-1, false); - return 0; + return VCD_ERROR_NONE; } #if 0 @@ -1885,7 +1885,7 @@ static int __set_waiting_for_widget_recording(int pid) // Set flag to wait for recording from widget client vcd_client_widget_set_waiting_for_recording(pid, true); - return 0; + return VCD_ERROR_NONE; } static int __start_internal_recognition() @@ -1954,7 +1954,7 @@ static int __start_internal_recognition() SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence); - return 0; + return VCD_ERROR_NONE; } static Eina_Bool __vcd_request_show_tooltip(void *data) @@ -1996,7 +1996,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); __set_waiting_for_widget_recording(pid); - return 0; + return VCD_ERROR_NONE; } } } else { @@ -2446,7 +2446,7 @@ int vcd_server_set_command(int pid, vc_cmd_type_e cmd_type) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_server_unset_command(int pid, vc_cmd_type_e cmd_type) @@ -2462,7 +2462,7 @@ int vcd_server_unset_command(int pid, vc_cmd_type_e cmd_type) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } int vcd_server_set_foreground(int pid, bool value) @@ -2478,7 +2478,7 @@ int vcd_server_set_foreground(int pid, bool value) return VCD_ERROR_OPERATION_FAILED; } - return 0; + return VCD_ERROR_NONE; } static int __vcd_server_launch_manager_app() @@ -2556,7 +2556,7 @@ int vcd_server_set_server_dialog(int pid, const char* app_id, const char* creden SLOG(LOG_INFO, TAG_VCD, "[Server] Set to false for server dialog, app_id(%s)", app_id); } - return 0; + return VCD_ERROR_NONE; } int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int continuous) @@ -2590,7 +2590,7 @@ int vcd_server_dialog(int pid, const char* disp_text, const char* utt_text, int return ret; } } - return 0; + return VCD_ERROR_NONE; } int vcd_server_is_system_command_valid(int pid, int* is_sys_cmd_valid) @@ -2607,7 +2607,7 @@ int vcd_server_is_system_command_valid(int pid, int* is_sys_cmd_valid) else *is_sys_cmd_valid = false; - return 0; + return VCD_ERROR_NONE; } static void __start_tts_request_thread(void* data, Ecore_Thread* thread) @@ -2715,7 +2715,7 @@ int vcd_server_request_tts(int pid, const char* text, const char* language, int g_tts_thread = ecore_thread_run(__start_tts_request_thread, __end_tts_request_thread, NULL, NULL); } - return 0; + return VCD_ERROR_NONE; } int vcd_server_cancel_tts(int pid, int utt_id) @@ -2808,7 +2808,7 @@ int vcd_server_set_exclusive_command(int pid, bool value) } } - return 0; + return VCD_ERROR_NONE; } int vcd_server_request_start(int pid, bool stop_by_silence) @@ -2843,7 +2843,7 @@ int vcd_server_request_start(int pid, bool stop_by_silence) return VCD_ERROR_INVALID_PARAMETER; } - return 0; + return VCD_ERROR_NONE; } int vcd_server_request_stop(int pid) @@ -2949,7 +2949,7 @@ int vcd_server_widget_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty, vc-service will be terminated"); ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); - return 0; + return VCD_ERROR_NONE; } return VCD_ERROR_INVALID_PARAMETER; } @@ -2962,7 +2962,7 @@ int vcd_server_widget_finalize(int pid) if (0 == vcd_client_get_ref_count()) { SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty, vc-service will be terminated"); ecore_timer_add(0, __finalize_quit_ecore_loop, NULL); - return 0; + return VCD_ERROR_NONE; } bool is_waiting = false; @@ -2988,7 +2988,7 @@ int vcd_server_widget_start_recording(int pid, bool widget_command) bool waiting; if (0 != vcd_client_widget_get_waiting_for_recording(pid, &waiting) || false == waiting) { SLOG(LOG_ERROR, TAG_VCD, "[Server] Server is not waiting for recording, pid(%d), waiting(%d)", pid, waiting); - return 0; + return VCD_ERROR_NONE; } if (true == widget_command) { @@ -3006,7 +3006,7 @@ int vcd_server_widget_start_recording(int pid, bool widget_command) ecore_timer_add(0, __vcd_request_show_tooltip, (void*)false); } - return 0; + return VCD_ERROR_NONE; } int vcd_server_widget_start(int pid, bool stop_by_silence) @@ -3032,7 +3032,7 @@ int vcd_server_widget_start(int pid, bool stop_by_silence) /* Notify show tooltip */ ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true); - return 0; + return VCD_ERROR_NONE; } int vcd_server_widget_stop(int pid) @@ -3255,7 +3255,7 @@ int vcd_send_update_status(vce_update_event_e update_event, const char* msg) SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Update event : Fail - msg(%s)", msg); } - return 0; + return VCD_ERROR_NONE; } int vcd_set_private_data_set_cb(vce_private_data_set_cb callback_func) diff --git a/server/vcd_server_data.cpp b/server/vcd_server_data.cpp index 7a238aa..579928a 100644 --- a/server/vcd_server_data.cpp +++ b/server/vcd_server_data.cpp @@ -121,7 +121,7 @@ int vcd_data_get_tts_text_data(unsigned int tts_uid, vc_tts_text_data_s** data) SLOG(LOG_ERROR, TAG_VCD, "[DATA ERROR] There is no tts_text data"); *data = NULL; pthread_mutex_unlock(&g_tts_text_data_mutex); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } std::list::iterator iter; @@ -159,7 +159,7 @@ int vcd_data_get_first_tts_text_data(vc_tts_text_data_s** data) SLOG(LOG_ERROR, TAG_VCD, "[DATA ERROR] There is no tts_text data"); *data = NULL; pthread_mutex_unlock(&g_tts_text_data_mutex); - return -1; + return VCD_ERROR_INVALID_PARAMETER; } std::list::iterator iter; diff --git a/server/vce.c b/server/vce.c index 9a66d2d..be70147 100644 --- a/server/vce.c +++ b/server/vce.c @@ -58,7 +58,7 @@ static int __vce_get_feature_enabled() } } - return 0; + return VCE_ERROR_NONE; } static int __check_privilege_initialize() @@ -177,7 +177,7 @@ int vce_main(int argc, char** argv, vce_request_callback_s *callback) SLOG(LOG_DEBUG, TAG_VCD, " "); SLOG(LOG_DEBUG, TAG_VCD, " "); - return 0; + return VCE_ERROR_NONE; } int vce_send_result(vce_result_event_e event, int* result_id, int count, const char* all_result, const char* non_fixed_result, const char* nlu_result, const char* msg, int* user_info, void *user_data) -- 2.7.4 From d7084335c138e9219c18523f7f763f4ebb9424c0 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 29 Jun 2022 17:39:17 +0900 Subject: [PATCH 14/16] Unify bundle data in client, mgr, and widget Change-Id: If822325a6edfcc6d6ea6fdf65229455fb8f081f6 Signed-off-by: sooyeon --- client/vc_mgr_tidl.c | 56 +++++----- client/vc_setting_tidl.c | 11 +- client/vc_tidl.c | 4 +- client/vc_widget_tidl.c | 16 +-- common/vc_defs.h | 48 ++++----- server/vcd_tidl.c | 266 ++++++++++++++++++++++++----------------------- 6 files changed, 193 insertions(+), 208 deletions(-) diff --git a/client/vc_mgr_tidl.c b/client/vc_mgr_tidl.c index 7376fd5..eaa5ddf 100644 --- a/client/vc_mgr_tidl.c +++ b/client/vc_mgr_tidl.c @@ -97,10 +97,10 @@ static void __notify_cb(void *user_data, bundle *msg) SLOG(LOG_DEBUG, TAG_VCM, "__notify_cb is invoked"); - bundle_get_str(msg, VC_MANAGER_BUNDLE_METHOD, &method); + bundle_get_str(msg, VC_BUNDLE_METHOD, &method); if (0 == strncmp(VCD_MANAGER_METHOD_SET_VOLUME, method, strlen(VCD_MANAGER_METHOD_SET_VOLUME))) { - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_VOLUME, &val); float volume = 0; if (val) { @@ -119,7 +119,7 @@ static void __notify_cb(void *user_data, bundle *msg) } /* VCD_MANAGER_METHOD_SET_VOLUME */ else if (0 == strncmp(VCD_MANAGER_METHOD_SET_SERVICE_STATE, method, strlen(VCD_MANAGER_METHOD_SET_SERVICE_STATE))) { - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val); int state = 0; if (val) { state = atoi(val); @@ -139,7 +139,7 @@ static void __notify_cb(void *user_data, bundle *msg) else if (0 == strncmp(VCD_MANAGER_METHOD_ALL_RESULT, method, strlen(VCD_MANAGER_METHOD_ALL_RESULT))) { SLOG(LOG_INFO, TAG_VCM, "@@@ Get All Result"); - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_RESULT, &val); if (val) { __vc_mgr_cb_all_result((vc_result_type_e)atoi(val)); @@ -153,8 +153,8 @@ static void __notify_cb(void *user_data, bundle *msg) char* event = NULL; char* pre_result = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_EVENT, &event); - bundle_get_str(msg, VC_MANAGER_BUNDLE_PRE_RESULT, &pre_result); + bundle_get_str(msg, VC_BUNDLE_EVENT, &event); + bundle_get_str(msg, VC_BUNDLE_PRE_RESULT, &pre_result); if (NULL != pre_result) { __vc_mgr_cb_pre_result((vc_pre_result_event_e)atoi(event), pre_result); @@ -169,9 +169,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* event = NULL; char* result = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_ENGINE_APP_ID, &engine_app_id); - bundle_get_str(msg, VC_MANAGER_BUNDLE_EVENT, &event); - bundle_get_str(msg, VC_MANAGER_BUNDLE_RESULT, &result); + bundle_get_str(msg, VC_BUNDLE_ENGINE_APP_ID, &engine_app_id); + bundle_get_str(msg, VC_BUNDLE_EVENT, &event); + bundle_get_str(msg, VC_BUNDLE_RESULT, &result); if (NULL != result) { gsize decodingSize=0; @@ -201,10 +201,10 @@ static void __notify_cb(void *user_data, bundle *msg) char* utt_text = NULL; char* continous = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &pid); - bundle_get_str(msg, VC_MANAGER_BUNDLE_DISP_TEXT, &disp_text); - bundle_get_str(msg, VC_MANAGER_BUNDLE_UTT_TEXT, &utt_text); - bundle_get_str(msg, VC_MANAGER_BUNDLE_CONTINUOUS, &continous); + bundle_get_str(msg, VC_BUNDLE_PID, &pid); + bundle_get_str(msg, VC_BUNDLE_DISP_TEXT, &disp_text); + bundle_get_str(msg, VC_BUNDLE_UTT_TEXT, &utt_text); + bundle_get_str(msg, VC_BUNDLE_CONTINUOUS, &continous); if (!strncmp(disp_text, "#NULL", strlen("#NULL") + 1)) disp_text = NULL; @@ -222,9 +222,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* daemon_pid = NULL; char* err_msg = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_REASON, &reason); - bundle_get_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, &daemon_pid); - bundle_get_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, &err_msg); + 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); char* temp_msg = NULL; if (NULL != err_msg && strncmp(err_msg, "#NULL", strlen("#NULL") + 1)) { @@ -246,9 +246,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* key = NULL; char* private_data = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &pid); - bundle_get_str(msg, VC_MANAGER_BUNDLE_KEY, &key); - bundle_get_str(msg, VC_MANAGER_BUNDLE_PRIVATE_DATA, &private_data); + bundle_get_str(msg, VC_BUNDLE_PID, &pid); + bundle_get_str(msg, VC_BUNDLE_KEY, &key); + bundle_get_str(msg, VC_BUNDLE_PRIVATE_DATA, &private_data); SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr get request set private data : pid(%d) ", atoi(pid)); if (pid > 0) { @@ -266,9 +266,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* audio_type = NULL; char* rate = NULL; - bundle_get_str(msg, VC_MANAGER_BUNDLE_AUDIO_CHANNEL, &channel); - bundle_get_str(msg, VC_MANAGER_BUNDLE_AUDIO_TYPE, &audio_type); - bundle_get_str(msg, VC_MANAGER_BUNDLE_AUDIO_RATE, &rate); + bundle_get_str(msg, VC_BUNDLE_AUDIO_CHANNEL, &channel); + bundle_get_str(msg, VC_BUNDLE_AUDIO_TYPE, &audio_type); + 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)); @@ -284,8 +284,8 @@ static void __notify_cb(void *user_data, bundle *msg) // int pid = 0; // int value = 0; - // bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &temp_pid); - // bundle_get_str(msg, VC_MANAGER_BUNDLE_VALUE, &temp_value); + // bundle_get_str(msg, VC_BUNDLE_PID, &temp_pid); + // bundle_get_str(msg, VC_BUNDLE_VALUE, &temp_value); // pid = atoi(temp_pid); // value = atoi(temp_value); @@ -308,7 +308,7 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ SLOG(LOG_DEBUG, TAG_VCM, "__send_buffer_cb is invoked"); - bundle_get_str(msg, VC_MANAGER_BUNDLE_METHOD, &method); + bundle_get_str(msg, VC_BUNDLE_METHOD, &method); if (0 == strncmp(VCD_MANAGER_METHOD_FEEDBACK_STREAMING, method, strlen(VCD_MANAGER_METHOD_FEEDBACK_STREAMING))) { char *utt_id = NULL; @@ -316,9 +316,9 @@ static void __send_buffer_cb(void *user_data, rpc_port_proxy_vc_mgr_proxy_array_ char* buffer = NULL; int len = 0; - bundle_get_str(msg, VC_MANAGER_BUNDLE_MESSAGE, &val); - bundle_get_str(msg, VC_MANAGER_BUNDLE_UTTID, &utt_id); - bundle_get_str(msg, VC_MANAGER_BUNDLE_EVENT, &event); + bundle_get_str(msg, VC_BUNDLE_PID, &val); + bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id); + bundle_get_str(msg, VC_BUNDLE_EVENT, &event); rpc_port_proxy_vc_mgr_proxy_array_char_get(data_in, &buffer, &len); __vc_mgr_cb_feedback_streaming(atoi(val), atoi(utt_id), atoi(event), buffer, len); diff --git a/client/vc_setting_tidl.c b/client/vc_setting_tidl.c index 6f687c3..42c8017 100644 --- a/client/vc_setting_tidl.c +++ b/client/vc_setting_tidl.c @@ -35,8 +35,6 @@ typedef struct { static GList* g_tidl_infos = NULL; -extern int __vc_cb_service_state(int state); - static vc_setting_tidl_info_s* __get_tidl_info_s(int pid) { @@ -169,15 +167,8 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) bundle_get_str(msg, VC_BUNDLE_METHOD, &method); if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO))) { + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] HELLO received"); } /* VCD_METHOD_HELLO */ - else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) { - /* signal!!! */ - char* state = NULL; - bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &state); - if (state) { - __vc_cb_service_state(atoi(state)); - } - } /* VCD_METHOD_SET_SERVICE_STATE */ else { SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg"); } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index dbfed0d..04698a7 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -231,8 +231,8 @@ static void __notify_cb(void* user_data, int pid, bundle* msg) char* utt_status = NULL; bundle_get_str(msg, VC_BUNDLE_PID, &pid); - bundle_get_str(msg, VC_BUNDLE_UTTID, &utt_id); - bundle_get_str(msg, VC_BUNDLE_UTTSTATUS, &utt_status); + bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id); + bundle_get_str(msg, VC_BUNDLE_UTT_STATUS, &utt_status); SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get utterance status : pid(%d), utt_id(%d), utt_status(%d)", atoi(pid), atoi(utt_id), atoi(utt_status)); __vc_cb_utterance_status(atoi(utt_id), atoi(utt_status)); diff --git a/client/vc_widget_tidl.c b/client/vc_widget_tidl.c index dc2b84b..091a57c 100644 --- a/client/vc_widget_tidl.c +++ b/client/vc_widget_tidl.c @@ -61,11 +61,11 @@ static void __notify_cb(void *user_data, bundle *msg) char* val = NULL; SLOG(LOG_DEBUG, TAG_VCW, "__notify_cb is invoked"); - bundle_get_str(msg, VC_WIDGET_BUNDLE_METHOD, &method); + bundle_get_str(msg, VC_BUNDLE_METHOD, &method); if (0 == strncmp(VCD_WIDGET_METHOD_HELLO, method, strlen(VCD_WIDGET_METHOD_HELLO))) { SLOG(LOG_INFO, TAG_VCW, "@@@ Get widget hello"); - bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_PID, &val); if (val) { SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get hello : pid(%d) ", atoi(val)); } else { @@ -75,7 +75,7 @@ static void __notify_cb(void *user_data, bundle *msg) } /* VCD_METHOD_HELLO */ else if (0 == strncmp(VCD_WIDGET_METHOD_SET_SERVICE_STATE, method, strlen(VCD_WIDGET_METHOD_SET_SERVICE_STATE))) { - bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val); + bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val); int state = 0; if (val) { state = atoi(val); @@ -87,8 +87,8 @@ static void __notify_cb(void *user_data, bundle *msg) else if (0 == strncmp(VCD_WIDGET_METHOD_SHOW_TOOLTIP, method, strlen(VCD_WIDGET_METHOD_SHOW_TOOLTIP))) { SLOG(LOG_DEBUG, TAG_VCW, "@@@ Show / Hide tooltip"); char* temp_show = NULL; - bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val); - bundle_get_str(msg, VC_WIDGET_BUNDLE_SHOW, &temp_show); + bundle_get_str(msg, VC_BUNDLE_PID, &val); + bundle_get_str(msg, VC_BUNDLE_SHOW, &temp_show); int pid = 0; int show = 0; @@ -122,9 +122,9 @@ static void __notify_cb(void *user_data, bundle *msg) char* temp_daemon_pid = NULL; char* err_msg = NULL; - bundle_get_str(msg, VC_WIDGET_BUNDLE_REASON, &temp_reason); - bundle_get_str(msg, VC_WIDGET_BUNDLE_DAEMON_PID, &temp_daemon_pid); - bundle_get_str(msg, VC_WIDGET_BUNDLE_ERROR_MESSAGE, &err_msg); + bundle_get_str(msg, VC_BUNDLE_REASON, &temp_reason); + bundle_get_str(msg, VC_BUNDLE_DAEMON_PID, &temp_daemon_pid); + bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg); int reason = 0; int daemon_pid = 0; diff --git a/common/vc_defs.h b/common/vc_defs.h index 2a74a03..d217052 100644 --- a/common/vc_defs.h +++ b/common/vc_defs.h @@ -68,10 +68,26 @@ extern "C" { #define VC_BUNDLE_DAEMON_PID "daemon_pid" #define VC_BUNDLE_ERR_MSG "err_msg" #define VC_BUNDLE_PID "pid" -#define VC_BUNDLE_UTTID "uttid" -#define VC_BUNDLE_UTTSTATUS "uttstatus" +#define VC_BUNDLE_UTT_ID "utt_id" +#define VC_BUNDLE_UTT_STATUS "utt_status" +#define VC_BUNDLE_UTT_TEXT "utt_text" #define VC_BUNDLE_FEEDBACK_EVENT "feedback_event" #define VC_BUNDLE_LENGTH "length" +#define VC_BUNDLE_SHOW "show" +#define VC_BUNDLE_EVENT "event" +#define VC_BUNDLE_PRE_RESULT "pre_result" +#define VC_BUNDLE_RESULT "result" +#define VC_BUNDLE_ENGINE_APP_ID "engine_app_id" +#define VC_BUNDLE_DISP_TEXT "disp_text" +#define VC_BUNDLE_CONTINUOUS "continuous" +#define VC_BUNDLE_KEY "key" +#define VC_BUNDLE_PRIVATE_DATA "private_data" +#define VC_BUNDLE_AUDIO_CHANNEL "audio_channel" +#define VC_BUNDLE_AUDIO_TYPE "audio_type" +#define VC_BUNDLE_AUDIO_RATE "audio_rate" +#define VC_BUNDLE_BUFFER "buffer" +#define VC_BUNDLE_VOLUME "volume" + /****************************************************************************************** * Message Definition for all @@ -145,14 +161,6 @@ extern "C" { #define VCD_WIDGET_METHOD_SHOW_TOOLTIP "vcd_widget_method_show_tooltip" #define VCD_WIDGET_METHOD_SET_SERVICE_STATE "vcd_widget_method_set_service_state" -#define VC_WIDGET_BUNDLE_METHOD "vc_widget_bundle_method" -#define VC_WIDGET_BUNDLE_MESSAGE "vc_widget_bundle_message" -#define VC_WIDGET_BUNDLE_SERVICE_STATE "vc_widget_bundle_service_state" -#define VC_WIDGET_BUNDLE_DAEMON_PID "vc_widget_bundle_daemon_pid" -#define VC_WIDGET_BUNDLE_SHOW "vc_widget_bundle_show" -#define VC_WIDGET_BUNDLE_REASON "vc_widget_bundle_reason" -#define VC_WIDGET_BUNDLE_ERROR_MESSAGE "vc_widget_bundle_error_message" - /****************************************************************************************** * Message Definitions for manager @@ -188,26 +196,6 @@ extern "C" { #define VC_MANAGER_METHOD_SEND_AUDIO_STREAMING "vc_manager_method_send_audio_streaming" #define VC_MANAGER_METHOD_CHANGE_SYSTEM_VOLUME "vc_manager_method_change_system_volume" -#define VC_MANAGER_BUNDLE_METHOD "vc_manager_bundle_method" -#define VC_MANAGER_BUNDLE_MESSAGE "vc_manager_bundle_message" -#define VC_MANAGER_BUNDLE_EVENT "vc_manager_bundle_event" -#define VC_MANAGER_BUNDLE_PRE_RESULT "vc_manager_bundle_pre_result" -#define VC_MANAGER_BUNDLE_ENGINE_APP_ID "vc_manager_bundle_engine_app_id" -#define VC_MANAGER_BUNDLE_RESULT "vc_manager_bundle_result" -#define VC_MANAGER_BUNDLE_DISP_TEXT "vc_manager_bundle_disp_text" -#define VC_MANAGER_BUNDLE_UTT_TEXT "vc_manager_bundle_utt_text" -#define VC_MANAGER_BUNDLE_CONTINUOUS "vc_manager_bundle_continuous" -#define VC_MANAGER_BUNDLE_REASON "vc_manager_bundle_reason" -#define VC_MANAGER_BUNDLE_DAEMON_PID "vc_manager_bundle_daemon_pid" -#define VC_MANAGER_BUNDLE_ERROR_MESSAGE "vc_manager_bundle_error_message" -#define VC_MANAGER_BUNDLE_KEY "vc_manager_bundle_key" -#define VC_MANAGER_BUNDLE_PRIVATE_DATA "vc_manager_bundle_private_data" -#define VC_MANAGER_BUNDLE_AUDIO_CHANNEL "vc_manager_bundle_audio_channel" -#define VC_MANAGER_BUNDLE_AUDIO_TYPE "vc_manager_bundle_audio_type" -#define VC_MANAGER_BUNDLE_AUDIO_RATE "vc_manager_bundle_audio_rate" -#define VC_MANAGER_BUNDLE_UTTID "vc_manager_bundle_uttid" -#define VC_MANAGER_BUNDLE_BUFFER "vc_manager_bundle_buffer" - #define VCD_MANAGER_METHOD_HELLO "vcd_manager_method_hello" #define VCD_MANAGER_METHOD_SPEECH_DETECTED "vcd_manager_method_speech_detected" #define VCD_MANAGER_METHOD_ALL_RESULT "vcd_manager_method_all_result" diff --git a/server/vcd_tidl.c b/server/vcd_tidl.c index f64dc51..237488f 100644 --- a/server/vcd_tidl.c +++ b/server/vcd_tidl.c @@ -211,103 +211,107 @@ void __send_msg(bundle* msg, vcd_client_type_e type, int pid) } } -void __send_signal(bundle* msg) +void __send_signal(bundle* msg, vcd_client_type_e type) { SLOG(LOG_INFO, TAG_VCD, "[TIDL] send signal start"); - pthread_mutex_lock(&g_mgr_tidl_info_mutex); + 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; - } + 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"); + 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; - } - pthread_mutex_unlock(&g_mgr_tidl_info_mutex); - - pthread_mutex_lock(&g_client_tidl_info_mutex); - // get all pids - int* client_list = NULL; - int client_count = 0; - int ret = -1; - ret = vcd_client_get_tidl_list(&client_list, &client_count); - - client_tidl_info_s* client_tidl_info = NULL; - int pid = -1; - - if (0 == ret && 0 < client_count) { - for (int i = 0 ; i < client_count ; i++) { - pid = client_list[i]; - - client_tidl_info = vcd_client_get_tidl_info(pid); - if (NULL == client_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); - continue; - } - - if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(client_tidl_info->notify_cb, pid, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - continue; + } /* signal to MANAGER */ + else if (VCD_CLIENT_TYPE_NORMAL == type) { + pthread_mutex_lock(&g_client_tidl_info_mutex); + // get all pids + int* client_list = NULL; + int client_count = 0; + int ret = -1; + ret = vcd_client_get_tidl_list(&client_list, &client_count); + + client_tidl_info_s* client_tidl_info = NULL; + int pid = -1; + + if (0 == ret && 0 < client_count) { + for (int i = 0 ; i < client_count ; i++) { + pid = client_list[i]; + + client_tidl_info = vcd_client_get_tidl_info(pid); + if (NULL == client_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get tidl info. pid(%d)", pid); + continue; + } + + if (0 != rpc_port_stub_vcd_stub_vc_notify_cb_invoke(client_tidl_info->notify_cb, pid, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + continue; + } } } - } - pthread_mutex_unlock(&g_client_tidl_info_mutex); + pthread_mutex_unlock(&g_client_tidl_info_mutex); + } /* signal to clients */ + else if (VCD_CLIENT_TYPE_WIDGET == type) { + pthread_mutex_lock(&g_widget_tidl_info_mutex); + GSList *iter = NULL; + GSList* widget_list = vcd_client_widget_get_tidl_info_list(); - pthread_mutex_lock(&g_widget_tidl_info_mutex); - GSList *iter = NULL; - GSList* widget_list = vcd_client_widget_get_tidl_info_list(); + int count = g_slist_length(widget_list); + int i; - int count = g_slist_length(widget_list); - int i; + widget_tidl_info_s *widget_tidl_info = NULL; - widget_tidl_info_s *widget_tidl_info = NULL; + if (0 < count) { + iter = g_slist_nth(widget_list, 0); + for (i = 0; i < count; i++) { + if (NULL == iter) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] widget list iterator broken"); + break; + } - if (0 < count) { - iter = g_slist_nth(widget_list, 0); - for (i = 0; i < count; i++) { - if (NULL == iter) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] widget list iterator broken"); - break; - } + widget_tidl_info = iter->data; - widget_tidl_info = iter->data; + if (NULL == widget_tidl_info) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] widget list data broken"); + break; + } - if (NULL == widget_tidl_info) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] widget list data broken"); - break; - } + SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to widget"); - SLOG(LOG_INFO, TAG_VCD, "[TIDL] message to widget"); + rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h handle = widget_tidl_info->notify_cb; + if (NULL == handle) { + SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); + break; + } - rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_h handle = widget_tidl_info->notify_cb; - if (NULL == handle) { - SLOG(LOG_ERROR, TAG_VCD, "[TIDL] notify callback handle is null"); - break; - } + if (0 != rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_invoke(handle, msg)) { + SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); + break; + } - if (0 != rpc_port_stub_vcd_widget_stub_vc_widget_notify_cb_invoke(handle, msg)) { - SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send msg"); - break; + iter = g_slist_next(iter); } - - iter = g_slist_next(iter); } - } - pthread_mutex_unlock(&g_widget_tidl_info_mutex); + pthread_mutex_unlock(&g_widget_tidl_info_mutex); + } /* signal to widgets */ } @@ -2047,11 +2051,11 @@ int vcdc_send_hello(int pid, vcd_client_type_e type) bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_HELLO); bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); } else if (VCD_CLIENT_TYPE_MANAGER == type) { - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_HELLO); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_HELLO); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); } else if (VCD_CLIENT_TYPE_WIDGET == type) { - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_HELLO); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_HELLO); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); } else { SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid"); bundle_free(msg); @@ -2130,8 +2134,8 @@ int vcdc_send_set_volume(int manager_pid, float volume) bundle* msg = bundle_create(); snprintf(tmp_volume, 20, "%.6f", volume); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_VOLUME); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_volume); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_VOLUME); + bundle_add_str(msg, VC_BUNDLE_VOLUME, tmp_volume); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2159,9 +2163,9 @@ int vcdc_send_show_tooltip(int pid, bool show) snprintf(tmp_pid, 10, "%d", pid); snprintf(tmp_show, 10, "%d", (int)show); - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SHOW_TOOLTIP); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_WIDGET_BUNDLE_SHOW, tmp_show); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_SHOW_TOOLTIP); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_SHOW, tmp_show); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2232,9 +2236,9 @@ int vcdc_send_pre_result_to_manager(int manager_pid, int event, const char* pre_ bundle* msg = bundle_create(); snprintf(tmp_event, 10, "%d", event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_PRE_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_PRE_RESULT, pre_result); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_PRE_RESULT); + bundle_add_str(msg, VC_BUNDLE_EVENT, tmp_event); + bundle_add_str(msg, VC_BUNDLE_PRE_RESULT, pre_result); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2252,10 +2256,10 @@ int vcdc_send_specific_engine_result_to_manager(int manager_pid, const char* eng gchar *gEncodedResult = g_base64_encode((const guchar*)result, strlen(result)); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ENGINE_APP_ID, engine_app_id); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_RESULT, gEncodedResult); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPECIFIC_ENGINE_RESULT); + bundle_add_str(msg, VC_BUNDLE_ENGINE_APP_ID, engine_app_id); + bundle_add_str(msg, VC_BUNDLE_EVENT, event); + bundle_add_str(msg, VC_BUNDLE_RESULT, gEncodedResult); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2277,8 +2281,8 @@ int vcdc_send_result_to_manager(int manager_pid, int result_type) bundle* msg = bundle_create(); snprintf(tmp_result, 10, "%d", result_type); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ALL_RESULT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_result); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_ALL_RESULT); + bundle_add_str(msg, VC_BUNDLE_RESULT, tmp_result); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2295,7 +2299,7 @@ int vcdc_send_speech_detected(int manager_pid) bundle* msg = bundle_create(); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPEECH_DETECTED); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SPEECH_DETECTED); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2314,17 +2318,19 @@ int vcdc_send_service_state(vcd_state_e state) bundle* msg = bundle_create(); snprintf(tmp_state, 10, "%d", (int)state); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_SERVICE_STATE); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_state); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_SERVICE_STATE); + bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); + __send_signal(msg, VCD_CLIENT_TYPE_MANAGER); bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_METHOD_SET_SERVICE_STATE); bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); + __send_signal(msg, VCD_CLIENT_TYPE_NORMAL); - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_WIDGET_METHOD_SET_SERVICE_STATE); - bundle_add_str(msg, VC_WIDGET_BUNDLE_MESSAGE, tmp_state); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_SET_SERVICE_STATE); + bundle_add_str(msg, VC_BUNDLE_SERVICE_STATE, tmp_state); + __send_signal(msg, VCD_CLIENT_TYPE_WIDGET); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND SIGNAL"); - __send_signal(msg); bundle_free(msg); return VCD_ERROR_NONE; @@ -2354,11 +2360,11 @@ int vcdc_send_dialog(int manager_pid, int pid, const char* disp_text, const char tmp_utt_text = strdup(utt_text); } - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_DIALOG); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DISP_TEXT, tmp_disp_text); - bundle_add_str(msg, VC_MANAGER_BUNDLE_UTT_TEXT, tmp_utt_text); - bundle_add_str(msg, VC_MANAGER_BUNDLE_CONTINUOUS, tmp_continuous); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_DIALOG); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_DISP_TEXT, tmp_disp_text); + bundle_add_str(msg, VC_BUNDLE_UTT_TEXT, tmp_utt_text); + bundle_add_str(msg, VC_BUNDLE_CONTINUOUS, tmp_continuous); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2389,10 +2395,10 @@ int vcdc_tidl_send_error_to_manager(int manager_pid, int reason, char *err_msg) snprintf(tmp_reason, 10, "%d", reason); snprintf(tmp_daemon_pid, 10, "%d", getpid()); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_MANAGER_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, temp_msg); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); + bundle_add_str(msg, VC_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, temp_msg); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2428,15 +2434,15 @@ int vcdc_tidl_send_error(int reason, char *err_msg) snprintf(tmp_reason, 10, "%d", reason); snprintf(tmp_daemon_pid, 10, "%d", getpid()); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_MANAGER_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_MANAGER_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_ERROR_MESSAGE, temp_msg); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); + bundle_add_str(msg, VC_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, temp_msg); - bundle_add_str(msg, VC_WIDGET_BUNDLE_METHOD, VCD_MANAGER_METHOD_ERROR); - bundle_add_str(msg, VC_WIDGET_BUNDLE_REASON, tmp_reason); - bundle_add_str(msg, VC_WIDGET_BUNDLE_DAEMON_PID, tmp_daemon_pid); - bundle_add_str(msg, VC_WIDGET_BUNDLE_ERROR_MESSAGE, temp_msg); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_ERROR); + bundle_add_str(msg, VC_BUNDLE_REASON, tmp_reason); + bundle_add_str(msg, VC_BUNDLE_DAEMON_PID, tmp_daemon_pid); + bundle_add_str(msg, VC_BUNDLE_ERR_MSG, temp_msg); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND SIGNAL"); @@ -2459,10 +2465,10 @@ int vcdc_send_request_set_private_data(int pid, const char* key, const char* dat bundle* msg = bundle_create(); snprintf(tmp_pid, 10, "%d", pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_PRIVATE_DATA); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_KEY, key); - bundle_add_str(msg, VC_MANAGER_BUNDLE_PRIVATE_DATA, data); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_SET_PRIVATE_DATA); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_KEY, key); + bundle_add_str(msg, VC_BUNDLE_PRIVATE_DATA, data); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2484,10 +2490,10 @@ int vcdc_send_feedback_audio_format_to_manager(int manager_pid, int rate, vc_aud snprintf(tmp_rate, 10, "%d", rate); snprintf(tmp_channel, 10, "%d", (int)channel); snprintf(tmp_audio_type, 10, "%d", (int)audio_type); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_RATE, tmp_rate); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_CHANNEL, tmp_channel); - bundle_add_str(msg, VC_MANAGER_BUNDLE_AUDIO_TYPE, tmp_audio_type); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_AUDIO_FORMAT); + bundle_add_str(msg, VC_BUNDLE_AUDIO_RATE, tmp_rate); + bundle_add_str(msg, VC_BUNDLE_AUDIO_CHANNEL, tmp_channel); + bundle_add_str(msg, VC_BUNDLE_AUDIO_TYPE, tmp_audio_type); SLOG(LOG_DEBUG, TAG_VCD, ">>>> VCD SEND MESSAGE"); @@ -2509,10 +2515,10 @@ int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id snprintf(tmp_pid, 10, "%d", pid); snprintf(tmp_utt_id, 10, "%d", utt_id); snprintf(tmp_event, 10, "%d", (int)event); - bundle_add_str(msg, VC_MANAGER_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_STREAMING); - bundle_add_str(msg, VC_MANAGER_BUNDLE_MESSAGE, tmp_pid); - bundle_add_str(msg, VC_MANAGER_BUNDLE_UTTID, tmp_utt_id); - bundle_add_str(msg, VC_MANAGER_BUNDLE_EVENT, tmp_event); + bundle_add_str(msg, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_FEEDBACK_STREAMING); + bundle_add_str(msg, VC_BUNDLE_PID, tmp_pid); + bundle_add_str(msg, VC_BUNDLE_UTT_ID, tmp_utt_id); + bundle_add_str(msg, VC_BUNDLE_EVENT, tmp_event); rpc_port_stub_vcd_mgr_stub_array_char_h streaming_data = NULL; rpc_port_stub_vcd_mgr_stub_array_char_create(&streaming_data); -- 2.7.4 From c901d727e37949af62dfbe801e5053c965563f85 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 30 Jun 2022 11:48:50 +0900 Subject: [PATCH 15/16] Remove unnecessary command and Fix return value in vcd_client_widget_get_foreground_pid() Change-Id: I686738186f46907a74adccf412bc2295a1b79655 Signed-off-by: sooyeon --- packaging/voice-control.spec | 4 ---- server/vcd_client_data.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packaging/voice-control.spec b/packaging/voice-control.spec index 952b983..eff8088 100644 --- a/packaging/voice-control.spec +++ b/packaging/voice-control.spec @@ -154,10 +154,6 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} -%if "%{tizen_profile_name}" == "tv" -mv -f org.tizen.voice.vcserver.tv.service org.tizen.voice.vcserver.service -%endif - %make_install %if 0%{?gcov:1} diff --git a/server/vcd_client_data.c b/server/vcd_client_data.c index 404d52f..057d919 100644 --- a/server/vcd_client_data.c +++ b/server/vcd_client_data.c @@ -1828,7 +1828,7 @@ int vcd_client_widget_get_foreground_pid() widget = __widget_get_element(fg_pid); if (NULL == widget) { SLOG(LOG_WARN, TAG_VCD, "[Client Data] Not found foreground pid of widget"); - return VCD_ERROR_INVALID_PARAMETER; + return -1; } return widget->pid; -- 2.7.4 From 570e4da59c2d2838ed6e1cd21fb66a90e3af04db Mon Sep 17 00:00:00 2001 From: sooyeon Date: Thu, 30 Jun 2022 13:37:55 +0900 Subject: [PATCH 16/16] Fix a minor issue (engine_appid was not saved in info handle) Change-Id: I380beddfa0953fd21a9524158d8aa5b8f098878c Signed-off-by: sooyeon --- client/vc_tidl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/vc_tidl.c b/client/vc_tidl.c index 04698a7..61ea8ea 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -355,16 +355,16 @@ int vc_tidl_open_connection() } int pid = getpid(); - char* engine_appid = __get_engine_appid(); + info->pid = pid; + info->engine_appid = __get_engine_appid(); - info->rpc_h = __create_rpc_port(pid, engine_appid); + info->rpc_h = __create_rpc_port(pid, info->engine_appid); if (NULL == info->rpc_h) { SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create proxy"); free(info); return VC_ERROR_OPERATION_FAILED; } - info->pid = pid; g_tidl_infos = g_list_append(g_tidl_infos, info); SLOG(LOG_ERROR, TAG_VCC, "[TIDL] pid(%d) rpc_h(%p), engine_appid(%s)", pid, info->rpc_h, info->engine_appid); -- 2.7.4