Correct to check return of fread
[platform/core/uifw/stt.git] / client / stt.c
index 76aa110..8a55d34 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  limitations under the License.
 */
 
-
-#include <sys/wait.h>
-#include <sys/types.h> 
-#include <unistd.h>
+#include <aul.h>
+#include <cynara-client.h>
+#include <cynara-error.h>
+#include <cynara-session.h>
+#include <dirent.h>
 #include <Ecore.h>
+#include <fcntl.h>
+#include <pthread.h>
 #include <sys/stat.h>
-#include <dirent.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <system_info.h>
+#include <unistd.h>
+#include <buxton2.h>
 
 #include "stt.h"
-#include "stt_main.h"
 #include "stt_client.h"
 #include "stt_dbus.h"
+#include "stt_config_mgr.h"
+#include "stt_internal.h"
+#include "stt_main.h"
 
-#define CONNECTION_RETRY_COUNT 3
 
-static bool g_is_daemon_started = false;
+static void __stt_notify_state_changed(void *data);
+static void __stt_notify_error(void *data);
 
 static Ecore_Timer* g_connect_timer = NULL;
+static float g_volume_db = 0;
+
+static int g_feature_enabled = -1;
+
+static int g_privilege_allowed = -1;
+static int g_privilege_applaunch_allowed = -1;
+
+static cynara *p_cynara = NULL;
+
+static bool g_err_callback_status = false;
+
+const char* stt_tag()
+{
+       return "sttc";
+}
+
+static int __stt_get_feature_enabled()
+{
+       if (0 == g_feature_enabled) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+               return STT_ERROR_NOT_SUPPORTED;
+       } else if (-1 == g_feature_enabled) {
+               bool stt_supported = false;
+               bool mic_supported = false;
+               if (0 == system_info_get_platform_bool(STT_FEATURE_PATH, &stt_supported)) {
+                       if (0 == system_info_get_platform_bool(STT_MIC_FEATURE_PATH, &mic_supported)) {
+                               if (false == stt_supported || false == mic_supported) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT NOT supported");
+                                       g_feature_enabled = 0;
+                                       return STT_ERROR_NOT_SUPPORTED;
+                               }
+
+                               g_feature_enabled = 1;
+                       } else {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get feature value");
+                               return STT_ERROR_NOT_SUPPORTED;
+                       }
+               } else {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get feature value");
+                       return STT_ERROR_NOT_SUPPORTED;
+               }
+       }
+
+       return 0;
+}
+
+static int __check_privilege_initialize()
+{
+       int ret = cynara_initialize(&p_cynara, NULL);
+       if (CYNARA_API_SUCCESS != ret)
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] fail to initialize");
+
+       return ret == CYNARA_API_SUCCESS;
+}
+
+static bool __check_privilege(const char* uid, const char * privilege)
+{
+       FILE *fp = NULL;
+       char label_path[1024] = "/proc/self/attr/current";
+       char smack_label[1024] = {'\0',};
+
+       if (!p_cynara) {
+               return false;
+       }
+
+       fp = fopen(label_path, "r");
+       if (fp != NULL) {
+               if (0 >= fread(smack_label, 1, sizeof(smack_label), fp))
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] fail to fread");
+
+               fclose(fp);
+       }
+
+       pid_t pid = getpid();
+       char *session = cynara_session_from_pid(pid);
+       int ret = cynara_check(p_cynara, smack_label, session, uid, privilege);
+       SLOG(LOG_DEBUG, TAG_STTC, "[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied");
+       if (session) {
+               free(session);
+               session = NULL;
+       }
+
+       if (ret != CYNARA_API_ACCESS_ALLOWED)
+               return false;
+       return true;
+}
+
+static void __check_privilege_deinitialize()
+{
+       if (p_cynara)
+               cynara_finish(p_cynara);
+       p_cynara = NULL;
+}
+
+static int __stt_check_privilege()
+{
+       char uid[16];
+
+       if (0 == g_privilege_allowed) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission is denied");
+               return STT_ERROR_PERMISSION_DENIED;
+       } else if (-1 == g_privilege_allowed) {
+               if (false == __check_privilege_initialize()) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] privilege initialize is failed");
+                       return STT_ERROR_PERMISSION_DENIED;
+               }
+               snprintf(uid, 16, "%d", getuid());
+               if (false == __check_privilege(uid, STT_PRIVILEGE_RECORDER)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission is denied");
+                       g_privilege_allowed = 0;
+                       __check_privilege_deinitialize();
+                       return STT_ERROR_PERMISSION_DENIED;
+               }
+               __check_privilege_deinitialize();
+       }
+
+       g_privilege_allowed = 1;
+       return STT_ERROR_NONE;
+}
+
+static int __stt_check_privilege_for_applaunch()
+{
+       char uid[16];
+
+       if (0 == g_privilege_applaunch_allowed) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission for applaunch is denied");
+               return STT_ERROR_PERMISSION_DENIED;
+       } else if (-1 == g_privilege_applaunch_allowed) {
+               if (false == __check_privilege_initialize()) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] privilege initialize is failed (applaunch)");
+                       return STT_ERROR_PERMISSION_DENIED;
+               }
+               snprintf(uid, 16, "%d", getuid());
+               if (false == __check_privilege(uid, STT_PRIVILEGE_APPLAUNCH)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Permission is denied : appmanager.launch");
+                       g_privilege_applaunch_allowed = 0;
+                       __check_privilege_deinitialize();
+                       return STT_ERROR_PERMISSION_DENIED;
+               }
+               __check_privilege_deinitialize();
+       }
+
+       g_privilege_applaunch_allowed = 1;
+       return STT_ERROR_NONE;
+}
+
+static const char* __stt_get_error_code(stt_error_e err)
+{
+       switch (err) {
+       case STT_ERROR_NONE:                    return "STT_ERROR_NONE";
+       case STT_ERROR_OUT_OF_MEMORY:           return "STT_ERROR_OUT_OF_MEMORY";
+       case STT_ERROR_IO_ERROR:                return "STT_ERROR_IO_ERROR";
+       case STT_ERROR_INVALID_PARAMETER:       return "STT_ERROR_INVALID_PARAMETER";
+       case STT_ERROR_TIMED_OUT:               return "STT_ERROR_TIMED_OUT";
+       case STT_ERROR_RECORDER_BUSY:           return "STT_ERROR_RECORDER_BUSY";
+       case STT_ERROR_OUT_OF_NETWORK:          return "STT_ERROR_OUT_OF_NETWORK";
+       case STT_ERROR_PERMISSION_DENIED:       return "STT_ERROR_PERMISSION_DENIED";
+       case STT_ERROR_NOT_SUPPORTED:           return "STT_ERROR_NOT_SUPPORTED";
+       case STT_ERROR_INVALID_STATE:           return "STT_ERROR_INVALID_STATE";
+       case STT_ERROR_INVALID_LANGUAGE:        return "STT_ERROR_INVALID_LANGUAGE";
+       case STT_ERROR_ENGINE_NOT_FOUND:        return "STT_ERROR_ENGINE_NOT_FOUND";
+       case STT_ERROR_OPERATION_FAILED:        return "STT_ERROR_OPERATION_FAILED";
+       case STT_ERROR_NOT_SUPPORTED_FEATURE:   return "STT_ERROR_NOT_SUPPORTED_FEATURE";
+       case STT_ERROR_SERVICE_RESET:           return "STT_ERROR_SERVICE_RESET";
+       default:
+               return "Invalid error code";
+       }
+}
+
+static int __stt_convert_config_error_code(stt_config_error_e code)
+{
+       if (code == STT_CONFIG_ERROR_NONE)                      return STT_ERROR_NONE;
+       if (code == STT_CONFIG_ERROR_OUT_OF_MEMORY)             return STT_ERROR_OUT_OF_MEMORY;
+       if (code == STT_CONFIG_ERROR_IO_ERROR)                  return STT_ERROR_IO_ERROR;
+       if (code == STT_CONFIG_ERROR_INVALID_PARAMETER)         return STT_ERROR_INVALID_PARAMETER;
+       if (code == STT_CONFIG_ERROR_PERMISSION_DENIED)         return STT_ERROR_PERMISSION_DENIED;
+       if (code == STT_CONFIG_ERROR_NOT_SUPPORTED)             return STT_ERROR_NOT_SUPPORTED;
+       if (code == STT_CONFIG_ERROR_INVALID_STATE)             return STT_ERROR_INVALID_STATE;
+       if (code == STT_CONFIG_ERROR_INVALID_LANGUAGE)          return STT_ERROR_INVALID_LANGUAGE;
+       if (code == STT_CONFIG_ERROR_ENGINE_NOT_FOUND)          return STT_ERROR_ENGINE_NOT_FOUND;
+       if (code == STT_CONFIG_ERROR_OPERATION_FAILED)          return STT_ERROR_OPERATION_FAILED;
+
+       return code;
+}
+
+void __stt_config_lang_changed_cb(const char* before_language, const char* current_language, void* user_data)
+{
+       SLOG(LOG_DEBUG, TAG_STTC, "Language changed : Before lang(%s) Current lang(%s)",
+               before_language, current_language);
+
+       if (0 == strcmp(before_language, current_language)) {
+               return;
+       }
+
+       GList* client_list = NULL;
+       client_list = stt_client_get_client_list();
+
+       GList *iter = NULL;
+       stt_client_s *data = NULL;
+
+       if (g_list_length(client_list) > 0) {
+               /* Get a first item */
+               iter = g_list_first(client_list);
+
+               while (NULL != iter) {
+                       data = iter->data;
+                       if (NULL != data->default_lang_changed_cb) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "Call default language changed callback : uid(%d)", data->uid);
+                               data->default_lang_changed_cb(data->stt, before_language, current_language,
+                                       data->default_lang_changed_user_data);
+                       }
 
-static int __check_stt_daemon();
-static Eina_Bool __stt_notify_state_changed(void *data);
-static Eina_Bool __stt_notify_error(void *data);
+                       /* Next item */
+                       iter = g_list_next(iter);
+               }
+       }
+
+       return;
+}
+
+static Eina_Bool __reconnect_by_engine_changed(void *data)
+{
+       stt_h stt = (stt_h)data;
+
+       stt_client_s* client = stt_client_get(stt);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[WARNING] A handle is not valid");
+               return EINA_FALSE;
+       }
+
+       if (STT_STATE_READY != client->current_state) {
+               usleep(10000);
+               return EINA_TRUE;
+       }
+
+       int ret = stt_unprepare(stt);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+       }
+       ret = stt_prepare(stt);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+       }
+
+       return EINA_FALSE;
+}
+
+void __stt_config_engine_changed_cb(const char* engine_id, const char* setting, const char* language, bool support_silence, bool need_credential, void* user_data)
+{
+       stt_h stt = (stt_h)user_data;
+
+       stt_client_s* client = stt_client_get(stt);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[WARNING] A handle is not valid");
+               return;
+       }
+
+       if (NULL != engine_id)  SLOG(LOG_DEBUG, TAG_STTC, "Engine id(%s)", engine_id);
+       if (NULL != setting)    SLOG(LOG_DEBUG, TAG_STTC, "Engine setting(%s)", setting);
+       if (NULL != language)   SLOG(LOG_DEBUG, TAG_STTC, "Language(%s)", language);
+       SLOG(LOG_DEBUG, TAG_STTC, "Silence(%s), Credential(%s)", support_silence ? "on" : "off", need_credential ? "need" : "no need");
+
+       /* When the default engine is changed, please unload the old engine and load the new one. */
+       int ret = -1;
+
+       if (NULL == client->current_engine_id) {
+               if (STT_STATE_RECORDING == client->current_state || STT_STATE_PROCESSING == client->current_state) {
+                       ret = stt_cancel(stt);
+                       if (0 != ret) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "[DEBUG] STT client canceling...");
+                       }
+
+                       ecore_idler_add(__reconnect_by_engine_changed, (void*)stt);
+               } else if (STT_STATE_READY == client->current_state) {
+                       ret = stt_unprepare(stt);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+                       }
+                       ret = stt_prepare(stt);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare for setting a new engine... (%d)", ret);
+                       }
+               }
+       }
+
+       /* call callback function */
+       if (NULL != client->engine_changed_cb) {
+               client->engine_changed_cb(stt, engine_id, language, support_silence, need_credential, client->engine_changed_user_data);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "No registered callback function for engine change");
+       }
+       return;
+}
+
+static int __stt_check_handle(stt_h stt, stt_client_s** client)
+{
+       if (NULL == stt) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input handle is null");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       stt_client_s* temp = NULL;
+       temp = stt_client_get(stt);
+
+       /* check handle */
+       if (NULL == temp) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+       *client = temp;
+
+       return STT_ERROR_NONE;
+}
 
 int stt_create(stt_h* stt)
 {
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== Create STT");
 
        if (NULL == stt) {
@@ -55,6 +380,29 @@ int stt_create(stt_h* stt)
                return STT_ERROR_OUT_OF_MEMORY;
        }
 
+       stt_client_s* client = stt_client_get(*stt);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to create client");
+               stt_client_destroy(*stt);
+               return STT_ERROR_OPERATION_FAILED;
+       }
+
+       int ret = stt_config_mgr_initialize(client->uid);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to init config manager : %s", __stt_get_error_code(ret));
+               stt_client_destroy(*stt);
+               return ret;
+       }
+
+       ret = stt_config_mgr_set_callback(client->uid, __stt_config_engine_changed_cb, __stt_config_lang_changed_cb, NULL, client->stt);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set config changed : %s", __stt_get_error_code(ret));
+               stt_client_destroy(*stt);
+               return ret;
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "[Success] uid(%d)", (*stt)->handle);
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -65,29 +413,27 @@ int stt_create(stt_h* stt)
 
 int stt_destroy(stt_h stt)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Destroy STT");
