Fix IPC interface for preparing protocol 76/279076/4
authorSuyeon Hwang <stom.hwang@samsung.com>
Fri, 29 Jul 2022 03:21:29 +0000 (12:21 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 2 Aug 2022 02:31:41 +0000 (11:31 +0900)
- Requirement:
Client want to send mode information to server with hello message.

- Solution:
Actually, mode information is already set before calling tts_prepare()
function, so client should be able to send mode information within hello
message. However, current code sends mode information through another
IPC method.
This patch changes the hello message interface between server and
client. Through this patch, client can send mode information with hello
message at once.

Change-Id: Ie4c622b48507935d2ba35980fc2b44c4854bdeb8
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
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_server.c
server/ttsd_tidl.c
tidl/tts.tidl

index 0e51157cb5eb8d188a562977877f8e26c7dff124..47947fbfea31e089ca51c9e09e544b8fe49887d9 100644 (file)
@@ -416,7 +416,8 @@ static int __send_hello_msg(tts_client_s* client)
        }
 
        unsigned int uid = tts_client_get_uid(client);
-       SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%u)", tts_client_get_handle(client), client, uid);
+       tts_mode_e mode = tts_client_get_mode(client);
+       SLOG(LOG_INFO, TAG_TTSC, "[INFO] tts_h(%p), tts_client(%p), uid(%u), mode(%d)", tts_client_get_handle(client), client, uid, (int)mode);
 
        /* check service engine status */
        bool is_launched = __is_engine_launched();
@@ -431,7 +432,7 @@ static int __send_hello_msg(tts_client_s* client)
                }
        }
 
-       if (0 != tts_ipc_request_hello(uid)) {
+       if (0 != tts_ipc_request_hello(uid, mode)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request hello !!"); //LCOV_EXCL_LINE
        } else {
                SLOG(LOG_INFO, TAG_TTSC, "@@@ Send Hello");
@@ -517,7 +518,8 @@ static int __prepare_sync_cb(tts_client_s* client)
        // TODO: make function duplicated block
        /* do request initialize */
        bool credential_needed = false;
-       int ret = tts_ipc_request_initialize(uid, &credential_needed);
+       tts_mode_e mode = tts_client_get_mode(client);
+       int ret = tts_ipc_request_initialize(uid, mode, &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 d4e3230dff8cd2556321483df563aaeabd1887a8..68364203e676d53bb1d4b3176c5a20dd27da3f72 100644 (file)
@@ -423,7 +423,7 @@ DBusMessage* __tts_dbus_make_message(unsigned int uid, const char* method)
        return msg;
 }
 
-int tts_dbus_request_hello(unsigned int uid)
+int tts_dbus_request_hello(unsigned int uid, tts_mode_e mode)
 {
        DBusError err;
        dbus_error_init(&err);
@@ -442,7 +442,7 @@ int tts_dbus_request_hello(unsigned int uid)
        }
 
        int pid = getpid();
-       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID)) {
+       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &mode, DBUS_TYPE_INVALID)) {
                dbus_message_unref(msg);
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
 
@@ -504,7 +504,7 @@ int tts_dbus_request_hello_sync(unsigned int uid)
        return result;
 }
 
-int tts_dbus_request_initialize(unsigned int uid, bool* credential_needed)
+int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, bool* credential_needed)
 {
        DBusMessage* msg;
        DBusError err;
@@ -520,7 +520,7 @@ int tts_dbus_request_initialize(unsigned int uid, bool* credential_needed)
        }
 
        int pid = getpid();
-       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID)) {
+       if (true != dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &mode, DBUS_TYPE_INVALID)) {
                dbus_message_unref(msg);
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
 
index 87e9c741ba23e0b3d87e3bf1588f5c8c0968f646..bfdf3497cc8bda7a4dde61d51054c578b5b99b8e 100644 (file)
@@ -27,11 +27,11 @@ int tts_dbus_close_connection(unsigned int uid);
 
 int tts_dbus_stop_listening(unsigned int uid);
 
-int tts_dbus_request_hello(unsigned int uid);
+int tts_dbus_request_hello(unsigned int uid, tts_mode_e mode);
 
 int tts_dbus_request_hello_sync(unsigned int uid);
 
-int tts_dbus_request_initialize(unsigned int uid, bool* credential_needed);
+int tts_dbus_request_initialize(unsigned int uid, tts_mode_e mode, bool* credential_needed);
 
 int tts_dbus_request_finalize(unsigned int uid);
 
index 2e3c5db996b4be507228fde3be38c3f3f470cf2b..96f4bbb9402de4f09d017e73ef7157394d88dea1 100644 (file)
@@ -107,14 +107,14 @@ int tts_ipc_stop_listening(unsigned int uid)
        return g_vtable[STOP_LISTENING](uid);
 }
 
