[rygel] tracker: Let the miner decide the RDF type



commit 193aff3bd259a1437ee1d243d0dcc49dae645ac2
Author: Jens Georg <mail jensge org>
Date:   Tue Oct 25 10:06:53 2011 +0200

    tracker: Let the miner decide the RDF type
    
    We only set the generic RDF type nfo:Media to prevent situations where
    a client uploads e.g. an image with DIDL meta-data for an MP3.
    Previously the item would then be a nmm:Music (from CreateItem) and
    nmm:Photo (from the miner).

 .../tracker/rygel-tracker-insertion-query.vala     |    2 +-
 .../tracker/rygel-tracker-search-container.vala    |   23 ++++++++++++++++---
 2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-insertion-query.vala b/src/plugins/tracker/rygel-tracker-insertion-query.vala
index 62fae0d..05c1e1a 100644
--- a/src/plugins/tracker/rygel-tracker-insertion-query.vala
+++ b/src/plugins/tracker/rygel-tracker-insertion-query.vala
@@ -60,7 +60,7 @@ public class Rygel.Tracker.InsertionQuery : Query {
         }
 
         var triplets = new QueryTriplets ();
-        triplets.add (new QueryTriplet (QUERY_ID, "a", category));
+        triplets.add (new QueryTriplet (QUERY_ID, "a", "nfo:Media"));
         triplets.add (new QueryTriplet (QUERY_ID, "a", type));
         triplets.add (new QueryTriplet (QUERY_ID, "nmm:uPnPShared", "true"));
         triplets.add (new QueryTriplet (QUERY_ID, "tracker:available", "true"));
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index c3762d9..40f5f36 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -116,13 +116,16 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
                                               uint              offset,
                                               uint              max_count,
                                               out uint          total_matches,
-                                              Cancellable?      cancellable)
+                                              Cancellable?      cancellable,
+                                              bool              generic_type = false)
                                               throws GLib.Error {
         var results = new MediaObjects ();
 
         var query = this.create_query (expression as RelationalExpression,
                                        (int) offset,
-                                       (int) max_count);
+                                       (int) max_count,
+                                       generic_type);
+
         if (query != null) {
             yield query.execute (this.resources);
 
@@ -159,7 +162,8 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
                                                 0,
                                                 1,
                                                 out total_matches,
-                                                cancellable);
+                                                cancellable,
+                                                true);
         if (results.size > 0) {
             return results[0];
         } else {
@@ -216,7 +220,8 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
 
     private SelectionQuery? create_query (RelationalExpression? expression,
                                           int                   offset,
-                                          int                   max_count) {
+                                          int                   max_count,
+                                          bool                  generic_type) {
         if (expression.operand1 == "upnp:class" &&
             !this.item_factory.upnp_class.has_prefix (expression.operand2)) {
             return null;
@@ -237,6 +242,16 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
             }
         }
 
+        // Drop to generic RDF type for find_object
+        if (generic_type) {
+            foreach (var triplet in query.triplets) {
+                if (triplet.predicate == "a" &&
+                    triplet.obj.has_prefix ("nmm:")) {
+                    triplet.obj = "nfo:Media";
+                }
+            }
+        }
+
         query.offset = offset;
         query.max_count = max_count;
 



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