Add function to get error message 55/69955/3 accepted/tizen/common/20160518.125015 accepted/tizen/ivi/20160518.090504 accepted/tizen/mobile/20160518.090447 accepted/tizen/tv/20160518.090445 accepted/tizen/wearable/20160518.090436 submit/tizen/20160518.015203
authorWonnam Jang <wn.jang@samsung.com>
Tue, 17 May 2016 10:43:32 +0000 (19:43 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Tue, 17 May 2016 11:00:32 +0000 (20:00 +0900)
Change-Id: I62061aa8bb9a4fca04d096ba08f30f7c30db9eb9
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
client/tts.c [changed mode: 0755->0644]
client/tts_client.h [changed mode: 0755->0644]
client/tts_dbus.c
include/tts.h [changed mode: 0755->0644]
server/ttsd_dbus.c
server/ttsd_dbus.h

old mode 100755 (executable)
new mode 100644 (file)
index 2127439..5adac65
@@ -31,6 +31,8 @@ static bool g_screen_reader;
 
 static int g_feature_enabled = -1;
 
+static bool g_err_callback_status = false;
+
 /* Function definition */
 static Eina_Bool __tts_notify_state_changed(void *data);
 static Eina_Bool __tts_notify_error(void *data);
@@ -737,6 +739,37 @@ int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max)
        return TTS_ERROR_NONE;
 }
 
