tracker r2897 - in trunk: . src/tracker-extract



Author: mr
Date: Fri Feb  6 21:27:05 2009
New Revision: 2897
URL: http://svn.gnome.org/viewvc/tracker?rev=2897&view=rev

Log:
	* src/tracker-extract/tracker-escape.c: Make sure we check for
	UTF8 validation before sending over dbus.

	* src/tracker-extract/tracker-extract.c: Fixed some warnings
	related to NULL hash tables.


Modified:
   trunk/ChangeLog
   trunk/src/tracker-extract/tracker-escape.c
   trunk/src/tracker-extract/tracker-extract.c

Modified: trunk/src/tracker-extract/tracker-escape.c
==============================================================================
--- trunk/src/tracker-extract/tracker-escape.c	(original)
+++ trunk/src/tracker-extract/tracker-escape.c	Fri Feb  6 21:27:05 2009
@@ -25,3 +25,32 @@
 #include <glib.h>
 
 #include "tracker-escape.h"
+
+gchar *
+tracker_escape_metadata (const gchar *str)
+{
+	const gchar *end;
+
+	if (g_utf8_validate (str, -1, &end)) {
+		return g_strdup (str);
+	}
+
+	return g_strndup (str, end - str);
+}
+
+gchar *
+tracker_escape_metadata_printf (const gchar *format,
+				...)
+{
+ 	va_list args;
+ 	gchar *str, *escaped;
+ 	
+ 	va_start (args, format);
+ 	str = g_strdup_vprintf (format, args);
+ 	va_end (args);
+ 	
+ 	escaped = tracker_escape_metadata (str);
+ 	g_free (str);
+ 	
+ 	return escaped;
+}

Modified: trunk/src/tracker-extract/tracker-extract.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract.c	(original)
+++ trunk/src/tracker-extract/tracker-extract.c	Fri Feb  6 21:27:05 2009
@@ -309,7 +309,7 @@
 	g_free (path_in_locale);
 	g_free (path_used);
 
-	return NULL;
+	return values;
 }
 
 void
@@ -355,21 +355,28 @@
 				  path,
 				  mime);
 
+	tracker_dbus_request_comment (request_id,
+				      "  Resetting shutdown timeout");
+
 	tracker_main_shutdown_timeout_reset ();
 
 	values = get_file_metadata (object, request_id, path, mime);
-
 	if (values) {
 		g_hash_table_foreach (values, 
 				      print_file_metadata_item, 
 				      GUINT_TO_POINTER (request_id));
-	}
-
-	dbus_g_method_return (context, values);
-
-	if (values) {
+		dbus_g_method_return (context, values);
 		g_hash_table_destroy (values);
+		tracker_dbus_request_success (request_id);
+	} else {
+		GError *actual_error = NULL;
+
+		tracker_dbus_request_failed (request_id,
+					     &actual_error,
+					     "Could not get any metadata for path:'%s' and mime:'%s'",
+					     path, 
+					     mime);
+		dbus_g_method_return_error (context, actual_error);
+		g_error_free (actual_error);
 	}
-
-	tracker_dbus_request_success (request_id);
 }



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