DVBChannelGroup:get_channels does the slicing.
authorZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Wed, 28 Jan 2009 12:33:41 +0000 (12:33 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Wed, 28 Jan 2009 12:33:41 +0000 (12:33 +0000)
DVBChannelGroup:get_channels does the slicing rather than DVBContentDir.

svn path=/trunk/; revision=501

src/plugins/dvb/rygel-dvb-channel-group.vala
src/plugins/dvb/rygel-dvb-content-dir.vala

index 031a37b..c522d83 100644 (file)
@@ -62,13 +62,20 @@ public class Rygel.DVBChannelGroup : MediaContainer {
         this.fetch_channels ();
     }
 
-    public ArrayList<DVBChannel> get_channels (uint     offset,
-                                               uint     max_count,
-                                               out uint child_count)
-                                               throws GLib.Error {
+    public Gee.List<DVBChannel> get_channels (uint     offset,
+                                              uint     max_count,
+                                              out uint child_count)
+                                              throws GLib.Error {
         child_count = this.channels.size;
 
-        return this.channels;
+        if (max_count == 0) {
+            max_count = child_count;
+        }
+
+        uint stop = offset + max_count;
+        stop = stop.clamp (0, child_count);
+
+        return this.channels.slice ((int) offset, (int) stop);
     }
 
     public DVBChannel find_channel (string id) {
index d768d29..268a4d4 100644 (file)
@@ -126,25 +126,14 @@ public class Rygel.DVBContentDir : ContentDirectory {
             throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
         }
 
-        Gee.List<MediaObject> children = null;
-
         var channels = group.get_channels (offset,
                                            max_count,
                                            out child_count);
-        if (max_count == 0) {
-            max_count = child_count;
-        }
-
-        uint stop = offset + max_count;
-
-        stop = stop.clamp (0, child_count);
-        children = channels.slice ((int) offset, (int) stop);
-
-        if (children == null) {
+        if (channels == null) {
             throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
         }
 
-        return children;
+        return channels;
     }
 
     public override Gee.List<MediaObject> get_root_children (