updates codes to sync with the latest 2.4 spin code 27/64027/1
authorWonnam Jang <wn.jang@samsung.com>
Tue, 29 Mar 2016 11:43:33 +0000 (20:43 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Tue, 29 Mar 2016 11:43:33 +0000 (20:43 +0900)
Change-Id: I8452952ab6783ccd43886fa2fd5465b0571fd6fe
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
28 files changed:
CMakeLists.txt
NOTICE
changelog
client/stt.c
client/stt_client.h
client/stt_dbus.c
client/stt_file.c
client/stt_file_client.h
common/stt_config_mgr.c
common/stt_config_parser.c
common/stt_defs.h
common/stt_engine.c
include/stt_file.h
org.tizen.voice.sttserver.service
packaging/stt.spec
server/CMakeLists.txt
server/sttd_client_data.c
server/sttd_dbus.c
server/sttd_dbus.h
server/sttd_dbus_server.c
server/sttd_engine_agent.c
server/sttd_recorder.c
server/sttd_recorder.h
server/sttd_server.c
server/sttd_server.h
server/sttp.h
test/CMakeLists.txt
test/test_main.c

index 20f41be..8760065 100644 (file)
@@ -25,9 +25,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(EXEC_PREFIX "${PREFIX}")
 SET(VERSION 0.2.54)
 
-IF (LIBDIR MATCHES "/usr/lib64")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIB64")
-ENDIF (LIBDIR)
+ADD_DEFINITIONS("-DSTT_LIBDIR=\"${LIBDIR}\"")
 
 ## Include common directory ##
 INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common")
@@ -57,7 +55,9 @@ ADD_SUBDIRECTORY(server)
 ADD_SUBDIRECTORY(test)
 
 ## config ##
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/stt-config.xml DESTINATION /usr/lib/voice/stt/1.0)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/stt-config.xml DESTINATION ${LIBDIR}/voice/stt/1.0)
 
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/stt-server.conf DESTINATION /etc/dbus-1/system.d)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.sttserver.service DESTINATION /usr/share/dbus-1/system-services)
+## Dbus service ##
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.voice.sttserver.service DESTINATION /usr/share/dbus-1/services)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/stt-server.conf DESTINATION /etc/dbus-1/session.d)
diff --git a/NOTICE b/NOTICE
index d08cb4d..39d0536 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -1,3 +1,3 @@
-Copyright (c) 2011-2014 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2011-2016 Samsung Electronics Co., Ltd. All rights reserved.
 Except as noted, this software is licensed under Apache License, Version 2.
 Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
index 37a87f1..c7e2e19 100644 (file)
--- a/changelog
+++ b/changelog
@@ -2,9 +2,10 @@ stt (0.2.54) -- Tue, 2 Jun 2015
 
   * Update IPC for getting volume not to use file (Dongyeol Lee <dy3.lee@samsung.com>)
   * Remove unused smack label (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Add engine valid check (Kwangyoun Kim <ky85.kim@samsung.com>)
   * Update daemon start by dbus activation (Dongyeol Lee <dy3.lee@samsung.com>)
   * Update state changed callback for thread (Dongyeol Lee <dy3.lee@samsung.com>)
-  * Apply dbus policy config (Kwangyoun Kim <ky85.kim@samsung.com>)
+  * Update IPC for rapid response time (Dongyeol Lee <dy3.lee@samsung.com>)
 
 stt (0.2.53) -- Thu, 21 Aug 2014
 
index 0b42088..91f6fc1 100644 (file)
 #include "stt_main.h"
 
 
-static Ecore_Timer* g_connect_timer = NULL;
-
 static void __stt_notify_state_changed(void *data);
 static Eina_Bool __stt_notify_error(void *data);
 
-static int g_count_check_daemon = 0;
+static Ecore_Timer* g_connect_timer = NULL;
+static float g_volume_db = 0;
+
+static int g_feature_enabled = -1;
 
 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 const char* __stt_get_error_code(stt_error_e err)
 {
        switch (err) {
@@ -81,7 +112,7 @@ static int __stt_convert_config_error_code(stt_config_error_e code)
 
 void __stt_config_lang_changed_cb(const char* before_language, const char* current_language, void* user_data)
 {
-       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Language changed : Before lang(%s) Current lang(%s)", 
+       SLOG(LOG_DEBUG, TAG_STTC, "Language changed : Before lang(%s) Current lang(%s)",
                before_language, current_language);
 
        if (0 == strcmp(before_language, current_language)) {
@@ -101,8 +132,8 @@ void __stt_config_lang_changed_cb(const char* before_language, const char* curre
                while (NULL != iter) {
                        data = iter->data;
                        if (NULL != data->default_lang_changed_cb) {
-                               SECURE_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, 
+                               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);
                        }
 
@@ -116,15 +147,8 @@ void __stt_config_lang_changed_cb(const char* before_language, const char* curre
 
 int stt_create(stt_h* stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== Create STT");
@@ -169,7 +193,7 @@ int stt_create(stt_h* stt)
                return ret;
        }
 
-       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[Success] uid(%d)", (*stt)->handle);
+       SLOG(LOG_DEBUG, TAG_STTC, "[Success] uid(%d)", (*stt)->handle);
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
@@ -179,23 +203,14 @@ int stt_create(stt_h* stt)
 
 int stt_destroy(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        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;
        }
 
@@ -254,7 +269,7 @@ int stt_destroy(stt_h stt)
        return STT_ERROR_NONE;
 }
 
-bool __stt_config_supported_engine_cb(const char* engine_id, const char* engine_name, 
+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)user_data;
@@ -277,23 +292,14 @@ bool __stt_config_supported_engine_cb(const char* engine_id, const char* engine_
 
 int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported engine");
 
        if (NULL == stt || 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;
        }
 
@@ -302,15 +308,11 @@ int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, v
        /* 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 (client->current_state != STT_STATE_CREATED) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not CREATE");
-               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;
        }
 
@@ -335,23 +337,14 @@ int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, v
 
 int stt_get_engine(stt_h stt, char** engine_id)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== Get current engine");
 
        if (NULL == stt || NULL == engine_id) {
                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;
        }
 
@@ -360,25 +353,28 @@ int stt_get_engine(stt_h stt, char** engine_id)
        /* 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 (client->current_state != STT_STATE_CREATED) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not CREATE");
-               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;
        }
 
        int ret = 0;
-       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));
+
+       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 {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Current engine uuid = %s", *engine_id);
+
+               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, "=====");
@@ -389,23 +385,14 @@ int stt_get_engine(stt_h stt, char** engine_id)
 
 int stt_set_engine(stt_h stt, const char* engine_id)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== Set current engine");
 
        if (NULL == stt || NULL == engine_id) {
                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;
        }
 
@@ -414,16 +401,12 @@ int stt_set_engine(stt_h stt, const char* engine_id)
        /* 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_CREATED) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state is not CREATE");
-               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;
        }
 
@@ -445,14 +428,17 @@ static Eina_Bool __stt_connect_daemon(void *data)
 
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not available");
+               g_connect_timer = NULL;
                return EINA_FALSE;
        }
 
        /* Send hello */
        int ret = -1;
        ret = stt_dbus_request_hello();
+
        if (0 != ret) {
                if (STT_ERROR_INVALID_STATE == ret) {
+                       g_connect_timer = NULL;
                        return EINA_FALSE;
                }
                return EINA_TRUE;
@@ -462,7 +448,6 @@ static Eina_Bool __stt_connect_daemon(void *data)
        SLOG(LOG_DEBUG, TAG_STTC, "===== Connect daemon");
 
        /* request initialization */
-
        bool silence_supported = false;
 
        ret = stt_dbus_request_initialize(client->uid, &silence_supported);
@@ -481,7 +466,7 @@ static Eina_Bool __stt_connect_daemon(void *data)
        } else {
                /* success to connect stt-daemon */
                client->silence_supported = silence_supported;
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s)", silence_supported ? "true" : "false");
+               SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s)", silence_supported ? "true" : "false");
        }
 
        if (NULL != client->current_engine_id) {
@@ -513,15 +498,15 @@ static Eina_Bool __stt_connect_daemon(void *data)
                }
        }
 
-       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] uid(%d)", client->uid);
+       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] uid(%d)", client->uid);
 
        client->before_state = client->current_state;
        client->current_state = STT_STATE_READY;
 
        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); 
+               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 {
@@ -536,15 +521,8 @@ static Eina_Bool __stt_connect_daemon(void *data)
 
 int stt_prepare(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== Prepare STT");
@@ -554,20 +532,15 @@ int stt_prepare(stt_h 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;
        }
 
        /* 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_count_check_daemon = 0;
        g_connect_timer = ecore_timer_add(0, __stt_connect_daemon, (void*)client);
 
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
@@ -578,15 +551,8 @@ int stt_prepare(stt_h stt)
 
 int stt_unprepare(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== Unprepare STT");
@@ -601,9 +567,7 @@ int stt_unprepare(stt_h 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;
        }
 
@@ -634,13 +598,18 @@ int stt_unprepare(stt_h 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); 
+               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, " ");
 
@@ -669,23 +638,14 @@ bool __stt_config_supported_language_cb(const char* engine_id, const char* langu
 
 int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== Foreach Supported Language");
 
        if (NULL == stt || 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;
        }
 
@@ -694,8 +654,6 @@ int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callbac
        /* 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;
        }
 
@@ -741,33 +699,20 @@ int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callbac
 
 int stt_get_default_language(stt_h stt, char** language)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        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, " ");
                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;
        }
 
@@ -788,15 +733,8 @@ int stt_get_default_language(stt_h stt, char** language)
 
 int stt_get_state(stt_h stt, stt_state_e* state)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt || NULL == state) {
@@ -805,7 +743,6 @@ int stt_get_state(stt_h stt, stt_state_e* state)
        }
 
        stt_client_s* client = stt_client_get(stt);
-
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
                return STT_ERROR_INVALID_PARAMETER;
@@ -826,15 +763,8 @@ int stt_get_state(stt_h stt, stt_state_e* state)
 
 int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt || NULL == type || NULL == support) {
@@ -843,7 +773,6 @@ int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support
        }
 
        stt_client_s* client = stt_client_get(stt);
-
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] A handle is not valid");
                return STT_ERROR_INVALID_PARAMETER;
@@ -851,7 +780,7 @@ int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support
 
        /* 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;
        }
 
@@ -873,7 +802,7 @@ int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support
                                }
                        }
                } else {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] recognition type is %s", *support ? "true " : "false");
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] recognition type is %s", *support ? "true " : "false");
                        break;
                }
        }
@@ -883,15 +812,8 @@ int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support
 
 int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt) {
@@ -900,7 +822,6 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
        }
 
        stt_client_s* client = stt_client_get(stt);
-
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get state : A handle is not valid");
                return STT_ERROR_INVALID_PARAMETER;
@@ -908,7 +829,7 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
 
        /* 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;
        }
 
@@ -928,15 +849,8 @@ int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type)
 
 int stt_set_start_sound(stt_h stt, const char* filename)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT SET START SOUND");
@@ -959,7 +873,7 @@ int stt_set_start_sound(stt_h stt, const char* filename)
 
        /* 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;
        }
 
@@ -981,7 +895,7 @@ int stt_set_start_sound(stt_h stt, const char* filename)
                                }
                        }
                } else {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set start sound : %s", filename);
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set start sound : %s", filename);
                        break;
                }
        }
@@ -991,15 +905,8 @@ int stt_set_start_sound(stt_h stt, const char* filename)
 
 int stt_unset_start_sound(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET START SOUND");
@@ -1018,7 +925,7 @@ int stt_unset_start_sound(stt_h 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_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
@@ -1040,7 +947,7 @@ int stt_unset_start_sound(stt_h stt)
                                }
                        }
                } else {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Unset start sound");
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Unset start sound");
                        break;
                }
        }
@@ -1050,15 +957,8 @@ int stt_unset_start_sound(stt_h stt)
 
 int stt_set_stop_sound(stt_h stt, const char* filename)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT SET STOP SOUND");
@@ -1082,7 +982,7 @@ int stt_set_stop_sound(stt_h stt, const char* filename)
 
        /* 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;
        }
 
@@ -1104,7 +1004,7 @@ int stt_set_stop_sound(stt_h stt, const char* filename)
                                }
                        }
                } else {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set stop sound : %s", filename);
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Set stop sound : %s", filename);
                        break;
                }
        }
@@ -1114,15 +1014,8 @@ int stt_set_stop_sound(stt_h stt, const char* filename)
 
 int stt_unset_stop_sound(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT UNSET STOP SOUND");
@@ -1141,7 +1034,7 @@ int stt_unset_stop_sound(stt_h 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_ERROR, TAG_STTC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
                return STT_ERROR_INVALID_STATE;
        }
 
@@ -1163,7 +1056,7 @@ int stt_unset_stop_sound(stt_h stt)
                                }
                        }
                } else {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Unset stop sound");
+                       SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Unset stop sound");
                        break;
                }
        }
@@ -1173,48 +1066,31 @@ int stt_unset_stop_sound(stt_h stt)
 
 int stt_start(stt_h stt, const char* language, const char* type)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        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 = 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;
        }
 
        /* 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;
        }
 
        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);
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_STATE;
        }
 
@@ -1235,6 +1111,7 @@ int stt_start(stt_h stt, const char* language, const char* type)
                temp = strdup(language);
        }
 
+#if 0
        ret = -1;
        /* do request */
        int count = 0;
@@ -1281,7 +1158,17 @@ int stt_start(stt_h stt, const char* language, const char* type)
                        break;
                }
        }
+#else
+       ret = stt_dbus_request_start(client->uid, temp, type, client->silence, appid);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start : %s", __stt_get_error_code(ret));
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Start is successful but not done");
+               client->internal_state = STT_INTERNAL_STATE_STARTING;
+       }
 
+       if (NULL != temp)       free(temp);
+#endif
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
@@ -1290,51 +1177,34 @@ int stt_start(stt_h stt, const char* language, const char* type)
 
 int stt_stop(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT STOP");
 
        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 = 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;
        }
 
        /* 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;
        }
 
        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);
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_STATE;
        }
-
+#if 0
        int ret = -1;
        /* do request */
        int count = 0;
@@ -1376,7 +1246,16 @@ int stt_stop(stt_h stt)
                        break;
                }
        }
+#else
+       int ret = stt_dbus_request_stop(client->uid);
 
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to stop : %s", __stt_get_error_code(ret));
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Stop is successful but not done");
+               client->internal_state = STT_INTERNAL_STATE_STOPING;
+       }
+#endif
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
@@ -1386,23 +1265,14 @@ int stt_stop(stt_h stt)
 
 int stt_cancel(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        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, " ");
                return STT_ERROR_INVALID_PARAMETER;
        }
 
@@ -1411,26 +1281,20 @@ int stt_cancel(stt_h 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;
        }
 
        /* 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 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;
        }
 
        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);
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
                return STT_ERROR_INVALID_STATE;
        }
-
+#if 0
        int ret = -1;
        /* do request */
        int count = 0;
@@ -1466,41 +1330,46 @@ int stt_cancel(stt_h stt)
                        break;
                }
        }
-
+#else
+       int ret = stt_dbus_request_cancel(client->uid);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to cancel : %s", __stt_get_error_code(ret));
+       } else {
+               SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Cancel is successful but not done");
+               client->internal_state = STT_INTERNAL_STATE_CANCELING;
+       }
+#endif
        SLOG(LOG_DEBUG, TAG_STTC, "=====");
        SLOG(LOG_DEBUG, TAG_STTC, " ");
 
        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)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt || NULL == volume) {
@@ -1517,16 +1386,11 @@ int stt_get_recording_volume(stt_h stt, float* volume)
        }
 
        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 : %s", __stt_get_error_code(ret));
-               return STT_ERROR_OPERATION_FAILED;
-       }
+       *volume = g_volume_db;
 
        return STT_ERROR_NONE;
 }
@@ -1544,7 +1408,7 @@ bool __stt_result_time_cb(int index, int event, const char* text, long start_tim
        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, 
+               client->result_time_cb(client->stt, index, (stt_result_time_event_e)event,
                        text, start_time, end_time, client->result_time_user_data);
        } else {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Callback is NULL");
@@ -1556,15 +1420,8 @@ bool __stt_result_time_cb(int index, int event, const char* text, long start_tim
 
 int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        SLOG(LOG_DEBUG, TAG_STTC, "===== STT FOREACH DETAILED RESULT");
@@ -1605,6 +1462,8 @@ static Eina_Bool __stt_notify_error(void *data)
 {
        stt_client_s* client = (stt_client_s*)data;
 
+       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");
@@ -1618,7 +1477,7 @@ static Eina_Bool __stt_notify_error(void *data)
                stt_client_use_callback(client);
                client->error_cb(client->stt, client->reason, client->error_user_data);
                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");
        }
@@ -1629,12 +1488,14 @@ static Eina_Bool __stt_notify_error(void *data)
 int __stt_cb_error(int uid, int reason)
 {
        stt_client_s* client = stt_client_get_by_uid(uid);
-       if (NULL == client) {
-               SLOG(LOG_ERROR, TAG_STTC, "Handle not found\n");
+       if( NULL == client ) {
+               SLOG(LOG_ERROR, TAG_STTC, "Handle not found");
                return -1;
        }
 
        client->reason = reason;
+       client->internal_state = STT_INTERNAL_STATE_NONE;
+       SLOG(LOG_INFO, TAG_STTC, "internal state is initialized to 0");
 
        if (NULL != client->error_cb) {
                ecore_timer_add(0, __stt_notify_error, client);
@@ -1661,16 +1522,19 @@ static void __stt_notify_state_changed(void *data)
 
        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 NULL");
+               SLOG(LOG_DEBUG, TAG_STTC, "Internal state change to NONE");
        } else if (STT_INTERNAL_STATE_STOPING == client->internal_state && STT_STATE_PROCESSING == client->current_state) {
                client->internal_state = STT_INTERNAL_STATE_NONE;
-               SLOG(LOG_DEBUG, TAG_STTC, "Internal state change NULL");
+               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->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); 
+               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 {
@@ -1696,7 +1560,7 @@ static Eina_Bool __stt_notify_result(void *data)
 
        if (NULL != client->recognition_result_cb) {
                stt_client_use_callback(client);
-               client->recognition_result_cb(client->stt, client->event, (const char**)client->data_list, client->data_count, 
+               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, "client recognition result callback called");
@@ -1754,11 +1618,13 @@ int __stt_cb_result(int uid, int event, char** data, int data_count, const char*
                return STT_ERROR_INVALID_PARAMETER;
        }
 
-       if (NULL != msg)        SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result Message = %s", msg);
+       if (NULL != msg)
+               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 (NULL != data[i])
+                       SLOG(LOG_DEBUG, TAG_STTC, "Recognition Result[%d] = %s", i, data[i]);
        }
 
        if (NULL != client->recognition_result_cb) {
@@ -1819,15 +1685,8 @@ int __stt_cb_set_state(int uid, int state)
 
 int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (stt == NULL || callback == NULL)
@@ -1842,7 +1701,7 @@ int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback,
        }
 
        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;
        }
 
@@ -1854,15 +1713,8 @@ int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback,
 
 int stt_unset_recognition_result_cb(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt)
@@ -1877,7 +1729,7 @@ int stt_unset_recognition_result_cb(stt_h stt)
        }
 
        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;
        }
 
@@ -1889,15 +1741,8 @@ int stt_unset_recognition_result_cb(stt_h stt)
 
 int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt || NULL == callback)
@@ -1912,7 +1757,7 @@ int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* use
        }
 
        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;
        }
 
