Join two tidl method, register and request_hello 35/256535/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Tue, 6 Apr 2021 08:36:45 +0000 (17:36 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 6 Apr 2021 08:36:47 +0000 (17:36 +0900)
These two callbacks are called on same and have similar behavior.
So, I combine these two method to simplify the behavior of ttsd_server_initialize().

By this patch, ttsd_server_initialize() has same behavior to use either tidl and dbus method.

Change-Id: I0f5366b8cf1407c7b5943633d19f9b67821d8ddd
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
client/tts_tidl.c
server/ttsd_server.c
server/ttsd_tidl.c
tidl/tts.tidl

index 581c541..27e9b8c 100644 (file)
@@ -374,8 +374,6 @@ int tts_tidl_request_hello(int uid)
                return TTS_ERROR_INVALID_PARAMETER;
        }
 
-       rpc_port_tts_notify_cb_h cb;
-
        if (!tts->connected) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Not Connected");
                return TTS_ERROR_OPERATION_FAILED;
@@ -383,19 +381,13 @@ int tts_tidl_request_hello(int uid)
 
        SLOG(LOG_DEBUG, TAG_TTSC, ">>>>> TTS Hello");
        /* register callback - needed to create new client before adding callback */
-       cb = rpc_port_tts_notify_cb_create(__notify_cb, false, NULL);
+       rpc_port_tts_notify_cb_h cb = rpc_port_tts_notify_cb_create(__notify_cb, false, NULL);
        if (0 != rpc_port_proxy_tts_invoke_register_cb(tts->rpc_h, client->pid, client->uid, cb)) {
                SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Failed to invoke register");
                return TTS_ERROR_OPERATION_FAILED;
        }
-       SLOG(LOG_DEBUG, TAG_TTSC, "TTS Register callback");
 
-       if (0 != rpc_port_proxy_tts_invoke_request_hello(tts->rpc_h, client->pid, client->uid)) {
-               SLOG(LOG_ERROR, TAG_TTSC, ">>> Request tts hello : Fail to invoke message");
-               return TTS_ERROR_OPERATION_FAILED;
-       }
        SLOG(LOG_DEBUG, TAG_TTSC, "<<<<");
-
        return TTS_ERROR_NONE;
 }
 
index 35dd834..276b0fc 100644 (file)
@@ -606,7 +606,7 @@ int ttsd_server_initialize(int pid, int uid, bool* credential_needed)
 {
        SLOG(LOG_INFO, tts_tag(), "[Server] Server initialize");
 
-       if (-1 != ttsd_data_is_client(uid) && false == ttsd_data_is_client_use_tidl(uid)) {
+       if (-1 != ttsd_data_is_client(uid)) {
                SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Uid has already been registered");
                return TTSD_ERROR_NONE;
        }
@@ -637,11 +637,9 @@ int ttsd_server_initialize(int pid, int uid, bool* credential_needed)
                }
        }
 
-       if (false == ttsd_data_is_client_use_tidl(uid)) {
-               if (0 != ttsd_data_new_client(pid, uid)) {
-                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add client info");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
+       if (0 != ttsd_data_new_client(pid, uid)) {
+               SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add client info");
+               return TTSD_ERROR_OPERATION_FAILED;
        }
 
        if (0 != ttsd_player_create_instance(uid)) {
index bebd4eb..9378635 100644 (file)
@@ -17,6 +17,8 @@
 #include "ttsd_data.h"
 #include "ttsd_server.h"
 
+#include "ttsd_tidl.h"
+
 rpc_port_stub_tts_callback_s g_callback;
 
 void __send_msg(int pid, int uid, bundle* msg)
@@ -63,12 +65,10 @@ static int __register_cb(rpc_port_stub_tts_context_h context, int pid, int uid,
 {
        SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS REGISTER CALLBACK uid(%d)", uid);
 
-       if (-1 == ttsd_data_is_client(uid)) {
-               SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Uid has not yet been registered");
-               if (0 != ttsd_data_new_client(pid, uid)) {
-                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to add client info");
-                       return TTSD_ERROR_OPERATION_FAILED;
-               }
+       bool credential_needed = false;
+       if (0 != ttsd_server_initialize(pid, uid, &credential_needed)) {
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize");
+               return TTSE_ERROR_OPERATION_FAILED;
        }
 
        if (0 != ttsd_data_set_notify_h(uid, callback, NULL)) {
@@ -76,6 +76,9 @@ static int __register_cb(rpc_port_stub_tts_context_h context, int pid, int uid,
                return TTSD_ERROR_OPERATION_FAILED;
        }
 
+       SLOG(LOG_INFO, tts_tag(), "create player instance");
+       ttsdc_tidl_send_hello(pid, uid, (int)credential_needed);
+
        SLOG(LOG_ERROR, tts_tag(), "<<<<<<<<<<<");
 
        return TTSE_ERROR_NONE;
@@ -127,25 +130,6 @@ int ttsdc_tidl_send_hello(int pid, int uid, int credential_needed)
        return TTSE_ERROR_NONE;
 }
 
-static int __request_hello_cb(rpc_port_stub_tts_context_h context, int pid, int uid, void *user_data)
-{
-       SLOG(LOG_INFO, tts_tag(), "[IN] ttsd hello : pid(%d), uid(%d)", pid, uid);
-
-       if (ttsd_data_get_notify_handle(uid)) {
-               SLOG(LOG_INFO, tts_tag(), "notify callback is set");
-
-               bool credential_needed = 0;
-               if (0 != ttsd_server_initialize(pid, uid, &credential_needed)) {
-                       SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] ttsd Hello : server initialize");
-                       return TTSE_ERROR_OPERATION_FAILED;
-               }
-               SLOG(LOG_INFO, tts_tag(), "create player instance");
-               ttsdc_tidl_send_hello(pid, uid, (int)credential_needed);
-       }
-
-       return TTSE_ERROR_NONE;
-}
-
 static int __initialize_cb(rpc_port_stub_tts_context_h context, int uid, int pid, bool *credential_needed, void *user_data)
 {
        SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts initialize : pid(%d), uid(%d)", pid , uid);
@@ -295,7 +279,6 @@ int ttsd_tidl_open_connection()
        g_callback.create = __create_client_cb;
        g_callback.terminate = __destroy_client_cb;
        g_callback.set_mode = __set_mode_cb;
-       g_callback.request_hello = __request_hello_cb;
        g_callback.register_cb = __register_cb;
        g_callback.unregister_cb = __unregister_cb;
        g_callback.initialize = __initialize_cb;
index 7a12e24..2ba57d7 100644 (file)
@@ -4,7 +4,6 @@ interface tts {
        int unregister_cb(int uid);
 
        int set_mode(int mode);
-       int request_hello(int pid, int uid);
        int initialize(in int pid, in int uid, 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);