Merge "Reset waiting flag when recognition starts by widget" into tizen
[platform/core/uifw/voice-control.git] / server / vcd_server.c
index de53304..65fb25b 100755 (executable)
@@ -14,7 +14,7 @@
 * limitations under the License.
 */
 
-#include <app.h>
+#include <app_control.h>
 #include <app_manager.h>
 #include <dirent.h>
 #include <sound_manager.h>
 #include "vcd_dbus.h"
 
 #include "voice_control_command_expand.h"
+#include "voice_control_common.h"
 
 /*
 * VC Server static variable
 */
-static bool    g_is_engine;
-
 static GList *g_proc_list = NULL;
 
 static Ecore_Timer *g_restart_timer = NULL;
@@ -50,45 +49,44 @@ typedef enum {
        VCD_SEND_EVENT_TYPE_HAPTIC_EVENT        /**< send haptic event to vc engine */
 } vcd_send_event_type_e;
 
+static int __vcd_server_launch_manager_app();
+
 /*
 * VC Server Internal Functions
 */
 static Eina_Bool __stop_by_silence(void *data)
 {
-       SLOG(LOG_DEBUG, TAG_VCD, "===== Silence Detected ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ Silence Detected ");
 
        vcd_server_mgr_stop();
 
-       SLOG(LOG_DEBUG, TAG_VCD, "=====");
-       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
        return EINA_FALSE;
 }
 
 static Eina_Bool __cancel_by_interrupt(void *data)
 {
-       SLOG(LOG_DEBUG, TAG_VCD, "===== Cancel by interrupt");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by interrupt");
 
        vcd_server_mgr_cancel();
 
-       SLOG(LOG_DEBUG, TAG_VCD, "=====");
-       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
        return EINA_FALSE;
 }
 
 static void __cancel_by_error(void *data)
 {
-       SLOG(LOG_DEBUG, TAG_VCD, "===== Cancel by error");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by error");
 
        vcd_server_mgr_cancel();
 
-       SLOG(LOG_DEBUG, TAG_VCD, "=====");
-       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
        return;
 }
 
 static Eina_Bool __restart_engine(void *data)
 {
-       SLOG(LOG_DEBUG, TAG_VCD, "===== Restart by no result");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ Restart by no result");
 
        g_restart_timer = NULL;
 
@@ -108,8 +106,7 @@ static Eina_Bool __restart_engine(void *data)
 
        SLOG(LOG_DEBUG, TAG_VCD, "[Server Success] Restart recognition");
 
-       SLOG(LOG_DEBUG, TAG_VCD, "=====");
-       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
        return EINA_FALSE;
 }
 
@@ -122,7 +119,7 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt
                return 0;
        }
 
-       vcp_speech_detect_e speech_detected = VCP_SPEECH_DETECT_NONE;
+       vce_speech_detect_e speech_detected = VCE_SPEECH_DETECT_NONE;
        int ret;
 
        ret = vcd_engine_recognize_audio(data, length, &speech_detected);
@@ -132,7 +129,7 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set recording data to engine(%d)", ret);
                ecore_timer_add(0, __cancel_by_interrupt, NULL);
                /* Send error cb to manager */
-               if (VCP_ERROR_OUT_OF_NETWORK == ret) {
+               if (VCE_ERROR_OUT_OF_NETWORK == ret) {
                        vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_TIMED_OUT, "Engine connection failed");
                } else {
                        vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "Engine recognition failed");
@@ -140,14 +137,14 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt
                return 0;
        }
 
