static GList *g_proc_list = NULL;
static Ecore_Timer *g_restart_timer = NULL;
+static Ecore_Timer *g_check_widget_client_timer = NULL;
/**
* @brief Enumerations of send event type.
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result, ret(%d)", ret);
break;
} else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send result : pid(%d) type(%d)", temp_cmd->pid, temp_cmd->type);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Send result : pid(%d) type(%d)", temp_cmd->pid, temp_cmd->type);
pre_pid = temp_cmd->pid;
pre_type = temp_cmd->type;
}
int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
{
+ int ret = __vcd_server_launch_manager_app();
+ if (0 != ret) {
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send ASR result : mgr_pid(%d), asr_result(%s)", vcd_client_manager_get_pid(), asr_result);
+ return ret;
+ }
+
if (NULL != asr_result) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result);
- vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result);
+ ret = vcdc_send_pre_result_to_manager(vcd_client_manager_get_pid(), event, asr_result);
+ if (0 != ret) {
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send ASR result : mgr_pid(%d), asr_result(%s)", vcd_client_manager_get_pid(), asr_result);
+ }
}
- return VCD_ERROR_NONE;
+ return ret;
}
int vcd_send_nlg_result(const char* nlg_result, void *user_data)
{
int ret = __vcd_server_launch_manager_app();
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
return ret;
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
ret = vcdc_send_dialog(vcd_client_manager_get_pid(), -1, nlg_result, NULL, 0); //0: VC_DIALOG_END
if (0 != ret)
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
+ SECURE_SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send dialog : mgr_pid(%d), nlg_result(%s)", vcd_client_manager_get_pid(), nlg_result);
return ret;
}
return NULL;
}
-int vcd_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, void *user_data)
+int vcd_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)
{
int ret = 0;
vc_info_parser_unset_result(vcd_client_manager_get_exclusive());
vcd_client_manager_set_result_text(all_result);
- SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)",
+ SECURE_SLOG(LOG_INFO, TAG_VCD, "[Server] Event(%d), Text(%s) Nonfixed(%s) Msg(%s) Result count(%d)",
event, all_result, non_fixed_result, msg, count);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] NLU result(%s)", nlu_result);
+
if (VCD_RECOGNITION_MODE_RESTART_AFTER_REJECT == vcd_client_get_recognition_mode()) {
if (VCE_RESULT_EVENT_REJECTED == event) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Restart by no or rejected result");
}
}
#if 1
-
- int pid = vcd_client_widget_get_foreground_pid();
- if (-1 != pid) {
- if (NULL != all_result) {
- vc_info_parser_set_result(all_result, event, msg, NULL, false);
- bool enable = false;
- vcd_client_widget_get_asr_result_enabled(pid, &enable);
- if (true == enable) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send ASR result to Widget client");
- bool is_consumed = false;
- if (0 != vcdc_send_asr_result(pid, VC_COMMAND_TYPE_WIDGET, &is_consumed)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send asr result");
- } else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result is consumed(%d)", is_consumed);
- if (true == is_consumed) {
- vcdc_send_show_tooltip(pid, false);
- if (-1 != vcd_client_manager_get_pid()) {
- /* Manager client is available */
- vc_info_parser_unset_result(false);
- vc_info_parser_set_result(all_result, VC_RESULT_EVENT_RESULT_SUCCESS, msg, NULL, false);
- if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
- SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
- }
- }
-
- vcd_client_manager_set_exclusive(false);
-
- vcd_config_set_service_state(VCD_STATE_READY);
- vcdc_send_service_state(VCD_STATE_READY);
- return VCD_ERROR_NONE;
- }
- }
- }
- }
- }
-
/* if nlu_result is exist, Add command handle(is_action) into result list */
/* Normal result */
SLOG(LOG_DEBUG, TAG_VCD, "[Server] @ Get engine result @");
}
/* priority filter */
- /* system > exclusive > foreground = widget > system_background > background */
+ /* system > exclusive > widget > foreground > system_background > background */
int i = 0;
int* filtered_id = (int*)calloc(count, sizeof(int));
if (!filtered_id) {
}
}
+ // ASR consume
+ if (top_priority >= VC_COMMAND_PRIORITY_WIDGET) {
+ int pid = vcd_client_widget_get_foreground_pid();
+ if (-1 != pid) {
+ if (NULL != all_result) {
+ vc_info_parser_set_result(all_result, event, msg, NULL, false);
+ bool enable = false;
+ vcd_client_widget_get_asr_result_enabled(pid, &enable);
+ if (true == enable) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send ASR result to Widget client");
+ bool is_consumed = false;
+ if (NULL != user_info) {
+ *user_info = 0x00;
+ }
+ if (0 != vcdc_send_asr_result(pid, event, all_result, VC_COMMAND_TYPE_WIDGET, &is_consumed)) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send asr result");
+ } else {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result is consumed(%d)", is_consumed);
+ if (true == is_consumed) {
+ if (NULL != user_info) {
+ *user_info = 0x01;
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Send whether ASR result is consumed or not (%d)", *user_info);
+ }
+ vcdc_send_show_tooltip(pid, false);
+ if (-1 != vcd_client_manager_get_pid()) {
+ /* Manager client is available */
+ vc_info_parser_unset_result(false);
+ vc_info_parser_set_result(all_result, VC_RESULT_EVENT_RESULT_SUCCESS, msg, NULL, false);
+ if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+ SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
+ }
+ }
+
+ vcd_client_manager_set_exclusive(false);
+
+ vcd_config_set_service_state(VCD_STATE_READY);
+ vcdc_send_service_state(VCD_STATE_READY);
+ vc_cmd_list_destroy(vc_cmd_list, true);
+ if (NULL != filtered_id) {
+ free(filtered_id);
+ filtered_id = NULL;
+ }
+ return VCD_ERROR_NONE;
+ }
+ }
+ }
+ }
+ }
+ }
+
int is_action = 0;
for (i = 0; i < filtered_count; i++) {
SLOG(LOG_INFO, TAG_VCD, "[Server] [%d] Filtered Result id(%d)", i, filtered_id[i]);
}
if (NULL != nlu_result) {
- SLOG(LOG_INFO, TAG_VCD, "[Server] NLU (%s)", nlu_result);
+ SECURE_SLOG(LOG_INFO, TAG_VCD, "[Server] NLU (%s)", nlu_result);
vc_info_parser_set_nlu_result(nlu_result);
if (0 == is_action) {
vc_cmd_h nlu_cmd;
if (0 == result_count) {
/* No result */
if (NULL != all_result) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is no command : %s", all_result);
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is no command : %s", all_result);
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Engine result is NULL");
}
#if 0
static void __vcd_server_nlu_result_cb(vce_result_event_e event, const char* nlu_result, void *user_data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU result cb - event(%d)", event);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] result (%s)", nlu_result);
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] NLU result cb - event(%d)", event);
+ SECURE_SLOG(LOG_DEBUG, TAG_VCD, "[Server] result (%s)", nlu_result);
int ret = vc_info_parser_set_nlu_result(nlu_result);
if (0 != ret) {
char* error_msg = NULL;
if (NULL != msg) {
error_msg = strdup(msg);
+ if (NULL == error_msg) {
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
}
- if (0 != vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg)) {
+ int ret = VCD_ERROR_NONE;
+ ret = vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg);
+ if (VCD_ERROR_NONE != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send error signal");
}
error_msg = NULL;
}
- return VCD_ERROR_NONE;
+ return ret;
}
/*
vcd_config_set_service_state(VCD_STATE_READY);
vcdc_send_service_state(VCD_STATE_READY);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server SUCCESS] initialize");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server SUCCESS] initialize");
return 0;
}
-void vcd_finalize()
+bool vcd_finalize()
{
GList *iter = NULL;
if (0 < g_list_length(g_proc_list)) {
}
vcd_engine_recognize_cancel();
}
+
if (0 != vcd_recorder_destroy()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to destroy recorder");
+ return false;
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] destroy recorder");
}
if (0 != vcd_engine_agent_release()) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to release engine");
+ return false;
} else {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] release engine");
}
vcd_config_set_service_state(VCD_STATE_NONE);
vcdc_send_service_state(VCD_STATE_NONE);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] mode finalize");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] mode finalize");
- return;
+ return true;
}
static Eina_Bool __finalize_quit_ecore_loop(void *data)
{
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] quit ecore main loop");
- ecore_main_loop_quit();
- return EINA_FALSE;
+ bool ret = vcd_finalize();
+ if (false == ret) {
+ return EINA_TRUE;
+ } else {
+ ecore_main_loop_quit();
+ return EINA_FALSE;
+ }
}
static void __read_proc()
if (0 != vcdc_send_manager_pid(pid))
SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send manager pid");
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager initialize : pid(%d)", pid);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Manager initialize : pid(%d)", pid);
return VCD_ERROR_NONE;
}
if (0 == vcd_client_get_ref_count()) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
}
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Manager Finalize : pid(%d)", pid);
return VCD_ERROR_NONE;
}
return VCD_ERROR_NONE;
}
+static int __reset_waiting_for_widget_recording(void)
+{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Reet waiting for widget recording");
+ // Delete timer to check that widget client is terminated
+ if (g_check_widget_client_timer) {
+ ecore_timer_del(g_check_widget_client_timer);
+ g_check_widget_client_timer = NULL;
+ }
+ // Reset flag to wait for recording from widget client
+ vcd_client_widget_set_waiting_for_recording(-1, false);
+ return 0;
+}
+
+static Eina_Bool __send_waiting_timeout_error_to_manager(void* data)
+{
+ intptr_t ppid = (intptr_t)data;
+ int pid = (int)ppid;
+ SLOG(LOG_ERROR, TAG_VCD, "Widget client didn't send to start recording, pid(%d)", pid);
+ __reset_waiting_for_widget_recording();
+
+ vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
+ return EINA_FALSE;
+}
+
+static int __set_waiting_for_widget_recording(int pid)
+{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Set waiting for widget recording, pid(%d)", pid);
+
+ // Check if the app included widget client is terminated or not. If it is terminated, vcd_server_widget_finalize() function will be called
+ // In that function, it will start recording
+ intptr_t ppid = (intptr_t)pid;
+ g_check_widget_client_timer = ecore_timer_add(2.0, __send_waiting_timeout_error_to_manager, (void*)ppid);
+
+ // Set flag to wait for recording from widget client
+ vcd_client_widget_set_waiting_for_recording(pid, true);
+ return 0;
+}
+
static int __start_internal_recognition()
{
int ret;
+ __reset_waiting_for_widget_recording();
if (0 != vcd_client_command_collect_command()) {
SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command");
return VCD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Set command");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Set command");
bool stop_by_silence = true;
if (VCD_RECOGNITION_MODE_MANUAL == vcd_client_get_recognition_mode()) {
return VCD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Start engine");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Start engine");
#if 1
/* 5. recorder start */
vcd_config_set_service_state(VCD_STATE_RECORDING);
vcdc_send_service_state(VCD_STATE_RECORDING);
- SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] Start recognition(%d)", stop_by_silence);
return 0;
}
{
int pid = vcd_client_widget_get_foreground_pid();
if (-1 != pid) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip show and widget command");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Request tooltip show and widget command, show(%d)", (bool)data);
vcdc_send_show_tooltip(pid, (bool)data);
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available.");
return VCD_ERROR_OPERATION_FAILED;
}
+ __reset_waiting_for_widget_recording();
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] set recognition mode = %d", recognition_mode);
vcd_client_set_recognition_mode(recognition_mode);
if (false == exclusive_cmd) {
if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) {
int pid = vcd_client_widget_get_foreground_pid();
if (-1 != pid) {
- SLOG(LOG_INFO, TAG_VCD, "[Server] Request tooltip show and widget command");
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Request tooltip show and widget command");
ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true);
+
+ __set_waiting_for_widget_recording(pid);
return 0;
}
}
}
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] start internal recognition");
+
int ret = __start_internal_recognition();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition : %d", ret);
vcd_client_unset_exclusive_command(fg_pid);
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] start internal recognition");
return VCD_ERROR_NONE;
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available.");
return VCD_ERROR_OPERATION_FAILED;
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] stop internal recognition");
#if 1
/* 2. Stop recorder */
vcd_config_set_service_state(VCD_STATE_PROCESSING);
vcdc_send_service_state(VCD_STATE_PROCESSING);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] stop internal recognition");
return VCD_ERROR_NONE;
}
if (VCD_STATE_READY == state) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Current state is READY");
vcd_recorder_stop();
+
+ if (false == vcd_client_manager_get_exclusive()) {
+ if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) {
+ int pid = vcd_client_widget_get_foreground_pid();
+ if (-1 != pid) {
+ SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip hide");
+ ecore_timer_add(0, __vcd_request_show_tooltip, (void*)false);
+ }
+ }
+ }
+
vcdc_send_service_state(VCD_STATE_READY);
return VCD_ERROR_NONE;
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] cancel internal recognition");
#if 1
/* 2. Stop recorder */
vcd_config_set_service_state(VCD_STATE_READY);
vcdc_send_service_state(VCD_STATE_READY);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server Success] cancel internal recognition");
return VCD_ERROR_NONE;
}
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to enable command type");
} else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Enable command type(%d)", cmd_type);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Enable command type(%d)", cmd_type);
}
return ret;
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to disable command type");
} else {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] Disable command type(%d)", cmd_type);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] Disable command type(%d)", cmd_type);
}
return ret;
if (0 == vcd_client_get_ref_count()) {
SLOG(LOG_DEBUG, TAG_VCD, "[Server] Connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
}
SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Client Finalize : pid(%d)", pid);
return VCD_ERROR_NONE;
}
+static void __vcd_server_widget_start_recording(void *data)
+{
+ SLOG(LOG_ERROR, TAG_VCD, "[Server INFO] start recording");
+
+ if (0 != __start_internal_recognition()) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition");
+ }
+}
+
int vcd_server_widget_finalize(int pid)
{
/* check if pid is valid */
}
if (0 == vcd_client_get_ref_count()) {
- SLOG(LOG_DEBUG, TAG_VCD, "[Server] connected client list is empty");
- ecore_timer_add(0, __finalize_quit_ecore_loop, NULL);
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty");
+ ecore_timer_add(0.5, __finalize_quit_ecore_loop, NULL);
+ return 0;
}
+ bool is_waiting = false;
+ if (0 != vcd_client_widget_get_waiting_for_recording(pid, &is_waiting)) {
+ SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to get waiting to recording");
+ }
+
+ if (true == is_waiting) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Server INFO] invoke to start recording");
+ ecore_main_loop_thread_safe_call_async(__vcd_server_widget_start_recording, NULL);
+ }
return VCD_ERROR_NONE;
}
return VCD_ERROR_INVALID_PARAMETER;
}
+ 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;
+ }
+
if (true == widget_command) {
vcd_client_widget_set_command(pid);
SLOG(LOG_DEBUG, TAG_VCD, "[Server] widget command is available");
SLOG(LOG_WARN, TAG_VCD, "[Server] widget command is NOT available");
}
+ SLOG(LOG_ERROR, TAG_VCD, "[Server] start internal recongition : %d", widget_command);
int ret = __start_internal_recognition();
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition : %d", ret);