[rygel] core: Add access-writes to MediaObject
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Add access-writes to MediaObject
- Date: Mon, 8 Nov 2010 21:34:19 +0000 (UTC)
commit de24172a50f70e74cc3a60084191fb285986acb3
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Nov 3 13:46:27 2010 +0200
core: Add access-writes to MediaObject
MediaItem and MediaContainer now provides boolean properties specifying
different access writes.
src/rygel/rygel-item-creator.vala | 3 ++-
src/rygel/rygel-item-destroyer.vala | 5 ++---
src/rygel/rygel-media-container.vala | 20 +++++++++++++++++++-
src/rygel/rygel-media-item.vala | 13 ++++++++++++-
src/rygel/rygel-media-object.vala | 3 +++
5 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/src/rygel/rygel-item-creator.vala b/src/rygel/rygel-item-creator.vala
index 7293a11..83caa0c 100644
--- a/src/rygel/rygel-item-creator.vala
+++ b/src/rygel/rygel-item-creator.vala
@@ -181,7 +181,8 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
if (media_object == null) {
throw new ContentDirectoryError.NO_SUCH_OBJECT (
_("No such object"));
- } else if (!(media_object is WritableContainer)) {
+ } else if (!(media_object is MediaContainer) ||
+ !(media_object as MediaContainer).expandable) {
throw new ContentDirectoryError.RESTRICTED_PARENT (
_("Object creation in %s not allowed"),
media_object.id);
diff --git a/src/rygel/rygel-item-destroyer.vala b/src/rygel/rygel-item-destroyer.vala
index 09066dd..1d46939 100644
--- a/src/rygel/rygel-item-destroyer.vala
+++ b/src/rygel/rygel-item-destroyer.vala
@@ -98,12 +98,11 @@ internal class Rygel.ItemDestroyer: GLib.Object, Rygel.StateMachine {
if (media_object == null) {
throw new ContentDirectoryError.NO_SUCH_OBJECT (
_("No such object"));
- } else if (media_object is MediaContainer &&
- !(media_object is WritableContainer)) {
+ } else if (!media_object.removable) {
throw new ContentDirectoryError.RESTRICTED_OBJECT (
_("Removal of object %s not allowed"),
media_object.id);
- } else if (!(media_object.parent is WritableContainer)) {
+ } else if (media_object.parent.restricted) {
throw new ContentDirectoryError.RESTRICTED_PARENT (
_("Object removal from %s not allowed"),
media_object.id);
diff --git a/src/rygel/rygel-media-container.vala b/src/rygel/rygel-media-container.vala
index b1eee51..9f689cb 100644
--- a/src/rygel/rygel-media-container.vala
+++ b/src/rygel/rygel-media-container.vala
@@ -46,6 +46,24 @@ public abstract class Rygel.MediaContainer : MediaObject {
public int child_count;
public uint32 update_id;
+ internal override bool removable {
+ get {
+ return this is WritableContainer && this.uris.size > 0;
+ }
+ }
+
+ internal override bool restricted {
+ get {
+ return !this.removable && !this.expandable;
+ }
+ }
+
+ internal bool expandable {
+ get {
+ return this is WritableContainer && this.uris.size > 0;
+ }
+ }
+
public MediaContainer (string id,
MediaContainer? parent,
string title,
@@ -223,7 +241,7 @@ public abstract class Rygel.MediaContainer : MediaObject {
didl_container.upnp_class = this.upnp_class;
didl_container.searchable = true;
- if (this is WritableContainer && this.uris.size > 0) {
+ if (!this.restricted) {
didl_container.restricted = false;
weak Xml.Node node = (Xml.Node) didl_container.xml_node;
weak Xml.Ns ns = (Xml.Ns) didl_container.upnp_namespace;
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index 9075dc3..deb41a1 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -56,6 +56,17 @@ public abstract class Rygel.MediaItem : MediaObject {
} // Size in bytes
internal bool place_holder { get; private set; default = false; }
+ internal override bool removable {
+ get {
+ return true;
+ }
+ }
+
+ internal override bool restricted {
+ get {
+ return !this.removable && !this.place_holder;
+ }
+ }
public MediaItem (string id,
MediaContainer parent,
@@ -170,7 +181,7 @@ public abstract class Rygel.MediaItem : MediaObject {
didl_item.parent_id = "0";
}
- didl_item.restricted = false;
+ didl_item.restricted = this.restricted;
didl_item.title = this.title;
didl_item.upnp_class = this.upnp_class;
diff --git a/src/rygel/rygel-media-object.vala b/src/rygel/rygel-media-object.vala
index 77915b3..e86a57e 100644
--- a/src/rygel/rygel-media-object.vala
+++ b/src/rygel/rygel-media-object.vala
@@ -86,6 +86,9 @@ public abstract class Rygel.MediaObject : GLib.Object {
}
}
+ internal abstract bool restricted { get; }
+ internal abstract bool removable { get; }
+
static construct {
try {
real_name_regex = new Regex (Regex.escape_string ("@REALNAME@"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]