Merge "Fix to check whether it is possible to access to files" into tizen
[platform/core/uifw/tts.git] / common / tts_config_parser.c
index ee9e5f0..443e2dd 100644 (file)
@@ -596,6 +596,8 @@ int tts_parser_copy_xml(const char* original, const char* destination)
        int ret = xmlSaveFile(destination, doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", destination);
        }
 
        /* Set mode */
@@ -663,6 +665,8 @@ int tts_parser_set_engine(const char* engine_id, const char* setting, const char
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -696,7 +700,7 @@ int tts_parser_set_voice(const char* language, int type)
        while (cur != NULL) {
                if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_LANGUAGE)) {
                        xmlNodeSetContent(cur, (const xmlChar *)language);
-               } 
+               }
 
                if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_CONFIG_VOICE_TYPE)) {
                        switch (type) {
@@ -716,6 +720,8 @@ int tts_parser_set_voice(const char* language, int type)
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -759,6 +765,8 @@ int tts_parser_set_auto_voice(bool value)
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -802,6 +810,8 @@ int tts_parser_set_speech_rate(int value)
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -834,7 +844,7 @@ int tts_parser_set_pitch(int value)
                        snprintf(temp, 10, "%d", value);
                        xmlNodeSetContent(cur, (const xmlChar *)temp);
                        break;
-               } 
+               }
 
                cur = cur->next;
        }
@@ -842,6 +852,8 @@ int tts_parser_set_pitch(int value)
        int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
        if (0 > ret) {
                SLOG(LOG_ERROR, tts_tag(), "[ERROR] Save result : %d", ret);
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to save %s", TTS_CONFIG);
        }
 
        return 0;
@@ -1087,3 +1099,26 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic
 
        return 0;
 }
+
+int tts_parser_reset()
+{
+       SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Reset g_config_doc as %s", TTS_DEFAULT_CONFIG);
+
+       if (NULL != g_config_doc) {
+               xmlFreeDoc(g_config_doc);
+               g_config_doc = NULL;
+       }
+
+       g_config_doc = xmlParseFile(TTS_DEFAULT_CONFIG);
+       if (NULL == g_config_doc) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse %s", TTS_DEFAULT_CONFIG);
+               return -1;
+       }
+
+       int ret = xmlSaveFile(TTS_CONFIG, g_config_doc);
+       if (0 > ret) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to save %s", TTS_CONFIG);
+       }
+
+       return 0;
+}