SLOG(LOG_DEBUG, TAG_TTSC, "Rejected from server");
}
-int tts_tidl_open_connection(int uid)
+static void __get_engine_app_id(int mode, int size, char* app_id)
{
- SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_open_connection");
+ if (NULL == app_id) {
+ SLOG(LOG_ERROR, TAG_TTSC, "app_id is NULL");
+ return;
+ }
+
+ char* engine_name = vconf_get_str(TTS_ENGINE_DB_DEFAULT);
+ if (NULL == engine_name) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get engine name");
+ engine_name = strdup(TTS_SERVER_ENGINE_DEFAULT);
+ }
- char engine_mode[256] = {0, };
- char* engine_name = NULL;
+ char* mode_str = "";
+ if (TTS_MODE_NOTIFICATION == mode) {
+ mode_str = TTS_NOTI_SERVER_MODE;
+ } else if (TTS_MODE_SCREEN_READER == mode) {
+ mode_str = TTS_SR_SERVER_MODE;
+ } else if (TTS_MODE_INTERRUPT == mode) {
+ mode_str = TTS_INTERRUPT_SERVER_MODE;
+ }
+
+ snprintf(app_id, size, "%s%s", engine_name, mode_str);
+ free(engine_name);
+
+ SLOG(LOG_INFO, TAG_TTSC, "engine app id : %s", app_id);
+}
+
+static rpc_port_proxy_tts_h __open_rpc_port(int uid, int mode)
+{
+ char engine_app_id[256] = {0, };
+ __get_engine_app_id(mode, 256, engine_app_id);
rpc_port_proxy_tts_callback_s rpc_callback = {
.connected = __on_connected,
.rejected = __on_rejected
};
+ rpc_port_proxy_tts_h handle = NULL;
+ intptr_t ptr_uid = uid;
+ if (0 != rpc_port_proxy_tts_create(engine_app_id, &rpc_callback, (void*)ptr_uid, &handle)) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create proxy");
+ return NULL;
+ }
+
+ if (0 != rpc_port_proxy_tts_connect(handle)) {
+ rpc_port_proxy_tts_destroy(handle);
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connect the service");
+ return NULL;
+ }
+
+ return handle;
+}
+
+int tts_tidl_open_connection(int uid)
+{
+ SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_open_connection");
+
tts_client_s* client = tts_client_get_by_uid(uid);
if (NULL == client) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get client");
return TTS_ERROR_OUT_OF_MEMORY;
}
- engine_name = vconf_get_str(TTS_ENGINE_DB_DEFAULT);
- if (NULL == engine_name) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to get engine name");
- engine_name = strdup(TTS_SERVER_ENGINE_DEFAULT);
- }
-
- if (TTS_ERROR_SERVICE_RESET != client->reason) {
- tts_mode_e mode = tts_client_get_mode(client);
- if (TTS_MODE_DEFAULT == mode) {
- strcat(engine_mode, engine_name);
- } else if (TTS_MODE_NOTIFICATION == mode) {
- strcat(engine_mode, engine_name);
- strcat(engine_mode, TTS_NOTI_SERVER_MODE);
- } else if (TTS_MODE_SCREEN_READER == mode) {
- strcat(engine_mode, engine_name);
- strcat(engine_mode, TTS_SR_SERVER_MODE);
- } else if (TTS_MODE_INTERRUPT == mode) {
- strcat(engine_mode, engine_name);
- strcat(engine_mode, TTS_INTERRUPT_SERVER_MODE);
- }
- client->reason = 0; // default value
- }
- free(engine_name);
-
- intptr_t ptr_uid = uid;
- if (0 != rpc_port_proxy_tts_create(engine_mode, &rpc_callback, (void*)ptr_uid, &info->rpc_h)) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to create proxy");
+ info->rpc_h = __open_rpc_port(uid, tts_client_get_mode(client));
+ if (NULL == info->rpc_h) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to open proxy");
free(info);
return TTS_ERROR_OPERATION_FAILED;
}
- if (0 != rpc_port_proxy_tts_connect(info->rpc_h)) {
- rpc_port_proxy_tts_destroy(info->rpc_h);
- info->rpc_h = NULL;
- free(info);
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to connect the service");
- return TTS_ERROR_OPERATION_FAILED;
- }
-
info->uid = uid;
g_tidl_infos = g_list_append(g_tidl_infos, info);
- SLOG(LOG_ERROR, TAG_TTSC, "[INFO] uid(%d) rpc_h(%p) engine(%s)", uid, info->rpc_h, engine_mode);
+ SLOG(LOG_ERROR, TAG_TTSC, "[INFO] uid(%d) rpc_h(%p)", uid, info->rpc_h);
SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
return TTS_ERROR_NONE;
}