core: Add can_create function to WritableContainer
authorJens Georg <mail@jensge.org>
Thu, 16 Feb 2012 11:46:36 +0000 (13:46 +0200)
committerJens Georg <mail@jensge.org>
Tue, 21 Feb 2012 13:41:44 +0000 (15:41 +0200)
src/rygel/rygel-item-creator.vala
src/rygel/rygel-writable-container.vala
tests/rygel-item-creator-test.vala

index 1cecd90..4419e8b 100644 (file)
@@ -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 " +
index 6e075cb..bc9097a 100644 (file)
@@ -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
index 32de7ed..aa5ec0c 100644 (file)
@@ -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");
     }