[tracker/refactor-extractor: 4/4] tracker-client: Refactored away tracker-statement-list



commit 96ef1d8552847b57730279b551605240fb0d842e
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Feb 12 12:50:24 2010 +0100

    tracker-client: Refactored away tracker-statement-list

 src/libtracker-client/Makefile.am                  |    3 -
 src/libtracker-client/tracker-statement-list.h     |   58 ----------
 src/libtracker-common/tracker-statement-list.c     |  114 --------------------
 src/libtracker-extract/tracker-xmp.c               |    4 +-
 .../tracker-extract-gstreamer-helix.c              |   49 +++++++--
 src/tracker-extract/tracker-extract-vorbis.c       |   24 ++--
 src/tracker-extract/tracker-extract.c              |    4 +-
 src/tracker-extract/tracker-topanalyzer.cpp        |   75 +++++++------
 8 files changed, 99 insertions(+), 232 deletions(-)
---
diff --git a/src/libtracker-client/Makefile.am b/src/libtracker-client/Makefile.am
index 1392d5d..d9ac612 100644
--- a/src/libtracker-client/Makefile.am
+++ b/src/libtracker-client/Makefile.am
@@ -37,9 +37,6 @@ libtracker_clientinclude_HEADERS = 			\
 	tracker.h					\
 	tracker-sparql-builder.h
 
