Fix to get the maximum text size from the engine meta data
[platform/core/uifw/tts.git] / common / tts_config_mgr.c
index 8ad002b..fd09c2d 100644 (file)
@@ -1044,6 +1044,12 @@ int tts_config_mgr_initialize(int uid)
                        return TTS_CONFIG_ERROR_OUT_OF_MEMORY;
                }
                temp_client->uid = uid;
+               temp_client->engine_cb = NULL;
+               temp_client->voice_cb = NULL;
+               temp_client->speech_cb = NULL;
+               temp_client->pitch_cb = NULL;
+               temp_client->screen_cb = NULL;
+               temp_client->user_data = NULL;
 
                g_config_client_list = g_slist_append(g_config_client_list, temp_client);
 
@@ -1056,6 +1062,12 @@ int tts_config_mgr_initialize(int uid)
                        return TTS_CONFIG_ERROR_OUT_OF_MEMORY;
                }
                temp_client->uid = uid;
+               temp_client->engine_cb = NULL;
+               temp_client->voice_cb = NULL;
+               temp_client->speech_cb = NULL;
+               temp_client->pitch_cb = NULL;
+               temp_client->screen_cb = NULL;
+               temp_client->user_data = NULL;
 
                g_config_client_list = g_slist_append(g_config_client_list, temp_client);
        }
@@ -2029,3 +2041,48 @@ int __tts_config_mgr_print_engine_info()
 
        return 0;
 }
+
+int tts_config_mgr_get_max_text_size(unsigned int* size)
+{
+       if (0 >= g_slist_length(g_config_client_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "Not initialized");
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == size) {
+               return TTS_CONFIG_ERROR_INVALID_PARAMETER;
+       }
+
+       GSList *iter = NULL;
+       tts_engine_info_s *engine_info = NULL;
+
+       if (0 >= g_slist_length(g_engine_list)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] There is no engine!!");
+               return TTS_CONFIG_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       /* Get a first item */
+       iter = g_slist_nth(g_engine_list, 0);
+
+       while (NULL != iter) {
+               engine_info = iter->data;
+
+               if (NULL == engine_info) {
+                       SLOG(LOG_ERROR, tts_tag(), "engine info is NULL");
+                       return TTS_CONFIG_ERROR_OPERATION_FAILED;
+               }
+
+               if (0 != strcmp(g_config_info->engine_id, engine_info->uuid)) {
+                       iter = g_slist_next(iter);
+                       continue;
+               }
+
+               break;
+       }
+
+       *size = engine_info->text_size;
+       SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Max text size is %d.", *size);
+
+       return 0;
+}
+