Add function to set/get private data 42/70142/1
authorWonnam Jang <wn.jang@samsung.com>
Wed, 18 May 2016 09:21:12 +0000 (18:21 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Wed, 18 May 2016 09:21:12 +0000 (18:21 +0900)
Change-Id: If6afebc18e5fa33cb418660ff9df848831d99947
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
14 files changed:
client/tts.c
client/tts_dbus.c
client/tts_dbus.h [changed mode: 0755->0644]
common/tts_defs.h
include/tts.h
server/ttsd_dbus.c
server/ttsd_dbus_server.c
server/ttsd_dbus_server.h
server/ttsd_engine_agent.c [changed mode: 0755->0644]
server/ttsd_engine_agent.h
server/ttsd_main.h [changed mode: 0755->0644]
server/ttsd_server.c
server/ttsd_server.h
server/ttsp.h [changed mode: 0755->0644]

index 5adac65..b37afb9 100644 (file)
@@ -1415,6 +1415,128 @@ int tts_pause(tts_h tts)
        return TTS_ERROR_NONE;
 }
 
+int tts_set_private_data(tts_h tts, const char* key, const char* data)
+{
+       if (0 != __tts_get_feature_enabled()) {
+               return TTS_ERROR_NOT_SUPPORTED;
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Set private data");
+
+       if (NULL == tts) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+       
+       if (NULL == key || NULL == data) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid parameter");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       tts_client_s* client = tts_client_get(tts);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       if (TTS_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid state : Current state is NOT 'READY'");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Screen reader option is NOT available. Ignore this request");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = tts_dbus_request_set_private_data(client->uid, key, data);
+               if (0 != ret) {
+                       if (TTS_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry : %s", __tts_get_error_code(ret));
+                               usleep(10000);
+                               count++;
+                               if (TTS_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, "");
+
+       return 0;
+}
+
+int tts_get_private_data(tts_h tts, const char* key, char** data)
+{
+       if (0 != __tts_get_feature_enabled()) {
+               return TTS_ERROR_NOT_SUPPORTED;
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "===== Get private data");
+
+       if (NULL == tts) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+       
+       if (NULL == key || NULL == data) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid parameter");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       tts_client_s* client = tts_client_get(tts);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] A handle is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       if (TTS_STATE_READY != client->current_state) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Invalid state : Current state is NOT 'READY'");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       if (false == g_screen_reader && TTS_MODE_SCREEN_READER == client->mode) {
+               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Screen reader option is NOT available. Ignore this request");
+               return TTS_ERROR_INVALID_STATE;
+       }
+
+       int ret = -1;
+       int count = 0;
+       while (0 != ret) {
+               ret = tts_dbus_request_get_private_data(client->uid, key, data);
+               if (0 != ret) {
+                       if (TTS_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] result : %s", __tts_get_error_code(ret));
+                               return ret;
+                       } else {
+                               SLOG(LOG_WARN, TAG_TTSC, "[WARNING] retry : %s", __tts_get_error_code(ret));
+                               usleep(10000);
+                               count++;
+                               if (TTS_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to request");
+                                       return ret;
+                               }
+                       }
+               }
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, "");
+
+       return 0;
+}
+
 static Eina_Bool __tts_notify_error(void *data)
 {
        tts_h tts = (tts_h)data;
index 0008e75..8c3b60a 100644 (file)
@@ -516,6 +516,146 @@ int tts_dbus_request_add_text(int uid, const char* text, const char* lang, int v
        return result;
 }
 
+int tts_dbus_request_set_private_data(int uid, const char* key, const char* data)
+{
+       if (NULL == key || NULL == data) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
+
+       msg = __tts_dbus_make_message(uid, TTS_METHOD_SET_PRIVATE_DATA);
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts set private data : Fail to make message");
+               return TTS_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts set private data : uid(%d)", uid);
+       }
+
+       if (true != dbus_message_append_args(msg,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &key,
+               DBUS_TYPE_STRING, &data,
+               DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       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);
+       }
+
+       if (NULL != result_msg) {
+               dbus_message_get_args(result_msg, &err,
+                       DBUS_TYPE_INT32, &result,
+                       DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts set private data : 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 set private data : result(%d)", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts set private data : result(%d)", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               tts_dbus_reconnect();
+               result = TTS_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
+
+int tts_dbus_request_get_private_data(int uid, const char* key, char** data)
+{
+       if (NULL == key || NULL == data) {
+               SLOG(LOG_ERROR, TAG_TTSC, "Input parameter is NULL");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
+
+       msg = __tts_dbus_make_message(uid, TTS_METHOD_GET_PRIVATE_DATA);
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts get private data : Fail to make message");
+               return TTS_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts get private data : uid(%d)", uid);
+       }
+
+       if (true != dbus_message_append_args(msg,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &key,
+               DBUS_TYPE_INVALID)) {
+               dbus_message_unref(msg);
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to append args");
+
+               return TTS_ERROR_OPERATION_FAILED;
+       }
+
+       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);
+       }
+
+       char* temp = NULL;
+       if (NULL != result_msg) {
+               dbus_message_get_args(result_msg, &err,
+                       DBUS_TYPE_INT32, &result,
+                       DBUS_TYPE_STRING, &temp,
+                       DBUS_TYPE_INVALID);
+
+               if (dbus_error_is_set(&err)) {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get private data : 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 private data : result(%d)", result);
+                       if (NULL != temp) {
+                               *data = strdup(temp);
+                               free(temp);
+                               temp = NULL;
+                       }
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts get private data : result(%d)", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               tts_dbus_reconnect();
+               result = TTS_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
+
 int tts_dbus_request_play(int uid)
 {
        DBusMessage* msg;
old mode 100755 (executable)
new mode 100644 (file)
index 4b4f834..deba016
@@ -42,6 +42,9 @@ int tts_dbus_request_stop(int uid);
 
 int tts_dbus_request_pause(int uid);
 
+int tts_dbus_request_set_private_data(int uid, const char* key, const char* data);
+
+int tts_dbus_request_get_private_data(int uid, const char* key, char** data);
 
 #ifdef __cplusplus
 }
index 625d302..5f97674 100644 (file)
@@ -57,6 +57,9 @@ extern "C" {
 #define TTS_METHOD_STOP                        "tts_method_stop"
 #define TTS_METHOD_PAUSE               "tts_method_pause"
 
+#define TTS_METHOD_SET_PRIVATE_DATA    "tts_method_set_private_data"
+#define TTS_METHOD_GET_PRIVATE_DATA    "tts_method_get_private_data"
+
 #define TTSD_METHOD_HELLO              "ttsd_method_hello"
 #define TTSD_METHOD_UTTERANCE_STARTED  "ttsd_method_utterance_started"
 #define TTSD_METHOD_UTTERANCE_COMPLETED        "ttsd_method_utterance_completed"
index c895f24..ed38d87 100644 (file)
@@ -373,6 +373,50 @@ int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, voi
 int tts_get_default_voice(tts_h tts, char** language, int* voice_type);
 
 /**
+ * @brief Sets the private data to tts engine.
+ * @since_tizen 3.0
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] key The field name of private data
+ * @param[in] data The data for set
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_READY.
+ *
+ * @see tts_get_private_data()
+*/
+int tts_set_private_data(tts_h tts, const char* key, const char* data);
+
+/**
+ * @brief Gets the private data from tts engine.
+ * @since_tizen 3.0
+ *
+ * @param[in] tts The TTS handle
+ * @param[in] key The field name of private data
+ * @param[out] data The data
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_STATE Invalid state
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ *
+ * @pre The state should be #TTS_STATE_READY.
+ *
+ * @see tts_set_private_data()
+*/
+int tts_get_private_data(tts_h tts, const char* key, char** data);
+
+/**
  * @brief Gets the maximum byte size for text.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
index 025d93d..630138b 100644 (file)
@@ -261,6 +261,12 @@ 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_PAUSE)) {
                ttsd_dbus_server_pause(g_conn_listener, msg);
 
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_SET_PRIVATE_DATA)) {
+               ttsd_dbus_server_set_private_data(g_conn_listener, msg);
+
+       } else if (dbus_message_is_method_call(msg, g_service_interface, TTS_METHOD_GET_PRIVATE_DATA)) {
+               ttsd_dbus_server_get_private_data(g_conn_listener, msg);
+
        } else {
                /* Invalid method */
        }
index fd11070..ed11f5f 100644 (file)
@@ -489,3 +489,114 @@ int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg)
 
        return 0;
 }
+
+int ttsd_dbus_server_set_private_data(DBusConnection* conn, DBusMessage* msg)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       int uid;
+       char* key;
+       char* data;
+       int ret = 0;
+       dbus_message_get_args(msg, &err,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &key,
+               DBUS_TYPE_STRING, &data,
+               DBUS_TYPE_INVALID);
+
+       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS set private data");
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
+               dbus_error_free(&err);
+               ret = TTSD_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, get_tag(), "[IN] tts set private data(%d)", uid);
+               ret = ttsd_server_set_private_data(uid, key, data);
+       }
+
+       DBusMessage* reply;
+       reply = dbus_message_new_method_return(msg);
+
+       if (NULL != reply) {
+               dbus_message_append_args(reply,
+                       DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_INVALID);
+
+               if (0 == ret) {
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts set private data : (%d)", ret);
+               } else {
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts set private data : (%d)", ret);
+               }
+
+               if (!dbus_connection_send(conn, reply, NULL)) {
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to send reply");
+               }
+
+               dbus_connection_flush(conn);
+               dbus_message_unref(reply);
+       } else {
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message");
+       }
+
+       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, get_tag(), "");
+
+       return 0;
+}
+
+int ttsd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       int uid;
+       char* key;
+       char* data;
+       int ret = 0;
+       dbus_message_get_args(msg, &err,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_STRING, &key,
+               DBUS_TYPE_INVALID);
+
+       SLOG(LOG_DEBUG, get_tag(), ">>>>> TTS get private data");
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, get_tag(), "[IN ERROR] Fail to get arguments (%s)", err.message);
+               dbus_error_free(&err);
+               ret = TTSD_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, get_tag(), "[IN] tts get private data(%d)", uid);
+               ret = ttsd_server_get_private_data(uid, key, &data);
+       }
+
+       DBusMessage* reply;
+       reply = dbus_message_new_method_return(msg);
+
+       if (NULL != reply) {
+               dbus_message_append_args(reply,
+                       DBUS_TYPE_INT32, &ret,
+                       DBUS_TYPE_INVALID);
+
+               if (0 == ret) {
+                       SLOG(LOG_DEBUG, get_tag(), "[OUT] tts get private data : (%d)", ret);
+               } else {
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] tts get private data : (%d)", ret);
+               }
+
+               if (!dbus_connection_send(conn, reply, NULL)) {
+                       SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to send reply");
+               }
+
+               dbus_connection_flush(conn);
+               dbus_message_unref(reply);
+       } else {
+               SLOG(LOG_ERROR, get_tag(), "[OUT ERROR] Fail to create reply message");
+       }
+
+       SLOG(LOG_DEBUG, get_tag(), "<<<<<");
+       SLOG(LOG_DEBUG, get_tag(), "");
+
+       return 0;
+}
index 04a5e3a..c316820 100644 (file)
@@ -43,6 +43,9 @@ int ttsd_dbus_server_stop(DBusConnection* conn, DBusMessage* msg);
 
 int ttsd_dbus_server_pause(DBusConnection* conn, DBusMessage* msg);
 
