Add interfaces for transfering service state 45/279845/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 11 Aug 2022 06:04:07 +0000 (15:04 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 19 Aug 2022 07:07:01 +0000 (16:07 +0900)
- Requirement:
The client and server needs interface for requesting and transfering
service state, respectively.

- Solution:
This patch adds new interfaces for requesting and transfering service
state. These new interfaces includes both Dbus and TIDL.

Change-Id: I10407b1e7c0bed1cb377c83d27c29db09882fefd
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
16 files changed:
client/tts_dbus.c
client/tts_dbus.h
client/tts_ipc.c
client/tts_ipc.h
client/tts_tidl.c
client/tts_tidl.h
common/tts_defs.h
server/ttsd_dbus.c
server/ttsd_dbus.h
server/ttsd_dbus_server.c
server/ttsd_dbus_server.h
server/ttsd_ipc.c
server/ttsd_ipc.h
server/ttsd_tidl.c
server/ttsd_tidl.h
tidl/tts.tidl

index 768035d..54c7dd9 100644 (file)
@@ -184,6 +184,20 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                        }
                } /* TTSD_SIGNAL_SET_STATE */
 
+               else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_SET_SERVICE_STATE)) {
+                       unsigned int uid = TTS_INVALID_UID;
+                       int before_state = 0;
+                       int current_state = 0;
+
+                       dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &before_state, DBUS_TYPE_INT32, &current_state, DBUS_TYPE_INVALID);
+                       if (dbus_error_is_set(&err)) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get arguments error (%s)", err.message);
+                               dbus_error_free(&err);
+                       }
+
+                       // TODO: implement notifier
+               } /* TTSD_METHOD_SET_SERVICE_STATE */
+
                else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_ERROR)) {
                        unsigned int uid;
                        int uttid;
@@ -959,3 +973,67 @@ int tts_dbus_request_add_pcm(unsigned int uid, int event, const char* data, int
        return result;
 }
 // LCOV_EXCL_STOP
+
+int tts_dbus_request_get_service_state(unsigned int uid, tts_service_state_e* service_state)
+{
+       if (NULL == service_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       DBusMessage* msg = __tts_dbus_make_message(uid, TTS_METHOD_GET_SERVICE_STATE);
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get service state : Fail to make message");
+               return TTS_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get service state : uid(%u)", uid);
+       }
+
+       if (true != dbus_message_append_args(msg,
+               DBUS_TYPE_UINT32, &uid,
+               DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       DBusError err;
+       dbus_error_init(&err);
+       DBusMessage* result_msg;
+       int result = TTS_ERROR_OPERATION_FAILED;
+       result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, WAITING_TIME, &err);
+       dbus_message_unref(msg);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Send error (%s)", err.message);
+               dbus_error_free(&err);
+       }
+
+       int state = (int)TTS_SERVICE_STATE_READY;
+       if (NULL != result_msg) {
+               dbus_message_get_args(result_msg, &err,
+                       DBUS_TYPE_INT32, &result,
+                       DBUS_TYPE_INT32, &state,
+                       DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get service state : Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+                       result = TTS_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts get service state : result(%d)", result);
+                       *service_state = (tts_service_state_e)state;
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get service state : result(%d)", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               tts_dbus_reconnect();
+               result = TTS_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
index d52ad49..70ec52a 100644 (file)
@@ -53,6 +53,8 @@ int tts_dbus_request_stop_pcm(unsigned int uid);
 
 int tts_dbus_request_add_pcm(unsigned int uid, int event, const char* data, int data_size, int audio_type, int rate);
 
+int tts_dbus_request_get_service_state(unsigned int uid, tts_service_state_e* service_state);
+
 #ifdef __cplusplus
 }
 #endif
index ef8bad1..806950e 100644 (file)
@@ -32,7 +32,8 @@ typedef enum {
        REQUEST_GET_PRIVATE_DATA,
        REQUEST_PLAY_PCM,
        REQUEST_STOP_PCM,
-       REQUEST_ADD_PCM
+       REQUEST_ADD_PCM,
+       REQUEST_GET_SERVICE_STATE
 } tts_ipc_vtable_e;
 
 
@@ -40,13 +41,15 @@ static int(*ttsc_dbus_vtable[])() = { &tts_dbus_open_connection, &tts_dbus_close
                                                &tts_dbus_request_hello, &tts_dbus_request_hello_sync, &tts_dbus_request_initialize,
                                                &tts_dbus_request_finalize, &tts_dbus_request_add_text, &tts_dbus_request_play, &tts_dbus_request_stop,
                                                &tts_dbus_request_pause, &tts_dbus_request_set_private_data, &tts_dbus_request_get_private_data,
-                                               &tts_dbus_request_play_pcm, &tts_dbus_request_stop_pcm, &tts_dbus_request_add_pcm };
+                                               &tts_dbus_request_play_pcm, &tts_dbus_request_stop_pcm, &tts_dbus_request_add_pcm,
+                                               &tts_dbus_request_get_service_state };
 
 static int(*ttsc_tidl_vtable[])() = { &tts_tidl_open_connection, &tts_tidl_close_connection, &tts_tidl_stop_listening,
                                                &tts_tidl_request_hello, &tts_tidl_request_hello_sync, &tts_tidl_request_initialize,
                                                &tts_tidl_request_finalize, &tts_tidl_request_add_text, &tts_tidl_request_play, &tts_tidl_request_stop,
                                                &tts_tidl_request_pause, &tts_tidl_request_set_private_data, &tts_tidl_request_get_private_data,
-                                               &tts_tidl_request_play_pcm, &tts_tidl_request_stop_pcm, &tts_tidl_request_add_pcm };
+                                               &tts_tidl_request_play_pcm, &tts_tidl_request_stop_pcm, &tts_tidl_request_add_pcm,
+                                               &tts_tidl_request_get_service_state };
 
 static int (**g_vtable)();
 static tts_ipc_method_e g_ipc_method = TTS_IPC_METHOD_UNDEFINED;
@@ -235,3 +238,13 @@ int tts_ipc_request_add_pcm(unsigned int uid, int event, const char* data, int d
 
        return g_vtable[REQUEST_ADD_PCM](uid, event, data, data_size, audio_type, rate);
 }
+
+int tts_ipc_request_get_service_state(unsigned int uid, tts_service_state_e* service_state)
+{
+       SLOG(LOG_INFO, TAG_TTSC, "[IPC] tts_ipc_request_get_service_state");
+
+       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_GET_SERVICE_STATE](uid, service_state);
+}
index 12615f0..e7591c3 100644 (file)
@@ -56,6 +56,8 @@ int tts_ipc_request_stop_pcm(unsigned int uid);
 
 int tts_ipc_request_add_pcm(unsigned int uid, int event, const char* data, int data_size, int audio_type, int rate);
 