-       if (VCP_SPEECH_DETECT_BEGIN == speech_detected) {
+       if (VCE_SPEECH_DETECT_BEGIN == speech_detected) {
                if (-1 != vcd_client_manager_get_pid()) {
                        /* Manager client is available */
                        if (0 != vcdc_send_speech_detected(vcd_client_manager_get_pid())) {
                                SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send speech detected");
                        }
                }
-       } else if (VCP_SPEECH_DETECT_END == speech_detected) {
+       } else if (VCE_SPEECH_DETECT_END == speech_detected) {
                if (VCD_RECOGNITION_MODE_STOP_BY_SILENCE == vcd_client_get_recognition_mode()) {
                        /* silence detected */
                        ecore_timer_add(0, __stop_by_silence, NULL);
@@ -175,17 +172,16 @@ static int __server_recorder_callback(const void* data, const unsigned int lengt
 
 void __server_recorder_interrupt_callback()
 {
-       SLOG(LOG_DEBUG, TAG_VCD, "===== Cancel by sound interrupt");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ Cancel by sound interrupt");
 
        ecore_timer_add(0, __cancel_by_interrupt, NULL);
 
-       SLOG(LOG_DEBUG, TAG_VCD, "=====");
-       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
 }
 
 static void __config_lang_changed_cb(const char* current_lang, void* user_data)
 {
-       SLOG(LOG_DEBUG, TAG_VCD, "===== Change language ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ Change language ");
 
        /* Current state is recording */
        vcd_state_e state = vcd_config_get_service_state();
@@ -200,15 +196,14 @@ static void __config_lang_changed_cb(const char* current_lang, void* user_data)
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set language of engine : %d", ret);
        }
 
-       SLOG(LOG_DEBUG, TAG_VCD, "=====");
-       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
 
        return;
 }
 
 static void __config_foreground_changed_cb(int previous, int current, void* user_data)
 {
-       SLOG(LOG_DEBUG, TAG_VCD, "===== Change foreground");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ Change foreground");
 
        SLOG(LOG_DEBUG, TAG_VCD, "Foreground pid(%d)", current);
 
@@ -221,8 +216,7 @@ static void __config_foreground_changed_cb(int previous, int current, void* user
                }
        }
 
-       SLOG(LOG_DEBUG, TAG_VCD, "=====");
-       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
 
        return;
 }
@@ -387,12 +381,14 @@ static Eina_Bool __vcd_send_selected_result(void *data)
                        GSList* iter = NULL;
                        vc_cmd_s* temp_cmd = NULL;
                        int ret = 0;
+                       int pre_pid = -1;
+                       int pre_type = -1;
 
                        iter = g_slist_nth(pid_list, 0);
                        while (NULL != iter) {
                                temp_cmd = iter->data;
 
-                               if (NULL != temp_cmd) {
+                               if (NULL != temp_cmd && (pre_pid != temp_cmd->pid || pre_type == VC_COMMAND_TYPE_WIDGET || temp_cmd->type == VC_COMMAND_TYPE_WIDGET)) {
                                        /* Launch deactivated several apps that is matched with result */
                                        ret = __vcd_launch_app(result);
                                        if (0 != ret) {
@@ -404,7 +400,9 @@ static Eina_Bool __vcd_send_selected_result(void *data)
                                                        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;
                                                }
                                        }
                                        free(temp_cmd);
@@ -424,15 +422,29 @@ static Eina_Bool __vcd_send_selected_result(void *data)
        return EINA_FALSE;
 }
 
-//static void __vcd_server_pre_result_cb(vcp_pre_result_event_e event, const char* pre_result, void *user_data)
-static void __vcd_server_asr_result_cb(vcp_asr_result_event_e event, const char* asr_result, void *user_data)
+int vcd_send_asr_result(vce_asr_result_event_e event, const char* asr_result, void *user_data)
 {
        if (NULL != asr_result) {
-               SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result - Event(%d), Text(%s)", event, asr_result);
+               SECURE_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);
        }
 
-       return;
+       return VCD_ERROR_NONE;
+}
+
+int vcd_send_nlg_result(const char* nlg_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 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)
+               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;
 }
 
 static void* __recorder_stop(void *data)
@@ -441,35 +453,39 @@ static void* __recorder_stop(void *data)
        return NULL;
 }
 
