tracker r2310 - in trunk: . docs/manpages src/tracker-utils



Author: ifrade
Date: Sat Oct  4 10:38:38 2008
New Revision: 2310
URL: http://svn.gnome.org/viewvc/tracker?rev=2310&view=rev

Log:
Added new tracker-services tool

Added:
   trunk/src/tracker-utils/tracker-services.c
Modified:
   trunk/ChangeLog
   trunk/docs/manpages/tracker-services.1
   trunk/src/tracker-utils/Makefile.am

Modified: trunk/docs/manpages/tracker-services.1
==============================================================================
--- trunk/docs/manpages/tracker-services.1	(original)
+++ trunk/docs/manpages/tracker-services.1	Sat Oct  4 10:38:38 2008
@@ -1,17 +1,37 @@
 .TH tracker-services 1 "July 2007" GNU "Conventions"
 
 .SH NAME
-tracker-services \- service types of trackerd
+tracker-services \- shows service types and propeties available in trackerd
 
-.SH INTRODUCTION
-Trackerd understands a number of different services which are used to
+.SH SYNOPSIS
+.B tracker-services
+[-sp] 
+
+.SH DESCRIPTION
+.PP
+.B tracker-services
+returns the services types and properties available in 
+.BR tracker (1)
+.PP
+Trackerd understands a number of different service types which are used to
 group search results and documents together. All searches and queries can
-be refined by specifying a service to search from.
+be refined by specifying a service type to search from.
 .PP
 For example one could search for "Roses" in the service Conversations
 which would only return hits from chat conversations.
 
+.SH OPTIONS
+.TP
+\-s 
+Return service types.
+.TP
+\-p
+Return properties.
+.PP
+These options can be used simultaneously.
+
 .SH SERVICE TYPES
+Default services types (Note than applications can add more):
 .TP
 Files
 Search for files only. This does not include Emails or Conversations.
@@ -21,7 +41,7 @@
 .TP
 Documents
 Searches for general documents like word processing,
-spreadsheets or text files.
+spreadsheets or PDF.
 .TP
 Emails
 Searches for Emails.
@@ -39,8 +59,7 @@
 Search for video files.
 .TP
 Text
-Search for text files, like word processing files, but e.g. not
-spreadsheets.
+Search for plain text files.
 .TP
 Development
 Search for development files. This includes make files,

Modified: trunk/src/tracker-utils/Makefile.am
==============================================================================
--- trunk/src/tracker-utils/Makefile.am	(original)
+++ trunk/src/tracker-utils/Makefile.am	Sat Oct  4 10:38:38 2008
@@ -22,7 +22,8 @@
 	tracker-files						\
 	tracker-status						\
 	tracker-unique						\
-	tracker-info
+	tracker-info						\
+	tracker-services
 
 tracker_search_SOURCES = tracker-search.c
 tracker_search_LDADD = $(libs)
@@ -50,3 +51,6 @@
 
 tracker_info_SOURCES = tracker-info.c
 tracker_info_LDADD = $(libs)
+
+tracker_services_SOURCES = tracker-services.c
+tracker_services_LDADD = $(libs)

Added: trunk/src/tracker-utils/tracker-services.c
==============================================================================
--- (empty file)
+++ trunk/src/tracker-utils/tracker-services.c	Sat Oct  4 10:38:38 2008
@@ -0,0 +1,152 @@
+/* -*- 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
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <locale.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include <libtracker/tracker.h>
+
+static gboolean services = FALSE;
+static gboolean properties = FALSE;
+
+static GOptionEntry entries[] = {
+	{ "service-types", 's', 0, G_OPTION_ARG_NONE, &services,
+	  N_("Return the known service types"),
+	  NULL
+	},
+	{ "properties", 'p', 0, G_OPTION_ARG_NONE, &properties,
+	  N_("Return the known properties"),
+	  NULL
+	},
+	{ NULL }
+};
+
+
+static void
+print_strv (gchar **values)
+{
+	guint i;
+
+	for (i = 0; values[i] != NULL; i++) {
+		g_print (" - %s\n", values[i]);
+	}
+
+	g_print ("\n");
+}
+
+int
+main (int argc, char **argv)
+{
+	TrackerClient   *client;
+	GOptionContext  *context;
+	gchar          **array;
+	GError	        *error = NULL;
+
+	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	/* Translators: this messagge will apper immediately after the	*/
+	/* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE>	*/
+	context = g_option_context_new (_(" - Show all available service types and properties in tracker"));
+	g_option_context_add_main_entries (context, entries, "tracker-services");
+	g_option_context_parse (context, &argc, &argv, NULL);
+
+	if (!services && !properties) {
+		gchar *help;
+		
+		help = g_option_context_get_help (context, TRUE, NULL);
+		g_option_context_free (context);
+		g_printerr (help);
+		g_free (help);
+		
+		return EXIT_FAILURE;
+	}
+	g_option_context_free (context);
+
+	client = tracker_connect (FALSE);
+
+	if (!client) {
+		g_printerr ("%s\n",
+			    _("Could not establish a DBus connection to Tracker"));
+		return EXIT_FAILURE;
+	}
+
+	if (services) {
+		array = tracker_metadata_get_registered_classes (client, &error);
+
+		if (error) {
+			g_printerr ("%s, %s\n",
+				    _("Could not get Tracker services"),
+				    error->message);
+			g_error_free (error);
+			
+			return EXIT_FAILURE;
+		}
+
+		if (!array) {
+			g_print ("%s\n",
+				 _("No services available"));
+		} else {
+			g_print ("%s\n\n",
+				 _("Service types available in Tracker:"));
+			
+			print_strv (array);
+			g_strfreev (array);
+		}
+	}
+
+	if (properties) {
+
+		array = tracker_metadata_get_registered_types (client, "*", &error);
+		
+		if (error) {
+			g_printerr ("%s, %s\n",
+				    _("Could not get Tracker properties"),
+				    error->message);
+			g_error_free (error);
+			
+			return EXIT_FAILURE;
+		}
+		
+		if (!array) {
+			g_print ("%s\n",
+				 _("No properties available"));
+		} else {
+			g_print ("%s\n\n",
+				 _("Properties available in Tracker:"));
+			
+			print_strv (array);
+			g_strfreev (array);
+		}
+		
+	}
+	tracker_disconnect (client);
+
+	return EXIT_SUCCESS;
+}



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