+int tts_ipc_request_get_service_state(unsigned int uid, tts_service_state_e* service_state);
+
 #ifdef __cplusplus
 }
 #endif
index 8b6edca..f773654 100644 (file)
@@ -102,6 +102,13 @@ static void __notify_cb(void *user_data, int pid, int uid, bundle *msg)
                if (val) {
                        tts_core_notify_state_changed(client, (tts_state_e)atoi(val));
                }
+       } else if (0 == strncmp(TTSD_METHOD_SET_SERVICE_STATE, method, strlen(TTSD_METHOD_SET_SERVICE_STATE))) {
+               char* before_state = NULL;
+               char* current_state = NULL;
+               bundle_get_str(msg, TTS_BUNDLE_BEFORE_STATE, &before_state);
+               bundle_get_str(msg, TTS_BUNDLE_CURRENT_STATE, &current_state);
+
+               // TODO: Implement notifier
        } else if (0 == strncmp(TTSD_METHOD_ERROR, method, strlen(TTSD_METHOD_ERROR))) {
                char *uttid = NULL;
                char *reason = NULL;
@@ -785,3 +792,34 @@ int tts_tidl_request_add_pcm(unsigned int uid, int event, const char* data, int
 
        return TTS_ERROR_NONE;
 }
+
+int tts_tidl_request_get_service_state(unsigned int uid, tts_service_state_e* service_state)
+{
+       SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_request_get_service_state");
+
+       tts_client_s* client = tts_client_get_by_uid(uid);
+       RETVM_IF(NULL == client, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get client");
+
+       tts_tidl_info_s* info = __get_tidl_info_s(uid);
+       RETVM_IF(NULL == info, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+
+       RETVM_IF(!info->connected, TTS_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+       int state = (int)TTS_SERVICE_STATE_READY;
+       int ret = rpc_port_proxy_tts_invoke_get_service_state(info->rpc_h, uid, &state);
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (TTS_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request get service state : Fail to invoke message");
+               return ret;
+       }
+
+       *service_state = (tts_service_state_e)state;
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "<<<< get service state : service state(%d)", state);
+
+       return TTS_ERROR_NONE;
+}
index f4f705e..ee3a504 100644 (file)
@@ -52,6 +52,8 @@ int tts_tidl_request_stop_pcm(unsigned int uid);
 
 int tts_tidl_request_add_pcm(unsigned int uid, int event, const char* data, int data_size, int audio_type, int rate);
 
+int tts_tidl_request_get_service_state(unsigned int uid, tts_service_state_e* service_state);
+
 #ifdef __cplusplus
 }
 #endif
index ee1a585..196e2e3 100644 (file)
@@ -60,6 +60,8 @@ extern "C" {
 #define TTS_BUNDLE_REASON "reason"
 #define TTS_BUNDLE_ERR_MSG "err_msg"
 #define TTS_BUNDLE_CREDENTIAL_NEEDED "credential_needed"
+#define TTS_BUNDLE_BEFORE_STATE "before_state"
+#define TTS_BUNDLE_CURRENT_STATE "current_state"
 
 #define TTS_METHOD_HELLO               "tts_method_hello"
 #define TTS_METHOD_HELLO_SYNC       "tts_method_hello_sync"
@@ -74,6 +76,7 @@ extern "C" {
 #define TTS_METHOD_PLAY_PCM            "tts_method_play_pcm"
 #define TTS_METHOD_STOP_PCM            "tts_method_stop_pcm"
 #define TTS_METHOD_ADD_PCM             "tts_method_add_pcm"
+#define TTS_METHOD_GET_SERVICE_STATE           "tts_method_get_service_state"
 
 #define TTS_METHOD_SET_PRIVATE_DATA    "tts_method_set_private_data"
 #define TTS_METHOD_GET_PRIVATE_DATA    "tts_method_get_private_data"
@@ -84,6 +87,7 @@ extern "C" {
 #define TTSD_METHOD_UTTERANCE_COMPLETED        "ttsd_method_utterance_completed"
 #define TTSD_METHOD_ERROR              "ttsd_method_error"
 #define TTSD_METHOD_SET_STATE          "ttsd_method_set_state"
+#define TTSD_METHOD_SET_SERVICE_STATE          "ttsd_method_set_service_state"
 
 
 /******************************************************************************************
index 129b5c7..d709b60 100644 (file)
@@ -147,6 +147,46 @@ int ttsdc_dbus_send_set_state_message(int pid, unsigned int uid, int state)
        return __send_message(pid, uid, state, TTSD_METHOD_SET_STATE);
 }
 
+int ttsdc_dbus_send_set_service_state_message(int pid, unsigned int uid, int before_state, int current_state)
+{
+       if (NULL == g_conn_sender) {
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Dbus connection is not available");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       DBusMessage* msg = NULL;
+
+       char target_if_name[64];
+       snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid);
+
+       /* create a message */
+       msg = dbus_message_new_signal(
+               TTS_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
+               target_if_name,                         /* interface name of the signal */
+               TTSD_METHOD_SET_SERVICE_STATE);                 /* name of the signal */
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to create message : %s", TTSD_METHOD_SET_SERVICE_STATE);
+               return TTSD_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[Dbus] Send set service state message : uid(%u) before_state(%d), current_state(%d)", uid, before_state, current_state);
+       }
+
+       dbus_message_append_args(msg, DBUS_TYPE_UINT32, &uid, DBUS_TYPE_INT32, &before_state, DBUS_TYPE_INT32, &current_state, DBUS_TYPE_INVALID);
+
+       if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
+               SLOG(LOG_ERROR, tts_tag(), "[Dbus ERROR] Fail to Send");
+               return TTSD_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, tts_tag(), "[Dbus] SUCCESS Send");
+               dbus_connection_flush(g_conn_sender);
+       }
+
+       dbus_message_unref(msg);
+
+       return TTSD_ERROR_NONE;
+}
+
 int ttsdc_dbus_send_error_message(int pid, unsigned int uid, int uttid, int reason, char* err_msg)
 {
        if (NULL == g_conn_sender) {
@@ -258,6 +298,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_ADD_PCM)) {
                        ttsd_dbus_server_add_pcm(g_conn_listener, msg);
 
+               } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_SERVICE_STATE)) {
+                       ttsd_dbus_server_get_service_state(g_conn_listener, msg);
+
                } else {
                        SLOG(LOG_DEBUG, tts_tag(), "Message is NOT valid");
                        /* Invalid method */
index 0d9cd9c..48cc4f8 100644 (file)
@@ -33,6 +33,8 @@ int ttsdc_dbus_send_error_message(int pid, unsigned int uid, int uttid, int reas
 
 int ttsdc_dbus_send_set_state_message(int pid, unsigned int uid, int state);
 
+int ttsdc_dbus_send_set_service_state_message(int pid, unsigned int uid, int before_state, int current_state);
+
 
 #ifdef __cplusplus
 }
index eb7ec0b..1915609 100644 (file)
@@ -828,3 +828,55 @@ int ttsd_dbus_server_add_pcm(DBusConnection* conn, DBusMessage* msg)
 
        return 0;
 }