-static void __vcd_server_result_cb(vcp_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;
+
        if (VCD_STATE_PROCESSING != vcd_config_get_service_state()) {
                if (VCD_RECOGNITION_MODE_RESTART_CONTINUOUSLY != vcd_client_get_recognition_mode()) {
                        SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not 'Processing' and mode is not 'Restart continuously'");
-                       return;
+                       return VCD_ERROR_INVALID_STATE;
                }
        }
 
        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 (VCP_RESULT_EVENT_REJECTED == event) {
+               if (VCE_RESULT_EVENT_REJECTED == event) {
                        SLOG(LOG_DEBUG, TAG_VCD, "[Server] Restart by no or rejected result");
                        /* If no result and restart option is ON */
                        /* Send reject message */
                        bool temp = vcd_client_manager_get_exclusive();
                        vc_info_parser_set_result(all_result, event, msg, NULL, temp);
-                       if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+                       ret = vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION);
+                       if (0 != ret) {
                                SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
                        }
 
                        g_restart_timer = ecore_timer_add(0, __restart_engine, NULL);
-                       return;
+                       return ret;
                }
                SLOG(LOG_DEBUG, TAG_VCD, "[Server] Stop recorder due to success");
                //vcd_recorder_stop();
@@ -478,52 +494,21 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
                SLOG(LOG_DEBUG, TAG_VCD, "[Server] Restart continuously");
                /* Restart option is ON */
                g_restart_timer = ecore_timer_add(0, __restart_engine, NULL);
-               if (VCP_RESULT_EVENT_REJECTED == event) {
+               if (VCE_RESULT_EVENT_REJECTED == event) {
                        bool temp = vcd_client_manager_get_exclusive();
                        vc_info_parser_set_result(all_result, event, msg, NULL, temp);
-                       if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
+                       ret = vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION);
+                       if (0 != ret) {
                                SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
                        }
-                       return;
+                       return ret;
                }
        }
 #if 1
-
-       int pid = vcd_client_widget_get_foreground_pid();
-       if (-1 != pid) {
-               if (NULL != all_result) {
-                       vc_info_parser_set_result(all_result, event, msg, NULL, false);
-                       bool enable = false;
-                       vcd_client_widget_get_asr_result_enabled(pid, &enable);
-                       if (true == enable) {
-                               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Send ASR result to Widget client");
-                               bool is_consumed = false;
-                               if (0 != vcdc_send_asr_result(pid, VC_COMMAND_TYPE_WIDGET, &is_consumed)) {
-                                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send asr result");
-                               } else {
-                                       SLOG(LOG_DEBUG, TAG_VCD, "[Server] ASR result is consumed(%d)", is_consumed);
-                                       if (true == is_consumed) {
-                                               vcdc_send_show_tooltip(pid, false);
-                                               if (-1 != vcd_client_manager_get_pid()) {
-                                                       /* Manager client is available */
-                                                       if (0 != vcdc_send_result_to_manager(vcd_client_manager_get_pid(), VC_RESULT_TYPE_NOTIFICATION)) {
-                                                               SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] Fail to send result");
-                                                       }
-                                               }
-
-                                               vcd_client_manager_set_exclusive(false);
-                                               return;
-                                       }
-                               }
-                       }
-               }
-       }
-
        /* if nlu_result is exist, Add command handle(is_action) into result list */
        /* Normal result */
-       SLOG(LOG_DEBUG, TAG_VCD, "[Server] === Get engine result ===");
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] @ Get engine result @");
 
-       int ret = -1;
        vc_cmd_s* temp_cmd = NULL;
        vc_cmd_list_h vc_cmd_list = NULL;
 
@@ -532,13 +517,17 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
                vcd_client_manager_set_exclusive(false);
                vcd_config_set_service_state(VCD_STATE_READY);
                vcdc_send_service_state(VCD_STATE_READY);
-               return;
+               return VCD_ERROR_NONE;
        }
 
        /* 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) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to allocate memory");
+               return VCD_ERROR_OUT_OF_MEMORY;
+       }
        int filtered_count = 0;
        int top_priority = VC_COMMAND_PRIORITY_BACKGROUND;
        for (i = 0; i < count; i++) {
@@ -554,13 +543,64 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
                        if (top_priority == temp_cmd->priority) {
                                filtered_id[filtered_count] = result_id[i];
                                filtered_count++;
-                       } else if (top_priority < temp_cmd->priority) {
-                               continue;
-                       } else {
+                       } else if (top_priority > temp_cmd->priority) {
                                filtered_id[0] = result_id[i];
                                filtered_count = 1;
                                top_priority = temp_cmd->priority;
                        }
+
+                       vc_cmd_destroy((vc_cmd_h)temp_cmd);
+                       temp_cmd = NULL;
+               }
+       }
+
+       // 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;
+                                               }
+                                       }
+                               }
+                       }
                }
        }
 
@@ -594,6 +634,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
                        if (0 != vc_cmd_list_add(vc_cmd_list, (vc_cmd_h)temp_cmd)) {
                                SLOG(LOG_DEBUG, TAG_VCD, "Fail to add command to list");
                                vc_cmd_destroy((vc_cmd_h)temp_cmd);
+                               temp_cmd = NULL;
                        }
                } else {
                        SLOG(LOG_WARN, TAG_VCD, "[Server WARNING] NOT found matached result(%d)", filtered_id[i]);
@@ -606,7 +647,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
        }
 
        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;
@@ -632,7 +673,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
 
        vc_cmd_print_list(vc_cmd_list);
 
-       SLOG(LOG_DEBUG, TAG_VCD, "[Server] =========================");
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] @@@@");
 
        int result_count = 0;
        vc_cmd_list_get_count(vc_cmd_list, &result_count);
@@ -640,7 +681,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
        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");
                }
@@ -663,7 +704,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
 
                vcd_client_manager_set_exclusive(false);
 
-               return;
+               return VCD_ERROR_NONE;
        } else {
                if (false == vcd_client_manager_get_exclusive()) {
                        int pid = vcd_client_widget_get_foreground_pid();
@@ -703,7 +744,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
 
        vc_cmd_list_destroy(vc_cmd_list, true);
 
-       return;
+       return VCD_ERROR_NONE;
 
 #else
        /* No result */
