[tracker/tracker-0.6] Allow queries without an rdf-file with tracker-query.



commit 733bdd616a733ec94196b935d0694a5e9b4184a7
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Thu May 7 18:01:30 2009 +0300

    Allow queries without an rdf-file with tracker-query.
---
 src/tracker-utils/tracker-query.c |   94 +++++++++++++++++++------------------
 1 files changed, 48 insertions(+), 46 deletions(-)

diff --git a/src/tracker-utils/tracker-query.c b/src/tracker-utils/tracker-query.c
index a7b3543..72787b0 100644
--- a/src/tracker-utils/tracker-query.c
+++ b/src/tracker-utils/tracker-query.c
@@ -113,7 +113,7 @@ main (int argc, char **argv)
 	GFile           *file;
 	gchar		*path_in_utf8, *abs_path;
 	gchar		*content;
-	gchar		*buffer;
+	gchar		*buffer = NULL;
 	gsize		 size;
 	GPtrArray	*array;
 
@@ -129,11 +129,11 @@ main (int argc, char **argv)
 	g_option_context_add_main_entries (context, entries, NULL);
 	g_option_context_parse (context, &argc, &argv, NULL);
 
-	if (!fields || !path) {
+	if (!fields) {
 		gchar *help;
 
 		g_printerr ("%s\n\n",
-			    _("Path or fields are missing"));
+			    _("Fields are missing"));
 
 		help = g_option_context_get_help (context, TRUE, NULL);
 		g_option_context_free (context);
@@ -171,53 +171,55 @@ main (int argc, char **argv)
 		}
 	}
 
-	path_in_utf8 = g_filename_to_utf8 (path, -1, NULL, NULL, &error);
-	if (error) {
-		g_printerr ("%s:'%s', %s\n",
-			    _("Could not get UTF-8 path from path"),
-			    path,
-			    error->message);
-		g_error_free (error);
-		tracker_disconnect (client);
-
-		return EXIT_FAILURE;
-	}
-
-	file = g_file_new_for_commandline_arg (path_in_utf8);
-	abs_path = g_file_get_path (file);
-
-	g_file_get_contents (abs_path, &content, &size, &error);
-	if (error) {
-		g_printerr ("%s:'%s', %s\n",
-			    _("Could not read file"),
-			    abs_path,
-			    error->message);
-		g_error_free (error);
+	if (path) {
+		path_in_utf8 = g_filename_to_utf8 (path, -1, NULL, NULL, &error);
+		if (error) {
+			g_printerr ("%s:'%s', %s\n",
+				    _("Could not get UTF-8 path from path"),
+				    path,
+				    error->message);
+			g_error_free (error);
+			tracker_disconnect (client);
+			
+			return EXIT_FAILURE;
+		}
+		
+		file = g_file_new_for_commandline_arg (path_in_utf8);
+		abs_path = g_file_get_path (file);
+		
+		g_file_get_contents (abs_path, &content, &size, &error);
+		if (error) {
+			g_printerr ("%s:'%s', %s\n",
+				    _("Could not read file"),
+				    abs_path,
+				    error->message);
+			g_error_free (error);
+			g_free (path_in_utf8);
+			g_free (abs_path);
+			g_object_unref (file);
+			tracker_disconnect (client);
+			
+			return EXIT_FAILURE;
+		}
+		
 		g_free (path_in_utf8);
 		g_free (abs_path);
 		g_object_unref (file);
-		tracker_disconnect (client);
-
-		return EXIT_FAILURE;
-	}
-
-	g_free (path_in_utf8);
-	g_free (abs_path);
-	g_object_unref (file);
-
-	buffer = g_locale_to_utf8 (content, size, NULL, NULL, &error);
-	g_free (content);
-
-	if (error) {
-		g_printerr ("%s, %s\n",
-			    _("Could not convert query file to UTF-8"),
-			    error->message);
-		g_error_free (error);
-		tracker_disconnect (client);
-
-		return EXIT_FAILURE;
+		
+		buffer = g_locale_to_utf8 (content, size, NULL, NULL, &error);
+		g_free (content);
+		
+		if (error) {
+			g_printerr ("%s, %s\n",
+				    _("Could not convert query file to UTF-8"),
+				    error->message);
+			g_error_free (error);
+			tracker_disconnect (client);
+			
+			return EXIT_FAILURE;
+		}
 	}
-
+		
 	array = tracker_search_query (client,
 				      time (NULL),
 				      type,



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