tracker r1314 - in branches/xesam-support: data src/trackerd



Author: pvanhoof
Date: Fri Apr 25 15:12:15 2008
New Revision: 1314
URL: http://svn.gnome.org/viewvc/tracker?rev=1314&view=rev

Log:
Changed the DBUS glib binding to use Async ops

Modified:
   branches/xesam-support/data/tracker-xesam-search.xml
   branches/xesam-support/src/trackerd/tracker-xesam-search.c
   branches/xesam-support/src/trackerd/tracker-xesam-search.h

Modified: branches/xesam-support/data/tracker-xesam-search.xml
==============================================================================
--- branches/xesam-support/data/tracker-xesam-search.xml	(original)
+++ branches/xesam-support/data/tracker-xesam-search.xml	Fri Apr 25 15:12:15 2008
@@ -7,11 +7,13 @@
   <interface name="org.freedesktop.xesam.Search">
 
     <method name="NewSession">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="session" direction="out" />
     </method>
 
 
     <method name="SetProperty">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="session" direction="in" />
       <arg type="s" name="prop" direction="in" />
       <arg type="v" name="val" direction="in" />
@@ -19,32 +21,38 @@
     </method>
 
     <method name="GetProperty">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="session" direction="in" />
       <arg type="s" name="prop" direction="in" />
       <arg type="v" name="value" direction="out" />
     </method>
 
     <method name="CloseSession">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="session" direction="in" />
     </method>
 
 
     <method name="NewSearch">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="session" direction="in" />
       <arg type="s" name="query_xml" direction="in" />
       <arg type="s" name="search" direction="out" />
     </method>
 
     <method name="StartSearch">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="search" direction="in" />
     </method>
 
     <method name="GetHitCount">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="search" direction="in" />
       <arg type="u" name="count" direction="out" />
     </method>
 
     <method name="GetHits">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="search" direction="in" />
       <arg type="u" name="count" direction="in" />
       <arg type="aav" name="hits" direction="out" />
@@ -52,6 +60,7 @@
 
 
     <method name="GetHitData">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="search" direction="in" />
       <arg type="au" name="hit_ids" direction="in" />
       <arg type="as" name="fields" direction="in" />
@@ -59,10 +68,12 @@
     </method>
 
     <method name="CloseSearch">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="s" name="search" direction="in" />
     </method>
 
     <method name="GetState">
+      <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
       <arg type="as" name="state_info" direction="out" />
     </method>
 

Modified: branches/xesam-support/src/trackerd/tracker-xesam-search.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-search.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-search.c	Fri Apr 25 15:12:15 2008
@@ -168,211 +168,337 @@
  * Functions
  */
 
-gboolean 
-tracker_xesam_search_new_session (TrackerXesamSearch   *object,
-				  gchar               **session_id,
-				  GError              **error)
+void 
+tracker_xesam_search_new_session (TrackerXesamSearch   *object, DBusGMethodInvocation *context)
 {
+	gchar *session_id = NULL;
 	guint request_id = tracker_dbus_get_next_request_id ();
+	GError *error = NULL;
+
+	/** We need this to link sessions to NameOwnerChanged events ... :-\
+	  * sender = dbus_g_method_get_sender (context); */
+
+	tracker_xesam_create_session (object, &session_id, &error);
 
-	tracker_xesam_create_session (object, session_id, error);
+	if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
+	} else {
+		dbus_g_method_return (context, session_id);
+		g_free (session_id);
+	}
 
 	tracker_dbus_request_success (request_id);
 
-	return (error?*error == NULL:TRUE);
 }
 
 
-gboolean 
+void 
 tracker_xesam_search_close_session (TrackerXesamSearch  *object,
 				    const gchar         *session_id,
-				    GError             **error)
+				    DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
+	GError *error = NULL;
 
-	tracker_xesam_search_close_session_interal (session_id, error);
+	tracker_xesam_search_close_session_interal (session_id, &error);
 
-	tracker_dbus_request_success (request_id);
+	if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
+	} else
+		dbus_g_method_return (context);
 
-	return (error?*error == NULL:TRUE);
+	tracker_dbus_request_success (request_id);
 }
 
 