+
+int ttsd_dbus_server_get_service_state(DBusConnection* conn, DBusMessage* msg)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       unsigned int uid;
+       int state = (int)TTSD_STATE_READY;
+       int ret = 0;
+
+       dbus_message_get_args(msg, &err,
+               DBUS_TYPE_UINT32, &uid,
+               DBUS_TYPE_INVALID);
+
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET SERVICE STATE");
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, tts_tag(), "[IN ERROR] tts get service state : Get arguments error (%s)", err.message);
+               dbus_error_free(&err);
+               ret = TTSD_ERROR_OPERATION_FAILED;
+       } else {
+               SECURE_SLOG(LOG_DEBUG, tts_tag(), "[IN] tts get service state : uid(%u)", uid);
+               // TODO: implement behavior
+       }
+
+       DBusMessage* reply;
+       reply = dbus_message_new_method_return(msg);
+
+       if (NULL != reply) {
+               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID);
+
+               if (0 == ret) {
+                       SLOG(LOG_DEBUG, tts_tag(), "[OUT] tts get service state : result(%d)", ret);
+               } else {
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : result(%d)", ret);
+               }
+
+               if (!dbus_connection_send(conn, reply, NULL)) {
+                       SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : Out Of Memory!");
+               }
+
+               dbus_connection_flush(conn);
+               dbus_message_unref(reply);
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[OUT ERROR] tts get service state : Fail to create reply message!!");
+       }
+
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, tts_tag(), "  ");
+
+       return 0;
+}
index 01f79e3..42075fe 100644 (file)
@@ -55,6 +55,8 @@ int ttsd_dbus_server_stop_pcm(DBusConnection* conn, DBusMessage* msg);
 
 int ttsd_dbus_server_add_pcm(DBusConnection* conn, DBusMessage* msg);
 
