core: Set X_DLNACAP according to configuration
authorJens Georg <mail@jensge.org>
Sun, 18 Mar 2012 21:02:10 +0000 (22:02 +0100)
committerJens Georg <mail@jensge.org>
Sun, 18 Mar 2012 21:05:24 +0000 (22:05 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=667781

src/rygel/rygel-root-device-factory.vala

index 982ab75..bb73ee6 100644 (file)
@@ -116,6 +116,7 @@ internal class Rygel.RootDeviceFactory {
         this.set_friendly_name_and_udn (device_element,
                                         plugin.name,
                                         plugin.title);
+        this.set_dlnacap (device_element);
 
         if (plugin.description != null) {
             this.set_description (device_element, plugin.description);
@@ -175,6 +176,30 @@ internal class Rygel.RootDeviceFactory {
         }
     }
 
+    private void set_dlnacap (Xml.Node *device_element) {
+        var element = XMLUtils.get_element (device_element,
+                                            "X_DLNACAP",
+                                            null);
+
+        var content = "";
+        var allow_upload = true;
+        var allow_delete = false;
+
+        try {
+            allow_upload = config.get_allow_upload ();
+            allow_delete = config.get_allow_deletion ();
+        } catch (Error error) { }
+
+        if (allow_upload) {
+            content += "av-upload,image-upload,audio-upload";
+        }
+
+        if (allow_delete) {
+            content += ",create-item-with-OCM-destroy-item";
+        }
+        element->set_content (content);
+    }
+
     private void set_description (Xml.Node *device_element,
                                   string    description) {
         Xml.Node *element = XMLUtils.get_element (device_element,