@@ -740,7 +781,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
        }
 
        /* Normal result */
-       SLOG(LOG_DEBUG, TAG_VCD, "[Server] === Get engine result ===");
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] @ Get engine result @");
 
        int ret = -1;
        vc_cmd_s* temp_cmd = NULL;
@@ -807,7 +848,7 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
 
        vc_cmd_print_list(vc_cmd_list);
 
-       SLOG(LOG_DEBUG, TAG_VCD, "[Server] =========================");
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] @@@@");
 
        int result_count = 0;
        vc_cmd_list_get_count(vc_cmd_list, &result_count);
@@ -854,10 +895,10 @@ static void __vcd_server_result_cb(vcp_result_event_e event, int* result_id, int
 }
 
 #if 0
-static void __vcd_server_nlu_result_cb(vcp_result_event_e event, const char* nlu_result, void *user_data)
+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) {
@@ -868,13 +909,15 @@ static void __vcd_server_nlu_result_cb(vcp_result_event_e event, const char* nlu
 }
 #endif
 
-static void __vcd_server_error_cb(vcp_error_e error, const char* msg, void *user_data)
+int vcd_send_error(vce_error_e error, const char* msg, void *user_data)
 {
        SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Engine Error cb - reason(%d), msg(%s)", error, msg);
        ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL);
 
        char* error_msg = NULL;
-       error_msg = strdup(msg);
+       if (NULL != msg) {
+               error_msg = strdup(msg);
+       }
 
        if (0 != vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), error, error_msg)) {
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to send error signal");
@@ -885,7 +928,7 @@ static void __vcd_server_error_cb(vcp_error_e error, const char* msg, void *user
                error_msg = NULL;
        }
 
-       return;
+       return VCD_ERROR_NONE;
 }
 
 /*
@@ -940,7 +983,7 @@ static int __vcd_db_clean_up()
        return ret;
 }
 
-int vcd_initialize()
+int vcd_initialize(vce_request_callback_s *callback)
 {
        int ret = 0;
 
@@ -961,8 +1004,7 @@ int vcd_initialize()
 
        vcd_config_set_service_state(VCD_STATE_NONE);
 
-       //ret = vcd_engine_agent_init(__vcd_server_pre_result_cb, __vcd_server_result_cb, __vcd_server_nlu_result_cb, __vcd_server_error_cb);
-       ret = vcd_engine_agent_init(__vcd_server_asr_result_cb, __vcd_server_result_cb, __vcd_server_error_cb);
+       ret = vcd_engine_agent_init();
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to engine agent initialize : result(%d)", ret);
                return ret;
@@ -973,21 +1015,8 @@ int vcd_initialize()
                return VCD_ERROR_OPERATION_FAILED;
        }
 
-       /* Find engine */
-       ret = vcd_engine_agent_initialize_current_engine();
-       if (0 != ret) {
-               if (VCD_ERROR_ENGINE_NOT_FOUND == ret)
-                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] There is No Voice control engine");
-               else
-                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to init engine");
-
-               g_is_engine = false;
-       } else {
-               g_is_engine = true;
-       }
-
        /* Load engine */