+int ttsd_dbus_server_get_service_state(DBusConnection* conn, DBusMessage* msg);
+
 #ifdef __cplusplus
 }
 #endif
index bef4533..72646a4 100644 (file)
 
 
 static int(*ttsd_dbus_vtable[])() = {&ttsd_dbus_open_connection, &ttsd_dbus_close_connection, &ttsdc_dbus_send_utt_start_message,
-                                       &ttsdc_dbus_send_utt_finish_message, &ttsdc_dbus_send_set_state_message, &ttsdc_dbus_send_error_message};
+                                       &ttsdc_dbus_send_utt_finish_message, &ttsdc_dbus_send_set_state_message, &ttsdc_dbus_send_error_message,
+                                       &ttsdc_dbus_send_set_service_state_message};
 static int(*ttsd_tidl_vtable[])() = {&ttsd_tidl_open_connection, &ttsd_tidl_close_connection, &ttsdc_tidl_send_utt_start_message,
-                                       &ttsdc_tidl_send_utt_finish_message, &ttsdc_tidl_send_set_state_message, &ttsdc_tidl_send_error_message};
+                                       &ttsdc_tidl_send_utt_finish_message, &ttsdc_tidl_send_set_state_message, &ttsdc_tidl_send_error_message,
+                                       &ttsdc_tidl_send_set_service_state_message};
 
 int ttsd_ipc_open_connection()
 {
@@ -159,3 +161,29 @@ int ttsdc_ipc_send_error_message(int pid, unsigned int uid, int uttid, int reaso
 
        return TTSD_ERROR_OPERATION_FAILED;
 }
+
+int ttsdc_ipc_send_set_service_state_message(int pid, unsigned int uid, int before_state, int current_state)
+{
+       SLOG(LOG_INFO, tts_tag(), "[IPC] ttsdc_ipc_send_set_service_state_message");
+
+       if (0 > ttsd_data_is_client(uid)) {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] uid is not valid (%u)", uid);
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       switch (ttsd_data_get_ipc_method(uid))
+       {
+       case TTS_IPC_METHOD_DBUS:
+               SLOG(LOG_DEBUG, tts_tag(), "[IPC] ipc method : dbus");
+               return ttsd_dbus_vtable[SEND_SET_SERVICE_STATE](pid, uid, before_state, current_state);
+
+       case TTS_IPC_METHOD_TIDL:
+               SLOG(LOG_DEBUG, tts_tag(), "[IPC] ipc method : tidl");
+               return ttsd_tidl_vtable[SEND_SET_SERVICE_STATE] (pid, uid, before_state, current_state);
+
+       default:
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] method is not valid");
+       }
+
+       return TTSD_ERROR_OPERATION_FAILED;
+}
index 88001dc..c6eb6b7 100644 (file)
@@ -27,7 +27,8 @@ typedef enum {
        SEND_UTTERANCE_START,
        SEND_UTTERANCE_FINISH,
        SEND_SET_STATE,
-       SEND_ERROR
+       SEND_ERROR,
+       SEND_SET_SERVICE_STATE
 } ttsd_ipc_vtable_e;
 
 int ttsd_ipc_open_connection();
