[rygel] core: Add can_create function to WritableContainer



commit b4f8d9a0b1c5aa265d806fbff6db9bbae286f9ed
Author: Jens Georg <mail jensge org>
Date:   Thu Feb 16 13:46:36 2012 +0200

    core: Add can_create function to WritableContainer

 src/rygel/rygel-item-creator.vala       |    2 +-
 src/rygel/rygel-writable-container.vala |   17 +++++++++++++++--
 tests/rygel-item-creator-test.vala      |    4 ++++
 3 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/rygel/rygel-item-creator.vala b/src/rygel/rygel-item-creator.vala
index 1cecd90..4419e8b 100644
--- a/src/rygel/rygel-item-creator.vala
+++ b/src/rygel/rygel-item-creator.vala
@@ -79,7 +79,7 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
              * modify the UPnP class to something we support and
              * fetch_container took care of this already.
              */
-            if (!container.create_classes.contains (didl_item.upnp_class) &&
+            if (!container.can_create (this.didl_item.upnp_class) &&
                 this.container_id != "DLNA_ORG.AnyContainer") {
                 throw new ContentDirectoryError.BAD_METADATA
                                         ("Creating of objects with class %s " +
diff --git a/src/rygel/rygel-writable-container.vala b/src/rygel/rygel-writable-container.vala
index 6e075cb..bc9097a 100644
--- a/src/rygel/rygel-writable-container.vala
+++ b/src/rygel/rygel-writable-container.vala
@@ -1,8 +1,9 @@
 /*
  * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
- * Copyright (C) 2010 Nokia Corporation.
+ * Copyright (C) 2010-2012 Nokia Corporation.
  *
- * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ * Author: Jens Georg <jensg openismus com>
+ *         Zeeshan Ali (Khattak) <zeeshanak gnome org>
  *                               <zeeshan ali nokia com>
  *
  * This file is part of Rygel.
@@ -41,6 +42,18 @@ public interface Rygel.WritableContainer : MediaContainer {
     public abstract ArrayList<string> create_classes { get; set; }
 
     /**
+     * Check if this container claims to be able to create an item with the
+     * given upnp class.
+     *
+     * @param upnp_class The class of an item to check
+     *
+     * @return true if it can, false, if not.Â
+     */
+    public bool can_create (string upnp_class) {
+        return this.create_classes.contains (upnp_class);
+    }
+
+    /**
      * Add a new item directly under this container.
      *
      * This doesn't imply creation of file(s) pointed to by item's URI(s), that
diff --git a/tests/rygel-item-creator-test.vala b/tests/rygel-item-creator-test.vala
index 32de7ed..aa5ec0c 100644
--- a/tests/rygel-item-creator-test.vala
+++ b/tests/rygel-item-creator-test.vala
@@ -202,6 +202,10 @@ public class Rygel.MediaObjects : Gee.ArrayList<MediaObject> {
 }
 
 public class Rygel.WritableContainer : Rygel.MediaContainer {
+    public bool can_create (string upnp_class) {
+        return this.create_classes.contains (upnp_class);
+    }
+
     public async File? get_writable (Cancellable? cancellable = null) {
         return File.new_for_commandline_arg ("/tmp");
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]