[tracker/experiment-with-roi: 7/13] libtracker-extract: new function to generate sparql of the region struct



commit 5e8940ee18da2a707f1fe7b0e2bf1f3851bdcd5c
Author: Ivan Frade <ivan frade gmail com>
Date:   Mon Aug 1 17:14:39 2011 +0300

    libtracker-extract: new function to generate sparql of the region struct
    
    Input arguments "uri" and "where" are not needed, but I keep the there
    for consistency with the other sparql-generation function.

 src/libtracker-extract/tracker-xmp.c        |   24 +++++++++++++++++++++---
 src/libtracker-extract/tracker-xmp.h        |   25 +++++++++++++++----------
 tests/libtracker-extract/tracker-test-xmp.c |    9 ++++++---
 3 files changed, 42 insertions(+), 16 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index c85aa56..079cc7b 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -839,8 +839,6 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
                    TrackerXmpData       *data)
 {
 	GPtrArray        *keywords;
-        GList            *iter;
-        TrackerXmpRegion *region;
 	guint i;
 
 	g_return_val_if_fail (TRACKER_SPARQL_IS_BUILDER (metadata), FALSE);
@@ -1160,6 +1158,27 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
 	}
 
 
+        if (data->regions) {
+                tracker_xmp_apply_regions (preupdate, metadata, where, uri, data);
+        }
+
+	return TRUE;
+}
+
+void 
+tracker_xmp_apply_regions (TrackerSparqlBuilder *preupdate,
+                           TrackerSparqlBuilder *metadata,
+                           GString              *where,
+                           const gchar          *uri,
+                           TrackerXmpData       *data)
+{
+        GList            *iter;
+        TrackerXmpRegion *region;
+
+        if (!data->regions) {
+                return;
+        }
+        
         for (iter = data->regions; iter != NULL; iter = iter->next) {
                 gchar *reguuid;
                 reguuid = tracker_sparql_get_uuid_urn ();
@@ -1229,5 +1248,4 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
                 g_free (reguuid);
         }
 
-	return TRUE;
 }
diff --git a/src/libtracker-extract/tracker-xmp.h b/src/libtracker-extract/tracker-xmp.h
index 3a094b0..1a3ed32 100644
--- a/src/libtracker-extract/tracker-xmp.h
+++ b/src/libtracker-extract/tracker-xmp.h
@@ -105,16 +105,21 @@ typedef struct {
         gchar *link_uri;
 } TrackerXmpRegion;
 
-TrackerXmpData * tracker_xmp_new   (const gchar          *buffer,
-                                    gsize                 len,
-                                    const gchar          *uri);
-void             tracker_xmp_free  (TrackerXmpData       *data);
-gboolean         tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
-                                    TrackerSparqlBuilder *metadata,
-                                    const gchar          *graph,
-                                    GString              *where,
-                                    const gchar          *uri,
-                                    TrackerXmpData       *data);
+TrackerXmpData *tracker_xmp_new           (const gchar          *buffer,
+                                           gsize                 len,
+                                           const gchar          *uri);
+void            tracker_xmp_free          (TrackerXmpData       *data);
+gboolean        tracker_xmp_apply         (TrackerSparqlBuilder *preupdate,
+                                           TrackerSparqlBuilder *metadata,
+                                           const gchar          *graph,
+                                           GString              *where,
+                                           const gchar          *uri,
+                                           TrackerXmpData       *data);
+void            tracker_xmp_apply_regions (TrackerSparqlBuilder *preupdate,
+                                           TrackerSparqlBuilder *metadata,
+                                           GString              *where,
+                                           const gchar          *uri,
+                                           TrackerXmpData       *data);
 
 #ifndef TRACKER_DISABLE_DEPRECATED
 
diff --git a/tests/libtracker-extract/tracker-test-xmp.c b/tests/libtracker-extract/tracker-test-xmp.c
index cd7bcc2..a9624e6 100644
--- a/tests/libtracker-extract/tracker-test-xmp.c
+++ b/tests/libtracker-extract/tracker-test-xmp.c
@@ -349,7 +349,8 @@ debug_print_sparql (TrackerXmpData *data)
 {
         /* To print the sparql */
         TrackerSparqlBuilder *metadata, *preupdate;
-        GString              *where;
+        GString *where;
+        const gchar *graph = NULL;
 
 	metadata = tracker_sparql_builder_new_update ();
 	preupdate = tracker_sparql_builder_new_update ();
@@ -358,7 +359,7 @@ debug_print_sparql (TrackerXmpData *data)
 	tracker_sparql_builder_insert_open (metadata, NULL);
         tracker_sparql_builder_subject_iri (metadata, "urn:uuid:test");
 
-        tracker_xmp_apply (preupdate, metadata, where, "urn:uuid:test", data);
+        tracker_xmp_apply (preupdate, metadata, graph, where, "urn:uuid:test", data);
 
 	tracker_sparql_builder_insert_close (metadata);
 
@@ -406,7 +407,9 @@ test_xmp_regions (void)
         g_assert_cmpstr (region->type, ==, "Face");
         g_assert_cmpstr (region->title, ==, "John Doe");
 
-        //debug_print_sparql (data);
+        if (0) {
+	        debug_print_sparql (data);
+        }
         
         tracker_xmp_free (data);
 }



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