From: Suyeon Hwang Date: Thu, 29 Dec 2022 08:01:33 +0000 (+0900) Subject: Add new IPC parameter for sending service state X-Git-Tag: accepted/tizen/unified/20230221.085046~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F12%2F288012%2F1;p=platform%2Fcore%2Fuifw%2Ftts.git Add new IPC parameter for sending service state - Requirement: Client library needs to get current service state when preparing is succeeded. - Contents: This patch changes the IPC interface parameter for service state. The client library needs to service state information for enhancing repreparing logic. Through this patch, client application can receive service state information when preparing is succeeded. Change-Id: I62eeab554074455d09ac1c28b369dde83318f399 Signed-off-by: Suyeon Hwang --- diff --git a/client/tts_core.c b/client/tts_core.c index 3cf8791d..7828d334 100644 --- a/client/tts_core.c +++ b/client/tts_core.c @@ -529,9 +529,10 @@ static int __prepare_sync_cb(tts_client_s* client) // TODO: make function duplicated block /* do request initialize */ bool credential_needed = false; + tts_service_state_e service_state = TTS_SERVICE_STATE_READY; tts_mode_e mode = tts_client_get_mode(client); int registered_callback_mask = tts_client_get_registered_event_mask(client); - int ret = tts_ipc_request_initialize(uid, mode, registered_callback_mask, &credential_needed); + int ret = tts_ipc_request_initialize(uid, mode, registered_callback_mask, &service_state, &credential_needed); if (TTS_ERROR_ENGINE_NOT_FOUND == ret || TTS_ERROR_PERMISSION_DENIED == ret) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to initialize. ret(%d/%s)", ret, get_error_message(ret)); tts_core_notify_error_async(client, ret, -1, NULL); diff --git a/client/tts_dbus.c b/client/tts_dbus.c index 6c3cfcb0..56c1b2e8 100644 --- a/client/tts_dbus.c +++ b/client/tts_dbus.c @@ -112,12 +112,14 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Get Hello"); unsigned int uid; - int ret; - int credential_needed; + int ret = TTS_ERROR_NONE; + int service_state = (int)TTS_SERVICE_STATE_READY; + int credential_needed = 0; dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &ret, + DBUS_TYPE_INT32, &service_state, DBUS_TYPE_INT32, &credential_needed, DBUS_TYPE_INVALID); @@ -524,7 +526,7 @@ int tts_dbus_request_hello_sync(unsigned int uid) return result; } -int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed) +int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed) { DBusMessage* msg; DBusError err; @@ -562,12 +564,14 @@ int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registere dbus_error_free(&err); } - int temp = 0; + int tmp_credential_needed = 0; + int tmp_service_state = -1; if (NULL != result_msg) { dbus_message_get_args(result_msg, &err, - DBUS_TYPE_INT32, &result, - DBUS_TYPE_INT32, &temp, - DBUS_TYPE_INVALID); + DBUS_TYPE_INT32, &result, + DBUS_TYPE_INT32, &tmp_service_state, + DBUS_TYPE_INT32, &tmp_credential_needed, + DBUS_TYPE_INVALID); if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get arguments error (%s)", err.message); @@ -578,8 +582,9 @@ int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registere dbus_message_unref(result_msg); if (0 == result) { - *credential_needed = (bool)temp; - SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : result = %d, credential_needed(%d)", result, *credential_needed); + *service_state = (tts_service_state_e)tmp_service_state; + *credential_needed = (bool)tmp_credential_needed; + SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : result = %d, service_state(%d), credential_needed(%d)", result, tmp_service_state, tmp_credential_needed); /* add a rule for daemon error */ tts_client_s* client = tts_client_get_by_uid(uid); diff --git a/client/tts_dbus.h b/client/tts_dbus.h index a0eaeb70..4ef0ed5f 100644 --- a/client/tts_dbus.h +++ b/client/tts_dbus.h @@ -31,7 +31,7 @@ int tts_dbus_request_hello(unsigned int uid, tts_mode_e mode, int registered_eve int tts_dbus_request_hello_sync(unsigned int uid); -int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed); +int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed); int tts_dbus_request_finalize(unsigned int uid); diff --git a/client/tts_ipc.c b/client/tts_ipc.c index 9b4eb366..b1af5a9d 100644 --- a/client/tts_ipc.c +++ b/client/tts_ipc.c @@ -129,14 +129,14 @@ int tts_ipc_request_hello_sync(unsigned int uid) return g_vtable[REQUEST_HELLO_SYNC](uid); } -int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed) +int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed) { SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_initialize"); RETVM_IF(false == tts_client_is_valid_uid(uid), TTS_ERROR_INVALID_PARAMETER, "Fail to get tts_client with uid(%u)", uid); RETVM_IF(NULL == g_vtable, TTS_ERROR_OPERATION_FAILED, "[ERROR] IPC method is not set"); - return g_vtable[REQUEST_INITIALIZE](uid, mode, registered_event_mask, credential_needed); + return g_vtable[REQUEST_INITIALIZE](uid, mode, registered_event_mask, service_state, credential_needed); } int tts_ipc_request_finalize(unsigned int uid) diff --git a/client/tts_ipc.h b/client/tts_ipc.h index 34bad752..fbddbbb7 100644 --- a/client/tts_ipc.h +++ b/client/tts_ipc.h @@ -34,7 +34,7 @@ int tts_ipc_request_hello(unsigned int uid, tts_mode_e mode, int registered_even int tts_ipc_request_hello_sync(unsigned int uid); -int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed); +int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed); int tts_ipc_request_finalize(unsigned int uid); diff --git a/client/tts_tidl.c b/client/tts_tidl.c index 7a1f0123..e3e0b362 100644 --- a/client/tts_tidl.c +++ b/client/tts_tidl.c @@ -80,8 +80,11 @@ static void __notify_cb(void *user_data, int pid, int uid, bundle *msg) if (0 == strncmp(TTSD_METHOD_HELLO, method, strlen(TTSD_METHOD_HELLO))) { char* credential_needed = NULL; + char* service_state = NULL; char* ret = NULL; + bundle_get_str(msg, TTS_BUNDLE_CREDENTIAL_NEEDED, &credential_needed); + bundle_get_str(msg, TTS_BUNDLE_CURRENT_STATE, &service_state); bundle_get_str(msg, TTS_BUNDLE_REASON, &ret); if (NULL != credential_needed && NULL != ret) { @@ -544,7 +547,7 @@ int tts_tidl_request_hello_sync(unsigned int uid) return TTS_ERROR_NONE; } -int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed) +int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed) { SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_initialize"); @@ -556,8 +559,9 @@ int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registere RETVM_IF(!info->connected, TTS_ERROR_IO_ERROR, "[ERROR] Not Connected"); - bool temp; - int ret = rpc_port_proxy_tts_invoke_initialize(info->rpc_h, client->pid, uid, (int)mode, registered_event_mask, &temp); + bool tmp_credential_needed = false; + int tmp_service_state = -1; + int ret = rpc_port_proxy_tts_invoke_initialize(info->rpc_h, client->pid, uid, (int)mode, registered_event_mask, &tmp_service_state, &tmp_credential_needed); int exception = get_last_result(); if (RPC_PORT_ERROR_NONE != exception) { ret = __convert_and_handle_tidl_error(exception, info); @@ -568,9 +572,10 @@ int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registere return ret; } - *credential_needed = temp; + *credential_needed = tmp_credential_needed; + *service_state = (tts_service_state_e)tmp_service_state; - SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : credential_needed(%d)", *credential_needed); + SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts initialize : service_state(%d), credential_needed(%d)", tmp_service_state, tmp_credential_needed); return TTS_ERROR_NONE; } diff --git a/client/tts_tidl.h b/client/tts_tidl.h index 19af39de..97a8de34 100644 --- a/client/tts_tidl.h +++ b/client/tts_tidl.h @@ -30,7 +30,7 @@ int tts_tidl_request_hello(unsigned int uid, tts_mode_e mode, int registered_eve int tts_tidl_request_hello_sync(unsigned int uid); -int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, bool* credential_needed); +int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, int registered_event_mask, tts_service_state_e* service_state, bool* credential_needed); int tts_tidl_request_finalize(unsigned int uid); diff --git a/server/ttsd_dbus.c b/server/ttsd_dbus.c index d709b605..734471bf 100644 --- a/server/ttsd_dbus.c +++ b/server/ttsd_dbus.c @@ -54,7 +54,7 @@ const char* __ttsd_get_error_code(ttsd_error_e err) return NULL; } -int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int credential_needed) +int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed) { if (NULL == g_conn_sender) { SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available"); @@ -78,7 +78,12 @@ int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int credential_nee SLOG(LOG_INFO, tts_tag(), "<<<< [Dbus] Send hello message : uid(%u), ret(%d), credential_needed(%d)", uid, ret, credential_needed); } - dbus_message_append_args(msg, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &credential_needed, DBUS_TYPE_INVALID); + dbus_message_append_args(msg, + DBUS_TYPE_UINT32, &uid, + DBUS_TYPE_INT32, &ret, + DBUS_TYPE_INT32, &service_state, + DBUS_TYPE_INT32, &credential_needed, + DBUS_TYPE_INVALID); if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to Send"); diff --git a/server/ttsd_dbus.h b/server/ttsd_dbus.h index 48cc4f80..0d23376c 100644 --- a/server/ttsd_dbus.h +++ b/server/ttsd_dbus.h @@ -23,7 +23,7 @@ int ttsd_dbus_open_connection(); int ttsd_dbus_close_connection(); -int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int credential_needed); +int ttsdc_dbus_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed); int ttsdc_dbus_send_utt_start_message(int pid, unsigned int uid, int uttid); diff --git a/server/ttsd_dbus_server.c b/server/ttsd_dbus_server.c index 93a44bd3..e299b87d 100644 --- a/server/ttsd_dbus_server.c +++ b/server/ttsd_dbus_server.c @@ -47,6 +47,7 @@ int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg) SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : pid(%d), uid(%u), mode(%d)", pid, uid, mode); bool is_initialized = false; bool is_credential_needed = false; + int service_state = TTSD_STATE_INVALID; int credential_needed = 0; int ret = -1; @@ -66,9 +67,11 @@ int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg) ret = TTS_ERROR_ALREADY_INITIALIZED; credential_needed = TTS_CREDENTIAL_NEEDED_ALREADY_INITIALIZED; } - SLOG(LOG_INFO, tts_tag(), "[INFO] send_hello. pid(%d), uid(%u), ret(%d), credential_needed(%d)", pid, uid, ret, credential_needed); - ttsdc_dbus_send_hello(pid, uid, ret, credential_needed); + SLOG(LOG_INFO, tts_tag(), "[INFO] send_hello. pid(%d), uid(%u), ret(%d), service_state(%d), credential_needed(%d)", + pid, uid, ret, service_state, credential_needed); + + ttsdc_dbus_send_hello(pid, uid, ret, service_state, credential_needed); } return 0; @@ -128,12 +131,14 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg) DBusMessage* reply; reply = dbus_message_new_method_return(msg); - int temp = (int)credential_needed; + int tmp_credential_needed = (int)credential_needed; + int tmp_service_state = -1; SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts initialize : result(%d), credential_needed(%d)", ret, (int)credential_needed); if (NULL != reply) { dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, - DBUS_TYPE_INT32, &temp, + DBUS_TYPE_INT32, &tmp_service_state, + DBUS_TYPE_INT32, &tmp_credential_needed, DBUS_TYPE_INVALID); if (0 == ret) { diff --git a/server/ttsd_ipc.h b/server/ttsd_ipc.h index c6eb6b7f..b5685368 100644 --- a/server/ttsd_ipc.h +++ b/server/ttsd_ipc.h @@ -35,7 +35,7 @@ int ttsd_ipc_open_connection(); int ttsd_ipc_close_connection(); -int ttsdc_ipc_send_hello(int pid, unsigned int uid, int ret, int credential_needed); +int ttsdc_ipc_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed); int ttsdc_ipc_send_utt_start_message(int pid, unsigned int uid, int uttid); diff --git a/server/ttsd_tidl.c b/server/ttsd_tidl.c index 0cb8403c..4b87a13b 100644 --- a/server/ttsd_tidl.c +++ b/server/ttsd_tidl.c @@ -147,6 +147,8 @@ static void __register_cb(rpc_port_stub_tts_context_h context, int pid, int uid, int ret = -1; int credential_needed = 0; + int service_state = TTSD_STATE_INVALID; + if (false == is_initialized) { bool is_credential_needed = false; ret = ttsd_server_initialize(pid, u_uid, mode, registered_event_mask, TTS_IPC_METHOD_TIDL, &is_credential_needed); @@ -190,7 +192,7 @@ static void __register_cb(rpc_port_stub_tts_context_h context, int pid, int uid, pthread_mutex_unlock(&g_tidl_proxy_infos_mutex); SLOG(LOG_INFO, tts_tag(), "create player instance"); - ttsdc_tidl_send_hello(pid, u_uid, ret, credential_needed); + ttsdc_tidl_send_hello(pid, u_uid, ret, service_state, credential_needed); SLOG(LOG_ERROR, tts_tag(), "<<<<<<<<<<<"); return; @@ -235,14 +237,18 @@ static int __register_cb_sync(rpc_port_stub_tts_context_h context, int pid, int return TTSD_ERROR_NONE; } -int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int credential_needed) +int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed) { - SLOG(LOG_INFO, tts_tag(), "[TIDL] ttsdc_tidl_send_hello : pid(%d), uid(%u), credential_needed(%d)", pid, uid, credential_needed); + SLOG(LOG_INFO, tts_tag(), "[TIDL] ttsdc_tidl_send_hello : pid(%d), uid(%u), service_state(%d), credential_needed(%d)", + pid, uid, service_state, credential_needed); + + char credential_needed_str[12] = {0, }; + char service_state_str[12] = {0, }; + char ret_str[12] = {0, }; - char tmp_val[10] = {0, }; - char ret_val[12] = {0, }; - snprintf(tmp_val, 10, "%d", credential_needed); - snprintf(ret_val, 12, "%d", ret); + snprintf(credential_needed_str, 12, "%d", credential_needed); + snprintf(service_state_str, 12, "%d", service_state); + snprintf(ret_str, 12, "%d", ret); bundle* msg = bundle_create(); if (NULL == msg) { @@ -251,8 +257,9 @@ int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int credential_nee } bundle_add_str(msg, TTS_BUNDLE_METHOD, TTSD_METHOD_HELLO); - bundle_add_str(msg, TTS_BUNDLE_REASON, ret_val); - bundle_add_str(msg, TTS_BUNDLE_CREDENTIAL_NEEDED, tmp_val); + bundle_add_str(msg, TTS_BUNDLE_REASON, ret_str); + bundle_add_str(msg, TTS_BUNDLE_CURRENT_STATE, service_state_str); + bundle_add_str(msg, TTS_BUNDLE_CREDENTIAL_NEEDED, credential_needed_str); SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTSD SEND HELLO MSG"); __send_msg(pid, uid, msg); @@ -261,7 +268,7 @@ int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int credential_nee return TTSD_ERROR_NONE; } -static int __initialize_cb(rpc_port_stub_tts_context_h context, int pid, int uid, int mode, int registered_event_mask, bool *credential_needed, void *user_data) +static int __initialize_cb(rpc_port_stub_tts_context_h context, int pid, int uid, int mode, int registered_event_mask, int *service_state, bool *credential_needed, void *user_data) { unsigned int u_uid = (unsigned int)uid; SECURE_SLOG(LOG_ERROR, tts_tag(), "[IN] tts initialize : pid(%d), uid(%u), mode(%d)", pid, u_uid, mode); diff --git a/server/ttsd_tidl.h b/server/ttsd_tidl.h index 4aafb628..71f77486 100644 --- a/server/ttsd_tidl.h +++ b/server/ttsd_tidl.h @@ -23,7 +23,7 @@ int ttsd_tidl_open_connection(); int ttsd_tidl_close_connection(); -int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int credential_needed); +int ttsdc_tidl_send_hello(int pid, unsigned int uid, int ret, int service_state, int credential_needed); int ttsdc_tidl_send_utt_start_message(int pid, unsigned int uid, int uttid); diff --git a/tidl/tts.tidl b/tidl/tts.tidl index 1d09a7be..a50ed58f 100644 --- a/tidl/tts.tidl +++ b/tidl/tts.tidl @@ -3,7 +3,7 @@ interface tts { void register_cb(int pid, int uid, int mode, int registered_event_mask, notify_cb callback) async; int register_cb_sync(int pid, int uid, notify_cb callback); - int initialize(in int pid, in int uid, in int mode, in int registered_event_mask, out bool credential_needed); + int initialize(in int pid, in int uid, in int mode, in int registered_event_mask, out int service_state, out bool credential_needed); int finalize(in int uid); int add_text(int uid, string text, string lang, int vctype, int speed, int uttid, string credential); int stop(in int uid);