@@ -1924,15 +1769,8 @@ 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)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt)
@@ -1947,7 +1785,7 @@ int stt_unset_state_changed_cb(stt_h stt)
        }
 
        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;
        }
 
@@ -1959,15 +1797,8 @@ int stt_unset_state_changed_cb(stt_h stt)
 
 int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt || NULL == callback)
@@ -1982,7 +1813,7 @@ int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
        }
 
        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;
        }
 
@@ -1994,15 +1825,8 @@ int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data)
 
 int stt_unset_error_cb(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt)
@@ -2017,7 +1841,7 @@ int stt_unset_error_cb(stt_h stt)
        }
 
        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;
        }
 
@@ -2029,15 +1853,8 @@ int stt_unset_error_cb(stt_h stt)
 
 int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt || NULL == callback)
@@ -2052,7 +1869,7 @@ int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_
        }
 
        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;
        }
 
@@ -2064,15 +1881,8 @@ int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_
 
 int stt_unset_default_language_changed_cb(stt_h stt)
 {
-       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");
-                               return STT_ERROR_NOT_SUPPORTED;
-                       }
-               }
+       if (0 != __stt_get_feature_enabled()) {
+               return STT_ERROR_NOT_SUPPORTED;
        }
 
        if (NULL == stt)
@@ -2087,7 +1897,7 @@ int stt_unset_default_language_changed_cb(stt_h stt)
        }
 
        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;
        }
 
index 6bbdbe1..de6242d 100644 (file)
@@ -26,7 +26,8 @@ extern "C" {
 typedef enum {
        STT_INTERNAL_STATE_NONE         = 0,
        STT_INTERNAL_STATE_STARTING     = 1,
-       STT_INTERNAL_STATE_STOPING      = 2
+       STT_INTERNAL_STATE_STOPING      = 2,
+       STT_INTERNAL_STATE_CANCELING    = 3
 }stt_internal_state_e;
 
 typedef struct {
index 4a3e63a..a7fc25d 100644 (file)
@@ -33,253 +33,255 @@ extern int __stt_cb_result(int uid, int event, char** data, int data_count, cons
 
 extern int __stt_cb_set_state(int uid, int state);
 
+extern int __stt_cb_set_volume(int uid, float volume);
+
 static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
 {
        if (NULL == g_conn_listener)    return ECORE_CALLBACK_RENEW;
 
        dbus_connection_read_write_dispatch(g_conn_listener, 50);
 
-       DBusMessage* msg = NULL;
-       msg = dbus_connection_pop_message(g_conn_listener);
-
-       if (true != dbus_connection_get_is_connected(g_conn_listener)) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is disconnected");
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       /* loop again if we haven't read a message */
-       if (NULL == msg) {
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage *reply = NULL;
-
-       char if_name[64];
-       snprintf(if_name, 64, "%s", STT_CLIENT_SERVICE_INTERFACE);
+       while (1) {
+               DBusMessage* msg = NULL;
+               msg = dbus_connection_pop_message(g_conn_listener);
 
-       if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_HELLO)) {
-               SLOG(LOG_DEBUG, TAG_STTC, "===== Get Hello");
-               int uid = 0;
-               int response = -1;
-
-               dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
-               if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
-                       dbus_error_free(&err);
+               if (true != dbus_connection_get_is_connected(g_conn_listener)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection is disconnected");
+                       break;
                }
 
-               if (uid > 0) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get hello : uid(%d)", uid);
-
-                       /* check uid */
-                       stt_client_s* client = stt_client_get_by_uid(uid);
-                       if (NULL != client)
-                               response = 1;
-                       else
-                               response = 0;
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get hello : invalid uid");
+               /* loop again if we haven't read a message */
+               if (NULL == msg) {
+                       break;
                }
 
-               reply = dbus_message_new_method_return(msg);
+               SLOG(LOG_DEBUG, TAG_STTC, "[DEBUG] Message is arrived");
 
-               if (NULL != reply) {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
+               DBusError err;
+               dbus_error_init(&err);
 
-                       if (!dbus_connection_send(g_conn_listener, reply, NULL))
-                               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to send reply");
-                       else
-                               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get hello : result(%d)", response);
+               DBusMessage *reply = NULL;
 
-                       dbus_connection_flush(g_conn_listener);
-                       dbus_message_unref(reply);
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to create reply message");
-               }
+               char if_name[64];
+               snprintf(if_name, 64, "%s%d", STT_CLIENT_SERVICE_INTERFACE, getpid());
 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-       } /* STTD_METHOD_HELLO */
+               if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_HELLO)) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "===== Get Hello");
+                       int uid = 0;
+                       int response = -1;
 
-       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_SET_STATE)) {
-               SLOG(LOG_DEBUG, TAG_STTC, "===== Set State");
-               int uid = 0;
-               int state = -1;
+                       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+                       if (dbus_error_is_set(&err)) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+                               dbus_error_free(&err);
+                       }
 
-               dbus_message_get_args(msg, &err, 
-                       DBUS_TYPE_INT32, &uid, 
-                       DBUS_TYPE_INT32, &state,
-                       DBUS_TYPE_INVALID);
+                       if (uid > 0) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get hello : uid(%d)", uid);
 
-               if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
-                       dbus_error_free(&err);
-               }
+                               /* check uid */
+                               stt_client_s* client = stt_client_get_by_uid(uid);
+                               if (NULL != client)
+                                       response = 1;
+                               else
+                                       response = 0;
+                       }
+                       else {
+                               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get hello : invalid uid");
+                       }
 
-               if (uid > 0 && state >= 0) {
-                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set state : uid(%d), state(%d)", uid, state);
-                       __stt_cb_set_state(uid, state);
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set state : invalid uid or state");
-               }
+                       reply = dbus_message_new_method_return(msg);
 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-       } /* STTD_METHOD_SET_STATE */
-       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_GET_STATE)) {
-               SLOG(LOG_DEBUG, TAG_STTC, "===== Get state");
-               int uid = 0;
-               int response = -1;
+                       if (NULL != reply) {
+                               dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
 
-               dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
+                               if (!dbus_connection_send(g_conn_listener, reply, NULL))
+                                       SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to send reply");
+                               else
+                                       SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get hello : result(%d)", response);
 
-               if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
-                       dbus_error_free(&err);
-               }
+                               dbus_connection_flush(g_conn_listener);
+                               dbus_message_unref(reply);
+                       }
+                       else {
+                               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to create reply message");
+                       }
 
-               if (uid > 0) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get state : uid(%d)", uid);
+                       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+                       SLOG(LOG_DEBUG, TAG_STTC, " ");
+               } /* STTD_METHOD_HELLO */
 
-                       /* check state */
-                       stt_client_s* client = stt_client_get_by_uid(uid);
-                       if (NULL != client)
-                               response = client->current_state;
-                       else
-                               SLOG(LOG_ERROR, TAG_STTC, "invalid uid");
+               else if (dbus_message_is_signal(msg, if_name, STTD_METHOD_SET_STATE)) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "===== Set State");
+                       int uid = 0;
+                       int state = -1;
 
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get state : invalid uid");
-               }
+                       dbus_message_get_args(msg, &err,
+                               DBUS_TYPE_INT32, &uid,
+                               DBUS_TYPE_INT32, &state,
+                               DBUS_TYPE_INVALID);
+
+                       if (dbus_error_is_set(&err)) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+                               dbus_error_free(&err);
+                       }
 
-               reply = dbus_message_new_method_return(msg);
+                       if (uid > 0 && state >= 0) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set state : uid(%d), state(%d)", uid, state);
+                               __stt_cb_set_state(uid, state);
+                       }
+                       else {
+                               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set state : invalid uid or state");
+                       }
 
-               if (NULL != reply) {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
+                       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+                       SLOG(LOG_DEBUG, TAG_STTC, " ");
+               } /* STTD_METHOD_SET_STATE */
 
-                       if (!dbus_connection_send(g_conn_listener, reply, NULL))
-                               SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get state : fail to send reply");
-                       else
-                               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get state : result(%d)", response);
+               else if (dbus_message_is_signal(msg, if_name, STTD_METHOD_SET_VOLUME)) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "===== Set volume : signal");
+                       int uid = 0;
+                       float volume = 0;
 
-                       dbus_connection_flush(g_conn_listener);
-                       dbus_message_unref(reply);
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get hello : fail to create reply message");
-               }
+                       dbus_message_get_args(msg, &err,
+                               DBUS_TYPE_INT32, &uid,
+                               DBUS_TYPE_INT32, &volume,
+                               DBUS_TYPE_INVALID);
 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-       } /* STTD_METHOD_GET_STATE */
+                       if (dbus_error_is_set(&err)) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+                               dbus_error_free(&err);
+                       }
 
-       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_RESULT)) {
-               SLOG(LOG_DEBUG, TAG_STTC, "===== Get Result");
-               int uid = 0;
-               DBusMessageIter args;
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set volume : uid(%d), volume(%f)", uid, volume); 
+                       __stt_cb_set_volume(uid, volume);
 
-               dbus_message_iter_init(msg, &args);
+                       /* SLOG(LOG_DEBUG, TAG_STTC, "====="); */
+                       /* SLOG(LOG_DEBUG, TAG_STTC, " "); */
+               } /* STTD_METHOD_SET_VOLUME */
 
-               /* Get result */
-               if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                       dbus_message_iter_get_basic(&args, &uid);
-                       dbus_message_iter_next(&args);
-               }
+               else if (dbus_message_is_signal(msg, if_name, STTD_METHOD_RESULT)) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "===== Get Result : signal");
+                       int uid = 0;
+                       DBusMessageIter args;
 
-               if (uid > 0) {
-                       char** temp_result = NULL;
-                       char* temp_msg = NULL;
-                       char* temp_char = NULL;
-                       int temp_event = 0;
-                       int temp_count = 0;
+                       dbus_message_iter_init(msg, &args);
 
-                       /* Get recognition type */
+                       /* Get result */
                        if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &temp_event);
+                               dbus_message_iter_get_basic(&args, &uid);
                                dbus_message_iter_next(&args);
                        }
 
-                       if (DBUS_TYPE_STRING == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &(temp_msg));
-                               dbus_message_iter_next(&args);
-                       }
+                       stt_client_s* client = NULL;
+                       client = stt_client_get_by_uid(uid);
+                       if (NULL != client) {
+                               char** temp_result = NULL;
+                               char* temp_msg = NULL;
+                               char* temp_char = NULL;
+                               int temp_event = 0;
+                               int temp_count = 0;
+                               int temp_result_id = 0;
+
+                               /* Get recognition type */
+                               if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
+                                       dbus_message_iter_get_basic(&args, &temp_event);
+                                       dbus_message_iter_next(&args);
+                               }
 
-                       /* Get voice size */
-                       if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
-                               dbus_message_iter_get_basic(&args, &temp_count);
-                               dbus_message_iter_next(&args);
-                       }
+                               if (DBUS_TYPE_STRING == dbus_message_iter_get_arg_type(&args)) {
+                                       dbus_message_iter_get_basic(&args, &(temp_msg));
+                                       dbus_message_iter_next(&args);
+                               }
 
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get result : uid(%d) event(%d) message(%s) count(%d)", 
-                               uid, temp_event, temp_msg, temp_count);
+                               /* Get voice size */
+                               if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
+                                       dbus_message_iter_get_basic(&args, &temp_count);
+                                       dbus_message_iter_next(&args);
+                               }
 
-                       if (temp_count <= 0) {
-                               __stt_cb_result(uid, temp_event, NULL, 0, temp_msg);
-                       } else {
-                               temp_result = (char**)calloc(temp_count, sizeof(char*));
+                               /* Get result id */
+                               if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
+                                       dbus_message_iter_get_basic(&args, &temp_result_id);
+                                       dbus_message_iter_next(&args);
+                               }
 
-                               if (NULL == temp_result)        {
-                                       SLOG(LOG_ERROR, TAG_STTC, "Fail : memory allocation error");
-                               } else {
-                                       int i = 0;
-                                       for (i = 0; i < temp_count; i++) {
-                                               dbus_message_iter_get_basic(&args, &(temp_char));
-                                               dbus_message_iter_next(&args);
+                               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get result : uid(%d) event(%d) message(%s) count(%d) result id(%d)",
+                                       uid, temp_event, temp_msg, temp_count, temp_result_id);
 
-                                               if (NULL != temp_char) {
-                                                       temp_result[i] = strdup(temp_char);
-                                                       SLOG(LOG_DEBUG, TAG_STTC, "result[%d] : %s", i, temp_result[i]);
+                               if (temp_count <= 0) {
+                                       __stt_cb_result(uid, temp_event, NULL, 0, temp_msg);
+                               } else {
+                                       temp_result = (char**)calloc(temp_count, sizeof(char*));
+
+                                       if (NULL == temp_result)        {
+                                               SLOG(LOG_ERROR, TAG_STTC, "Fail : memory allocation error");
+                                       } else {
+                                               int i = 0;
+                                               for (i = 0; i < temp_count; i++) {
+                                                       dbus_message_iter_get_basic(&args, &(temp_char));
+                                                       dbus_message_iter_next(&args);
+
+                                                       if (NULL != temp_char) {
+                                                               temp_result[i] = strdup(temp_char);
+                                                               SLOG(LOG_DEBUG, TAG_STTC, "result[%d] : %s", i, temp_result[i]);
+                                                       }
                                                }
-                                       }
 
-                                       __stt_cb_result(uid, temp_event, temp_result, temp_count, temp_msg);
+                                               __stt_cb_result(uid, temp_event, temp_result, temp_count, temp_msg);
 
-                                       for (i = 0; i < temp_count; i++) {
-                                               if (NULL != temp_result[i])
-                                                       free(temp_result[i]);
-                                       }
+                                               for (i = 0; i < temp_count; i++) {
+                                                       if (NULL != temp_result[i])
+                                                               free(temp_result[i]);
+                                               }
 
-                                       free(temp_result);
+                                               free(temp_result);
+                                       }
                                }
+                       } else {
+                               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get result : invalid uid");
                        }
-               } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get result : invalid uid");
-               }
 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-       /* STTD_METHOD_RESULT */
+                       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+                       SLOG(LOG_DEBUG, TAG_STTC, " ");
+               }/* STTD_METHOD_RESULT */
 
-       else if (dbus_message_is_method_call(msg, if_name, STTD_METHOD_ERROR)) {
-               SLOG(LOG_DEBUG, TAG_STTC, "===== Get Error");
-               int uid;
-               int reason;
-               char* err_msg;
+               else if (dbus_message_is_signal(msg, if_name, STTD_METHOD_ERROR)) {
+                       SLOG(LOG_DEBUG, TAG_STTC, "===== Get Error");
+                       int uid;
+                       int reason;
+                       char* err_msg;
 
-               dbus_message_get_args(msg, &err,
-                       DBUS_TYPE_INT32, &uid,
-                       DBUS_TYPE_INT32, &reason,
-                       DBUS_TYPE_STRING, &err_msg,
-                       DBUS_TYPE_INVALID);
+                       dbus_message_get_args(msg, &err,
+                               DBUS_TYPE_INT32, &uid,
+                               DBUS_TYPE_INT32, &reason,
+                               DBUS_TYPE_STRING, &err_msg,
+                               DBUS_TYPE_INVALID);
 
-               if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt Get Error message : Get arguments error (%s)", err.message);
-                       dbus_error_free(&err);
-               } else {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt Get Error message : uid(%d), reason(%d), msg(%s)", uid, reason, err_msg);
-                       __stt_cb_error(uid, reason);
-               }
+                       if (dbus_error_is_set(&err)) {
+                               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt Get Error message : Get arguments error (%s)", err.message);
+                               dbus_error_free(&err);
+                       }
+                       else {
+                               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt Get Error message : uid(%d), reason(%d), msg(%s)", uid, reason, err_msg);
+                               __stt_cb_error(uid, reason);
+                       }
 
-               SLOG(LOG_DEBUG, TAG_STTC, "=====");
-               SLOG(LOG_DEBUG, TAG_STTC, " ");
-       /* STTD_METHOD_ERROR */
+                       SLOG(LOG_DEBUG, TAG_STTC, "=====");
+                       SLOG(LOG_DEBUG, TAG_STTC, " ");
+               }/* STTD_METHOD_ERROR */
 
-       /* free the message */
-       dbus_message_unref(msg);
+               else {
+                       SLOG(LOG_DEBUG, TAG_STTC, "Message is NOT valid");
+                       dbus_message_unref(msg);
+                       break;
+               }
+
+               /* free the message */
+               dbus_message_unref(msg);
+       }/* while */
 
-       return ECORE_CALLBACK_PASS_ON;
+       return ECORE_CALLBACK_RENEW;
 }
 
 int stt_dbus_open_connection()
@@ -295,7 +297,7 @@ int stt_dbus_open_connection()
        dbus_error_init(&err);
 
        /* connect to the DBUS system bus, and check for errors */
-       g_conn_sender = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
+       g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
        if (dbus_error_is_set(&err)) {
                SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Dbus Connection Error (%s)", err.message);
                dbus_error_free(&err);
@@ -309,10 +311,10 @@ int stt_dbus_open_connection()
        dbus_connection_set_exit_on_disconnect(g_conn_sender, false);
 
        /* connect to the DBUS system bus, and check for errors */
-       g_conn_listener = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
+       g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
 
-       if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)", err.message);
+       if (dbus_error_is_set(&err)) { 
+               SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)", err.message); 
                dbus_error_free(&err);
        }
 
@@ -325,27 +327,27 @@ int stt_dbus_open_connection()
 
        char service_name[64];
        memset(service_name, '\0', 64);
-       snprintf(service_name, 64, "%s", STT_CLIENT_SERVICE_NAME);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
-       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "service name is %s\n", service_name);
+       SLOG(LOG_DEBUG, TAG_STTC, "service name is %s", service_name);
 
        /* register our name on the bus, and check for errors */
        dbus_bus_request_name(g_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_STTC, "Name Error (%s)\n", err.message);
-               dbus_error_free(&err);
+               SLOG(LOG_ERROR, TAG_STTC, "Name Error (%s)", err.message); 
+               dbus_error_free(&err); 
        }
 
-       char rule[128];
-       snprintf(rule, 128, "type='signal',interface='%s'", STT_CLIENT_SERVICE_INTERFACE);
+       char rule[128] = {0, };
+       snprintf(rule, 128, "type='signal',interface='%s%d'", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        /* add a rule for which messages we want to see */
        dbus_bus_add_match(g_conn_listener, rule, &err);
        dbus_connection_flush(g_conn_listener);
 
        if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)\n", err.message);
+               SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
                dbus_error_free(&err);
                return STT_ERROR_OPERATION_FAILED;
        }
@@ -381,7 +383,7 @@ int stt_dbus_close_connection()
 
        char service_name[64];
        memset(service_name, '\0', 64);
-       snprintf(service_name, 64, "%s", STT_CLIENT_SERVICE_NAME);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
        dbus_bus_release_name(g_conn_listener, service_name, &err);
        if (dbus_error_is_set(&err)) {
@@ -389,6 +391,9 @@ int stt_dbus_close_connection()
                dbus_error_free(&err);
        }
 
+       dbus_connection_close(g_conn_sender);
+       dbus_connection_close(g_conn_listener);
+
        g_conn_sender = NULL;
        g_conn_listener = NULL;
 
@@ -437,23 +442,28 @@ int stt_dbus_request_hello()
        DBusMessage* result_msg = NULL;
        int result = 0;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_short_time, &err);
-       dbus_message_unref(msg);
-       if (dbus_error_is_set(&err)) {
-               dbus_error_free(&err);
-       }
-
-       if (NULL != result_msg) {
-               dbus_message_unref(result_msg);
-
+       if(g_conn_sender) {
+               result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_short_time, &err);
+               dbus_message_unref(msg);
                if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
                        dbus_error_free(&err);
                }
 
