[tracker/libtracker-sparql-porting: 9/44] tracker-import: Use new libtracker-sparql API



commit f30fbfd629fdc9d05a2845ab30f77fc4fa9b938a
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Jul 20 17:26:53 2010 +0100

    tracker-import: Use new libtracker-sparql API

 src/tracker-utils/tracker-import.c |   39 +++++++++++++++++++----------------
 1 files changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/src/tracker-utils/tracker-import.c b/src/tracker-utils/tracker-import.c
index 3b78906..a602f93 100644
--- a/src/tracker-utils/tracker-import.c
+++ b/src/tracker-utils/tracker-import.c
@@ -29,8 +29,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 
-#include <libtracker-client/tracker-client.h>
-#include <libtracker-common/tracker-common.h>
+#include <libtracker-sparql/tracker-sparql.h>
 
 #define ABOUT	  \
 	"Tracker " PACKAGE_VERSION "\n"
@@ -60,9 +59,10 @@ static GOptionEntry   entries[] = {
 int
 main (int argc, char **argv)
 {
-	TrackerClient   *client;
-	GOptionContext  *context;
-	gchar          **p;
+	TrackerSparqlConnection *connection;
+	GOptionContext *context;
+	GError *error = NULL;
+	gchar **p;
 
 	setlocale (LC_ALL, "");
 
@@ -102,33 +102,36 @@ main (int argc, char **argv)
 
 	g_option_context_free (context);
 
-	client = tracker_client_new (0, G_MAXINT);
+	g_type_init ();
 
-	if (!client) {
-		g_printerr ("%s\n",
-		            _("Could not establish a D-Bus connection to Tracker"));
+	if (!g_thread_supported ()) {
+		g_thread_init (NULL);
+	}
+
+	connection = tracker_sparql_connection_get (&error);
+
+	if (!connection) {
+		g_printerr ("%s: %s\n",
+		            _("Could not establish a connection to Tracker"),
+		            error ? error->message : _("No error given"));
+		g_clear_error (&error);
 		return EXIT_FAILURE;
 	}
 
 	for (p = filenames; *p; p++) {
 		GError *error = NULL;
-		GFile  *file;
-		gchar  *uri;
+		GFile *file;
 
 		g_print ("%s:'%s'\n",
 		         _("Importing Turtle file"),
 		         *p);
 
 		file = g_file_new_for_commandline_arg (*p);
-		uri = g_file_get_uri (file);
-
-		tracker_resources_load (client, uri, &error);
-
+		tracker_sparql_connection_import (connection, file, NULL, &error);
 		g_object_unref (file);
-		g_free (uri);
 
 		if (error) {
-			g_printerr ("%s, %s\n",
+			g_printerr ("  %s, %s\n",
 			            _("Unable to import Turtle file"),
 			            error->message);
 
@@ -140,7 +143,7 @@ main (int argc, char **argv)
 		g_print ("\n");
 	}
 
-	g_object_unref (client);
+	g_object_unref (connection);
 
 	return EXIT_SUCCESS;
 }



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