-
-       if (NULL == stt) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input handle is null");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_ERROR_INVALID_PARAMETER;
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
-       
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Destroy STT");
+
        /* check used callback */
        if (0 != stt_client_get_use_callback(client)) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Cannot destroy in Callback function");
                return STT_ERROR_OPERATION_FAILED;
        }
 
+       stt_config_mgr_finalize(client->uid);
+
        int ret = -1;
 
        /* check state */
@@ -97,103 +443,579 @@ int stt_destroy(stt_h stt)
        case STT_STATE_READY:
                ret = stt_dbus_request_finalize(client->uid);
                if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request finalize");
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request finalize : %s", __stt_get_error_code(ret));
                }
-               g_is_daemon_started = false;
        case STT_STATE_CREATED:
                if (NULL != g_connect_timer) {
                        SLOG(LOG_DEBUG, TAG_STTC, "Connect Timer is deleted");
                        ecore_timer_del(g_connect_timer);
+                       g_connect_timer = NULL;
                }
+
                /* Free resources */
                stt_client_destroy(stt);
                break;
+       default:
+               break;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTC, "Success: destroy");
-
        if (0 == stt_client_get_size()) {
                if (0 != stt_dbus_close_connection()) {
                        SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to close connection");
                }
        }
 
+       stt = NULL;
+
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
        return STT_ERROR_NONE;
 }
 