-               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt hello");
-       } else {
-               result = STT_ERROR_TIMED_OUT;
+               if (NULL != result_msg) {
+                       dbus_message_unref(result_msg);
+
+                       if (dbus_error_is_set(&err)) {
+                               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+                               dbus_error_free(&err);
+                       }
+
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt hello");
+               } else {
+                       result = STT_ERROR_TIMED_OUT;
+               }
+       }else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+               result = STT_ERROR_OPERATION_FAILED;
        }
 
        return result;
@@ -474,7 +484,7 @@ int stt_dbus_request_initialize(int uid, bool* silence_supported)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt initialize : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt initialize : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt initialize : uid(%d)", uid);
        }
 
        int pid = getpid();
@@ -489,37 +499,42 @@ int stt_dbus_request_initialize(int uid, bool* silence_supported)
        DBusMessage* result_msg;
        int result = STT_ERROR_OPERATION_FAILED;
 
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
-       dbus_message_unref(msg);
-       if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
-               dbus_error_free(&err);
-       }
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, 
-                       DBUS_TYPE_INT32, &result, 
-                       DBUS_TYPE_INT32, silence_supported,
-                       DBUS_TYPE_INVALID);
-
+       if(g_conn_sender) {
+               result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
+               dbus_message_unref(msg);
                if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Send Error (%s)", err.message);
                        dbus_error_free(&err);
-                       result = STT_ERROR_OPERATION_FAILED;
                }
 
-               if (0 == result) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d, silence(%d)",
-                               result, *silence_supported);
+               if (NULL != result_msg) {
+                       dbus_message_get_args(result_msg, &err,
+                               DBUS_TYPE_INT32, &result,
+                               DBUS_TYPE_INT32, silence_supported,
+                               DBUS_TYPE_INVALID);
+
+                       if (dbus_error_is_set(&err)) {
+                               SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
+                               dbus_error_free(&err);
+                               result = STT_ERROR_OPERATION_FAILED;
+                       }
+
+                       if (0 == result) {
+                               SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d, silence(%d)",
+                                       result, *silence_supported);
+                       } else {
+                               SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d", result);
+                       }
+
+                       dbus_message_unref(result_msg);
                } else {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d", result);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+                       stt_dbus_reconnect();
+                       result = STT_ERROR_TIMED_OUT;
                }
-
-               dbus_message_unref(result_msg);
        } else {
-               SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
-               stt_dbus_reconnect();
-               result = STT_ERROR_TIMED_OUT;
+               SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+               result = STT_ERROR_OPERATION_FAILED;
        }
 
        return result;
@@ -539,7 +554,7 @@ int stt_dbus_request_finalize(int uid)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt finalize : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt finalize : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt finalize : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
@@ -598,7 +613,7 @@ int stt_dbus_request_set_current_engine(int uid, const char* engine_id, bool* si
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set engine : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set engine : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set engine : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg,
@@ -626,15 +641,15 @@ int stt_dbus_request_set_current_engine(int uid, const char* engine_id, bool* si
                        DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err);
+                       SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err); 
                        result = STT_ERROR_OPERATION_FAILED;
                }
 
                dbus_message_unref(result_msg);
 
                if (0 == result) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set engine : result = %d , silence(%d)", 
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set engine : result = %d , silence(%d)", 
                                result, *silence_supported);
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set engine : result = %d", result);
@@ -667,7 +682,7 @@ int stt_dbus_request_check_app_agreed(int uid, const char* appid, bool* value)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt check app agreed : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt check app agreed : uid(%d) appid(%s)", uid, appid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt check app agreed : uid(%d) appid(%s)", uid, appid);
        }
 
        dbus_message_append_args(msg,
@@ -704,7 +719,7 @@ int stt_dbus_request_check_app_agreed(int uid, const char* appid, bool* value)
 
                if (0 == result) {
                        *value = (bool)available;
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt check app agreed : result = %d, available = %d", result, *value);
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt check app agreed : result = %d, available = %d", result, *value);
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt check app agreed : result = %d", result);
                }
@@ -736,7 +751,7 @@ int stt_dbus_request_get_support_langs(int uid, stt_h stt, stt_supported_languag
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get supported languages : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get supported languages : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get supported languages : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
@@ -821,7 +836,7 @@ int stt_dbus_request_get_default_lang(int uid, char** language)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get default language : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get default language  : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get default language  : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg,
@@ -857,7 +872,7 @@ int stt_dbus_request_get_default_lang(int uid, char** language)
 
                if (0 == result) {
                        *language = strdup(temp_lang);
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get default language : result = %d, language = %s", result, *language);
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get default language : result = %d, language = %s", result, *language);
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get default language : result = %d", result);
                }
@@ -889,7 +904,7 @@ int stt_dbus_request_is_recognition_type_supported(int uid, const char* type, bo
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt is partial result supported : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt is recognition type supported : uid(%d) type(%s)", uid, type);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt is recognition type supported : uid(%d) type(%s)", uid, type);
        }
 
        dbus_message_append_args(msg,
@@ -926,7 +941,7 @@ int stt_dbus_request_is_recognition_type_supported(int uid, const char* type, bo
 
                if (0 == result) {
                        *support = (bool)result_support;
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt is recognition type supported : result = %d, support = %s", result, *support ? "true" : "false");
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt is recognition type supported : result = %d, support = %s", result, *support ? "true" : "false");
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt is recognition type supported : result = %d", result);
                }
@@ -958,7 +973,7 @@ int stt_dbus_request_set_start_sound(int uid, const char* file)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set start sound : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set start sound : uid(%d) file(%s)", uid, file);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set start sound : uid(%d) file(%s)", uid, file);
        }
 
        dbus_message_append_args(msg,
@@ -992,7 +1007,7 @@ int stt_dbus_request_set_start_sound(int uid, const char* file)
                dbus_message_unref(result_msg);
 
                if (0 == result) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set start sound : result = %d", result);
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set start sound : result = %d", result);
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set start sound : result = %d", result);
                }
@@ -1019,7 +1034,7 @@ int stt_dbus_request_unset_start_sound(int uid)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset start sound : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset start sound : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset start sound : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg,
@@ -1052,7 +1067,7 @@ int stt_dbus_request_unset_start_sound(int uid)
                dbus_message_unref(result_msg);
 
                if (0 == result) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt unset start sound : result = %d", result);
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt unset start sound : result = %d", result);
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt unset start sound : result = %d", result);
                }
@@ -1084,7 +1099,7 @@ int stt_dbus_request_set_stop_sound(int uid, const char* file)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set stop sound : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set stop sound : uid(%d) file(%s)", uid, file);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set stop sound : uid(%d) file(%s)", uid, file);
        }
 
        dbus_message_append_args(msg,
@@ -1118,7 +1133,7 @@ int stt_dbus_request_set_stop_sound(int uid, const char* file)
                dbus_message_unref(result_msg);
 
                if (0 == result) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set stop sound : result = %d", result);
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set stop sound : result = %d", result);
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set stop sound : result = %d", result);
                }
@@ -1145,7 +1160,7 @@ int stt_dbus_request_unset_stop_sound(int uid)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset stop sound : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset stop sound : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt unset stop sound : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg,
@@ -1178,7 +1193,7 @@ int stt_dbus_request_unset_stop_sound(int uid)
                dbus_message_unref(result_msg);
 
                if (0 == result) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt unset stop sound : result = %d", result);
+                       SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt unset stop sound : result = %d", result);
                } else {
                        SLOG(LOG_ERROR, TAG_STTC, "<<<< stt unset stop sound : result = %d", result);
                }
@@ -1211,17 +1226,36 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int sile
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start : uid(%d), language(%s), type(%s)", uid, lang, type);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start : uid(%d), language(%s), type(%s)", uid, lang, type);
        }
 
        dbus_message_append_args(msg,
-               DBUS_TYPE_INT32, &uid, 
-               DBUS_TYPE_STRING, &lang,   
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &lang,
                DBUS_TYPE_STRING, &type,
                DBUS_TYPE_INT32, &silence,
                DBUS_TYPE_STRING, &appid,
                DBUS_TYPE_INVALID);
-       
+#if 1
+       if(g_conn_sender) {
+               dbus_message_set_no_reply(msg, TRUE);
+
+               if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt start message : Out Of Memory !");
+                       return STT_ERROR_OUT_OF_MEMORY;
+               } else {
+                       dbus_connection_flush(g_conn_sender);
+               }
+
+               dbus_message_unref(msg);
+
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+               return STT_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+#else
        DBusError err;
        dbus_error_init(&err);
 
@@ -1259,6 +1293,7 @@ int stt_dbus_request_start(int uid, const char* lang, const char* type, int sile
        }
 
        return result;
+#endif
 }
 
 int stt_dbus_request_stop(int uid)
@@ -1276,13 +1311,31 @@ int stt_dbus_request_stop(int uid)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt stop : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt stop : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt stop : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg, 
                DBUS_TYPE_INT32, &uid, 
                DBUS_TYPE_INVALID);
+#if 1
+       if(g_conn_sender) {
+               dbus_message_set_no_reply(msg, TRUE);
+
+               if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt stop message : Out Of Memory !");
+                       return STT_ERROR_OUT_OF_MEMORY;
+               } else {
+                       dbus_connection_flush(g_conn_sender);
+               }
+
+               dbus_message_unref(msg);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+               return STT_ERROR_OPERATION_FAILED;
+       }
 
+       return 0;
+#else
        DBusError err;
        dbus_error_init(&err);
 
@@ -1320,6 +1373,7 @@ int stt_dbus_request_stop(int uid)
        }
 
        return result;
+#endif
 }
 
 int stt_dbus_request_cancel(int uid)
@@ -1337,13 +1391,31 @@ int stt_dbus_request_cancel(int uid)
                SLOG(LOG_ERROR, TAG_STTC, ">>>> stt cancel : Fail to make message");
                return STT_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt cancel : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt cancel : uid(%d)", uid);
        }
 
        dbus_message_append_args(msg, 
                DBUS_TYPE_INT32, &uid, 
                DBUS_TYPE_INVALID);
+#if 1
+       if(g_conn_sender) {
+               dbus_message_set_no_reply(msg, TRUE);
+
+               if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+                       SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt stop message : Out Of Memory !");
+                       return STT_ERROR_OUT_OF_MEMORY;
+               } else {
+                       dbus_connection_flush(g_conn_sender);
+               }
 
+               dbus_message_unref(msg);
+       } else {
+               SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+               return STT_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+#else
        DBusError err;
        dbus_error_init(&err);
 
@@ -1381,4 +1453,5 @@ int stt_dbus_request_cancel(int uid)
        }
 
        return result;
+#endif
 }
index 0d3371a..e1998df 100644 (file)
@@ -51,7 +51,7 @@ static int    g_engine_id_count = 0;
 #define STT_FILE_CONFIG_HANDLE 100000
 
 
-const char* stt_tag()
+const char* stt_tag(void)
 {
        return TAG_STTFC;
 }
@@ -125,7 +125,7 @@ static int __stt_file_get_engine_info(const char* filepath, sttengine_info_s** i
        if ((error = dlerror()) != NULL || NULL == get_engine_info) {
                SLOG(LOG_WARN, TAG_STTFC, "[Engine Agent WARNING] Invalid engine. Fail to open sttp_get_engine_info : %s", error);
                dlclose(handle);
-               return -1;
+               return STT_FILE_ERROR_ENGINE_NOT_FOUND;
        }
 
        sttengine_info_s* temp;
@@ -192,7 +192,7 @@ static bool __stt_file_is_engine(const char* filepath)
        return false;
 }
 
-void __stt_file_relseae_engine_info()
+void __stt_file_relseae_engine_info(void)
 {
        GSList *iter = NULL;
 
@@ -255,7 +255,7 @@ static sttengine_info_s* __stt_file_get_engine_by_id(int engine_id)
        return NULL;
 }
 
-void __stt_file_result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count, 
+void __stt_file_result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count,
                 const char* msg, void* time_info, void *user_data)
 {
 
@@ -343,7 +343,7 @@ static int __stt_file_load_engine(sttengine_info_s* engine)
        return STT_FILE_ERROR_NONE;
 }
 
-int stt_file_initialize()
+int stt_file_initialize(void)
 {
        SLOG(LOG_DEBUG, TAG_STTFC, "===== Initialize STT FILE");
 
@@ -498,7 +498,7 @@ int stt_file_initialize()
        return STT_FILE_ERROR_NONE;
 }
 
-int stt_file_deinitialize()
+int stt_file_deinitialize(void)
 {
        SLOG(LOG_DEBUG, TAG_STTFC, "===== Deinitialize STT FILE");
 
@@ -594,7 +594,7 @@ int stt_file_foreach_supported_engines(stt_file_supported_engine_cb callback, vo
        }
 
        if (client->current_state != STT_FILE_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state is not 'Ready'");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", client->current_state);
                SLOG(LOG_DEBUG, TAG_STTFC, "=====");
                SLOG(LOG_DEBUG, TAG_STTFC, " ");
                return STT_FILE_ERROR_INVALID_STATE;
@@ -646,7 +646,7 @@ int stt_file_get_engine(char** engine_id)
        }
 
        if (client->current_state != STT_FILE_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state is not 'Ready'");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", client->current_state);
                SLOG(LOG_DEBUG, TAG_STTFC, "=====");
                SLOG(LOG_DEBUG, TAG_STTFC, " ");
                return STT_FILE_ERROR_INVALID_STATE;
@@ -690,7 +690,7 @@ int stt_file_set_engine(const char* engine_id)
 
        /* check state */
        if (client->current_state != STT_FILE_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state is not 'Ready'");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state(%d) is not 'Ready'", client->current_state);
                SLOG(LOG_DEBUG, TAG_STTFC, "=====");
                SLOG(LOG_DEBUG, TAG_STTFC, " ");
                return STT_FILE_ERROR_INVALID_STATE;
@@ -811,7 +811,7 @@ int stt_file_foreach_supported_languages(stt_file_supported_language_cb callback
        return STT_FILE_ERROR_NONE;
 }
 
-int stt_file_start(const char* language, const char* type, const char* filepath, 
+int stt_file_start(const char* language, const char* type, const char* filepath,
                stt_file_audio_type_e audio_type, int sample_rate)
 {
        SLOG(LOG_DEBUG, TAG_STTFC, "===== STT FILE START");
@@ -828,7 +828,7 @@ int stt_file_start(const char* language, const char* type, const char* filepath,
 
        /* check state */
        if (client->current_state != STT_FILE_STATE_READY) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state is not READY");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid State: Current state(%d) is not READY", client->current_state);
                SLOG(LOG_DEBUG, TAG_STTFC, "=====");
                SLOG(LOG_DEBUG, TAG_STTFC, " ");
                return STT_FILE_ERROR_INVALID_STATE;
@@ -886,7 +886,7 @@ int stt_file_start(const char* language, const char* type, const char* filepath,
        return STT_FILE_ERROR_NONE;
 }
 
-int stt_file_cancel()
+int stt_file_cancel(void)
 {
        SLOG(LOG_DEBUG, TAG_STTFC, "===== STT FILE CANCEL");
 
@@ -902,7 +902,7 @@ int stt_file_cancel()
 
        /* check state */
        if (STT_FILE_STATE_PROCESSING != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid state : Current state is NOT 'Processing'");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Invalid state : Current state(%d) is NOT 'Processing'", client->current_state);
                SLOG(LOG_DEBUG, TAG_STTFC, "=====");
                SLOG(LOG_DEBUG, TAG_STTFC, " ");
                return STT_FILE_ERROR_INVALID_STATE;
@@ -938,7 +938,7 @@ int stt_file_cancel()
 bool __stt_file_result_time_cb(int index, sttp_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data)
 {
        SLOG(LOG_DEBUG, TAG_STTFC, "(%d) event(%d) text(%s) start(%ld) end(%ld)",
-                index, event, text, start_time, end_time);
+               index, event, text, start_time, end_time);
 
        stt_file_client_s* client = stt_file_client_get();
 
@@ -949,7 +949,7 @@ bool __stt_file_result_time_cb(int index, sttp_result_time_event_e event, const
        }
 
        if (NULL != client->result_time_cb) {
-               client->result_time_cb(index, (stt_file_result_time_event_e)event, 
+               client->result_time_cb(index, (stt_file_result_time_event_e)event,
                        text, start_time, end_time, client->result_time_user_data);
        } else {
                SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Callback is NULL");
@@ -1004,7 +1004,7 @@ int stt_file_set_recognition_result_cb(stt_file_recognition_result_cb callback,
        }
 
        if (STT_FILE_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state is not 'ready'");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state(%d) is not 'ready'", client->current_state);
                return STT_FILE_ERROR_INVALID_STATE;
        }
 
@@ -1014,7 +1014,7 @@ int stt_file_set_recognition_result_cb(stt_file_recognition_result_cb callback,
        return 0;
 }
 
-int stt_file_unset_recognition_result_cb()
+int stt_file_unset_recognition_result_cb(void)
 {
        stt_file_client_s* client = stt_file_client_get();
 
@@ -1025,7 +1025,7 @@ int stt_file_unset_recognition_result_cb()
        }
 
        if (STT_FILE_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state is not 'ready'");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state(%d) is not 'ready'", client->current_state);
                return STT_FILE_ERROR_INVALID_STATE;
        }
 
@@ -1049,7 +1049,7 @@ int stt_file_set_state_changed_cb(stt_file_state_changed_cb callback, void* user
        }
 
        if (STT_FILE_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state is not 'ready'");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state(%d) is not 'ready'", client->current_state);
                return STT_FILE_ERROR_INVALID_STATE;
        }
 
@@ -1059,7 +1059,7 @@ int stt_file_set_state_changed_cb(stt_file_state_changed_cb callback, void* user
        return 0;
 }
 
-int stt_file_unset_state_changed_cb()
+int stt_file_unset_state_changed_cb(void)
 {
        stt_file_client_s* client = stt_file_client_get();
 
@@ -1070,7 +1070,7 @@ int stt_file_unset_state_changed_cb()
        }
 
        if (STT_FILE_STATE_READY != client->current_state) {
-               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state is not 'ready'");
+               SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Current state(%d) is not 'ready'", client->current_state);
                return STT_FILE_ERROR_INVALID_STATE;
        }
 
index 5db6fed..9a675df 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -50,7 +50,7 @@ typedef struct {
 
        /* result data */
        void*   time_info;
-       
+
        /* error data */
        int     reason;
 }stt_file_client_s;
index 045bc86..b66b1d8 100644 (file)
@@ -90,7 +90,7 @@ bool __stt_config_mgr_check_lang_is_valid(const char* engine_id, const char* lan
                                /*Get handle data from list*/
                                engine_lang = iter_lang->data;
 
-                               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", i, engine_lang);
+                               SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", i, engine_lang);
 
                                if (0 == strcmp(language, engine_lang)) {
                                        return true;
@@ -150,7 +150,7 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language)
                                        /* Default language is STT_BASE_LANGUAGE */
                                        if (0 == strcmp(STT_BASE_LANGUAGE, engine_lang)) {
                                                *language = strdup(engine_lang);
-                                               SECURE_SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language);
+                                               SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language);
                                                return 0;
                                        }
                                }
@@ -161,7 +161,7 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language)
                        /* Not support STT_BASE_LANGUAGE */
                        if (NULL != engine_lang) {
                                *language = strdup(engine_lang);
-                               SECURE_SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language);
+                               SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language);
                                return 0;
                        }
                }
