Fix to save time info and to make directories 77/86277/2 accepted/tizen/common/20160831.162321 submit/tizen/20160831.130415
authorsooyeon.kim <sooyeon.kim@samsung.com>
Wed, 31 Aug 2016 09:57:04 +0000 (18:57 +0900)
committersooyeon.kim <sooyeon.kim@samsung.com>
Wed, 31 Aug 2016 12:57:10 +0000 (21:57 +0900)
Change-Id: I8ad6344688c5faef78b51e226e997ecaf93da049
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
common/stt_config_mgr.c
common/stt_defs.h
server/sttd_server.c

index c9b7870..f5ba157 100644 (file)
@@ -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;
 }
 
index 59b2b36..1761eee 100644 (file)
@@ -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")
index a3b528e..aaee986 100644 (file)
@@ -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;
        }