[rygel] tracker: Item factory provides key chains, not keys



commit 4925340a0ef5a7a6812dcf1a2e4d22380409e91f
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Dec 11 16:23:10 2009 +0200

    tracker: Item factory provides key chains, not keys
    
    This is to allow item factories to provide complex (chained) properties.

 .../tracker/rygel-tracker-item-factory.vala        |   21 +++++++-----
 .../tracker/rygel-tracker-music-item-factory.vala  |   16 +++++----
 .../rygel-tracker-picture-item-factory.vala        |   12 ++++---
 .../tracker/rygel-tracker-search-container.vala    |   33 ++++++++++++++-----
 .../tracker/rygel-tracker-video-item-factory.vala  |   14 +++++---
 5 files changed, 60 insertions(+), 36 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-item-factory.vala b/src/plugins/tracker/rygel-tracker-item-factory.vala
index 0a49516..22f37b0 100644
--- a/src/plugins/tracker/rygel-tracker-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-item-factory.vala
@@ -72,15 +72,18 @@ public abstract class Rygel.TrackerItemFactory {
         return item;
     }
 
-    public virtual ArrayList<string> get_metadata_keys () {
-        var keys = new ArrayList<string> ();
-        keys.add ("nfo:fileName");        // Metadata.FILE_NAME
-        keys.add ("nie:title");           // Metadata.TITLE
-        keys.add ("nie:mimeType");        // Metadata.MIME
-        keys.add ("nfo:fileSize");        // Metadata.SIZE
-        keys.add ("nie:contentCreated");  // Metadata.DATE
-
-        assert (keys.size == Metadata.LAST_KEY);
+    public virtual ArrayList<ArrayList<string>> get_metadata_key_chains () {
+        var keys = new ArrayList<ArrayList<string>> ();
+
+        for (var i = 0; i < Metadata.LAST_KEY; i++) {
+            keys.add (new ArrayList<string> ());
+        }
+
+        keys[Metadata.FILE_NAME].add ("nfo:fileName");
+        keys[Metadata.TITLE].add ("nie:title");
+        keys[Metadata.MIME].add ("nie:mimeType");
+        keys[Metadata.SIZE].add ("nfo:fileSize");
+        keys[Metadata.DATE].add ("nie:contentCreated");
 
         return keys;
     }
diff --git a/src/plugins/tracker/rygel-tracker-music-item-factory.vala b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
index 63231ab..0d987ea 100644
--- a/src/plugins/tracker/rygel-tracker-music-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
@@ -63,15 +63,17 @@ public class Rygel.TrackerMusicItemFactory : Rygel.TrackerItemFactory {
         return item;
     }
 
-    public override ArrayList<string> get_metadata_keys () {
-        var keys = base.get_metadata_keys ();
+    public override ArrayList<ArrayList<string>> get_metadata_key_chains () {
+        var keys = base.get_metadata_key_chains ();
 
-        keys.add ("nmm:length");      // MusicMetadata.DURATION
-        keys.add ("nmm:performer");   // MusicMetadata.AUDIO_ARTIST
-        keys.add ("nmm:musicAlbum");  // MusicMetadata.AUDIO_ALBUM
-        keys.add ("nmm:trackNumber"); // MusicMetadata.AUDIO_TRACK_NUM
+        for (var i = keys.size; i < MusicMetadata.LAST_KEY; i++) {
+            keys.add (new ArrayList<string> ());
+        }
 
-        assert (keys.size == MusicMetadata.LAST_KEY);
+        keys[MusicMetadata.DURATION].add ("nmm:length");
+        keys[MusicMetadata.AUDIO_ARTIST].add ("nmm:performer");
+        keys[MusicMetadata.AUDIO_ALBUM].add ("nmm:musicAlbum");
+        keys[MusicMetadata.AUDIO_TRACK_NUM].add ("nmm:trackNumber");
 
         return keys;
     }
diff --git a/src/plugins/tracker/rygel-tracker-picture-item-factory.vala b/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
index 29cbb60..5078ca2 100644
--- a/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
@@ -56,13 +56,15 @@ public class Rygel.TrackerPictureItemFactory : Rygel.TrackerItemFactory {
         return item;
     }
 
-    public override ArrayList<string> get_metadata_keys () {
-        var keys = base.get_metadata_keys ();
+    public override ArrayList<ArrayList<string>> get_metadata_key_chains () {
+        var keys = base.get_metadata_key_chains ();
 
-        keys.add ("nfo:width");  // PictureMetadata.WIDTH
-        keys.add ("nfo:height"); // PictureMetadata.HEIGHT
+        for (var i = keys.size; i < PictureMetadata.LAST_KEY; i++) {
+            keys.add (new ArrayList<string> ());
+        }
 
-        assert (keys.size == PictureMetadata.LAST_KEY);
+        keys[PictureMetadata.WIDTH].add ("nfo:width");
+        keys[PictureMetadata.HEIGHT].add ("nfo:height");
 
         return keys;
     }
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index 159e7a1..2035aa7 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -72,15 +72,30 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
                                                     false));
 
         var optional = new TrackerQueryTriplets ();
-        foreach (var key in this.item_factory.get_metadata_keys ()) {
-            var variable = "?" + key.replace (":", "_");
+        foreach (var chain in this.item_factory.get_metadata_key_chains ()) {
+            string next_subject = null;
 
-            variables.add (variable);
+            foreach (var key in chain) {
+                var variable = "?" + key.replace (":", "_");
 
-            var triplet = new TrackerQueryTriplet (ITEM_VARIABLE,
-                                                   key,
-                                                   variable);
-            optional.add (triplet);
+                string subject;
+                if (key == chain.first ()) {
+                    subject = ITEM_VARIABLE;
+                } else {
+                    subject = next_subject;
+                }
+
+                var triplet = new TrackerQueryTriplet (subject,
+                                                       key,
+                                                       variable);
+                optional.add (triplet);
+
+                if (key == chain.last ()) {
+                    variables.add (variable);
+                }
+
+                next_subject = variable;
+            }
         }
 
         this.query = new TrackerQuery (variables,
diff --git a/src/plugins/tracker/rygel-tracker-video-item-factory.vala b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
index 2c4e8dd..a450ab2 100644
--- a/src/plugins/tracker/rygel-tracker-video-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
@@ -60,14 +60,16 @@ public class Rygel.TrackerVideoItemFactory : Rygel.TrackerItemFactory {
         return item;
     }
 
-    public override ArrayList<string> get_metadata_keys () {
-        var keys = base.get_metadata_keys ();
+    public override ArrayList<ArrayList<string>> get_metadata_key_chains () {
+        var keys = base.get_metadata_key_chains ();
 
-        keys.add ("nfo:width");  // VideoMetadata.WIDTH
-        keys.add ("nfo:height"); // VideoMetadata.HEIGHT
-        keys.add ("nmm:length"); // VideoMetadata.DURATION
+        for (var i = keys.size; i < VideoMetadata.LAST_KEY; i++) {
+            keys.add (new ArrayList<string> ());
+        }
 
-        assert (keys.size == VideoMetadata.LAST_KEY);
+        keys[VideoMetadata.WIDTH].add ("nfo:width");
+        keys[VideoMetadata.HEIGHT].add ("nfo:height");
+        keys[VideoMetadata.DURATION].add ("nmm:length");
 
         return keys;
     }



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