-       if (0 != vcd_engine_agent_load_current_engine()) {
+       if (0 != vcd_engine_agent_load_current_engine(callback)) {
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to load current engine");
                return VCD_ERROR_OPERATION_FAILED;
        }
@@ -998,7 +1027,7 @@ int vcd_initialize()
        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;
 }
@@ -1043,14 +1072,14 @@ void vcd_finalize()
        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;
 }
 
 static Eina_Bool __finalize_quit_ecore_loop(void *data)
 {
-       SLOG(LOG_DEBUG, TAG_VCD, "[Server] quit ecore main loop");
+       SLOG(LOG_ERROR, TAG_VCD, "[Server] quit ecore main loop");
        ecore_main_loop_quit();
        return EINA_FALSE;
 }
@@ -1113,7 +1142,7 @@ static void __vcd_cleanup_client(vcd_client_type_e type)
        }
 
        if (0 == ret || mgr_pid > 0) {
-               SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up %s client ", type ? (type == 1) ? "Widget" : "Manager" : "Normal");
+               SLOG(LOG_DEBUG, TAG_VCD, "@@@ Clean up %s client ", type ? (type == 1) ? "Widget" : "Manager" : "Normal");
                if (NULL != client_list && client_count > 0) {
                        for (i = 0; i < client_count; i++) {
                                exist = false;
@@ -1121,8 +1150,8 @@ static void __vcd_cleanup_client(vcd_client_type_e type)
                                for (j = 0; j < g_list_length(g_proc_list); j++) {
                                        iter = g_list_nth(g_proc_list, j);
                                        if (NULL != iter) {
-                                               if (client_list[i] == GPOINTER_TO_INT(iter->data)) {
-                                                       SLOG(LOG_DEBUG, TAG_VCD, "%s pid(%d) is running", type ? (type == 1) ? "Widget" : "Manager" : "Normal", client_list[i]);
+                                               if (*(client_list + i) == GPOINTER_TO_INT(iter->data)) {
+                                                       SLOG(LOG_DEBUG, TAG_VCD, "%s pid(%d) is running", type ? (type == 1) ? "Widget" : "Manager" : "Normal", *(client_list + i));
                                                        exist = true;
                                                        break;
                                                }
@@ -1130,18 +1159,17 @@ static void __vcd_cleanup_client(vcd_client_type_e type)
                                }
 
                                if (false == exist) {
-                                       SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == 1) ? "Widget" : "Manager" : "Normal", client_list[i]);
+                                       SLOG(LOG_ERROR, TAG_VCD, "%s pid(%d) should be removed", type ? (type == 1) ? "Widget" : "Manager" : "Normal", *(client_list + i));
                                        if (VCD_CLIENT_TYPE_NORMAL == type)
-                                               vcd_server_finalize(client_list[i]);
+                                               vcd_server_finalize(*(client_list + i));
                                        else if (VCD_CLIENT_TYPE_WIDGET == type)
-                                               vcd_server_widget_finalize(client_list[i]);
+                                               vcd_server_widget_finalize(*(client_list + i));
                                        else
                                                vcd_server_mgr_finalize(mgr_pid);
                                }
                        }
                }
-               SLOG(LOG_DEBUG, TAG_VCD, "=====");
-               SLOG(LOG_DEBUG, TAG_VCD, "  ");
+               SLOG(LOG_DEBUG, TAG_VCD, "@@@");
        }
        if (NULL != client_list && -1 == mgr_pid) {
                free(client_list);
@@ -1153,14 +1181,14 @@ static void __vcd_cleanup_client(vcd_client_type_e type)
 Eina_Bool vcd_cleanup_client_all(void *data)
 {
        __read_proc();
-       
+
        __vcd_cleanup_client(VCD_CLIENT_TYPE_NORMAL);
        __vcd_cleanup_client(VCD_CLIENT_TYPE_WIDGET);
        __vcd_cleanup_client(VCD_CLIENT_TYPE_MANAGER);
 
 #if 0
        if (0 == vcd_client_get_list(&client_list, &client_count)) {
-               SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up client ");
+               SLOG(LOG_DEBUG, TAG_VCD, "@@@ Clean up client ");
                if (NULL != client_list && client_count > 0) {
                        for (i = 0; i < client_count; i++) {
                                exist = false;
@@ -1192,8 +1220,7 @@ Eina_Bool vcd_cleanup_client_all(void *data)
 #endif
                        }
                }
-               SLOG(LOG_DEBUG, TAG_VCD, "=====");
-               SLOG(LOG_DEBUG, TAG_VCD, "  ");
+               SLOG(LOG_DEBUG, TAG_VCD, "@@@");
        }
        if (NULL != client_list) {
                free(client_list);
@@ -1202,7 +1229,7 @@ Eina_Bool vcd_cleanup_client_all(void *data)
 
        /* If app is in background state, app cannot response message. */
        if (0 == vcd_client_widget_get_list(&client_list, &client_count)) {
-               SLOG(LOG_DEBUG, TAG_VCD, "===== Clean up widget");
+               SLOG(LOG_DEBUG, TAG_VCD, "@@@ Clean up widget");
                if (NULL != client_list && client_count > 0) {
                        for (i = 0; i < client_count; i++) {
                                exist = false;
@@ -1234,8 +1261,7 @@ Eina_Bool vcd_cleanup_client_all(void *data)
 #endif
                        }
                }
-               SLOG(LOG_DEBUG, TAG_VCD, "=====");
-               SLOG(LOG_DEBUG, TAG_VCD, "  ");
+               SLOG(LOG_DEBUG, TAG_VCD, "@@@");
        }
 
        if (NULL != client_list) {
@@ -1286,16 +1312,6 @@ int vcd_server_get_foreground()
 */
 int vcd_server_mgr_initialize(int pid)
 {
-       if (false == g_is_engine) {
-               if (0 != vcd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
-                       g_is_engine = false;
-                       return VCD_ERROR_ENGINE_NOT_FOUND;
-               } else {
-                       g_is_engine = true;
-               }
-       }
-
        /* check if pid is valid */
        if (false == vcd_client_manager_is_valid(pid)) {
                SLOG(LOG_ERROR, TAG_VCD, "[Server] old manager pid(%d) be removed", vcd_client_manager_get_pid());
@@ -1312,7 +1328,7 @@ int vcd_server_mgr_initialize(int pid)
        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;
 }
@@ -1341,7 +1357,7 @@ int vcd_server_mgr_finalize(int pid)
                ecore_timer_add(0, __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;
 }
@@ -1396,7 +1412,7 @@ int vcd_server_mgr_set_audio_type(int pid, const char* audio_type)
        }
 
        int ret = 0;
-       vcp_audio_type_e type = VCP_AUDIO_TYPE_PCM_S16_LE;
+       vce_audio_type_e type = VCE_AUDIO_TYPE_PCM_S16_LE;
        int rate = 16000;
        int channel = 1;
 
@@ -1452,6 +1468,7 @@ int vcd_server_mgr_set_client_info(int pid)
 static int __start_internal_recognition()
 {
        int ret;
+       vcd_client_widget_set_waiting_for_recording(-1, false);
 
        if (0 != vcd_client_command_collect_command()) {
                SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to collect command");
@@ -1473,7 +1490,7 @@ static int __start_internal_recognition()
                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()) {
@@ -1493,8 +1510,9 @@ static int __start_internal_recognition()
                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 */
        ret = vcd_recorder_start();
        if (0 != ret) {
@@ -1506,11 +1524,12 @@ static int __start_internal_recognition()
                        vcdc_send_error_signal_to_manager(vcd_client_manager_get_pid(), VCD_ERROR_OPERATION_FAILED, "voice_engine.error.proc_fail");
                return ret;
        }
+#endif
 
        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;
 }
@@ -1519,7 +1538,7 @@ static Eina_Bool __vcd_request_show_tooltip(void *data)
 {
        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);
        }
 
@@ -1539,8 +1558,9 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive
                SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available.");
                return VCD_ERROR_OPERATION_FAILED;
        }
+       vcd_client_widget_set_waiting_for_recording(-1, false);
 
-       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) {
@@ -1549,8 +1569,9 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool 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_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);
+                               vcd_client_widget_set_waiting_for_recording(pid, true);
                                return 0;
                        }
                }
