[rygel] external: Implement MediaContainer.find_object()



commit 535a2c4a9c33063526d9d045a12deaa7d27aa748
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Jun 16 19:44:58 2010 +0300

    external: Implement MediaContainer.find_object()
    
    Since the UPnP IDs of the objects are the same as their D-Bus paths (
    execpt for the root container), we are able to provide a much more
    efficient implementation of search by ID.

 src/plugins/external/rygel-external-container.vala |   50 ++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/external/rygel-external-container.vala b/src/plugins/external/rygel-external-container.vala
index 7b87e73..4a77c42 100644
--- a/src/plugins/external/rygel-external-container.vala
+++ b/src/plugins/external/rygel-external-container.vala
@@ -25,6 +25,7 @@
 using GUPnP;
 using DBus;
 using Gee;
+using FreeDesktop;
 
 /**
  * Represents an external container.
@@ -134,6 +135,55 @@ public class Rygel.ExternalContainer : Rygel.MediaContainer {
         return yield this.create_media_objects (result);
     }
 
+    public override async MediaObject? find_object (string       id,
+                                                    Cancellable? cancellable)
+                                                    throws GLib.Error {
+        MediaObject media_object = null;
+
+        // Create proxy to MediaObject iface
+        var actual_object = this.connection.get_object (this.service_name, id)
+                            as ExternalMediaObject;
+
+        if (actual_object.object_type == "container") {
+            media_object = this.find_container_by_id (id);
+
+            if (media_object == null) {
+                // Not a child container, lets search in child containers then
+                foreach (var container in this.containers) {
+                    media_object = yield container.find_object (id,
+                                                                cancellable);
+
+                    if (media_object != null) {
+                        break;
+                    }
+                }
+            }
+        } else {
+            var parent_container = new ExternalDummyContainer
+                                        ((string) actual_object.parent,
+                                         "LaLaLa",
+                                         0,
+                                         null);
+
+            var props_iface = this.connection.get_object (this.service_name, id)
+                              as Properties;
+
+            var props = yield props_iface.get_all (ExternalMediaItem.IFACE);
+
+            // Its an item then
+            media_object = yield this.item_factory.create (
+                                        id,
+                                        actual_object.object_type,
+                                        actual_object.display_name,
+                                        props,
+                                        this.service_name,
+                                        this.host_ip,
+                                        parent_container);
+        }
+
+        return media_object;
+    }
+
     private async Gee.List<MediaObject> create_media_objects (
                                         HashTable<string,Value?>[] all_props,
                                         MediaContainer?            parent



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