-static Eina_Bool __stt_connect_daemon(void *data)
+bool __stt_config_supported_engine_cb(const char* engine_id, const char* engine_name,
+                                     const char* setting, bool support_silence, void* user_data)
 {
-       stt_h stt = (stt_h)data;
+       stt_h stt = (stt_h)user_data;
 
        stt_client_s* client = stt_client_get(stt);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[WARNING] A handle is not valid");
+               return false;
+       }
+
+       /* call callback function */
+       if (NULL != client->supported_engine_cb) {
+               return client->supported_engine_cb(stt, engine_id, engine_name, client->supported_engine_user_data);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "No registered callback function of supported engine");
+       }
+
+       return false;
+}
+
+int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported engine");
+
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (client->current_state != STT_STATE_CREATED) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       client->supported_engine_cb = callback;
+       client->supported_engine_user_data = user_data;
+
+       int ret = 0;
+       ret = stt_config_mgr_get_engine_list(__stt_config_supported_engine_cb, client->stt);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get engines : %s", __stt_get_error_code(ret));
+       }
+
+       client->supported_engine_cb = NULL;
+       client->supported_engine_user_data = NULL;
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return ret;
+}
+
+int stt_get_engine(stt_h stt, char** engine_id)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Get current engine");
+
+       if (NULL == engine_id) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (client->current_state != STT_STATE_CREATED) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       int ret = 0;
+
+       if (NULL != client->current_engine_id) {
+               *engine_id = strdup(client->current_engine_id);
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current engine uuid = %s", *engine_id);
+       } else {
+
+               ret = stt_config_mgr_get_engine(engine_id);
+               ret = __stt_convert_config_error_code(ret);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request get current engine : %s", __stt_get_error_code(ret));
+               } else {
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current engine uuid = %s", *engine_id);
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return ret;
+}
+
+int __stt_set_buxtonkey(const char* engine_id)
+{
+       /* Set vconfkey */
+       struct buxton_client * bux_cli;
+       struct buxton_layer * bux_layer;
+       struct buxton_value * bux_val;
+
+       int ret = buxton_open(&bux_cli, NULL, NULL);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] Fail to open buxton client");
+               return STT_ERROR_OPERATION_FAILED;
+       }
+       SLOG(LOG_DEBUG, stt_tag(), "[DBUS-BUXTON2] buxton_open: %d", ret);
+       bux_layer = buxton_create_layer("system");
+       if (NULL == bux_layer) {
+               SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] buxton_create_layer FAIL");
+               buxton_close(bux_cli);
+               bux_cli = NULL;
+               return STT_ERROR_OPERATION_FAILED;
+       }
+       bux_val = buxton_value_create_string(engine_id);
+       if (NULL == bux_val) {
+               SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] buxton_value_create_string FAIL");
+               buxton_free_layer(bux_layer);
+               buxton_close(bux_cli);
+               bux_layer = NULL;
+               bux_cli = NULL;
+               return STT_ERROR_OPERATION_FAILED;
+       }
+
+       ret = buxton_set_value_sync(bux_cli, bux_layer, STT_ENGINE_DB_CUSTOM, bux_val);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] Fail to set value sync");
+               buxton_value_free(bux_val);
+               buxton_free_layer(bux_layer);
+               buxton_close(bux_cli);
+
+               bux_cli = NULL;
+               bux_layer = NULL;
+               bux_val = NULL;
+               return STT_ERROR_OPERATION_FAILED;
+       }
+       SLOG(LOG_DEBUG, stt_tag(), "[DBUS-BUXTON2] buxton_set_value_sync: %d, %s", ret, STT_ENGINE_DB_CUSTOM);
+
+       buxton_value_free(bux_val);
+       buxton_free_layer(bux_layer);
+       buxton_close(bux_cli);
+
+       bux_cli = NULL;
+       bux_layer = NULL;
+       bux_val = NULL;
+
+       return STT_ERROR_NONE;
+}
+
+int stt_set_engine(stt_h stt, const char* engine_id)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_privilege_for_applaunch()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Set current engine");
+
+       if (NULL == engine_id) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (client->current_state != STT_STATE_CREATED) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not CREATED", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (NULL != client->current_engine_id) {
+               free(client->current_engine_id);
+               client->current_engine_id = NULL;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== engined_id(%s)", engine_id);
+
+       client->current_engine_id = strdup(engine_id);
+
+       /* Set vconfkey */
+       int ret = __stt_set_buxtonkey(engine_id);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] set buxtonkey Failed!!!");
+               return ret;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return 0;
+}
+
+int stt_set_credential(stt_h stt, const char* credential)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Set credential");
+
+       if (NULL == credential) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (client->current_state != STT_STATE_CREATED && client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not CREATED or READY", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (NULL != client->credential) {
+               free(client->credential);
+               client->credential = NULL;
+       }
+       client->credential = strdup(credential);
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return STT_ERROR_NONE;
+}
+
+int stt_set_private_data(stt_h stt, const char* key, const char* data)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Set private data");
+
+       if (NULL == key || NULL == data) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid parameter");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (STT_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (true != client->internal && (0 == strcmp(key, "server") || 0 == strcmp(key, "rampcode") || 0 == strcmp(key, "epd"))) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] This is not an internal app");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_set_private_data(client->uid, key, data);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set private data : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry : %s", __stt_get_error_code(ret));
+                               usleep(10000);
+                               count++;
+                               if (STT_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, "");
+
+       return STT_ERROR_NONE;
+
+}
+int stt_get_private_data(stt_h stt, const char* key, char** data)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Get private data");
+
+       if (NULL == key || NULL == data) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid parameter");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* check state */
+       if (STT_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_get_private_data(client->uid, key, data);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get private data : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry : %s", __stt_get_error_code(ret));
+                               usleep(10000);
+                               count++;
+                               if (STT_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               }
+       }
+
+       if (0 == strncmp(*data, "NULL", strlen(*data))) {
+               free(*data);
+               *data = NULL;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, "");
+
+       return STT_ERROR_NONE;
+}
+
+int stt_set_server_stt(stt_h stt, const char* key, char* user_data)
+{
+       int ret = -1;
+       stt_client_s* client = NULL;
+
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Set STT server");
+
+       if (NULL == key || NULL == user_data) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid parameter");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (STT_STATE_CREATED != client->current_state && STT_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] The current state is invalid (%d).", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+
+       client->internal = true;
+
+       char* private_key = NULL;
+       private_key = strdup(key);
+       if (NULL == private_key) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory(private_key)");
+               return STT_ERROR_OUT_OF_MEMORY;
+       }
+
+       char* data = NULL;
+       data = strdup(user_data);
+       if (NULL == data) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory(data)");
+               free(private_key);
+               private_key = NULL;
+               return STT_ERROR_OUT_OF_MEMORY;
+       }
+
+       ret = stt_set_private_data(stt, private_key, data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set private data, ret(%d), key(%s)", ret, private_key);
+       }
+
+       free(data);
+       data = NULL;
+       free(private_key);
+       private_key = NULL;
+
+       SLOG(LOG_DEBUG, TAG_STTC, "======");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return ret;
+}
+
+static Eina_Bool __stt_connect_daemon(void *data)
+{
+       stt_client_s* client = (stt_client_s*)data;
+       int ret = -1;
 
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               return STT_ERROR_INVALID_PARAMETER;
+               g_connect_timer = NULL;
+               return EINA_FALSE;
+       }
+
+       if (0 == stt_client_get_size() || NULL == stt_client_get_by_uid(client->uid)) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Client has been already destroyed");
+               return EINA_FALSE;
+       }
+
+       /* Check and Set vconfkey of custom engine before sending hello */
+       if (1 == g_privilege_applaunch_allowed && NULL != client->current_engine_id) {
+               /* Set vconfkey */
+               ret = __stt_set_buxtonkey(client->current_engine_id);
+               if (0 != ret) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "[DEBUG] set buxtonkey Failed!!! (inside __stt_connect_daemon)");
+                       return EINA_TRUE;
+               }
        }
 
        /* Send hello */
-       if (0 != stt_dbus_request_hello()) {
-               if (false == g_is_daemon_started) {
-                       g_is_daemon_started = true;
-                       __check_stt_daemon();
+       ret = stt_dbus_request_hello(client->uid);
+
+       if (0 != ret) {
+               if (STT_ERROR_INVALID_STATE == ret) {
+                       g_connect_timer = NULL;
+                       return EINA_FALSE;
                }
                return EINA_TRUE;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Connect daemon");
+       g_connect_timer = NULL;
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Connect stt-service");
 
        /* request initialization */
-       int ret = -1;
-       int i = 1;
        bool silence_supported = false;
-       bool profanity_supported = false;
-       bool punctuation_supported = false;
+       bool credential_needed = false;
 
-       while (1) {
-               ret = stt_dbus_request_initialize(client->uid, &silence_supported, &profanity_supported, &punctuation_supported);
+       ret = stt_dbus_request_initialize(client->uid, &silence_supported, &credential_needed);
 
-               if (STT_ERROR_ENGINE_NOT_FOUND == ret) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : STT Engine Not found");
-                       
-                       client->reason = STT_ERROR_ENGINE_NOT_FOUND;
+       if (STT_ERROR_ENGINE_NOT_FOUND == ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : %s", __stt_get_error_code(ret));
 
-                       ecore_timer_add(0, __stt_notify_error, (void*)stt);
+               client->reason = STT_ERROR_ENGINE_NOT_FOUND;
+               ecore_main_loop_thread_safe_call_async(__stt_notify_error, (void*)client);
 
-                       return EINA_FALSE;
-
-               } else if(0 != ret) {
-                       usleep(1);
-                       if(CONNECTION_RETRY_COUNT == i) {
-                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : TIMED OUT");
-
-                               client->reason = STT_ERROR_TIMED_OUT;
-
-                               ecore_timer_add(0, __stt_notify_error, (void*)stt);
+               return EINA_FALSE;
 
-                               return EINA_FALSE;
-                       }    
-                       i++;
-               } else {
-                       /* success to connect stt-daemon */
-                       stt_client_set_option_supported(client->stt, silence_supported, profanity_supported, punctuation_supported);
-                       SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s), profanity(%s), punctuation(%s)", 
-                               silence_supported ? "true" : "false", profanity_supported ? "true" : "false", punctuation_supported ? "true" : "false");
-                       break;
+       } else if (STT_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[WARNING] Fail to connection. Retry to connect");
+               return EINA_TRUE;
+       } else {
+               /* success to connect stt-service */
+               client->silence_supported = silence_supported;
+               client->credential_needed = credential_needed;
+               SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s), credential(%s)", silence_supported ? "support" : "no support", credential_needed ? "need" : "no need");
+       }
+
+#ifdef __UNUSED_CODES__
+       if (NULL != client->current_engine_id) {
+               ret = -1;
+               int count = 0;
+               silence_supported = false;
+               credential_needed = false;
+               SLOG(LOG_DEBUG, TAG_STTC, "[WARNING] current_engine_id(%s)", client->current_engine_id);
+
+               while (0 != ret) {
+                       ret = stt_dbus_request_set_current_engine(client->uid, client->current_engine_id, &silence_supported, &credential_needed);
+                       if (0 != ret) {
+                               if (STT_ERROR_TIMED_OUT != ret) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set current engine : %s", __stt_get_error_code(ret));
+                                       return ret;
+                               } else {
+                                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                                       usleep(10000);
+                                       count++;
+                                       if (STT_RETRY_COUNT == count) {
+                                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                               return ret;
+                                       }
+                               }
+                       } else {
+                               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current engine uuid = %s", client->current_engine_id);
+
+                               /* success to change engine */
+                               client->silence_supported = silence_supported;
+                               SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s), credential(%s)", silence_supported ? "support" : "no support", credential_needed ? "need" : "no need");
+                       }
                }
        }
