[rygel] tracker: Set item size in the tracker-miner graph



commit a1ad9ec77c7d08c64151db5fdce2cd4c651bcaf1
Author: Jens Georg <mail jensge org>
Date:   Fri May 6 11:44:08 2011 +0200

    tracker: Set item size in the tracker-miner graph
    
    Otherwise the miner doesn't correct it after extracting.
    
    This fixed DLNA requirement 7.3.128.7

 .../tracker/rygel-tracker-insertion-query.vala     |   23 +++++++++++++------
 .../tracker/rygel-tracker-query-triplet.vala       |   20 +++++++++++++++++
 .../tracker/rygel-tracker-query-triplets.vala      |    9 +++++++-
 3 files changed, 44 insertions(+), 8 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-insertion-query.vala b/src/plugins/tracker/rygel-tracker-insertion-query.vala
index 4f342f3..511e1ef 100644
--- a/src/plugins/tracker/rygel-tracker-insertion-query.vala
+++ b/src/plugins/tracker/rygel-tracker-insertion-query.vala
@@ -29,6 +29,14 @@ public class Rygel.Tracker.InsertionQuery : Query {
     private const string TEMP_ID = "x";
     private const string QUERY_ID = "_:" + TEMP_ID;
 
+    // We need to add the size in the miner's graph so that the miner will
+    // update it and correct a (possibly wrong) size we got via CreateItem
+    // (DLNA requirement 7.3.128.7)
+    // FIXME: Use constant from libtracker-miner once we port to
+    // libtracker-sparql
+    private const string MINER_GRAPH =
+                              "urn:uuid:472ed0cc-40ff-4e37-9c0c-062d78656540";
+
     public string id;
 
     public InsertionQuery (MediaItem item, string category) {
@@ -55,19 +63,20 @@ public class Rygel.Tracker.InsertionQuery : Query {
         triplets.add (new QueryTriplet (QUERY_ID,
                                         "nie:url",
                                         "\"" + item.uris[0] + "\""));
-        if (item.size > 0) {
-            triplets.add (new QueryTriplet
-                                        (QUERY_ID,
-                                         "nie:byteSize",
-                                         "\"" + item.size.to_string () + "\""));
-        }
-
         var now = TimeVal ();
         var date = now.to_iso8601 ();
         triplets.add (new QueryTriplet (QUERY_ID,
                                         "nie:contentCreated",
                                         "\"" + date + "\""));
 
+        if (item.size > 0) {
+            triplets.add (new QueryTriplet.with_graph
+                                        (MINER_GRAPH,
+                                         QUERY_ID,
+                                         "nie:byteSize",
+                                         "\"" + item.size.to_string () + "\""));
+        }
+
         base (triplets);
     }
 
diff --git a/src/plugins/tracker/rygel-tracker-query-triplet.vala b/src/plugins/tracker/rygel-tracker-query-triplet.vala
index 6543102..d81041e 100644
--- a/src/plugins/tracker/rygel-tracker-query-triplet.vala
+++ b/src/plugins/tracker/rygel-tracker-query-triplet.vala
@@ -26,6 +26,7 @@ using Gee;
  * Represents SPARQL Triplet
  */
 public class Rygel.Tracker.QueryTriplet {
+    public string graph;
     public string subject;
     public string predicate;
     public string obj;
@@ -33,11 +34,22 @@ public class Rygel.Tracker.QueryTriplet {
     public QueryTriplet next;
 
     public QueryTriplet (string subject, string predicate, string obj) {
+        this.graph = null;
         this.subject = subject;
         this.predicate = predicate;
         this.obj = obj;
     }
 
+    public QueryTriplet.with_graph (string graph,
+                                    string subject,
+                                    string predicate,
+                                    string object) {
+        this.graph = graph;
+        this.subject = subject;
+        this.predicate = predicate;
+        this.obj = object;
+    }
+
     public QueryTriplet.chain (string       subject,
                                string       predicate,
                                QueryTriplet next) {
@@ -75,6 +87,10 @@ public class Rygel.Tracker.QueryTriplet {
     public string to_string (bool include_subject = true) {
         string str = "";
 
+        if (graph != null) {
+            str += "GRAPH <%s> {".printf (this.graph);
+        }
+
         if (include_subject) {
             str += " " + subject;
         }
@@ -87,6 +103,10 @@ public class Rygel.Tracker.QueryTriplet {
             str += " " + this.obj;
         }
 
+        if (graph != null) {
+            str += "}";
+        }
+
         return str;
     }
 }
diff --git a/src/plugins/tracker/rygel-tracker-query-triplets.vala b/src/plugins/tracker/rygel-tracker-query-triplets.vala
index f25a55e..587919e 100644
--- a/src/plugins/tracker/rygel-tracker-query-triplets.vala
+++ b/src/plugins/tracker/rygel-tracker-query-triplets.vala
@@ -46,7 +46,8 @@ public class Rygel.Tracker.QueryTriplets : ArrayList<QueryTriplet> {
             str += this[i].to_string (include_subject);
 
             if (i < this.size - 1) {
-                include_subject = this[i].subject != this[i + 1].subject;
+                include_subject = this[i].subject != this[i + 1].subject ||
+                                  this.check_graph_change (i);
 
                 if (include_subject) {
                     str += " . ";
@@ -66,4 +67,10 @@ public class Rygel.Tracker.QueryTriplets : ArrayList<QueryTriplet> {
             this.add (triplet);
         }
     }
+
+    private bool check_graph_change (int i) {
+        return (this[i].graph == null && this[i + 1].graph != null) ||
+               (this[i].graph != null && this[i + 1].graph == null) ||
+               (this[i].graph != this[i + 1].graph);
+    }
 }



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