From: Suyeon Hwang Date: Fri, 17 Jul 2020 05:32:43 +0000 (+0900) Subject: Remove external definition from common module X-Git-Tag: accepted/tizen/unified/20200810.123208~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F238758%2F1;p=platform%2Fcore%2Fuifw%2Fstt.git Remove external definition from common module `common` module should not have accessed any other modules like `client` or `server`, but it has used `log_tag()` function on `client` module by external definition. This kind of access occurs cyclic depedency. This patch removes external definition on common modules to remove cyclic depedencies. Change-Id: I769a0886bdfb150c8943687d230ba85afe7d0ea0 Signed-off-by: Suyeon Hwang --- diff --git a/common/stt_config_mgr.c b/common/stt_config_mgr.c index be6c113..ea20502 100644 --- a/common/stt_config_mgr.c +++ b/common/stt_config_mgr.c @@ -35,8 +35,6 @@ typedef struct { } stt_config_client_s; -extern const char* stt_tag(); - static GSList* g_engine_list = NULL; static GSList* g_config_client_list = NULL; @@ -52,7 +50,7 @@ int __stt_config_mgr_print_engine_info(); bool __stt_config_mgr_check_lang_is_valid(const char* engine_id, const char* language) { if (NULL == engine_id || NULL == language) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Input parameter is NULL"); return false; } @@ -60,7 +58,7 @@ bool __stt_config_mgr_check_lang_is_valid(const char* engine_id, const char* lan stt_engine_info_s *engine_info = NULL; if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] There is no engine!!"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] There is no engine!!"); return false; } @@ -71,7 +69,7 @@ bool __stt_config_mgr_check_lang_is_valid(const char* engine_id, const char* lan engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Engine info is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Engine info is NULL"); return false; } @@ -91,7 +89,7 @@ bool __stt_config_mgr_check_lang_is_valid(const char* engine_id, const char* lan /*Get handle data from list*/ engine_lang = iter_lang->data; - SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", i, engine_lang); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " [%dth] %s", i, engine_lang); if (0 == strcmp(language, engine_lang)) { return true; @@ -111,7 +109,7 @@ bool __stt_config_mgr_check_lang_is_valid(const char* engine_id, const char* lan int __stt_config_mgr_select_lang(const char* engine_id, char** language) { if (NULL == engine_id || NULL == language) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Input parameter is NULL"); return STT_CONFIG_ERROR_INVALID_PARAMETER; } @@ -119,7 +117,7 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language) stt_engine_info_s *engine_info = NULL; if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] There is no engine!!"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] There is no engine!!"); return STT_CONFIG_ERROR_OPERATION_FAILED; } @@ -130,7 +128,7 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language) engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "engine info is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "engine info is NULL"); iter = g_slist_next(iter); continue; } @@ -141,14 +139,14 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language) } if (NULL == engine_info->default_lang) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Default language of the engine info is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Default language of the engine info is NULL"); return STT_CONFIG_ERROR_INVALID_LANGUAGE; } *language = strdup(engine_info->default_lang); if (NULL != *language) { - SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Selected language : %s", *language); return STT_CONFIG_ERROR_NONE; } } @@ -158,7 +156,7 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language) Eina_Bool stt_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handler) { - SLOG(LOG_DEBUG, stt_tag(), "===== Config changed callback event"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "===== Config changed callback event"); int length; struct inotify_event event; @@ -166,9 +164,9 @@ Eina_Bool stt_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handl length = read(g_fd_noti, &event, sizeof(struct inotify_event)); if (0 > length) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty Inotify event"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, stt_tag(), "====="); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, stt_tag(), " "); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty Inotify event"); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "====="); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, " "); //LCOV_EXCL_LINE return ECORE_CALLBACK_PASS_ON; //LCOV_EXCL_LINE } @@ -283,11 +281,11 @@ Eina_Bool stt_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handl if (NULL != setting) free(setting); if (NULL != lang) free(lang); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Undefined event"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Undefined event"); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, stt_tag(), "====="); - SLOG(LOG_DEBUG, stt_tag(), " "); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "====="); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " "); return ECORE_CALLBACK_PASS_ON; } @@ -300,7 +298,7 @@ int __stt_config_mgr_register_config_event() fd = inotify_init(); if (fd < 0) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail get inotify fd"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail get inotify fd"); //LCOV_EXCL_LINE return -1; //LCOV_EXCL_LINE } g_fd_noti = fd; @@ -310,7 +308,7 @@ int __stt_config_mgr_register_config_event() g_fd_handler_noti = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)stt_config_mgr_inotify_event_cb, NULL, NULL, NULL); if (NULL == g_fd_handler_noti) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to get handler_noti"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to get handler_noti"); //LCOV_EXCL_LINE return -1; //LCOV_EXCL_LINE } @@ -334,7 +332,7 @@ int __stt_config_set_auto_language() value = vconf_get_str(VCONFKEY_LANGSET); if (NULL == value) { - SLOG(LOG_ERROR, stt_tag(), "[Config ERROR] Fail to get display language"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[Config ERROR] Fail to get display language"); //LCOV_EXCL_LINE return -1; } @@ -343,27 +341,27 @@ int __stt_config_set_auto_language() /* Check current config info */ if (NULL == g_config_info) { - SLOG(LOG_ERROR, stt_tag(), "Current config info is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Current config info is NULL"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_OPERATION_FAILED; } /* Check current language */ if (NULL == g_config_info->language) { - SLOG(LOG_ERROR, stt_tag(), "Current config language is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Current config language is NULL"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_OPERATION_FAILED; } if (0 == strncmp(g_config_info->language, candidate_lang, 5)) { - SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto. STT language(%s) is same with display lang", g_config_info->language); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[Config] Language is auto. STT language(%s) is same with display lang", g_config_info->language); return 0; } else { - SLOG(LOG_DEBUG, stt_tag(), "[Config] Display language : %s", candidate_lang); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[Config] Display language : %s", candidate_lang); //LCOV_EXCL_LINE } if (true == __stt_config_mgr_check_lang_is_valid(g_config_info->engine_id, candidate_lang)) { char* before_lang = NULL; if (0 != stt_parser_set_language(candidate_lang)) { - SLOG(LOG_ERROR, stt_tag(), "Fail to save default language"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Fail to save default language"); return -1; } @@ -372,7 +370,7 @@ int __stt_config_set_auto_language() free(g_config_info->language); g_config_info->language = strdup(candidate_lang); - SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto. Set default language(%s)", g_config_info->language); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[Config] Language is auto. Set default language(%s)", g_config_info->language); /* Call all callbacks of client*/ GSList *iter = NULL; @@ -400,23 +398,23 @@ int __stt_config_set_auto_language() /* Candidate language is not valid */ char* tmp_language = NULL; if (0 != __stt_config_mgr_select_lang(g_config_info->engine_id, &tmp_language)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to select language"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to select language"); return -1; } if (NULL == tmp_language) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Selected language is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Selected language is NULL"); return -1; } if (0 != stt_parser_set_language(tmp_language)) { free(tmp_language); tmp_language = NULL; - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to save config"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to save config"); return -1; } - SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto but display lang is not supported. Default language change(%s)", tmp_language); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[Config] Language is auto but display lang is not supported. Default language change(%s)", tmp_language); /* Call all callbacks of client*/ GSList *iter = NULL; @@ -482,7 +480,7 @@ void __stt_config_release_client(int uid) } if (0 < g_slist_length(g_config_client_list)) { - SLOG(LOG_DEBUG, stt_tag(), "Client count (%d)", g_slist_length(g_config_client_list)); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Client count (%d)", g_slist_length(g_config_client_list)); } return; } @@ -515,7 +513,7 @@ void __stt_config_release_engine() int __stt_config_mgr_check_engine_is_valid(const char* engine_id) { if (NULL == engine_id) { - SLOG(LOG_ERROR, stt_tag(), "Input parameter is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Input parameter is NULL"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_INVALID_PARAMETER; } @@ -523,7 +521,7 @@ int __stt_config_mgr_check_engine_is_valid(const char* engine_id) stt_engine_info_s *engine_info = NULL; if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, stt_tag(), "There is no engine!!"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "There is no engine!!"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_ENGINE_NOT_FOUND; } @@ -534,12 +532,12 @@ int __stt_config_mgr_check_engine_is_valid(const char* engine_id) engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "engine info is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "engine info is NULL"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_ENGINE_NOT_FOUND; } if (0 == strcmp(engine_id, engine_info->uuid)) { - SLOG(LOG_DEBUG, stt_tag(), "Default engine is valid : %s", engine_id); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Default engine is valid : %s", engine_id); return STT_CONFIG_ERROR_NONE; } @@ -549,13 +547,13 @@ int __stt_config_mgr_check_engine_is_valid(const char* engine_id) /* Change default engine */ iter = g_slist_nth(g_engine_list, 0); if (NULL == iter) { - SLOG(LOG_ERROR, stt_tag(), "Operation failed - false engine"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Operation failed - false engine"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_OPERATION_FAILED; } engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Engine info is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Engine info is NULL"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_ENGINE_NOT_FOUND; } @@ -582,7 +580,7 @@ int __stt_config_mgr_check_engine_is_valid(const char* engine_id) bool is_valid_lang = false; if (0 >= g_slist_length(engine_info->languages)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty supported language"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty supported language"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_ENGINE_NOT_FOUND; } @@ -593,7 +591,7 @@ int __stt_config_mgr_check_engine_is_valid(const char* engine_id) /*Get handle data from list*/ lang = iter_lang->data; - SLOG(LOG_DEBUG, stt_tag(), " %s", lang); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " %s", lang); if (NULL != lang) { if (0 == strcmp(lang, g_config_info->language)) { /* language is valid */ @@ -625,17 +623,17 @@ int __stt_config_mgr_check_engine_is_valid(const char* engine_id) } //LCOV_EXCL_START - SLOG(LOG_DEBUG, stt_tag(), "[Config] Engine changed"); - SLOG(LOG_DEBUG, stt_tag(), " Engine : %s", g_config_info->engine_id); - SLOG(LOG_DEBUG, stt_tag(), " Setting : %s", g_config_info->setting); - SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language); - SLOG(LOG_DEBUG, stt_tag(), " Silence detection : %s", g_config_info->silence_detection ? "on" : "off"); - SLOG(LOG_DEBUG, stt_tag(), " Credential : %s", g_config_info->credential ? "true" : "false"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[Config] Engine changed"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " Engine : %s", g_config_info->engine_id); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " Setting : %s", g_config_info->setting); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " language : %s", g_config_info->language); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " Silence detection : %s", g_config_info->silence_detection ? "on" : "off"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " Credential : %s", g_config_info->credential ? "true" : "false"); //LCOV_EXCL_STOP if (0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language, g_config_info->silence_detection, g_config_info->credential)) { - SLOG(LOG_ERROR, stt_tag(), "Fail to save config"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Fail to save config"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_OPERATION_FAILED; } @@ -648,10 +646,10 @@ static void __get_engine_list(const char* directory) struct dirent *dirp = NULL; if (NULL == directory) { - SLOG(LOG_ERROR, stt_tag(), "[Directory ERROR] Directory is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[Directory ERROR] Directory is NULL"); //LCOV_EXCL_LINE return; } else { - SLOG(LOG_DEBUG, stt_tag(), "[Directory DEBUG] Directory: %s", directory); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[Directory DEBUG] Directory: %s", directory); } dp = opendir(directory); @@ -673,11 +671,11 @@ static void __get_engine_list(const char* directory) if (NULL != filepath) { snprintf(filepath, filesize, "%s/%s", directory, dirp->d_name); } else { - SLOG(LOG_ERROR, stt_tag(), "[Config ERROR] Memory not enough!!"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[Config ERROR] Memory not enough!!"); //LCOV_EXCL_LINE continue; } - SLOG(LOG_DEBUG, stt_tag(), "[File DEBUG] File path: %s", filepath); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[File DEBUG] File path: %s", filepath); if (0 == stt_parser_get_engine_info(filepath, &info)) { g_engine_list = g_slist_append(g_engine_list, info); @@ -692,7 +690,7 @@ static void __get_engine_list(const char* directory) closedir(dp); } else { - SLOG(LOG_WARN, stt_tag(), "[Config WARNING] Fail to open directory"); + SLOG(LOG_WARN, TAG_STTCONFIG, "[Config WARNING] Fail to open directory"); } return; @@ -712,7 +710,7 @@ int stt_config_mgr_initialize(int uid) get_uid = iter->data; if (uid == *get_uid) { - SLOG(LOG_WARN, stt_tag(), "[CONFIG] uid(%d) has already registered", uid); + SLOG(LOG_WARN, TAG_STTCONFIG, "[CONFIG] uid(%d) has already registered", uid); return 0; } @@ -721,7 +719,7 @@ int stt_config_mgr_initialize(int uid) temp_client = (stt_config_client_s*)calloc(1, sizeof(stt_config_client_s)); if (NULL == temp_client) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to allocate memory"); return STT_CONFIG_ERROR_OUT_OF_MEMORY; } temp_client->uid = uid; @@ -733,48 +731,48 @@ int stt_config_mgr_initialize(int uid) /* Add uid */ g_config_client_list = g_slist_append(g_config_client_list, temp_client); - SLOG(LOG_WARN, stt_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid); + SLOG(LOG_WARN, TAG_STTCONFIG, "[CONFIG] Add uid(%d) but config has already initialized", 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); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[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); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "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); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[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); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "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); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[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); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "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); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[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); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Success to make directory : %s", STT_DOWNLOAD_ENGINE_INFO); } } @@ -782,17 +780,17 @@ int stt_config_mgr_initialize(int uid) /* Get file name from default engine directory */ g_engine_list = NULL; - SLOG(LOG_WARN, stt_tag(), "[CONFIG] default engine info(%s)", STT_DEFAULT_ENGINE_INFO); + SLOG(LOG_WARN, TAG_STTCONFIG, "[CONFIG] default engine info(%s)", STT_DEFAULT_ENGINE_INFO); - SLOG(LOG_DEBUG, stt_tag(), "[CONFIG] Get default engine list"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[CONFIG] Get default engine list"); __get_engine_list(STT_DEFAULT_ENGINE_INFO); - SLOG(LOG_DEBUG, stt_tag(), "[CONFIG] Get download engine list"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[CONFIG] Get download engine list"); __get_engine_list(STT_DOWNLOAD_ENGINE_INFO); __stt_config_mgr_print_engine_info(); if (0 != stt_parser_load_config(&g_config_info)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse configure information"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to parse configure information"); __stt_config_release_client(uid); __stt_config_release_engine(); return STT_CONFIG_ERROR_OPERATION_FAILED; @@ -800,7 +798,7 @@ int stt_config_mgr_initialize(int uid) /* Check whether engine id is valid */ if (0 != __stt_config_mgr_check_engine_is_valid(g_config_info->engine_id)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to get default engine"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to get default engine"); __stt_config_release_client(uid); __stt_config_release_engine(); stt_parser_unload_config(g_config_info); @@ -815,7 +813,7 @@ int stt_config_mgr_initialize(int uid) /* Default language is not valid */ char* tmp_language; if (0 != __stt_config_mgr_select_lang(g_config_info->engine_id, &tmp_language)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to select language"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to select language"); __stt_config_release_client(uid); __stt_config_release_engine(); stt_parser_unload_config(g_config_info); @@ -834,17 +832,17 @@ int stt_config_mgr_initialize(int uid) } /* print stt-service config */ - SLOG(LOG_DEBUG, stt_tag(), "== STT service config =="); - SLOG(LOG_DEBUG, stt_tag(), " engine : %s", g_config_info->engine_id); - SLOG(LOG_DEBUG, stt_tag(), " setting : %s", g_config_info->setting); - SLOG(LOG_DEBUG, stt_tag(), " auto language : %s", g_config_info->auto_lang ? "on" : "off"); - SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language); - SLOG(LOG_DEBUG, stt_tag(), " silence detection : %s", g_config_info->silence_detection ? "on" : "off"); - SLOG(LOG_DEBUG, stt_tag(), " credential : %s", g_config_info->credential ? "true" : "false"); - SLOG(LOG_DEBUG, stt_tag(), "==================="); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "== STT service config =="); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " engine : %s", g_config_info->engine_id); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " setting : %s", g_config_info->setting); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " auto language : %s", g_config_info->auto_lang ? "on" : "off"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " language : %s", g_config_info->language); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " silence detection : %s", g_config_info->silence_detection ? "on" : "off"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " credential : %s", g_config_info->credential ? "true" : "false"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "==================="); if (0 != __stt_config_mgr_register_config_event()) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to register config event"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to register config event"); __stt_config_release_client(uid); __stt_config_release_engine(); stt_parser_unload_config(g_config_info); @@ -856,7 +854,7 @@ int stt_config_mgr_initialize(int uid) temp_client = (stt_config_client_s*)calloc(1, sizeof(stt_config_client_s)); if (NULL == temp_client) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_OUT_OF_MEMORY; } temp_client->uid = uid; @@ -897,7 +895,7 @@ int stt_config_mgr_finalize(int uid) } if (0 < g_slist_length(g_config_client_list)) { - SLOG(LOG_DEBUG, stt_tag(), "Client count (%d)", g_slist_length(g_config_client_list)); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Client count (%d)", g_slist_length(g_config_client_list)); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_NONE; } @@ -990,7 +988,7 @@ int stt_config_mgr_unset_callback(int uid) int stt_config_mgr_get_engine_list(stt_config_supported_engine_cb callback, void* user_data) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return STT_CONFIG_ERROR_INVALID_STATE; } @@ -1002,7 +1000,7 @@ int stt_config_mgr_get_engine_list(stt_config_supported_engine_cb callback, void stt_engine_info_s *engine_info = NULL; if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_WARN, stt_tag(), "[ERROR] Engine list is NULL"); + SLOG(LOG_WARN, TAG_STTCONFIG, "[ERROR] Engine list is NULL"); return STT_CONFIG_ERROR_ENGINE_NOT_FOUND; } @@ -1013,11 +1011,11 @@ int stt_config_mgr_get_engine_list(stt_config_supported_engine_cb callback, void engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), " Engine info is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, " Engine info is NULL"); return STT_CONFIG_ERROR_OPERATION_FAILED; } - if (false == callback(engine_info->uuid, engine_info->name, + if (false == callback(engine_info->uuid, engine_info->name, engine_info->setting, engine_info->support_silence_detection, user_data)) { break; } @@ -1031,7 +1029,7 @@ int stt_config_mgr_get_engine_list(stt_config_supported_engine_cb callback, void int stt_config_mgr_get_engine(char** engine) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_INVALID_STATE; } @@ -1042,7 +1040,7 @@ int stt_config_mgr_get_engine(char** engine) if (NULL != g_config_info->engine_id) { *engine = strdup(g_config_info->engine_id); } else { - SLOG(LOG_ERROR, stt_tag(), " Engine id is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, " Engine id is NULL"); //LCOV_EXCL_LINE *engine = NULL; return STT_CONFIG_ERROR_ENGINE_NOT_FOUND; } @@ -1060,31 +1058,31 @@ int __stt_config_set_buxtonkey(const char* engine) int ret = buxton_open(&bux_cli, NULL, NULL); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] Fail to open buxton client, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[DBUS-BUXTON2] Fail to open buxton client, ret(%d)", ret); return STT_CONFIG_ERROR_OPERATION_FAILED; } bux_layer = buxton_create_layer("system"); if (NULL == bux_layer) { - SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] buxton_create_layer FAIL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[DBUS-BUXTON2] buxton_create_layer FAIL"); buxton_close(bux_cli); bux_cli = NULL; return STT_CONFIG_ERROR_OPERATION_FAILED; } bux_val = buxton_value_create_string(engine); if (NULL == bux_val) { - SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] buxton_value_create_string FAIL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[DBUS-BUXTON2] buxton_value_create_string FAIL"); buxton_free_layer(bux_layer); buxton_close(bux_cli); bux_layer = NULL; bux_cli = NULL; return STT_CONFIG_ERROR_OPERATION_FAILED; } else { - SLOG(LOG_DEBUG, stt_tag(), "[DBUS-BUXTON2] layer: %s", buxton_layer_get_name(bux_layer)); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[DBUS-BUXTON2] layer: %s", buxton_layer_get_name(bux_layer)); } ret = buxton_set_value_sync(bux_cli, bux_layer, STT_ENGINE_DB_DEFAULT, bux_val); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[DBUS-BUXTON2] Fail to set value sync, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[DBUS-BUXTON2] Fail to set value sync, ret(%d)", ret); buxton_value_free(bux_val); buxton_free_layer(bux_layer); buxton_close(bux_cli); @@ -1094,7 +1092,7 @@ int __stt_config_set_buxtonkey(const char* engine) bux_val = NULL; return STT_CONFIG_ERROR_OPERATION_FAILED; } - SLOG(LOG_DEBUG, stt_tag(), "[DBUS-BUXTON2] buxton_set_value_sync: %s", STT_ENGINE_DB_DEFAULT); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[DBUS-BUXTON2] buxton_set_value_sync: %s", STT_ENGINE_DB_DEFAULT); buxton_value_free(bux_val); buxton_free_layer(bux_layer); @@ -1110,7 +1108,7 @@ int __stt_config_set_buxtonkey(const char* engine) int stt_config_mgr_set_engine(const char* engine) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return STT_CONFIG_ERROR_INVALID_STATE; } @@ -1127,11 +1125,11 @@ int stt_config_mgr_set_engine(const char* engine) return 0; } - SLOG(LOG_DEBUG, stt_tag(), "New engine id : %s", engine); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "New engine id : %s", engine); int ret = __stt_config_set_buxtonkey(engine); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] set buxtonkey Failed!!!"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] set buxtonkey Failed!!!"); return ret; } @@ -1146,7 +1144,7 @@ int stt_config_mgr_set_engine(const char* engine) engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Engine info is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Engine info is NULL"); iter = g_slist_next(iter); continue; } @@ -1187,7 +1185,7 @@ int stt_config_mgr_set_engine(const char* engine) /*Get handle data from list*/ lang = iter_lang->data; - SLOG(LOG_DEBUG, stt_tag(), " %s", lang); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " %s", lang); if (NULL != lang && NULL != g_config_info->language) { if (0 == strcmp(lang, g_config_info->language)) { /* language is valid */ @@ -1211,7 +1209,7 @@ int stt_config_mgr_set_engine(const char* engine) iter_lang = g_slist_nth(engine_info->languages, 0); if (NULL == iter_lang) { - SLOG(LOG_ERROR, stt_tag(), "Fail to get default language"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Fail to get default language"); break; } @@ -1237,20 +1235,20 @@ int stt_config_mgr_set_engine(const char* engine) } if (true == is_valid_engine) { - SLOG(LOG_DEBUG, stt_tag(), "[Config] Engine changed"); - SLOG(LOG_DEBUG, stt_tag(), " Engine : %s", g_config_info->engine_id); - SLOG(LOG_DEBUG, stt_tag(), " Setting : %s", g_config_info->setting); - SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language); - SLOG(LOG_DEBUG, stt_tag(), " Silence detection : %s", g_config_info->silence_detection ? "on" : "off"); - SLOG(LOG_DEBUG, stt_tag(), " Credential : %s", g_config_info->credential ? "true" : "false"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[Config] Engine changed"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " Engine : %s", g_config_info->engine_id); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " Setting : %s", g_config_info->setting); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " language : %s", g_config_info->language); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " Silence detection : %s", g_config_info->silence_detection ? "on" : "off"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " Credential : %s", g_config_info->credential ? "true" : "false"); if (0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language, g_config_info->silence_detection, g_config_info->credential)) { - SLOG(LOG_ERROR, stt_tag(), " Fail to save config"); + SLOG(LOG_ERROR, TAG_STTCONFIG, " Fail to save config"); return STT_CONFIG_ERROR_OPERATION_FAILED; } } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Engine id is not valid"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Engine id is not valid"); return STT_CONFIG_ERROR_INVALID_PARAMETER; } @@ -1260,12 +1258,12 @@ int stt_config_mgr_set_engine(const char* engine) int stt_config_mgr_get_engine_agreement(const char* engine, char** agreement) { if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, stt_tag(), "There is no engine"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "There is no engine"); return STT_CONFIG_ERROR_INVALID_STATE; } if (NULL == agreement) { - SLOG(LOG_ERROR, stt_tag(), "Input parameter is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Input parameter is NULL"); return STT_CONFIG_ERROR_INVALID_PARAMETER; } @@ -1276,13 +1274,13 @@ int stt_config_mgr_get_engine_agreement(const char* engine, char** agreement) if (NULL == engine) { current_engine = strdup(g_config_info->engine_id); if (NULL == current_engine) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to allocate memory"); return STT_CONFIG_ERROR_OUT_OF_MEMORY;; } } else { current_engine = strdup(engine); if (NULL == current_engine) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to allocate memory"); return STT_CONFIG_ERROR_OUT_OF_MEMORY;; } } @@ -1294,7 +1292,7 @@ int stt_config_mgr_get_engine_agreement(const char* engine, char** agreement) engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] engine info is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] engine info is NULL"); if (NULL != current_engine) free(current_engine); return STT_CONFIG_ERROR_OPERATION_FAILED; } @@ -1307,7 +1305,7 @@ int stt_config_mgr_get_engine_agreement(const char* engine, char** agreement) if (NULL != engine_info->agreement) { *agreement = strdup(engine_info->agreement); } else { - SLOG(LOG_WARN, stt_tag(), "[WARNING] engine agreement is not support"); + SLOG(LOG_WARN, TAG_STTCONFIG, "[WARNING] engine agreement is not support"); } break; } @@ -1321,12 +1319,12 @@ int stt_config_mgr_get_engine_agreement(const char* engine, char** agreement) int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported_langauge_cb callback, void* user_data) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_INVALID_STATE; } if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_ERROR, stt_tag(), "There is no engine"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "There is no engine"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_ENGINE_NOT_FOUND; } @@ -1340,7 +1338,7 @@ int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] engine info is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] engine info is NULL"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_OPERATION_FAILED; } @@ -1360,7 +1358,7 @@ int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported lang = iter_lang->data; if (NULL != lang) { - SLOG(LOG_DEBUG, stt_tag(), " %s", lang); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " %s", lang); if (false == callback(engine_info->uuid, lang, user_data)) break; } @@ -1377,7 +1375,7 @@ int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported int stt_config_mgr_get_default_language(char** language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_INVALID_STATE; } @@ -1388,7 +1386,7 @@ int stt_config_mgr_get_default_language(char** language) if (NULL != g_config_info->language) { *language = strdup(g_config_info->language); } else { - SLOG(LOG_ERROR, stt_tag(), " language is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, " language is NULL"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_OPERATION_FAILED; } @@ -1399,7 +1397,7 @@ int stt_config_mgr_get_default_language(char** language) int stt_config_mgr_set_default_language(const char* language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return STT_CONFIG_ERROR_INVALID_STATE; } @@ -1410,13 +1408,13 @@ int stt_config_mgr_set_default_language(const char* language) /* Check language is valid */ if (NULL != g_config_info->language) { if (0 != stt_parser_set_language(language)) { - SLOG(LOG_ERROR, stt_tag(), "Fail to save engine id"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Fail to save engine id"); return STT_CONFIG_ERROR_OPERATION_FAILED; } free(g_config_info->language); g_config_info->language = strdup(language); } else { - SLOG(LOG_ERROR, stt_tag(), " language is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, " language is NULL"); return STT_CONFIG_ERROR_OPERATION_FAILED; } @@ -1426,7 +1424,7 @@ int stt_config_mgr_set_default_language(const char* language) int stt_config_mgr_get_auto_language(bool* value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return STT_CONFIG_ERROR_INVALID_STATE; } @@ -1442,14 +1440,14 @@ int stt_config_mgr_get_auto_language(bool* value) int stt_config_mgr_set_auto_language(bool value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return STT_CONFIG_ERROR_INVALID_STATE; } if (g_config_info->auto_lang != value) { /* Check language is valid */ if (0 != stt_parser_set_auto_lang(value)) { - SLOG(LOG_ERROR, stt_tag(), "Fail to save engine id"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Fail to save engine id"); return STT_CONFIG_ERROR_OPERATION_FAILED; } g_config_info->auto_lang = value; @@ -1465,7 +1463,7 @@ int stt_config_mgr_set_auto_language(bool value) int stt_config_mgr_get_silence_detection(bool* value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return STT_CONFIG_ERROR_INVALID_STATE; } @@ -1480,12 +1478,12 @@ int stt_config_mgr_get_silence_detection(bool* value) int stt_config_mgr_set_silence_detection(bool value) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return STT_CONFIG_ERROR_INVALID_STATE; } if (0 != stt_parser_set_silence_detection(value)) { - SLOG(LOG_ERROR, stt_tag(), "Fail to save engine id"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Fail to save engine id"); return STT_CONFIG_ERROR_OPERATION_FAILED; } @@ -1497,7 +1495,7 @@ int stt_config_mgr_set_silence_detection(bool value) bool stt_config_check_default_engine_is_valid(const char* engine) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return false; } @@ -1531,7 +1529,7 @@ bool stt_config_check_default_engine_is_valid(const char* engine) bool stt_config_check_default_language_is_valid(const char* language) { if (0 >= g_slist_length(g_config_client_list)) { - SLOG(LOG_ERROR, stt_tag(), "Not initialized"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Not initialized"); return false; } @@ -1540,7 +1538,7 @@ bool stt_config_check_default_language_is_valid(const char* language) } if (NULL == g_config_info->engine_id) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Default engine id is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Default engine id is NULL"); return false; } @@ -1557,7 +1555,7 @@ bool stt_config_check_default_language_is_valid(const char* language) engine_info = iter->data; if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Engine info is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Engine info is NULL"); iter = g_slist_next(iter); continue; } @@ -1595,28 +1593,28 @@ int __stt_config_mgr_print_engine_info() stt_engine_info_s *engine_info = NULL; if (0 >= g_slist_length(g_engine_list)) { - SLOG(LOG_DEBUG, stt_tag(), "-------------- engine list -----------------"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, stt_tag(), " No Engine in engine directory"); //LCOV_EXCL_LINE - SLOG(LOG_DEBUG, stt_tag(), "--------------------------------------------"); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "-------------- engine list -----------------"); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, " No Engine in engine directory"); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "--------------------------------------------"); //LCOV_EXCL_LINE return 0; } /* Get a first item */ iter = g_slist_nth(g_engine_list, 0); - SLOG(LOG_DEBUG, stt_tag(), "--------------- engine list -----------------"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "--------------- engine list -----------------"); int i = 1; while (NULL != iter) { engine_info = iter->data; - SLOG(LOG_DEBUG, stt_tag(), "[%dth]", i); - SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name); - SLOG(LOG_DEBUG, stt_tag(), " id : %s", engine_info->uuid); - SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting); - SLOG(LOG_DEBUG, stt_tag(), " agreement : %s", engine_info->agreement); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[%dth]", i); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " name : %s", engine_info->name); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " id : %s", engine_info->uuid); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " setting : %s", engine_info->setting); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " agreement : %s", engine_info->agreement); - SLOG(LOG_DEBUG, stt_tag(), " languages"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " languages"); GSList *iter_lang = NULL; char* lang; if (g_slist_length(engine_info->languages) > 0) { @@ -1628,21 +1626,21 @@ int __stt_config_mgr_print_engine_info() /*Get handle data from list*/ lang = iter_lang->data; - SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", j, lang); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " [%dth] %s", j, lang); /*Get next item*/ iter_lang = g_slist_next(iter_lang); j++; } } else { - SLOG(LOG_ERROR, stt_tag(), " language is NONE"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, " language is NONE"); //LCOV_EXCL_LINE } - SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", + SLOG(LOG_DEBUG, TAG_STTCONFIG, " silence support : %s", engine_info->support_silence_detection ? "true" : "false"); iter = g_slist_next(iter); i++; } - SLOG(LOG_DEBUG, stt_tag(), "--------------------------------------------"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "--------------------------------------------"); return 0; } @@ -1686,13 +1684,13 @@ int stt_config_mgr_reset_time_info() int stt_config_mgr_add_time_info(int index, int event, const char* text, long start_time, long end_time) { if (NULL == text) { - SLOG(LOG_ERROR, stt_tag(), "Invalid parameter : text is NULL"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "Invalid parameter : text is NULL"); return -1; } stt_result_time_info_s *info = (stt_result_time_info_s*)calloc(1, sizeof(stt_result_time_info_s)); if (NULL == info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to allocate memory"); return STT_CONFIG_ERROR_OUT_OF_MEMORY; } info->index = index; @@ -1703,12 +1701,12 @@ 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; - SECURE_SLOG(LOG_DEBUG, stt_tag(), "[DEBUG] inside stt_config_mgr_add_time_info: index(%d), text(%s), start time(%ld), end_time(%ld)", info->index, (NULL == info->text) ? "NULL" : info->text, info->start_time, info->end_time); + SECURE_SLOG(LOG_DEBUG, TAG_STTCONFIG, "[DEBUG] inside stt_config_mgr_add_time_info: index(%d), text(%s), start time(%ld), end_time(%ld)", 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)); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[DEBUG] inside stt_config_mgr_add_time_info: g_time_list length(%d)", g_slist_length(g_time_list)); return 0; } @@ -1717,7 +1715,7 @@ int stt_config_mgr_add_time_info(int index, int event, const char* text, long st int stt_config_mgr_foreach_time_info(stt_config_result_time_cb callback, void* user_data) { if (NULL == callback) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL : callback function"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Input parameter is NULL : callback function"); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_INVALID_PARAMETER; } @@ -1725,7 +1723,7 @@ int stt_config_mgr_foreach_time_info(stt_config_result_time_cb callback, void* u int ret; ret = stt_parser_get_time_info(&temp_time); if (0 != ret) { - SLOG(LOG_WARN, stt_tag(), "[WARNING] Fail to get time info : %d", ret); //LCOV_EXCL_LINE + SLOG(LOG_WARN, TAG_STTCONFIG, "[WARNING] Fail to get time info : %d", ret); //LCOV_EXCL_LINE return STT_CONFIG_ERROR_NONE; } @@ -1737,7 +1735,7 @@ int stt_config_mgr_foreach_time_info(stt_config_result_time_cb callback, void* u while (NULL != iter) { data = iter->data; - if (false == callback(data->index, data->event, data->text, + if (false == callback(data->index, data->event, data->text, data->start_time, data->end_time, user_data)) { break; } @@ -1773,14 +1771,14 @@ int stt_config_mgr_foreach_time_info(stt_config_result_time_cb callback, void* u int stt_config_mgr_save_time_info_file() { if (0 == g_slist_length(g_time_list)) { - SLOG(LOG_WARN, stt_tag(), "[WARNING] There is no time info to save"); + SLOG(LOG_WARN, TAG_STTCONFIG, "[WARNING] There is no time info to save"); return STT_CONFIG_ERROR_OPERATION_FAILED; } int ret = 0; ret = stt_parser_set_time_info(g_time_list); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to save time info : %d", ret); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to save time info : %d", ret); return STT_CONFIG_ERROR_OPERATION_FAILED; } diff --git a/common/stt_config_parser.c b/common/stt_config_parser.c index 7292a1d..3459ff3 100644 --- a/common/stt_config_parser.c +++ b/common/stt_config_parser.c @@ -48,14 +48,13 @@ #define STT_TAG_TIME_START "start" #define STT_TAG_TIME_END "end" -extern const char* stt_tag(); static xmlDocPtr g_config_doc = NULL; int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info) { if (NULL == path || NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE return -1; } @@ -71,7 +70,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info cur = xmlDocGetRootElement(doc); if (cur == NULL) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -79,7 +78,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info if (xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_BASE_TAG)) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT 'stt-engine'"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong type, root node is NOT 'stt-engine'"); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -88,7 +87,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info cur = cur->xmlChildrenNode; if (cur == NULL) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -100,7 +99,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info if (NULL == temp) { //LCOV_EXCL_START xmlFreeDoc(doc); - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to allocate memory"); return -1; //LCOV_EXCL_STOP } @@ -120,54 +119,54 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_NAME)) { key = xmlNodeGetContent(cur); if (NULL != key) { - /* SLOG(LOG_DEBUG, stt_tag(), "Engine name : %s", (char *)key); */ + /* SLOG(LOG_DEBUG, TAG_STTCONFIG, "Engine name : %s", (char *)key); */ if (NULL != temp->name) free(temp->name); temp->name = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_NAME); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_ENGINE_NAME); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_ID)) { key = xmlNodeGetContent(cur); if (NULL != key) { - /* SLOG(LOG_DEBUG, stt_tag(), "Engine uuid : %s", (char *)key); */ + /* SLOG(LOG_DEBUG, TAG_STTCONFIG, "Engine uuid : %s", (char *)key); */ if (NULL != temp->uuid) free(temp->uuid); temp->uuid = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_ID); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_ENGINE_ID); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_SETTING)) { key = xmlNodeGetContent(cur); if (NULL != key) { - SLOG(LOG_DEBUG, stt_tag(), "Engine setting : %s", (char *)key); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Engine setting : %s", (char *)key); if (NULL != temp->setting) free(temp->setting); temp->setting = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SETTING); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_ENGINE_SETTING); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_AGREEMENT)) { key = xmlNodeGetContent(cur); if (NULL != key) { - SLOG(LOG_DEBUG, stt_tag(), "Engine agreement : %s", (char *)key); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Engine agreement : %s", (char *)key); if (NULL != temp->agreement) free(temp->agreement); temp->agreement = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_AGREEMENT); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_ENGINE_AGREEMENT); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_DEFAULT)) { key = xmlNodeGetContent(cur); if (NULL != key) { - SLOG(LOG_DEBUG, stt_tag(), "Engine agreement : %s", (char *)key); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Engine agreement : %s", (char *)key); if (NULL != temp->default_lang) free(temp->default_lang); temp->default_lang = strdup((char*)key); is_default_lang_set = true; xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_DEFAULT); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_ENGINE_DEFAULT); } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_LANGUAGE_SET)) { xmlNodePtr lang_node = NULL; @@ -179,7 +178,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info if (0 == xmlStrcmp(lang_node->name, (const xmlChar *)STT_TAG_ENGINE_LANGUAGE)) { key = xmlNodeGetContent(lang_node); if (NULL != key) { - /* SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key); */ + /* SLOG(LOG_DEBUG, TAG_STTCONFIG, "language : %s", (char *)key); */ temp_lang = strdup((char*)key); temp->languages = g_slist_append(temp->languages, temp_lang); @@ -191,7 +190,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info } xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_LANGUAGE); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_ENGINE_LANGUAGE); //LCOV_EXCL_LINE } } @@ -200,7 +199,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_SILENCE_SUPPORT)) { key = xmlNodeGetContent(cur); if (NULL != key) { - /*SLOG(LOG_DEBUG, stt_tag(), "silence-detection-support : %s", (char *)key); */ + /*SLOG(LOG_DEBUG, TAG_STTCONFIG, "silence-detection-support : %s", (char *)key); */ if (0 == xmlStrcmp(key, (const xmlChar *)"true")) temp->support_silence_detection = true; @@ -209,12 +208,12 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_SILENCE_SUPPORT); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_ENGINE_SILENCE_SUPPORT); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_ENGINE_CREDENTIAL_NEED)) { key = xmlNodeGetContent(cur); if (NULL != key) { - //SLOG(LOG_DEBUG, stt_tag(), "app-credential-need : %s", (char *)key); + //SLOG(LOG_DEBUG, TAG_STTCONFIG, "app-credential-need : %s", (char *)key); if (0 == xmlStrcmp(key, (const xmlChar *)"true")) temp->need_credential = true; @@ -223,7 +222,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_ENGINE_CREDENTIAL_NEED); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_ENGINE_CREDENTIAL_NEED); } } else { @@ -236,7 +235,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info if (NULL == temp->name || NULL == temp->uuid) { /* Invalid engine */ - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Invalid engine : %s", path); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Invalid engine : %s", path); stt_parser_free_engine_info(temp); return -1; } @@ -249,7 +248,7 @@ int stt_parser_get_engine_info(const char* path, stt_engine_info_s** engine_info int stt_parser_free_engine_info(stt_engine_info_s* engine_info) { if (NULL == engine_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE return -1; } @@ -285,12 +284,12 @@ int stt_parser_print_engine_info(stt_engine_info_s* engine_info) if (NULL == engine_info) return -1; - SLOG(LOG_DEBUG, stt_tag(), "== get engine info =="); - SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name); - SLOG(LOG_DEBUG, stt_tag(), " id : %s", engine_info->uuid); - if (NULL != engine_info->setting) SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "== get engine info =="); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " name : %s", engine_info->name); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " id : %s", engine_info->uuid); + if (NULL != engine_info->setting) SLOG(LOG_DEBUG, TAG_STTCONFIG, " setting : %s", engine_info->setting); - SLOG(LOG_DEBUG, stt_tag(), " languages"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " languages"); GSList *iter = NULL; char* lang; if (g_slist_length(engine_info->languages) > 0) { @@ -302,18 +301,18 @@ int stt_parser_print_engine_info(stt_engine_info_s* engine_info) /*Get handle data from list*/ lang = iter->data; - SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", i, lang); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " [%dth] %s", i, lang); /*Get next item*/ iter = g_slist_next(iter); i++; } } else { - SLOG(LOG_ERROR, stt_tag(), " language is NONE"); + SLOG(LOG_ERROR, TAG_STTCONFIG, " language is NONE"); } - SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", engine_info->support_silence_detection ? "true" : "false"); - SLOG(LOG_DEBUG, stt_tag(), " credential need : %s", engine_info->need_credential ? "true" : "false"); - SLOG(LOG_DEBUG, stt_tag(), "====================="); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " silence support : %s", engine_info->support_silence_detection ? "true" : "false"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, " credential need : %s", engine_info->need_credential ? "true" : "false"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "====================="); return 0; } @@ -322,7 +321,7 @@ int stt_parser_print_engine_info(stt_engine_info_s* engine_info) int stt_parser_load_config(stt_config_s** config_info) { if (NULL == config_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE return -1; } @@ -334,7 +333,7 @@ int stt_parser_load_config(stt_config_s** config_info) if (0 != access(STT_CONFIG, F_OK)) { doc = xmlParseFile(STT_DEFAULT_CONFIG); if (doc == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG); //LCOV_EXCL_LINE xmlCleanupParser(); return -1; } @@ -351,13 +350,13 @@ int stt_parser_load_config(stt_config_s** config_info) usleep(10000); if (STT_RETRY_COUNT == retry_count) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_CONFIG); - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Remove the file"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to parse file error : %s", STT_CONFIG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Remove the file"); remove(STT_CONFIG); doc = xmlParseFile(STT_DEFAULT_CONFIG); if (NULL == doc) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to parse file error : %s", STT_DEFAULT_CONFIG); xmlCleanupParser(); return -1; } @@ -369,20 +368,20 @@ int stt_parser_load_config(stt_config_s** config_info) cur = xmlDocGetRootElement(doc); if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); //LCOV_EXCL_LINE xmlFreeDoc(doc); return -1; } if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); //LCOV_EXCL_LINE xmlFreeDoc(doc); return -1; } cur = cur->xmlChildrenNode; if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); //LCOV_EXCL_LINE xmlFreeDoc(doc); return -1; } @@ -392,7 +391,7 @@ int stt_parser_load_config(stt_config_s** config_info) temp = (stt_config_s*)calloc(1, sizeof(stt_config_s)); if (NULL == temp) { xmlFreeDoc(doc); - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to allocate memory"); //LCOV_EXCL_LINE return -1; } @@ -404,56 +403,56 @@ int stt_parser_load_config(stt_config_s** config_info) if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_ID)) { key = xmlNodeGetContent(cur); if (NULL != key) { - /*SLOG(LOG_DEBUG, stt_tag(), "Engine id : %s", (char *)key); */ + /*SLOG(LOG_DEBUG, TAG_STTCONFIG, "Engine id : %s", (char *)key); */ if (NULL != temp->engine_id) free(temp->engine_id); temp->engine_id = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] engine id is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] engine id is NULL"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_ENGINE_SETTING)) { key = xmlNodeGetContent(cur); if (NULL != key) { - /*SLOG(LOG_DEBUG, stt_tag(), "Setting path : %s", (char *)key); */ + /*SLOG(LOG_DEBUG, TAG_STTCONFIG, "Setting path : %s", (char *)key); */ if (NULL != temp->setting) free(temp->setting); temp->setting = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] setting path is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] setting path is NULL"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_AUTO_LANGUAGE)) { key = xmlNodeGetContent(cur); if (NULL != key) { - /*SLOG(LOG_DEBUG, stt_tag(), "Auto language : %s", (char *)key); */ + /*SLOG(LOG_DEBUG, TAG_STTCONFIG, "Auto language : %s", (char *)key); */ if (0 == xmlStrcmp(key, (const xmlChar *)"on")) { temp->auto_lang = true; } else if (0 == xmlStrcmp(key, (const xmlChar *)"off")) { temp->auto_lang = false; } else { - SLOG(LOG_ERROR, stt_tag(), "Auto voice is wrong"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Auto voice is wrong"); //LCOV_EXCL_LINE temp->auto_lang = true; } xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] auto language is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] auto language is NULL"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_LANGUAGE)) { key = xmlNodeGetContent(cur); if (NULL != key) { - /*SLOG(LOG_DEBUG, stt_tag(), "language : %s", (char *)key); */ + /*SLOG(LOG_DEBUG, TAG_STTCONFIG, "language : %s", (char *)key); */ if (NULL != temp->language) free(temp->language); temp->language = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] language is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] language is NULL"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_SILENCE_DETECTION)) { key = xmlNodeGetContent(cur); if (NULL != key) { - /*SLOG(LOG_DEBUG, stt_tag(), "silence-detection : %s", (char *)key); */ + /*SLOG(LOG_DEBUG, TAG_STTCONFIG, "silence-detection : %s", (char *)key); */ if (0 == xmlStrcmp(key, (const xmlChar *)"on")) temp->silence_detection = true; @@ -462,12 +461,12 @@ int stt_parser_load_config(stt_config_s** config_info) xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] silence-detection is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] silence-detection is NULL"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_CONFIG_CREDENTIAL)) { key = xmlNodeGetContent(cur); if (NULL != key) { - //SLOG(LOG_DEBUG, stt_tag(), "credential : %s", (char *)key); + //SLOG(LOG_DEBUG, TAG_STTCONFIG, "credential : %s", (char *)key); if (0 == xmlStrcmp(key, (const xmlChar *)"true")) temp->credential = true; @@ -476,7 +475,7 @@ int stt_parser_load_config(stt_config_s** config_info) xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] credential is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] credential is NULL"); //LCOV_EXCL_LINE } } else { @@ -499,21 +498,21 @@ int stt_parser_load_config(stt_config_s** config_info) usleep(10000); if (STT_RETRY_COUNT == retry_count) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Save result : %d", ret); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Save result : %d", ret); return -1; } } while (0 != ret); /* Set mode */ if (0 > chmod(STT_CONFIG, 0600)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to change file mode : %d", ret); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to change file mode : %d", ret); } /* Set owner */ if (0 > chown(STT_CONFIG, 5000, 5000)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to change file owner : %d", ret); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to change file owner : %d", ret); } - SLOG(LOG_DEBUG, stt_tag(), "Default config is changed : pid(%d)", getpid()); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Default config is changed : pid(%d)", getpid()); } return 0; @@ -553,18 +552,18 @@ int stt_parser_set_engine(const char* engine_id, const char* setting, const char xmlNodePtr cur = NULL; cur = xmlDocGetRootElement(g_config_doc); if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); return -1; } if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); return -1; } cur = cur->xmlChildrenNode; if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); return -1; } @@ -599,7 +598,7 @@ int stt_parser_set_engine(const char* engine_id, const char* setting, const char } int ret = xmlSaveFile(STT_CONFIG, g_config_doc); - SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Save result : %d", ret); return 0; } @@ -612,18 +611,18 @@ int stt_parser_set_language(const char* language) xmlNodePtr cur = NULL; cur = xmlDocGetRootElement(g_config_doc); if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); return -1; } if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); return -1; } cur = cur->xmlChildrenNode; if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); return -1; } @@ -636,7 +635,7 @@ int stt_parser_set_language(const char* language) } int ret = xmlSaveFile(STT_CONFIG, g_config_doc); - SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Save result : %d", ret); return 0; @@ -651,18 +650,18 @@ int stt_parser_set_auto_lang(bool value) xmlNodePtr cur = NULL; cur = xmlDocGetRootElement(g_config_doc); if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); return -1; } if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); return -1; } cur = cur->xmlChildrenNode; if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); return -1; } @@ -673,7 +672,7 @@ int stt_parser_set_auto_lang(bool value) } else if (false == value) { xmlNodeSetContent(cur, (const xmlChar *)"off"); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong value of auto voice"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong value of auto voice"); return -1; } break; @@ -682,7 +681,7 @@ int stt_parser_set_auto_lang(bool value) } int ret = xmlSaveFile(STT_CONFIG, g_config_doc); - SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Save result : %d", ret); return 0; } @@ -695,18 +694,18 @@ int stt_parser_set_silence_detection(bool value) xmlNodePtr cur = NULL; cur = xmlDocGetRootElement(g_config_doc); if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); return -1; } if (xmlStrcmp(cur->name, (const xmlChar *) STT_TAG_CONFIG_BASE_TAG)) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); return -1; } cur = cur->xmlChildrenNode; if (cur == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); return -1; } @@ -722,7 +721,7 @@ int stt_parser_set_silence_detection(bool value) } int ret = xmlSaveFile(STT_CONFIG, g_config_doc); - SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Save result : %d", ret); return 0; } @@ -731,7 +730,7 @@ int stt_parser_set_silence_detection(bool value) int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang, char** language, int* silence, int* credential) { if (NULL == engine || NULL == language || NULL == silence || NULL == credential) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Input parameter is NULL"); //LCOV_EXCL_LINE return -1; } @@ -744,7 +743,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang doc = xmlParseFile(STT_CONFIG); if (doc == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to parse file error : %s", STT_CONFIG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to parse file error : %s", STT_CONFIG); return -1; } @@ -752,7 +751,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang cur_old = xmlDocGetRootElement(g_config_doc); if (cur_new == NULL || cur_old == NULL) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -760,7 +759,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang if (xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_BASE_TAG) || xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_BASE_TAG)) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong type, root node is NOT %s", STT_TAG_CONFIG_BASE_TAG); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -770,7 +769,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang cur_old = cur_old->xmlChildrenNode; if (cur_new == NULL || cur_old == NULL) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -788,7 +787,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang key_new = xmlNodeGetContent(cur_new); if (NULL != key_new) { if (0 != xmlStrcmp(key_old, key_new)) { - SLOG(LOG_DEBUG, stt_tag(), "Old engine id(%s), New engine(%s)", (char*)key_old, (char*)key_new); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Old engine id(%s), New engine(%s)", (char*)key_old, (char*)key_new); if (NULL != *engine) free(*engine); *engine = strdup((char*)key_new); } @@ -797,7 +796,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang xmlFree(key_old); } } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Old config and new config are different"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Old config and new config are different"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_ENGINE_SETTING)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_ENGINE_SETTING)) { @@ -806,7 +805,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang key_new = xmlNodeGetContent(cur_new); if (NULL != key_new) { if (0 != xmlStrcmp(key_old, key_new)) { - SLOG(LOG_DEBUG, stt_tag(), "Old engine setting(%s), New engine setting(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Old engine setting(%s), New engine setting(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE if (NULL != *setting) free(*setting); *setting = strdup((char*)key_new); } @@ -815,7 +814,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang xmlFree(key_old); } } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Old config and new config are different"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Old config and new config are different"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_AUTO_LANGUAGE)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_AUTO_LANGUAGE)) { @@ -824,7 +823,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang key_new = xmlNodeGetContent(cur_new); if (NULL != key_new) { if (0 != xmlStrcmp(key_old, key_new)) { - SLOG(LOG_DEBUG, stt_tag(), "Old auto lang(%s), New auto lang(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Old auto lang(%s), New auto lang(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE if (0 == xmlStrcmp((const xmlChar*)"on", key_new)) { *auto_lang = (int)true; } else { @@ -837,7 +836,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang xmlFree(key_old); } } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] old config and new config are different"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] old config and new config are different"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_LANGUAGE)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_LANGUAGE)) { @@ -846,7 +845,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang key_new = xmlNodeGetContent(cur_new); if (NULL != key_new) { if (0 != xmlStrcmp(key_old, key_new)) { - SLOG(LOG_DEBUG, stt_tag(), "Old language(%s), New language(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Old language(%s), New language(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE if (NULL != *language) free(*language); *language = strdup((char*)key_new); } @@ -855,7 +854,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang xmlFree(key_old); } } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] old config and new config are different"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] old config and new config are different"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_SILENCE_DETECTION)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_SILENCE_DETECTION)) { @@ -864,7 +863,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang key_new = xmlNodeGetContent(cur_new); if (NULL != key_new) { if (0 != xmlStrcmp(key_old, key_new)) { - SLOG(LOG_DEBUG, stt_tag(), "Old silence(%s), New silence(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Old silence(%s), New silence(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE if (0 == xmlStrcmp(key_new, (const xmlChar*)"on")) { *silence = 1; } else { @@ -877,7 +876,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang xmlFree(key_old); } } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] old config and new config are different"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] old config and new config are different"); //LCOV_EXCL_LINE } } else if (0 == xmlStrcmp(cur_new->name, (const xmlChar*)STT_TAG_CONFIG_CREDENTIAL)) { if (0 == xmlStrcmp(cur_old->name, (const xmlChar*)STT_TAG_CONFIG_CREDENTIAL)) { @@ -886,7 +885,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang key_new = xmlNodeGetContent(cur_new); if (NULL != key_new) { if (0 != xmlStrcmp(key_old, key_new)) { - SLOG(LOG_DEBUG, stt_tag(), "Old credential(%s), New credential(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Old credential(%s), New credential(%s)", (char*)key_old, (char*)key_new); //LCOV_EXCL_LINE if (0 == xmlStrcmp(key_new, (const xmlChar*)"true")) { *credential = 1; } else { @@ -898,7 +897,7 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang xmlFree(key_old); } } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] old config and new config are different"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] old config and new config are different"); //LCOV_EXCL_LINE } } else { @@ -922,12 +921,12 @@ int stt_parser_find_config_changed(char** engine, char** setting, int* auto_lang int stt_parser_set_time_info(GSList* time_list) { if (0 == g_slist_length(time_list)) { - SLOG(LOG_WARN, stt_tag(), "[WARNING] There is no time info to save"); + SLOG(LOG_WARN, TAG_STTCONFIG, "[WARNING] There is no time info to save"); return -1; } if (-1 == remove(STT_TIME_INFO_PATH)) { - SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH); + SLOG(LOG_WARN, TAG_STTCONFIG, "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH); } xmlDocPtr doc = NULL; @@ -935,7 +934,7 @@ int stt_parser_set_time_info(GSList* time_list) doc = xmlNewDoc((const xmlChar*)"1.0"); if (doc == NULL) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make new doc"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Fail to make new doc"); return -1; } @@ -959,13 +958,13 @@ int stt_parser_set_time_info(GSList* time_list) data = iter->data; if (NULL == data) { - SLOG(LOG_DEBUG, stt_tag(), "data is NULL"); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "data is NULL"); continue; } xmlNodePtr temp_node = NULL; - SECURE_SLOG(LOG_DEBUG, stt_tag(), "[%d] i(%d) t(%s) s(%ld) e(%ld)", + SECURE_SLOG(LOG_DEBUG, TAG_STTCONFIG, "[%d] i(%d) t(%s) s(%ld) e(%ld)", data->index, data->event, data->text, data->start_time, data->end_time); temp_node = xmlNewNode(NULL, (const xmlChar*)STT_TAG_TIME_TEXT); @@ -987,7 +986,7 @@ int stt_parser_set_time_info(GSList* time_list) } int ret = xmlSaveFormatFile(STT_TIME_INFO_PATH, doc, 1); - SLOG(LOG_DEBUG, stt_tag(), "Save result : %d", ret); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Save result : %d", ret); xmlFreeDoc(doc); return 0; @@ -1011,7 +1010,7 @@ void __stt_parser_time_info_free(void* data) int stt_parser_get_time_info(GSList** time_list) { if (NULL == time_list) { - SLOG(LOG_ERROR, stt_tag(), "Invalid parameter : text is NULL"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "Invalid parameter : text is NULL"); //LCOV_EXCL_LINE return -1; } @@ -1020,14 +1019,14 @@ int stt_parser_get_time_info(GSList** time_list) doc = xmlParseFile(STT_TIME_INFO_PATH); if (doc == NULL) { - SLOG(LOG_WARN, stt_tag(), "[WARNING] File is not exist"); //LCOV_EXCL_LINE + SLOG(LOG_WARN, TAG_STTCONFIG, "[WARNING] File is not exist"); //LCOV_EXCL_LINE return -1; } cur = xmlDocGetRootElement(doc); if (cur == NULL) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -1035,7 +1034,7 @@ int stt_parser_get_time_info(GSList** time_list) if (xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_TIME_BASE_TAG)) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] The wrong type, root node is NOT '%s'", STT_TAG_TIME_BASE_TAG); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] The wrong type, root node is NOT '%s'", STT_TAG_TIME_BASE_TAG); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -1044,7 +1043,7 @@ int stt_parser_get_time_info(GSList** time_list) cur = cur->xmlChildrenNode; if (cur == NULL) { //LCOV_EXCL_START - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Empty document"); + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Empty document"); xmlFreeDoc(doc); return -1; //LCOV_EXCL_STOP @@ -1059,7 +1058,7 @@ int stt_parser_get_time_info(GSList** time_list) if (0 == xmlStrcmp(cur->name, (const xmlChar *)STT_TAG_TIME_INDEX)) { key = xmlGetProp(cur, (const xmlChar*)STT_TAG_TIME_COUNT); if (NULL == key) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_COUNT); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_TIME_COUNT); //LCOV_EXCL_LINE if (NULL != temp_time_list) { g_slist_free_full(temp_time_list, __stt_parser_time_info_free); @@ -1069,7 +1068,7 @@ int stt_parser_get_time_info(GSList** time_list) return -1; } - SLOG(LOG_DEBUG, stt_tag(), "Count : %s", (char *)key); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Count : %s", (char *)key); /* Get time count */ int count = 0; @@ -1077,7 +1076,7 @@ int stt_parser_get_time_info(GSList** time_list) xmlFree(key); if (count <= 0) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] count is invalid : %d", count); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] count is invalid : %d", count); //LCOV_EXCL_LINE break; } @@ -1093,7 +1092,7 @@ int stt_parser_get_time_info(GSList** time_list) temp_info = (stt_result_time_info_s*)calloc(1, sizeof(stt_result_time_info_s)); if (NULL == temp_info) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Memory alloc error!!"); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] Memory alloc error!!"); //LCOV_EXCL_LINE if (NULL != temp_time_list) { g_slist_free_full(temp_time_list, __stt_parser_time_info_free); @@ -1104,7 +1103,7 @@ int stt_parser_get_time_info(GSList** time_list) } temp_info->index = index; - SLOG(LOG_DEBUG, stt_tag(), "index : %d", temp_info->index); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "index : %d", temp_info->index); if (0 == i) temp_info->event = 0; else if (count -1 == i) temp_info->event = 2; @@ -1113,11 +1112,11 @@ int stt_parser_get_time_info(GSList** time_list) if (0 == xmlStrcmp(time_node->name, (const xmlChar *)STT_TAG_TIME_TEXT)) { key = xmlNodeGetContent(time_node); if (NULL != key) { - SLOG(LOG_DEBUG, stt_tag(), "text : %s", (char *)key); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "text : %s", (char *)key); //LCOV_EXCL_LINE temp_info->text = strdup((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_TEXT); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_TIME_TEXT); //LCOV_EXCL_LINE free(temp_info); break; } @@ -1130,11 +1129,11 @@ int stt_parser_get_time_info(GSList** time_list) if (0 == xmlStrcmp(time_node->name, (const xmlChar *)STT_TAG_TIME_START)) { key = xmlNodeGetContent(time_node); if (NULL != key) { - SLOG(LOG_DEBUG, stt_tag(), "Start time : %s", (char *)key); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "Start time : %s", (char *)key); //LCOV_EXCL_LINE temp_info->start_time = atoi((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_START); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_TIME_START); //LCOV_EXCL_LINE if (NULL != temp_info->text) free(temp_info->text); free(temp_info); break; @@ -1148,11 +1147,11 @@ int stt_parser_get_time_info(GSList** time_list) if (0 == xmlStrcmp(time_node->name, (const xmlChar *)STT_TAG_TIME_END)) { key = xmlNodeGetContent(time_node); if (NULL != key) { - SLOG(LOG_DEBUG, stt_tag(), "End time : %s", (char *)key); //LCOV_EXCL_LINE + SLOG(LOG_DEBUG, TAG_STTCONFIG, "End time : %s", (char *)key); //LCOV_EXCL_LINE temp_info->end_time = atoi((char*)key); xmlFree(key); } else { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] <%s> has no content", STT_TAG_TIME_END); //LCOV_EXCL_LINE + SLOG(LOG_ERROR, TAG_STTCONFIG, "[ERROR] <%s> has no content", STT_TAG_TIME_END); //LCOV_EXCL_LINE if (NULL != temp_info->text) free(temp_info->text); free(temp_info); break; @@ -1178,7 +1177,7 @@ int stt_parser_get_time_info(GSList** time_list) int stt_parser_clear_time_info() { if (-1 == remove(STT_TIME_INFO_PATH)) { - /* SLOG(LOG_WARN, stt_tag(), "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH); */ + /* SLOG(LOG_WARN, TAG_STTCONFIG, "[PLAYER WARNING] Fail to remove file(%s)", STT_TIME_INFO_PATH); */ } return 0; diff --git a/common/stt_defs.h b/common/stt_defs.h index b94e4e5..44c276b 100644 --- a/common/stt_defs.h +++ b/common/stt_defs.h @@ -106,6 +106,12 @@ extern "C" { #define STT_PRIVILEGE_RECORDER "http://tizen.org/privilege/recorder" #define STT_PRIVILEGE_APPLAUNCH "http://tizen.org/privilege/appmanager.launch" +/****************************************************************************************** +* Defines for log tag +*******************************************************************************************/ +#define TAG_STTE "stte" +#define TAG_STTCONFIG "sttconfig" + #ifdef __cplusplus } #endif diff --git a/common/stt_engine.c b/common/stt_engine.c index 6a7434f..014863f 100644 --- a/common/stt_engine.c +++ b/common/stt_engine.c @@ -20,24 +20,22 @@ #include "stt_engine.h" #include "sttd_engine_agent.h" +#include "stt_defs.h" -/* -* Internal data structure -*/ +/** Internal data structure **/ typedef struct { char* engine_path; stte_request_callback_s *callback; } sttengine_s; -extern const char* stt_tag(); -/** stt engine */ +/** Static variables **/ +/* Stt engine */ static sttengine_s *g_engine = NULL; - static bool g_is_from_lib = false; -/** callback functions */ +/* Callback functions */ static stt_engine_result_cb g_result_cb = NULL; static stte_private_data_set_cb g_set_private_data_cb = NULL; static stte_private_data_requested_cb g_get_private_data_cb = NULL; @@ -45,6 +43,7 @@ static stte_audio_type_cb g_set_audio_type_cb = NULL; static void* g_set_audio_type_user_data = NULL; +/** Static function **/ static int __stt_set_engine_from(bool is_from_lib) { g_is_from_lib = is_from_lib; @@ -76,21 +75,23 @@ static const char* __stt_get_engine_error_code(stte_error_e err) } } + +/** Public function **/ /* Register engine id */ int stt_engine_load(const char* filepath, stte_request_callback_s *callback) { if (NULL == callback || NULL == filepath) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } /* allocation memory */ if (NULL != g_engine) { - SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine is already loaded"); + SLOG(LOG_WARN, TAG_STTE, "[Engine WARNING] engine is already loaded"); } else { g_engine = (sttengine_s*)calloc(1, sizeof(sttengine_s)); if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to allocate memory"); + SLOG(LOG_ERROR, TAG_STTE, "[ERROR] Fail to allocate memory"); return STTE_ERROR_OUT_OF_MEMORY; } @@ -99,7 +100,7 @@ int stt_engine_load(const char* filepath, stte_request_callback_s *callback) g_engine->engine_path = strdup(filepath); } - SLOG(LOG_DEBUG, stt_tag(), "[Engine Success] Load engine : version(%d)", g_engine->callback->version); + SLOG(LOG_DEBUG, TAG_STTE, "[Engine Success] Load engine : version(%d)", g_engine->callback->version); return 0; } @@ -108,7 +109,7 @@ int stt_engine_load(const char* filepath, stte_request_callback_s *callback) int stt_engine_unload() { if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } @@ -130,32 +131,32 @@ int stt_engine_unload() int stt_engine_initialize(bool is_from_lib) { if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->initialize) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } int ret; ret = __stt_set_engine_from(is_from_lib); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set engine : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to set engine : %s", __stt_get_engine_error_code(ret)); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to initialize"); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to initialize"); ret = g_engine->callback->initialize(); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to initialize : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to initialize : %s", __stt_get_engine_error_code(ret)); } return ret; @@ -164,26 +165,26 @@ int stt_engine_initialize(bool is_from_lib) int stt_engine_deinitialize() { if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->deinitialize) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to deinitialize"); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to deinitialize"); int ret; ret = g_engine->callback->deinitialize(); if (0 != ret) { - SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Fail to deinitialize : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_WARN, TAG_STTE, "[Engine WARNING] Fail to deinitialize : %s", __stt_get_engine_error_code(ret)); } return ret; @@ -194,7 +195,7 @@ static bool __supported_language_cb(const char* language, void* user_data) GSList** lang_list = (GSList**)user_data; if (NULL == language || NULL == lang_list) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Input parameter is NULL in callback!!!!"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Input parameter is NULL in callback!!!!"); return false; } @@ -209,29 +210,29 @@ static bool __supported_language_cb(const char* language, void* user_data) int stt_engine_get_supported_langs(GSList** lang_list) { if (NULL == lang_list) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->foreach_langs) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } int ret; ret = g_engine->callback->foreach_langs(__supported_language_cb, (void*)lang_list); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] get language list error : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] get language list error : %s", __stt_get_engine_error_code(ret)); } return ret; @@ -240,29 +241,29 @@ int stt_engine_get_supported_langs(GSList** lang_list) int stt_engine_is_valid_language(const char* language, bool *is_valid) { if (NULL == language || NULL == is_valid) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->is_valid_lang) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } int ret = STTE_ERROR_NONE; ret = g_engine->callback->is_valid_lang(language, is_valid); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to check valid language(%d)", ret); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to check valid language(%d)", ret); } return ret; } @@ -270,7 +271,7 @@ int stt_engine_is_valid_language(const char* language, bool *is_valid) int stt_engine_set_private_data(const char* key, const char* data) { if (NULL == key || NULL == data) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } @@ -278,7 +279,7 @@ int stt_engine_set_private_data(const char* key, const char* data) if (NULL != g_set_private_data_cb) { ret = g_set_private_data_cb(key, data); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set private data(%d)", ret); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to set private data(%d)", ret); } } @@ -288,7 +289,7 @@ int stt_engine_set_private_data(const char* key, const char* data) int stt_engine_get_private_data(const char* key, char** data) { if (NULL == key || NULL == data) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } @@ -297,11 +298,11 @@ int stt_engine_get_private_data(const char* key, char** data) if (NULL != g_get_private_data_cb) { ret = g_get_private_data_cb(key, &temp); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get private data(%d)", ret); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to get private data(%d)", ret); return ret; } } else { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] There's no private data function)"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] There's no private data function)"); } if (NULL == temp) @@ -315,22 +316,22 @@ int stt_engine_get_private_data(const char* key, char** data) int stt_engine_get_first_language(char** language) { if (NULL == language) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->foreach_langs || NULL == g_engine->callback->is_valid_lang) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } @@ -338,7 +339,7 @@ int stt_engine_get_first_language(char** language) int ret; ret = g_engine->callback->foreach_langs(__supported_language_cb, &lang_list); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] get language list error : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] get language list error : %s", __stt_get_engine_error_code(ret)); return ret; } @@ -383,24 +384,24 @@ int stt_engine_get_first_language(char** language) int stt_engine_support_silence(bool* support) { if (NULL == support) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to support silence"); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to support silence"); if (NULL == g_engine->callback->support_silence) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } @@ -414,24 +415,24 @@ int stt_engine_support_silence(bool* support) int stt_engine_need_app_credential(bool* need) { if (NULL == need) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to need app credential"); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to need app credential"); if (NULL == g_engine->callback->need_app_credential) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } @@ -445,31 +446,31 @@ int stt_engine_need_app_credential(bool* need) int stt_engine_support_recognition_type(const char* type, bool* support) { if (NULL == type || NULL == support) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->support_recognition_type) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR} Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR} Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to support recognition type, type(%s)", type); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to support recognition type, type(%s)", type); int ret = STTE_ERROR_NONE; ret = g_engine->callback->support_recognition_type(type, support); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get supporting recognition type(%d)", ret); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to get supporting recognition type(%d)", ret); } return ret; } @@ -477,31 +478,31 @@ int stt_engine_support_recognition_type(const char* type, bool* support) int stt_engine_get_audio_format(stte_audio_type_e* types, int* rate, int* channels) { if (NULL == types || NULL == rate || NULL == channels) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->get_audio_format) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to get audio format"); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to get audio format"); int ret; ret = g_engine->callback->get_audio_format(types, rate, channels); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get audio format : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to get audio format : %s", __stt_get_engine_error_code(ret)); } return ret; @@ -511,27 +512,27 @@ int stt_engine_get_audio_format(stte_audio_type_e* types, int* rate, int* channe int stt_engine_set_silence_detection(bool value) { if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->set_silence_detection) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to set silence detection(%d)", value); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to set silence detection(%d)", value); int ret = g_engine->callback->set_silence_detection(value); if (STTE_ERROR_NOT_SUPPORTED_FEATURE == ret) { - SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Not support silence detection"); + SLOG(LOG_WARN, TAG_STTE, "[Engine WARNING] Not support silence detection"); } else if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set silence detection : %d", ret); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to set silence detection : %d", ret); } return ret; } @@ -539,31 +540,31 @@ int stt_engine_set_silence_detection(bool value) int stt_engine_check_app_agreed(const char* appid, bool* is_agreed) { if (NULL == is_agreed) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->check_app_agreed) { - SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Not support app agreement. All app is available"); + SLOG(LOG_WARN, TAG_STTE, "[Engine WARNING] Not support app agreement. All app is available"); *is_agreed = true; return 0; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to app agreed, appid(%s), is_agreed(%d)", appid, *is_agreed); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to app agreed, appid(%s), is_agreed(%d)", appid, *is_agreed); int ret = g_engine->callback->check_app_agreed(appid, is_agreed); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to get app agreement : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to get app agreement : %s", __stt_get_engine_error_code(ret)); *is_agreed = false; } @@ -574,32 +575,32 @@ int stt_engine_check_app_agreed(const char* appid, bool* is_agreed) int stt_engine_recognize_start(const char* lang, const char* recognition_type, const char* appid, const char* credential, void* user_param) { if (NULL == lang || NULL == recognition_type) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->start) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to start, lang(%s), recognition_type(%s), credential(%s)", lang, recognition_type, credential); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to start, lang(%s), recognition_type(%s), credential(%s)", lang, recognition_type, credential); int ret = g_engine->callback->start(lang, recognition_type, appid, credential, user_param); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start recognition : %s", __stt_get_engine_error_code(ret)); - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start recognition : lang(%s), recognition_type(%s), credential(%s)", lang, recognition_type, credential); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to start recognition : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to start recognition : lang(%s), recognition_type(%s), credential(%s)", lang, recognition_type, credential); } return ret; @@ -608,28 +609,28 @@ int stt_engine_recognize_start(const char* lang, const char* recognition_type, c int stt_engine_set_recording_data(const void* data, unsigned int length) { if (NULL == data) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->set_recording) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } int ret = g_engine->callback->set_recording(data, length); if (0 != ret) { - SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] Fail to set recording : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_WARN, TAG_STTE, "[Engine WARNING] Fail to set recording : %s", __stt_get_engine_error_code(ret)); } return ret; @@ -638,25 +639,25 @@ int stt_engine_set_recording_data(const void* data, unsigned int length) int stt_engine_recognize_stop() { if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->stop) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to stop"); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to stop"); int ret = g_engine->callback->stop(); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to stop : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to stop : %s", __stt_get_engine_error_code(ret)); } return ret; @@ -665,25 +666,25 @@ int stt_engine_recognize_stop() int stt_engine_recognize_cancel() { if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->cancel) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] request to cancel"); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] request to cancel"); int ret = g_engine->callback->cancel(); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to cancel : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to cancel : %s", __stt_get_engine_error_code(ret)); } return ret; @@ -692,55 +693,55 @@ int stt_engine_recognize_cancel() int stt_engine_foreach_result_time(void* time_info, stte_result_time_cb callback, void* user_data) { if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback->foreach_result_time) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } int ret = g_engine->callback->foreach_result_time(time_info, callback, user_data); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to foreach result time : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to foreach result time : %s", __stt_get_engine_error_code(ret)); } return ret; } -int stt_engine_recognize_start_file(const char* lang, const char* recognition_type, +int stt_engine_recognize_start_file(const char* lang, const char* recognition_type, const char* filepath, stte_audio_type_e audio_type, int sample_rate, void* user_param) { if (NULL == filepath || NULL == lang || NULL == recognition_type) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid Parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid Parameter"); return STTE_ERROR_INVALID_PARAMETER; } if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } #ifdef __UNUSED_CODES__ if (NULL == g_engine->callback->start_file) { - SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine API is invalid"); + SLOG(LOG_WARN, TAG_STTE, "[Engine WARNING] engine API is invalid"); return STTE_ERROR_NOT_SUPPORTED_FEATURE; } int ret = g_engine->callback->start_file(lang, recognition_type, filepath, audio_type, sample_rate, user_param); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start file recognition : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to start file recognition : %s", __stt_get_engine_error_code(ret)); } #endif return 0; @@ -749,24 +750,24 @@ int stt_engine_recognize_start_file(const char* lang, const char* recognition_ty int stt_engine_recognize_cancel_file() { if (NULL == g_engine) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] No engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] No engine"); return STTE_ERROR_OPERATION_FAILED; } if (NULL == g_engine->callback) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid engine"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid engine"); return STTE_ERROR_OPERATION_FAILED; } #ifdef __UNUSED_CODES__ if (NULL == g_engine->callback->cancel_file) { - SLOG(LOG_WARN, stt_tag(), "[Engine WARNING] engine API is invalid"); + SLOG(LOG_WARN, TAG_STTE, "[Engine WARNING] engine API is invalid"); return STTE_ERROR_NOT_SUPPORTED_FEATURE; } int ret = g_engine->callback->cancel_file(); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to start file recognition : %s", __stt_get_engine_error_code(ret)); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to start file recognition : %s", __stt_get_engine_error_code(ret)); } #endif return 0; @@ -775,7 +776,7 @@ int stt_engine_recognize_cancel_file() int stt_engine_set_recognition_result_cb(stt_engine_result_cb result_cb, void* user_data) { if (NULL == result_cb) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid parameter"); return STTE_ERROR_INVALID_PARAMETER; } @@ -788,14 +789,14 @@ int stt_engine_send_result(stte_result_event_e event, const char* type, const ch const char* msg, void* time_info, void* user_data) { if (NULL == type || NULL == result) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid parameter"); } int ret = STTE_ERROR_NONE; if (false == __stt_get_engine_from()) { ret = sttd_engine_agent_send_result(event, type, result, result_count, msg, time_info, user_data); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to send result"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to send result"); } } else { ret = g_result_cb(event, type, result, result_count, msg, time_info, user_data); @@ -808,7 +809,7 @@ int stt_engine_send_error(stte_error_e error, const char* msg) int ret = STTE_ERROR_NONE; ret = sttd_engine_agent_send_error(error, msg); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to send error info"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to send error info"); } return ret; } @@ -818,7 +819,7 @@ int stt_engine_send_speech_status(stte_speech_status_e status, void* user_data) int ret = STTE_ERROR_NONE; ret = sttd_engine_agent_send_speech_status(status, user_data); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to send speech status"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to send speech status"); } return ret; } @@ -826,7 +827,7 @@ int stt_engine_send_speech_status(stte_speech_status_e status, void* user_data) int stt_engine_set_private_data_set_cb(stte_private_data_set_cb private_data_set_cb, void* user_data) { if (NULL == private_data_set_cb) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid parameter"); return STTE_ERROR_INVALID_PARAMETER; } @@ -838,7 +839,7 @@ int stt_engine_set_private_data_set_cb(stte_private_data_set_cb private_data_set int stt_engine_set_private_data_requested_cb(stte_private_data_requested_cb private_data_requested_cb, void* user_data) { if (NULL == private_data_requested_cb) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid parameter"); return STTE_ERROR_INVALID_PARAMETER; } @@ -850,20 +851,20 @@ int stt_engine_set_private_data_requested_cb(stte_private_data_requested_cb priv int stt_engine_set_audio_type(const char* audio_type) { if (NULL == audio_type) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid parameter"); return STTE_ERROR_INVALID_PARAMETER; } - SLOG(LOG_INFO, stt_tag(), "[Engine Info] set audio type (%s)", audio_type); + SLOG(LOG_INFO, TAG_STTE, "[Engine Info] set audio type (%s)", audio_type); int ret = STTE_ERROR_NONE; if (NULL != g_set_audio_type_cb) { ret = g_set_audio_type_cb(audio_type, g_set_audio_type_user_data); if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Fail to set audio type, ret(%d)", ret); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Fail to set audio type, ret(%d)", ret); } } else { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] There's no set audio function)"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] There's no set audio function)"); } return ret; @@ -872,7 +873,7 @@ int stt_engine_set_audio_type(const char* audio_type) int stt_engine_set_audio_type_set_cb(stte_audio_type_cb audio_type_set_cb, void* user_data) { if (NULL == audio_type_set_cb) { - SLOG(LOG_ERROR, stt_tag(), "[Engine ERROR] Invalid parameter"); + SLOG(LOG_ERROR, TAG_STTE, "[Engine ERROR] Invalid parameter"); return STTE_ERROR_INVALID_PARAMETER; } diff --git a/common/stt_network.c b/common/stt_network.c index e8e6535..fcd979d 100644 --- a/common/stt_network.c +++ b/common/stt_network.c @@ -16,8 +16,8 @@ #include #include "stt_network.h" +#include "stt_defs.h" -extern const char* stt_tag(); int stt_network_initialize() { @@ -35,16 +35,16 @@ bool stt_network_is_connected() int network_status = 0; int ret = vconf_get_int(VCONFKEY_NETWORK_STATUS, &network_status); if (0 != ret) { - SLOG(LOG_WARN, stt_tag(), "[Network] Fail to get network status, ret(%d)", ret); + SLOG(LOG_WARN, TAG_STTCONFIG, "[Network] Fail to get network status, ret(%d)", ret); return false; } if (network_status == VCONFKEY_NETWORK_OFF) { - SLOG(LOG_WARN, stt_tag(), "[Network] Current network connection is OFF."); + SLOG(LOG_WARN, TAG_STTCONFIG, "[Network] Current network connection is OFF."); return false; } - SLOG(LOG_DEBUG, stt_tag(), "[Network] Network status is %d", network_status); + SLOG(LOG_DEBUG, TAG_STTCONFIG, "[Network] Network status is %d", network_status); return true; }