+#endif
+       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] uid(%d)", client->uid);
 
        client->before_state = client->current_state;
        client->current_state = STT_STATE_READY;
 
-       ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
-
-       g_connect_timer = NULL;
-
-       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] uid(%d)", client->uid);
+       if (NULL != client->state_changed_cb) {
+               stt_client_use_callback(client);
+               client->state_changed_cb(client->stt, client->before_state,
+                       client->current_state, client->state_changed_user_data);
+               stt_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+       }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, "  ");
@@ -201,30 +1023,26 @@ static Eina_Bool __stt_connect_daemon(void *data)
        return EINA_FALSE;
 }
 
-
 int stt_prepare(stt_h stt)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Prepare STT");
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
        /* check state */
        if (client->current_state != STT_STATE_CREATED) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not 'CREATED'"); 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not 'CREATED'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       g_connect_timer = ecore_timer_add(0, __stt_connect_daemon, (void*)stt);
+       g_connect_timer = ecore_timer_add(0.02, __stt_connect_daemon, (void*)client);
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -234,34 +1052,63 @@ int stt_prepare(stt_h stt)
 
 int stt_unprepare(stt_h stt)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Unprepare STT");
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Unprepare STT");
+
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not 'READY'"); 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not 'READY'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       int ret = stt_dbus_request_finalize(client->uid);
-       if (0 != ret) {
-               SLOG(LOG_WARN, TAG_STTC, "[ERROR] Fail to request finalize");
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_finalize(client->uid);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request finalize : %s", __stt_get_error_code(ret));
+                               break;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10000);
+                               count++;
+                               if (STT_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       break;
+                               }
+                       }
+               }
        }
-       g_is_daemon_started = false;
+
+       client->internal_state = STT_INTERNAL_STATE_NONE;
 
        client->before_state = client->current_state;
        client->current_state = STT_STATE_CREATED;
 
-       ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+       if (NULL != client->state_changed_cb) {
+               stt_client_use_callback(client);
+               client->state_changed_cb(client->stt, client->before_state,
+                       client->current_state, client->state_changed_user_data);
+               stt_client_not_use_callback(client);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+       }
+
+       if (g_connect_timer) {
+               ecore_timer_del(g_connect_timer);
+               g_connect_timer = NULL;
+       }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -269,80 +1116,112 @@ int stt_unprepare(stt_h stt)
        return STT_ERROR_NONE;
 }
 
+bool __stt_config_supported_language_cb(const char* engine_id, const char* language, void* user_data)
+{
+       stt_h stt = (stt_h)user_data;
+
+       stt_client_s* client = stt_client_get(stt);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "[WARNING] A handle is not valid");
+               return false;
+       }
+
+       /* call callback function */
+       if (NULL != client->supported_lang_cb) {
+               return client->supported_lang_cb(stt, language, client->supported_lang_user_data);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "No registered callback function of supported languages");
+       }
+
+       return false;
+}
+
 int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data)
 {
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
        SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported Language");
 
-       if (NULL == stt || NULL == callback) {
+       if (NULL == callback) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
+       int ret;
+       char* current_engine_id = NULL;
 
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_ERROR_INVALID_PARAMETER;
+       if (NULL == client->current_engine_id) {
+               ret = stt_config_mgr_get_engine(&current_engine_id);
+               ret = __stt_convert_config_error_code(ret);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get default engine id : %s", __stt_get_error_code(ret));
+                       return ret;
+               }
+       } else {
+               current_engine_id = strdup(client->current_engine_id);
+               if (NULL == current_engine_id) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
+                       return STT_ERROR_OUT_OF_MEMORY;
+               }
        }
 
-       /* check state */
-       if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
-               return STT_ERROR_INVALID_STATE;
-       }
+       client->supported_lang_cb = callback;
+       client->supported_lang_user_data = user_data;
 
-       int ret = 0;
-       ret = stt_dbus_request_get_support_langs(client->uid, client->stt, callback, user_data);
+       ret = stt_config_mgr_get_language_list(current_engine_id, __stt_config_supported_language_cb, client->stt);
+       ret = __stt_convert_config_error_code(ret);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get languages");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get languages : %s", __stt_get_error_code(ret));
+       }
+
+       if (NULL != current_engine_id) {
+               free(current_engine_id);
+               current_engine_id = NULL;
        }
 
+       client->supported_lang_cb = NULL;
+       client->supported_lang_user_data = NULL;
+
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
-       return STT_ERROR_NONE;
+       return ret;
 }
 
-
 int stt_get_default_language(stt_h stt, char** language)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== Get Default Language");
-
-       if (NULL == stt || NULL == language) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
+       SLOG(LOG_DEBUG, TAG_STTC, "===== Get Default Language");
 
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       if (NULL == language) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       /* check state */
-       if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
-               return STT_ERROR_INVALID_STATE;
-       }
-
        int ret = 0;
-       ret = stt_dbus_request_get_default_lang(client->uid, language);
-
+       ret = stt_config_mgr_get_default_language(language);
+       ret = __stt_convert_config_error_code(ret);
        if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail : request get default language");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get default language : %s", __stt_get_error_code(ret));
        } else {
                SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current language = %s", *language);
        }
@@ -355,159 +1234,357 @@ int stt_get_default_language(stt_h stt, char** language)
 
 int stt_get_state(stt_h stt, stt_state_e* state)
 {
-       if (NULL == stt || NULL == state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
-
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
+       if (NULL == state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
        *state = client->current_state;
 
-       switch(*state) {
-               case STT_STATE_CREATED:         SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'CREATED'");        break;
-               case STT_STATE_READY:           SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Ready'");          break;
-               case STT_STATE_RECORDING:       SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Recording'");      break;
-               case STT_STATE_PROCESSING:      SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Processing'");     break;
+       switch (*state) {
+       case STT_STATE_CREATED:         SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'CREATED'");        break;
+       case STT_STATE_READY:           SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Ready'");          break;
+       case STT_STATE_RECORDING:       SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Recording'");      break;
+       case STT_STATE_PROCESSING:      SLOG(LOG_DEBUG, TAG_STTC, "Current state is 'Processing'");     break;
+       default:                        SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid value");             break;
        }
 
        return STT_ERROR_NONE;
 }
 
-int stt_is_partial_result_supported(stt_h stt, bool* partial_result)
+int stt_get_error_message(stt_h stt, char** err_msg)
 {
-       if (NULL == stt || NULL == partial_result) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
-
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not valid");
+       if (NULL == err_msg) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       /* check state */
-       if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
-               return STT_ERROR_INVALID_STATE;
+       if (false == g_err_callback_status) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] This callback should be called during an err_callback");
+               return STT_ERROR_OPERATION_FAILED;
        }
 
-       int ret = 0;
-       ret = stt_dbus_request_is_partial_result_supported(client->uid, partial_result);
-
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get partial result supported");
+       if (NULL != client->err_msg) {
+               *err_msg = strdup(client->err_msg);
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Error msg (%s)", *err_msg);
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Partial result supporting is %s", *partial_result ? "true " : "false");
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Error msg (NULL)");
        }
 
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
        return STT_ERROR_NONE;
 }
 
-int stt_set_profanity_filter(stt_h stt, stt_option_profanity_e type)
+int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support)
 {
-       if (NULL == stt) {
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == type || NULL == support) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
 
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_is_recognition_type_supported(client->uid, type, support);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get recognition type supported : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10000);
+                               count++;
+                               if (STT_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] recognition type is %s", *support ? "true " : "false");
+                       break;
+               }
+       }
+
+       return STT_ERROR_NONE;
+}
+
+int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       if (true == client->profanity_supported) {
-               if (type >= STT_OPTION_PROFANITY_FALSE && type <= STT_OPTION_PROFANITY_AUTO)
-                       client->profanity = type;       
-               else {
+       if (true == client->silence_supported) {
+               if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO) {
+                       client->silence = type;
+               else {
                        SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
                        return STT_ERROR_INVALID_PARAMETER;
                }
        } else {
-               return STT_ERROR_NOT_SUPPORTED_FEATURE; 
+               return STT_ERROR_NOT_SUPPORTED_FEATURE;
        }
 
        return STT_ERROR_NONE;
 }
 
-int stt_set_punctuation_override(stt_h stt, stt_option_punctuation_e type)
+int stt_set_start_sound(stt_h stt, const char* filename)
 {
-       if (NULL == stt) {
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT SET START SOUND");
+
+       if (NULL == filename) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
+       if (0 != access(filename, F_OK)) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] File does not exist");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
 
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_set_start_sound(client->uid, filename);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set start sound : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10000);
+                               count++;
+                               if (STT_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set start sound : %s", filename);
+                       break;
+               }
+       }
+
+       return STT_ERROR_NONE;
+}
+
+int stt_unset_start_sound(stt_h stt)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
-       
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET START SOUND");
+
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       if (true == client->punctuation_supported) {
-               if (type >= STT_OPTION_PUNCTUATION_FALSE && type <= STT_OPTION_PUNCTUATION_AUTO)
-                       client->punctuation = type;     
-               else {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
-                       return STT_ERROR_INVALID_PARAMETER;
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_unset_start_sound(client->uid);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to unset start sound : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10000);
+                               count++;
+                               if (STT_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Unset start sound");
+                       break;
                }
-       } else {
-               return STT_ERROR_NOT_SUPPORTED_FEATURE; 
        }
 
        return STT_ERROR_NONE;
 }
 
