Item constructors take an optional metadata argument.
authorZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Sat, 14 Feb 2009 15:23:49 +0000 (15:23 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Sat, 14 Feb 2009 15:23:49 +0000 (15:23 +0000)
This is to avoid each item having to fetch it's metadata from Tracker on
creation if the creator of the item already has it's metadata at hand.

svn path=/trunk/; revision=570

src/plugins/tracker/rygel-tracker-container.vala
src/plugins/tracker/rygel-tracker-image-item.vala
src/plugins/tracker/rygel-tracker-item.vala
src/plugins/tracker/rygel-tracker-music-item.vala
src/plugins/tracker/rygel-tracker-video-item.vala

index 903e89a..d2b2426 100644 (file)
@@ -216,11 +216,20 @@ public class Rygel.TrackerContainer : MediaContainer {
         MediaItem item;
 
         if (this.child_class == MediaItem.VIDEO_CLASS) {
-            item = new TrackerVideoItem (this.id + ":" + path, path, this);
+            item = new TrackerVideoItem (this.id + ":" + path,
+                                         path,
+                                         this,
+                                         null);
         } else if (this.child_class == MediaItem.IMAGE_CLASS) {
-            item = new TrackerImageItem (this.id + ":" + path, path, this);
+            item = new TrackerImageItem (this.id + ":" + path,
+                                         path,
+                                         this,
+                                         null);
         } else {
-            item = new TrackerMusicItem (this.id + ":" + path, path, this);
+            item = new TrackerMusicItem (this.id + ":" + path,
+                                         path,
+                                         this,
+                                         null);
         }
 
         return item;
index 335608f..80e7259 100644 (file)
@@ -43,10 +43,11 @@ public class Rygel.TrackerImageItem : TrackerItem {
         LAST_KEY
     }
 
-    public TrackerImageItem (string              id,
-                             string              path,
-                             TrackerContainer    parent) throws GLib.Error {
-        base (id, path, parent);
+    public TrackerImageItem (string           id,
+                             string           path,
+                             TrackerContainer parent,
+                             string[]?        metadata) throws GLib.Error {
+        base (id, path, parent, metadata);
     }
 
     public override string[] get_metadata_keys () {
index 47e4639..64b4b30 100644 (file)
@@ -34,13 +34,20 @@ public abstract class Rygel.TrackerItem : MediaItem {
 
     public TrackerItem (string           id,
                         string           path,
-                        TrackerContainer parent) throws GLib.Error {
+                        TrackerContainer parent,
+                        string[]?        metadata) throws GLib.Error {
         base (id, parent.id, "", parent.child_class);
 
         this.path = path;
         this.parent = parent;
 
-        var values = this.fetch_metadata ();
+        string[] values;
+        if (metadata == null) {
+            values = this.fetch_metadata ();
+        } else {
+            values = metadata;
+        }
+
         this.init_from_metadata (values);
     }
 
index 5da6bc3..746a524 100644 (file)
@@ -43,10 +43,11 @@ public class Rygel.TrackerMusicItem : TrackerItem {
         LAST_KEY
     }
 
-    public TrackerMusicItem (string              id,
-                             string              path,
-                             TrackerContainer    parent) throws GLib.Error {
-        base (id, path, parent);
+    public TrackerMusicItem (string           id,
+                             string           path,
+                             TrackerContainer parent,
+                             string[]?        metadata) throws GLib.Error {
+        base (id, path, parent, metadata);
     }
 
     public override string[] get_metadata_keys () {
index c10b687..77e5e1f 100644 (file)
@@ -41,10 +41,11 @@ public class Rygel.TrackerVideoItem : TrackerItem {
         LAST_KEY
     }
 
-    public TrackerVideoItem (string              id,
-                             string              path,
-                             TrackerContainer    parent) throws GLib.Error {
-        base (id, path, parent);
+    public TrackerVideoItem (string           id,
+                             string           path,
+                             TrackerContainer parent,
+                             string[]?        metadata) throws GLib.Error {
+        base (id, path, parent, metadata);
     }
 
     public override string[] get_metadata_keys () {