[rygel] core: Make use of GUPnP.ProtocolInfo



commit 411e03a29439af788893d561275a34c9ca59d7eb
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Aug 16 16:22:18 2010 +0300

    core: Make use of GUPnP.ProtocolInfo
    
    Instead of passing around ProtocolInfo as strings, use a list of
    ProtocolInfo objects and translate them to strings only where/when needed.

 src/rygel/rygel-http-server.vala               |   14 ++++++++------
 src/rygel/rygel-source-connection-manager.vala |   11 ++++++++++-
 src/rygel/rygel-transcode-manager.vala         |   17 +++++++++--------
 3 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/src/rygel/rygel-http-server.vala b/src/rygel/rygel-http-server.vala
index db84854..2d06383 100644
--- a/src/rygel/rygel-http-server.vala
+++ b/src/rygel/rygel-http-server.vala
@@ -162,14 +162,16 @@ internal class Rygel.HTTPServer : Rygel.TranscodeManager, Rygel.StateMachine {
         return "http-get";
     }
 
-    internal override string get_protocol_info () {
-        var protocol_info = base.get_protocol_info ();
+    internal override ArrayList<ProtocolInfo> get_protocol_info () {
+        var protocol_infos = base.get_protocol_info ();
 
-        if (protocol_info != "") {
-            protocol_info += ",";
-        }
+        var protocol_info = new ProtocolInfo ();
+        protocol_info.protocol = this.get_protocol ();
+        protocol_info.mime_type = "*";
+
+        protocol_infos.add (protocol_info);
 
-        return protocol_info += this.get_protocol () + ":*:*:*";
+        return protocol_infos;
     }
 
     private void on_request_completed (StateMachine machine) {
diff --git a/src/rygel/rygel-source-connection-manager.vala b/src/rygel/rygel-source-connection-manager.vala
index df640c8..1990b43 100644
--- a/src/rygel/rygel-source-connection-manager.vala
+++ b/src/rygel/rygel-source-connection-manager.vala
@@ -34,8 +34,17 @@ internal class Rygel.SourceConnectionManager : Rygel.ConnectionManager {
         this.av_transport_id = -1;
         this.direction = "Output";
 
+        this.source_protocol_info = "";
+
         var server = this.get_http_server ();
-        this.source_protocol_info = server.get_protocol_info ();
+        foreach (var protocol_info in server.get_protocol_info ()) {
+            if (this.source_protocol_info != "") {
+                // No comma before the first one
+                this.source_protocol_info += ",";
+            }
+
+            this.source_protocol_info += protocol_info.to_string ();
+        }
     }
 
     private HTTPServer get_http_server () {
diff --git a/src/rygel/rygel-transcode-manager.vala b/src/rygel/rygel-transcode-manager.vala
index 4d7a9be..917f83d 100644
--- a/src/rygel/rygel-transcode-manager.vala
+++ b/src/rygel/rygel-transcode-manager.vala
@@ -117,19 +117,20 @@ internal abstract class Rygel.TranscodeManager : GLib.Object {
 
     internal abstract string get_protocol ();
 
-    internal virtual string get_protocol_info () {
-        string protocol_info = "";
+    internal virtual ArrayList<ProtocolInfo> get_protocol_info () {
+        var protocol_infos = new ArrayList<ProtocolInfo> ();
 
         foreach (var transcoder in this.transcoders) {
-            if (protocol_info != "")   // No comma before the first one
-                protocol_info += ",";
+            var protocol_info = new ProtocolInfo ();
 
-            protocol_info += this.get_protocol () +
-                             ":*:" + transcoder.mime_type +
-                             ":DLNA.ORG_PN=" + transcoder.dlna_profile;
+            protocol_info.protocol = this.get_protocol ();
+            protocol_info.mime_type = transcoder.mime_type;
+            protocol_info.dlna_profile = transcoder.dlna_profile;
+
+            protocol_infos.add (protocol_info);
         }
 
-        return protocol_info;
+        return protocol_infos;
     }
 }
 



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