-int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
+int stt_set_stop_sound(stt_h stt, const char* filename)
 {
-       if (NULL == stt) {
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT SET STOP SOUND");
+
+       if (NULL == filename) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
+       if (0 != access(filename, F_OK)) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] File does not exist");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
 
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_set_stop_sound(client->uid, filename);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to set stop sound : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10000);
+                               count++;
+                               if (STT_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set stop sound : %s", filename);
+                       break;
+               }
+       }
+
+       return STT_ERROR_NONE;
+}
+
+int stt_unset_stop_sound(stt_h stt)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET STOP SOUND");
+
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       if (true == client->silence_supported) {
-               if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO)
-                       client->silence = type; 
-               else {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
-                       return STT_ERROR_INVALID_PARAMETER;
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = stt_dbus_request_unset_stop_sound(client->uid);
+               if (0 != ret) {
+                       if (STT_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to unset stop sound : %s", __stt_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_STTC, "[WARNING] retry");
+                               usleep(10000);
+                               count++;
+                               if (STT_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               } else {
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Unset stop sound");
+                       break;
                }
-       } else {
-               return STT_ERROR_NOT_SUPPORTED_FEATURE; 
        }
 
        return STT_ERROR_NONE;
@@ -515,56 +1592,70 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
 
 int stt_start(stt_h stt, const char* language, const char* type)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== STT START");
-
-       if (NULL == stt) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_ERROR_INVALID_PARAMETER;
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT START");
+
        /* check state */
        if (client->current_state != STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not READY"); 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       char* temp;
+       if (STT_INTERNAL_STATE_NONE != client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is NOT none : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+       }
+
+       int ret = -1;
+       char appid[1024] = {0, };
+       ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1);
+
+       if ((AUL_R_OK != ret) || (0 == strlen(appid))) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get application ID");
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[DEBUG] Current app id is %s", appid);
+       }
+
+       char* temp = NULL;
        if (NULL == language) {
                temp = strdup("default");
        } else {
                temp = strdup(language);
        }
 
-       int ret; 
-       /* do request */
-       ret = stt_dbus_request_start(client->uid, temp, type, client->profanity, client->punctuation, client->silence);
-
-       if (ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
+       if (NULL == temp) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
+               return STT_ERROR_OUT_OF_MEMORY;
+       }
 
-               client->before_state = client->current_state;
-               client->current_state = STT_STATE_RECORDING;
+       if (true == client->credential_needed && NULL == client->credential) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Do not have app credential for this engine(%s)", client->current_engine_id);
+               free(temp);
+               temp = NULL;
+               return STT_ERROR_PERMISSION_DENIED;
+       }
 
-               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+       client->internal_state = STT_INTERNAL_STATE_STARTING;
+       ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid, client->credential);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : %s", __stt_get_error_code(ret));
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is successful but not done");
        }
 
        free(temp);
+       temp = NULL;
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -574,45 +1665,43 @@ int stt_start(stt_h stt, const char* language, const char* type)
 
 int stt_stop(stt_h stt)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== STT STOP");
-
-       if (NULL == stt) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] [ERROR] Input parameter is NULL");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT STOP");
 
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_ERROR_INVALID_PARAMETER;
-       }   
-       
        /* check state */
        if (client->current_state != STT_STATE_RECORDING) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Current state is NOT RECORDING"); 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Current state(%d) is NOT RECORDING", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       int ret = 0; 
-       /* do request */
-       ret = stt_dbus_request_stop(client->uid);
+       if (STT_INTERNAL_STATE_STARTING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STARTING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+       } else if (STT_INTERNAL_STATE_CANCELING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is CANCELING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_READY;
+       } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STOPPING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_PROCESSING;
+       }
+
+       client->internal_state = STT_INTERNAL_STATE_STOPPING;
+       int ret = stt_dbus_request_stop(client->uid);
        if (0 != ret) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Fail to stop");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to stop : %s", __stt_get_error_code(ret));
+               client->internal_state = STT_INTERNAL_STATE_NONE;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
-
-               client->before_state = client->current_state;
-               client->current_state = STT_STATE_PROCESSING;
-
-               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Stop is successful but not done");
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -624,45 +1713,43 @@ int stt_stop(stt_h stt)
 
 int stt_cancel(stt_h stt)
 {
-       SLOG(LOG_DEBUG, TAG_STTC, "===== STT CANCEL");
-
-       if (NULL == stt) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input handle is null");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-               return STT_ERROR_INVALID_PARAMETER;
-       }       
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT CANCEL");
 
        /* check state */
        if (STT_STATE_RECORDING != client->current_state && STT_STATE_PROCESSING != client->current_state) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : Current state is 'Ready'");
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid state : Current state(%d) is 'Ready'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       int ret; 
-       /* do request */
-       ret = stt_dbus_request_cancel(client->uid);
+       if (STT_INTERNAL_STATE_STARTING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STARTING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+       } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STOPPING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_PROCESSING;
+       } else if (STT_INTERNAL_STATE_CANCELING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is CANCELING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_READY;
+       }
+
+       client->internal_state = STT_INTERNAL_STATE_CANCELING;
+       int ret = stt_dbus_request_cancel(client->uid);
        if (0 != ret) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Fail to cancel");
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to cancel : %s", __stt_get_error_code(ret));
+               client->internal_state = STT_INTERNAL_STATE_NONE;
        } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
-
-               client->before_state = client->current_state;
-               client->current_state = STT_STATE_READY;
-
-               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Cancel is successful but not done");
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -671,194 +1758,270 @@ int stt_cancel(stt_h stt)
        return ret;
 }
 
-static int __stt_get_audio_volume(float* volume)
+int __stt_cb_set_volume(int uid, float volume)
 {
-       FILE* fp = fopen(STT_AUDIO_VOLUME_PATH, "rb");
-       if (!fp) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to open Volume File");
-               return STT_ERROR_OPERATION_FAILED;
+       stt_client_s* client = NULL;
+
+       client = stt_client_get_by_uid(uid);
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_STTC, "Handle is NOT valid");
+               return STT_ERROR_INVALID_PARAMETER;
        }
 
-       int readlen = fread((void*)volume, sizeof(*volume), 1, fp);
-       fclose(fp);
+       if (STT_STATE_RECORDING != client->current_state) {
+               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : NO 'Recording' state, cur(%d)", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
 
-       if (0 == readlen)
-               *volume = 0.0f;
+       g_volume_db = volume;
+       SLOG(LOG_DEBUG, TAG_STTC, "Set volume (%f)", g_volume_db);
 
        return 0;
 }
 
 int stt_get_recording_volume(stt_h stt, float* volume)
 {
-       if (NULL == stt || NULL == volume) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       if (NULL == volume) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
                return STT_ERROR_INVALID_PARAMETER;
-       } 
-       
+       }
+
        if (STT_STATE_RECORDING != client->current_state) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : NO 'Recording' state");
+               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : NO 'Recording' state, cur(%d)", client->current_state);
                return STT_ERROR_INVALID_STATE;
-       }    
-       
-       int ret = 0;
-       ret = __stt_get_audio_volume(volume);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get audio volume");
-               return STT_ERROR_OPERATION_FAILED;
        }
 
+       *volume = g_volume_db;
+
        return STT_ERROR_NONE;
 }
 
