From 74d97cb917248a1c198b25e20baf1a723760bbb0 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Wed, 28 Jan 2009 12:33:41 +0000 Subject: [PATCH] DVBChannelGroup:get_channels does the slicing. DVBChannelGroup:get_channels does the slicing rather than DVBContentDir. svn path=/trunk/; revision=501 --- src/plugins/dvb/rygel-dvb-channel-group.vala | 17 ++++++++++++----- src/plugins/dvb/rygel-dvb-content-dir.vala | 15 ++------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/plugins/dvb/rygel-dvb-channel-group.vala b/src/plugins/dvb/rygel-dvb-channel-group.vala index 031a37b..c522d83 100644 --- a/src/plugins/dvb/rygel-dvb-channel-group.vala +++ b/src/plugins/dvb/rygel-dvb-channel-group.vala @@ -62,13 +62,20 @@ public class Rygel.DVBChannelGroup : MediaContainer { this.fetch_channels (); } - public ArrayList get_channels (uint offset, - uint max_count, - out uint child_count) - throws GLib.Error { + public Gee.List 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) { diff --git a/src/plugins/dvb/rygel-dvb-content-dir.vala b/src/plugins/dvb/rygel-dvb-content-dir.vala index d768d29..268a4d4 100644 --- a/src/plugins/dvb/rygel-dvb-content-dir.vala +++ b/src/plugins/dvb/rygel-dvb-content-dir.vala @@ -126,25 +126,14 @@ public class Rygel.DVBContentDir : ContentDirectory { throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object"); } - Gee.List 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 get_root_children ( -- 2.7.4