[tracker/dbus-fd-experiment: 10/15] Steroids: Simplify update



commit d0620c1b664b7290e779c91a34c96ef27190d9c2
Author: Adrien Bustany <abustany gnome org>
Date:   Wed Jun 2 12:57:02 2010 -0400

    Steroids: Simplify update
    
    This command changes the way updates are done using DBus FD passing.
    Instead of doing first a Prepare call and then get a FD where to write
    the query, the client directly passes a FD to the server, and writes the
    query to it. This reduces the number of DBus roundtrips.

 data/dbus/tracker-steroids.xml       |   26 --
 src/libtracker-client/tracker.c      |   49 ++---
 src/tracker-store/Makefile.am        |    3 +-
 src/tracker-store/tracker-dbus.c     |   12 +-
 src/tracker-store/tracker-steroids.c |  458 +++++++++++++++++-----------------
 src/tracker-store/tracker-steroids.h |   23 +--
 6 files changed, 265 insertions(+), 306 deletions(-)
---
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index 43f5623..60d6cba 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -1659,11 +1659,11 @@ tracker_resources_sparql_update_fast (TrackerClient  *client,
 	TrackerClientPrivate *private;
 	DBusConnection *connection;
 	DBusMessage *message;
+	DBusMessageIter iter;
 	DBusMessage *reply;
 	DBusPendingCall *call;
-	guint query_id;
 	DBusError dbus_error;
-	int fd;
+	int pipefd[2];
 	char *query_size_buffer;
 	int query_len;
 	int query_index;
@@ -1673,43 +1673,30 @@ tracker_resources_sparql_update_fast (TrackerClient  *client,
 
 	private = TRACKER_CLIENT_GET_PRIVATE (client);
 
-	connection = dbus_g_connection_get_connection (private->connection);
-
-	dbus_error_init (&dbus_error);
-
-	message = dbus_message_new_method_call (TRACKER_STEROIDS_SERVICE,
-	                                        TRACKER_STEROIDS_PATH,
-	                                        TRACKER_STEROIDS_INTERFACE,
-	                                        "PrepareUpdate");
-	reply = dbus_connection_send_with_reply_and_block (connection,
-	                                                   message,
-	                                                   -1,
-	                                                   &dbus_error);
-	dbus_message_unref (message);
-
-	if (!reply) {
-		dbus_set_g_error (error, &dbus_error);
+	if (pipe (pipefd) < 0) {
+		g_set_error (error,
+		             TRACKER_CLIENT_ERROR,
+		             TRACKER_CLIENT_ERROR_UNSUPPORTED,
+		             "Cannot open pipe");
 		return;
 	}
 
-	dbus_message_get_args (reply,
-	                       &dbus_error,
-	                       DBUS_TYPE_UNIX_FD, &fd,
-	                       DBUS_TYPE_UINT32,  &query_id,
-	                       DBUS_TYPE_INVALID);
-	dbus_message_unref (reply);
+	connection = dbus_g_connection_get_connection (private->connection);
+
+	dbus_error_init (&dbus_error);
 
 	message = dbus_message_new_method_call (TRACKER_STEROIDS_SERVICE,
 	                                        TRACKER_STEROIDS_PATH,
 	                                        TRACKER_STEROIDS_INTERFACE,
 	                                        "Update");
-	dbus_message_append_args (message,
-	                          DBUS_TYPE_UINT32, &query_id,
-	                          DBUS_TYPE_INVALID);
+	dbus_message_iter_init_append (message, &iter);
+	dbus_message_iter_append_basic (&iter, DBUS_TYPE_UNIX_FD, &pipefd[0]);
 	dbus_connection_send_with_reply (connection,
 	                                 message,
 	                                 &call,
 	                                 -1);
+	dbus_message_unref (message);
+	close (pipefd[0]);
 
 	if (!call) {
 		g_set_error (error,
@@ -1726,19 +1713,21 @@ tracker_resources_sparql_update_fast (TrackerClient  *client,
 	query_index = 0;
 	buffer_write_int (query_size_buffer, query_len);
 
-	pipe_write (fd, query_size_buffer, sizeof (int));
+	pipe_write (pipefd[1], query_size_buffer, sizeof (int));
 
 	if ((sizeof (int) + query_len) > TRACKER_STEROIDS_BUFFER_SIZE) {
-		pipe_write (fd, query, TRACKER_STEROIDS_BUFFER_SIZE - sizeof (int));
+		pipe_write (pipefd[1], query, TRACKER_STEROIDS_BUFFER_SIZE - sizeof (int));
 		query_index += TRACKER_STEROIDS_BUFFER_SIZE - sizeof (int);
 	}
 
 	while (query_index < query_len) {
 		int to_send = MIN(TRACKER_STEROIDS_BUFFER_SIZE, query_len - query_index);
-		pipe_write (fd, query + query_index, to_send);
+		pipe_write (pipefd[1], query + query_index, to_send);
 		query_index += to_send;
 	}
 
+	close (pipefd[1]);
+
 	g_free (query_size_buffer);
 
 	dbus_pending_call_block (call);
diff --git a/src/tracker-store/Makefile.am b/src/tracker-store/Makefile.am
index 305f2d7..a5b986f 100644
--- a/src/tracker-store/Makefile.am
+++ b/src/tracker-store/Makefile.am
@@ -90,8 +90,7 @@ dbus_sources = 								\
 	tracker-resources-glue.h					\
 	tracker-statistics-glue.h					\
 	tracker-resources-class-glue.h					\
-	tracker-status-glue.h						\
-	tracker-steroids-glue.h
+	tracker-status-glue.h
 
 tracker-marshal.h: tracker-marshal.list
 	$(AM_V_GEN)$(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --header > $@
diff --git a/src/tracker-store/tracker-dbus.c b/src/tracker-store/tracker-dbus.c
index 87df0e5..310f804 100644
--- a/src/tracker-store/tracker-dbus.c
+++ b/src/tracker-store/tracker-dbus.c
@@ -45,7 +45,6 @@
 
 #ifdef HAVE_DBUS_FD_PASSING
 #include "tracker-steroids.h"
-#include "tracker-steroids-glue.h"
 #endif
 
 static DBusGConnection *connection;
@@ -298,15 +297,14 @@ tracker_dbus_register_objects (void)
 	/* Add org.freedesktop.Tracker1.Steroids */
 	object = tracker_steroids_new ();
 	if (!object) {
-		g_critical ("Could net create TrackerSteroids object to register");
+		g_critical ("Could not create TrackerSteroids object to register");
 		return FALSE;
 	}
 
-	dbus_register_object (connection,
-	                      gproxy,
-	                      G_OBJECT (object),
-	                      &dbus_glib_tracker_steroids_object_info,
-	                      TRACKER_STEROIDS_PATH);
+	dbus_connection_add_filter (dbus_g_connection_get_connection (connection),
+	                            tracker_steroids_connection_filter,
+	                            object,
+	                            NULL);
 	objects = g_slist_prepend (objects, object);
 #endif
 
diff --git a/src/tracker-store/tracker-steroids.c b/src/tracker-store/tracker-steroids.c
index 1ff83e8..9456834 100644
--- a/src/tracker-store/tracker-steroids.c
+++ b/src/tracker-store/tracker-steroids.c
@@ -24,6 +24,9 @@
 #include "tracker-steroids.h"
 #include "tracker-store.h"
 
+#define DBUS_ERROR_UNKNOWN_METHOD_NAME "org.freedesktop.DBus.Error.UnknownMethod"
+#define DBUS_ERROR_UNKNOWN_METHOD_MESSAGE "Method \"%s\" with signature \"%s\" on interface \"%s\" doesn't exist"
+
 /**
  * /!\ IMPORTANT WARNING /!\
  *
@@ -44,12 +47,13 @@ typedef struct {
 
 typedef struct {
 	TrackerSteroids *parent;
+	DBusMessage *call_message;
 	char *query;
 	int fd;
 	unsigned int send_buffer_index;
 	char send_buffer[TRACKER_STEROIDS_BUFFER_SIZE];
 	guint request_id;
-	DBusGMethodInvocation *context;
+	DBusConnection *connection;
 } ClientInfo;
 
 typedef struct {
@@ -90,6 +94,9 @@ destroy_client_info (gpointer user_data)
 {
 	ClientInfo *info = user_data;
 
+	dbus_message_unref (info->call_message);
+	dbus_connection_unref (info->connection);
+
 	if (info->query) {
 		g_free (info->query);
 	}
@@ -189,48 +196,49 @@ query_callback (gpointer  inthread_data,
                 GError   *error,
                 gpointer  user_data)
 {
-	InThreadPtr *ptr  = inthread_data;
-	ClientInfo  *info = user_data;
-	TrackerSteroidsPrivate *priv = TRACKER_STEROIDS_GET_PRIVATE (info->parent);
-	DBusMessage *reply;
-
-	if (info->fd) {
-		close (info->fd);
-	}
-
-	if (ptr && ptr->error) {
-		/* Client is still there, but query failed */
-		tracker_dbus_request_failed (info->request_id,
-		                             info->context,
-		                             &ptr->error,
-		                             NULL);
-		dbus_g_method_return_error (info->context, ptr->error);
-		g_error_free (ptr->error);
-	} else if (error) {
-		/* Client has disappeared */
-		tracker_dbus_request_failed (info->request_id,
-		                             info->context,
-		                             &error,
-		                             NULL);
-		dbus_g_method_return_error (info->context, error);
-	} else {
-		tracker_dbus_request_success (info->request_id,
-		                              info->context);
-		reply = dbus_g_method_get_reply (info->context);
-		dbus_g_method_send_reply (info->context, reply);
-	}
-
-	if (ptr) {
-		g_slice_free (InThreadPtr, ptr);
-	}
-
-	g_hash_table_remove (priv->clients, info);
+//	InThreadPtr *ptr  = inthread_data;
+//	ClientInfo  *info = user_data;
+//	TrackerSteroidsPrivate *priv = TRACKER_STEROIDS_GET_PRIVATE (info->parent);
+//	DBusMessage *reply;
+//
+//	if (info->fd) {
+//		close (info->fd);
+//	}
+//
+//	if (ptr && ptr->error) {
+//		/* Client is still there, but query failed */
+//		tracker_dbus_request_failed (info->request_id,
+//		                             info->context,
+//		                             &ptr->error,
+//		                             NULL);
+//		dbus_g_method_return_error (info->context, ptr->error);
+//		g_error_free (ptr->error);
+//	} else if (error) {
+//		/* Client has disappeared */
+//		tracker_dbus_request_failed (info->request_id,
+//		                             info->context,
+//		                             &error,
+//		                             NULL);
+//		dbus_g_method_return_error (info->context, error);
+//	} else {
+//		tracker_dbus_request_success (info->request_id,
+//		                              info->context);
+//		reply = dbus_g_method_get_reply (info->context);
+//		dbus_g_method_send_reply (info->context, reply);
+//	}
+//
+//	if (ptr) {
+//		g_slice_free (InThreadPtr, ptr);
+//	}
+//
+//	g_hash_table_remove (priv->clients, info);
 }
 
 static void
 update_callback (GError *error, gpointer user_data)
 {
 	ClientInfo *info = user_data;
+	DBusMessage *reply;
 
 	if (info->fd) {
 		close (info->fd);
@@ -238,16 +246,22 @@ update_callback (GError *error, gpointer user_data)
 
 	if (error) {
 		tracker_dbus_request_failed (info->request_id,
-		                             info->context,
+		                             NULL,
 		                             &error,
 		                             NULL);
-		dbus_g_method_return_error (info->context, error);
+		reply = dbus_message_new_error (info->call_message,
+		                                TRACKER_STEROIDS_INTERFACE ".UpdateError",
+		                                error->message);
+		dbus_connection_send (info->connection, reply, NULL);
+		dbus_message_unref (reply);
 		return;
 	}
 
 	tracker_dbus_request_success (info->request_id,
-	                              info->context);
-	dbus_g_method_return (info->context);
+	                              NULL);
+	reply = dbus_message_new_method_return (info->call_message);
+	dbus_connection_send (info->connection, reply, NULL);
+	dbus_message_unref (reply);
 }
 
 static gpointer
@@ -379,221 +393,217 @@ query_inthread (TrackerDBCursor *cursor,
 	return ptr;
 }
 
-static ClientInfo*
-tracker_steroids_prepare (TrackerSteroids        *steroids,
-                          DBusGMethodInvocation  *context,
-                          gboolean                read,
-                          GError                **error)
+//static ClientInfo*
+//tracker_steroids_prepare (TrackerSteroids        *steroids,
+//                          DBusGMethodInvocation  *context,
+//                          gboolean                read,
+//                          GError                **error)
+//{
+//	TrackerSteroidsPrivate *priv = TRACKER_STEROIDS_GET_PRIVATE (steroids);
+//	guint                   request_id;
+//	gchar                  *sender;
+//	int                     pipefd[2];
+//	DBusMessage            *reply;
+//	DBusMessageIter         iter;
+//	GError *inner_error = NULL;
+//	ClientInfo             *info;
+//
+//	request_id = tracker_dbus_get_next_request_id ();
+//
+//	tracker_dbus_request_new (request_id,
+//	                          context,
+//	                          "%s()",
+//	                          __FUNCTION__);
+//
+//	if (pipe (pipefd) < 0) {
+//		g_set_error (&inner_error, TRACKER_DBUS_ERROR, 0, "Cannot open pipe");
+//
+//		tracker_dbus_request_failed (request_id,
+//		                             context,
+//		                             &inner_error,
+//		                             NULL);
+//		dbus_g_method_return_error (context, inner_error);
+//		g_propagate_error (error, inner_error);
+//
+//		return NULL;
+//	}
+//
+//	info = g_slice_new0 (ClientInfo);
+//	info->parent = steroids;
+//	info->fd = pipefd[1 - read];
+//
+//	sender = dbus_g_method_get_sender (context);
+//
+//	reply = dbus_g_method_get_reply (context);
+//
+//	dbus_message_iter_init_append (reply, &iter);
+//
+//	if (!dbus_message_iter_append_basic (&iter,
+//	                                     DBUS_TYPE_UNIX_FD,
+//	                                     &pipefd[read])) {
+//		g_critical ("FD passing not supported");
+//
+//		g_set_error (&inner_error, TRACKER_DBUS_ERROR, 0, "FD passing not supported");
+//
+//		tracker_dbus_request_failed (request_id,
+//		                             context,
+//		                             &inner_error,
+//		                             NULL);
+//		dbus_g_method_return_error (context, inner_error);
+//		g_propagate_error (error, inner_error);
+//
+//		g_slice_free (ClientInfo, info);
+//		g_free (sender);
+//		return NULL;
+//	}
+//
+//	dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &request_id);
+//
+//	g_hash_table_insert (priv->clients,
+//	                     GUINT_TO_POINTER (request_id),
+//	                     info);
+//
+//	tracker_dbus_request_success (request_id, context);
+//	dbus_g_method_send_reply (context, reply);
+//
+//	g_free (sender);
+//
+//	return info;
+//}
+
+static void
+tracker_steroids_fetch (TrackerSteroids *steroids,
+						DBusConnection  *connection,
+						DBusMessage     *message)
+{
+//	TrackerSteroidsPrivate *priv = TRACKER_STEROIDS_GET_PRIVATE (steroids);
+//	ClientInfo             *info;
+//	guint                   request_id;
+//	gchar                  *sender;
+//	GError                 *inner_error = NULL;
+//
+//	request_id = tracker_dbus_get_next_request_id ();
+//
+//	tracker_dbus_request_new (request_id,
+//	                          context,
+//	                          "%s(): %u",
+//	                          __FUNCTION__,
+//	                          query_id);
+//
+//	info = g_hash_table_lookup (priv->clients,
+//	                            GUINT_TO_POINTER (query_id));
+//
+//	if (!info) {
+//		g_set_error (&inner_error, TRACKER_DBUS_ERROR, 0, "Wrong query id");
+//		tracker_dbus_request_failed (request_id,
+//		                             context,
+//		                             &inner_error,
+//		                             NULL);
+//		dbus_g_method_return_error (info->context, inner_error);
+//		g_propagate_error (error, inner_error);
+//
+//		return;
+//	}
+//
+//	info->request_id = request_id;
+//	info->context = context;
+//
+//	sender = dbus_g_method_get_sender (context);
+//
+//	tracker_store_sparql_query (info->query, TRACKER_STORE_PRIORITY_HIGH,
+//	                            query_inthread, query_callback, sender,
+//	                            info, destroy_client_info);
+//
+//	g_free (sender);
+}
+
+static void
+tracker_steroids_update (TrackerSteroids *steroids,
+                         DBusConnection  *connection,
+                         DBusMessage     *message)
 {
-	TrackerSteroidsPrivate *priv = TRACKER_STEROIDS_GET_PRIVATE (steroids);
+	DBusError               dbus_error;
+	ClientInfo             *info;
 	guint                   request_id;
-	gchar                  *sender;
-	int                     pipefd[2];
+	const gchar            *sender;
+	static char             query_size_buffer[sizeof(int)];
+	int                     query_size;
 	DBusMessage            *reply;
-	DBusMessageIter         iter;
-	GError *inner_error = NULL;
-	ClientInfo             *info;
+
+	if (g_strcmp0 (dbus_message_get_signature (message), DBUS_TYPE_UNIX_FD_AS_STRING)) {
+		reply = dbus_message_new_error_printf (message,
+		                                       DBUS_ERROR_UNKNOWN_METHOD_NAME,
+		                                       DBUS_ERROR_UNKNOWN_METHOD_MESSAGE,
+		                                       "Update",
+		                                       dbus_message_get_signature (message),
+		                                       dbus_message_get_interface (message));
+		dbus_connection_send (connection, message, NULL);
+		dbus_message_unref (reply);
+		return;
+	}
 
 	request_id = tracker_dbus_get_next_request_id ();
 
 	tracker_dbus_request_new (request_id,
-	                          context,
+	                          NULL,
 	                          "%s()",
 	                          __FUNCTION__);
 
-	if (pipe (pipefd) < 0) {
-		g_set_error (&inner_error, TRACKER_DBUS_ERROR, 0, "Cannot open pipe");
-
-		tracker_dbus_request_failed (request_id,
-		                             context,
-		                             &inner_error,
-		                             NULL);
-		dbus_g_method_return_error (context, inner_error);
-		g_propagate_error (error, inner_error);
-
-		return NULL;
-	}
-
 	info = g_slice_new0 (ClientInfo);
 	info->parent = steroids;
-	info->fd = pipefd[1 - read];
-
-	sender = dbus_g_method_get_sender (context);
-
-	reply = dbus_g_method_get_reply (context);
+	info->connection = dbus_connection_ref (connection);
+	info->call_message = dbus_message_ref (message);
 
-	dbus_message_iter_init_append (reply, &iter);
+	dbus_error_init (&dbus_error);
 
-	if (!dbus_message_iter_append_basic (&iter,
-	                                     DBUS_TYPE_UNIX_FD,
-	                                     &pipefd[read])) {
-		g_critical ("FD passing not supported");
+	dbus_message_get_args (message,
+	                       &dbus_error,
+	                       DBUS_TYPE_UNIX_FD, &info->fd,
+	                       DBUS_TYPE_INVALID);
 
-		g_set_error (&inner_error, TRACKER_DBUS_ERROR, 0, "FD passing not supported");
-
-		tracker_dbus_request_failed (request_id,
-		                             context,
-		                             &inner_error,
-		                             NULL);
-		dbus_g_method_return_error (context, inner_error);
-		g_propagate_error (error, inner_error);
-
-		g_slice_free (ClientInfo, info);
-		g_free (sender);
-		return NULL;
-	}
-
-	dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &request_id);
-
-	g_hash_table_insert (priv->clients,
-	                     GUINT_TO_POINTER (request_id),
-	                     info);
-
-	tracker_dbus_request_success (request_id, context);
-	dbus_g_method_send_reply (context, reply);
+	info->request_id = request_id;
 
-	g_free (sender);
+	sender = dbus_message_get_sender (message);
 
-	return info;
-}
+	buffer_read (info->fd, query_size_buffer, sizeof (int));
+	query_size = buffer_read_int (query_size_buffer);
 
-void
-tracker_steroids_prepare_query (TrackerSteroids        *steroids,
-                                const char             *query,
-                                DBusGMethodInvocation  *context,
-                                GError                **error)
-{
-	ClientInfo *info;
-	GError *inner_error = NULL;
+	/* We malloc one more char to ensure string is 0 terminated */
+	info->query = g_malloc0 ((1 + query_size) * sizeof (char));
 
-	tracker_dbus_async_return_if_fail (query != NULL, context);
+	buffer_read (info->fd, info->query, query_size);
 
-	info = tracker_steroids_prepare (steroids, context, FALSE, &inner_error);
+	close (info->fd);
+	info->fd = 0;
 
-	if (!info) {
-		g_propagate_error (error, inner_error);
-	} else {
-		info->query = g_strdup (query);
-	}
+	tracker_store_sparql_update (info->query, TRACKER_STORE_PRIORITY_HIGH, FALSE,
+	                             update_callback, sender,
+	                             info, destroy_client_info);
 }
 
-void
-tracker_steroids_fetch (TrackerSteroids        *steroids,
-                        guint                   query_id,
-                        DBusGMethodInvocation  *context,
-                        GError                **error)
+DBusHandlerResult
+tracker_steroids_connection_filter (DBusConnection *connection,
+                                    DBusMessage    *message,
+                                    void           *user_data)
 {
-	TrackerSteroidsPrivate *priv = TRACKER_STEROIDS_GET_PRIVATE (steroids);
-	ClientInfo             *info;
-	guint                   request_id;
-	gchar                  *sender;
-	GError                 *inner_error = NULL;
-
-	request_id = tracker_dbus_get_next_request_id ();
+	TrackerSteroids *steroids = user_data;
 
-	tracker_dbus_request_new (request_id,
-	                          context,
-	                          "%s(): %u",
-	                          __FUNCTION__,
-	                          query_id);
-
-	info = g_hash_table_lookup (priv->clients,
-	                            GUINT_TO_POINTER (query_id));
-
-	if (!info) {
-		g_set_error (&inner_error, TRACKER_DBUS_ERROR, 0, "Wrong query id");
-		tracker_dbus_request_failed (request_id,
-		                             context,
-		                             &inner_error,
-		                             NULL);
-		dbus_g_method_return_error (info->context, inner_error);
-		g_propagate_error (error, inner_error);
+	g_return_val_if_fail (TRACKER_IS_STEROIDS (steroids), DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
 
-		return;
+	if (g_strcmp0 (TRACKER_STEROIDS_PATH, dbus_message_get_path (message))) {
+		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 	}
 
-	info->request_id = request_id;
-	info->context = context;
-
-	sender = dbus_g_method_get_sender (context);
-
-	tracker_store_sparql_query (info->query, TRACKER_STORE_PRIORITY_HIGH,
-	                            query_inthread, query_callback, sender,
-	                            info, destroy_client_info);
-
-	g_free (sender);
-}
-
-void
-tracker_steroids_prepare_update (TrackerSteroids        *steroids,
-                                 DBusGMethodInvocation  *context,
-                                 GError                **error)
-{
-	ClientInfo *info;
-	GError *inner_error = NULL;
-
-	info = tracker_steroids_prepare (steroids, context, TRUE, &inner_error);
-
-	if (!info) {
-		g_propagate_error (error, inner_error);
+	if (g_strcmp0 (TRACKER_STEROIDS_INTERFACE, dbus_message_get_interface (message))) {
+		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 	}
-}
 
-void
-tracker_steroids_update (TrackerSteroids        *steroids,
-                         guint                   query_id,
-                         DBusGMethodInvocation  *context,
-                         GError                **error)
-{
-	TrackerSteroidsPrivate *priv = TRACKER_STEROIDS_GET_PRIVATE (steroids);
-	ClientInfo             *info;
-	guint                   request_id;
-	gchar                  *sender;
-	static char             query_size_buffer[sizeof(int)];
-	int                     query_size;
-	GError                 *inner_error = NULL;
-
-	request_id = tracker_dbus_get_next_request_id ();
-
-	tracker_dbus_request_new (request_id,
-	                          context,
-	                          "%s(): %u",
-	                          __FUNCTION__,
-	                          query_id);
-
-	info = g_hash_table_lookup (priv->clients,
-	                            GUINT_TO_POINTER (query_id));
-
-	if (!info) {
-		g_set_error (&inner_error, TRACKER_DBUS_ERROR, 0, "Wrong query id");
-		tracker_dbus_request_failed (request_id,
-		                             context,
-		                             &inner_error,
-		                             NULL);
-		dbus_g_method_return_error (info->context, inner_error);
-		g_propagate_error (error, inner_error);
-
-		return;
+	if (!g_strcmp0 ("Update", dbus_message_get_member (message))) {
+		tracker_steroids_update (steroids, connection, message);
+		return DBUS_HANDLER_RESULT_HANDLED;
 	}
 
-	info->request_id = request_id;
-	info->context = context;
-
-	sender = dbus_g_method_get_sender (context);
-
-	buffer_read (info->fd, query_size_buffer, sizeof (int));
-	query_size = buffer_read_int (query_size_buffer);
-
-	/* We malloc one more char to ensure string is 0 terminated */
-	info->query = g_malloc0 ((1 + query_size) * sizeof (char));
-
-	buffer_read (info->fd, info->query, query_size);
-
-	tracker_store_sparql_update (info->query, TRACKER_STORE_PRIORITY_HIGH, FALSE,
-	                             update_callback, sender,
-	                             info, destroy_client_info);
-
-	g_free (sender);
+	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
 static void
diff --git a/src/tracker-store/tracker-steroids.h b/src/tracker-store/tracker-steroids.h
index d941cb6..3cfe2d1 100644
--- a/src/tracker-store/tracker-steroids.h
+++ b/src/tracker-store/tracker-steroids.h
@@ -55,22 +55,11 @@ struct TrackerSteroidsClass {
 	GObjectClass parent;
 };
 
-GType            tracker_steroids_get_type      (void) G_GNUC_CONST;
-TrackerSteroids* tracker_steroids_new           (void);
-void             tracker_steroids_prepare_query (TrackerSteroids        *steroids,
-                                                 const gchar            *query,
-                                                 DBusGMethodInvocation  *context,
-                                                 GError                **error);
-void             tracker_steroids_fetch         (TrackerSteroids        *steroids,
-                                                 guint                   query_id,
-                                                 DBusGMethodInvocation  *context,
-                                                 GError                **error);
-void             tracker_steroids_prepare_update (TrackerSteroids        *steroids,
-                                                  DBusGMethodInvocation  *context,
-                                                  GError                **error);
-void             tracker_steroids_update         (TrackerSteroids        *steroids,
-                                                  guint                   query_id,
-                                                  DBusGMethodInvocation  *context,
-                                                  GError                **error);
+GType            tracker_steroids_get_type (void) G_GNUC_CONST;
+TrackerSteroids* tracker_steroids_new      (void);
+DBusHandlerResult
+        tracker_steroids_connection_filter (DBusConnection *connection,
+                                            DBusMessage    *message,
+                                            void           *user_data);
 
 #endif /* __TRACKER_STEROIDS_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]