-int stt_start_file_recognition(stt_h stt, const char* filepath, const char* language, const char* type)
+bool __stt_result_time_cb(int index, int event, const char* text, long start_time, long end_time, void* user_data)
 {
-       if (NULL == stt || NULL == type || NULL == filepath) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
-               return STT_ERROR_INVALID_PARAMETER;
-       }
-
-       stt_client_s* client = stt_client_get(stt);
+       stt_client_s* client = (stt_client_s*)user_data;
 
        /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               return STT_ERROR_INVALID_PARAMETER;
-       } 
-
-       if (STT_STATE_READY != client->current_state) {
-               SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] Invalid state : NO 'Ready' state");
-               return STT_ERROR_INVALID_STATE;
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
+               return EINA_FALSE;
        }
 
-       char* temp;
-       if (NULL == language) {
-               temp = strdup("default");
+       if (NULL != client->result_time_cb) {
+               SLOG(LOG_DEBUG, TAG_STTC, "(%d) event(%d) text(%s) start(%ld) end(%ld)",
+                       index, event, text, start_time, end_time);
+               client->result_time_cb(client->stt, index, (stt_result_time_event_e)event,
+                       text, start_time, end_time, client->result_time_user_data);
        } else {
-               temp = strdup(language);
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Callback is NULL");
+               return false;
        }
 
-       int ret; 
-       ret = stt_dbus_request_start_file_recognition(client->uid, filepath, temp, type, client->profanity, client->punctuation);
+       return true;
+}
 
-       if (ret) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start");
-       } else {
-               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS]");
+int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
 
-               client->before_state = client->current_state;
-               client->current_state = STT_STATE_PROCESSING;
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT FOREACH DETAILED RESULT");
+
+       if (NULL == callback) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       client->result_time_cb = callback;
+       client->result_time_user_data = user_data;
 
-               ecore_timer_add(0, __stt_notify_state_changed, (void*)stt);
+       int ret = -1;
+       ret = stt_config_mgr_foreach_time_info(__stt_result_time_cb, client);
+       ret = __stt_convert_config_error_code(ret);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to foreach time info : %s", __stt_get_error_code(ret));
        }
 
-       free(temp);
+       client->result_time_cb = NULL;
+       client->result_time_user_data = NULL;
 
-       return STT_ERROR_NONE;
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return ret;
 }
 
-static Eina_Bool __stt_notify_error(void *data)
+static void __stt_notify_error(void *data)
 {
-       stt_h stt = (stt_h)data;
+       stt_client_s* client = (stt_client_s*)data;
 
-       stt_client_s* client = stt_client_get(stt);
+       SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error from sttd");
 
        /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
-               return EINA_FALSE;
+               return;
        }
 
+       if (NULL == stt_client_get_by_uid(client->uid))
+               return;
+
        if (NULL != client->error_cb) {
                stt_client_use_callback(client);
-               client->error_cb(client->stt, client->reason, client->error_user_data); 
+               g_err_callback_status = true;
+               client->error_cb(client->stt, client->reason, client->error_user_data);
+               g_err_callback_status = false;
                stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "Error callback is called");
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is called : reason [%d]", client->reason);
        } else {
                SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
        }
 
-       return EINA_FALSE;
+       return;
 }
 
-int __stt_cb_error(int uid, int reason)
+int __stt_cb_error(int uid, int reason, char* err_msg)
 {
-       stt_client_s* client = stt_client_get_by_uid(uid);
-       if( NULL == client ) {
-               SLOG(LOG_ERROR, TAG_STTC, "Handle not found\n");
-               return -1;
-       }
+       if (-1 == uid) {
+               GList* client_list = NULL;
+               client_list = stt_client_get_client_list();
+
+               GList *iter = NULL;
+               stt_client_s *data = NULL;
+
+               if (g_list_length(client_list) > 0) {
+                       /* Get a first item */
+                       iter = g_list_first(client_list);
+
+                       while (NULL != iter) {
+                               data = iter->data;
+
+                               data->reason = reason;
+                               data->internal_state = STT_INTERNAL_STATE_NONE;
+                               if (NULL != data->err_msg) {
+                                       free(data->err_msg);
+                                       data->err_msg = NULL;
+                               }
+                               if (NULL != err_msg)
+                                       data->err_msg = strdup(err_msg);
+
+                               SLOG(LOG_INFO, TAG_STTC, "internal state is initialized to 0");
+
+                               if (NULL != data->error_cb) {
+                                       ecore_main_loop_thread_safe_call_async(__stt_notify_error, data);
+                               } else {
+                                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
+                               }
+
+                               if (STT_ERROR_SERVICE_RESET == reason) {
+                                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] Service reset");
+
+                                       data->current_state = STT_STATE_CREATED;
+                                       if (0 != stt_prepare(data->stt)) {
+                                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare");
+                                       }
+                               }
+
+                               /* Next item */
+                               iter = g_list_next(iter);
+                       }
+               }
+       } else {
+               stt_client_s* client = stt_client_get_by_uid(uid);
+               if (NULL == client) {
+                       SLOG(LOG_ERROR, TAG_STTC, "Handle not found");
+                       return -1;
+               }
 
-       client->reason = reason;
+               client->reason = reason;
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+               if (NULL != client->err_msg) {
+                       free(client->err_msg);
+                       client->err_msg = NULL;
+               }
+               if (NULL != err_msg)
+                       client->err_msg = strdup(err_msg);
 
-       if (NULL != client->error_cb) {
-               ecore_timer_add(0, __stt_notify_error, client->stt);
-       } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
-       }    
+               SLOG(LOG_INFO, TAG_STTC, "internal state is initialized to 0");
+
+               if (NULL != client->error_cb) {
+                       ecore_main_loop_thread_safe_call_async(__stt_notify_error, client);
+               } else {
+                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] Error callback is null");
+               }
+
+               if (STT_ERROR_SERVICE_RESET == reason) {
+                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] Service reset");
+
+                       client->current_state = STT_STATE_CREATED;
+                       if (0 != stt_prepare(client->stt)) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to prepare");
+                       }
+               }
+       }
 
        return 0;
 }
 
-static Eina_Bool __stt_notify_result(void *data)
+static void __stt_notify_state_changed(void *data)
 {
-       stt_h stt = (stt_h)data;
-
-       stt_client_s* client = stt_client_get(stt);
+       stt_client_s* client = (stt_client_s*)data;
 
        /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
-               return EINA_FALSE;
+               return;
+       }
+
+       if (NULL == stt_client_get_by_uid(client->uid)) {
+               return;
+       }
+
+       if (STT_INTERNAL_STATE_STARTING == client->internal_state && STT_STATE_RECORDING == client->current_state) {
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+               SLOG(LOG_DEBUG, TAG_STTC, "Internal state change to NONE");
+       } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state && STT_STATE_PROCESSING == client->current_state) {
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+               SLOG(LOG_DEBUG, TAG_STTC, "Internal state change to NONE");
+       } else if (STT_INTERNAL_STATE_CANCELING == client->internal_state && STT_STATE_READY == client->current_state) {
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+               SLOG(LOG_DEBUG, TAG_STTC, "Internal state change to NONE");
        }
 
-       if (NULL != client->result_cb) {
+       if (NULL != client->state_changed_cb) {
                stt_client_use_callback(client);
-               client->result_cb(client->stt, client->type, (const char**)client->data_list, client->data_count, client->msg, client->result_user_data);
+               client->state_changed_cb(client->stt, client->before_state,
+                       client->current_state, client->state_changed_user_data);
                stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "client result callback called");
+               SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called, State(%d)", client->current_state);
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] User result callback is null");
-       } 
-
-       /* Free result */
-       if (NULL != client->type)
-               free(client->type);
-
-       if (NULL != client->data_list) {
-               char **temp = NULL;
-               temp = client->data_list;
-
-               int i = 0;
-               for (i = 0;i < client->data_count;i++) {
-                       if(NULL != temp[i])
-                               free(temp[i]);
-                       else 
-                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error");
-               }
-               free(client->data_list);
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null, State(%d)", client->current_state);
        }
-       
-       if (NULL != client->msg) 
-               free(client->msg);
-
-       client->data_count = 0;
 
-       return EINA_FALSE;
+       return;
 }
 