-noinst_HEADERS =					\
-	tracker-statement-list.h
-
 # Generate DBus files from XML data.
 dbus_sources = 						\
 	tracker-resources-glue.h			\
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index 36bdaa4..9279db0 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -271,7 +271,7 @@ iterate_simple (const gchar    *uri,
 		} else if (!data->artist && g_ascii_strcasecmp (name, "Artist") == 0) {
 			data->artist = g_strdup (value);
 		/* } else if (g_ascii_strcasecmp (name, "Software") == 0) {
-			   tracker_statement_list_insert (metadata, uri,
+			   tracker_stmt_list_insert (metadata, uri,
 			   "Image:Software", value);*/
 		} else if (!data->make && g_ascii_strcasecmp (name, "Make") == 0) {
 			data->make = g_strdup (value);
@@ -284,7 +284,7 @@ iterate_simple (const gchar    *uri,
 		} else if (!data->metering_mode && g_ascii_strcasecmp (name, "MeteringMode") == 0) {
 			data->metering_mode = g_strdup (fix_metering_mode (value));
 		/* } else if (g_ascii_strcasecmp (name, "ExposureProgram") == 0) {
-			   tracker_statement_list_insert (metadata, uri,
+			   tracker_stmt_list_insert (metadata, uri,
 			   "Image:ExposureProgram", value);*/
 		} else if (!data->exposure_time && g_ascii_strcasecmp (name, "ExposureTime") == 0) {
 			data->exposure_time = g_strdup (value);
diff --git a/src/tracker-extract/tracker-extract-gstreamer-helix.c b/src/tracker-extract/tracker-extract-gstreamer-helix.c
index ad21d80..9e17b37 100644
--- a/src/tracker-extract/tracker-extract-gstreamer-helix.c
+++ b/src/tracker-extract/tracker-extract-gstreamer-helix.c
@@ -372,7 +372,15 @@ add_int64_info (TrackerSparqlBuilder *metadata,
                 const gchar        *key,
                 gint64      info)
 {
-	tracker_statement_list_insert_with_int64 (metadata, uri, key, info);
+	gchar *value_str;
+
+	value_str = g_strdup_printf ("%" G_GINT64_FORMAT, info);
+
+	tracker_sparql_builder_subject_iri (metadata, uri);
+	tracker_sparql_builder_predicate_iri (metadata, key);
+	tracker_sparql_builder_object_unvalidated (metadata, value_str);
+
+	g_free (value_str);
 }
 
 static void
@@ -381,7 +389,15 @@ add_uint_info (TrackerSparqlBuilder *metadata,
                gchar      *key,
                guint       info)
 {
-	tracker_statement_list_insert_with_int (metadata, uri, key, info);
+	gchar *value_str;
+
+	value_str = g_strdup_printf ("%d", info);
+
+	tracker_sparql_builder_subject_iri (metadata, uri);
+	tracker_sparql_builder_predicate_iri (metadata, key);
+	tracker_sparql_builder_object_unvalidated (metadata, value_str);
+
+	g_free (value_str);
 }
 
 static void
@@ -399,7 +415,9 @@ add_string_gst_tag (TrackerSparqlBuilder        *metadata,
 
 	if (s) {
 		if (ret && s[0] != '\0') {
-			tracker_statement_list_insert (metadata, uri, key, s);
+			tracker_sparql_builder_subject_iri (metadata, uri);
+			tracker_sparql_builder_predicate_iri (metadata, key);
+			tracker_sparql_builder_object_unvalidated (metadata, s);
 		}
 
 		g_free (s);
@@ -419,7 +437,15 @@ add_uint_gst_tag (TrackerSparqlBuilder  *metadata,
 	ret = gst_tag_list_get_uint (tag_list, tag, &n);
 
 	if (ret) {
-		tracker_statement_list_insert_with_int (metadata, uri, key, n);
+		gchar *value_str;
+
+		value_str = g_strdup_printf ("%" G_GUINT32_FORMAT, n);
+
+		tracker_sparql_builder_subject_iri (metadata, uri);
+		tracker_sparql_builder_predicate_iri (metadata, key);
+		tracker_sparql_builder_object_unvalidated (metadata, value_str);
+
+		g_free (value_str);
 	}
 }
 
@@ -436,7 +462,15 @@ add_double_gst_tag (TrackerSparqlBuilder        *metadata,
 	ret = gst_tag_list_get_double (tag_list, tag, &n);
 
 	if (ret) {
-		tracker_statement_list_insert_with_double (metadata, uri, key, n);
+		gchar *value_str;
+
+		value_str = g_strdup_printf ("%g", n);
+
+		tracker_sparql_builder_subject_iri (metadata, uri);
+		tracker_sparql_builder_predicate_iri (metadata, key);
+		tracker_sparql_builder_object_unvalidated (metadata, value_str);
+
+		g_free (value_str);
 	}
 }
 
@@ -457,8 +491,9 @@ add_year_of_gdate_gst_tag (TrackerSparqlBuilder  *metadata,
 		gchar buf[10];
 
 		if (g_date_strftime (buf, 10, "%Y", date)) {
-			tracker_statement_list_insert (metadata, uri,
-			                               key, buf);
+			tracker_sparql_builder_subject_iri (metadata, uri);
+			tracker_sparql_builder_predicate_iri (metadata, key);
+			tracker_sparql_builder_object_unvalidated (metadata, buf);
 		}
 	}
 
diff --git a/src/tracker-extract/tracker-extract-vorbis.c b/src/tracker-extract/tracker-extract-vorbis.c
index e1c71a3..dfc86db 100644
--- a/src/tracker-extract/tracker-extract-vorbis.c
+++ b/src/tracker-extract/tracker-extract-vorbis.c
@@ -236,11 +236,11 @@ extract_vorbis (const char *uri,
 	}
 
 	if (vorbis_data.TrackGain) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.); */
 		g_free (vorbis_data.TrackGain);
 	}
 	if (vorbis_data.TrackPeakGain) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.); */
 		g_free (vorbis_data.TrackPeakGain);
 	}
 
@@ -281,7 +281,7 @@ extract_vorbis (const char *uri,
 	}
 
 	if (vorbis_data.CodecVersion) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.); */
 		g_free (vorbis_data.CodecVersion);
 	}
 
@@ -298,22 +298,22 @@ extract_vorbis (const char *uri,
 	}
 
 	if (vorbis_data.MBAlbumID) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.MBAlbumID); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.MBAlbumID); */
 		g_free (vorbis_data.MBAlbumID);
 	}
 
 	if (vorbis_data.MBArtistID) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.MBArtistID); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.MBArtistID); */
 		g_free (vorbis_data.MBArtistID);
 	}
 
 	if (vorbis_data.MBAlbumArtistID) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.MBAlbumArtistID); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.MBAlbumArtistID); */
 		g_free (vorbis_data.MBAlbumArtistID);
 	}
 
 	if (vorbis_data.MBTrackID) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.MBTrackID); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.MBTrackID); */
 		g_free (vorbis_data.MBTrackID);
 	}
 
