return TTS_CONFIG_ERROR_NONE;
}
+
+
+int tts_config_mgr_check_duplicate_personal_voice(const char* engine_id, const char* unique_id, bool* matched)
+{
+ SLOG(LOG_DEBUG, TAG_TTSCONFIG, "[DEBUG] engine id = %s", engine_id);
+ if (NULL == engine_id) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] Input Parameter is null");
+ return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+ }
+
+ char filepath[512] = {'\0',};
+ memset(filepath, '\0', 512);
+ snprintf(filepath, 512, "%s/%s-%s", TTS_DOWNLOAD_PERSONAL_INFO, engine_id, "personal.xml");
+
+ tts_personal_info_s* info = NULL;
+ int ret = tts_parser_get_personal_info(filepath, &info);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSCONFIG, "[ERROR] There is no personal info file. It can be first time or fail.");
+ return 0;
+ }
+
+ GSList *iter_personal_voice = NULL;
+ tts_config_personal_s* personal_voice = NULL;
+ *matched = false;
+ if (g_slist_length(info->personal_voices) > 0) {
+ /* Get a first item */
+ iter_personal_voice = g_slist_nth(info->personal_voices, 0);
+
+ int j = 1;
+ while (NULL != iter_personal_voice) {
+ /*Get handle data from list*/
+ personal_voice = iter_personal_voice->data;
+
+ SLOG(LOG_DEBUG, TAG_TTSCONFIG, " [%dth] unique_id(%s)", j, personal_voice->unique_id);
+ if (0 == strncmp(unique_id, personal_voice->unique_id, strlen(unique_id))) {
+ *matched = true;
+ break;
+ }
+
+ /*Get next item*/
+ iter_personal_voice = g_slist_next(iter_personal_voice);
+ j++;
+ }
+ } else {
+ return -1;
+ }
+
+ return 0;
+}
\ No newline at end of file
int tts_config_mgr_update_personal_voice(const char* engine_id, const char* language, const char* unique_id, const char* display_name, const char* device_name);
int tts_config_mgr_get_personal_voice_list(const char* engine_id, tts_config_supported_personal_voice_cb callback, void* user_data);
-
+int tts_config_mgr_check_duplicate_personal_voice(const char* engine_id, const char* unique_id, bool* matched);
#ifdef __cplusplus
}
SLOG(LOG_DEBUG, tts_tag(), "[Server] TTS Current Engine(%s)", current_engine);
int ret = tts_config_mgr_update_personal_voice(current_engine, language, unique_id, display_name, device_name);
+
+ bool matched = false;
+ ret = tts_config_mgr_check_duplicate_personal_voice(current_engine, unique_id, &matched);
if (0 != ret) {
- SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to update personal voice to xml");
+ SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to check duplicate personal voice");
return TTSD_ERROR_OPERATION_FAILED;
}
- return 0;
+ if (!matched) {
+ ret = tts_config_mgr_update_personal_voice(current_engine, language, unique_id, display_name, device_name);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Config ERROR] Fail to update personal voice to xml");
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ return ret;
}
bool __ttsd_config_personal_voices(const char* language, const char* unique_id, const char* display_name, const char* device_name, void* user_data)