-int tts_ipc_request_hello(unsigned int uid)
+int tts_ipc_request_hello(unsigned int uid, tts_mode_e mode)
 {
        SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_hello");
 
        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_HELLO](uid);
+       return g_vtable[REQUEST_HELLO](uid, mode);
 }
 
 int tts_ipc_request_hello_sync(unsigned int uid)
@@ -127,14 +127,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, bool* credential_needed)
+int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, 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, credential_needed);
+       return g_vtable[REQUEST_INITIALIZE](uid, mode, credential_needed);
 }
 
 int tts_ipc_request_finalize(unsigned int uid)
index df61feadf6897bc48d7746720f760cd20774ba5d..cf332cd12780a137af601bd7e02b8ecce149f059 100644 (file)
@@ -30,11 +30,11 @@ int tts_ipc_close_connection(unsigned int uid);
 
 int tts_ipc_stop_listening(unsigned int uid);
 
-int tts_ipc_request_hello(unsigned int uid);
+int tts_ipc_request_hello(unsigned int uid, tts_mode_e mode);
 
 int tts_ipc_request_hello_sync(unsigned int uid);
 
-int tts_ipc_request_initialize(unsigned int uid, bool* credential_needed);
+int tts_ipc_request_initialize(unsigned int uid, tts_mode_e mode, bool* credential_needed);
 
 int tts_ipc_request_finalize(unsigned int uid);
 
index 3c32134f8e05a1dcb6686b6a058ed913071b12ca..f2ffbf688411fd578cfc0db96aeb49f75de534d8 100644 (file)
@@ -307,7 +307,7 @@ static int __create_notify_callback_handle(tts_tidl_info_s* info)
        return TTS_ERROR_NONE;
 }
 
-static int __invoke_register_callback(int pid, tts_tidl_info_s* info)
+static int __invoke_register_callback(int pid, tts_mode_e mode, tts_tidl_info_s* info)
 {
        if (info->register_callback_invoked) {
                SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Already register callback is invoked");
@@ -320,12 +320,12 @@ static int __invoke_register_callback(int pid, tts_tidl_info_s* info)
                return ret;
        }
 
-       rpc_port_proxy_tts_invoke_register_cb(info->rpc_h, pid, info->uid, info->notify_cb_h);
+       rpc_port_proxy_tts_invoke_register_cb(info->rpc_h, pid, info->uid, (int)mode, info->notify_cb_h);
        info->register_callback_invoked = true;
        return TTS_ERROR_NONE;
 }
 
-int tts_tidl_request_hello(unsigned int uid)
+int tts_tidl_request_hello(unsigned int uid, tts_mode_e mode)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_hello");
 
@@ -364,7 +364,7 @@ int tts_tidl_request_hello(unsigned int uid)
        }
 
        SLOG(LOG_DEBUG, TAG_TTSC, ">>>>> TTS Hello");
-       if (TTS_ERROR_NONE != __invoke_register_callback(client->pid, info)) {
+       if (TTS_ERROR_NONE != __invoke_register_callback(client->pid, mode, info)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to invoke register callback");
                return TTS_ERROR_OPERATION_FAILED;
        }
@@ -453,7 +453,7 @@ int tts_tidl_request_hello_sync(unsigned int uid)
        return TTS_ERROR_NONE;
 }
 