+int ttsd_dbus_server_set_private_data(DBusConnection* conn, DBusMessage* msg);
+
+int ttsd_dbus_server_get_private_data(DBusConnection* conn, DBusMessage* msg);
 
 #ifdef __cplusplus
 }
old mode 100755 (executable)
new mode 100644 (file)
index 7196df6..c3d794c
@@ -1565,6 +1565,69 @@ int ttsd_engine_get_default_voice(char** lang, int* vctype)
        return 0;
 }
 
+int ttsd_engine_set_private_data(const char* key, const char* data)
+{
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       if (false == g_cur_engine.is_loaded) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       if (NULL == key) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Invalid parameter");
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == g_cur_engine.pefuncs->set_private_data) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not supported feature");
+               return TTSD_ERROR_NOT_SUPPORTED_FEATURE;
+       }
+
+       int ret = 0;
+       ret = g_cur_engine.pefuncs->set_private_data(key, data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to set private data(%d)", ret);
+       }
+
+       return ret;
+}
+
+int ttsd_engine_get_private_data(const char* key, char** data)
+{
+       if (false == g_agent_init) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not Initialized");
+               return TTSD_ERROR_OPERATION_FAILED;
+       }
+
+       if (false == g_cur_engine.is_loaded) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] No loaded engine");
+               return TTSD_ERROR_ENGINE_NOT_FOUND;
+       }
+
+       if (NULL == key || NULL == data) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Invalid parameter");
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == g_cur_engine.pefuncs->get_private_data) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Not supported feature");
+               return TTSD_ERROR_NOT_SUPPORTED_FEATURE;
+       }
+
+       int ret = 0;
+       ret = g_cur_engine.pefuncs->get_private_data(key, data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Engine Agent ERROR] Fail to get private data(%d)", ret);
+       }
+
+       return ret;
+}
+
+
 void __free_voice_list(GList* voice_list)
 {
        GList *iter = NULL;
index 08f6fa4..21fac93 100644 (file)
@@ -60,6 +60,10 @@ int ttsd_engine_agent_set_default_speed(int speed);
 
 int ttsd_engine_agent_set_default_pitch(int pitch);
 
+int ttsd_engine_set_private_data(const char* key, const char* data);
+
+int ttsd_engine_get_private_data(const char* key, char** data);
+
 /*
 * TTS Engine Interfaces for client
 */
old mode 100755 (executable)
new mode 100644 (file)
index ef8f98e..03df745
@@ -37,19 +37,20 @@ extern "C" {
 #define ENGINE_AGENT_DEBUG
 
 typedef enum {
-       TTSD_ERROR_NONE                 = TIZEN_ERROR_NONE,             /**< Successful */
-       TTSD_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
-       TTSD_ERROR_IO_ERROR             = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
-       TTSD_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
-       TTSD_ERROR_OUT_OF_NETWORK       = TIZEN_ERROR_NETWORK_DOWN,     /**< Out of network */
-       TTSD_ERROR_TIMED_OUT            = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
-       TTSD_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
-       TTSD_ERROR_NOT_SUPPORTED        = TIZEN_ERROR_NOT_SUPPORTED,    /**< TTS NOT supported */
-       TTSD_ERROR_INVALID_STATE        = TIZEN_ERROR_TTS | 0x01,       /**< Invalid state */
-       TTSD_ERROR_INVALID_VOICE        = TIZEN_ERROR_TTS | 0x02,       /**< Invalid voice */
-       TTSD_ERROR_ENGINE_NOT_FOUND     = TIZEN_ERROR_TTS | 0x03,       /**< No available engine */
-       TTSD_ERROR_OPERATION_FAILED     = TIZEN_ERROR_TTS | 0x04,       /**< Operation failed */
-       TTSD_ERROR_AUDIO_POLICY_BLOCKED = TIZEN_ERROR_TTS | 0x05        /**< Audio policy blocked */
+       TTSD_ERROR_NONE                         = TIZEN_ERROR_NONE,             /**< Successful */
+       TTSD_ERROR_OUT_OF_MEMORY                = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of Memory */
+       TTSD_ERROR_IO_ERROR                     = TIZEN_ERROR_IO_ERROR,         /**< I/O error */
+       TTSD_ERROR_INVALID_PARAMETER            = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
+       TTSD_ERROR_OUT_OF_NETWORK               = TIZEN_ERROR_NETWORK_DOWN,     /**< Out of network */
+       TTSD_ERROR_TIMED_OUT                    = TIZEN_ERROR_TIMED_OUT,        /**< No answer from the daemon */
+       TTSD_ERROR_PERMISSION_DENIED            = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
+       TTSD_ERROR_NOT_SUPPORTED                = TIZEN_ERROR_NOT_SUPPORTED,    /**< TTS NOT supported */
+       TTSD_ERROR_INVALID_STATE                = TIZEN_ERROR_TTS | 0x01,       /**< Invalid state */
+       TTSD_ERROR_INVALID_VOICE                = TIZEN_ERROR_TTS | 0x02,       /**< Invalid voice */
+       TTSD_ERROR_ENGINE_NOT_FOUND             = TIZEN_ERROR_TTS | 0x03,       /**< No available engine */
+       TTSD_ERROR_OPERATION_FAILED             = TIZEN_ERROR_TTS | 0x04,       /**< Operation failed */
+       TTSD_ERROR_AUDIO_POLICY_BLOCKED         = TIZEN_ERROR_TTS | 0x05,       /**< Audio policy blocked */
+       TTSD_ERROR_NOT_SUPPORTED_FEATURE        = TIZEN_ERROR_TTS | 0x06        /**< Not supported feature */
 } ttsd_error_e;
 
 typedef enum {
index ad0e6cc..5d7f152 100644 (file)
@@ -928,3 +928,49 @@ int ttsd_server_get_current_voice(int uid, char** language, int* voice_type)
 
        return TTSD_ERROR_NONE;
 }
+
+int ttsd_server_set_private_data(int uid, const char* key, const char* data)
+{
+       app_state_e state;
+       if (0 > ttsd_data_get_client_state(uid, &state)) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid", uid);
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (APP_STATE_READY != state) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Current state(%d) is NOT 'READY'", uid);
+               return TTSD_ERROR_INVALID_STATE;
+       }
+
+       int ret = ttsd_engine_set_private_data(key, data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to set private data");
+       } else {
+               SLOG(LOG_DEBUG, get_tag(), "[Server] Set private data");
+       }
+
+       return ret;
+}
+
+int ttsd_server_get_private_data(int uid, const char* key, char** data)
+{
+       app_state_e state;
+       if (0 > ttsd_data_get_client_state(uid, &state)) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] uid(%d) is NOT valid", uid);
+               return TTSD_ERROR_INVALID_PARAMETER;
+       }
+
+       if (APP_STATE_READY != state) {
+               SLOG(LOG_WARN, get_tag(), "[Server ERROR] Current state(%d) is NOT 'READY'", uid);
+               return TTSD_ERROR_INVALID_STATE;
+       }
+
+       int ret = ttsd_engine_get_private_data(key, data);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, get_tag(), "[Server ERROR] Fail to get private data");
+       } else {
+               SLOG(LOG_DEBUG, get_tag(), "[Server] Get private data");
+       }
+
+       return ret;
+}
\ No newline at end of file
index 326667d..5f408a8 100644 (file)
@@ -51,6 +51,9 @@ int ttsd_server_stop(int uid);
 
 int ttsd_server_pause(int uid, int* utt_id);
 
