X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=common%2Ftts_config_parser.c;h=ee9e5f0e719bdee747c94766b52d1d0753cf96c1;hb=1bed1387e0585b61fa43c4a5c99275f0f32511cf;hp=e8cf3dbcfa0ef8e10fe7fe7fb388ddbdb25c8416;hpb=352f001d4607772615c6689c6b5be51aa21cb8bc;p=platform%2Fcore%2Fuifw%2Ftts.git diff --git a/common/tts_config_parser.c b/common/tts_config_parser.c index e8cf3db..ee9e5f0 100644 --- a/common/tts_config_parser.c +++ b/common/tts_config_parser.c @@ -43,6 +43,7 @@ #define TTS_TAG_VOICE_TYPE_MALE "male" #define TTS_TAG_VOICE_TYPE_CHILD "child" +#define TTS_MAX_TEXT_SIZE 2000 extern char* tts_tag(); @@ -58,14 +59,21 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info return -1; } + bool isTextsize = false; xmlDocPtr doc = NULL; xmlNodePtr cur = NULL; xmlChar *key = NULL; xmlChar *attr = NULL; - doc = xmlParseFile(path); - if (doc == NULL) { - SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse xml file"); + if (0 == access(path, F_OK)) { + SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to access to %s", path); + doc = xmlParseFile(path); + if (doc == NULL) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse xml file"); + return -1; + } + } else { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to access to %s", path); return -1; } @@ -213,6 +221,7 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info SLOG(LOG_ERROR, tts_tag(), "[ERROR] <%s> has no content", TTS_TAG_ENGINE_PITCH_SUPPORT); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)TTS_TAG_ENGINE_TEXT_SIZE)) { + isTextsize = true; key = xmlNodeGetContent(cur); if (NULL != key) { temp->text_size = atoi((char*)key); @@ -225,10 +234,14 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info cur = cur->next; } + if (false == isTextsize) { + temp->text_size = TTS_MAX_TEXT_SIZE; + } + xmlFreeDoc(doc); doc = NULL; - if (NULL == temp->name || NULL == temp->uuid) { + if (NULL == temp->uuid) { /* Invalid engine */ SECURE_SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid engine : %s", path); tts_parser_free_engine_info(temp); @@ -322,7 +335,7 @@ int tts_parser_print_engine_info(tts_engine_info_s* engine_info) SLOG(LOG_ERROR, tts_tag(), " Voice is NONE"); } - SLOG(LOG_DEBUG, tts_tag(), "====================="); + SLOG(LOG_DEBUG, tts_tag(), "@@@"); return 0; } @@ -529,7 +542,7 @@ int tts_parser_load_config(tts_config_s** config_info) } while (0 != ret); /* Set mode */ - if (0 > chmod(TTS_CONFIG, 0666)) { + if (0 > chmod(TTS_CONFIG, 0600)) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to change file mode : %d", ret); } @@ -568,9 +581,15 @@ int tts_parser_copy_xml(const char* original, const char* destination) } xmlDocPtr doc = NULL; - doc = xmlParseFile(original); - if (doc == NULL) { - SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", original); + if (0 == access(original, F_OK)) { + SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to access to %s", original); + doc = xmlParseFile(original); + if (doc == NULL) { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", original); + return -1; + } + } else { + SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to access to %s", original); return -1; } @@ -580,7 +599,7 @@ int tts_parser_copy_xml(const char* original, const char* destination) } /* Set mode */ - if (0 > chmod(destination, 0666)) { + if (0 > chmod(destination, 0600)) { SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to change file mode : %d", ret); } @@ -845,9 +864,12 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic int retry_count = 0; while (NULL == doc) { - doc = xmlParseFile(TTS_CONFIG); - if (NULL != doc) { - break; + if (0 == access(TTS_CONFIG, F_OK)) { + SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to access to %s", TTS_CONFIG); + doc = xmlParseFile(TTS_CONFIG); + if (NULL != doc) { + break; + } } retry_count++; usleep(10000);