[rygel] core: Throw error on item creation of wrong DLNA PN



commit cc4bff9b722eaaf9f3c4f57f1f992f694c7dbd44
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Apr 13 15:02:03 2011 +0300

    core: Throw error on item creation of wrong DLNA PN
    
    Throw error 712 on creation of item of wrong DLNA profile to satisfy DLNA
    CTT testcase 7.3.134.3.

 src/rygel/rygel-item-creator.vala |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/rygel/rygel-item-creator.vala b/src/rygel/rygel-item-creator.vala
index c53a7f3..f761377 100644
--- a/src/rygel/rygel-item-creator.vala
+++ b/src/rygel/rygel-item-creator.vala
@@ -21,6 +21,7 @@
  */
 
 using GUPnP;
+using Gst;
 
 private errordomain Rygel.ItemCreatorError {
     PARSE
@@ -83,6 +84,12 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
 
                 if (info != null) {
                     if (info.dlna_profile != null) {
+                        if (!this.is_profile_valid (info.dlna_profile)) {
+                            throw new ContentDirectoryError.BAD_METADATA
+                                        ("'%s' DLNA profile unsupported",
+                                         info.dlna_profile);
+                        }
+
                         this.item.dlna_profile = info.dlna_profile;
                     }
 
@@ -339,5 +346,22 @@ internal class Rygel.ItemCreator: GLib.Object, Rygel.StateMachine {
         debug ("Finished waiting for new item to appear under container '%s'",
                container.id);
     }
+
+    private bool is_profile_valid (string profile) {
+        var discoverer = new GUPnP.DLNADiscoverer ((ClockTime) SECOND,
+                                                   true,
+                                                   false);
+
+        var valid = false;
+        foreach (var known_profile in discoverer.list_profiles ()) {
+            if (known_profile.name == profile) {
+                valid = true;
+
+                break;
+            }
+        }
+
+        return valid;
+    }
 }
 



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