Fix to save time info and to make directories
[platform/core/uifw/stt.git] / common / stt_config_mgr.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;
 }