@@ -379,7 +379,7 @@ int __stt_config_set_auto_language()
                free(g_config_info->language);
                g_config_info->language = strdup(candidate_lang);
 
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto. Set default language(%s)", g_config_info->language);
+               SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto. Set default language(%s)", g_config_info->language);
 
                /* Call all callbacks of client*/
                GSList *iter = NULL;
@@ -421,7 +421,7 @@ int __stt_config_set_auto_language()
                        return -1;
                }
 
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto but display lang is not supported. Default language change(%s)", tmp_language);
+               SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto but display lang is not supported. Default language change(%s)", tmp_language);
 
                /* Call all callbacks of client*/
                GSList *iter = NULL;
@@ -490,6 +490,7 @@ void __stt_config_release_client(int uid)
        if (0 < g_slist_length(g_config_client_list)) {
                SLOG(LOG_DEBUG, stt_tag(), "Client count (%d)", g_slist_length(g_config_client_list));
        }
+       return;
 }
 
 void __stt_config_release_engine()
@@ -514,6 +515,7 @@ void __stt_config_release_engine()
                        iter = g_slist_nth(g_engine_list, 0);
                }
        }
+       return;
 }
 
 int __stt_config_mgr_check_engine_is_valid(const char* engine_id)
@@ -652,7 +654,7 @@ int stt_config_mgr_initialize(int uid)
                        get_uid = iter->data;
 
                        if (uid == *get_uid) {
-                               SECURE_SLOG(LOG_WARN, stt_tag(), "[CONFIG] uid(%d) has already registered", uid);
+                               SLOG(LOG_WARN, stt_tag(), "[CONFIG] uid(%d) has already registered", uid);
                                return 0;
                        }
 
@@ -673,7 +675,7 @@ int stt_config_mgr_initialize(int uid)
                /* Add uid */
                g_config_client_list = g_slist_append(g_config_client_list, temp_client);
 
-               SECURE_SLOG(LOG_WARN, stt_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid);
+               SLOG(LOG_WARN, stt_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid);
                return STT_CONFIG_ERROR_NONE;
        }
 
@@ -685,6 +687,7 @@ int stt_config_mgr_initialize(int uid)
 
        g_engine_list = NULL;
 
+       SLOG(LOG_WARN, stt_tag(), "[CONFIG] default engine info(%s)", STT_DEFAULT_ENGINE_INFO);
        dp  = opendir(STT_DEFAULT_ENGINE_INFO);
        if (NULL != dp) {
                do {
@@ -772,11 +775,11 @@ int stt_config_mgr_initialize(int uid)
 
        /* print daemon config */
        SLOG(LOG_DEBUG, stt_tag(), "== Daemon config ==");
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), " engine : %s", g_config_info->engine_id);
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", g_config_info->setting);
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), " auto language : %s", g_config_info->auto_lang ? "on" : "off");
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language);
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence detection : %s", g_config_info->silence_detection ? "on" : "off");
+       SLOG(LOG_DEBUG, stt_tag(), " engine : %s", g_config_info->engine_id);
+       SLOG(LOG_DEBUG, stt_tag(), " setting : %s", g_config_info->setting);
+       SLOG(LOG_DEBUG, stt_tag(), " auto language : %s", g_config_info->auto_lang ? "on" : "off");
+       SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language);
+       SLOG(LOG_DEBUG, stt_tag(), " silence detection : %s", g_config_info->silence_detection ? "on" : "off");
        SLOG(LOG_DEBUG, stt_tag(), "===================");
 
        if (0 != __stt_config_mgr_register_config_event()) {
@@ -1003,7 +1006,7 @@ int stt_config_mgr_set_engine(const char* engine)
                return 0;
        }
 
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), "New engine id : %s", engine);
+       SLOG(LOG_DEBUG, stt_tag(), "New engine id : %s", engine);
 
        GSList *iter = NULL;
        stt_engine_info_s *engine_info = NULL;
@@ -1054,7 +1057,7 @@ int stt_config_mgr_set_engine(const char* engine)
                        /*Get handle data from list*/
                        lang = iter_lang->data;
 
-                       SECURE_SLOG(LOG_DEBUG, stt_tag(), " %s", lang);
+                       SLOG(LOG_DEBUG, stt_tag(), " %s", lang);
                        if (NULL != lang) {
                                if (0 == strcmp(lang, g_config_info->language)) {
                                        /* language is valid */
@@ -1096,10 +1099,10 @@ int stt_config_mgr_set_engine(const char* engine)
 
        if (true == is_valid_engine) {
                SLOG(LOG_DEBUG, stt_tag(), "[Config] Engine changed");
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  Engine : %s", g_config_info->engine_id);
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  Setting : %s", g_config_info->setting);
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  language : %s", g_config_info->language);
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  Silence detection : %s", g_config_info->silence_detection ? "on" : "off");
+               SLOG(LOG_DEBUG, stt_tag(), "  Engine : %s", g_config_info->engine_id);
+               SLOG(LOG_DEBUG, stt_tag(), "  Setting : %s", g_config_info->setting);
+               SLOG(LOG_DEBUG, stt_tag(), "  language : %s", g_config_info->language);
+               SLOG(LOG_DEBUG, stt_tag(), "  Silence detection : %s", g_config_info->silence_detection ? "on" : "off");
 
                if (0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language,
                        g_config_info->silence_detection)) {
@@ -1215,7 +1218,7 @@ int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported
                        /*Get handle data from list*/
                        lang = iter_lang->data;
 
-                       SECURE_SLOG(LOG_DEBUG, stt_tag(), " %s", lang);
+                       SLOG(LOG_DEBUG, stt_tag(), " %s", lang);
                        if (NULL != lang) {
                                if (false == callback(engine_info->uuid, lang, user_data))
                                        break;
@@ -1464,11 +1467,11 @@ int __stt_config_mgr_print_engine_info()
        while (NULL != iter) {
                engine_info = iter->data;
 
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), "[%dth]", i);
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name);
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), " id   : %s", engine_info->uuid);
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting);
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), " agreement : %s", engine_info->agreement);
+               SLOG(LOG_DEBUG, stt_tag(), "[%dth]", i);
+               SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name);
+               SLOG(LOG_DEBUG, stt_tag(), " id   : %s", engine_info->uuid);
+               SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting);
+               SLOG(LOG_DEBUG, stt_tag(), " agreement : %s", engine_info->agreement);
 
                SLOG(LOG_DEBUG, stt_tag(), " languages");
                GSList *iter_lang = NULL;
@@ -1482,7 +1485,7 @@ int __stt_config_mgr_print_engine_info()
                                /*Get handle data from list*/
                                lang = iter_lang->data;
 
-                               SECURE_SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", j, lang);
+                               SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", j, lang);
 
                                /*Get next item*/
                                iter_lang = g_slist_next(iter_lang);
@@ -1491,7 +1494,7 @@ int __stt_config_mgr_print_engine_info()
                } else {
                        SLOG(LOG_ERROR, stt_tag(), "  language is NONE");
                }
-               SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", 
+               SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", 
                        engine_info->support_silence_detection ? "true" : "false");
                iter = g_slist_next(iter);
                i++;
@@ -1521,8 +1524,12 @@ int stt_config_mgr_reset_time_info()
 
                g_time_list = g_slist_remove(g_time_list, data);
                if (NULL != data) {
-                       if (NULL == data->text) free(data->text);
+                       if (NULL != data->text) {
+                               free(data->text);
+                               data->text = NULL;
+                       }
                        free(data);
+                       data = NULL;
                }
 
                /*Get next item*/
@@ -1598,8 +1605,12 @@ int stt_config_mgr_foreach_time_info(stt_config_result_time_cb callback, void* u
                if (NULL != data) {
                        temp_time = g_slist_remove(temp_time, data);
 
-                       if (NULL == data->text) free(data->text);
+                       if (NULL != data->text) {
+                               free(data->text);
+                               data->text = NULL;
+                       }
                        free(data);
+                       data = NULL;
                }
 
                /*Get next item*/
@@ -1631,4 +1642,4 @@ int stt_config_mgr_remove_time_info_file()
        stt_parser_clear_time_info();
 
        return STT_CONFIG_ERROR_NONE;
-}
\ No newline at end of file
+}
index a779086..c64ae6c 100644 (file)
@@ -108,7 +108,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info
                                temp->name = strdup((char*)key);
                                xmlFree(key);
                        } else {
-                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_NAME);
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_NAME);
                        }
                } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_ID)) {
                        key = xmlNodeGetContent(cur);
@@ -118,7 +118,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info
                                temp->uuid = strdup((char*)key);
                                xmlFree(key);
                        } else {
-                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_ID);
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_ID);
                        }
                } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_SETTING)) {
                        key = xmlNodeGetContent(cur);
@@ -155,7 +155,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info
                                                temp->languages = g_slist_append(temp->languages, temp_lang);
                                                xmlFree(key);
                                        } else {
-                                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_LANGUAGE);
+                                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_LANGUAGE);
                                        }
                                }
 
@@ -173,7 +173,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info
 
                                xmlFree(key);
                        } else {
-                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SILENCE_SUPPORT);
+                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SILENCE_SUPPORT);
                        }
                } else {
 
@@ -186,7 +186,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info
 
        if (NULL == temp->name || NULL == temp->uuid) {
                /* Invalid engine */
-               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Invalid engine : %s", path);
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Invalid engine : %s", path);
                stt_parser_free_engine_info(temp);
                return -1;
        }
@@ -235,9 +235,9 @@ int stt_parser_print_engine_info(stt_engine_info_s* engine_info)
                return -1;
 
        SLOG(LOG_DEBUG, stt_tag(), "== get engine info ==");
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name);
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), " id   : %s", engine_info->uuid);
-       if (NULL != engine_info->setting)       SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting);
+       SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name);
+       SLOG(LOG_DEBUG, stt_tag(), " id   : %s", engine_info->uuid);
+       if (NULL != engine_info->setting)       SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting);
 
        SLOG(LOG_DEBUG, stt_tag(), " languages");
        GSList *iter = NULL;
@@ -251,7 +251,7 @@ int stt_parser_print_engine_info(stt_engine_info_s* engine_info)
                        /*Get handle data from list*/
                        lang = iter->data;
 
-                       SECURE_SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", i, lang);
+                       SLOG(LOG_DEBUG, stt_tag(), "  [%dth] %s", i, lang);
 
                        /*Get next item*/
                        iter = g_slist_next(iter);
@@ -260,7 +260,7 @@ int stt_parser_print_engine_info(stt_engine_info_s* engine_info)
        } else {
                SLOG(LOG_ERROR, stt_tag(), "  language is NONE");
        }
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", engine_info->support_silence_detection ? "true" : "false");
+       SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", engine_info->support_silence_detection ? "true" : "false");
        SLOG(LOG_DEBUG, stt_tag(), "=====================");
 
        return 0;
@@ -282,7 +282,7 @@ int stt_parser_load_config(stt_config_s** config_info)
        if (doc == NULL) {
                doc = xmlParseFile(STT_DEFAULT_CONFIG);
                if (doc == NULL) {
-                       SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG);
+                       SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG);
                        return -1;
                }
                is_default_open = true;
@@ -296,7 +296,7 @@ int stt_parser_load_config(stt_config_s** config_info)
        }
 
        if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
-               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
                xmlFreeDoc(doc);
                return -1;
        }
@@ -335,7 +335,7 @@ int stt_parser_load_config(stt_config_s** config_info)
                } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_SETTING)) {
                        key = xmlNodeGetContent(cur);
                        if (NULL != key) {
-                               /*SECURE_SLOG(LOG_DEBUG, stt_tag(), "Setting path : %s", (char *)key); */
+                               /*SLOG(LOG_DEBUG, stt_tag(), "Setting path : %s", (char *)key); */
                                if (NULL != temp->setting)      free(temp->setting);
                                temp->setting = strdup((char*)key);
                                xmlFree(key);
@@ -346,7 +346,7 @@ int stt_parser_load_config(stt_config_s** config_info)
                } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_AUTO_LANGUAGE)) {
                        key = xmlNodeGetContent(cur);
                        if (NULL != key) {
-                               /*SECURE_SLOG(LOG_DEBUG, stt_tag(), "Auto language : %s", (char *)key); */
+                               /*SLOG(LOG_DEBUG, stt_tag(), "Auto language : %s", (char *)key); */
 
                                if (0 == xmlStrcmp(key, (const xmlChar *)"on")) {
                                        temp->auto_lang = true;
@@ -428,7 +428,7 @@ int stt_parser_set_engine(const char* engine_id, const char* setting, const char
        }
 
        if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
-               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
                return -1;
        }
 
@@ -480,7 +480,7 @@ int stt_parser_set_language(const char* language)
        }
 
        if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
-               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
                return -1;
        }
 
@@ -562,7 +562,7 @@ int stt_parser_set_silence_detection(bool value)
        }
 
        if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) {
-               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
                return -1;
        }
 
@@ -605,7 +605,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang
 
        doc = xmlParseFile(STT_CONFIG);
        if (doc == NULL) {
-               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_CONFIG);
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_CONFIG);
                return -1;
        }
 
@@ -618,7 +618,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang
        }
 
        if (xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_BASE_TAG) || xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_BASE_TAG)) {
-               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG);
                xmlFreeDoc(doc);
                return -1;
        }
@@ -643,7 +643,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang
                                        key_new = xmlNodeGetContent(cur_new);
                                        if (NULL != key_new) {
                                                if (0 != xmlStrcmp(key_old, key_new)) {
-                                                       SECURE_SLOG(LOG_DEBUG, stt_tag(), "Old engine id(%s), New engine(%s)", (char*)key_old, (char*)key_new);
+                                                       SLOG(LOG_DEBUG, stt_tag(), "Old engine id(%s), New engine(%s)", (char*)key_old, (char*)key_new);
                                                        if (NULL != *engine)    free(*engine);
                                                        *engine = strdup((char*)key_new);
                                                }
@@ -701,7 +701,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang
                                        key_new = xmlNodeGetContent(cur_new);
                                        if (NULL != key_new) {
                                                if (0 != xmlStrcmp(key_old, key_new)) {
-                                                       SECURE_SLOG(LOG_DEBUG, stt_tag(), "Old language(%s), New language(%s)", (char*)key_old, (char*)key_new);
+                                                       SLOG(LOG_DEBUG, stt_tag(), "Old language(%s), New language(%s)", (char*)key_old, (char*)key_new);
                                                        if (NULL != *language)  free(*language);
                                                        *language = strdup((char*)key_new);
                                                }
@@ -719,7 +719,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang
                                        key_new = xmlNodeGetContent(cur_new);
                                        if (NULL != key_new) {
                                                if (0 != xmlStrcmp(key_old, key_new)) {
-                                                       SECURE_SLOG(LOG_DEBUG, stt_tag(), "Old silence(%s), New silence(%s)", (char*)key_old, (char*)key_new);
+                                                       SLOG(LOG_DEBUG, stt_tag(), "Old silence(%s), New silence(%s)", (char*)key_old, (char*)key_new);
                                                        if (0 == xmlStrcmp(key_new, (const xmlChar*)"on")) {
                                                                *silence = 1;
                                                        } else {
@@ -760,7 +760,7 @@ int stt_parser_set_time_info(GSList* time_list)
        }
 
        if (-1 == remove(STT_TIME_INFO_PATH)) {
-               SECURE_SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH);
+               SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH);
        }
 
        xmlDocPtr doc = NULL;
@@ -768,7 +768,7 @@ int stt_parser_set_time_info(GSList* time_list)
 
        doc = xmlNewDoc((const xmlChar*)"1.0");
        if (doc == NULL) {
-               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make new doc");
+               SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make new doc");
                return -1;
        }
 
@@ -791,10 +791,15 @@ int stt_parser_set_time_info(GSList* time_list)
        while (NULL != iter) {
                data = iter->data;
 
+               if (NULL == data) {
+                       SLOG(LOG_DEBUG, stt_tag(), "data is NULL");
+                       continue;
+               }
+
                xmlNodePtr temp_node = NULL;
 
                SLOG(LOG_DEBUG, stt_tag(), "[%d] i(%d) t(%s) s(%d) e(%d)",
-                        data->index, data->event, data->text, data->start_time, data->end_time);
+                       data->index, data->event, data->text, data->start_time, data->end_time);
 
                temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_TEXT);
                xmlNodeSetContent(temp_node, (const xmlChar*)data->text);
@@ -912,7 +917,7 @@ int stt_parser_get_time_info(GSList** time_list)
                                                temp_info->text = strdup((char*)key);
                                                xmlFree(key);
                                        } else {
-                                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_TEXT);
+                                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_TEXT);
                                                free(temp_info);
                                                break;
                                        }
@@ -929,7 +934,7 @@ int stt_parser_get_time_info(GSList** time_list)
                                                temp_info->start_time = atoi((char*)key);
                                                xmlFree(key);
                                        } else {
-                                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_START);
+                                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_START);
                                                if (NULL != temp_info->text)    free(temp_info->text);
                                                free(temp_info);
                                                break;
@@ -947,7 +952,7 @@ int stt_parser_get_time_info(GSList** time_list)
                                                temp_info->end_time = atoi((char*)key);
                                                xmlFree(key);
                                        } else {
-                                               SECURE_SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_END);
+                                               SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_END);
                                                if (NULL != temp_info->text)    free(temp_info->text);
                                                free(temp_info);
                                                break;
@@ -973,7 +978,7 @@ int stt_parser_get_time_info(GSList** time_list)
 int stt_parser_clear_time_info()
 {
        if (-1 == remove(STT_TIME_INFO_PATH)) {
-               SECURE_SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH);
+               /* SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH); */
        }
 
        return 0;
