Add interfaces for transfering service state
[platform/core/uifw/tts.git] / server / ttsd_dbus_server.c
index eb7ec0b..1915609 100644 (file)
@@ -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;
+}