[rygel] tracker: create_item implemented by SearchContainer



commit 255722fd9de9dcfbc3317d28b010e7d684d71598
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Sep 18 15:21:43 2009 +0300

    tracker: create_item implemented by SearchContainer
    
    create_item should be implemented by SearchContainer.

 .../tracker/rygel-tracker-get-metadata-result.vala |    4 ++-
 .../tracker/rygel-tracker-image-category.vala      |    7 -----
 .../tracker/rygel-tracker-music-category.vala      |    7 -----
 .../tracker/rygel-tracker-search-container.vala    |   24 +++++++++++++++++++-
 .../tracker/rygel-tracker-search-result.vala       |    5 +++-
 .../tracker/rygel-tracker-video-category.vala      |    7 -----
 6 files changed, 30 insertions(+), 24 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-get-metadata-result.vala b/src/plugins/tracker/rygel-tracker-get-metadata-result.vala
index 82ae448..e8ff568 100644
--- a/src/plugins/tracker/rygel-tracker-get-metadata-result.vala
+++ b/src/plugins/tracker/rygel-tracker-get-metadata-result.vala
@@ -46,7 +46,9 @@ public class Rygel.TrackerGetMetadataResult :
         var search_container = (TrackerSearchContainer) this.source_object;
 
         string path = search_container.get_item_path (item_id);
-        this.data = search_container.create_item (path, metadata);
+        this.data = search_container.create_item (search_container.service,
+                                                  path,
+                                                  metadata);
 
         this.complete ();
     }
diff --git a/src/plugins/tracker/rygel-tracker-image-category.vala b/src/plugins/tracker/rygel-tracker-image-category.vala
index f154447..47ba965 100644
--- a/src/plugins/tracker/rygel-tracker-image-category.vala
+++ b/src/plugins/tracker/rygel-tracker-image-category.vala
@@ -34,12 +34,5 @@ public class Rygel.TrackerImageCategory : Rygel.TrackerSearchContainer {
     protected override string[] get_metadata_keys () {
         return TrackerImageItem.get_metadata_keys ();
     }
-
-    protected override MediaItem? create_item (string path, string[] metadata) {
-        return new TrackerImageItem (this.id + ":" + path,
-                                     path,
-                                     this,
-                                     metadata);
-    }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-music-category.vala b/src/plugins/tracker/rygel-tracker-music-category.vala
index d7ee4ea..66b02a1 100644
--- a/src/plugins/tracker/rygel-tracker-music-category.vala
+++ b/src/plugins/tracker/rygel-tracker-music-category.vala
@@ -34,12 +34,5 @@ public class Rygel.TrackerMusicCategory : Rygel.TrackerSearchContainer {
     protected override string[] get_metadata_keys () {
         return TrackerMusicItem.get_metadata_keys ();
     }
-
-    protected override MediaItem? create_item (string path, string[] metadata) {
-        return new TrackerMusicItem (this.id + ":" + path,
-                                     path,
-                                     this,
-                                     metadata);
-    }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index 07f4717..2896c29 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -206,6 +206,29 @@ public abstract class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
         }
     }
 
+    public MediaItem? create_item (string   service,
+                                   string   path,
+                                   string[] metadata) {
+        if (service == TrackerVideoItem.SERVICE) {
+            return new TrackerVideoItem (this.id + ":" + path,
+                                         path,
+                                         this,
+                                         metadata);
+        } else if (service == TrackerImageItem.SERVICE) {
+            return new TrackerImageItem (this.id + ":" + path,
+                                         path,
+                                         this,
+                                         metadata);
+        } else if (service == TrackerMusicItem.SERVICE) {
+            return new TrackerMusicItem (this.id + ":" + path,
+                                         path,
+                                         this,
+                                         metadata);
+        } else {
+            return null;
+        }
+    }
+
     private void create_proxies () throws GLib.Error {
         DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION);
 
@@ -231,6 +254,5 @@ public abstract class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
     }
 
     protected abstract string[] get_metadata_keys ();
-    protected abstract MediaItem? create_item (string path, string[] metadata);
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-search-result.vala b/src/plugins/tracker/rygel-tracker-search-result.vala
index b3fb66b..7af3c80 100644
--- a/src/plugins/tracker/rygel-tracker-search-result.vala
+++ b/src/plugins/tracker/rygel-tracker-search-result.vala
@@ -48,9 +48,12 @@ public class Rygel.TrackerSearchResult :
         /* Iterate through all items */
         for (uint i = 0; i < search_result.length; i++) {
             string child_path = search_result[i][0];
+            string service = search_result[i][1];
             string[] metadata = this.slice_strv_tail (search_result[i], 2);
 
-            var item = search_container.create_item (child_path, metadata);
+            var item = search_container.create_item (service,
+                                                     child_path,
+                                                     metadata);
             this.data.add (item);
         }
 
diff --git a/src/plugins/tracker/rygel-tracker-video-category.vala b/src/plugins/tracker/rygel-tracker-video-category.vala
index c8577a2..a4b1723 100644
--- a/src/plugins/tracker/rygel-tracker-video-category.vala
+++ b/src/plugins/tracker/rygel-tracker-video-category.vala
@@ -34,12 +34,5 @@ public class Rygel.TrackerVideoCategory : Rygel.TrackerSearchContainer {
     protected override string[] get_metadata_keys () {
         return TrackerVideoItem.get_metadata_keys ();
     }
-
-    protected override MediaItem? create_item (string path, string[] metadata) {
-        return new TrackerVideoItem (this.id + ":" + path,
-                                     path,
-                                     this,
-                                     metadata);
-    }
 }
 



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