index 1a9921e..35e5215 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -25,9 +25,9 @@ extern "C" {
 * Definition for Dbus
 *******************************************************************************************/
 
-#define STT_CLIENT_SERVICE_NAME         "org.tizen.stt.client"
-#define STT_CLIENT_SERVICE_OBJECT_PATH  "/org/tizen/stt/client"
-#define STT_CLIENT_SERVICE_INTERFACE    "org.tizen.stt.client"
+#define STT_CLIENT_SERVICE_NAME         "org.tizen.voice.sttclient"
+#define STT_CLIENT_SERVICE_OBJECT_PATH  "/org/tizen/voice/sttclient"
+#define STT_CLIENT_SERVICE_INTERFACE    "org.tizen.voice.sttclient"
 
 #define STT_SERVER_SERVICE_NAME         "org.tizen.voice.sttserver"
 #define STT_SERVER_SERVICE_OBJECT_PATH  "/org/tizen/voice/sttserver"
@@ -61,34 +61,26 @@ extern "C" {
 #define STTD_METHOD_ERROR              "sttd_method_error"
 #define STTD_METHOD_HELLO              "sttd_method_hello"
 #define STTD_METHOD_SET_STATE          "sttd_method_set_state"
-#define STTD_METHOD_GET_STATE          "sttd_method_get_state"
+#define STTD_METHOD_SET_VOLUME         "sttd_method_set_volume"
+
 
 /******************************************************************************************
 * Defines for configuration
 *******************************************************************************************/
 
-#define STT_AUDIO_VOLUME_PATH          "/tmp/stt_vol"
-
 #define STT_TIME_INFO_PATH             tzplatform_mkpath(TZ_USER_HOME, "share/.voice/stt-time.xml")
 
-#ifdef LIB64
-#define STT_USR_BASE                   "/usr/lib64/voice"
-#else
-#define STT_USR_BASE                   "/usr/lib/voice"
-#endif
-#define STT_OPT_BASE                   "/opt/usr/data/voice"
-
-#define STT_DEFAULT_CONFIG             STT_USR_BASE"/stt/1.0/stt-config.xml"
+#define STT_DEFAULT_CONFIG             STT_LIBDIR"/voice/stt/1.0/stt-config.xml"
 #define STT_CONFIG                     tzplatform_mkpath(TZ_USER_HOME, "share/.voice/stt-config.xml")
 
-#define STT_DEFAULT_ENGINE             STT_USR_BASE"/stt/1.0/engine"
-#define STT_DOWNLOAD_ENGINE            STT_OPT_BASE"/stt/1.0/engine"
+#define STT_DEFAULT_ENGINE             STT_LIBDIR"/voice/stt/1.0/engine"
+#define STT_DOWNLOAD_ENGINE            tzplatform_mkpath(TZ_USER_HOME, "share/.voice/stt/1.0/engine")
 
-#define STT_DEFAULT_ENGINE_INFO                STT_USR_BASE"/stt/1.0/engine-info"
-#define STT_DOWNLOAD_ENGINE_INFO       STT_OPT_BASE"/stt/1.0/engine-info"
+#define STT_DEFAULT_ENGINE_INFO                STT_LIBDIR"/voice/stt/1.0/engine-info"
+#define STT_DOWNLOAD_ENGINE_INFO       tzplatform_mkpath(TZ_USER_HOME, "share/.voice/stt/1.0/engine-info")
 
-#define STT_DEFAULT_ENGINE_SETTING     STT_USR_BASE"/stt/1.0/engine-setting"
-#define STT_DOWNLOAD_ENGINE_SETTING    STT_OPT_BASE"/stt/1.0/engine-setting"
+#define STT_DEFAULT_ENGINE_SETTING     STT_LIBDIR"/voice/stt/1.0/engine-setting"
+#define STT_DOWNLOAD_ENGINE_SETTING    tzplatform_mkpath(TZ_USER_HOME, "share/.voice/stt/1.0/engine-setting")
 
 #define STT_BASE_LANGUAGE              "en_US"
 
index 1b315bb..3bc518a 100644 (file)
@@ -206,7 +206,7 @@ int stt_engine_load(int engine_id, const char* filepath)
                return STTP_ERROR_OPERATION_FAILED;
        }
 
-       SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Engine Success] Load engine : version(%d), size(%d)", engine->pefuncs->version, engine->pefuncs->size);
+       SLOG(LOG_DEBUG, stt_tag(), "[Engine Success] Load engine : version(%d), size(%d)", engine->pefuncs->version, engine->pefuncs->size);
 
        g_engine_list = g_slist_append(g_engine_list, engine);
 
index 3e99067..45bb97a 100644 (file)
@@ -11,7 +11,7 @@
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 #ifndef __STT_FILE_H__
@@ -84,7 +84,7 @@ typedef enum {
 }stt_file_result_time_event_e;
 
 /**
-* @brief Recognition type : Continuous free dictation. 
+* @brief Recognition type : Continuous free dictation.
 */
 #define STT_RECOGNITION_TYPE_FREE_PARTIAL      "stt.recognition.type.FREE.PARTIAL"
 
@@ -97,7 +97,7 @@ typedef enum {
 * @param[in] user_data User data passed from the stt_file_setting_foreach_supported_engines().
 *
 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre stt_file_foreach_supported_engines() will invoke this callback. 
+* @pre stt_file_foreach_supported_engines() will invoke this callback.
 *
 * @see stt_file_foreach_supported_engines()
 */
@@ -120,7 +120,7 @@ typedef bool(*stt_file_supported_engine_cb)(const char* engine_id, const char* e
 * @see stt_file_set_recognition_result_cb()
 * @see stt_file_unset_recognition_result_cb()
 */
-typedef void (*stt_file_recognition_result_cb)(stt_file_result_event_e event, const char** data, int data_count, 
+typedef void (*stt_file_recognition_result_cb)(stt_file_result_event_e event, const char** data, int data_count,
                                          const char* msg, void *user_data);
 
 /**
@@ -139,11 +139,11 @@ typedef void (*stt_file_recognition_result_cb)(stt_file_result_event_e event, co
 *
 * @see stt_file_recognition_result_cb()
 */
-typedef bool (*stt_file_result_time_cb)(int index, stt_file_result_time_event_e event, const char* text, 
+typedef bool (*stt_file_result_time_cb)(int index, stt_file_result_time_event_e event, const char* text,
                                   long start_time, long end_time, void* user_data);
 
 /**
-* @brief Called when the state of STT FILE is changed. 
+* @brief Called when the state of STT FILE is changed.
 *
 * @param[in] previous A previous state
 * @param[in] current A current state
@@ -157,7 +157,7 @@ typedef bool (*stt_file_result_time_cb)(int index, stt_file_result_time_event_e
 typedef void (*stt_file_state_changed_cb)(stt_file_state_e previous, stt_file_state_e current, void* user_data);
 
 /**
-* @brief Called to retrieve the supported languages. 
+* @brief Called to retrieve the supported languages.
 *
 * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
 *              followed by ISO 639-1 for the two-letter language code. \n
@@ -165,7 +165,7 @@ typedef void (*stt_file_state_changed_cb)(stt_file_state_e previous, stt_file_st
 * @param[in] user_data The user data passed from the foreach function
 *
 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre stt_file_foreach_supported_languages() will invoke this callback. 
+* @pre stt_file_foreach_supported_languages() will invoke this callback.
 *
 * @see stt_file_foreach_supported_languages()
 */
@@ -184,9 +184,9 @@ typedef bool (*stt_file_supported_language_cb)(const char* language, void* user_
 * @pre The state should be #STT_FILE_STATE_NONE.
 * @post If this function is called, the STT state will be #STT_FILE_STATE_READY.
 *
-* @see stt_file_deinitialize()
+* @see stt_file_deinitialize(void)
 */
-int stt_file_initialize();
+int stt_file_initialize(void);
 
 /**
 * @brief Deinitialize STT FILE.
@@ -198,9 +198,9 @@ int stt_file_initialize();
 * @pre The state should be #STT_FILE_STATE_READY.
 * @post If this function is called, the STT FILE state will be #STT_FILE_STATE_NONE.
 *
-* @see stt_file_initialize()
+* @see stt_file_initialize(void)
 */
-int stt_file_deinitialize();
+int stt_file_deinitialize(void);
 
 /**
 * @brief Gets the current state.
@@ -228,7 +228,7 @@ int stt_file_get_state(stt_file_state_e* state);
 * @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure.
 *
 * @pre The state should be #STT_FILE_STATE_READY.
-* @post        This function invokes stt_file_supported_engine_cb() repeatedly for getting engine information. 
+* @post        This function invokes stt_file_supported_engine_cb() repeatedly for getting engine information.
 *
 * @see stt_file_supported_engine_cb()
 */
@@ -245,7 +245,7 @@ int stt_file_foreach_supported_engines(stt_file_supported_engine_cb callback, vo
 * @retval #STT_FILE_ERROR_NONE Success.
 * @retval #STT_FILE_ERROR_OUT_OF_MEMORY Out of memory.
 * @retval #STT_FILE_ERROR_INVALID_PARAMETER Invalid parameter.
-* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state. 
+* @retval #STT_FILE_ERROR_INVALID_STATE Invalid state.
 * @retval #STT_FILE_ERROR_OPERATION_FAILED Operation failure.
 *
 * @pre The state should be #STT_FILE_STATE_READY.
@@ -285,7 +285,7 @@ int stt_file_set_engine(const char* engine_id);
 * @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
 *
 * @pre The state should be #STT_FILE_STATE_READY.
-* @post        This function invokes stt_file_supported_language_cb() repeatedly for getting languages. 
+* @post        This function invokes stt_file_supported_language_cb() repeatedly for getting languages.
 *
 * @see stt_file_supported_language_cb()
 * @see stt_file_get_default_language()
@@ -316,7 +316,7 @@ int stt_file_foreach_supported_languages(stt_file_supported_language_cb callback
 *
 * @see stt_file_cancel()
 */
-int stt_file_start(const char* language, const char* type, const char* filepath, 
+int stt_file_start(const char* language, const char* type, const char* filepath,
                        stt_file_audio_type_e audio_type, int sample_rate);
 
 /**
@@ -333,7 +333,7 @@ int stt_file_start(const char* language, const char* type, const char* filepath,
 *
 * @see stt_file_start()
 */
-int stt_file_cancel();
+int stt_file_cancel(void);
 
 
 /**
@@ -349,7 +349,7 @@ int stt_file_cancel();
 * @retval #STT_FILE_ERROR_INVALID_STATE Invalid state
 *
 * @pre This function should be called in stt_file_recognition_result_cb().
-* @post        This function invokes stt_file_result_time_cb() repeatedly for getting time information. 
+* @post        This function invokes stt_file_result_time_cb() repeatedly for getting time information.
 *
 * @see stt_file_result_time_cb()
 * @see stt_file_recognition_result_cb()
@@ -385,7 +385,7 @@ int stt_file_set_recognition_result_cb(stt_file_recognition_result_cb callback,
 *
 * @see stt_file_set_recognition_result_cb()
 */
-int stt_file_unset_recognition_result_cb();
+int stt_file_unset_recognition_result_cb(void);
 
 /**
 * @brief Registers a callback function to be called when STT FILE state changes.
@@ -417,7 +417,7 @@ int stt_file_set_state_changed_cb(stt_file_state_changed_cb callback, void* user
 *
 * @see stt_file_set_state_changed_cb()
 */
-int stt_file_unset_state_changed_cb();
+int stt_file_unset_state_changed_cb(void);
 
 
 #ifdef __cplusplus
index 12b72be..483e5e8 100644 (file)
@@ -1,5 +1,5 @@
 [D-BUS Service]
 Name=org.tizen.voice.sttserver
 Exec=/usr/bin/stt-daemon
-User=root
-Group=root
+User=app
+Group=app
index 153b304..a18be17 100644 (file)
@@ -22,7 +22,6 @@ BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(vconf)
 
-
 BuildRequires:  cmake
 
 %description
@@ -89,17 +88,9 @@ install LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
 %post 
 /sbin/ldconfig
 
-mkdir -p /usr/lib/voice
-
-mkdir -p /usr/share/voice
-
-mkdir -p /opt/home/app/.voice
-chown 5000:5000 /opt/home/app/.voice
+mkdir -p %{_libdir}/voice/
 
-mkdir -p /opt/usr/data/voice/stt/1.0
-chown 5000:5000 /opt/usr/data/voice
-chown 5000:5000 /opt/usr/data/voice/stt
-chown 5000:5000 /opt/usr/data/voice/stt/1.0
+mkdir -p /usr/share/voice/test
 
 
 %postun -p /sbin/ldconfig
@@ -108,14 +99,12 @@ chown 5000:5000 /opt/usr/data/voice/stt/1.0
 %manifest %{name}.manifest
 %license LICENSE.APLv2
 %defattr(-,root,root,-)
-%{_libdir}/libstt.so
-%{_libdir}/libstt_file.so
-%{_libdir}/libstt_setting.so
-/usr/lib/voice/stt/1.0/stt-config.xml
+%{_libdir}/lib*.so
+%{_libdir}/voice/stt/1.0/stt-config.xml
 %{_bindir}/stt-daemon
-/etc/dbus-1/system.d/stt-server.conf
-/usr/share/dbus-1/system-services/org.tizen.voice.sttserver.service
-/opt/usr/devel/bin/stt-test
+/usr/share/dbus-1/services/org.tizen.voice*
+/etc/dbus-1/session.d/stt-server.conf
+/usr/share/voice/test/stt-test
 /usr/share/license/%{name}
 
 %files devel
index 841cd9c..0d8cc6a 100644 (file)
@@ -22,8 +22,8 @@ FOREACH(flag ${pkgs_CFLAGS})
 ENDFOREACH(flag)
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_C_FLAGS_RELEASE "-O2")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fPIE")
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIE")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
index 8029b57..6331a08 100644 (file)
@@ -443,7 +443,7 @@ int stt_client_set_app_agreed(int uid)
 
        tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -460,7 +460,7 @@ bool stt_client_get_app_agreed(int uid)
 
        tmp = __client_get_item(uid);
        if (NULL == tmp) {
-               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
+               SLOG(LOG_ERROR, TAG_STTD, "[Client Data ERROR] uid(%d) is NOT valid", uid);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
index e7b9d09..ed0ab08 100644 (file)
@@ -28,6 +28,7 @@ static Ecore_Fd_Handler* g_dbus_fd_handler = NULL;
 
 static int g_waiting_time = 3000;
 
+static int g_internal_result_id = 0;
 
 int sttdc_send_hello(int uid)
 {
@@ -39,19 +40,19 @@ int sttdc_send_hello(int uid)
 
        char service_name[64];
        memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s", STT_CLIENT_SERVICE_NAME);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
        char target_if_name[128];
-       snprintf(target_if_name, sizeof(target_if_name), "%s", STT_CLIENT_SERVICE_INTERFACE);
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg = NULL;
 
-       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send hello message : uid(%d)", uid);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send hello message : uid(%d)", uid);
 
        msg = dbus_message_new_method_call(
-               service_name, 
-               STT_CLIENT_SERVICE_OBJECT_PATH, 
-               target_if_name, 
+               service_name,
+               STT_CLIENT_SERVICE_OBJECT_PATH,
+               target_if_name,
                STTD_METHOD_HELLO);
 
        if (NULL == msg) {
@@ -70,6 +71,13 @@ int sttdc_send_hello(int uid)
        dbus_message_unref(msg);
        if (dbus_error_is_set(&err)) {
                SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Send error (%s)", err.message);
+               if (NULL != err.name) {
+                       if (!strcmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN)) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Unknown service. Client is not available");
+                               dbus_error_free(&err);
+                               return 0;
+                       }
+               }
                dbus_error_free(&err);
        }
 
@@ -77,9 +85,8 @@ int sttdc_send_hello(int uid)
                dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
 
                if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Get arguments error (%s)\n", err.message);
+                       SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Get arguments error (%s)", err.message);
                        dbus_error_free(&err);
-                       result = -1;
                }
 
                dbus_message_unref(result_msg);
@@ -90,7 +97,7 @@ int sttdc_send_hello(int uid)
        return result;
 }
 
-int sttdc_send_set_state(int uid, int state)
+int sttdc_send_set_volume(int uid, float volume)
 {
        int pid = sttd_client_get_pid(uid);
 
@@ -101,20 +108,19 @@ int sttdc_send_set_state(int uid, int state)
 
        char service_name[64];
        memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s", STT_CLIENT_SERVICE_NAME);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
        char target_if_name[128];
-       snprintf(target_if_name, sizeof(target_if_name), "%s", STT_CLIENT_SERVICE_INTERFACE);
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg;
 
-       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send change state message : uid(%d), state(%d)", uid, state);
+       /* SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send set volume : uid(%d), volume(%f) volume size(%d)", uid, volume, sizeof(float)); */
 
-       msg = dbus_message_new_method_call(
-               service_name,
-               STT_CLIENT_SERVICE_OBJECT_PATH,
-               target_if_name,
-               STTD_METHOD_SET_STATE);
+       msg = dbus_message_new_signal(
+               STT_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
+               target_if_name,                 /* interface name of the signal */
+               STTD_METHOD_SET_VOLUME);        /* name of the signal */
 
        if (NULL == msg) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
@@ -123,24 +129,22 @@ int sttdc_send_set_state(int uid, int state)
 
        dbus_message_append_args(msg,
                DBUS_TYPE_INT32, &uid,
-               DBUS_TYPE_INT32, &state,
+               DBUS_TYPE_INT32, &volume,
                DBUS_TYPE_INVALID);
 
-       dbus_message_set_no_reply(msg, TRUE);
-
        if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send message : Out Of Memory !");
        } else {
-               SLOG(LOG_DEBUG, TAG_STTD, "<<<< Send error message : uid(%d), state(%d)", uid, state);
+               SLOG(LOG_DEBUG, TAG_STTD, "<<<< Send set volume : uid(%d), volume(%f)", uid, volume);
                dbus_connection_flush(g_conn_sender);
        }
 
-       dbus_connection_flush(g_conn_sender);
        dbus_message_unref(msg);
 
        return 0;
 }
-int sttdc_send_get_state(int uid, int* state)
+
+int sttdc_send_set_state(int uid, int state)
 {
        int pid = sttd_client_get_pid(uid);
 
@@ -151,61 +155,37 @@ int sttdc_send_get_state(int uid, int* state)
 
        char service_name[64];
        memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s", STT_CLIENT_SERVICE_NAME);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
        char target_if_name[128];
-       snprintf(target_if_name, sizeof(target_if_name), "%s", STT_CLIENT_SERVICE_INTERFACE);
-
-       DBusMessage* msg;
-
-       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] Send get state message : uid(%d)", uid);
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
-       msg = dbus_message_new_method_call(
-               service_name, 
-               STT_CLIENT_SERVICE_OBJECT_PATH, 
-               target_if_name, 
-               STTD_METHOD_GET_STATE);
+       DBusMessage* msg = NULL;
+       msg = dbus_message_new_signal(
+               STT_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
+               target_if_name,                 /* interface name of the signal */
+               STTD_METHOD_SET_STATE);         /* name of the signal */
 
        if (NULL == msg) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
                return -1;
        }
 
-       dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
-
-       DBusError err;
-       dbus_error_init(&err);
-
-       DBusMessage* result_msg;
-       int tmp = -1;
-       int result = 0;
-
-       result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
-       dbus_message_unref(msg);
-       if (dbus_error_is_set(&err)) {
-               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Send error (%s)", err.message);
-               dbus_error_free(&err);
-       }
-
-       if (NULL != result_msg) {
-               dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &tmp, DBUS_TYPE_INVALID);
-
-               if (dbus_error_is_set(&err)) {
-                       SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Get arguments error (%s)\n", err.message);
-                       dbus_error_free(&err);
-                       result = -1;
-               } else {
-                       *state = tmp;
-                       result = 0;
-               }
+       dbus_message_append_args(msg,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_INT32, &state,
+               DBUS_TYPE_INVALID);
 
-               dbus_message_unref(result_msg);
+       if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send change state message : Out Of Memory !");
        } else {
-               SLOG(LOG_ERROR, TAG_STTD, "[Dbus] Result message is NULL. Client is not available");
-               result = -1;
+               SLOG(LOG_DEBUG, TAG_STTD, "<<<< Send change state message : uid(%d), state(%d)", uid, state);
+               dbus_connection_flush(g_conn_sender);
        }
 
-       return result;
+       dbus_message_unref(msg);
+
+       return 0;
 }
 
 int sttdc_send_result(int uid, int event, const char** data, int data_count, const char* result_msg)
@@ -218,20 +198,20 @@ int sttdc_send_result(int uid, int event, const char** data, int data_count, con
 
        char service_name[64];
        memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s", STT_CLIENT_SERVICE_NAME);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
        char target_if_name[128];
        memset(target_if_name, 0, 128);
-       snprintf(target_if_name, sizeof(target_if_name), "%s", STT_CLIENT_SERVICE_INTERFACE);
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg = NULL;
-       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), event(%d), result count(%d)", uid, event, data_count);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), event(%d), result count(%d) result id(%d)", 
+               uid, event, data_count, g_internal_result_id);
 
-       msg = dbus_message_new_method_call(
-               service_name, 
-               STT_CLIENT_SERVICE_OBJECT_PATH, 
-               target_if_name, 
-               STTD_METHOD_RESULT);
+       msg = dbus_message_new_signal(
+               STT_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
+               target_if_name,                 /* interface name of the signal */
+               STTD_METHOD_RESULT);            /* name of the signal */
 
        if (NULL == msg) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