-gboolean 
+void 
 tracker_xesam_search_set_property (TrackerXesamSearch   *object,
 				  const gchar         *session_id,
 				  const gchar         *prop,
-				  GValue              *val,  /* not sure */
-				  GValue             **new_val,  /* not sure */
-				  GError             **error)
+				  GValue              *val, 
+				  DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
-	TrackerXesamSession *session = tracker_xesam_get_session (session_id, error);
+	GError *error = NULL;
+	TrackerXesamSession *session = tracker_xesam_get_session (session_id, &error);
 
 	if (session) {
-		tracker_xesam_session_set_property (session, prop, val, new_val, error);
+		GValue *new_val = NULL;
+		tracker_xesam_session_set_property (session, prop, val, &new_val, &error);
+
+		if (error) {
+			dbus_g_method_return_error (context, error);
+			g_error_free (error);
+		} else if (new_val) {
+			dbus_g_method_return (context, new_val);
+			g_value_unset (new_val);
+		}
+
 		g_object_unref (session);
+	} else if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
 	}
 
 	tracker_dbus_request_success (request_id);
 
-	return (error?*error == NULL:TRUE);
 }
 
-gboolean 
+void
 tracker_xesam_search_get_property (TrackerXesamSearch  *object,
 				   const gchar         *session_id,
 				   const gchar         *prop,
-				   GValue             **value,  /* not sure */
-				   GError             **error)
+				   DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
-	TrackerXesamSession *session = tracker_xesam_get_session (session_id, error);
+	GError *error = NULL;
+	TrackerXesamSession *session = tracker_xesam_get_session (session_id, &error);
 
 	if (session) {
-		tracker_xesam_session_get_property (session, prop, value, error);
+		GValue *value = NULL;
+		tracker_xesam_session_get_property (session, prop, &value, &error);
+
+		if (error) {
+			dbus_g_method_return_error (context, error);
+			g_error_free (error);
+		} else {
+			dbus_g_method_return (context, value);
+			g_value_unset (value);
+		}
+
 		g_object_unref (session);
+	} else if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
 	}
 
 	tracker_dbus_request_success (request_id);
 
-	return (error?*error == NULL:TRUE);
+	return;
 }
 
 
-gboolean 
+void
 tracker_xesam_search_new_search (TrackerXesamSearch  *object,
 				 const gchar         *session_id,
 				 const gchar         *query_xml,
-				 gchar              **search_id,
-				 GError             **error)
+				 DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
-	TrackerXesamSession *session = tracker_xesam_get_session (session_id, error);
+	GError *error = NULL;
+	TrackerXesamSession *session = tracker_xesam_get_session (session_id, &error);
 
 	if (session) {
 		TrackerXesamLiveSearch *search;
-		search = tracker_xesam_session_create_search (session, query_xml, search_id, error);
+		gchar *search_id = NULL;
+		search = tracker_xesam_session_create_search (session, query_xml, &search_id, &error);
 
 		if (search)
 			g_object_unref (search);
 
+		if (error) {
+			dbus_g_method_return_error (context, error);
+			g_error_free (error);
+		} else {
+			dbus_g_method_return (context, search_id);
+			g_free (search_id);
+		}
+
 		g_object_unref (session);
+	} else if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
 	}
 
 	tracker_dbus_request_success (request_id);
 
-	return (error?*error == NULL:TRUE);
 }
 
-gboolean 
+void
 tracker_xesam_search_start_search (TrackerXesamSearch  *object,
 				   const gchar         *search_id,
-				   GError             **error)
+				   DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
-	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, error);
+	GError *error = NULL;
+	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, &error);
 
 	if (search) {
-		tracker_xesam_live_search_activate (search, error);
+		tracker_xesam_live_search_activate (search, &error);
+
+		if (error) {
+			dbus_g_method_return_error (context, error);
+			g_error_free (error);
+		} else
+			dbus_g_method_return (context);
+
 		g_object_unref (search);
+	} else if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
 	}
 
 	tracker_dbus_request_success (request_id);
-
-	return (error?*error == NULL:TRUE);
 }
 