@@ -44,6 +45,9 @@ int ttsdc_ipc_send_error_message(int pid, unsigned int uid, int uttid, int reaso
 
 int ttsdc_ipc_send_set_state_message(int pid, unsigned int uid, int state);
 
+int ttsdc_ipc_send_set_service_state_message(int pid, unsigned int uid, int before_state, int current_state);
+
+
 #ifdef __cplusplus
 }
 #endif
index a516f7f..495b737 100644 (file)
@@ -452,6 +452,17 @@ static int __add_pcm_cb(rpc_port_stub_tts_context_h context, int uid, int event,
        return TTSD_ERROR_NONE;
 }
 
+static int __get_service_state(rpc_port_stub_tts_context_h context, int uid, int* service_state, void *user_data)
+{
+       unsigned int u_uid = (unsigned int)uid;
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS GET SERVICE STATE (%u)", u_uid);
+
+       // TODO: implement business logic
+
+       SLOG(LOG_DEBUG, tts_tag(), "<<<<<");
+       return TTSD_ERROR_NONE;
+}
+
 int ttsd_tidl_open_connection()
 {
        SLOG(LOG_DEBUG, tts_tag(), "[TIDL] ttsd_tidl_open_connection");
@@ -471,6 +482,7 @@ int ttsd_tidl_open_connection()
        g_callback.get_private = __get_private_cb;
        g_callback.play = __play_cb;
        g_callback.add_pcm = __add_pcm_cb;
+       g_callback.get_service_state = __get_service_state;
 
 
        int ret = -1;
@@ -530,6 +542,28 @@ int ttsdc_tidl_send_set_state_message(int pid, unsigned int uid, int state)
        return __send_message(pid, uid, state, TTSD_METHOD_SET_STATE);
 }
 
+int ttsdc_tidl_send_set_service_state_message(int pid, unsigned int uid, int before_state, int current_state)
+{
+       SLOG(LOG_DEBUG, tts_tag(), "[TIDL] ttsdc_tidl_send_set_service_state_message");
+
+       char str_before_state[10] = {0, };
+       char str_current_state[10] = {0, };
+
+       snprintf(str_before_state, 10, "%d", before_state);
+       snprintf(str_current_state, 10, "%d", current_state);
+
+       bundle* msg = bundle_create();
+       bundle_add_str(msg, TTS_BUNDLE_METHOD, TTSD_METHOD_SET_SERVICE_STATE);
+       bundle_add_str(msg, TTS_BUNDLE_BEFORE_STATE, str_before_state);
+       bundle_add_str(msg, TTS_BUNDLE_CURRENT_STATE, str_current_state);
+
+       SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTSD SEND SET SERVICE STATE MESSAGE");
+       __send_msg(pid, uid, msg);
+
+       bundle_free(msg);
+       return TTSD_ERROR_NONE;
+}
+
 int ttsdc_tidl_send_error_message(int pid, unsigned int uid, int uttid, int reason, char* err_msg)
 {
        SLOG(LOG_DEBUG, tts_tag(), "[TIDL] ttsdc_tidl_send_error_message");
index f844021..4aafb62 100644 (file)
@@ -33,6 +33,8 @@ int ttsdc_tidl_send_set_state_message(int pid, unsigned int uid, int state);
 
 int ttsdc_tidl_send_error_message(int pid, unsigned int uid, int uttid, int reason, char* err_msg);
 
+int ttsdc_tidl_send_set_service_state_message(int pid, unsigned int uid, int before_state, int current_state);
+
 #ifdef __cplusplus
 }
 #endif
index bcc1387..c6071e3 100644 (file)
@@ -14,4 +14,5 @@ interface tts {
        int get_private(in int uid, string key, out string priv_data);
        int play(int uid, string credential);
        int add_pcm(int uid, int event, array<char> pcm_data, int data_size, int audio_type, int rate);
+       int get_service_state(in int uid, out int service_state);
 }