From: sooyeon.kim Date: Mon, 2 Mar 2020 04:30:44 +0000 (+0900) Subject: Change the step of checking utf8 validation and text size X-Git-Tag: submit/tizen/20200323.110648~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F227806%2F1;p=platform%2Fcore%2Fuifw%2Ftts.git Change the step of checking utf8 validation and text size Change-Id: Idc42686df3e46dc6cea88e0bfbf6c0c2bc29f616 Signed-off-by: sooyeon.kim (cherry picked from commit dfc3cde49f4afb40f26a559573e04b3272057883) --- diff --git a/client/tts.c b/client/tts.c index 1637606..8676a5c 100644 --- a/client/tts.c +++ b/client/tts.c @@ -1260,7 +1260,7 @@ int tts_get_max_text_size(tts_h tts, unsigned int* size) g_max_text_size = (int)*size; - SLOG(LOG_DEBUG, TAG_TTSC, "Get max text count : %d", *size); + SLOG(LOG_INFO, TAG_TTSC, "Get max text size : %d byte", *size); return TTS_ERROR_NONE; } @@ -1390,30 +1390,6 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty return TTS_ERROR_INVALID_STATE; } - if (-1 == g_max_text_size) { - SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] g_max_text_size is %d", g_max_text_size); - if (0 != tts_config_mgr_get_max_text_size((unsigned int*)&g_max_text_size)) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get max text size"); - return TTS_ERROR_INVALID_PARAMETER; - } - } - - if (0 == g_max_text_size) { - if (strlen(text) <= 0) { - SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Max Text Size is %d", g_max_text_size); - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is invalid. (max text size is unlimited.)"); - SLOG(LOG_DEBUG, TAG_TTSC, "@@@"); - return TTS_ERROR_INVALID_PARAMETER; - } - } else { - SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] g_max_text_size is %d", g_max_text_size); - if (g_max_text_size < strlen(text) || strlen(text) <= 0) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is invalid. current text_size(%d)", strlen(text)); - SLOG(LOG_DEBUG, TAG_TTSC, "@@@"); - return TTS_ERROR_INVALID_PARAMETER; - } - } - if (TTS_SPEED_AUTO > speed || TTS_SPEED_MAX < speed) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] speed value(%d) is invalid.", speed); SLOG(LOG_DEBUG, TAG_TTSC, "@@@"); @@ -1447,7 +1423,33 @@ int tts_add_text(tts_h tts, const char* text, const char* language, int voice_ty SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Text is invalid - '%s'", text); return TTS_ERROR_INVALID_PARAMETER; } - SLOG(LOG_DEBUG, TAG_TTSC, "Text is valid - text is '%s'", text); + + /* check text size */ + if (-1 == g_max_text_size) { + SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] g_max_text_size is %d byte", g_max_text_size); + if (0 != tts_config_mgr_get_max_text_size((unsigned int*)&g_max_text_size)) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get max text size"); + return TTS_ERROR_INVALID_PARAMETER; + } + } + + if (0 == g_max_text_size) { + if (strlen(text) <= 0) { + SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] Max Text Size is %d byte", g_max_text_size); + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is invalid. (max text size is unlimited.)"); + SLOG(LOG_DEBUG, TAG_TTSC, "@@@"); + return TTS_ERROR_INVALID_PARAMETER; + } + } else { + SLOG(LOG_DEBUG, TAG_TTSC, "[DEBUG] g_max_text_size is %d byte", g_max_text_size); + if (g_max_text_size < strlen(text) || strlen(text) <= 0) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input text size is invalid. current text_size(%d byte)", strlen(text)); + SLOG(LOG_DEBUG, TAG_TTSC, "@@@"); + return TTS_ERROR_INVALID_PARAMETER; + } + } + + SLOG(LOG_DEBUG, TAG_TTSC, "Text is valid - text(%d byte) is '%s'", strlen(text), text); /* save texts for repetition */ if (NULL != client->text_repeat) {