From 97ec8f067306caecf6bc7275ee58b92eb4f60c0f Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 31 Aug 2016 18:57:04 +0900 Subject: [PATCH] Fix to save time info and to make directories Change-Id: I8ad6344688c5faef78b51e226e997ecaf93da049 Signed-off-by: sooyeon.kim --- common/stt_config_mgr.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ common/stt_defs.h | 5 +++-- server/sttd_server.c | 13 ++++--------- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/common/stt_config_mgr.c b/common/stt_config_mgr.c index c9b7870..f5ba157 100644 --- a/common/stt_config_mgr.c +++ b/common/stt_config_mgr.c @@ -750,6 +750,48 @@ int stt_config_mgr_initialize(int uid) return STT_CONFIG_ERROR_NONE; } + /* Make directories */ + if (0 != access(STT_CONFIG_BASE, F_OK)) { + if (0 != mkdir(STT_CONFIG_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make directory : %s", STT_CONFIG_BASE); + __stt_config_release_client(uid); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, stt_tag(), "Success to make directory : %s", STT_CONFIG_BASE); + } + } + + if (0 != access(STT_HOME, F_OK)) { + if (0 != mkdir(STT_HOME, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make directory : %s", STT_HOME); + __stt_config_release_client(uid); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, stt_tag(), "Success to make directory : %s", STT_HOME); + } + } + + if (0 != access(STT_DOWNLOAD_BASE, F_OK)) { + if (0 != mkdir(STT_DOWNLOAD_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make directory : %s", STT_DOWNLOAD_BASE); + __stt_config_release_client(uid); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, stt_tag(), "Success to make directory : %s", STT_DOWNLOAD_BASE); + } + } + + if (0 != access(STT_DOWNLOAD_ENGINE_INFO, F_OK)) { + if (0 != mkdir(STT_DOWNLOAD_ENGINE_INFO, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make directory : %s", STT_DOWNLOAD_ENGINE_INFO); + __stt_config_release_client(uid); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, stt_tag(), "Success to make directory : %s", STT_DOWNLOAD_ENGINE_INFO); + } + } + + /* Get file name from default engine directory */ g_engine_list = NULL; @@ -1604,9 +1646,13 @@ int stt_config_mgr_add_time_info(int index, int event, const char* text, long st info->start_time = start_time; info->end_time = end_time; + SLOG(LOG_DEBUG, stt_tag(), "[DEBUG] inside stt_config_mgr_add_time_info: index(%d), text(%s), start time(%d), end_time(%d)", info->index, (NULL == info->text) ? "NULL" : info->text, info->start_time, info->end_time); + /* Add item to global list */ g_time_list = g_slist_append(g_time_list, info); + SLOG(LOG_DEBUG, stt_tag(), "[DEBUG] inside stt_config_mgr_add_time_info: g_time_list length(%d)", g_slist_length(g_time_list)); + return 0; } diff --git a/common/stt_defs.h b/common/stt_defs.h index 59b2b36..1761eee 100644 --- a/common/stt_defs.h +++ b/common/stt_defs.h @@ -70,11 +70,12 @@ extern "C" { * Defines for configuration *******************************************************************************************/ -#define STT_TIME_INFO_PATH tzplatform_mkpath(TZ_USER_HOME, "share/.voice/stt-time.xml") - +#define STT_CONFIG_BASE tzplatform_mkpath(TZ_USER_HOME, "share/.voice") #define STT_CONFIG tzplatform_mkpath(TZ_USER_HOME, "share/.voice/stt-config.xml") #define STT_DEFAULT_CONFIG tzplatform_mkpath(TZ_SYS_RO_SHARE, "/voice/stt/1.0/stt-config.xml") +#define STT_TIME_INFO_PATH tzplatform_mkpath(TZ_USER_HOME, "share/.voice/stt-time.xml") + #define STT_DEFAULT_ENGINE tzplatform_mkpath(TZ_SYS_RO_SHARE, "/voice/stt/1.0/engine") #define STT_DEFAULT_ENGINE_INFO tzplatform_mkpath(TZ_SYS_RO_SHARE, "/voice/stt/1.0/engine-info") #define STT_DEFAULT_ENGINE_SETTING tzplatform_mkpath(TZ_SYS_RO_SHARE, "/voice/stt/1.0/engine-setting") diff --git a/server/sttd_server.c b/server/sttd_server.c index a3b528e..aaee986 100644 --- a/server/sttd_server.c +++ b/server/sttd_server.c @@ -297,15 +297,10 @@ bool __server_result_time_callback(int index, stte_result_time_event_e event, co SLOG(LOG_DEBUG, TAG_STTD, "[Server] index(%d) event(%d) text(%s) start(%ld) end(%ld)", 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(&stte_result_time_mutex); - return false; - } - } else { + 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(&stte_result_time_mutex); return false; } -- 2.7.4