X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=common%2Fstt_config_mgr.c;h=b2d346bc848dfb06ed1f6991f7b8a2b93834671d;hb=e5c5a41fb4080d3a9ea3bbb92ee0b91312378b4a;hp=045bc86317e3de392dee49e3227e6a144b4346d5;hpb=b6f36bfc2a673deeacc6b3d6527870f02567a7fb;p=platform%2Fcore%2Fuifw%2Fstt.git diff --git a/common/stt_config_mgr.c b/common/stt_config_mgr.c old mode 100644 new mode 100755 index 045bc86..b2d346b --- a/common/stt_config_mgr.c +++ b/common/stt_config_mgr.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved +* Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,6 +19,7 @@ #include #include #include +#include #include "stt_config_mgr.h" #include "stt_defs.h" @@ -90,7 +91,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; - SECURE_SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", i, engine_lang); + SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", i, engine_lang); if (0 == strcmp(language, engine_lang)) { return true; @@ -150,7 +151,7 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language) /* Default language is STT_BASE_LANGUAGE */ if (0 == strcmp(STT_BASE_LANGUAGE, engine_lang)) { *language = strdup(engine_lang); - SECURE_SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language); + SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", (NULL == *language) ? "NULL" : *language); return 0; } } @@ -161,7 +162,7 @@ int __stt_config_mgr_select_lang(const char* engine_id, char** language) /* Not support STT_BASE_LANGUAGE */ if (NULL != engine_lang) { *language = strdup(engine_lang); - SECURE_SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", *language); + SLOG(LOG_DEBUG, stt_tag(), "Selected language : %s", (NULL == *language) ? "NULL" : *language); return 0; } } @@ -193,11 +194,12 @@ Eina_Bool stt_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handl char* lang = NULL; int auto_lang = -1; int silence = -1; + int credential = -1; GSList *iter = NULL; stt_config_client_s* temp_client = NULL; - if (0 != stt_parser_find_config_changed(&engine, &setting, &auto_lang, &lang, &silence)) + if (0 != stt_parser_find_config_changed(&engine, &setting, &auto_lang, &lang, &silence, &credential)) return ECORE_CALLBACK_PASS_ON; /* Engine changed */ @@ -220,6 +222,8 @@ Eina_Bool stt_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handl if (-1 != silence) g_config_info->silence_detection = silence; + if (-1 != credential) g_config_info->credential = credential; + /* Call all callbacks of client*/ iter = g_slist_nth(g_config_client_list, 0); @@ -229,7 +233,7 @@ Eina_Bool stt_config_mgr_inotify_event_cb(void* data, Ecore_Fd_Handler *fd_handl if (NULL != temp_client) { if (NULL != temp_client->engine_cb) { temp_client->engine_cb(g_config_info->engine_id, g_config_info->setting, g_config_info->language, - g_config_info->silence_detection, temp_client->user_data); + g_config_info->silence_detection, g_config_info->credential, temp_client->user_data); } } @@ -353,7 +357,18 @@ int __stt_config_set_auto_language() strncpy(candidate_lang, value, 5); free(value); + /* Check current config info */ + if (NULL == g_config_info) { + SLOG(LOG_ERROR, stt_tag(), "Current config info is NULL"); + 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"); + 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); return 0; @@ -362,12 +377,6 @@ int __stt_config_set_auto_language() } if (true == __stt_config_mgr_check_lang_is_valid(g_config_info->engine_id, candidate_lang)) { - /* stt default language change */ - if (NULL == g_config_info->language) { - SLOG(LOG_ERROR, stt_tag(), "Current config language is NULL"); - return -1; - } - char* before_lang = NULL; if (0 != stt_parser_set_language(candidate_lang)) { SLOG(LOG_ERROR, stt_tag(), "Fail to save default language"); @@ -379,7 +388,7 @@ int __stt_config_set_auto_language() free(g_config_info->language); g_config_info->language = strdup(candidate_lang); - SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto. Set default language(%s)", g_config_info->language); + SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto. Set default language(%s)", g_config_info->language); /* Call all callbacks of client*/ GSList *iter = NULL; @@ -421,7 +430,7 @@ int __stt_config_set_auto_language() return -1; } - SECURE_SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto but display lang is not supported. Default language change(%s)", tmp_language); + SLOG(LOG_DEBUG, stt_tag(), "[Config] Language is auto but display lang is not supported. Default language change(%s)", tmp_language); /* Call all callbacks of client*/ GSList *iter = NULL; @@ -441,12 +450,11 @@ int __stt_config_set_auto_language() iter = g_slist_next(iter); } - if (NULL != g_config_info->language) { - free(g_config_info->language); - g_config_info->language = strdup(tmp_language); - } + free(g_config_info->language); + g_config_info->language = strdup(tmp_language); free(tmp_language); + tmp_language = NULL; } return 0; @@ -490,6 +498,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)); } + return; } void __stt_config_release_engine() @@ -514,6 +523,7 @@ void __stt_config_release_engine() iter = g_slist_nth(g_engine_list, 0); } } + return; } int __stt_config_mgr_check_engine_is_valid(const char* engine_id) @@ -552,6 +562,11 @@ 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"); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } + engine_info = iter->data; if (NULL == engine_info) { SLOG(LOG_ERROR, stt_tag(), "[ERROR] Engine info is NULL"); @@ -628,16 +643,73 @@ int __stt_config_mgr_check_engine_is_valid(const char* 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"); if (0 != stt_parser_set_engine(g_config_info->engine_id, g_config_info->setting, g_config_info->language, - g_config_info->silence_detection)) { - SLOG(LOG_ERROR, stt_tag(), " Fail to save config"); + g_config_info->silence_detection, g_config_info->credential)) { + SLOG(LOG_ERROR, stt_tag(), "Fail to save config"); return STT_CONFIG_ERROR_OPERATION_FAILED; } return STT_CONFIG_ERROR_NONE; } +static void __get_engine_list(const char* directory) +{ + DIR *dp = NULL; + struct dirent *dirp = NULL; + + if (NULL == directory) { + SLOG(LOG_ERROR, stt_tag(), "[Directory ERROR] Directory is NULL"); + return; + } else { + SLOG(LOG_DEBUG, stt_tag(), "[Directory DEBUG] Directory: %s", directory); + } + + dp = opendir(directory); + if (NULL != dp) { + do { + dirp = readdir(dp); + + if (NULL != dirp) { + if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name)) + continue; + + stt_engine_info_s* info; + char* filepath = NULL; + int filesize; + + filesize = strlen(directory) + strlen(dirp->d_name) + 5; + filepath = (char*)calloc(filesize, sizeof(char)); + + if (NULL != filepath) { + snprintf(filepath, filesize, "%s/%s", directory, dirp->d_name); + } else { + SLOG(LOG_ERROR, stt_tag(), "[Config ERROR] Memory not enough!!"); + continue; + } + + SLOG(LOG_DEBUG, stt_tag(), "[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); + } + + if (NULL != filepath) { + free(filepath); + filepath = NULL; + } + } + } while (NULL != dirp); + + closedir(dp); + } else { + SLOG(LOG_WARN, stt_tag(), "[Config WARNING] Fail to open directory"); + } + + return; +} + int stt_config_mgr_initialize(int uid) { GSList *iter = NULL; @@ -652,7 +724,7 @@ int stt_config_mgr_initialize(int uid) get_uid = iter->data; if (uid == *get_uid) { - SECURE_SLOG(LOG_WARN, stt_tag(), "[CONFIG] uid(%d) has already registered", uid); + SLOG(LOG_WARN, stt_tag(), "[CONFIG] uid(%d) has already registered", uid); return 0; } @@ -673,58 +745,61 @@ int stt_config_mgr_initialize(int uid) /* Add uid */ g_config_client_list = g_slist_append(g_config_client_list, temp_client); - SECURE_SLOG(LOG_WARN, stt_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid); + SLOG(LOG_WARN, stt_tag(), "[CONFIG] Add uid(%d) but config has already initialized", uid); return STT_CONFIG_ERROR_NONE; } - /* Get file name from default engine directory */ - DIR *dp = NULL; - int ret = -1; - struct dirent entry; - struct dirent *dirp = NULL; - - g_engine_list = NULL; - - dp = opendir(STT_DEFAULT_ENGINE_INFO); - if (NULL != dp) { - do { - ret = readdir_r(dp, &entry, &dirp); - if (0 != ret) { - SLOG(LOG_ERROR, stt_tag(), "[File ERROR] Fail to read directory"); - break; - } + /* Make directories */ + if (0 != access(STT_CONFIG_BASE, F_OK)) { + if (0 != mkdir(STT_CONFIG_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make directory : %s", STT_CONFIG_BASE); + __stt_config_release_client(uid); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, stt_tag(), "Success to make directory : %s", STT_CONFIG_BASE); + } + } - if (NULL != dirp) { - if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name)) - continue; + if (0 != access(STT_HOME, F_OK)) { + if (0 != mkdir(STT_HOME, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make directory : %s", STT_HOME); + __stt_config_release_client(uid); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, stt_tag(), "Success to make directory : %s", STT_HOME); + } + } - stt_engine_info_s* info; - char* filepath; - int filesize; + if (0 != access(STT_DOWNLOAD_BASE, F_OK)) { + if (0 != mkdir(STT_DOWNLOAD_BASE, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make directory : %s", STT_DOWNLOAD_BASE); + __stt_config_release_client(uid); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, stt_tag(), "Success to make directory : %s", STT_DOWNLOAD_BASE); + } + } - filesize = strlen(STT_DEFAULT_ENGINE_INFO) + strlen(dirp->d_name) + 5; - filepath = (char*)calloc(filesize, sizeof(char)); + if (0 != access(STT_DOWNLOAD_ENGINE_INFO, F_OK)) { + if (0 != mkdir(STT_DOWNLOAD_ENGINE_INFO, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] Fail to make directory : %s", STT_DOWNLOAD_ENGINE_INFO); + __stt_config_release_client(uid); + return STT_CONFIG_ERROR_OPERATION_FAILED; + } else { + SLOG(LOG_DEBUG, stt_tag(), "Success to make directory : %s", STT_DOWNLOAD_ENGINE_INFO); + } + } - if (NULL != filepath) { - snprintf(filepath, filesize, "%s/%s", STT_DEFAULT_ENGINE_INFO, dirp->d_name); - } else { - SLOG(LOG_ERROR, stt_tag(), "[Config ERROR] Memory not enough!!"); - continue; - } - if (0 == stt_parser_get_engine_info(filepath, &info)) { - g_engine_list = g_slist_append(g_engine_list, info); - } + /* Get file name from default engine directory */ + g_engine_list = NULL; - if (NULL != filepath) - free(filepath); - } - } while (NULL != dirp); + SLOG(LOG_WARN, stt_tag(), "[CONFIG] default engine info(%s)", STT_DEFAULT_ENGINE_INFO); - closedir(dp); - } else { - SLOG(LOG_WARN, stt_tag(), "[Config WARNING] Fail to open default directory"); - } + SLOG(LOG_DEBUG, stt_tag(), "[CONFIG] Get default engine list"); + __get_engine_list(STT_DEFAULT_ENGINE_INFO); + SLOG(LOG_DEBUG, stt_tag(), "[CONFIG] Get download engine list"); + __get_engine_list(STT_DOWNLOAD_ENGINE_INFO); __stt_config_mgr_print_engine_info(); @@ -770,13 +845,14 @@ int stt_config_mgr_initialize(int uid) } } - /* print daemon config */ - SLOG(LOG_DEBUG, stt_tag(), "== Daemon config =="); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " engine : %s", g_config_info->engine_id); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", g_config_info->setting); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " auto language : %s", g_config_info->auto_lang ? "on" : "off"); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence detection : %s", g_config_info->silence_detection ? "on" : "off"); + /* 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(), "==================="); if (0 != __stt_config_mgr_register_config_event()) { @@ -983,6 +1059,62 @@ int stt_config_mgr_get_engine(char** engine) return STT_CONFIG_ERROR_NONE; } +int __stt_config_set_buxtonkey(const char* engine) +{ + /* Set vconfkey */ + struct buxton_client * bux_cli; + struct buxton_layer * bux_layer; + struct buxton_value * bux_val; + + 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); + 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"); + 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"); + 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)); + } + + 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); + buxton_value_free(bux_val); + buxton_free_layer(bux_layer); + buxton_close(bux_cli); + + bux_cli = NULL; + bux_layer = NULL; + 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); + + buxton_value_free(bux_val); + buxton_free_layer(bux_layer); + buxton_close(bux_cli); + + bux_cli = NULL; + bux_layer = NULL; + bux_val = NULL; + + return STT_CONFIG_ERROR_NONE; +} + int stt_config_mgr_set_engine(const char* engine) { if (0 >= g_slist_length(g_config_client_list)) { @@ -1003,7 +1135,13 @@ int stt_config_mgr_set_engine(const char* engine) return 0; } - SECURE_SLOG(LOG_DEBUG, stt_tag(), "New engine id : %s", engine); + SLOG(LOG_DEBUG, stt_tag(), "New engine id : %s", engine); + + int ret = __stt_config_set_buxtonkey(engine); + if (0 != ret) { + SLOG(LOG_ERROR, stt_tag(), "[ERROR] set buxtonkey Failed!!!"); + return ret; + } GSList *iter = NULL; stt_engine_info_s *engine_info = NULL; @@ -1027,13 +1165,16 @@ int stt_config_mgr_set_engine(const char* engine) continue; } - if (NULL != g_config_info->engine_id) + if (NULL != g_config_info->engine_id) { free(g_config_info->engine_id); + g_config_info->engine_id = NULL; + } g_config_info->engine_id = strdup(engine); if (NULL != g_config_info->setting) { free(g_config_info->setting); + g_config_info->setting = NULL; } if (NULL != engine_info->setting) { @@ -1054,17 +1195,15 @@ int stt_config_mgr_set_engine(const char* engine) /*Get handle data from list*/ lang = iter_lang->data; - SECURE_SLOG(LOG_DEBUG, stt_tag(), " %s", lang); - if (NULL != lang) { + SLOG(LOG_DEBUG, stt_tag(), " %s", lang); + if (NULL != lang && NULL != g_config_info->language) { if (0 == strcmp(lang, g_config_info->language)) { /* language is valid */ is_valid_lang = true; - if (NULL != g_config_info->language) { - free(g_config_info->language); + free(g_config_info->language); + g_config_info->language = strdup(lang); - g_config_info->language = strdup(lang); - } break; } } @@ -1076,8 +1215,14 @@ int stt_config_mgr_set_engine(const char* engine) if (false == is_valid_lang) { if (NULL != g_config_info->language) { free(g_config_info->language); + g_config_info->language = NULL; iter_lang = g_slist_nth(engine_info->languages, 0); + if (NULL == iter_lang) { + SLOG(LOG_ERROR, stt_tag(), "Fail to get default language"); + break; + } + lang = iter_lang->data; g_config_info->language = strdup(lang); @@ -1090,19 +1235,25 @@ int stt_config_mgr_set_engine(const char* engine) g_config_info->silence_detection = false; } + if (false == engine_info->need_credential) { + if (true == g_config_info->credential) + g_config_info->credential = false; + } + is_valid_engine = true; break; } if (true == is_valid_engine) { SLOG(LOG_DEBUG, stt_tag(), "[Config] Engine changed"); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " Engine : %s", g_config_info->engine_id); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " Setting : %s", g_config_info->setting); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " language : %s", g_config_info->language); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " Silence detection : %s", g_config_info->silence_detection ? "on" : "off"); + 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"); 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->silence_detection, g_config_info->credential)) { SLOG(LOG_ERROR, stt_tag(), " Fail to save config"); return STT_CONFIG_ERROR_OPERATION_FAILED; } @@ -1215,8 +1366,8 @@ int stt_config_mgr_get_language_list(const char* engine_id, stt_config_supported /*Get handle data from list*/ lang = iter_lang->data; - SECURE_SLOG(LOG_DEBUG, stt_tag(), " %s", lang); if (NULL != lang) { + SLOG(LOG_DEBUG, stt_tag(), " %s", lang); if (false == callback(engine_info->uuid, lang, user_data)) break; } @@ -1464,11 +1615,11 @@ int __stt_config_mgr_print_engine_info() while (NULL != iter) { engine_info = iter->data; - SECURE_SLOG(LOG_DEBUG, stt_tag(), "[%dth]", i); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " name : %s", engine_info->name); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " id : %s", engine_info->uuid); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " setting : %s", engine_info->setting); - SECURE_SLOG(LOG_DEBUG, stt_tag(), " agreement : %s", engine_info->agreement); + 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, stt_tag(), " languages"); GSList *iter_lang = NULL; @@ -1482,7 +1633,7 @@ int __stt_config_mgr_print_engine_info() /*Get handle data from list*/ lang = iter_lang->data; - SECURE_SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", j, lang); + SLOG(LOG_DEBUG, stt_tag(), " [%dth] %s", j, lang); /*Get next item*/ iter_lang = g_slist_next(iter_lang); @@ -1491,7 +1642,7 @@ int __stt_config_mgr_print_engine_info() } else { SLOG(LOG_ERROR, stt_tag(), " language is NONE"); } - SECURE_SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", + SLOG(LOG_DEBUG, stt_tag(), " silence support : %s", engine_info->support_silence_detection ? "true" : "false"); iter = g_slist_next(iter); i++; @@ -1521,8 +1672,12 @@ int stt_config_mgr_reset_time_info() g_time_list = g_slist_remove(g_time_list, data); if (NULL != data) { - if (NULL == data->text) free(data->text); + if (NULL != data->text) { + free(data->text); + data->text = NULL; + } free(data); + data = NULL; } /*Get next item*/ @@ -1552,9 +1707,13 @@ int stt_config_mgr_add_time_info(int index, int event, const char* text, long st info->start_time = start_time; info->end_time = end_time; + SLOG(LOG_DEBUG, stt_tag(), "[DEBUG] inside stt_config_mgr_add_time_info: index(%d), text(%s), start time(%d), end_time(%d)", info->index, (NULL == info->text) ? "NULL" : info->text, info->start_time, info->end_time); + /* Add item to global list */ g_time_list = g_slist_append(g_time_list, info); + SLOG(LOG_DEBUG, stt_tag(), "[DEBUG] inside stt_config_mgr_add_time_info: g_time_list length(%d)", g_slist_length(g_time_list)); + return 0; } @@ -1598,8 +1757,12 @@ int stt_config_mgr_foreach_time_info(stt_config_result_time_cb callback, void* u if (NULL != data) { temp_time = g_slist_remove(temp_time, data); - if (NULL == data->text) free(data->text); + if (NULL != data->text) { + free(data->text); + data->text = NULL; + } free(data); + data = NULL; } /*Get next item*/ @@ -1631,4 +1794,4 @@ int stt_config_mgr_remove_time_info_file() stt_parser_clear_time_info(); return STT_CONFIG_ERROR_NONE; -} \ No newline at end of file +}