* limitations under the License.
*/
+#include <app_manager.h>
#include <dirent.h>
#include <Ecore.h>
#include <iconv.h>
return TTS_ERROR_NONE;
}
+int tts_set_server_tts(tts_h tts, const char* credential)
+{
+ if (0 != __tts_get_feature_enabled()) {
+ return TTS_ERROR_NOT_SUPPORTED;
+ }
+
+ if (NULL == tts || NULL == credential) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ tts_client_s* client = tts_client_get(tts);
+
+ if (NULL == client) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : A handle is not valid");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (TTS_STATE_CREATED != client->current_state && TTS_STATE_READY != client->current_state) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] The current state is invalid (%d).", client->current_state);
+ return TTS_ERROR_INVALID_STATE;
+ }
+
+ if (NULL != client->credential) {
+ free(client->credential);
+ client->credential = NULL;
+ }
+
+ client->credential = strdup(credential);
+ if (NULL == client->credential) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
+ return TTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ client->internal = true;
+
+ char* key = NULL;
+ if (NULL != credential)
+ key = strdup("EnableServerTTS");
+ else
+ key = strdup("DisableServerTTS");
+ if (NULL == key) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to allocate memory");
+ return TTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ int pid = getpid();
+ char* appid = NULL;
+ int ret = app_manager_get_app_id(pid, &appid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get appid, ret(%d), pid(%d), appid(%s)", ret, pid, appid);
+ free(key);
+ key = NULL;
+ return TTS_ERROR_OPERATION_FAILED;
+ }
+
+ ret = tts_set_private_data(tts, key, appid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to set private data, ret(%d), pid(%d), appid(%s)", ret, pid, appid);
+ free(key);
+ key = NULL;
+ return ret;
+ }
+
+ free(appid);
+ appid = NULL;
+ free(key);
+ key = NULL;
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+ SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+ return TTS_ERROR_NONE;
+}
+
static Eina_Bool __tts_connect_daemon(void *data)
{
tts_h tts = (tts_h)data;
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry add text : %s", __tts_get_error_code(ret));
usleep(10000);
count++;
- if (TTS_RETRY_COUNT == count) {
+ if (TTS_RETRY_MIN_COUNT == count) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
break;
}
return TTS_ERROR_INVALID_STATE;
}
+ if (true != client->internal && (0 == strcmp(key, "EnableServerTTS") || 0 == strcmp(key, "DisableServerTTS"))) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] This is not an internal app");
+ return TTS_ERROR_INVALID_PARAMETER;
+ }
+
int ret = -1;
int count = 0;
while (0 != ret) {
}
}
+ if (0 == strncmp(*data, "NULL", strlen(*data))) {
+ free(*data);
+ *data = NULL;
+ }
+
SLOG(LOG_DEBUG, TAG_TTSC, "=====");
SLOG(LOG_DEBUG, TAG_TTSC, "");