Add new IPC parameter for sending service state 12/288012/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 29 Dec 2022 08:01:33 +0000 (17:01 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 9 Feb 2023 05:31:21 +0000 (14:31 +0900)
- 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 <stom.hwang@samsung.com>
14 files changed:
client/tts_core.c
client/tts_dbus.c
client/tts_dbus.h
client/tts_ipc.c
client/tts_ipc.h
client/tts_tidl.c
client/tts_tidl.h
server/ttsd_dbus.c
server/ttsd_dbus.h
server/ttsd_dbus_server.c
server/ttsd_ipc.h
server/ttsd_tidl.c
server/ttsd_tidl.h
tidl/tts.tidl

index 3cf8791d306bd33da73cdfd2d9db40889676017d..7828d334bdfe9c955a081aef3e95264fa5586b7a 100644 (file)
@@ -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);
index 6c3cfcb0a8829e11ffc356a15f26fd84f0c0f2c1..56c1b2e82e99e58d550c023ff002d7099c5d9797 100644 (file)
@@ -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);
index a0eaeb70b0bd2b1050bef5e42115bfa0d947207b..4ef0ed5f2dee4ee596bedf8ac47315306ee9ea63 100644 (file)
@@ -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);
 
index 9b4eb3662d7640d3ea0e66b78fdc9d77befa3ab4..b1af5a9d6628cafc109ddc36175920420936bf14 100644 (file)
@@ -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)
index 34bad752077e9f56c2a8908411db0f8b4bdef28d..fbddbbb76a2017d5ea86937324e933924f5a65a0 100644 (file)
@@ -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);
 
index 7a1f0123b45c6a685ee34c14e3dff341bd9087dd..e3e0b362673d8e550366b15ad48a16cd1539dd3f 100644 (file)
@@ -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;
 }
index 19af39ded717aacb4e4cdb03888a6d58c2d99855..97a8de34bbd11a6d2bd2fa3312abc4c0e2036df3 100644 (file)
@@ -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);
 
index d709b605561bc5f30c5b4ef8024388a4620e2756..734471bf332e269d63b324b9ffd7e907257add36 100644 (file)
@@ -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");
index 48cc4f8021797a4db7fd96dee8a1f157a57c58df..0d23376c126dc9814eacc2866e1504866495e90d 100644 (file)
@@ -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);
 
index 93a44bd31a9b8256851076233fa5e0920dd34c85..e299b87d76612fbb4e5d8dbb853de26e115abd72 100644 (file)
@@ -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) {
index c6eb6b7fcbf721e19c02969322c4b474a520a704..b56853680595b6a382111859dabe12e57a5ba97b 100644 (file)
@@ -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);
 
index 0cb8403c00e99d33e8779bce75b489f084ffebdd..4b87a13b4fce8d09cf6faab42cf61dbfa3adbf02 100644 (file)
@@ -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);
index 4aafb628525b0bd150432f9df075d8ed6e6f83e3..71f774860ba587f35fd3fdf742a09751218e35c0 100644 (file)
@@ -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);
 
index 1d09a7be482edd03287b5cde444a4ca33a4e3b5a..a50ed58f1b84b7e8b9ef1eb89f45957ce7d29e1e 100644 (file)
@@ -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);