+int tts_get_error_message(tts_h tts, char** err_msg)
+{
+       if(0 != __tts_get_feature_enabled()) {
+               return TTS_ERROR_NOT_SUPPORTED;
+       }
+
+       if (NULL == tts || NULL == err_msg) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input parameter is null");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       tts_client_s* client = tts_client_get(tts);
+
+       if (NULL == client) {
+               SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Get state : A handle is not valid");
+               return TTS_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL != client->err_msg) {
+               *err_msg = strdup(client->err_msg);
+               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Error msg (%s)", *err_msg);
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Error msg (NULL)");
+       }
+
+       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+       SLOG(LOG_DEBUG, TAG_TTSC, " ");
+
+       return TTS_ERROR_NONE;
+}
+
 int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id)
 {
        if (0 != __tts_get_feature_enabled()) {
@@ -1399,7 +1432,9 @@ static Eina_Bool __tts_notify_error(void *data)
        if (NULL != client->error_cb) {
                SLOG(LOG_DEBUG, TAG_TTSC, "Call callback function of error");
                tts_client_use_callback(client);
+               g_err_callback_status = true;
                client->error_cb(client->tts, client->utt_id, client->reason, client->error_user_data);
+               g_err_callback_status = false;
                tts_client_not_use_callback(client);
        } else {
                SLOG(LOG_WARN, TAG_TTSC, "No registered callback function of error ");
@@ -1408,7 +1443,7 @@ static Eina_Bool __tts_notify_error(void *data)
        return EINA_FALSE;
 }
 
-int __tts_cb_error(int uid, tts_error_e reason, int utt_id)
+int __tts_cb_error(int uid, tts_error_e reason, int utt_id, char* err_msg)
 {
        tts_client_s* client = tts_client_get_by_uid(uid);
 
@@ -1419,6 +1454,11 @@ int __tts_cb_error(int uid, tts_error_e reason, int utt_id)
 
        client->utt_id = utt_id;
        client->reason = reason;
+       if (NULL != client->err_msg) {
+               free(client->err_msg);
+               client->err_msg = NULL;
+       }
+       client->err_msg = strdup(err_msg);
 
        /* call callback function */
        if (NULL != client->error_cb) {
old mode 100755 (executable)
new mode 100644 (file)
index 5a2520e..0ffd4b8
@@ -57,6 +57,7 @@ typedef struct {
        /* callback data */
        int             utt_id;
        int             reason;
+       char*           err_msg;
 
        /* connection */
        Ecore_Timer*    conn_timer;
index ffe5742..0008e75 100644 (file)
@@ -32,7 +32,7 @@ static DBusConnection* g_conn_listener = NULL;
 static Ecore_Fd_Handler* g_dbus_fd_handler = NULL;
 
 
-extern int __tts_cb_error(int uid, tts_error_e reason, int utt_id);
+extern int __tts_cb_error(int uid, tts_error_e reason, int utt_id, char *err_msg);
 
 extern int __tts_cb_set_state(int uid, int state);
 
@@ -115,20 +115,22 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                int uid;
                int uttid;
                int reason;
+               char* err_msg;
 
                dbus_message_get_args(msg, &err,
                        DBUS_TYPE_INT32, &uid,
                        DBUS_TYPE_INT32, &uttid,
                        DBUS_TYPE_INT32, &reason,
+                       DBUS_TYPE_INT32, &err_msg,
                        DBUS_TYPE_INVALID);
 
                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 { 
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< Get Error message : uid(%d), error(%d), uttid(%d), err_msg(%s)", uid, reason, uttid, (NULL == err_msg) ? "NULL" : err_msg);
+                       __tts_cb_error(uid, reason, uttid, err_msg);
 
-               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);
                }
        } /* TTSD_SIGNAL_ERROR */
 
old mode 100755 (executable)
new mode 100644 (file)
index b7c2073..c895f24
@@ -432,6 +432,27 @@ int tts_get_state(tts_h tts, tts_state_e* state);
 int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max);
 
 /**
+ * @brief Gets the current error message.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @remarks This function should be called during an tts error callback. If not, the error as operation failure will be returned. \n
+ * If the function succeeds, @a err_msg must be released using free() when it is no longer required.
+ *
+ * @param[in] tts The TTS handle
+ * @param[out] err_msg The current error message
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ *
+ * @see tts_set_error_cb()
+ * @see tts_unset_error_cb()
+*/
+int tts_get_error_message(tts_h tts, char** err_msg);
+
+/**
  * @brief Adds a text to the queue.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
index 3702575..025d93d 100644 (file)
@@ -172,7 +172,7 @@ int ttsdc_send_set_state_message(int pid, int uid, int state)
        return ttsdc_send_message(pid, uid, state, TTSD_METHOD_SET_STATE);
 }
 
-int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
+int ttsdc_send_error_message(int pid, int uid, int uttid, int reason, char* err_msg)
 {
        if (NULL == g_conn_sender) {
                SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] Dbus connection is not available");
@@ -193,9 +193,10 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
        }
 
        dbus_message_append_args(msg,
-               DBUS_TYPE_INT32, &uid, 
-               DBUS_TYPE_INT32, &uttid, 
-               DBUS_TYPE_INT32, &reason, 
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_INT32, &uttid,
+               DBUS_TYPE_INT32, &reason,
+               DBUS_TYPE_INT32, &err_msg,
                DBUS_TYPE_INVALID);
 
        dbus_message_set_no_reply(msg, TRUE);
@@ -203,8 +204,8 @@ int ttsdc_send_error_message(int pid, int uid, int uttid, int reason)
        if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, get_tag(), "[Dbus ERROR] <<<< error message : Out Of Memory !");
        } else {
-               SLOG(LOG_DEBUG, get_tag(), "<<<< Send error message : uid(%d), reason(%s), uttid(%d)",
-                        uid, __ttsd_get_error_code(reason), uttid);
+               SLOG(LOG_DEBUG, get_tag(), "<<<< Send error message : uid(%d), reason(%s), uttid(%d), err_msg(%d)",
+                        uid, __ttsd_get_error_code(reason), uttid, (NULL == err_msg) ? "NULL" : err_msg);
                dbus_connection_flush(g_conn_sender);
        }
 
index 478441e..4e95e17 100644 (file)
@@ -29,7 +29,7 @@ int ttsdc_send_utt_start_message(int pid, int uid, int uttid);
 
 int ttsdc_send_utt_finish_message(int pid, int uid, int uttid);
 
-int ttsdc_send_error_message(int pid, int uid, int uttid, int reason);
+int ttsdc_send_error_message(int pid, int uid, int uttid, int reason, char* err_msg);
 
 int ttsdc_send_set_state_message(int pid, int uid, int state);