From 00e90f4c4aa9a35f1ba46f6bd5c063260d2c1f10 Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Mon, 9 Feb 2009 22:29:20 +0000 Subject: [PATCH] More utilization of state-machine in Browse. These changes are particularly for ease of move to async MediaContainer.get_children method when it's there. svn path=/trunk/; revision=559 --- src/rygel/rygel-browse.vala | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/rygel/rygel-browse.vala b/src/rygel/rygel-browse.vala index 0f66d58..eed106d 100644 --- a/src/rygel/rygel-browse.vala +++ b/src/rygel/rygel-browse.vala @@ -153,19 +153,14 @@ public class Browse: GLib.Object { var container = (MediaContainer) this.media_object; this.total_matches = container.child_count; + this.update_id = container.update_id; + if (this.requested_count == 0) { // No max count requested, try to fetch all children this.requested_count = this.total_matches; } - if (!this.serialize_children ()) { - return; - } - - this.update_id = container.update_id; - - // Conclude the successful Browse action - this.conclude (); + this.fetch_children (); } private void parse_args () { @@ -241,10 +236,11 @@ public class Browse: GLib.Object { this.completed (); } - private bool serialize_children () { - var children = this.get_children (); + private void serialize_children (Gee.List? children) { if (children == null) { - return false; + this.handle_error ( + new ContentDirectoryError.NO_SUCH_OBJECT ("No such object")); + return; } /* serialize all children */ @@ -253,27 +249,27 @@ public class Browse: GLib.Object { this.didl_writer.serialize (children[i]); } catch (Error err) { this.handle_error (err); - return false; + return; } } - this.number_returned = children.size; - - return true; + // Conclude the successful Browse action + this.conclude (); } - private Gee.List? get_children () { + private void fetch_children () { var container = (MediaContainer) this.media_object; try { var children = container.get_children (this.index, this.requested_count); + this.number_returned = children.size; - return children; + serialize_children (children); } catch { this.handle_error ( new ContentDirectoryError.NO_SUCH_OBJECT ("No such object")); - return null; + return; } } } -- 2.7.4