@@ -261,14 +241,27 @@ int sttdc_send_result(int uid, int event, const char** data, int data_count, con
        /* Append result size */
        if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(data_count))) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus] response message : Fail to append result size");
+               dbus_message_unref(msg);
+               return -1;
+       }
+
+       if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &(g_internal_result_id))) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Dbus] response message : Fail to append internal result id");
+               dbus_message_unref(msg);
                return -1;
        }
 
+       g_internal_result_id++;
+
+       if (10000 == g_internal_result_id) {
+               g_internal_result_id = 1;
+       }
+
        int i;
-       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result size (%d)", data_count);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result size (%d)", data_count);
        for (i = 0; i < data_count; i++) {
                if (NULL != data[i]) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result (%d, %s)", i, data[i]);
+                       SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] result (%d, %s)", i, data[i] );
 
                        if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &data[i])) {
                                SLOG(LOG_ERROR, TAG_STTD, "[Dbus] response message : Fail to append result data");
@@ -291,8 +284,6 @@ int sttdc_send_result(int uid, int event, const char** data, int data_count, con
                }
        }
 
-       dbus_message_set_no_reply(msg, TRUE);
-
        if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to send message : Out Of Memory !");
        }
@@ -318,26 +309,25 @@ int sttdc_send_error_signal(int uid, int reason, const char *err_msg)
 
        char service_name[64];
        memset(service_name, 0, 64);
-       snprintf(service_name, 64, "%s", STT_CLIENT_SERVICE_NAME);
+       snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
 
        char target_if_name[128];
-       snprintf(target_if_name, sizeof(target_if_name), "%s", STT_CLIENT_SERVICE_INTERFACE);
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
 
        DBusMessage* msg = NULL;
-       msg = dbus_message_new_method_call(
-               service_name, 
-               STT_CLIENT_SERVICE_OBJECT_PATH, 
-               target_if_name, 
-               STTD_METHOD_ERROR);
+       msg = dbus_message_new_signal(
+               STT_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
+               target_if_name,                 /* interface name of the signal */
+               STTD_METHOD_ERROR);             /* name of the signal */
 
        if (NULL == msg) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
                return STTD_ERROR_OUT_OF_MEMORY;
        }
 
-       dbus_message_append_args(msg, 
-               DBUS_TYPE_INT32, &uid, 
-               DBUS_TYPE_INT32, &reason, 
+       dbus_message_append_args(msg,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_INT32, &reason,
                DBUS_TYPE_STRING, &err_msg,
                DBUS_TYPE_INVALID);
 
@@ -435,7 +425,7 @@ int sttd_dbus_open_connection()
        int ret;
 
        /* Create connection for sender */
-       g_conn_sender = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+       g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
        if (dbus_error_is_set(&err)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
                dbus_error_free(&err);
@@ -447,7 +437,7 @@ int sttd_dbus_open_connection()
        }
 
        /* connect to the bus and check for errors */
-       g_conn_listener = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
+       g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
 
        if (dbus_error_is_set(&err)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail dbus_bus_get : %s", err.message);
@@ -483,6 +473,7 @@ int sttd_dbus_open_connection()
 
        if (dbus_error_is_set(&err)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] dbus_bus_add_match() : %s", err.message);
+               dbus_error_free(&err);
                return STTD_ERROR_OPERATION_FAILED;
        }
 
@@ -515,6 +506,9 @@ int sttd_dbus_close_connection()
                dbus_error_free(&err);
        }
 
+       dbus_connection_close(g_conn_listener);
+       dbus_connection_close(g_conn_sender);
+
        g_conn_listener = NULL;
        g_conn_sender = NULL;
 
index bb6b3fa..9311eca 100644 (file)
@@ -26,7 +26,7 @@ int sttd_dbus_close_connection();
 
 int sttdc_send_hello(int uid);
 
-int sttdc_send_get_state(int uid, int* state);
+int sttdc_send_set_volume(int uid, float volume);
 
 int sttdc_send_set_state(int uid, int state);
 
index 358357d..c693317 100644 (file)
@@ -69,7 +69,7 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt initialize : pid(%d), uid(%d)", pid , uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt initialize : pid(%d), uid(%d)", pid , uid); 
                ret =  sttd_server_initialize(pid, uid, &silence_supported);
        }
 
@@ -83,7 +83,7 @@ int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d)", 
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d)", 
                                ret, silence_supported); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
@@ -121,7 +121,7 @@ int sttd_dbus_server_finalize(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt finalize : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt finalize : uid(%d)", uid); 
                ret =  sttd_server_finalize(uid);
        }
 
@@ -172,7 +172,7 @@ int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported engines : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported engines : uid(%d)", uid); 
                ret = sttd_server_get_supported_engines(uid, &engine_list);
        }
 
@@ -203,7 +203,7 @@ int sttd_dbus_server_get_support_engines(DBusConnection* conn, DBusMessage* msg)
 
                                        if (NULL != engine) {
                                                if (NULL != engine->engine_id && NULL != engine->engine_name && NULL != engine->ug_name) {
-                                                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "engine id : %s, engine name : %s, ug_name, : %s", 
+                                                       SLOG(LOG_DEBUG, TAG_STTD, "engine id : %s, engine name : %s, ug_name, : %s", 
                                                                engine->engine_id, engine->engine_name, engine->ug_name);
 
                                                        dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &(engine->engine_id));
@@ -270,7 +270,7 @@ int sttd_dbus_server_set_current_engine(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set current engine : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set current engine : uid(%d)", uid); 
                ret = sttd_server_set_current_engine(uid, engine_id, &silence_supported);
        }
 
@@ -284,7 +284,7 @@ int sttd_dbus_server_set_current_engine(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d)", 
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d)", 
                                ret, silence_supported);
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d) ", ret);
@@ -324,7 +324,7 @@ int sttd_dbus_server_get_current_engine(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get current engine : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get current engine : uid(%d)", uid); 
                ret = sttd_server_get_current_engine(uid, &engine);
        }
 
@@ -386,8 +386,8 @@ int sttd_dbus_server_check_app_agreed(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt Is engine available : uid(%d)", uid);
-               ret = sttd_server_check_agg_agreed(uid, appid, &available);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt Is engine available : uid(%d)", uid); 
+               ret = sttd_server_check_app_agreed(uid, appid, &available);
        }
 
        DBusMessage* reply;
@@ -440,7 +440,7 @@ int sttd_dbus_server_get_support_lang(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported langs : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt supported langs : uid(%d)", uid); 
                ret = sttd_server_get_supported_languages(uid, &lang_list);
        }
 
@@ -519,7 +519,7 @@ int sttd_dbus_server_get_default_lang(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get default lang : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt get default lang : uid(%d)", uid); 
                ret = sttd_server_get_current_langauage(uid, &lang);
        }
 
@@ -578,7 +578,7 @@ int sttd_dbus_server_is_recognition_type_supported(DBusConnection* conn, DBusMes
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt is recognition type supported : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt is recognition type supported : uid(%d)", uid);
                ret = sttd_server_is_recognition_type_supported(uid, type, &support);
        }
 
@@ -593,7 +593,7 @@ int sttd_dbus_server_is_recognition_type_supported(DBusConnection* conn, DBusMes
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), Support(%s)", ret, support ? "true" : "false");
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), Support(%s)", ret, support ? "true" : "false"); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
@@ -632,7 +632,7 @@ int sttd_dbus_server_set_start_sound(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set start sound : uid(%d) file(%s)", uid, file);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set start sound : uid(%d) file(%s)", uid, file);
                ret = sttd_server_set_start_sound(uid, file);
        }
 
@@ -646,7 +646,7 @@ int sttd_dbus_server_set_start_sound(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret);
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
@@ -684,7 +684,7 @@ int sttd_dbus_server_unset_start_sound(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt unset start sound : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt unset start sound : uid(%d)", uid);
                ret = sttd_server_set_start_sound(uid, NULL);
        }
 
@@ -698,7 +698,7 @@ int sttd_dbus_server_unset_start_sound(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret);
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
@@ -737,7 +737,7 @@ int sttd_dbus_server_set_stop_sound(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set stop sound : uid(%d) file(%s)", uid, file);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt set stop sound : uid(%d) file(%s)", uid, file);
                ret = sttd_server_set_stop_sound(uid, file);
        }
 
@@ -789,7 +789,7 @@ int sttd_dbus_server_unset_stop_sound(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt unset stop sound : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt unset stop sound : uid(%d)", uid);
                ret = sttd_server_set_stop_sound(uid, NULL);
        }
 
@@ -803,7 +803,7 @@ int sttd_dbus_server_unset_stop_sound(DBusConnection* conn, DBusMessage* msg)
                        DBUS_TYPE_INVALID);
 
                if (0 == ret) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret);
+                       SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret); 
                } else {
                        SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
                }
@@ -851,11 +851,21 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%d), lang(%s), type(%s), silence(%d) appid(%s)"
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start : uid(%d), lang(%s), type(%s), silence(%d) appid(%s)"
                        , uid, lang, type, silence, appid); 
                ret = sttd_server_start(uid, lang, type, silence, appid);
        }
 
+       if (0 <= ret) {
+               SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
+               if (0 != sttdc_send_error_signal(uid, ret, "[ERROR] Fail to start")) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to send error signal");
+               }
+       }
+
+#if 0
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
@@ -877,6 +887,7 @@ int sttd_dbus_server_start(DBusConnection* conn, DBusMessage* msg)
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
+#endif
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
@@ -900,10 +911,19 @@ int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt stop : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt stop : uid(%d)", uid); 
                ret = sttd_server_stop(uid);
        }
 
+       if (0 <= ret) {
+               SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
+               if (0 != sttdc_send_error_signal(uid, ret, "[ERROR] Fail to stop")) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to send error signal");
+               }
+       }
+#if 0
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
@@ -925,6 +945,7 @@ int sttd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg)
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
+#endif
 
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
@@ -948,10 +969,19 @@ int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg)
                dbus_error_free(&err);
                ret = STTD_ERROR_OPERATION_FAILED;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt cancel : uid(%d)", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt cancel : uid(%d)", uid); 
                ret = sttd_server_cancel(uid);
        }
 
+       if (0 <= ret) {
+               SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret);
+       } else {
+               SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
+               if (0 != sttdc_send_error_signal(uid, ret, "[ERROR] Fail to cancel")) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to send error signal");
+               }
+       }
+#if 0
        DBusMessage* reply;
        reply = dbus_message_new_method_return(msg);
 
@@ -973,7 +1003,7 @@ int sttd_dbus_server_cancel(DBusConnection* conn, DBusMessage* msg)
        } else {
                SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
        }
-
+#endif
        SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
index 30c498a..4376d7f 100644 (file)
@@ -77,17 +77,17 @@ static silence_dectection_callback g_silence_cb;
 
 
 /** callback functions */
-void __result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count, 
+void __result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count,
                 const char* msg, void* time_info, void *user_data);
 
-bool __result_time_cb(int index, sttp_result_time_event_e event, const char* text, 
+bool __result_time_cb(int index, sttp_result_time_event_e event, const char* text,
                      long start_time, long end_time, void* user_data);
 
 void __detect_silence_cb(sttp_silence_type_e type, void* user_data);
 
 bool __supported_language_cb(const char* language, void* user_data);
 
-void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, 
+void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name,
                      bool use_network, void* user_data);
 
 /*
@@ -102,7 +102,7 @@ int __log_enginelist();
 /*
 * STT Engine Agent Interfaces
 */