-static Eina_Bool __stt_notify_state_changed(void *data)
+static Eina_Bool __stt_notify_result(void *data)
 {
-       stt_h stt = (stt_h)data;
-
-       stt_client_s* client = stt_client_get(stt);
+       stt_client_s* client = (stt_client_s*)data;
 
        /* check handle */
        if (NULL == client) {
@@ -866,128 +2029,117 @@ static Eina_Bool __stt_notify_state_changed(void *data)
                return EINA_FALSE;
        }
 
-       if (NULL != client->state_changed_cb) {
+       if (NULL == stt_client_get_by_uid(client->uid)) {
+               return EINA_FALSE;
+       }
+
+       if (NULL != client->recognition_result_cb) {
                stt_client_use_callback(client);
-               client->state_changed_cb(client->stt, client->before_state, client->current_state, client->state_changed_user_data); 
+               client->recognition_result_cb(client->stt, client->event, (const char**)client->data_list, client->data_count,
+                       client->msg, client->recognition_result_user_data);
                stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "State changed callback is called");
+               SLOG(LOG_DEBUG, TAG_STTC, "client recognition result callback called");
        } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] User recognition result callback is NULL");
        }
 
-       return EINA_FALSE;
-}
-
-int __stt_cb_result(int uid, const char* type, const char** data, int data_count, const char* msg)
-{
-       stt_client_s* client = NULL;
-       
-       client = stt_client_get_by_uid(uid);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "Handle is NOT valid");
-               return -1;
+       if (NULL != client->msg) {
+               free(client->msg);
+               client->msg = NULL;
        }
 
-       SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result Message = %s", msg);
-
-       int i=0;
-       for (i = 0;i < data_count;i++) {
-               if(NULL != data[i])
-                       SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result[%d] = %s", i, data[i]);
-       }       
-
-       if (NULL != client->result_cb) {
-               client->type = strdup(type);
-               client->msg = strdup(msg);
-               client->data_count = data_count;
-
-               if (data_count > 0) {
-                       char **temp = NULL;
-                       temp = malloc( sizeof(char*) * data_count);
+       if (NULL != client->data_list) {
+               char **temp = NULL;
+               temp = client->data_list;
 
-                       for (i = 0;i < data_count;i++) {
-                               if(NULL != data[i])
-                                       temp[i] = strdup(data[i]);
-                               else 
-                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error");
+               int i = 0;
+               for (i = 0; i < client->data_count; i++) {
+                       if (NULL != temp[i]) {
+                               free(temp[i]);
+                               temp[i] = NULL;
+                       } else {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error");
                        }
-
-                       client->data_list = temp;
                }
-
-               ecore_timer_add(0, __stt_notify_result, client->stt);
-       } else {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] User result callback is null");
-       }   
-
-       client->before_state = client->current_state;
-       client->current_state = STT_STATE_READY;
-
-       if (NULL != client->state_changed_cb) {
-               ecore_timer_add(0, __stt_notify_state_changed, client->stt);
-       } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+               free(client->data_list);
+               client->data_list = NULL;
        }
 
-       return 0;
-}
-
-static Eina_Bool __stt_notify_partial_result(void *data)
-{
-       stt_h stt = (stt_h)data;
-
-       stt_client_s* client = stt_client_get(stt);
+       client->data_count = 0;
 
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify error : A handle is not valid");
-               return EINA_FALSE;
-       }
+       stt_config_mgr_remove_time_info_file();
 
-       if (client->partial_result_cb) {
-               stt_client_use_callback(client);
-               client->partial_result_cb(client->stt, client->partial_result, client->partial_result_user_data);
-               stt_client_not_use_callback(client);
-               SLOG(LOG_DEBUG, TAG_STTC, "Partial result callback is called");
-       } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Partial result callback is null");
-       }   
+       if (STT_RESULT_EVENT_FINAL_RESULT == client->event || STT_RESULT_EVENT_ERROR == client->event) {
+               client->before_state = client->current_state;
+               client->current_state = STT_STATE_READY;
 
-       if (NULL != client->partial_result)
-               free(client->partial_result);
+               if (NULL != client->state_changed_cb) {
+                       ecore_main_loop_thread_safe_call_async(__stt_notify_state_changed, client);
+               } else {
+                       SLOG(LOG_WARN, TAG_STTC, "[WARNING] State changed callback is null");
+               }
+       }
 
        return EINA_FALSE;
 }
 
-int __stt_cb_partial_result(int uid, const char* data)
+int __stt_cb_result(int uid, int event, char** data, int data_count, const char* msg)
 {
        stt_client_s* client = NULL;
 
        client = stt_client_get_by_uid(uid);
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "Handle is NOT valid");
-               return -1;
+               return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (client->current_state == STT_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTC, "Current state has already been 'Ready' state");      
-               return 0;
+       if (NULL != msg)
+               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result Message = %s", msg);
+
+       int i = 0;
+       for (i = 0; i < data_count; i++) {
+               if (NULL != data[i])
+                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result[%d] = %s", i, data[i]);
        }
 
-       if (client->partial_result_cb) {
-               client->partial_result = strdup(data);
-               ecore_timer_add(0, __stt_notify_partial_result, client->stt);
+       if (NULL != client->recognition_result_cb) {
+               client->event = event;
+               if (NULL != msg) {
+                       client->msg = strdup(msg);
+               }
+
+               client->data_count = data_count;
+
+               if (data_count > 0) {
+                       char **temp = NULL;
+                       temp = (char**)calloc(data_count, sizeof(char*));
+                       if (NULL == temp) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
+                               return STT_ERROR_OUT_OF_MEMORY;
+                       }
+
+                       for (i = 0; i < data_count; i++) {
+                               if (NULL != data[i])
+                                       temp[i] = strdup(data[i]);
+                               else
+                                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Result data is error");
+                       }
+
+                       client->data_list = temp;
+               }
        } else {
-               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Partial result callback is null");
-       }  
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] User result callback is null");
+       }
 
-       return 0;
+       __stt_notify_result(client);
+
+       return STT_ERROR_NONE;
 }
 
 int __stt_cb_set_state(int uid, int state)
 {
        stt_client_s* client = stt_client_get_by_uid(uid);
-       if( NULL == client ) {
+       if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "Handle not found");
                return -1;
        }
@@ -1002,121 +2154,119 @@ int __stt_cb_set_state(int uid, int state)
        client->before_state = client->current_state;
        client->current_state = state_from_daemon;
 
-       ecore_timer_add(0, __stt_notify_state_changed, client->stt);
+       ecore_main_loop_thread_safe_call_async(__stt_notify_state_changed, client);
        return 0;
 }
 
-int stt_set_result_cb(stt_h stt, stt_result_cb callback, void* user_data)
+static void __stt_notify_speech_status(void *data)
 {
-       if (stt == NULL || callback == NULL)
-               return STT_ERROR_INVALID_PARAMETER;
-
-       stt_client_s* client = stt_client_get(stt);
+       stt_client_s* client = (stt_client_s*)data;
 
        /* check handle */
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               return STT_ERROR_INVALID_PARAMETER;
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to notify speech status : A handle is not valid");
+               return;
        }
 
-       if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
-               return STT_ERROR_INVALID_STATE;
+       if (NULL == stt_client_get_by_uid(client->uid)) {
+               return;
        }
 
-       client->result_cb = callback;
-       client->result_user_data = user_data;
+       if (NULL != client->speech_status_cb) {
+               stt_client_use_callback(client);
+               client->speech_status_cb(client->stt, client->speech_status, client->speech_status_user_data);
+               stt_client_not_use_callback(client);
+               SLOG(LOG_DEBUG, TAG_STTC, "Speech status callback is called");
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARNING] Speech status callback is null");
+       }
 
-       return 0;
+       return;
 }
 
-int stt_unset_result_cb(stt_h stt)
+int __stt_cb_speech_status(int uid, int status)
 {
-       if (NULL == stt)
-               return STT_ERROR_INVALID_PARAMETER;
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
+       stt_client_s* client = stt_client_get_by_uid(uid);
        if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
-               return STT_ERROR_INVALID_PARAMETER;
-       }
-
-       if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
-               return STT_ERROR_INVALID_STATE;
+               SLOG(LOG_ERROR, TAG_STTC, "Handle not found");
+               return -1;
        }
 
-       client->result_cb = NULL;
-       client->result_user_data = NULL;
+       client->speech_status = status;
 
+       ecore_main_loop_thread_safe_call_async(__stt_notify_speech_status, client);
        return 0;
 }
 
-int stt_set_partial_result_cb(stt_h stt, stt_partial_result_cb callback, void* user_data)
+int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data)
 {
-       if (NULL == stt || NULL == callback)
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
+       }
 
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       if (callback == NULL)
                return STT_ERROR_INVALID_PARAMETER;
-       }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->partial_result_cb = callback;
-       client->partial_result_user_data = user_data;
+       client->recognition_result_cb = callback;
+       client->recognition_result_user_data = user_data;
 
        return 0;
 }
 