@@ -1571,6 +1592,8 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive
                }
        }
 
+       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);
@@ -1581,6 +1604,7 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive
                vcd_client_unset_exclusive_command(fg_pid);
        }
 
+       SLOG(LOG_ERROR, TAG_VCD, "[Server Success] start internal recognition");
        return VCD_ERROR_NONE;
 }
 
@@ -1595,9 +1619,12 @@ int vcd_server_mgr_stop()
                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_recorder_stop();
+#endif
 
        /* 3. Stop engine recognition */
        int ret = vcd_engine_recognize_stop();
@@ -1609,17 +1636,12 @@ int vcd_server_mgr_stop()
        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;
 }
 
 int vcd_server_mgr_cancel()
 {
-       /* 1. Check current state */
-       vcd_state_e state = vcd_config_get_service_state();
-       if (VCD_STATE_RECORDING != state && VCD_STATE_PROCESSING != state) {
-               SLOG(LOG_WARN, TAG_VCD, "[Server ERROR] Current state is not recording or processing");
-               return VCD_ERROR_INVALID_STATE;
-       }
        if (-1 == vcd_client_manager_get_pid()) {
                SLOG(LOG_DEBUG, TAG_VCD, "[Server] Manager is NOT available.");
                return VCD_ERROR_OPERATION_FAILED;
@@ -1631,8 +1653,32 @@ int vcd_server_mgr_cancel()
                g_restart_timer = NULL;
        }
 
+       /* 1. Check current state */
+       vcd_state_e state = vcd_config_get_service_state();
+       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_recorder_stop();
+#endif
+
        /* 3. Cancel engine */
        int ret = vcd_engine_recognize_cancel();
        if (0 != ret) {
@@ -1655,6 +1701,7 @@ int vcd_server_mgr_cancel()
        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;
 }
 
@@ -1767,6 +1814,8 @@ int vcd_server_mgr_do_action(int pid, int type, const char* action)
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to process do action : %d", ret);
        } else {
+               vcd_config_set_service_state(VCD_STATE_PROCESSING);
+               vcdc_send_service_state(VCD_STATE_PROCESSING);
                SLOG(LOG_DEBUG, TAG_VCD, "[Server SUCCESS] Process do action");
        }
 
