From d7084335c138e9219c18523f7f763f4ebb9424c0 Mon Sep 17 00:00:00 2001 From: sooyeon Date: Wed, 29 Jun 2022 17:39:17 +0900 Subject: [PATCH] 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