-gboolean 
+void
 tracker_xesam_search_get_hit_count (TrackerXesamSearch  *object,
 				    const gchar         *search_id,
-				    guint               *count,
-				    GError             **error)
+				    DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
-	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, error);
+	GError *error = NULL;
+	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, &error);
 
 	if (search) {
-		tracker_xesam_live_search_get_hit_count (search, count, error);
+		guint count = -1;
+		tracker_xesam_live_search_get_hit_count (search, &count, &error);
+
+		if (error) {
+			dbus_g_method_return_error (context, error);
+			g_error_free (error);
+		} else
+			dbus_g_method_return (context, count);
+
 		g_object_unref (search);
+
+	} else if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
 	}
 
 	tracker_dbus_request_success (request_id);
 
-	return (error?*error == NULL:TRUE);
 }
 
-gboolean 
+inline static void
+unsetvalue (gpointer data, gpointer user_data)
+{
+	g_value_unset (data);
+}
+
+inline static void 
+foreach_hits_data (gpointer hits_data, gpointer user_data)
+{
+	g_ptr_array_foreach ((GPtrArray *) hits_data, unsetvalue, NULL);
+}
+
+inline static void
+freeup_hits_data (GPtrArray *hits_data)
+{
+	g_ptr_array_foreach (hits_data, foreach_hits_data, NULL);
+}
+
+void
 tracker_xesam_search_get_hits (TrackerXesamSearch  *object,
 			       const gchar         *search_id,
 			       guint                count,
-			       GPtrArray          **hits, /* not sure */
-			       GError             **error)
+			       DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
-	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, error);
+	GError *error = NULL;
+	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, &error);
 
 	if (search) {
-		tracker_xesam_live_search_get_hits (search, count, hits, error);
+		GPtrArray *hits = NULL;
+		tracker_xesam_live_search_get_hits (search, count, &hits, &error);
+
+		if (error) {
+			dbus_g_method_return_error (context, error);
+			g_error_free (error);
+		} else {
+			dbus_g_method_return (context, hits);
+			freeup_hits_data (hits);
+		}
+
 		g_object_unref (search);
+	} else if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
 	}
 
 	tracker_dbus_request_success (request_id);
-
-	return (error?*error == NULL:TRUE);
 }
 
-gboolean 
+void 
 tracker_xesam_search_get_hit_data (TrackerXesamSearch  *object,
 				   const gchar         *search_id,
 				   GArray              *hit_ids, /* not sure */
 				   GStrv                fields, 
-				   GPtrArray          **hit_data, /* not sure */
-				   GError             **error)
+				   DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
-	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, error);
+	GError *error = NULL;
+	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, &error);
 
 	if (search) {
-		tracker_xesam_live_search_get_hit_data (search, hit_ids, fields, hit_data, error);
+		GPtrArray *hit_data = NULL;
+		tracker_xesam_live_search_get_hit_data (search, hit_ids, fields, &hit_data, &error);
+
+		if (error) {
+			dbus_g_method_return_error (context, error);
+			g_error_free (error);
+		} else {
+			dbus_g_method_return (context, hit_data);
+			freeup_hits_data (hit_data);
+		}
+
+
 		g_object_unref (search);
+	} else if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
 	}
 
 	tracker_dbus_request_success (request_id);
 
-	return (error == NULL);
 }
 
-gboolean 
+void 
 tracker_xesam_search_close_search (TrackerXesamSearch  *object,
 				   const gchar         *search_id,
-				   GError             **error)
+				   DBusGMethodInvocation *context)
 {
 	guint request_id = tracker_dbus_get_next_request_id ();
-	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, error);
+	GError *error = NULL;
+	TrackerXesamLiveSearch *search = tracker_xesam_get_live_search (search_id, &error);
 
 	if (search) {
-		tracker_xesam_live_search_close (search, error);
+		tracker_xesam_live_search_close (search, &error);
+
+		if (error) {
+			dbus_g_method_return_error (context, error);
+			g_error_free (error);
+		} else
+			dbus_g_method_return (context);
+
 		g_object_unref (search);
+	} else if (error) {
+		dbus_g_method_return_error (context, error);
+		g_error_free (error);
 	}
 
 	tracker_dbus_request_success (request_id);
 
-	return (error?*error == NULL:TRUE);
 }
 
-gboolean 
+void 
 tracker_xesam_search_get_state (TrackerXesamSearch   *object,
-				GStrv                *state_info, /* not sure */
-				GError              **error)
+				DBusGMethodInvocation *context)
 {
-	if (state_info) {
-		gchar **state = g_malloc (sizeof (gchar *) * 1);
-		state[0] = g_strdup (tracker_status_get_as_string ());
-		*state_info = state;
-	}
+	guint request_id = tracker_dbus_get_next_request_id ();
+	GStrv state_info;
+	gchar **state = g_malloc (sizeof (gchar *) * 1);
+
+	state[0] = g_strdup (tracker_status_get_as_string ());
+
+	dbus_g_method_return (context, state_info);
 
-	return TRUE;
+	g_strfreev (state_info);
+
+	tracker_dbus_request_success (request_id);
 }
 
 /**

Modified: branches/xesam-support/src/trackerd/tracker-xesam-search.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-search.h	(original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-search.h	Fri Apr 25 15:12:15 2008
@@ -73,52 +73,44 @@
          tracker_xesam_search_new              (void);
 
 
-gboolean tracker_xesam_search_new_session      (TrackerXesamSearch   *object,
-						gchar               **session,
-						GError              **error);
-gboolean tracker_xesam_search_set_property     (TrackerXesamSearch   *object,
+void     tracker_xesam_search_new_session      (TrackerXesamSearch   *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_set_property     (TrackerXesamSearch   *object,
 						const gchar         *session_id,
 						const gchar         *prop,
 						GValue              *val,  /* not sure */
-						GValue             **new_val,  /* not sure */
-						GError             **error);
-gboolean tracker_xesam_search_get_property     (TrackerXesamSearch  *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_get_property     (TrackerXesamSearch  *object,
 						const gchar         *session_id,
 						const gchar         *prop,
-						GValue             **value,  /* not sure */
-						GError             **error);
-gboolean tracker_xesam_search_close_session    (TrackerXesamSearch  *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_close_session    (TrackerXesamSearch  *object,
 						const gchar         *session_id,
-						GError             **error);
-gboolean tracker_xesam_search_new_search       (TrackerXesamSearch  *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_new_search       (TrackerXesamSearch  *object,
 						const gchar         *session_id,
 						const gchar         *query_xml,
-						gchar              **search_id,
-						GError             **error);
-gboolean tracker_xesam_search_start_search     (TrackerXesamSearch  *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_start_search     (TrackerXesamSearch  *object,
 						const gchar         *search_id,
-						GError             **error);
-gboolean tracker_xesam_search_get_hit_count    (TrackerXesamSearch  *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_get_hit_count    (TrackerXesamSearch  *object,
 						const gchar         *search_id,
-						guint               *count,
-						GError             **error);
-gboolean tracker_xesam_search_get_hits        (TrackerXesamSearch  *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_get_hits        (TrackerXesamSearch  *object,
 						const gchar         *search_id,
 						guint                count,
-						GPtrArray          **hits, /* not sure */
-						GError             **error);
-gboolean tracker_xesam_search_get_hit_data     (TrackerXesamSearch  *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_get_hit_data     (TrackerXesamSearch  *object,
 						const gchar         *search_id,
 						GArray              *hit_ids,  /* not sure */
 						GStrv               fields, 
-						GPtrArray          **hit_data, /* not sure */
-						GError             **error);
-gboolean tracker_xesam_search_close_search     (TrackerXesamSearch  *object,
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_close_search     (TrackerXesamSearch  *object,
 						const gchar         *search_id,
-						GError             **error);
-gboolean tracker_xesam_search_get_state       (TrackerXesamSearch   *object,
-						GStrv               *state_info, /* not sure */
-						GError             **error);
+					        DBusGMethodInvocation *context);
+void     tracker_xesam_search_get_state       (TrackerXesamSearch   *object,
+					        DBusGMethodInvocation *context);
 
 
 void tracker_xesam_search_emit_state_changed (TrackerXesamSearch *self, GStrv state_info);



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