tracker r2063 - in branches/indexer-split: . src/tracker-utils



Author: mr
Date: Tue Aug 12 16:39:19 2008
New Revision: 2063
URL: http://svn.gnome.org/viewvc/tracker?rev=2063&view=rev

Log:
	* src/tracker-utils/tracker-query.c:
	* src/tracker-utils/tracker-search.c:
	* src/tracker-utils/tracker-unique.c: Fixed a memory leak.

	* src/tracker-utils/tracker-stats.c: Clean up.


Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/tracker-utils/tracker-query.c
   branches/indexer-split/src/tracker-utils/tracker-search.c
   branches/indexer-split/src/tracker-utils/tracker-stats.c
   branches/indexer-split/src/tracker-utils/tracker-unique.c

Modified: branches/indexer-split/src/tracker-utils/tracker-query.c
==============================================================================
--- branches/indexer-split/src/tracker-utils/tracker-query.c	(original)
+++ branches/indexer-split/src/tracker-utils/tracker-query.c	Tue Aug 12 16:39:19 2008
@@ -80,19 +80,19 @@
 static void
 get_meta_table_data (gpointer value)
 {
-	gchar **meta, **p;
+	gchar **meta;
+	gchar **p;
+	gchar  *str;
 	gint    i = 0;
 
 	meta = value;
 
 	for (p = meta, i = 0; *p; p++, i++) {
-		gchar *str;
-
-		str = g_filename_from_utf8 (*p, -1, NULL, NULL, NULL);
-
                 switch (i) {
                 case 0:
+			str = g_filename_from_utf8 (*p, -1, NULL, NULL, NULL);
                         g_print ("  %s:'%s'", _("Path"), str);
+			g_free (str);
                         break;
                 case 1:
 			g_print (", %s:'%s'", _("Service"), *p);

Modified: branches/indexer-split/src/tracker-utils/tracker-search.c
==============================================================================
--- branches/indexer-split/src/tracker-utils/tracker-search.c	(original)
+++ branches/indexer-split/src/tracker-utils/tracker-search.c	Tue Aug 12 16:39:19 2008
@@ -65,19 +65,19 @@
 static void
 get_meta_table_data (gpointer value)
 {
-	gchar **meta, **p;
+	gchar **meta;
+	gchar **p;
+	gchar  *str;
 	gint    i = 0;
 
 	meta = value;
 
 	for (p = meta, i = 0; *p; p++, i++) {
-		gchar *str;
-
-		str = g_filename_from_utf8 (*p, -1, NULL, NULL, NULL);
-
                 switch (i) {
                 case 0:
+			str = g_filename_from_utf8 (*p, -1, NULL, NULL, NULL);
                         g_print ("  %s:'%s'", _("Path"), str);
+			g_free (str);
                         break;
                 case 1:
 			g_print (", %s:'%s'", _("Service"), *p);

Modified: branches/indexer-split/src/tracker-utils/tracker-stats.c
==============================================================================
--- branches/indexer-split/src/tracker-utils/tracker-stats.c	(original)
+++ branches/indexer-split/src/tracker-utils/tracker-stats.c	Tue Aug 12 16:39:19 2008
@@ -1,4 +1,5 @@
-/* Tracker - indexer and metadata database engine
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
  * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
  * Copyright (C) 2008, Nokia
  *
@@ -30,39 +31,33 @@
 
 #include <libtracker/tracker.h>
 
-#define TOTAL_COUNT _("Total files indexed")
-
 static void
 get_meta_table_data (gpointer value)
 {
-	char **meta, **meta_p;
-
-	meta = (char **)value;
-
-	int i = 0;
-	for (meta_p = meta; *meta_p; meta_p++) {
-
-		if (i == 0) {
-			g_print ("%s : ", *meta_p);
-
-		} else {
-			g_print ("%s ", *meta_p);
-		}
-		i++;
+	gchar **meta;
+        gchar **p;
+	gint    i;
+
+	meta = value;
+
+	for (p = meta, i = 0; *p; p++, i++) {
+                if (i == 0) {
+                        g_print ("  %s", *p);
+                } else {
+			g_print (" = %s", *p);
+                }
 	}
+
 	g_print ("\n");
 }
 
-
-
 int 
 main (int argc, char **argv) 
 {
-	
-	GPtrArray *out_array = NULL;
-	GError *error = NULL;
-	GOptionContext *context = NULL;
-	TrackerClient *client = NULL;
+	TrackerClient  *client;
+	GOptionContext *context;
+	GPtrArray      *array;
+	GError         *error = NULL;
 
 	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -71,51 +66,38 @@
         /* Translators: this messagge will apper immediately after the  */
         /* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE>     */
         context = g_option_context_new (_(" - Show number of indexed files for each service"));
+	g_option_context_parse (context, &argc, &argv, NULL);
+	g_option_context_free (context);
 
-	g_option_context_parse (context, &argc, &argv, &error);
+	client = tracker_connect (FALSE);
 
-        g_option_context_free (context);
-
-        if (error) {
-                g_printerr ("%s: %s", argv[0], error->message);
-                g_printerr ("\n");
-                g_printerr (_("Try \"%s --help\" for more information."), argv[0]);
-                g_printerr ("\n");
-                return 1;
-        }
-
-	client =  tracker_connect (FALSE);
-
-        if (!client) {
-                g_printerr (_("%s: no connection to tracker daemon"), argv[0]);
-                g_printerr ("\n");
-                g_printerr (_("Ensure \"trackerd\" is running before launch this command."));
-                g_printerr ("\n");
-                return 1;
-        }
+	if (!client) {
+		g_printerr (_("Could not establish a DBus connection to Tracker"));
+		return EXIT_FAILURE;
+	}
 
-	out_array = tracker_get_stats (client, &error);
+	array = tracker_get_stats (client, &error);
 
 	if (error) {
-		g_warning ("%s: an error has occurred: %s", argv[0], error->message);
+		g_printerr ("%s, %s\n",
+                            _("Could not get Tracker statistics"),
+                            error->message);
 		g_error_free (error);
-	}
-
-	if (out_array) {
-		gchar *tmp;
-
-		tmp = g_strconcat("\n-------", _("fetching index stats"),
-				  "---------\n\n", NULL);
-
-		g_print (tmp);
-		g_ptr_array_foreach (out_array, (GFunc)get_meta_table_data, NULL);
-		g_ptr_array_free (out_array, TRUE);
-		g_print ("------------------------------------\n\n");
-		
-		g_free (tmp);
 
+                return EXIT_FAILURE;
 	}
 
+        if (!array) {
+                g_print (_("No statistics available"));
+                g_print ("\n");
+        } else {
+                g_print (_("Statistics:"));
+                g_print ("\n");
+                
+                g_ptr_array_foreach (array, (GFunc) get_meta_table_data, NULL);
+                g_ptr_array_free (array, TRUE);
+        }
+        
 	tracker_disconnect (client);
 
 	return EXIT_SUCCESS;

Modified: branches/indexer-split/src/tracker-utils/tracker-unique.c
==============================================================================
--- branches/indexer-split/src/tracker-utils/tracker-unique.c	(original)
+++ branches/indexer-split/src/tracker-utils/tracker-unique.c	Tue Aug 12 16:39:19 2008
@@ -70,19 +70,19 @@
 static void
 get_meta_table_data (gpointer value)
 {
-	gchar **meta, **p;
+	gchar **meta;
+        gchar **p;
+        gchar  *str;
 	gint    i = 0;
 
 	meta = value;
 
 	for (p = meta, i = 0; *p; p++, i++) {
-		gchar *str;
-
-		str = g_filename_from_utf8 (*p, -1, NULL, NULL, NULL);
-
                 switch (i) {
                 case 0:
+                        str = g_filename_from_utf8 (*p, -1, NULL, NULL, NULL);
                         g_print ("  %s:'%s'", _("Path"), str);
+                        g_free (str);
                         break;
                 case 1:
 			g_print (", %s:'%s'", _("Service"), *p);



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