-int sttd_engine_agent_init(result_callback result_cb, result_time_callback time_cb, 
+int sttd_engine_agent_init(result_callback result_cb, result_time_callback time_cb,
                           silence_dectection_callback silence_cb)
 {
        /* initialize static data */
@@ -220,7 +220,7 @@ int sttd_engine_agent_release()
        return 0;
 }
 
-void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name, 
+void __engine_info_cb(const char* engine_uuid, const char* engine_name, const char* setting_ug_name,
                      bool use_network, void* user_data)
 {
        sttengine_info_s* temp = (sttengine_info_s*)user_data;
@@ -737,7 +737,7 @@ int sttd_engine_agent_load_current_engine(int uid, const char* engine_uuid)
                return STTD_ERROR_OPERATION_FAILED;
        }
 
-       ret = sttd_recorder_create(engine->engine_id, atype, channels, rate);
+       ret = sttd_recorder_create(engine->engine_id, uid, atype, channels, rate);
        if (0 != ret) {
                SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to create recorder : %d %s", engine->engine_id, engine->engine_name);
                return STTD_ERROR_OPERATION_FAILED;
@@ -1066,7 +1066,7 @@ int __set_option(sttengine_info_s* engine, int silence)
        return 0;
 }
 
-int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const char* recognition_type, 
+int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const char* recognition_type,
                                      int silence, void* user_param)
 {
        if (false == g_agent_init) {
@@ -1143,7 +1143,7 @@ int sttd_engine_agent_recognize_start_engine(int uid, const char* lang, const ch
 
        SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] Create recorder");
 
-       ret = sttd_recorder_create(engine->engine_id, atype, channels, rate);
+       ret = sttd_recorder_create(engine->engine_id, uid, atype, channels, rate);
        if (0 != ret) {
                SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to create recorder : %d %s", engine->engine_id, engine->engine_name);
                return STTD_ERROR_OPERATION_FAILED;
@@ -1396,11 +1396,11 @@ int sttd_engine_agent_set_default_engine(const char* engine_uuid)
                        data = iter->data;
 
                        if (true == data->use_default_engine) {
-                               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] uid(%d) change engine from id(%d) to id(%d)", 
+                               SLOG(LOG_DEBUG, TAG_STTD, "[Engine Agent] uid(%d) change engine from id(%d) to id(%d)",
                                        data->uid, data->engine_id, engine->engine_id);
 
                                if (0 != sttd_engine_agent_load_current_engine(data->uid, NULL)) {
-                                       SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to load current engine : uid(%d)", data->uid);
+                                       SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to load current engine : uid(%d)", data->uid);
                                }
                        }
 
@@ -1446,7 +1446,7 @@ int sttd_engine_agent_set_silence_detection(bool value)
 int sttd_engine_agent_check_app_agreed(int uid, const char* appid, bool* result)
 {
        if (false == g_agent_init) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized"); 
+               SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized");
                return STTD_ERROR_OPERATION_FAILED;
        }
 
@@ -1479,7 +1479,7 @@ int sttd_engine_agent_check_app_agreed(int uid, const char* appid, bool* result)
 * STT Engine Callback Functions                                                                                        `                                 *
 */
 
-void __result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count, 
+void __result_cb(sttp_result_event_e event, const char* type, const char** data, int data_count,
                 const char* msg, void* time_info, void *user_data)
 {
        if (false == g_agent_init) {
index aee8806..0d2c45a 100644 (file)
 #include <audio_io.h>
 #include <Ecore.h>
 #include <math.h>
+#include <pthread.h>
 #include <sound_manager.h>
 
 #include "stt_defs.h"
+#include "sttd_dbus.h"
 #include "sttd_recorder.h"
 #include "sttd_main.h"
 #include "sttp.h"
@@ -25,6 +27,8 @@
 #define FRAME_LENGTH 160
 #define BUFFER_LENGTH FRAME_LENGTH * 2
 
+static pthread_mutex_t sttd_audio_in_handle_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 typedef enum {
        STTD_RECORDER_STATE_NONE = -1,
        STTD_RECORDER_STATE_READY = 0,  /**< Recorder is ready to start */
@@ -33,6 +37,7 @@ typedef enum {
 
 typedef struct {
        int                     engine_id;
+       int                     uid;
        audio_in_h              audio_h;
        sttp_audio_type_e       audio_type;
 } stt_recorder_s;
@@ -47,8 +52,6 @@ static stt_recorder_interrupt_cb      g_interrupt_cb;
 
 static sttd_recorder_state     g_recorder_state = STTD_RECORDER_STATE_NONE;
 
-static FILE* g_pFile_vol;
-
 static int g_buffer_count;
 
 /* Sound buf save for test */
@@ -82,7 +85,7 @@ const char* __stt_get_session_interrupt_code(sound_session_interrupted_code_e co
 void __sttd_recorder_sound_interrupted_cb(sound_session_interrupted_code_e code, void *user_data)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Get the interrupt code from sound mgr : %s",
-                __stt_get_session_interrupt_code(code));
+               __stt_get_session_interrupt_code(code));
 
        if (SOUND_SESSION_INTERRUPTED_COMPLETED == code || SOUND_SESSION_INTERRUPTED_BY_EARJACK_UNPLUG == code)
                return;
@@ -105,6 +108,10 @@ int sttd_recorder_initialize(stt_recorder_audio_cb audio_cb, stt_recorder_interr
                return STTD_ERROR_INVALID_STATE;
        }
 
+       if( 0 != pthread_mutex_init(&sttd_audio_in_handle_mutex, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to initialize audio in handle mutex.");
+       }
+
        g_audio_cb = audio_cb;
        g_interrupt_cb = interrupt_cb;
        g_recorder_state = STTD_RECORDER_STATE_NONE;
@@ -123,6 +130,10 @@ int sttd_recorder_initialize(stt_recorder_audio_cb audio_cb, stt_recorder_interr
 
 int sttd_recorder_deinitialize()
 {
+       if( 0 != pthread_mutex_destroy(&sttd_audio_in_handle_mutex)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to destroy audio in handle mutex.");
+       }
+
        if (0 != sound_manager_unset_session_interrupted_cb()) {
                SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to unset sound interrupt callback");
        }
@@ -146,12 +157,6 @@ int sttd_recorder_deinitialize()
                iter = g_slist_nth(g_recorder_list, 0);
        }
 
-       if (0 == access(STT_AUDIO_VOLUME_PATH, R_OK)) {
-               if (0 != remove(STT_AUDIO_VOLUME_PATH)) {
-                       SLOG(LOG_WARN, TAG_STTD, "[Recorder WARN] Fail to remove volume file");
-               }
-       }
-
        g_recorder_state = STTD_RECORDER_STATE_NONE;
 
        return 0;
@@ -187,7 +192,7 @@ int sttd_recorder_unset_audio_session()
        return 0;
 }
 
-int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, unsigned int sample_rate)
+int sttd_recorder_create(int engine_id, int uid, sttp_audio_type_e type, int channel, unsigned int sample_rate)
 {
        /* Check engine id is valid */
        if (NULL != __get_recorder(engine_id)) {
@@ -211,8 +216,8 @@ int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, uns
        switch (type) {
                case STTP_AUDIO_TYPE_PCM_S16_LE:        audio_type = AUDIO_SAMPLE_TYPE_S16_LE;  break;
                case STTP_AUDIO_TYPE_PCM_U8:            audio_type = AUDIO_SAMPLE_TYPE_U8;      break;
-               default:        
-                       SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Invalid Audio Type"); 
+               default:
+                       SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Invalid Audio Type");
                        return STTD_ERROR_OPERATION_FAILED;
                        break;
        }
@@ -233,6 +238,7 @@ int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, uns
        }
 
        recorder->engine_id = engine_id;
+       recorder->uid = uid;
        recorder->audio_h = temp_in_h;
        recorder->audio_type = type;
 
@@ -245,11 +251,16 @@ int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, uns
 
 int sttd_recorder_destroy(int engine_id)
 {
+       // critical section required because this function can be called from stt engine thread context
+       SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Enter critical section");
+       pthread_mutex_lock(&sttd_audio_in_handle_mutex);
+
        /* Check engine id is valid */
        stt_recorder_s* recorder;
        recorder = __get_recorder(engine_id);
        if (NULL == recorder) {
                SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Engine id is not valid");
+               pthread_mutex_unlock(&sttd_audio_in_handle_mutex);
                return STTD_ERROR_INVALID_PARAMETER;
        }
 
@@ -272,6 +283,9 @@ int sttd_recorder_destroy(int engine_id)
 
        free(recorder);
 
+       pthread_mutex_unlock(&sttd_audio_in_handle_mutex);
+       SLOG(LOG_WARN, TAG_STTD, "[Recorder WARNING] Leave critical section");
+
        return 0;
 }
 
@@ -348,11 +362,12 @@ Eina_Bool __read_audio_func(void *data)
                return EINA_FALSE;
        }
 
-       float vol_db = get_volume_decibel(g_buffer, BUFFER_LENGTH, recorder->audio_type);
-
-       rewind(g_pFile_vol);
-
-       fwrite((void*)(&vol_db), sizeof(vol_db), 1, g_pFile_vol);
+       if (0 == g_buffer_count % 30) {
+               float vol_db = get_volume_decibel(g_buffer, BUFFER_LENGTH, recorder->audio_type);
+               if (0 != sttdc_send_set_volume(recorder->uid, vol_db)) {
+                       SLOG(LOG_ERROR, TAG_STTD, "[Recorder] Fail to send recording volume(%f)", vol_db);
+               }
+       }
 
        /* Audio read log */
        if (0 == g_buffer_count % 50) {
@@ -399,12 +414,6 @@ int sttd_recorder_start(int engine_id)
        g_recorder_state = STTD_RECORDER_STATE_RECORDING;
        g_recording_engine_id = engine_id;
 
-       g_pFile_vol = fopen(STT_AUDIO_VOLUME_PATH, "wb+");
-       if (!g_pFile_vol) {
-               SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Fail to create Volume File");
-               return -1;
-       }
-
        g_buffer_count = 0;
 
 #ifdef BUF_SAVE_MODE
@@ -446,8 +455,6 @@ int sttd_recorder_stop(int engine_id)
        g_recorder_state = STTD_RECORDER_STATE_READY;
        g_recording_engine_id = -1;
 
-       fclose(g_pFile_vol);
-
 #ifdef BUF_SAVE_MODE
        fclose(g_pFile);
 #endif
index 377e8c0..f00b8a8 100644 (file)
@@ -34,7 +34,7 @@ int sttd_recorder_set_audio_session();
 
 int sttd_recorder_unset_audio_session();
 
-int sttd_recorder_create(int engine_id, sttp_audio_type_e type, int channel, unsigned int sample_rate);
+int sttd_recorder_create(int engine_id, int uid, sttp_audio_type_e type, int channel, unsigned int sample_rate);
 
 int sttd_recorder_destroy(int engine_id);
 
index 705129e..62c1d0e 100644 (file)
@@ -11,6 +11,7 @@
 *  limitations under the License.
 */
 
+#include <pthread.h>
 #include <sound_manager.h>
 #include <wav_player.h>
 
@@ -23,6 +24,9 @@
 #include "sttd_recorder.h"
 #include "sttd_server.h"
 
+static pthread_mutex_t sttpe_result_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t sttpe_result_time_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 
 /*
 * STT Server static variable
@@ -36,11 +40,12 @@ Ecore_Timer*        g_processing_timer = NULL;
 
 static int g_recording_log_count = 0;
 
+static GList *g_proc_list = NULL;
+
 /*
 * STT Server Callback Functions
 */
-
-Eina_Bool __stop_by_silence(void *data)
+void __stop_by_silence(void *data)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Stop by silence detection");
 
@@ -52,7 +57,7 @@ Eina_Bool __stop_by_silence(void *data)
        if (0 != uid) {
                ret = sttd_server_stop(uid);
                if (0 > ret) {
-                       return EINA_FALSE;
+                       return;
                }
 
                if (STTD_RESULT_STATE_DONE == ret) {
@@ -72,7 +77,7 @@ Eina_Bool __stop_by_silence(void *data)
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
-       return EINA_FALSE;
+       return;
 }
 
 static void __cancel_recognition_internal()
@@ -105,7 +110,7 @@ static void __cancel_recognition_internal()
        }
 }
 
-Eina_Bool __cancel_by_error(void *data)
+static void __cancel_by_error(void *data)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Cancel by error");
 
@@ -114,7 +119,7 @@ Eina_Bool __cancel_by_error(void *data)
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
-       return EINA_FALSE;
+       return;
 }
 
 int __server_audio_recorder_callback(const void* data, const unsigned int length)
@@ -124,7 +129,7 @@ int __server_audio_recorder_callback(const void* data, const unsigned int length
 
        if (NULL == data || 0 == length) {
                SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Recording data is not valid");
-               ecore_timer_add(0, __cancel_by_error, NULL);
+               ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL);
                return -1;
        }
 
@@ -132,12 +137,12 @@ int __server_audio_recorder_callback(const void* data, const unsigned int length
        if (0 != uid) {
                ret = sttd_engine_agent_set_recording_data(uid, data, length);
                if (ret < 0) {
-                       ecore_timer_add(0, __cancel_by_error, NULL);
+                       ecore_main_loop_thread_safe_call_async(__cancel_by_error, NULL);
                        return -1;
                }
                g_recording_log_count++;
                if (200 <= g_recording_log_count) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "=== Set recording data ===");
+                       SLOG(LOG_DEBUG, TAG_STTD, "=== Set recording data ===");
                        g_recording_log_count = 0;
                }
        } else {
@@ -162,7 +167,7 @@ void __server_audio_interrupt_callback()
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 }
 
-Eina_Bool __cancel_by_no_record(void *data)
+void __cancel_by_no_record(void *data)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Cancel by no record");
 
@@ -171,13 +176,16 @@ Eina_Bool __cancel_by_no_record(void *data)
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
 
-       return EINA_FALSE;
+       return;
 }
 
 void __server_recognition_result_callback(sttp_result_event_e event, const char* type,
                                        const char** data, int data_count, const char* msg, void *user_data)
 {
-       SLOG(LOG_DEBUG, TAG_STTD, "===== Recognition Result Callback");
+       // critical section
+       pthread_mutex_lock(&sttpe_result_mutex);
+
+       SLOG(LOG_DEBUG, TAG_STTD, "===== RESULT event[%d] type[%s] data[%p] data_count[%d]", event, type, data, data_count);
 
        /* check uid */
        int uid = stt_client_get_current_recognition();
@@ -187,17 +195,18 @@ void __server_recognition_result_callback(sttp_result_event_e event, const char*
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] uid is NOT valid ");
                SLOG(LOG_DEBUG, TAG_STTD, "=====");
                SLOG(LOG_DEBUG, TAG_STTD, "  ");
+               pthread_mutex_unlock(&sttpe_result_mutex);
                return;
        }
 
-       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid (%d), event(%d)", uid, event);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid (%d), event(%d)", uid, event);
 
        /* send result to client */
        if (STTP_RESULT_EVENT_FINAL_RESULT == event) {
                if (APP_STATE_PROCESSING != state) {
                        SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current state is NOT 'Processing'.");
                }
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] the size of result from engine is '%d'", data_count);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] the size of result from engine is '%d'", data_count);
 
                /* Delete timer for processing time out */
                if (NULL != g_processing_timer) {
@@ -233,7 +242,7 @@ void __server_recognition_result_callback(sttp_result_event_e event, const char*
                stt_client_unset_current_recognition();
 
        } else if (STTP_RESULT_EVENT_PARTIAL_RESULT == event) {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] The partial result from engine is event[%d] data_count[%d]", event,  data_count);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The partial result from engine is event[%d] data_count[%d]", event,  data_count);
 
                sttd_config_time_save();
                sttd_config_time_reset();
@@ -276,26 +285,33 @@ void __server_recognition_result_callback(sttp_result_event_e event, const char*
 
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
+       pthread_mutex_unlock(&sttpe_result_mutex);
 
        return;
 }
 
 bool __server_result_time_callback(int index, sttp_result_time_event_e event, const char* text, long start_time, long end_time, void* user_data)
 {
+       pthread_mutex_lock(&sttpe_result_time_mutex);
+
        SLOG(LOG_DEBUG, TAG_STTD, "[Server] index(%d) event(%d) text(%s) start(%ld) end(%ld)",
-                index, event, text, start_time, end_time);
+               index, event, text, start_time, end_time);
 
        if (0 == index) {
                int ret;
                ret = sttd_config_time_add(index, (int)event, text, start_time, end_time);
                if (0 != ret) {
                        SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add time info");
+                       pthread_mutex_unlock(&sttpe_result_time_mutex);
                        return false;
                }
        } else {
+               pthread_mutex_unlock(&sttpe_result_time_mutex);
                return false;
        }
 
+       pthread_mutex_unlock(&sttpe_result_time_mutex);
+
        return true;
 }
 
@@ -317,11 +333,11 @@ void __server_silence_dectection_callback(sttp_silence_type_e type, void *user_p
                }
 
                if (STTP_SILENCE_TYPE_NO_RECORD_TIMEOUT == type) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Silence Detection type - No Record");
-                       ecore_timer_add(0, __cancel_by_no_record, NULL);
+                       SLOG(LOG_DEBUG, TAG_STTD, "Silence Detection type - No Record");
+                       ecore_main_loop_thread_safe_call_async(__cancel_by_no_record, NULL);
                } else if (STTP_SILENCE_TYPE_END_OF_SPEECH_DETECTED == type) {
-                       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "Silence Detection type - End of Speech");
-                       ecore_timer_add(0, __stop_by_silence, NULL);
+                       SLOG(LOG_DEBUG, TAG_STTD, "Silence Detection type - End of Speech");
+                       ecore_main_loop_thread_safe_call_async(__stop_by_silence, NULL);
                }
        } else {
                SLOG(LOG_WARN, TAG_STTD, "[Server WARNING] Current recogntion uid is not valid ");
@@ -339,7 +355,7 @@ void __sttd_server_engine_changed_cb(const char* engine_id, const char* language
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Engine id is NULL");
                return;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] New default engine : %s", engine_id);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] New default engine : %s", engine_id);
        }
 
        /* need to change state of app to ready */
@@ -347,7 +363,7 @@ void __sttd_server_engine_changed_cb(const char* engine_id, const char* language
        uid = stt_client_get_current_recognition();
 
        if (0 != uid) {
-               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server] Set ready state of uid(%d)", uid);
+               SLOG(LOG_ERROR, TAG_STTD, "[Server] Set ready state of uid(%d)", uid);
 
                sttd_server_cancel(uid);
                sttdc_send_set_state(uid, (int)APP_STATE_READY);
@@ -379,7 +395,7 @@ void __sttd_server_language_changed_cb(const char* language, void* user_data)
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] language is NULL");
                return;
        } else {
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] Get language changed : %s", language);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] Get language changed : %s", language);
        }
 
        int ret = sttd_engine_agent_set_default_language(language);
@@ -391,7 +407,7 @@ void __sttd_server_language_changed_cb(const char* language, void* user_data)
 
 void __sttd_server_silence_changed_cb(bool value, void* user_data)
 {
-       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] Get silence detection changed : %s", value ? "on" : "off");
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] Get silence detection changed : %s", value ? "on" : "off");
 
        int ret = 0;
        ret = sttd_engine_agent_set_silence_detection(value);
@@ -409,7 +425,15 @@ int sttd_initialize()
 {
        int ret = 0;
 
-       if (sttd_config_initialize(__sttd_server_engine_changed_cb, __sttd_server_language_changed_cb, 
+       if( 0 != pthread_mutex_init(&sttpe_result_mutex, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to initialize sttpe result mutex.");
+       }
+
+       if( 0 != pthread_mutex_init(&sttpe_result_time_mutex, NULL)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to initialize sttpe sttpe_result_time_mutex.");
+       }
+
+       if (sttd_config_initialize(__sttd_server_engine_changed_cb, __sttd_server_language_changed_cb,
                __sttd_server_silence_changed_cb, NULL)) {
                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to initialize config.");
        }
@@ -445,6 +469,23 @@ int sttd_initialize()
 
 int sttd_finalize()
 {
+       if( 0 != pthread_mutex_destroy(&sttpe_result_mutex)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to destroy sttpe result mutex.");
+       }
+
+       if( 0 != pthread_mutex_destroy(&sttpe_result_time_mutex)) {
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to destroy sttpe_result_time_mutex.");
+       }
+
+       GList *iter = NULL;
+       if (0 < g_list_length(g_proc_list)) {
+               iter = g_list_first(g_proc_list);
+               while (NULL != iter) {
+                       g_proc_list = g_list_remove_link(g_proc_list, iter);
+                       iter = g_list_first(g_proc_list);
+               }
+       }
+
        sttd_recorder_deinitialize();
 
        sttd_config_finalize();
@@ -454,12 +495,52 @@ int sttd_finalize()
        return STTD_ERROR_NONE;
 }
 
+static void __read_proc()
+{
+       DIR *dp = NULL;
+       struct dirent entry;
+       struct dirent *dirp = NULL;
+       int ret = -1;
+       int tmp;
+
+       GList *iter = NULL;
+       if (0 < g_list_length(g_proc_list)) {
+               iter = g_list_first(g_proc_list);
+               while (NULL != iter) {
+                       g_proc_list = g_list_remove_link(g_proc_list, iter);
+                       iter = g_list_first(g_proc_list);
+               }
+       }
+
+       dp = opendir("/proc");
+       if (NULL == dp) {
+               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to open proc");
+       } else {
+               do {
+                       ret = readdir_r(dp, &entry, &dirp);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Fail to readdir");
+                               break;
+                       }
+
+                       if (NULL != dirp) {
+                               tmp = atoi(dirp->d_name);
+                               if (0 >= tmp)   continue;
+                               g_proc_list = g_list_append(g_proc_list, GINT_TO_POINTER(tmp));
+                       }
+               } while (NULL != dirp);
+               closedir(dp);
+       }
+       return;
+}
+
 Eina_Bool sttd_cleanup_client(void *data)
 {
        int* client_list = NULL;
        int client_count = 0;
-       int result;
        int i = 0;
+       int j = 0;
+       bool exist = false;
 
        if (0 != sttd_client_get_list(&client_list, &client_count)) {
                if (NULL != client_list)
@@ -470,16 +551,43 @@ Eina_Bool sttd_cleanup_client(void *data)
 
        if (NULL != client_list) {
                SLOG(LOG_DEBUG, TAG_STTD, "===== Clean up client ");
+               
+               __read_proc();
+
+               for (i = 0;i < client_count;i++) {
+                       int pid = sttd_client_get_pid(client_list[i]);
+                       if (0 > pid) {
+                               SLOG(LOG_ERROR, TAG_STTD, "[ERROR] Invalid pid");
+                               continue;
+                       }
+
+                       exist = false;
+                       GList *iter = NULL;
+                       for (j = 0; j < g_list_length(g_proc_list); j++) {
+                               iter = g_list_nth(g_proc_list, j);
+                               if (NULL != iter) {
+                                       if (pid == GPOINTER_TO_INT(iter->data)) {
+                                               SLOG(LOG_DEBUG, TAG_STTD, "uid (%d) is running", client_list[i]);
+                                               exist = true;
+                                               break;
+                                       }
+                               }
+                       }
 
-               for (i = 0; i < client_count; i++) {
+                       if (false == exist) {
+                               SLOG(LOG_ERROR, TAG_STTD, "uid (%d) should be removed", client_list[i]);
+                               sttd_server_finalize(client_list[i]);
+                       }
+#if 0
                        result = sttdc_send_hello(client_list[i]);
 
                        if (0 == result) {
-                               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", client_list[i]);
+                               SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", client_list[i]);
                                sttd_server_finalize(client_list[i]);
                        } else if (-1 == result) {
                                SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Hello result has error");
                        }
+#endif
                }
 
                SLOG(LOG_DEBUG, TAG_STTD, "=====");
@@ -601,7 +709,7 @@ int sttd_server_get_supported_engines(int uid, GSList** engine_list)
 
        /* Check state of uid */
        if (APP_STATE_READY != state) {
-               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
                return STTD_ERROR_INVALID_STATE;
        }
 
@@ -626,7 +734,7 @@ int sttd_server_set_current_engine(int uid, const char* engine_id, bool* silence
 
        /* Check state of uid */
        if (APP_STATE_READY != state) {
-               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
                return STTD_ERROR_INVALID_STATE;
        }
 
@@ -657,7 +765,7 @@ int sttd_server_get_current_engine(int uid, char** engine_id)
 
        /* Check state of uid */
        if (APP_STATE_READY != state) {
-               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
                return STTD_ERROR_INVALID_STATE;
        }
 
@@ -671,7 +779,7 @@ int sttd_server_get_current_engine(int uid, char** engine_id)
        return STTD_ERROR_NONE;
 }
 
-int sttd_server_check_agg_agreed(int uid, const char* appid, bool* available)
+int sttd_server_check_app_agreed(int uid, const char* appid, bool* available)
 {
        /* Check if uid is valid */
        app_state_e state;
@@ -682,7 +790,7 @@ int sttd_server_check_agg_agreed(int uid, const char* appid, bool* available)
 
        /* Check state of uid */
        if (APP_STATE_READY != state) {
-               SECURE_SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
+               SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] The state of uid(%d) is not Ready", uid);
                return STTD_ERROR_INVALID_STATE;
        }
 
@@ -776,7 +884,7 @@ int sttd_server_is_recognition_type_supported(int uid, const char* type, int* su
 
        *support = (int)temp;
 
-       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] recognition type supporting is %s", *support ? "true" : "false");
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] recognition type supporting is %s", *support ? "true" : "false");
 
        return STTD_ERROR_NONE;
 }
@@ -817,6 +925,7 @@ int sttd_server_set_stop_sound(int uid, const char* file)
        return 0;
 }
 
+#if 0
 Eina_Bool __check_recording_state(void *data)
 {
        /* current uid */
@@ -827,18 +936,18 @@ Eina_Bool __check_recording_state(void *data)
        app_state_e state;
        if (0 != sttdc_send_get_state(uid, (int*)&state)) {
                /* client is removed */
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] uid(%d) should be removed.", uid);
                sttd_server_finalize(uid);
                return EINA_FALSE;
        }
 
        if (APP_STATE_READY == state) {
                /* Cancel stt */
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Ready'. The daemon should cancel recording", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Ready'. The daemon should cancel recording", uid);
                sttd_server_cancel(uid);
        } else if (APP_STATE_PROCESSING == state) {
                /* Cancel stt and send change state */
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Processing'. The daemon should cancel recording", uid);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] The state of uid(%d) is 'Processing'. The daemon should cancel recording", uid);
                sttd_server_cancel(uid);
                sttdc_send_set_state(uid, (int)APP_STATE_READY);
        } else {
@@ -849,6 +958,7 @@ Eina_Bool __check_recording_state(void *data)
 
        return EINA_FALSE;
 }
+#endif
 
 Eina_Bool __stop_by_recording_timeout(void *data)
 {
@@ -872,8 +982,9 @@ Eina_Bool __stop_by_recording_timeout(void *data)
        return EINA_FALSE;
 }
 
-void __sttd_server_recorder_start(int uid)
+void __sttd_server_recorder_start(void* data)
 {
+       int uid = (int)data;
        int current_uid = stt_client_get_current_recognition();
 
        if (uid != current_uid) {
@@ -897,9 +1008,8 @@ void __sttd_start_sound_completed_cb(int id, void *user_data)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Start sound completed");
 
-       int uid = (int)user_data;
-       /* 4. after wav play callback, recorder start */
-       __sttd_server_recorder_start(uid);
+       /* After wav play callback, recorder start */
+       ecore_main_loop_thread_safe_call_async(__sttd_server_recorder_start, user_data);
 
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
@@ -964,10 +1074,10 @@ int sttd_server_start(int uid, const char* lang, const char* recognition_type, i
        }
 
        /* engine start recognition */
-       SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] start : uid(%d), lang(%s), recog_type(%s)",
-                               uid, lang, recognition_type);
+       SLOG(LOG_DEBUG, TAG_STTD, "[Server] start : uid(%d), lang(%s), recog_type(%s)",
+                       uid, lang, recognition_type);
        if (NULL != sound)
-               SECURE_SLOG(LOG_DEBUG, TAG_STTD, "[Server] start sound : %s", sound);
+               SLOG(LOG_DEBUG, TAG_STTD, "[Server] start sound : %s", sound);
 
        /* 1. Set audio session */
        ret = sttd_recorder_set_audio_session();
@@ -1028,6 +1138,9 @@ int sttd_server_start(int uid, const char* lang, const char* recognition_type, i
                        return STTD_ERROR_OPERATION_FAILED;
                }
 
+               /* Notify uid state change */
+               sttdc_send_set_state(uid, APP_STATE_RECORDING);
+
                SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Start recognition");
                return STTD_RESULT_STATE_DONE;
        }
@@ -1069,8 +1182,9 @@ Eina_Bool __time_out_for_processing(void *data)
        return EINA_FALSE;
 }
 
-void __sttd_server_engine_stop(int uid)
+void __sttd_server_engine_stop(void* data)
 {
+       int uid = (int)data;
        /* change uid state */
        sttd_client_set_state(uid, APP_STATE_PROCESSING);
 
@@ -1098,9 +1212,8 @@ void __sttd_stop_sound_completed_cb(int id, void *user_data)
 {
        SLOG(LOG_DEBUG, TAG_STTD, "===== Stop sound completed");
 
-       int uid = (int)user_data;
        /* After wav play callback, engine stop */
-       __sttd_server_engine_stop(uid);
+       ecore_main_loop_thread_safe_call_async(__sttd_server_engine_stop, user_data);
 
        SLOG(LOG_DEBUG, TAG_STTD, "=====");
        SLOG(LOG_DEBUG, TAG_STTD, "  ");
@@ -1183,6 +1296,9 @@ int sttd_server_stop(int uid)
                /* change uid state */
                sttd_client_set_state(uid, APP_STATE_PROCESSING);
 
+               /* Notify uid state change */
+               sttdc_send_set_state(uid, APP_STATE_PROCESSING);
+
                SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] Stop recognition");
 
                g_processing_timer = ecore_timer_add(g_processing_timeout, __time_out_for_processing, NULL);
@@ -1239,5 +1355,8 @@ int sttd_server_cancel(int uid)
                return STTD_ERROR_OPERATION_FAILED;
        }
 
+       /* Notify uid state change */
+       sttdc_send_set_state(uid, APP_STATE_READY);
+
        return STTD_ERROR_NONE;
 }
index ac32122..8f6e1e7 100644 (file)
@@ -48,7 +48,7 @@ int sttd_server_set_current_engine(int uid, const char* engine_id, bool* silence
 
 int sttd_server_get_current_engine(int uid, char** engine_id);
 
-int sttd_server_check_agg_agreed(int uid, const char* appid, bool* available);
+int sttd_server_check_app_agreed(int uid, const char* appid, bool* available);
 
 int sttd_server_get_supported_languages(int uid, GSList** lang_list);
 
index 13e03ae..d78698a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-*  Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved 
+*  Copyright (c) 2011-2014 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
@@ -26,7 +26,7 @@
 extern "C" {
 #endif
 
-/** 
+/**
 * @brief Enumerations of error codes.
 */
 typedef enum {
@@ -42,7 +42,7 @@ typedef enum {
 }sttp_error_e;
 
 /**
-* @brief Enumerations of audio type. 
+* @brief Enumerations of audio type.
 */
 typedef enum {
        STTP_AUDIO_TYPE_PCM_S16_LE = 0, /**< Signed 16bit audio type, Little endian */
@@ -75,70 +75,70 @@ typedef enum {
        STTP_SILENCE_TYPE_END_OF_SPEECH_DETECTED        /**< End of speech is detected */
 }sttp_silence_type_e;
 
-/** 
+/**
 * @brief Recognition type : free form dictation and default type.
 */
 #define STTP_RECOGNITION_TYPE_FREE             "stt.recognition.type.FREE"
 
-/** 
-* @brief Recognition type : free form dictation continuously. 
+/**
+* @brief Recognition type : free form dictation continuously.
 */
 #define STTP_RECOGNITION_TYPE_FREE_PARTIAL     "stt.recognition.type.FREE.PARTIAL"
 
 /**
-* @brief Recognition type : Search. 
+* @brief Recognition type : Search.
 */
 #define STTP_RECOGNITION_TYPE_SEARCH           "stt.recognition.type.SEARCH"
 
-/** 
-* @brief Recognition type : web search. 
+/**
+* @brief Recognition type : web search.
 */
 #define STTP_RECOGNITION_TYPE_WEB_SEARCH       "stt.recognition.type.WEB_SEARCH"
 
 /**
-* @brief Recognition type : Map. 
+* @brief Recognition type : Map.
 */
 #define STTP_RECOGNITION_TYPE_MAP              "stt.recognition.type.MAP"
 
 
-/** 
+/**
 * @brief Result message : None message
 */
 #define STTP_RESULT_MESSAGE_NONE               "stt.result.message.none"
 
-/** 
+/**
 * @brief Result error message : Recognition was failed because the speech started too soon
 */
 #define STTP_RESULT_MESSAGE_ERROR_TOO_SOON     "stt.result.message.error.too.soon"
 
-/** 
+/**
 * @brief Result error message : Recognition was failed because the speech started too short
 */
 #define STTP_RESULT_MESSAGE_ERROR_TOO_SHORT    "stt.result.message.error.too.short"
 
-/** 
+/**
 * @brief Result error message : Recognition was failed because the speech started too long
 */
 #define STTP_RESULT_MESSAGE_ERROR_TOO_LONG     "stt.result.message.error.too.long"
 
-/** 
+/**
 * @brief Result error message : Recognition was failed because the speech started too quiet to listen
 */
 #define STTP_RESULT_MESSAGE_ERROR_TOO_QUIET    "stt.result.message.error.too.quiet"
 
-/** 
-* @brief Result error message : Recognition was failed because the speech started too loud to listen 
+/**
+* @brief Result error message : Recognition was failed because the speech started too loud to listen
 */
 #define STTP_RESULT_MESSAGE_ERROR_TOO_LOUD     "stt.result.message.error.too.loud"
 
-/** 
+/**
 * @brief Result error message : Recognition was failed because the speech started too fast to listen
 */
 #define STTP_RESULT_MESSAGE_ERROR_TOO_FAST     "stt.result.message.error.too.fast"
 
-/** 
+/**
 * @brief Called to get recognition result.
-* 
+*
 * @param[in] event A result event
 * @param[in] type A recognition type (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_FREE_PARTIAL)
 * @param[in] data Result texts
@@ -151,11 +151,11 @@ typedef enum {
 * @see sttpe_start()
 * @see sttpe_stop()
 */
-typedef void (*sttpe_result_cb)(sttp_result_event_e event, const char* type, const char** data, int data_count, 
+typedef void (*sttpe_result_cb)(sttp_result_event_e event, const char* type, const char** data, int data_count,
                                const char* msg, void* time_info, void* user_data);
 
 /**
-* @brief Called to retrieve the time stamp of result. 
+* @brief Called to retrieve the time stamp of result.
 *
 * @param[in] index The result index
 * @param[in] event The token event
@@ -166,16 +166,16 @@ typedef void (*sttpe_result_cb)(sttp_result_event_e event, const char* type, con
 *
 * @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
 *
-* @pre sttpe_result_cb() should be called. 
+* @pre sttpe_result_cb() should be called.
 *
 * @see sttpe_result_cb()
 */
-typedef bool (*sttpe_result_time_cb)(int index, sttp_result_time_event_e event, const char* text, 
+typedef bool (*sttpe_result_time_cb)(int index, sttp_result_time_event_e event, const char* text,
                                long start_time, long end_time, void* user_data);
 
-/** 
+/**
 * @brief Called to detect silence from recording data.
-* 
+*
 * @param[in] user_data The user data passed from the start function.
 *
 * @pre sttpe_set_recording_data() will invoke this callback.
@@ -185,7 +185,7 @@ typedef bool (*sttpe_result_time_cb)(int index, sttp_result_time_event_e event,
 typedef void (*sttpe_silence_detected_cb)(sttp_silence_type_e type, void* user_data);
 
 /**
-* @brief Called to retrieve the supported languages. 
+* @brief Called to retrieve the supported languages.
 *
 * @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code
 *              followed by ISO 639-1 for the two-letter language code \n
@@ -194,7 +194,7 @@ typedef void (*sttpe_silence_detected_cb)(sttp_silence_type_e type, void* user_d
 *
 * @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
 *
-* @pre sttpe_foreach_supported_languages() will invoke this callback. 
+* @pre sttpe_foreach_supported_languages() will invoke this callback.
 *
 * @see sttpe_foreach_supported_languages()
 */
@@ -211,7 +211,7 @@ typedef bool (*sttpe_supported_language_cb)(const char* language, void* user_dat
 * @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STTP_ERROR_INVALID_STATE Already initialized
 * @retval #STTP_ERROR_OPERATION_FAILED Operation failed
-* 
+*
 * @see sttpe_deinitialize()
 */
 typedef int (* sttpe_initialize)(sttpe_result_cb result_cb, sttpe_silence_detected_cb silence_cb);
@@ -222,7 +222,7 @@ typedef int (* sttpe_initialize)(sttpe_result_cb result_cb, sttpe_silence_detect
 * @return 0 on success, otherwise a negative error value
 * @retval #STTP_ERROR_NONE Successful
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
-* 
+*
 * @see sttpe_initialize()
 */
 typedef int (* sttpe_deinitialize)(void);
@@ -238,7 +238,7 @@ typedef int (* sttpe_deinitialize)(void);
 * @retval #STTP_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
 *
-* @post        This function invokes sttpe_supported_language_cb() repeatedly for getting supported languages. 
+* @post        This function invokes sttpe_supported_language_cb() repeatedly for getting supported languages.
 *
 * @see sttpe_supported_language_cb()
 */
@@ -256,7 +256,7 @@ typedef int (* sttpe_foreach_supported_langs)(sttpe_supported_language_cb callba
 typedef bool (* sttpe_is_valid_language)(const char* language);
 
 /**
-* @brief Gets whether the engine supports silence detection. 
+* @brief Gets whether the engine supports silence detection.
 *
 * @return @c true to support silence detection, \n @c false not to support silence detection.
 *
@@ -265,7 +265,7 @@ typedef bool (* sttpe_is_valid_language)(const char* language);
 typedef bool (* sttpe_support_silence_detection)(void);
 
 /**
-* @brief Gets supporting recognition type. 
+* @brief Gets supporting recognition type.
 *
 * @return @c true to support recognition type, \n @c false not to support recognition type.
 *
@@ -273,7 +273,7 @@ typedef bool (* sttpe_support_silence_detection)(void);
 typedef bool (* sttpe_support_recognition_type)(const char* type);
 
 /**
-* @brief Gets recording format of the engine. 
+* @brief Gets recording format of the engine.
 *
 * @param[out] types The format used by the recorder.
 * @param[out] rate The sample rate used by the recorder.
@@ -287,7 +287,7 @@ typedef int (* sttpe_get_recording_format)(sttp_audio_type_e* types, int* rate,
 
 /**
 * @brief Sets silence detection option.
-* 
+*
 * @param[in] value A value
 *
 * @return 0 on success, otherwise a negative error value
@@ -299,7 +299,7 @@ typedef int (* sttpe_set_silence_detection)(bool value);
 
 /**
 * @brief Gets whether application is agreed to get engine service.
-* 
+*
 * @param[in] appid Application ID
 * @param[in] value A value
 *
@@ -322,7 +322,7 @@ typedef int (* sttpe_check_app_agreed)(const char* appid, bool* value);
 * @retval #STTP_ERROR_INVALID_STATE Not initialized
 *
 * @pre sttpe_result_cb() will be invoke this function.
-* @post        This function invokes sttpe_result_time_cb() repeatedly for getting result time information. 
+* @post        This function invokes sttpe_result_time_cb() repeatedly for getting result time information.
 *
 * @see sttpe_result_time_cb()
 */
@@ -331,9 +331,9 @@ typedef int (* sttpe_foreach_result_time)(void* time_info, sttpe_result_time_cb
 /**
 * @brief Start recognition.
 *
-* @param[in] language A language. 
+* @param[in] language A language.
 * @param[in] type A recognition type. (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_WEB_SEARCH)
-* @param[in] user_data The user data to be passed to the callback function. 
+* @param[in] user_data The user data to be passed to the callback function.
 *
 * @return 0 on success, otherwise a negative error value
 * @retval #STTP_ERROR_NONE Successful
@@ -352,10 +352,10 @@ typedef int (* sttpe_foreach_result_time)(void* time_info, sttpe_result_time_cb
 typedef int (* sttpe_start)(const char* language, const char* type, void *user_data);
 
 /**
-* @brief Sets recording data for speech recognition from recorder. 
+* @brief Sets recording data for speech recognition from recorder.
+*
+* @remark This function should be returned immediately after recording data copy.
 *
-* @remark This function should be returned immediately after recording data copy. 
-* 
 * @param[in] data A recording data
 * @param[in] length A length of recording data
 *
@@ -409,12 +409,12 @@ typedef int (* sttpe_cancel)(void);
 /**
 * @brief Start recognition of file.
 *
-* @param[in] language A language. 
+* @param[in] language A language.
 * @param[in] type A recognition type. (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_WEB_SEARCH)
 * @param[in] filepath A filepath for recognition.
 * @param[in] audio_type A audio type of file.
 * @param[in] sample_rate A sample rate of file.
-* @param[in] user_data The user data to be passed to the callback function. 
+* @param[in] user_data The user data to be passed to the callback function.
 *
 * @return 0 on success, otherwise a negative error value
 * @retval #STTP_ERROR_NONE Successful
@@ -428,7 +428,7 @@ typedef int (* sttpe_cancel)(void);
 *
 * @see sttpe_cancel_file()
 */
-typedef int (* sttpe_start_file)(const char* language, const char* type, const char* filepath, 
+typedef int (* sttpe_start_file)(const char* language, const char* type, const char* filepath,
                                 sttp_audio_type_e audio_type, int sample_rate, void *user_data);
 
 /**
@@ -447,9 +447,9 @@ typedef int (* sttpe_cancel_file)(void);
 * @brief A structure of the engine functions.
 */
 typedef struct {
-       int size;                                               /**< Size of structure */    
+       int size;                                               /**< Size of structure */
        int version;                                            /**< Version */
-       
+
        sttpe_initialize                initialize;             /**< Initialize engine */
        sttpe_deinitialize              deinitialize;           /**< Shutdown engine */
 
@@ -460,7 +460,7 @@ typedef struct {
        sttpe_support_recognition_type  support_recognition_type; /**< Get recognition type support */
        sttpe_get_recording_format      get_audio_format;       /**< Get audio format */
        sttpe_foreach_result_time       foreach_result_time;    /**< Foreach result time */
-       
+
        /* Set engine information */
        sttpe_set_silence_detection     set_silence_detection;  /**< Set silence detection */
 
@@ -488,7 +488,7 @@ typedef struct {
 } sttpd_funcs_s;
 
 /**
-* @brief Loads the engine. 
+* @brief Loads the engine.
 *
 * @param[in] pdfuncs The daemon functions
 * @param[out] pefuncs The engine functions
@@ -507,7 +507,7 @@ typedef struct {
 int sttp_load_engine(sttpd_funcs_s* pdfuncs, sttpe_funcs_s* pefuncs);
 
 /**
-* @brief Unloads this engine by the daemon. 
+* @brief Unloads this engine by the daemon.
 *
 * @pre The sttp_load_engine() should be successful.
 *
@@ -524,15 +524,15 @@ void sttp_unload_engine(void);
 * @param[in] use_network @c true to need network @c false not to need network.
 * @param[in] user_data The User data passed from sttp_get_engine_info()
 *
-* @pre sttp_get_engine_info() will invoke this callback. 
+* @pre sttp_get_engine_info() will invoke this callback.
 *
 * @see sttp_get_engine_info()
 */
-typedef void (*sttpe_engine_info_cb)(const char* engine_uuid, const char* engine_name, const char* engine_setting, 
+typedef void (*sttpe_engine_info_cb)(const char* engine_uuid, const char* engine_name, const char* engine_setting,
                                     bool use_network, void* user_data);
 
 /**
-* @brief Gets the engine base information before the engine is loaded by the daemon. 
+* @brief Gets the engine base information before the engine is loaded by the daemon.
 *
 * @param[in] callback Callback function
 * @param[in] user_data User data to be passed to the callback function
@@ -556,5 +556,5 @@ int sttp_get_engine_info(sttpe_engine_info_cb callback, void* user_data);
 /**
  * @}@}
  */
+
 #endif /* __STTP_H__ */
index e2b79e1..1556ae6 100644 (file)
@@ -11,7 +11,8 @@ FOREACH(flag ${pkgs_test_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 
 FIND_PROGRAM(UNAME NAMES uname)
 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
@@ -24,4 +25,4 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
 
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_test_LDFLAGS} stt stt_file)
 
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /opt/usr/devel/bin)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/share/voice/test)
index cb74bd7..7e80ad1 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <stdio.h>
 #include <Ecore.h>
-#include <dlog/dlog.h>
+#include <dlog.h>
 
 #include <stt.h>
 #include <stt_file.h>
@@ -138,6 +138,20 @@ static Eina_Bool __file_start(void *data)
        return EINA_FALSE;
 }
 
+static Eina_Bool __stt_get_volume(void *data)
+{
+       float volume = 0.0;
+       int ret = stt_get_recording_volume(g_stt, &volume);
+       if (STT_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to get volume");
+               return EINA_FALSE;
+       }
+
+       SLOG(LOG_DEBUG, TAG_STT_TEST, "Get volume : %f", volume);
+
+       return EINA_TRUE;
+}
+
 static Eina_Bool __stt_start(void *data)
 {
        int ret;
@@ -152,6 +166,9 @@ static Eina_Bool __stt_start(void *data)
        if (STT_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_STT_TEST, "[ERROR] Fail to start");
        }
+
+       ecore_timer_add(0.1, __stt_get_volume, NULL);
+
        return EINA_FALSE;
 }
 
@@ -187,16 +204,16 @@ static void __stt_recognition_result_cb(stt_h stt, stt_result_event_e event, con
        ecore_timer_add(0, __stt_finalize, NULL);
 }
 
-int main(int argc, char *argv[])
+int main (int argc, char *argv[])
 {
-       if (2 < argc) {
+       if (2 > argc) {
                SLOG(LOG_DEBUG, TAG_STT_TEST, "Please check parameter");
                SLOG(LOG_DEBUG, TAG_STT_TEST, "Ex> stt-test -f <file path>");
                SLOG(LOG_DEBUG, TAG_STT_TEST, "Ex> stt-test -m");
                return 0;
        }
 
-       if (strcmp("-f", argv[1]) && strcmp("-m", argv[1])) {
+       if (0 != strcmp("-f", argv[1]) && 0 != strcmp("-m", argv[1])) {
                SLOG(LOG_DEBUG, TAG_STT_TEST, "Please check parameter");
                SLOG(LOG_DEBUG, TAG_STT_TEST, "Ex> stt-test -f <file path>");
                SLOG(LOG_DEBUG, TAG_STT_TEST, "Ex> stt-test -m");