rygel r327 - in trunk/src: plugins/tracker rygel
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r327 - in trunk/src: plugins/tracker rygel
- Date: Sun, 14 Dec 2008 20:20:53 +0000 (UTC)
Author: zeeshanak
Date: Sun Dec 14 20:20:52 2008
New Revision: 327
URL: http://svn.gnome.org/viewvc/rygel?rev=327&view=rev
Log:
Move most of the root container handling to base class.
So that plugins need to a bit less work.
Modified:
trunk/src/plugins/tracker/rygel-media-tracker.vala
trunk/src/rygel/rygel-content-directory.vala
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 Sun Dec 14 20:20:52 2008
@@ -33,8 +33,6 @@
public class Rygel.MediaTracker : ContentDirectory {
public static const int MAX_REQUESTED_COUNT = 128;
- private MediaContainer root_container;
-
/* FIXME: Make this a static if you know how to initize it */
private List<TrackerContainer> containers;
@@ -45,8 +43,6 @@
// Chain-up to base first
base.constructed ();
- this.root_container = new MediaContainer.root ("MediaTracker", 0);
-
this.containers = new List<TrackerContainer> ();
this.containers.append
(new TrackerContainer ("16",
@@ -91,25 +87,20 @@
out uint number_returned,
out uint total_matches,
out uint update_id) throws GLib.Error {
- if (container_id == this.root_container.id) {
- number_returned = this.add_root_container_children (didl_writer);
- total_matches = number_returned;
- } else {
- TrackerContainer container;
+ TrackerContainer container;
- if (requested_count == 0)
- requested_count = MAX_REQUESTED_COUNT;
+ if (requested_count == 0)
+ requested_count = MAX_REQUESTED_COUNT;
- container = this.find_container_by_id (container_id);
- if (container == null)
- number_returned = 0;
- else {
- number_returned =
- container.add_children_from_db (didl_writer,
- starting_index,
- requested_count,
- out total_matches);
- }
+ container = this.find_container_by_id (container_id);
+ if (container == null)
+ number_returned = 0;
+ else {
+ number_returned =
+ container.add_children_from_db (didl_writer,
+ starting_index,
+ requested_count,
+ out total_matches);
}
if (number_returned > 0) {
@@ -127,27 +118,21 @@
out uint update_id) throws GLib.Error {
bool found = false;
- if (object_id == this.root_container.id) {
- this.root_container.serialize (didl_writer);
-
- found = true;
- } else {
- TrackerContainer container;
+ TrackerContainer container;
- /* First try containers */
- container = find_container_by_id (object_id);
+ /* First try containers */
+ container = find_container_by_id (object_id);
- if (container != null) {
- container.serialize (didl_writer);
+ if (container != null) {
+ container.serialize (didl_writer);
- found = true;
- } else {
- /* Now try items */
- container = get_item_parent (object_id);
+ found = true;
+ } else {
+ /* Now try items */
+ container = get_item_parent (object_id);
- if (container != null)
- found = container.add_item_from_db (didl_writer, object_id);
- }
+ if (container != null)
+ found = container.add_item_from_db (didl_writer, object_id);
}
if (!found) {
@@ -157,14 +142,24 @@
update_id = uint32.MAX;
}
- /* Private methods */
- private uint add_root_container_children (DIDLLiteWriter didl_writer) {
+ public override void add_root_children_metadata
+ (DIDLLiteWriter didl_writer,
+ string filter,
+ uint starting_index,
+ uint requested_count,
+ string sort_criteria,
+ out uint number_returned,
+ out uint total_matches,
+ out uint update_id)
+ throws GLib.Error {
foreach (TrackerContainer container in this.containers)
container.serialize (didl_writer);
- return this.containers.length ();
+ total_matches = number_returned = this.containers.length ();
+ update_id = uint32.MAX;
}
+ /* Private methods */
private TrackerContainer? find_container_by_id (string container_id) {
TrackerContainer container;
Modified: trunk/src/rygel/rygel-content-directory.vala
==============================================================================
--- trunk/src/rygel/rygel-content-directory.vala (original)
+++ trunk/src/rygel/rygel-content-directory.vala Sun Dec 14 20:20:52 2008
@@ -49,6 +49,8 @@
protected string search_caps;
protected string sort_caps;
+ protected MediaContainer root_container;
+
DIDLLiteWriter didl_writer;
// Public abstract methods derived classes need to implement
@@ -73,8 +75,22 @@
throw new ServerError.NOT_IMPLEMENTED ("Not Implemented\n");
}
+ public virtual void add_root_children_metadata
+ (DIDLLiteWriter didl_writer,
+ string filter,
+ uint starting_index,
+ uint requested_count,
+ string sort_criteria,
+ out uint number_returned,
+ out uint total_matches,
+ out uint update_id)
+ throws Error {
+ throw new ServerError.NOT_IMPLEMENTED ("Not Implemented\n");
+ }
+
public override void constructed () {
this.didl_writer = new DIDLLiteWriter ();
+ this.setup_root_container ();
this.system_update_id = 0;
this.feature_list =
@@ -155,24 +171,42 @@
try {
if (browse_metadata) {
- this.add_metadata (this.didl_writer,
- object_id,
- filter,
- sort_criteria,
- out update_id);
+ // BrowseMetadata
+ if (object_id == this.root_container.id) {
+ this.root_container.serialize (didl_writer);
+ update_id = this.system_update_id;
+ } else {
+ this.add_metadata (this.didl_writer,
+ object_id,
+ filter,
+ sort_criteria,
+ out update_id);
+ }
num_returned = 1;
total_matches = 1;
} else {
- this.add_children_metadata (this.didl_writer,
- object_id,
- filter,
- starting_index,
- requested_count,
- sort_criteria,
- out num_returned,
- out total_matches,
- out update_id);
+ // BrowseDirectChildren
+ if (object_id == this.root_container.id) {
+ this.add_root_children_metadata (this.didl_writer,
+ filter,
+ starting_index,
+ requested_count,
+ sort_criteria,
+ out num_returned,
+ out total_matches,
+ out update_id);
+ } else {
+ this.add_children_metadata (this.didl_writer,
+ object_id,
+ filter,
+ starting_index,
+ requested_count,
+ sort_criteria,
+ out num_returned,
+ out total_matches,
+ out update_id);
+ }
}
/* End DIDL-Lite fragment */
@@ -271,5 +305,11 @@
value.init (typeof (string));
value.set_string (this.feature_list);
}
+
+ private void setup_root_container () {
+ string friendly_name = this.root_device.get_friendly_name ();
+ this.root_container = new MediaContainer.root (friendly_name, 0);
+ }
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]