rygel r494 - in trunk/src: plugins/dvb plugins/test plugins/tracker rygel



Author: zeeshanak
Date: Wed Jan 28 12:33:12 2009
New Revision: 494
URL: http://svn.gnome.org/viewvc/rygel?rev=494&view=rev

Log:
Save ContentDir implementations from handling HTTPServer.item_requested.

Modified:
   trunk/src/plugins/dvb/rygel-dvb-channel-group.vala
   trunk/src/plugins/test/rygel-test-content-dir.vala
   trunk/src/plugins/tracker/rygel-media-tracker.vala
   trunk/src/rygel/rygel-content-directory.vala

Modified: trunk/src/plugins/dvb/rygel-dvb-channel-group.vala
==============================================================================
--- trunk/src/plugins/dvb/rygel-dvb-channel-group.vala	(original)
+++ trunk/src/plugins/dvb/rygel-dvb-channel-group.vala	Wed Jan 28 12:33:12 2009
@@ -60,8 +60,6 @@
         this.http_server = http_server;
 
         this.fetch_channels ();
-
-        this.http_server.item_requested += this.on_item_requested;
     }
 
     public ArrayList<DVBChannel> get_channels (uint     offset,
@@ -120,14 +118,5 @@
 
         this.child_count = this.channels.size;
     }
-
-    private void on_item_requested (HTTPServer    http_server,
-                                    string        item_id,
-                                    out MediaItem item) {
-        var channel = this.find_channel (item_id);
-        if (channel != null) {
-            item = channel;
-        }
-    }
 }
 

Modified: trunk/src/plugins/test/rygel-test-content-dir.vala
==============================================================================
--- trunk/src/plugins/test/rygel-test-content-dir.vala	(original)
+++ trunk/src/plugins/test/rygel-test-content-dir.vala	Wed Jan 28 12:33:12 2009
@@ -38,7 +38,6 @@
         // Chain-up to base first
         base.constructed ();
 
-        this.http_server.item_requested += this.on_item_requested;
         this.http_server.need_stream_source += this.on_need_stream_source;
 
         this.items = new ArrayList<MediaItem> ();
@@ -97,12 +96,6 @@
     }
 
     /* Private methods */
-    private void on_item_requested (HTTPServer    http_server,
-                                    string        item_id,
-                                    out MediaItem item) {
-        item = (MediaItem) this.find_object_by_id (item_id);
-    }
-
     private void on_need_stream_source (HTTPServer  http_server,
                                         MediaItem   item,
                                         out Element src) {

Modified: trunk/src/plugins/tracker/rygel-media-tracker.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-media-tracker.vala	(original)
+++ trunk/src/plugins/tracker/rygel-media-tracker.vala	Wed Jan 28 12:33:12 2009
@@ -40,8 +40,6 @@
         // Chain-up to base first
         base.constructed ();
 
-        this.http_server.item_requested += on_item_requested;
-
         this.containers = new ArrayList<TrackerContainer> ();
         this.containers.add
                         (new TrackerContainer ("16",
@@ -170,15 +168,6 @@
         return container;
     }
 
-    private void on_item_requested (HTTPServer    http_server,
-                                    string        item_id,
-                                    out MediaItem item) {
-        TrackerContainer container = get_item_parent (item_id);
-
-        if (container != null)
-            item = container.get_item_from_db (item_id);
-    }
-
     private ArrayList<MediaObject> slice_object_list (
                                         ArrayList<MediaObject> list,
                                         uint                   offset,

Modified: trunk/src/rygel/rygel-content-directory.vala
==============================================================================
--- trunk/src/rygel/rygel-content-directory.vala	(original)
+++ trunk/src/rygel/rygel-content-directory.vala	Wed Jan 28 12:33:12 2009
@@ -99,6 +99,8 @@
         this.setup_root_container ();
         this.http_server = new HTTPServer (context, this.get_type ().name ());
 
+        this.http_server.item_requested += this.on_item_requested;
+
         this.system_update_id = 0;
         this.feature_list =
             "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
@@ -369,5 +371,20 @@
         args.number_returned = children.size;
         args.update_id = uint32.MAX;
     }
+
+    private void on_item_requested (HTTPServer    http_server,
+                                    string        item_id,
+                                    out MediaItem item) {
+        try {
+            var media_object = this.find_object_by_id (item_id);
+            if (media_object is MediaItem) {
+                item = (MediaItem) media_object;
+            }
+        } catch (Error err) {
+            warning ("Requested item '%s' not found: %s\n",
+                     item_id,
+                     err.message);
+        }
+    }
 }
 



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