[rygel] core: Serialization handled by MediaObject itself
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Serialization handled by MediaObject itself
- Date: Wed, 25 Aug 2010 14:45:45 +0000 (UTC)
commit 5aabc44fc312e2406bb2dd32eceddb2ccf648fad
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Aug 25 16:23:06 2010 +0300
core: Serialization handled by MediaObject itself
Serialization of MediaObject is now completely handled by the MediaObject
itself.
src/rygel/rygel-didl-lite-writer.vala | 34 +--------------------------------
src/rygel/rygel-media-container.vala | 28 +++++++++++++++++++++++++++
src/rygel/rygel-media-item.vala | 4 +-
src/rygel/rygel-media-object.vala | 3 ++
src/rygel/rygel-music-item.vala | 4 +-
src/rygel/rygel-photo-item.vala | 4 +-
src/rygel/rygel-video-item.vala | 4 +-
7 files changed, 40 insertions(+), 41 deletions(-)
---
diff --git a/src/rygel/rygel-didl-lite-writer.vala b/src/rygel/rygel-didl-lite-writer.vala
index cc17574..36be260 100644
--- a/src/rygel/rygel-didl-lite-writer.vala
+++ b/src/rygel/rygel-didl-lite-writer.vala
@@ -39,38 +39,6 @@ internal class Rygel.DIDLLiteWriter : GUPnP.DIDLLiteWriter {
}
public void serialize (MediaObject media_object) throws Error {
- if (media_object is MediaItem) {
- ((MediaItem) media_object).serialize (this);
- } else if (media_object is MediaContainer) {
- this.serialize_container ((MediaContainer) media_object);
- } else {
- throw new DIDLLiteWriterError.UNSUPPORTED_OBJECT (
- _("Unable to serialize unsupported object"));
- }
- }
-
- private void serialize_container (MediaContainer container) throws Error {
- var didl_container = this.add_container ();
- if (container.parent != null) {
- didl_container.parent_id = container.parent.id;
- } else {
- didl_container.parent_id = "-1";
- }
-
- didl_container.id = container.id;
- didl_container.title = container.title;
- didl_container.child_count = container.child_count;
- didl_container.upnp_class = container.upnp_class;
- didl_container.restricted = container.uris.size <= 0;
- didl_container.searchable = true;
-
- if (!didl_container.restricted) {
- weak Xml.Node node = (Xml.Node) didl_container.xml_node;
- weak Xml.Ns ns = (Xml.Ns) didl_container.upnp_namespace;
-
- foreach (var create_class in container.create_classes) {
- node.new_child (ns, "createClass", create_class);
- }
- }
+ media_object.serialize (this);
}
}
diff --git a/src/rygel/rygel-media-container.vala b/src/rygel/rygel-media-container.vala
index e79d47d..5cafed3 100644
--- a/src/rygel/rygel-media-container.vala
+++ b/src/rygel/rygel-media-container.vala
@@ -260,6 +260,34 @@ public abstract class Rygel.MediaContainer : MediaObject {
}
}
+ internal override DIDLLiteObject serialize (DIDLLiteWriter writer)
+ throws Error {
+ var didl_container = writer.add_container ();
+ if (this.parent != null) {
+ didl_container.parent_id = this.parent.id;
+ } else {
+ didl_container.parent_id = "-1";
+ }
+
+ didl_container.id = this.id;
+ didl_container.title = this.title;
+ didl_container.child_count = this.child_count;
+ didl_container.upnp_class = this.upnp_class;
+ didl_container.restricted = this.uris.size <= 0;
+ didl_container.searchable = true;
+
+ if (!didl_container.restricted) {
+ weak Xml.Node node = (Xml.Node) didl_container.xml_node;
+ weak Xml.Ns ns = (Xml.Ns) didl_container.upnp_namespace;
+
+ foreach (var create_class in this.create_classes) {
+ node.new_child (ns, "createClass", create_class);
+ }
+ }
+
+ return didl_container;
+ }
+
private async MediaObjects search_in_children (SearchExpression expression,
MediaObjects children,
uint limit,
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index 35e5858..ff96434 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -141,8 +141,8 @@ public abstract class Rygel.MediaItem : MediaObject {
}
}
- internal virtual DIDLLiteItem serialize (DIDLLiteWriter writer)
- throws Error {
+ internal override DIDLLiteObject serialize (DIDLLiteWriter writer)
+ throws Error {
var didl_item = writer.add_item ();
didl_item.id = this.id;
diff --git a/src/rygel/rygel-media-object.vala b/src/rygel/rygel-media-object.vala
index 770652a..9d1ec9d 100644
--- a/src/rygel/rygel-media-object.vala
+++ b/src/rygel/rygel-media-object.vala
@@ -122,6 +122,9 @@ public abstract class Rygel.MediaObject : GLib.Object {
return null;
}
+ internal abstract DIDLLiteObject serialize (DIDLLiteWriter writer)
+ throws Error;
+
internal virtual int compare_by_property (MediaObject media_object,
string property) {
switch (property) {
diff --git a/src/rygel/rygel-music-item.vala b/src/rygel/rygel-music-item.vala
index 8e4e6e4..6a69979 100644
--- a/src/rygel/rygel-music-item.vala
+++ b/src/rygel/rygel-music-item.vala
@@ -90,8 +90,8 @@ public class Rygel.MusicItem : AudioItem {
}
}
- internal override DIDLLiteItem serialize (DIDLLiteWriter writer)
- throws Error {
+ internal override DIDLLiteObject serialize (DIDLLiteWriter writer)
+ throws Error {
var didl_item = base.serialize (writer);
if (this.artist != null && this.artist != "") {
diff --git a/src/rygel/rygel-photo-item.vala b/src/rygel/rygel-photo-item.vala
index 83b1a7b..93f722a 100644
--- a/src/rygel/rygel-photo-item.vala
+++ b/src/rygel/rygel-photo-item.vala
@@ -57,8 +57,8 @@ public class Rygel.PhotoItem : ImageItem {
}
}
- internal override DIDLLiteItem serialize (DIDLLiteWriter writer)
- throws Error {
+ internal override DIDLLiteObject serialize (DIDLLiteWriter writer)
+ throws Error {
var didl_item = base.serialize (writer);
if (this.creator != null && this.creator != "") {
diff --git a/src/rygel/rygel-video-item.vala b/src/rygel/rygel-video-item.vala
index 59435cb..660dd37 100644
--- a/src/rygel/rygel-video-item.vala
+++ b/src/rygel/rygel-video-item.vala
@@ -117,8 +117,8 @@ public class Rygel.VideoItem : AudioItem, VisualItem {
}
}
- internal override DIDLLiteItem serialize (DIDLLiteWriter writer)
- throws Error {
+ internal override DIDLLiteObject serialize (DIDLLiteWriter writer)
+ throws Error {
var didl_item = base.serialize (writer);
if (this.author != null && this.author != "") {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]