@@ -1793,7 +1842,7 @@ int vcd_server_mgr_enable_command_type(int pid, int cmd_type)
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to enable command type");
        } else {
-               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Enable command type(%d)", cmd_type);
+               SLOG(LOG_ERROR, TAG_VCD, "[Server] Enable command type(%d)", cmd_type);
        }
 
        return ret;
@@ -1819,7 +1868,7 @@ int vcd_server_mgr_disable_command_type(int pid, int cmd_type)
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to disable command type");
        } else {
-               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Disable command type(%d)", cmd_type);
+               SLOG(LOG_ERROR, TAG_VCD, "[Server] Disable command type(%d)", cmd_type);
        }
 
        return ret;
@@ -1830,21 +1879,9 @@ int vcd_server_mgr_disable_command_type(int pid, int cmd_type)
 */
 int vcd_server_initialize(int pid)
 {
-       if (false == g_is_engine) {
-               if (0 != vcd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
-                       g_is_engine = false;
-                       return VCD_ERROR_ENGINE_NOT_FOUND;
-               } else {
-                       g_is_engine = true;
-               }
-       }
-
        if (false == vcd_engine_is_available_engine()) {
-               if (0 != vcd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
-                       return VCD_ERROR_ENGINE_NOT_FOUND;
-               }
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
+               return VCD_ERROR_ENGINE_NOT_FOUND;
        }
 
        /* check if pid is valid */
@@ -2147,21 +2184,9 @@ int vcd_server_request_cancel(int pid)
 */
 int vcd_server_widget_initialize(int pid)
 {
-       if (false == g_is_engine) {
-               if (0 != vcd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
-                       g_is_engine = false;
-                       return VCD_ERROR_ENGINE_NOT_FOUND;
-               } else {
-                       g_is_engine = true;
-               }
-       }
-
        if (false == vcd_engine_is_available_engine()) {
-               if (0 != vcd_engine_agent_initialize_current_engine()) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
-                       return VCD_ERROR_ENGINE_NOT_FOUND;
-               }
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] No Engine");
+               return VCD_ERROR_ENGINE_NOT_FOUND;
        }
 
        /* check if pid is valid */
@@ -2181,6 +2206,14 @@ int vcd_server_widget_initialize(int pid)
        return VCD_ERROR_NONE;
 }
 