@@ -336,12 +336,12 @@ extract_vorbis (const char *uri,
 	}
 
 	if (vorbis_data.Organization) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.Organization); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.Organization); */
 		g_free (vorbis_data.Organization);
 	}
 
 	if (vorbis_data.Location) {
-		/* tracker_statement_list_insert (metadata, uri, _PREFIX "", vorbis_data.Location); */
+		/* tracker_stmt_list_insert (metadata, uri, _PREFIX "", vorbis_data.Location); */
 		g_free (vorbis_data.Location);
 	}
 
@@ -365,9 +365,9 @@ extract_vorbis (const char *uri,
 		tracker_sparql_builder_object_int64 (metadata, (gint64) bitrate);
 
 		/*
-		  tracker_statement_list_insert_with_int (metadata, uri, "Audio.CodecVersion", vi->version);
-		  tracker_statement_list_insert_with_int (metadata, uri, NFO_PREFIX "channels", vi->channels);
-		  tracker_statement_list_insert_with_int (metadata, uri, NFO_PREFIX "sampleRate", vi->rate);
+		  tracker_stmt_list_insert_with_int (metadata, uri, "Audio.CodecVersion", vi->version);
+		  tracker_stmt_list_insert_with_int (metadata, uri, NFO_PREFIX "channels", vi->channels);
+		  tracker_stmt_list_insert_with_int (metadata, uri, NFO_PREFIX "sampleRate", vi->rate);
 		*/
 	}
 
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index 3aa29c1..2dc5fe2 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -236,7 +236,7 @@ get_file_metadata (TrackerExtract         *extract,
 
 #ifdef HAVE_LIBSTREAMANALYZER
 	if (!priv->force_internal_extractors) {
-		tracker_dbus_request_comment (request_id,
+		tracker_dbus_request_comment (request_id, context,
 		                              "  Extracting with libstreamanalyzer...");
 
 		tracker_topanalyzer_extract (uri, statements, &content_type);
@@ -250,7 +250,7 @@ get_file_metadata (TrackerExtract         *extract,
 			return TRUE;
 		}
 	} else {
-		tracker_dbus_request_comment (request_id,
+		tracker_dbus_request_comment (request_id, context,
 		                              "  Extracting with internal extractors ONLY...");
 	}
 #endif /* HAVE_LIBSTREAMANALYZER */
diff --git a/src/tracker-extract/tracker-topanalyzer.cpp b/src/tracker-extract/tracker-topanalyzer.cpp
index 0f673c8..3c56c1a 100644
--- a/src/tracker-extract/tracker-topanalyzer.cpp
+++ b/src/tracker-extract/tracker-topanalyzer.cpp
@@ -40,8 +40,6 @@
 #include <libtracker-common/tracker-type-utils.h>
 #include <libtracker-common/tracker-os-dependant.h>
 #include <libtracker-common/tracker-sparql-builder.h>
-#include <libtracker-common/tracker-statement-list.h>
-
 #include <libtracker-common/tracker-ontology.h>
 
 #include <libtracker-extract/tracker-utils.h>
@@ -139,9 +137,10 @@ namespace Tracker {
 	                                        const char* text,
 	                                        int32_t length)
 	{
-		tracker_statement_list_insert (metadata, idx->path().c_str(),
-		                               NIE_PREFIX "plainTextContent",
-		                               text);
+
+		tracker_sparql_builder_subject_iri (metadata, idx->path().c_str());
+		tracker_sparql_builder_predicate_iri (metadata, NIE_PREFIX "plainTextContent");
+		tracker_sparql_builder_object_unvalidated (metadata, text);
 	}
 
 	const gchar* Tracker::TripleCollector::predicateMapping (const std::string &key)
@@ -214,7 +213,7 @@ namespace Tracker {
 	}
 
 	/* The methods below basically just convert the C++ world to the C world
-	 * of tracker_statement_list_insert. Nothing magical about it. */
+	 * of TrackerSparqlBuilder. Nothing magical about it. */
 
 	void Tracker::TripleCollector::addValue (const AnalysisResult* idx,
 	                                         const RegisteredField* field,
@@ -231,10 +230,9 @@ namespace Tracker {
 			return;
 		}
 
-		tracker_statement_list_insert (metadata,
-		                               idx->path().c_str(),
-		                               predicate,
-		                               value.c_str());
+		tracker_sparql_builder_subject_iri (metadata, idx->path().c_str());
+		tracker_sparql_builder_predicate_iri (metadata, predicate);
+		tracker_sparql_builder_object_unvalidated (metadata, value.c_str());
 	}
 
 	void Tracker::TripleCollector::addValue (const AnalysisResult* idx,
@@ -248,10 +246,9 @@ namespace Tracker {
 			return;
 		}
 
-		tracker_statement_list_insert (metadata,
-		                               idx->path().c_str(),
-		                               predicate,
-		                               (const gchar*) data);
+		tracker_sparql_builder_subject_iri (metadata, idx->path().c_str());
+		tracker_sparql_builder_predicate_iri (metadata, predicate);
+		tracker_sparql_builder_object_unvalidated (metadata, (const gchar*) data);
 	}
 
 	void Tracker::TripleCollector::addValue (const AnalysisResult* idx,
@@ -259,15 +256,19 @@ namespace Tracker {
 	                                         int32_t value)
 	{
 		const gchar *predicate = predicateMapping (field);
+		gchar *value_str;
 
 		if (!predicateNeeded (predicate)) {
 			return;
 		}
 
-		tracker_statement_list_insert_with_int (metadata,
-		                                        idx->path().c_str(),
-		                                        predicate,
-		                                        (gint) value);
+		value_str = g_strdup_printf ("%d", value);
+
+		tracker_sparql_builder_subject_iri (metadata, idx->path().c_str());
+		tracker_sparql_builder_predicate_iri (metadata, predicate);
+		tracker_sparql_builder_object_unvalidated (metadata, value_str);
+
+		g_free (value_str);
 	}
 
 	void Tracker::TripleCollector::addValue (const AnalysisResult* idx,
@@ -275,15 +276,19 @@ namespace Tracker {
 	                                         uint32_t value )
 	{
 		const gchar *predicate = predicateMapping (field);
+		gchar *value_str;
 
 		if (!predicateNeeded (predicate)) {
 			return;
 		}
 
-		tracker_statement_list_insert_with_int (metadata,
-		                                        idx->path().c_str(),
-		                                        predicate,
-		                                        (gint) value);
+		value_str = g_strdup_printf ("%" G_GUINT32_FORMAT, value);
+
+		tracker_sparql_builder_subject_iri (metadata, idx->path().c_str());
+		tracker_sparql_builder_predicate_iri (metadata, predicate);
+		tracker_sparql_builder_object_unvalidated (metadata, value_str);
+
+		g_free (value_str);
 	}
 
 	void Tracker::TripleCollector::addValue (const AnalysisResult* idx,
@@ -291,15 +296,19 @@ namespace Tracker {
 	                                         double value )
 	{
 		const gchar *predicate = predicateMapping (field);
+		gchar *value_str;
 
 		if (!predicateNeeded (predicate)) {
 			return;
 		}
 
-		tracker_statement_list_insert_with_double (metadata,
-		                                           idx->path().c_str(),
-		                                           predicate,
-		                                           (gdouble) value);
+		value_str = g_strdup_printf ("%g", value);
+
+		tracker_sparql_builder_subject_iri (metadata, idx->path().c_str());
+		tracker_sparql_builder_predicate_iri (metadata, predicate);
+		tracker_sparql_builder_object_unvalidated (metadata, value_str);
+
+		g_free (value_str);
 	}
 
 	void Tracker::TripleCollector::addTriplet (const std::string& subject,
@@ -312,10 +321,9 @@ namespace Tracker {
 			return;
 		}
 
-		tracker_statement_list_insert (metadata,
-		                               subject.c_str(),
-		                               predicate_str,
-		                               object.c_str());
+		tracker_sparql_builder_subject_iri (metadata, subject.c_str());
+		tracker_sparql_builder_predicate_iri (metadata, predicate_str);
+		tracker_sparql_builder_object_unvalidated (metadata, object.c_str());
 	}
 
 	void Tracker::TripleCollector::addValue (const AnalysisResult* idx,
@@ -334,10 +342,9 @@ namespace Tracker {
 			return;
 		}
 
-		tracker_statement_list_insert (metadata,
-		                               idx->path().c_str(),
-		                               predicate,
-		                               value.c_str());
+		tracker_sparql_builder_subject_iri (metadata, idx->path().c_str());
+		tracker_sparql_builder_predicate_iri (metadata, predicate);
+		tracker_sparql_builder_object_unvalidated (metadata, value.c_str());
 	}
 
 	void Tracker::TripleCollector::finishAnalysis (const AnalysisResult*) { }



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