-int stt_unset_partial_result_cb(stt_h stt)
+int stt_unset_recognition_result_cb(stt_h stt)
 {
-       if (NULL == stt)
-               return STT_ERROR_INVALID_PARAMETER;
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
-       client->partial_result_cb = NULL;
-       client->partial_result_user_data = NULL;
+       client->recognition_result_cb = NULL;
+       client->recognition_result_user_data = NULL;
 
        return 0;
 }
 
 int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data)
 {
-       if (NULL == stt || NULL == callback)
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
+       }
 
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       if (NULL == callback)
                return STT_ERROR_INVALID_PARAMETER;
-       }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
@@ -1128,19 +2278,19 @@ int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* use
 
 int stt_unset_state_changed_cb(stt_h stt)
 {
-       if (NULL == stt)
-               return STT_ERROR_INVALID_PARAMETER;
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
@@ -1150,22 +2300,24 @@ int stt_unset_state_changed_cb(stt_h stt)
        return 0;
 }
 
-
 int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
 {
-       if (NULL == stt || NULL == callback)
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
+       }
 
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       if (NULL == callback)
                return STT_ERROR_INVALID_PARAMETER;
-       }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
@@ -1177,19 +2329,19 @@ int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
 
 int stt_unset_error_cb(stt_h stt)
 {
-       if (NULL == stt)
-               return STT_ERROR_INVALID_PARAMETER;
-
-       stt_client_s* client = stt_client_get(stt);
-
-       /* check handle */
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
                return STT_ERROR_INVALID_PARAMETER;
        }
 
        if (STT_STATE_CREATED != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state is not 'ready'."); 
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
@@ -1199,102 +2351,280 @@ int stt_unset_error_cb(stt_h stt)
        return 0;
 }
 
-int __get_cmd_line(char *file, char *buf) 
+int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data)
 {
-       FILE *fp = NULL;
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
 
-       fp = fopen(file, "r");
-       if (fp == NULL) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get command line");
-               return -1;
+       if (NULL == callback)
+               return STT_ERROR_INVALID_PARAMETER;
+
+       if (STT_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
+               return STT_ERROR_INVALID_STATE;
        }
 
-       memset(buf, 0, 256);
-       if (NULL == fgets(buf, 256, fp)) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to fget command line");
-               fclose(fp);
-               return -1;
+       client->default_lang_changed_cb = callback;
+       client->default_lang_changed_user_data = user_data;
+
+       return 0;
+}
+
+int stt_unset_default_language_changed_cb(stt_h stt)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (STT_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
+               return STT_ERROR_INVALID_STATE;
        }
-       fclose(fp);
+
+       client->default_lang_changed_cb = NULL;
+       client->default_lang_changed_user_data = NULL;
 
        return 0;
 }
 
-static bool __stt_is_alive()
+int stt_set_engine_changed_cb(stt_h stt, stt_engine_changed_cb callback, void* user_data)
 {
-       DIR *dir;
-       struct dirent *entry;
-       struct stat filestat;
-       
-       int pid;
-       char cmdLine[256];
-       char tempPath[256];
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == callback)
+               return STT_ERROR_INVALID_PARAMETER;
 
-       dir  = opendir("/proc");
-       if (NULL == dir) {
-               SLOG(LOG_ERROR, TAG_STTC, "process checking is FAILED");
-               return FALSE;
+       if (STT_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
+               return STT_ERROR_INVALID_STATE;
        }
 
-       while ((entry = readdir(dir)) != NULL) {
-               if (0 != lstat(entry->d_name, &filestat))
-                       continue;
+       client->engine_changed_cb = callback;
+       client->engine_changed_user_data = user_data;
 
-               if (!S_ISDIR(filestat.st_mode))
-                       continue;
+       return 0;
+}
 
-               pid = atoi(entry->d_name);
-               if (pid <= 0) continue;
+int stt_unset_engine_changed_cb(stt_h stt)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
 
-               sprintf(tempPath, "/proc/%d/cmdline", pid);
-               if (0 != __get_cmd_line(tempPath, cmdLine)) {
-                       continue;
-               }
-               if ( 0 == strncmp(cmdLine, "[stt-daemon]", strlen("[stt-daemon]")) ||
-                       0 == strncmp(cmdLine, "stt-daemon", strlen("stt-daemon")) ||
-                       0 == strncmp(cmdLine, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))) {
-                               SLOG(LOG_DEBUG, TAG_STTC, "stt-daemon is ALIVE !! \n");
-                               closedir(dir);
-                               return TRUE;
-               }
+       if (STT_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
+               return STT_ERROR_INVALID_STATE;
        }
-       SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon !! \n");
 
-       closedir(dir);
-       return FALSE;
+       client->engine_changed_cb = NULL;
+       client->engine_changed_user_data = NULL;
 
+       return 0;
 }
 
-static int __check_stt_daemon()
+int stt_set_speech_status_cb(stt_h stt, stt_speech_status_cb callback, void* user_data)
 {
-       if( TRUE == __stt_is_alive() )
-               return 0;
-       
-       /* fork-exec stt-daemon */
-       int pid, i;
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
 
-       pid = fork();
+       if (NULL == callback)
+               return STT_ERROR_INVALID_PARAMETER;
 
-       switch(pid) {
-       case -1:
-               SLOG(LOG_DEBUG, TAG_STTC, "[STT ERROR] fail to create STT-DAEMON \n");
-               break;
+       if (STT_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
 
-       case 0:
-               setsid();
-               for (i = 0;i < _NSIG;i++)
-                       signal(i, SIG_DFL);
+       client->speech_status_cb = callback;
+       client->speech_status_user_data = user_data;
 
-               execl("/usr/bin/stt-daemon", "/usr/bin/stt-daemon", NULL);
-               break;
+       return 0;
+}
 
-       default:
-               break;
+int stt_unset_speech_status_cb(stt_h stt)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (STT_STATE_CREATED != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Current state(%d) is not 'Created'", client->current_state);
+               return STT_ERROR_INVALID_STATE;
        }
 
+       client->speech_status_cb = NULL;
+       client->speech_status_user_data = NULL;
+
        return 0;
 }
 
+int stt_start_file(stt_h stt, const char* language, const char* type, const char* filepath, stt_audio_type_e audio_type, int sample_rate)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+       if (NULL == filepath) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Input parameter is NULL");
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT START FILE");
+
+       /* check state */
+       if (client->current_state != STT_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (STT_INTERNAL_STATE_NONE != client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is NOT none : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+       }
+
+       int ret = -1;
+       char appid[1024] = {0, };
+       ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1);
+
+       if ((AUL_R_OK != ret) || (0 == strlen(appid))) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to get application ID");
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[DEBUG] Current app id is %s", appid);
+       }
+
+       char* temp = NULL;
+       if (NULL == language) {
+               temp = strdup("default");
+       } else {
+               temp = strdup(language);
+       }
+
+       if (NULL == temp) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
+               return STT_ERROR_OUT_OF_MEMORY;
+       }
+
+       if (true == client->credential_needed && NULL == client->credential) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Do not have app credential for this engine(%s)", client->current_engine_id);
+               free(temp);
+               temp = NULL;
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+
+       client->internal_state = STT_INTERNAL_STATE_STARTING;
+       ret = stt_dbus_request_start_file(client->uid, temp, type, client->silence, appid, client->credential, filepath, audio_type, sample_rate);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start file : %s", __stt_get_error_code(ret));
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is successful but not done");
+       }
+
+       free(temp);
+       temp = NULL;
+
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
+
+       return ret;
+}
+
+int stt_cancel_file(stt_h stt)
+{
+       stt_client_s* client = NULL;
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
+       }
+       if (0 != __stt_check_privilege()) {
+               return STT_ERROR_PERMISSION_DENIED;
+       }
+       if (0 != __stt_check_handle(stt, &client)) {
+               return STT_ERROR_INVALID_PARAMETER;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STTC, "===== STT CANCEL FILE");
+
+       /* check state */
+       if (STT_STATE_RECORDING != client->current_state && STT_STATE_PROCESSING != client->current_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid state : Current state(%d) is 'Ready'", client->current_state);
+               return STT_ERROR_INVALID_STATE;
+       }
+
+       if (STT_INTERNAL_STATE_STARTING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STARTING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_RECORDING;
+       } else if (STT_INTERNAL_STATE_STOPPING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is STOPPING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_PROCESSING;
+       } else if (STT_INTERNAL_STATE_CANCELING == client->internal_state) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State : Internal state is CANCELING : %d", client->internal_state);
+               return STT_ERROR_IN_PROGRESS_TO_READY;
+       }
+
+       client->internal_state = STT_INTERNAL_STATE_CANCELING;
+       int ret = stt_dbus_request_cancel_file(client->uid);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to cancel file : %s", __stt_get_error_code(ret));
+               client->internal_state = STT_INTERNAL_STATE_NONE;
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Cancel file is successful but not done");
+       }
 
+       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+       SLOG(LOG_DEBUG, TAG_STTC, " ");
 
+       return ret;
+}