+static void __vcd_server_widget_start_recording(void *data)
+{
+       if (0 != __start_internal_recognition()) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recongition");
+       }
+       vcd_client_widget_set_waiting_for_recording(-1, false);
+}
+
 int vcd_server_widget_finalize(int pid)
 {
        /* check if pid is valid */
@@ -2195,10 +2228,20 @@ int vcd_server_widget_finalize(int pid)
        }
 
        if (0 == vcd_client_get_ref_count()) {
-               SLOG(LOG_DEBUG, TAG_VCD, "[Server] connected client list is empty");
+               SLOG(LOG_ERROR, TAG_VCD, "[Server] connected client list is empty");
                ecore_timer_add(0, __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_INFO, 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;
 }
 
@@ -2218,6 +2261,7 @@ int vcd_server_widget_start_recording(int pid, bool widget_command)
                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);
@@ -2319,3 +2363,172 @@ int vcd_server_widget_enable_asr_result(int pid, bool enable)
 
        return ret;
 }
+
+int vcd_server_set_language(const char* language)
+{
+       int ret = VCD_ERROR_NONE;
+
+       ret = vcd_config_set_default_language(language);
+       if (0 != ret) {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Fail to set language : %d", ret);
+               return ret;
+       }
+
+       ret = vcd_engine_set_current_language(language);
+       if (0 != ret) {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Fail to set language : %d", ret);
+               return ret;
+       }
+
+       return ret;
+}
+/*
+* For engine service
+*/
+int vcd_get_foreach_command(vce_cmd_h vce_command, vce_command_cb callback, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get foreach command");
+
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] input parameter is NULL");
+               return VCD_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = 0;
+       ret = vcd_engine_agent_get_foreach_command(vce_command, callback, user_data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get foreach command : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
+int vcd_get_command_count(vce_cmd_h vce_command)
+{
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get command count");
+
+       int ret = 0;
+       ret = vcd_engine_agent_get_command_count(vce_command);
+       if (0 > ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get command count : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
+int vcd_get_audio_type(char** audio_type)
+{
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get audio type");
+
+       int ret = 0;
+       ret = vcd_engine_agent_get_audio_type(audio_type);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get audio type : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
+int vcd_set_private_data(const char* key, const char* data)
+{
+       vcd_state_e state = vcd_config_get_service_state();
+
+       if (VCD_STATE_READY != state) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state(%d) is NOT 'READY'", state);
+               return VCD_ERROR_INVALID_STATE;
+       }
+
+       int ret = vcd_engine_agent_set_private_data(key, data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data to the manager client : ret(%d)", ret);
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data to the manager client, key(%s), data(%s)", key, data);
+       }
+
+       return ret;
+}
+
+int vcd_get_private_data(const char* key, char** data)
+{
+       vcd_state_e state = vcd_config_get_service_state();
+
+       if (VCD_STATE_READY != state) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state(%d) is NOT 'READY'", state);
+               return VCD_ERROR_INVALID_STATE;
+       }
+
+       int ret = vcd_engine_agent_get_private_data(key, data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to get private data from the manager client : ret(%d)", ret);
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Get private data from the manager client, key(%s), data(%s)", key, data);
+       }
+
+       return ret;
+}
+
+int vcd_start_recording()
+{
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Start recording");
+
+       int ret = 0;
+       ret = vcd_engine_agent_start_recording();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to start recording : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
+int vcd_stop_recording()
+{
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Stop recording");
+
+       int ret = 0;
+       ret = vcd_engine_agent_stop_recording();
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to stop recording : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
+int vcd_set_private_data_set_cb(vce_private_data_set_cb callback_func)
+{
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data set cb");
+
+       int ret = 0;
+       ret = vcd_engine_agent_set_private_data_set_cb(callback_func);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data set cb : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
+int vcd_set_private_data_requested_cb(vce_private_data_requested_cb callback_func)
+{
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set private data requested cb");
+
+       int ret = 0;
+       ret = vcd_engine_agent_set_private_data_requested_cb(callback_func);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set private data requested cb : ret(%d)", ret);
+       }
+
+       return ret;
+}
+
+int vcd_set_nlu_base_info_requested_cb(vce_nlu_base_info_requested_cb callback_func)
+{
+       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Set nlu base info requested cb");
+
+       int ret = 0;
+       ret = vcd_engine_agent_set_nlu_base_info_requested_cb(callback_func);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to set nlu base info requested cb : ret(%d)", ret);
+       }
+
+       return ret;
+}
+