-int tts_tidl_request_initialize(unsigned int uid, bool* credential_needed)
+int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, bool* credential_needed)
 {
        SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_initialize");
 
@@ -466,7 +466,7 @@ int tts_tidl_request_initialize(unsigned int uid, bool* credential_needed)
        RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
 
        bool temp;
-       int ret = rpc_port_proxy_tts_invoke_initialize(info->rpc_h, client->pid, uid, &temp);
+       int ret = rpc_port_proxy_tts_invoke_initialize(info->rpc_h, client->pid, uid, (int)mode, &temp);
        int exception = get_last_result();
        if (RPC_PORT_ERROR_NONE != exception) {
                ret = __convert_unhandled_error(exception);
index 56a80f0ff0785c5da77ae37ff5436288a5768332..34e026fe5bcd00ce7696bb1d7c5acb608522abb4 100644 (file)
@@ -26,11 +26,11 @@ int tts_tidl_close_connection(unsigned int uid);
 
 int tts_tidl_stop_listening(unsigned int uid);
 
-int tts_tidl_request_hello(unsigned int uid);
+int tts_tidl_request_hello(unsigned int uid, tts_mode_e mode);
 
 int tts_tidl_request_hello_sync(unsigned int uid);
 
-int tts_tidl_request_initialize(unsigned int uid, bool* credential_needed);
+int tts_tidl_request_initialize(unsigned int uid, tts_mode_e mode, bool* credential_needed);
 
 int tts_tidl_request_finalize(unsigned int uid);
 
index 82e41df596302d01aa0e172ecf9c928c1e0c4949..95b6d1b135d76c0cccd506df7c43f7a8766188ac 100644 (file)
@@ -31,13 +31,14 @@ int ttsd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
 
        int pid;
        unsigned int uid;
-       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INVALID);
+       int mode = 0;
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &mode, DBUS_TYPE_INVALID);
 
        if (dbus_error_is_set(&err)) {
                SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : get arguments error (%s)", err.message);
                dbus_error_free(&err);
        } else {
-               SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : pid(%d), uid(%u)", pid, uid);
+               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 credential_needed = 0;
@@ -93,13 +94,16 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
        DBusError err;
        dbus_error_init(&err);
 
-       int pid, uid;
+       int pid;
+       unsigned int uid;
        bool credential_needed = 0;
+       int mode = 0;
        int ret = 0;
 
        dbus_message_get_args(msg, &err,
                DBUS_TYPE_INT32, &pid,
                DBUS_TYPE_UINT32, &uid,
+               DBUS_TYPE_INT32, &mode,
                DBUS_TYPE_INVALID);
 
        SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS INITIALIZE");
@@ -110,7 +114,7 @@ int ttsd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
                ret = TTSD_ERROR_OPERATION_FAILED;
        } else {
 
-               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts initialize : pid(%d), uid(%u)", pid , uid);
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts initialize : pid(%d), uid(%u), mode(%d)", pid, uid, mode);
                ret = ttsd_server_initialize(pid, uid, TTS_IPC_METHOD_DBUS, &credential_needed);
        }
 
index fe0cf2a97562574bc12da1f0bbc13e55f44370d0..adf3abe9f92fc520fdcb3bcc6de939b92f508503 100644 (file)
@@ -137,10 +137,10 @@ static void __destroy_client_cb(rpc_port_stub_tts_context_h context, void *user_
        free(sender);
 }
 
-static void __register_cb(rpc_port_stub_tts_context_h context, int pid, int uid, rpc_port_stub_tts_notify_cb_h callback, void* user_data)
+static void __register_cb(rpc_port_stub_tts_context_h context, int pid, int uid, int mode, rpc_port_stub_tts_notify_cb_h callback, void *user_data)
 {
        unsigned int u_uid = (unsigned int)uid;
-       SLOG(LOG_ERROR, tts_tag(), ">>>>> TTS REGISTER CALLBACK uid(%u)", u_uid);
+       SLOG(LOG_ERROR, tts_tag(), ">>>>> TTS REGISTER CALLBACK uid(%u), mode(%d)", u_uid, mode);
 
        bool is_initialized = false;
        ttsd_server_is_already_initialized(pid, u_uid, &is_initialized);
@@ -276,10 +276,10 @@ 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, bool *credential_needed, void *user_data)
+static int __initialize_cb(rpc_port_stub_tts_context_h context, int pid, int uid, int mode, 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)", pid, u_uid);
+       SECURE_SLOG(LOG_ERROR, tts_tag(), "[IN] tts initialize : pid(%d), uid(%u), mode(%d)", pid, u_uid, mode);
 
        if (0 != ttsd_server_initialize(pid, u_uid, TTS_IPC_METHOD_TIDL, credential_needed)) {
                return TTSD_ERROR_OPERATION_FAILED;
index 38fcf5773a76040f63cc82a6d3dc364145f19a42..c112d9a65fc25c363c3e0f6dd786581971cca1dc 100644 (file)
@@ -1,10 +1,10 @@
 interface tts {
        void notify_cb(int pid, int uid, bundle msg) delegate;
-       void register_cb(int pid, int uid, notify_cb callback) async;
+       void register_cb(int pid, int uid, int mode, notify_cb callback) async;
        int register_cb_sync(int pid, int uid, notify_cb callback);
 
        int set_mode(in int uid, in int mode);
-       int initialize(in int pid, in int uid, out bool credential_needed);
+       int initialize(in int pid, in int uid, in int mode, 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);