[rygel/wip/upload-profiles: 2/3] server: Move knowledge of supported profiles



commit df3422a92a0c00f5de2eab1127b08032cb189f62
Author: Jens Georg <jensg openismus com>
Date:   Fri Aug 9 13:17:24 2013 +0200

    server: Move knowledge of supported profiles
    
    Query the supported profiles (all, upload) from the MediaServerPlugin,
    provide a default implementation that does return everything from the
    profiles supported by the MediaEngine.

 src/librygel-server/rygel-content-directory.vala   |    4 +-
 src/librygel-server/rygel-media-server-plugin.vala |   36 ++++++++++++++++++++
 src/librygel-server/rygel-object-creator.vala      |    3 +-
 .../rygel-source-connection-manager.vala           |    4 +-
 4 files changed, 42 insertions(+), 5 deletions(-)
---
diff --git a/src/librygel-server/rygel-content-directory.vala 
b/src/librygel-server/rygel-content-directory.vala
index 8619dc6..739d3bf 100644
--- a/src/librygel-server/rygel-content-directory.vala
+++ b/src/librygel-server/rygel-content-directory.vala
@@ -773,8 +773,8 @@ internal class Rygel.ContentDirectory: Service {
             return;
         }
 
-        unowned GLib.List<DLNAProfile> profiles = MediaEngine.get_default ().
-                                        get_dlna_profiles ();
+        var plugin = this.root_device.resource_factory as MediaServerPlugin;
+        unowned GLib.List<DLNAProfile> profiles = plugin.upload_profiles;
         var requested_profiles = upload_profiles.split (",");
         var builder = new StringBuilder ();
         foreach (var profile in profiles) {
diff --git a/src/librygel-server/rygel-media-server-plugin.vala 
b/src/librygel-server/rygel-media-server-plugin.vala
index 1ee13d2..75333a0 100644
--- a/src/librygel-server/rygel-media-server-plugin.vala
+++ b/src/librygel-server/rygel-media-server-plugin.vala
@@ -39,6 +39,42 @@ public abstract class Rygel.MediaServerPlugin : Rygel.Plugin {
                                 BuildConfig.DATA_DIR + "/xml/MediaServer3.xml";
 
     public MediaContainer root_container { get; construct; }
+    private GLib.List<DLNAProfile> _upload_profiles;
+    public unowned GLib.List<unowned DLNAProfile> upload_profiles {
+        get {
+            return _upload_profiles;
+        }
+
+        construct set {
+            if (value != null) {
+                _upload_profiles = null;
+                foreach (var profile in value) {
+                    _upload_profiles.append (profile);
+                }
+            } else {
+                _upload_profiles = _supported_profiles.copy ();
+            }
+        }
+    }
+
+    private GLib.List<DLNAProfile> _supported_profiles;
+    public unowned GLib.List<unowned DLNAProfile> supported_profiles {
+        get {
+            return _supported_profiles;
+        }
+
+        construct set {
+            if (value != null) {
+                _supported_profiles = null;
+                foreach (var profile in value) {
+                    _supported_profiles.append (profile);
+                }
+            } else {
+                _supported_profiles = MediaEngine.get_default ().
+                                        get_dlna_profiles ().copy ();
+            }
+        }
+    }
 
     /**
      * Create an instance of the plugin.
diff --git a/src/librygel-server/rygel-object-creator.vala b/src/librygel-server/rygel-object-creator.vala
index 58b193c..6e1fe25 100644
--- a/src/librygel-server/rygel-object-creator.vala
+++ b/src/librygel-server/rygel-object-creator.vala
@@ -786,7 +786,8 @@ internal class Rygel.ObjectCreator: GLib.Object, Rygel.StateMachine {
     private bool is_profile_valid (string profile) {
         unowned GLib.List<DLNAProfile> profiles, result;
 
-        profiles = MediaEngine.get_default ().get_dlna_profiles ();
+        var plugin = this.content_dir.root_device.resource_factory as MediaServerPlugin;
+        profiles = plugin.upload_profiles;
         var p = new DLNAProfile (profile, "");
 
         result = profiles.find_custom (p, DLNAProfile.compare_by_name);
diff --git a/src/librygel-server/rygel-source-connection-manager.vala 
b/src/librygel-server/rygel-source-connection-manager.vala
index 77031bd..4c23884 100644
--- a/src/librygel-server/rygel-source-connection-manager.vala
+++ b/src/librygel-server/rygel-source-connection-manager.vala
@@ -51,8 +51,8 @@ internal class Rygel.SourceConnectionManager : Rygel.ConnectionManager {
         var server = this.get_http_server ();
         var protocol_infos = server.get_protocol_info ();
 
-        unowned GLib.List<DLNAProfile> profiles = MediaEngine.get_default ().
-                                                              get_dlna_profiles ();
+        var plugin = this.root_device.resource_factory as MediaServerPlugin;
+        unowned GLib.List<DLNAProfile> profiles = plugin.supported_profiles;
 
         var protocol = server.get_protocol ();
 


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