[tracker] tracker-extract-png.c: Use TrackerSparqlBuilder.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] tracker-extract-png.c: Use TrackerSparqlBuilder.
- Date: Wed, 4 Nov 2009 17:35:28 +0000 (UTC)
commit 4c66a854957c101b5cab9743ec1007dc84d6e5f7
Author: Carlos Garnacho <carlos lanedo com>
Date: Wed Nov 4 18:12:39 2009 +0100
tracker-extract-png.c: Use TrackerSparqlBuilder.
src/tracker-extract/tracker-extract-png.c | 135 ++++++++++++++++++-----------
1 files changed, 85 insertions(+), 50 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index dad0719..cbc1237 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -39,7 +39,6 @@
#include <libtracker-common/tracker-ontology.h>
#include <libtracker-common/tracker-type-utils.h>
-#include <libtracker-common/tracker-statement-list.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-utils.h>
@@ -101,11 +100,10 @@ insert_keywords (TrackerSparqlBuilder *metadata, const gchar *uri, gchar *keywor
if (keywords[len - 1] == '"')
keywords[len - 1] = '\0';
- for (keyw = strtok_r (keywords, ",; ", &lasts); keyw;
+ for (keyw = strtok_r (keywords, ",; ", &lasts); keyw;
keyw = strtok_r (NULL, ",; ", &lasts)) {
- tracker_statement_list_insert (metadata, uri,
- NIE_PREFIX "keyword",
- (const gchar*) keyw);
+ tracker_sparql_builder_predicate (metadata, "nie:keyword");
+ tracker_sparql_builder_object_unvalidated (metadata, keyw);
}
}
@@ -207,39 +205,51 @@ read_metadata (png_structp png_ptr, png_infop info_ptr, const gchar *uri, Tracke
if (png_data.comment) {
- tracker_statement_list_insert (metadata, uri, NIE_PREFIX "comment", png_data.comment);
+ tracker_sparql_builder_predicate (metadata, "nie:comment");
+ tracker_sparql_builder_object_unvalidated (metadata, png_data.comment);
g_free (png_data.comment);
}
if (merge_data.license) {
- tracker_statement_list_insert (metadata, uri, NIE_PREFIX "license", merge_data.license);
+ tracker_sparql_builder_predicate (metadata, "nie:license");
+ tracker_sparql_builder_object_unvalidated (metadata, merge_data.license);
g_free (merge_data.license);
}
if (merge_data.creator) {
- tracker_statement_list_insert (metadata, ":", RDF_PREFIX "type", NCO_PREFIX "Contact");
- tracker_statement_list_insert (metadata, ":", NCO_PREFIX "fullname", merge_data.creator);
- tracker_statement_list_insert (metadata, uri, NCO_PREFIX "creator", ":");
+ tracker_sparql_builder_predicate (metadata, "nco:creator");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Contact");
+
+ tracker_sparql_builder_predicate (metadata, "nco:fullname");
+ tracker_sparql_builder_object_unvalidated (metadata, merge_data.creator);
+ tracker_sparql_builder_object_blank_close (metadata);
g_free (merge_data.creator);
}
if (merge_data.date) {
- tracker_statement_list_insert (metadata, uri, NIE_PREFIX "contentCreated", merge_data.date);
+ tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
+ tracker_sparql_builder_object_unvalidated (metadata, merge_data.date);
g_free (merge_data.date);
}
if (merge_data.description) {
- tracker_statement_list_insert (metadata, uri, NIE_PREFIX "description", merge_data.description);
+ tracker_sparql_builder_predicate (metadata, "nie:description");
+ tracker_sparql_builder_object_unvalidated (metadata, merge_data.description);
g_free (merge_data.description);
}
if (merge_data.copyright) {
- tracker_statement_list_insert (metadata, uri, NIE_PREFIX "copyright", merge_data.copyright);
+ tracker_sparql_builder_predicate (metadata, "nie:copyright");
+ tracker_sparql_builder_object_unvalidated (metadata, merge_data.copyright);
g_free (merge_data.copyright);
}
if (merge_data.title) {
- tracker_statement_list_insert (metadata, uri, NIE_PREFIX "title", merge_data.title);
+ tracker_sparql_builder_predicate (metadata, "nie:title");
+ tracker_sparql_builder_object_unvalidated (metadata, merge_data.title);
g_free (merge_data.title);
}
@@ -255,98 +265,128 @@ read_metadata (png_structp png_ptr, png_infop info_ptr, const gchar *uri, Tracke
}
if (xmp_data.publisher) {
- tracker_statement_list_insert (metadata, ":", RDF_PREFIX "type", NCO_PREFIX "Contact");
- tracker_statement_list_insert (metadata, ":", NCO_PREFIX "fullname", xmp_data.publisher);
- tracker_statement_list_insert (metadata, uri, NCO_PREFIX "publisher", ":");
+ tracker_sparql_builder_predicate (metadata, "nco:publisher");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Contact");
+
+ tracker_sparql_builder_predicate (metadata, "nco:fullname");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.publisher);
+ tracker_sparql_builder_object_blank_close (metadata);
g_free (xmp_data.publisher);
}
if (xmp_data.type) {
- tracker_statement_list_insert (metadata, uri, DC_PREFIX "type", xmp_data.type);
+ tracker_sparql_builder_predicate (metadata, "dc:type");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.type);
g_free (xmp_data.type);
}
if (xmp_data.format) {
- tracker_statement_list_insert (metadata, uri, DC_PREFIX "format", xmp_data.format);
+ tracker_sparql_builder_predicate (metadata, "dc:format");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.format);
g_free (xmp_data.format);
}
if (xmp_data.identifier) {
- tracker_statement_list_insert (metadata, uri, DC_PREFIX "identifier", xmp_data.identifier);
+ tracker_sparql_builder_predicate (metadata, "dc:identifier");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.identifier);
g_free (xmp_data.identifier);
}
if (xmp_data.source) {
- tracker_statement_list_insert (metadata, uri, DC_PREFIX "source", xmp_data.source);
+ tracker_sparql_builder_predicate (metadata, "dc:source");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.source);
g_free (xmp_data.source);
}
if (xmp_data.language) {
- tracker_statement_list_insert (metadata, uri, DC_PREFIX "language", xmp_data.language);
+ tracker_sparql_builder_predicate (metadata, "dc:language");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.language);
g_free (xmp_data.language);
}
if (xmp_data.relation) {
- tracker_statement_list_insert (metadata, uri, DC_PREFIX "relation", xmp_data.relation);
+ tracker_sparql_builder_predicate (metadata, "dc:relation");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.relation);
g_free (xmp_data.relation);
}
if (xmp_data.coverage) {
- tracker_statement_list_insert (metadata, uri, DC_PREFIX "coverage", xmp_data.coverage);
+ tracker_sparql_builder_predicate (metadata, "dc:coverage");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.coverage);
g_free (xmp_data.coverage);
}
if (xmp_data.Make || xmp_data.Model) {
- gchar *final_camera = tracker_merge (" ", 2, xmp_data.Make, xmp_data.Model);
- tracker_statement_list_insert (metadata, uri, NMM_PREFIX "camera", final_camera);
+ gchar *final_camera = tracker_merge (" ", 2, xmp_data.Make, xmp_data.Model);
+
+ tracker_sparql_builder_predicate (metadata, "nmm:camera");
+ tracker_sparql_builder_object_unvalidated (metadata, final_camera);
g_free (final_camera);
}
if (xmp_data.Orientation) {
- tracker_statement_list_insert (metadata, uri, NFO_PREFIX "orientation", xmp_data.Orientation);
+ tracker_sparql_builder_predicate (metadata, "nfo:orientation");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.Orientation);
g_free (xmp_data.Orientation);
}
if (xmp_data.WhiteBalance) {
- tracker_statement_list_insert (metadata, uri, NMM_PREFIX "whiteBalance", xmp_data.WhiteBalance);
+ tracker_sparql_builder_predicate (metadata, "nmm:whiteBalance");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.WhiteBalance);
g_free (xmp_data.WhiteBalance);
}
if (xmp_data.FNumber) {
- tracker_statement_list_insert (metadata, uri, NMM_PREFIX "fnumber", xmp_data.FNumber);
+ tracker_sparql_builder_predicate (metadata, "nmm:fnumber");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.FNumber);
g_free (xmp_data.FNumber);
}
if (xmp_data.Flash) {
- tracker_statement_list_insert (metadata, uri, NMM_PREFIX "flash", xmp_data.Flash);
+ tracker_sparql_builder_predicate (metadata, "nmm:flash");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.Flash);
g_free (xmp_data.Flash);
}
if (xmp_data.FocalLength) {
- tracker_statement_list_insert (metadata, uri, NMM_PREFIX "focalLength", xmp_data.FocalLength);
+ tracker_sparql_builder_predicate (metadata, "nmm:focalLength");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.FocalLength);
g_free (xmp_data.FocalLength);
}
if (xmp_data.Artist || xmp_data.contributor) {
gchar *final_artist = tracker_coalesce (2, xmp_data.Artist, xmp_data.contributor);
- tracker_statement_list_insert (metadata, ":", RDF_PREFIX "type", NCO_PREFIX "Contact");
- tracker_statement_list_insert (metadata, ":", NCO_PREFIX "fullname", final_artist);
- tracker_statement_list_insert (metadata, uri, NCO_PREFIX "contributor", ":");
+
+ tracker_sparql_builder_predicate (metadata, "nco:contributor");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Contact");
+
+ tracker_sparql_builder_predicate (metadata, "nco:fullname");
+ tracker_sparql_builder_object_unvalidated (metadata, final_artist);
+ tracker_sparql_builder_object_blank_close (metadata);
g_free (final_artist);
}
if (xmp_data.ExposureTime) {
- tracker_statement_list_insert (metadata, uri, NMM_PREFIX "exposureTime", xmp_data.ExposureTime);
+ tracker_sparql_builder_predicate (metadata, "nmm:exposureTime");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.ExposureTime);
g_free (xmp_data.ExposureTime);
}
if (xmp_data.ISOSpeedRatings) {
- tracker_statement_list_insert (metadata, uri, NMM_PREFIX "isoSpeed", xmp_data.ISOSpeedRatings);
+ tracker_sparql_builder_predicate (metadata, "nmm:isoSpeed");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.ISOSpeedRatings);
g_free (xmp_data.ISOSpeedRatings);
}
if (xmp_data.MeteringMode) {
- tracker_statement_list_insert (metadata, uri, NMM_PREFIX "meteringMode", xmp_data.MeteringMode);
+ tracker_sparql_builder_predicate (metadata, "nmm:meteringMode");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.MeteringMode);
g_free (xmp_data.MeteringMode);
}
}
@@ -447,24 +487,19 @@ extract_png (const gchar *uri,
png_read_end (png_ptr, end_ptr);
- tracker_statement_list_insert (metadata, uri,
- RDF_PREFIX "type",
- NFO_PREFIX "Image");
-
- tracker_statement_list_insert (metadata, uri,
- RDF_PREFIX "type",
- NMM_PREFIX "Photo");
+ tracker_sparql_builder_subject_iri (metadata, uri);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nfo:Image");
+ tracker_sparql_builder_object (metadata, "nmm:Photo");
read_metadata (png_ptr, info_ptr, uri, metadata);
read_metadata (png_ptr, end_ptr, uri, metadata);
- tracker_statement_list_insert_with_int (metadata, uri,
- NFO_PREFIX "width",
- width);
+ tracker_sparql_builder_predicate (metadata, "nfo:width");
+ tracker_sparql_builder_object_int64 (metadata, width);
- tracker_statement_list_insert_with_int (metadata, uri,
- NFO_PREFIX "height",
- height);
+ tracker_sparql_builder_predicate (metadata, "nfo:height");
+ tracker_sparql_builder_object_int64 (metadata, height);
png_destroy_read_struct (&png_ptr, &info_ptr, &end_ptr);
tracker_file_close (f, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]