From 3d6d48614fd49503fb7566e77fceb32bfd37b6cf Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 11 Aug 2022 15:04:07 +0900 Subject: [PATCH] Add interfaces for transfering service state - 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 --- client/tts_dbus.c | 78 +++++++++++++++++++++++++++++++++++++++ client/tts_dbus.h | 2 + client/tts_ipc.c | 19 ++++++++-- client/tts_ipc.h | 2 + client/tts_tidl.c | 38 +++++++++++++++++++ client/tts_tidl.h | 2 + common/tts_defs.h | 4 ++ server/ttsd_dbus.c | 43 +++++++++++++++++++++ server/ttsd_dbus.h | 2 + server/ttsd_dbus_server.c | 52 ++++++++++++++++++++++++++ server/ttsd_dbus_server.h | 2 + server/ttsd_ipc.c | 32 +++++++++++++++- server/ttsd_ipc.h | 6 ++- server/ttsd_tidl.c | 34 +++++++++++++++++ server/ttsd_tidl.h | 2 + tidl/tts.tidl | 1 + 16 files changed, 313 insertions(+), 6 deletions(-) diff --git a/client/tts_dbus.c b/client/tts_dbus.c index 768035d4..54c7dd97 100644 --- a/client/tts_dbus.c +++ b/client/tts_dbus.c @@ -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, ¤t_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; +} diff --git a/client/tts_dbus.h b/client/tts_dbus.h index d52ad493..70ec52a5 100644 --- a/client/tts_dbus.h +++ b/client/tts_dbus.h @@ -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 diff --git a/client/tts_ipc.c b/client/tts_ipc.c index ef8bad16..806950e8 100644 --- a/client/tts_ipc.c +++ b/client/tts_ipc.c @@ -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); +} diff --git a/client/tts_ipc.h b/client/tts_ipc.h index 12615f0f..e7591c30 100644 --- a/client/tts_ipc.h +++ b/client/tts_ipc.h @@ -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 diff --git a/client/tts_tidl.c b/client/tts_tidl.c index 8b6edca5..f7736544 100644 --- a/client/tts_tidl.c +++ b/client/tts_tidl.c @@ -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, ¤t_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; +} diff --git a/client/tts_tidl.h b/client/tts_tidl.h index f4f705ea..ee3a5047 100644 --- a/client/tts_tidl.h +++ b/client/tts_tidl.h @@ -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 diff --git a/common/tts_defs.h b/common/tts_defs.h index ee1a585b..196e2e35 100644 --- a/common/tts_defs.h +++ b/common/tts_defs.h @@ -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" /****************************************************************************************** diff --git a/server/ttsd_dbus.c b/server/ttsd_dbus.c index 129b5c7c..d709b605 100644 --- a/server/ttsd_dbus.c +++ b/server/ttsd_dbus.c @@ -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, ¤t_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 */ diff --git a/server/ttsd_dbus.h b/server/ttsd_dbus.h index 0d9cd9c8..48cc4f80 100644 --- a/server/ttsd_dbus.h +++ b/server/ttsd_dbus.h @@ -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 } diff --git a/server/ttsd_dbus_server.c b/server/ttsd_dbus_server.c index eb7ec0bb..1915609d 100644 --- a/server/ttsd_dbus_server.c +++ b/server/ttsd_dbus_server.c @@ -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; +} diff --git a/server/ttsd_dbus_server.h b/server/ttsd_dbus_server.h index 01f79e3a..42075fe2 100644 --- a/server/ttsd_dbus_server.h +++ b/server/ttsd_dbus_server.h @@ -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 diff --git a/server/ttsd_ipc.c b/server/ttsd_ipc.c index bef45337..72646a48 100644 --- a/server/ttsd_ipc.c +++ b/server/ttsd_ipc.c @@ -18,9 +18,11 @@ 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; +} diff --git a/server/ttsd_ipc.h b/server/ttsd_ipc.h index 88001dc7..c6eb6b7f 100644 --- a/server/ttsd_ipc.h +++ b/server/ttsd_ipc.h @@ -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 diff --git a/server/ttsd_tidl.c b/server/ttsd_tidl.c index a516f7f3..495b7374 100644 --- a/server/ttsd_tidl.c +++ b/server/ttsd_tidl.c @@ -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"); diff --git a/server/ttsd_tidl.h b/server/ttsd_tidl.h index f8440217..4aafb628 100644 --- a/server/ttsd_tidl.h +++ b/server/ttsd_tidl.h @@ -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 diff --git a/tidl/tts.tidl b/tidl/tts.tidl index bcc1387b..c6071e30 100644 --- a/tidl/tts.tidl +++ b/tidl/tts.tidl @@ -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 pcm_data, int data_size, int audio_type, int rate); + int get_service_state(in int uid, out int service_state); } -- 2.34.1