From 093556606c9af1b7136006a4d5ccebcb2b32eae6 Mon Sep 17 00:00:00 2001 From: Lee Dongyeol Date: Wed, 15 Jul 2015 14:50:37 +0900 Subject: [PATCH] Adapt dbus signal for utterance notification Change-Id: Ia265372b5f8c0ac6033532b48d1fb997dcea961c --- changelog | 1 + client/tts_dbus.c | 134 +++++++++++------------------------------------- common/tts_config_mgr.c | 2 + common/tts_defs.h | 1 - packaging/tts.spec | 3 +- server/ttsd_dbus.c | 23 +++------ tts-server.conf | 38 ++++++++++++++ 7 files changed, 81 insertions(+), 121 deletions(-) diff --git a/changelog b/changelog index 00778d3..b96985c 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,7 @@ tts (0.2.42) -- Fri, 29 May 2015 * Update utt message to change file message to dbus ipc (Dongyeol Lee ) * Remove unused smack label (Kwangyoun Kim ) + * Upgate utt message IPC based on signal (Dongyeol Lee ) tts (0.2.41) -- Sat, 13 Aug 2014 diff --git a/client/tts_dbus.c b/client/tts_dbus.c index 5e0b45b..3357625 100644 --- a/client/tts_dbus.c +++ b/client/tts_dbus.c @@ -62,60 +62,11 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle DBusError err; dbus_error_init(&err); - - DBusMessage *reply = NULL; - char if_name[64]; - //snprintf(if_name, 64, "%s%d", TTS_CLIENT_SERVICE_INTERFACE, getpid()); + char if_name[64] = {0, }; snprintf(if_name, 64, "%s", TTS_CLIENT_SERVICE_INTERFACE); - /* check if the message is a signal from the correct interface and with the correct name */ - if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_HELLO)) { - SLOG(LOG_DEBUG, TAG_TTSC, "===== Get Hello"); - int uid = 0; - int response = -1; - - dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &uid, 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); - } - - if (uid > 0) { - SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts get hello : uid(%d)", uid); - - /* check uid */ - tts_client_s* client = tts_client_get_by_uid(uid); - if (NULL != client) - response = 1; - else - response = 0; - } else { - SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get hello : invalid uid"); - } - - reply = dbus_message_new_method_return(msg); - - if (NULL != reply) { - dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID); - - if (!dbus_connection_send(g_conn_listener, reply, NULL)) - SLOG(LOG_ERROR, TAG_TTSC, ">>>> tts get hello : fail to send reply"); - else - SLOG(LOG_DEBUG, TAG_TTSC, ">>>> tts get hello : result(%d)", response); - - dbus_connection_flush(g_conn_listener); - dbus_message_unref(reply); - } else { - SLOG(LOG_ERROR, TAG_TTSC, ">>>> tts get hello : fail to create reply message"); - } - - SLOG(LOG_DEBUG, TAG_TTSC, "====="); - SLOG(LOG_DEBUG, TAG_TTSC, " "); - } /* TTSD_METHOD_HELLO */ - - else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_UTTERANCE_STARTED)) { - SLOG(LOG_DEBUG, TAG_TTSC, "===== Get utterance started"); + if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_UTTERANCE_STARTED)) { int uid = 0; int uttid = 0; @@ -125,19 +76,12 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle dbus_error_free(&err); } - if (uid > 0) { + if (0 == __tts_cb_utt_started(uid, uttid)) { SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts utterance started : uid(%d) uttid(%d)", uid, uttid); - __tts_cb_utt_started(uid, uttid); - } else { - SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts utterance started : invalid uid"); } - - SLOG(LOG_DEBUG, TAG_TTSC, "====="); - SLOG(LOG_DEBUG, TAG_TTSC, " "); } /* TTSD_METHOD_UTTERANCE_STARTED */ - else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_UTTERANCE_COMPLETED)) { - SLOG(LOG_DEBUG, TAG_TTSC, "===== Get utterance completed"); + else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_UTTERANCE_COMPLETED)) { int uid = 0; int uttid = 0; @@ -147,19 +91,12 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle dbus_error_free(&err); } - if (uid > 0) { + if (0 == __tts_cb_utt_completed(uid, uttid)) { SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts utterance completed : uid(%d) uttid(%d)", uid, uttid); - __tts_cb_utt_completed(uid, uttid); - } else { - SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts utterance completed : invalid uid"); } - - SLOG(LOG_DEBUG, TAG_TTSC, "====="); - SLOG(LOG_DEBUG, TAG_TTSC, " "); } /* TTSD_METHOD_UTTERANCE_COMPLETED */ - else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_SET_STATE)) { - SLOG(LOG_DEBUG, TAG_TTSC, "===== Set state changed"); + else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_SET_STATE)) { int uid = 0; int state = 0; @@ -169,20 +106,12 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle dbus_error_free(&err); } - if (uid > 0) { + if (0 == __tts_cb_set_state(uid, state)) { SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts state changed : uid(%d) state(%d)", uid, state); - __tts_cb_set_state(uid, state); - } else { - SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts state changed : invalid uid"); } - - SLOG(LOG_DEBUG, TAG_TTSC, "====="); - SLOG(LOG_DEBUG, TAG_TTSC, " "); } /* TTSD_METHOD_SET_STATE */ - else if (dbus_message_is_method_call(msg, if_name, TTSD_METHOD_ERROR)) { - SLOG(LOG_DEBUG, TAG_TTSC, "===== Get error message"); - + else if (dbus_message_is_signal(msg, if_name, TTSD_METHOD_ERROR)) { int uid; int uttid; int reason; @@ -193,17 +122,15 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle DBUS_TYPE_INT32, &reason, DBUS_TYPE_INVALID); - if (dbus_error_is_set(&err)) { + if (dbus_error_is_set(&err)) { SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message - Get arguments error (%s)", err.message); - dbus_error_free(&err); - } else { + dbus_error_free(&err); + } + + if (0 == __tts_cb_error(uid, reason, uttid)) { SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message : uid(%d), error(%d), uttid(%d)", uid, reason, uttid); - __tts_cb_error(uid, reason, uttid); } - - SLOG(LOG_DEBUG, TAG_TTSC, "====="); - SLOG(LOG_DEBUG, TAG_TTSC, " "); - }/* TTS_SIGNAL_ERROR */ + } /* TTSD_METHOD_ERROR */ /* free the message */ dbus_message_unref(msg); @@ -248,12 +175,12 @@ int tts_dbus_open_connection() return TTS_ERROR_OPERATION_FAILED; } +#if 0 int pid = getpid(); char service_name[64]; memset(service_name, 0, 64); - //snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid); - snprintf(service_name, 64, "%s", TTS_CLIENT_SERVICE_NAME); + snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid); SLOG(LOG_DEBUG, TAG_TTSC, "Service name is %s", service_name); @@ -263,11 +190,9 @@ int tts_dbus_open_connection() SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Name Error (%s)", err.message); dbus_error_free(&err); } - - char rule[128]; - //snprintf(rule, 128, "type='method_call',interface='%s%d'", TTS_CLIENT_SERVICE_INTERFACE, pid); - snprintf(rule, 128, "type='method_call',interface='%s'", TTS_CLIENT_SERVICE_INTERFACE); - +#endif + char rule[128] = {0, }; + snprintf(rule, 128, "type='signal',interface='%s'", TTS_CLIENT_SERVICE_INTERFACE); SLOG(LOG_DEBUG, TAG_TTSC, "rule is %s", rule); /* add a rule for which messages we want to see */ @@ -300,12 +225,12 @@ int tts_dbus_close_connection() ecore_main_fd_handler_del(g_dbus_fd_handler); g_dbus_fd_handler = NULL; } - +#if 0 int pid = getpid(); char service_name[64]; memset(service_name, 0, 64); - //snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid); + snprintf(service_name, 64, "%s%d", TTS_CLIENT_SERVICE_NAME, pid); snprintf(service_name, 64, "%s", TTS_CLIENT_SERVICE_NAME); dbus_bus_release_name(g_conn_listener, service_name, &err); @@ -313,7 +238,7 @@ int tts_dbus_close_connection() SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Release name error (%s)", err.message); dbus_error_free(&err); } - +#endif g_conn_sender = NULL; g_conn_listener = NULL; @@ -364,8 +289,6 @@ DBusMessage* __tts_dbus_make_message(int uid, const char* method) TTS_SERVER_SERVICE_OBJECT_PATH, TTS_SERVER_SERVICE_INTERFACE, method); - - SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Service name : %s, method : %s", TTS_SERVER_SERVICE_NAME, method); } else if (TTS_MODE_NOTIFICATION == client->mode) { msg = dbus_message_new_method_call( TTS_NOTI_SERVER_SERVICE_NAME, @@ -388,24 +311,29 @@ DBusMessage* __tts_dbus_make_message(int uid, const char* method) int tts_dbus_request_hello(int uid) { + DBusError err; + dbus_error_init(&err); DBusMessage* msg; msg = __tts_dbus_make_message(uid, TTS_METHOD_HELLO); + + if (dbus_error_is_set(&err)) { + SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts dbus log : %s", err); + dbus_error_free(&err); + } + if (NULL == msg) { SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts hello : Fail to make message"); return TTS_ERROR_OPERATION_FAILED; } - DBusError err; - dbus_error_init(&err); - DBusMessage* result_msg = NULL; int result = 0; result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, HELLO_WAITING_TIME, &err); dbus_message_unref(msg); if (dbus_error_is_set(&err)) { - SLOG(LOG_DEBUG, TAG_TTSC, ">>>> error : %s", err); + SLOG(LOG_DEBUG, TAG_TTSC, "<<<< tts dbus log : %s", err); dbus_error_free(&err); } diff --git a/common/tts_config_mgr.c b/common/tts_config_mgr.c index 9cef646..3f4575d 100644 --- a/common/tts_config_mgr.c +++ b/common/tts_config_mgr.c @@ -1070,6 +1070,8 @@ int tts_config_mgr_finalize(int uid) return 0; } + tts_config_mgr_unset_callback(uid); + __tts_config_release_engine(); tts_parser_unload_config(g_config_info); diff --git a/common/tts_defs.h b/common/tts_defs.h index 469e55c..7fe3943 100644 --- a/common/tts_defs.h +++ b/common/tts_defs.h @@ -62,7 +62,6 @@ 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_GET_STATE "ttsd_method_get_state" /****************************************************************************************** diff --git a/packaging/tts.spec b/packaging/tts.spec index 9f45360..a8a1565 100644 --- a/packaging/tts.spec +++ b/packaging/tts.spec @@ -1,6 +1,6 @@ Name: tts Summary: Text To Speech client library and daemon -Version: 0.2.41 +Version: 0.2.42 Release: 1 Group: Graphics & UI Framework/Voice Framework License: Apache-2.0 @@ -10,6 +10,7 @@ Source1002: %{name}-devel.manifest Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-media-audio-io) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(dbus-1) diff --git a/server/ttsd_dbus.c b/server/ttsd_dbus.c index e414684..37fc2b4 100644 --- a/server/ttsd_dbus.c +++ b/server/ttsd_dbus.c @@ -56,6 +56,7 @@ const char* __ttsd_get_error_code(ttsd_error_e err) int ttsdc_send_hello(int pid, int uid) { +#if 0 if (NULL == g_conn_sender) { SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available" ); return -1; @@ -117,6 +118,8 @@ int ttsdc_send_hello(int pid, int uid) } return result; +#endif + return 0; } int ttsdc_send_message(int pid, int uid, int data, const char *method) @@ -126,27 +129,17 @@ int ttsdc_send_message(int pid, int uid, int data, const char *method) return -1; } - char service_name[64]; - memset(service_name, 0, 64); - //snprintf(service_name, sizeof(service_name), "%s%d", TTS_CLIENT_SERVICE_NAME, pid); - snprintf(service_name, sizeof(service_name), "%s", TTS_CLIENT_SERVICE_NAME); - char target_if_name[64]; memset(target_if_name, 0, 64); - //snprintf(target_if_name, sizeof(target_if_name), "%s%d", TTS_CLIENT_SERVICE_INTERFACE, pid); snprintf(target_if_name, sizeof(target_if_name), "%s", TTS_CLIENT_SERVICE_INTERFACE); - SLOG(LOG_ERROR, get_tag(), "<<<< [Dbus] service name(%s) object(%s) interface(%s)", - service_name, TTS_CLIENT_SERVICE_OBJECT_PATH, target_if_name); - DBusMessage* msg = NULL; /* create a message & check for errors */ - msg = dbus_message_new_method_call( - service_name, - TTS_CLIENT_SERVICE_OBJECT_PATH, - target_if_name, - method); + msg = dbus_message_new_signal( + TTS_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */ + target_if_name, /* interface name of the signal */ + method); /* name of the signal */ if (NULL == msg) { SLOG(LOG_ERROR, get_tag(), "<<<< [Dbus ERROR] Fail to create message : %s", method); @@ -157,8 +150,6 @@ int ttsdc_send_message(int pid, int uid, int data, const char *method) dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INT32, &data, DBUS_TYPE_INVALID); - dbus_message_set_no_reply(msg, TRUE); - if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) { SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Fail to Send"); return -1; diff --git a/tts-server.conf b/tts-server.conf index d2e8b73..8c8dadf 100644 --- a/tts-server.conf +++ b/tts-server.conf @@ -39,6 +39,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +