tracker r3029 - in trunk: . src/libtracker-common src/libtracker-db



Author: mr
Date: Fri Mar  6 16:39:21 2009
New Revision: 3029
URL: http://svn.gnome.org/viewvc/tracker?rev=3029&view=rev

Log:
	* src/libtracker-db/tracker-db-dbus.c: Some code clean ups.

	* src/libtracker-common/tracker-thumbnailer.c: When we get an
	error from the thumbnailer, include the context so we know where
	the error came from.

	* src/libtracker-db/tracker-db-manager.c:
	(function_group_concat_step): Fixed my g_return_if_fail()
	change for the g_assert() which ottela added initially, logic was
	wrong way round.


Modified:
   trunk/ChangeLog
   trunk/src/libtracker-common/tracker-dbus.c
   trunk/src/libtracker-common/tracker-dbus.h
   trunk/src/libtracker-common/tracker-thumbnailer.c
   trunk/src/libtracker-db/tracker-db-dbus.c
   trunk/src/libtracker-db/tracker-db-dbus.h
   trunk/src/libtracker-db/tracker-db-manager.c

Modified: trunk/src/libtracker-common/tracker-dbus.c
==============================================================================
--- trunk/src/libtracker-common/tracker-dbus.c	(original)
+++ trunk/src/libtracker-common/tracker-dbus.c	Fri Mar  6 16:39:21 2009
@@ -128,6 +128,19 @@
 }
 
 gchar **
+tracker_dbus_str_to_strv (const gchar *str)
+{
+	gchar **strv;
+	
+	strv = g_new (gchar*, 2);
+	strv[0] = g_strdup (str);
+	strv[1] = NULL;
+	
+	return strv;
+}
+
+
+gchar **
 tracker_dbus_queue_str_to_strv (GQueue *queue,
 				gint	max)
 {

Modified: trunk/src/libtracker-common/tracker-dbus.h
==============================================================================
--- trunk/src/libtracker-common/tracker-dbus.h	(original)
+++ trunk/src/libtracker-common/tracker-dbus.h	Fri Mar  6 16:39:21 2009
@@ -91,6 +91,7 @@
 GValue *	 tracker_dbus_gvalue_slice_new	     (GType			  type);
 void		 tracker_dbus_gvalue_slice_free      (GValue			 *value);
 gchar **	 tracker_dbus_slist_to_strv	     (GSList			 *list);
+gchar **         tracker_dbus_str_to_strv            (const gchar                *str);
 gchar **	 tracker_dbus_queue_str_to_strv      (GQueue			 *queue,
 						      gint			  max);
 gchar **	 tracker_dbus_queue_gfile_to_strv    (GQueue			 *queue,

Modified: trunk/src/libtracker-common/tracker-thumbnailer.c
==============================================================================
--- trunk/src/libtracker-common/tracker-thumbnailer.c	(original)
+++ trunk/src/libtracker-common/tracker-thumbnailer.c	Fri Mar  6 16:39:21 2009
@@ -140,13 +140,14 @@
 	private->service_is_enabled = tracker_config_get_enable_thumbnails (private->config);
 
 	g_debug ("Thumbnailer service %s", 
-		   private->service_is_enabled ? "enabled" : "disabled");
+		 private->service_is_enabled ? "enabled" : "disabled");
 }
 
 static void
-thumbnailer_reply_cb (DBusGProxy     *proxy,
-		      DBusGProxyCall *call,
-		      gpointer	      user_data)
+thumbnailer_reply_handle (DBusGProxy     *proxy,
+			  DBusGProxyCall *call,
+			  guint           request_id,
+			  const gchar    *operation)
 {
 	GError *error = NULL;
 	guint	handle;
@@ -163,13 +164,48 @@
 			       G_TYPE_INVALID);
 
 	if (error) {
-		g_warning ("%s", error->message);
+		g_warning ("Thumbnailer %s failed for request ID:%d, %s", 
+			   operation,
+			   request_id,
+			   error->message);
 		g_error_free (error);
 		return;
 	}
 
-	g_debug ("Received response from thumbnailer, request ID:%d",
-	       GPOINTER_TO_UINT (user_data));
+	g_debug ("Thumbnailer response received for request ID:%d",
+		 request_id);
+}
+
+static void
+thumbnailer_reply_queue_cb (DBusGProxy     *proxy,
+			    DBusGProxyCall *call,
+			    gpointer	    user_data)
+{
+	thumbnailer_reply_handle (proxy, call, GPOINTER_TO_UINT (user_data), "queue");
+}
+
+static void
+thumbnailer_reply_move_cb (DBusGProxy     *proxy,
+			   DBusGProxyCall *call,
+			   gpointer	   user_data)
+{
+	thumbnailer_reply_handle (proxy, call, GPOINTER_TO_UINT (user_data), "move");
+}
+
+static void
+thumbnailer_reply_delete_cb (DBusGProxy     *proxy,
+			     DBusGProxyCall *call,
+			     gpointer	     user_data)
+{
+	thumbnailer_reply_handle (proxy, call, GPOINTER_TO_UINT (user_data), "delete");
+}
+
+static void
+thumbnailer_reply_cleanup_cb (DBusGProxy     *proxy,
+			      DBusGProxyCall *call,
+			      gpointer	      user_data)
+{
+	thumbnailer_reply_handle (proxy, call, GPOINTER_TO_UINT (user_data), "cleanup");
 }
 
 static gboolean
@@ -187,12 +223,12 @@
 	private->mime_types[private->count] = NULL;
 	
 	g_debug ("Sending request to thumbnailer to queue %d files, request ID:%d...", 
-		   private->count,
-		   private->request_id);
+		 private->count,
+		 private->request_id);
 	
 	dbus_g_proxy_begin_call (private->requester_proxy,
 				 "Queue",
-				 thumbnailer_reply_cb,
+				 thumbnailer_reply_queue_cb,
 				 GUINT_TO_POINTER (private->request_id), 
 				 NULL,
 				 G_TYPE_STRV, private->uris,
@@ -289,12 +325,12 @@
 	
 	if (error) {
 		g_debug ("Thumbnailer service did not return supported mime types, %s",
-			   error->message);
+			 error->message);
 
 		g_error_free (error);
 	} else if (mime_types) {
 		g_debug ("Thumbnailer supports %d mime types", 
-			   g_strv_length (mime_types));
+			 g_strv_length (mime_types));
 
 		private->supported_mime_types = mime_types;
 		private->service_is_available = TRUE;
@@ -340,24 +376,25 @@
 	private->request_id++;
 
 	g_debug ("Requesting thumbnailer moves URI from:'%s' to:'%s', request_id:%d...",
-		   from_uri,
-		   to_uri,
-		   private->request_id); 
+		 from_uri,
+		 to_uri,
+		 private->request_id); 
 
-	if (!strstr (to_uri, ":/"))
+	if (!strstr (to_uri, ":/")) {
 		to[0] = g_filename_to_uri (to_uri, NULL, NULL);
-	else
+	} else {
 		to[0] = g_strdup (to_uri);
+	}
 
-	if (!strstr (from_uri, ":/"))
+	if (!strstr (from_uri, ":/")) {
 		from[0] = g_filename_to_uri (from_uri, NULL, NULL);
-	else
+	} else {
 		from[0] = g_strdup (from_uri);
-
+	}
 	
 	dbus_g_proxy_begin_call (private->requester_proxy,
 				 "Move",
-				 thumbnailer_reply_cb,
+				 thumbnailer_reply_move_cb,
 				 GUINT_TO_POINTER (private->request_id), 
 				 NULL,
 				 G_TYPE_STRV, from,
@@ -366,7 +403,6 @@
 
 	g_free (from[0]);
 	g_free (to[0]);
-
 }
 
 void
@@ -400,18 +436,19 @@
 
 	private->request_id++;
 
-	if (!strstr (uri, ":/"))
+	if (!strstr (uri, ":/")) {
 		uris[0] = g_filename_to_uri (uri, NULL, NULL);
-	else
+	} else {
 		uris[0] = g_strdup (uri);
+	}
 
 	g_debug ("Requesting thumbnailer removes URI:'%s', request_id:%d...",
-		   uri,
-		   private->request_id); 
+		 uri,
+		 private->request_id); 
 	
 	dbus_g_proxy_begin_call (private->requester_proxy,
 				 "Delete",
-				 thumbnailer_reply_cb,
+				 thumbnailer_reply_delete_cb,
 				 GUINT_TO_POINTER (private->request_id),
 				 NULL,
 				 G_TYPE_STRV, uris,
@@ -439,12 +476,12 @@
 	private->request_id++;
 
 	g_debug ("Requesting thumbnailer cleanup URI:'%s', request_id:%d...",
-		   uri_prefix,
-		   private->request_id); 
+		 uri_prefix,
+		 private->request_id); 
 
 	dbus_g_proxy_begin_call (private->requester_proxy,
 				 "Cleanup",
-				 thumbnailer_reply_cb,
+				 thumbnailer_reply_cleanup_cb,
 				 GUINT_TO_POINTER (private->request_id),
 				 NULL,
 				 G_TYPE_STRING, uri_prefix,
@@ -479,8 +516,8 @@
 	private->request_id++;
 
 	g_debug ("Requesting thumbnailer to get thumbnail for URI:'%s', request_id:%d...",
-		   uri,
-		   private->request_id); 
+		 uri,
+		 private->request_id); 
 
 	/* We want to deal with the current list first if it is
 	 * already at the limit.
@@ -496,10 +533,11 @@
 	}
 
 	/* Add new URI (detect if we got passed a path) */
-	if (!strstr (uri, ":/"))
+	if (!strstr (uri, ":/")) {
 		private->uris[private->count] = g_filename_to_uri (uri, NULL, NULL);
-	else
+	} else {
 		private->uris[private->count] = g_strdup (uri);
+	}
 
 	if (mime_type) {
 		private->mime_types[private->count] = g_strdup (mime_type);

Modified: trunk/src/libtracker-db/tracker-db-dbus.c
==============================================================================
--- trunk/src/libtracker-db/tracker-db-dbus.c	(original)
+++ trunk/src/libtracker-db/tracker-db-dbus.c	Fri Mar  6 16:39:21 2009
@@ -35,28 +35,36 @@
 } OneElem;
 
 static inline void
-row_add (GPtrArray *row, gchar *value)
+row_add (GPtrArray *row, 
+	 gchar     *value)
 {
-	OneElem *elem = g_slice_new (OneElem);
+	OneElem *elem;
 	GSList  *list = NULL;
 
+	elem = g_slice_new (OneElem);
+	list = NULL;
+
 	list = g_slist_prepend (list, value);
 	elem->value = list;
 	g_ptr_array_add (row, elem);
 }
 
 static inline void
-row_insert (GPtrArray *row, gchar *value, guint lindex)
+row_insert (GPtrArray *row, 
+	    gchar     *value, 
+	    guint      lindex)
 {
-	OneElem *elem = g_ptr_array_index (row, lindex);
-	GSList  *list = elem->value;
+	OneElem *elem;
+	GSList  *list;
 	GSList  *iter;
 
+	elem = g_ptr_array_index (row, lindex);
+	list = elem->value;
+
 	/* We check for duplicate values here so that
 	 * we can have several multivalued fields in
 	 * the same query.
 	 */
-
 	for (iter = list; iter; iter=iter->next) {
 		if (strcmp (iter->data, value) == 0) {
 			return;
@@ -74,7 +82,7 @@
 
 	for (i = 0; i < row->len; i++) {
 		OneElem *elem;
-		GSList *list;
+		GSList  *list;
 
 		elem = g_ptr_array_index (row, i);
 		list = elem->value;
@@ -89,13 +97,17 @@
 }
 
 static inline gpointer
-rows_lookup (GPtrArray *rows, gint key)
+rows_lookup (GPtrArray *rows,
+	     gint       key)
 {
 	guint	 i;
 	gpointer value = NULL;
 
 	for (i = 0; i < rows->len; i++) {
-		OneRow *row = g_ptr_array_index (rows, i);
+		OneRow *row;
+
+		row = g_ptr_array_index (rows, i);
+
 		if (row->key == key) {
 			value = row->value;
 			break;
@@ -121,9 +133,13 @@
 }
 
 static inline void
-rows_add (GPtrArray *rows, gint key, gpointer value)
+rows_add (GPtrArray *rows, 
+	  gint       key, 
+	  gpointer   value)
 {
-	OneRow *row = g_slice_new (OneRow);
+	OneRow *row;
+
+	row = g_slice_new (OneRow);
 
 	row->key = key;
 	row->value = value;
@@ -132,15 +148,16 @@
 }
 
 static inline void
-rows_migrate (GPtrArray *rows, GPtrArray *result)
+rows_migrate (GPtrArray *rows,
+	      GPtrArray *result)
 {
-	guint i,j;
+	guint i, j;
 
 	/* Go thought the lists and join with | separator */
 	for (i = 0; i < rows->len; i++) {
-		OneRow      *row;
-		GPtrArray   *array;
-		gchar      **strv;
+		OneRow     *row;
+		GPtrArray  *array;
+		gchar     **strv;
 
 		row   = g_ptr_array_index (rows, i);
 		array = row->value;
@@ -148,10 +165,10 @@
 		strv = g_new0 (gchar*, array->len + 1);
 
 		for (j = 0; j < array->len; j++) {
-			OneElem   *elem;
-			GSList    *list;
-			GSList    *iter;
-			GString   *string;
+			OneElem *elem;
+			GSList  *list;
+			GSList  *iter;
+			GString *string;
 
 			elem   = g_ptr_array_index (array, j);
 			list   = elem->value;
@@ -172,7 +189,6 @@
 	}
 }
 
-
 static gchar **
 dbus_query_result_to_strv (TrackerDBResultSet *result_set,
 			   gint		       column,
@@ -246,15 +262,15 @@
 
 gchar **
 tracker_dbus_query_result_columns_to_strv (TrackerDBResultSet *result_set,
-					   gint offset_column,
-					   gint until_column,
-					   gboolean rewind)
-{
-	gchar   **strv = NULL;
-	gint	  i = 0;
-	gint	  columns;
-	gint      row_counter = 0;
-	gboolean  valid = TRUE;
+					   gint                offset_column,
+					   gint                until_column,
+					   gboolean            rewind)
+{
+	gchar    **strv = NULL;
+	gint	   i = 0;
+	gint	   columns;
+	gint       row_counter = 0;
+	gboolean   valid = TRUE;
 
 	if (result_set) {
 		columns = tracker_db_result_set_get_n_columns (result_set);
@@ -268,11 +284,13 @@
 		strv = g_new (gchar*, 1);
 		strv[0] = NULL;
 		return strv;
-	} else if (offset_column == -1)
+	} else if (offset_column == -1) {
 		offset_column = 0;
+	}
 
-	if (until_column == -1)
+	if (until_column == -1) {
 		until_column = columns;
+	}
 
 	strv = g_new (gchar*, until_column + 1);
 
@@ -280,7 +298,7 @@
 
 		for (i = offset_column ; i < until_column; i++) {
 			GValue value = {0, };
-			GValue	transform = {0, };
+			GValue transform = {0, };
 			
 			g_value_init (&transform, G_TYPE_STRING);
 			
@@ -408,12 +426,12 @@
 	}
 
 	while (valid) {
-		GSList	              *list = NULL;
-		gchar                **p;
+		GSList  *list = NULL;
+		gchar  **p;
 
 		/* Append fields to the array */
 		for (i = 0; i < columns; i++) {
-			GValue	 transform = { 0, };
+			GValue	transform = { 0, };
 			GValue	value = { 0, };
 			gchar  *str;
 
@@ -458,10 +476,10 @@
 GPtrArray *
 tracker_dbus_query_result_multi_to_ptr_array (TrackerDBResultSet *result_set)
 {
-	GPtrArray  *result;
-	GPtrArray  *rows;
-	gboolean    valid = FALSE;
-	gint	    columns;
+	GPtrArray *result;
+	GPtrArray *rows;
+	gboolean   valid = FALSE;
+	gint	   columns;
 
 	rows = g_ptr_array_new ();
 
@@ -476,12 +494,11 @@
 	}
 
 	while (valid) {
-		gint		       key;		
-		GPtrArray             *row;
-
-		gint	               column;
-		gboolean	       add = FALSE;
-		GValue		       value_in = {0, };
+		GPtrArray *row;
+		GValue	   value_in = {0, };
+		gint	   key;		
+		gint       column;
+		gboolean   add = FALSE;
 
 		/* Get the key and the matching row if exists */
 		_tracker_db_result_set_get_value (result_set, 0, &value_in);
@@ -494,9 +511,9 @@
 
 		/* Append fields or values to the array */
 		for (column = 1; column < columns; column++) {
-			GValue	   transform = { 0, };
-			GValue	   value = { 0, };
-			gchar     *str;
+			GValue  transform = { 0, };
+			GValue  value = { 0, };
+			gchar  *str;
 
 			g_value_init (&transform, G_TYPE_STRING);
 

Modified: trunk/src/libtracker-db/tracker-db-dbus.h
==============================================================================
--- trunk/src/libtracker-db/tracker-db-dbus.h	(original)
+++ trunk/src/libtracker-db/tracker-db-dbus.h	Fri Mar  6 16:39:21 2009
@@ -28,20 +28,19 @@
 
 #include "tracker-db-interface.h"
 
-gchar **    tracker_dbus_query_result_to_strv	     (TrackerDBResultSet *result_set,
-						      gint		  column,
-						      gint		 *count);
-gchar **    tracker_dbus_query_result_numeric_to_strv (TrackerDBResultSet *result_set,
-						       gint		   column,
-						       gint		  *count);
-gchar **    tracker_dbus_query_result_columns_to_strv (TrackerDBResultSet *result_set,
-						       gint offset_column,
-						       gint until_column,
-						       gboolean rewind);
-GHashTable *tracker_dbus_query_result_to_hash_table (TrackerDBResultSet *result_set);
-GPtrArray * tracker_dbus_query_result_to_ptr_array  (TrackerDBResultSet *result_set);
-GPtrArray * tracker_dbus_query_result_multi_to_ptr_array  (TrackerDBResultSet *result_set);
-
+gchar **    tracker_dbus_query_result_to_strv            (TrackerDBResultSet *result_set,
+							  gint                column,
+							  gint               *count);
+gchar **    tracker_dbus_query_result_numeric_to_strv    (TrackerDBResultSet *result_set,
+							  gint                column,
+							  gint               *count);
+gchar **    tracker_dbus_query_result_columns_to_strv    (TrackerDBResultSet *result_set,
+							  gint                offset_column,
+							  gint                until_column,
+							  gboolean            rewind);
+GHashTable *tracker_dbus_query_result_to_hash_table      (TrackerDBResultSet *result_set);
+GPtrArray * tracker_dbus_query_result_to_ptr_array       (TrackerDBResultSet *result_set);
+GPtrArray * tracker_dbus_query_result_multi_to_ptr_array (TrackerDBResultSet *result_set);
 
 G_END_DECLS
 

Modified: trunk/src/libtracker-db/tracker-db-manager.c
==============================================================================
--- trunk/src/libtracker-db/tracker-db-manager.c	(original)
+++ trunk/src/libtracker-db/tracker-db-manager.c	Fri Mar  6 16:39:21 2009
@@ -1316,7 +1316,7 @@
 {
 	AggregateData *p;
 
-	g_return_if_fail (argc != 1);
+	g_return_if_fail (argc == 1);
 
 	p = aggregate_context;
 
@@ -1348,7 +1348,6 @@
 	return result;
 }
 
-
 static GValue
 function_get_service_name (TrackerDBInterface *interface,
 			   gint		       argc,
@@ -1730,7 +1729,6 @@
 	}
 }
 
-
 static void
 db_get_static_data (TrackerDBInterface *iface)
 {



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