Fix log characters
[platform/core/uifw/tts.git] / client / tts_dbus.c
index df39b69..519a53e 100644 (file)
@@ -136,9 +136,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                } /* TTSD_SIGNAL_ERROR */
 
                else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) {
-                       SLOG(LOG_DEBUG, TAG_TTSC, "===== Owner Changed");
+                       SLOG(LOG_DEBUG, TAG_TTSC, "@@@ Owner Changed");
                        __tts_cb_error(-1, TTS_ERROR_SERVICE_RESET, -1, "Daemon Reset");
-                       SLOG(LOG_DEBUG, TAG_TTSC, "=====");
+                       SLOG(LOG_DEBUG, TAG_TTSC, "@@@");
                        SLOG(LOG_DEBUG, TAG_TTSC, " ");
                } /* NameOwnerChanged */
 
@@ -936,3 +936,185 @@ int tts_dbus_request_pause(int uid)
 
        return result;
 }
+
+int tts_dbus_request_play_pcm(int uid)
+{
+       DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
+
+       msg = __tts_dbus_make_message(uid, TTS_METHOD_PLAY_PCM);
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts play pcm : Fail to make message");
+               return TTS_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts play pcm : uid(%d)", uid);
+       }
+
+       if (true != dbus_message_append_args(msg,
+               DBUS_TYPE_INT32, &uid,
+               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 play pcm : 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 play pcm : result(%d)", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts play pcm : 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_stop_pcm(int uid)
+{
+       DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
+
+       msg = __tts_dbus_make_message(uid, TTS_METHOD_STOP_PCM);
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts stop pcm : Fail to make message");
+               return TTS_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts stop pcm : uid(%d)", uid);
+       }
+
+       if (true != dbus_message_append_args(msg,
+               DBUS_TYPE_INT32, &uid,
+               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 stop pcm : 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 stop pcm : result(%d)", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts stop pcm : 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_add_pcm(int uid, int event, const char* data, int data_size, int audio_type, int rate)
+{
+       DBusMessage* msg;
+       DBusError err;
+       dbus_error_init(&err);
+
+       msg = __tts_dbus_make_message(uid, TTS_METHOD_ADD_PCM);
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_TTSC, ">>>> Request tts add pcm : Fail to make message");
+               return TTS_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_TTSC, ">>>> Request tts add pcm : uid(%d)", uid);
+       }
+
+       if (true != dbus_message_append_args(msg,
+               DBUS_TYPE_INT32, &uid,
+               DBUS_TYPE_INT32, &event,
+               DBUS_TYPE_INT32, &audio_type,
+               DBUS_TYPE_INT32, &rate,
+               DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+               &data, data_size,
+               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 add pcm : 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 add pcm : result(%d)", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_TTSC, "<<<< tts add pcm : result(%d)", result);
+               }
+       } else {
+               SLOG(LOG_ERROR, TAG_TTSC, "<<<< Result message is NULL ");
+               tts_dbus_reconnect();
+               result = TTS_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}