+int ttsd_server_set_private_data(int uid, const char* key, const char* data);
+
+int ttsd_server_get_private_data(int uid, const char* key, char** data);
 
 #ifdef __cplusplus
 }
old mode 100755 (executable)
new mode 100644 (file)
index ecd4df3..911dabb
@@ -252,6 +252,38 @@ typedef int (*ttspe_start_synthesis)(const char* language, int type, const char*
 */
 typedef int (*ttspe_cancel_synthesis)(void);
 
+/**
+* @brief Set private data.
+* @since_tizen 3.0
+*
+* @param[in] key Key field of private data.
+* @param[in] data Data field of private data.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failed
+*
+* @see ttse_get_private_data()
+*/
+typedef int (* ttspe_set_private_data)(const char* key, const char* data);
+
+/**
+* @brief Get private data.
+* @since_tizen 3.0
+*
+* @param[out] key Key field of private data.
+* @param[out] data Data field of private data.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failed
+*
+* @see ttse_set_private_data()
+*/
+typedef int (* ttspe_get_private_data)(const char* key, char** data);
+
 
 /**
 * @brief Gets the mode.
@@ -315,6 +347,8 @@ typedef struct {
        /* Control synthesis */
        ttspe_start_synthesis           start_synth;            /**< Start synthesis */
        ttspe_cancel_synthesis          cancel_synth;           /**< Cancel synthesis */
+       ttspe_set_private_data          set_private_data;       /**< Set private data */
+       ttspe_get_private_data          get_private_data;       /**< Get private data */
 } ttspe_funcs_s;
 
 /**