[rygel/wip/didl-s: 35/35] renderer: More variables to global state



commit 2edbcdf0e6c59626e12b180434f0c8c84a4f894c
Author: Jens Georg <jensg openismus com>
Date:   Wed Nov 21 17:55:53 2012 +0100

    renderer: More variables to global state

 src/librygel-renderer/rygel-av-transport.vala      |   82 +++++++-------------
 src/librygel-renderer/rygel-player-controller.vala |   19 +++++
 2 files changed, 47 insertions(+), 54 deletions(-)
---
diff --git a/src/librygel-renderer/rygel-av-transport.vala b/src/librygel-renderer/rygel-av-transport.vala
index b6b65ce..c65644c 100644
--- a/src/librygel-renderer/rygel-av-transport.vala
+++ b/src/librygel-renderer/rygel-av-transport.vala
@@ -37,25 +37,6 @@ internal class Rygel.AVTransport : Service {
     private Session session;
     private string protocol_info;
 
-    private string _metadata = "";
-    public string metadata {
-        owned get {
-            if (this._metadata != null) {
-                return this._metadata;
-            } else {
-                return "";
-            }
-        }
-
-        set {
-            if (value.has_prefix ("&lt;")) {
-                this._metadata = this.unescape (value);
-            } else {
-                this._metadata = value;
-            }
-        }
-    }
-
     public string track_metadata {
         owned get {
             if (this.player.metadata != null) {
@@ -88,24 +69,6 @@ internal class Rygel.AVTransport : Service {
         }
     }
 
-    private string _uri;
-    public string uri {
-        owned get {
-            if (this._uri == null) {
-                return "";
-            }
-
-            return this._uri;
-        }
-
-        set {
-            this._uri = value;
-            this.changelog.log ("AVTransportURI", this._uri);
-        }
-    }
-
-
-
     private string _status = "OK";
     public string status {
         get {
@@ -178,9 +141,12 @@ internal class Rygel.AVTransport : Service {
         this.controller.notify["playback-state"].connect (this.notify_state_cb);
         this.controller.notify["n-tracks"].connect (this.notify_n_tracks_cb);
         this.controller.notify["track"].connect (this.notify_track_cb);
+        this.controller.notify["uri"].connect (this.notify_uri_cb);
+        this.controller.notify["metadata"].connect (this.notify_meta_data_cb);
+
         this.player.notify["duration"].connect (this.notify_duration_cb);
-        this.player.notify["uri"].connect (this.notify_uri_cb);
-        this.player.notify["metadata"].connect (this.notify_meta_data_cb);
+        this.player.notify["uri"].connect (this.notify_track_uri_cb);
+        this.player.notify["metadata"].connect (this.notify_track_meta_data_cb);
 
         this.session = new SessionAsync ();
         this.protocol_info = plugin.get_protocol_info ();
@@ -216,9 +182,9 @@ internal class Rygel.AVTransport : Service {
         log.log ("CurrentTrackMetaData",
                  Markup.escape_text (this.track_metadata));
         log.log ("AVTransportURIMetaData",
-                 Markup.escape_text (this.metadata));
+                 Markup.escape_text (this.controller.metadata));
         log.log ("CurrentTrackURI",              this.track_uri);
-        log.log ("AVTransportURI",               this.uri);
+        log.log ("AVTransportURI",               this.controller.uri);
         log.log ("NextAVTransportURI",           "NOT_IMPLEMENTED");
         log.log ("NextAVTransportURIMetaData",   "NOT_IMPLEMENTED");
 
@@ -294,8 +260,8 @@ internal class Rygel.AVTransport : Service {
                         return;
                     }
 
-                    this.metadata = _metadata;
-                    this.uri = _uri;
+                    this.controller.metadata = _metadata;
+                    this.controller.uri = _uri;
 
                     if (mime == "text/xml" &&
                         features.has_prefix ("DLNA.ORG_PN=DIDL_S")) {
@@ -322,8 +288,8 @@ internal class Rygel.AVTransport : Service {
             });
             this.session.queue_message (message, null);
         } else {
-            this.metadata = _metadata;
-            this.uri = _uri;
+            this.controller.metadata = _metadata;
+            this.controller.uri = _uri;
             if (_uri == "") {
                 this.controller.n_tracks = 0;
                 this.controller.track = 0;
@@ -359,10 +325,10 @@ internal class Rygel.AVTransport : Service {
                         media_duration,
                     "CurrentURI",
                         typeof (string),
-                        this.uri,
+                        this.controller.uri,
                     "CurrentURIMetaData",
                         typeof (string),
-                        this.metadata,
+                        this.controller.metadata,
                     "NextURI",
                         typeof (string),
                         "NOT_IMPLEMENTED",
@@ -408,10 +374,10 @@ internal class Rygel.AVTransport : Service {
                         media_duration,
                     "CurrentURI",
                         typeof (string),
-                        this.uri,
+                        this.controller.uri,
                     "CurrentURIMetaData",
                         typeof (string),
-                        this.metadata,
+                        this.controller.metadata,
                     "NextURI",
                         typeof (string),
                         "NOT_IMPLEMENTED",
@@ -653,18 +619,26 @@ internal class Rygel.AVTransport : Service {
                             this.player.duration_as_str);
     }
 
-    private void notify_uri_cb (Object player, ParamSpec p) {
+    private void notify_track_uri_cb (Object player, ParamSpec p) {
         this.changelog.log ("CurrentTrackURI", this.track_uri);
     }
 
+    private void notify_uri_cb (Object player, ParamSpec p) {
+        this.changelog.log ("AVTransportURI", this.controller.uri);
+    }
+
+    private void notify_track_meta_data_cb (Object player, ParamSpec p) {
+        this.changelog.log ("CurrentTrackMetaData",
+                            Markup.escape_text (this.track_metadata));
+    }
+
     private void notify_meta_data_cb (Object player, ParamSpec p) {
-        this._metadata = this.player.metadata;
-        this.changelog.log ("CurrentTrackMetadata",
-                            Markup.escape_text (this.metadata));
+        this.changelog.log ("AVTransportURIMetaData",
+                            Markup.escape_text (this.controller.metadata));
     }
 
     private async void handle_playlist (ServiceAction action) {
-        var message = new Message ("GET", this.uri);
+        var message = new Message ("GET", this.controller.uri);
         this.session.queue_message (message, () => {
             handle_playlist.callback ();
         });
diff --git a/src/librygel-renderer/rygel-player-controller.vala b/src/librygel-renderer/rygel-player-controller.vala
index 60a7a22..a3ef1dc 100644
--- a/src/librygel-renderer/rygel-player-controller.vala
+++ b/src/librygel-renderer/rygel-player-controller.vala
@@ -14,6 +14,12 @@ internal class Rygel.PlayerController : Object {
     public string playback_state { get; set; default = "NO_MEDIA_PRESENT"; }
     public uint n_tracks { get; set; default = 0; }
     public uint track { get; set; default = 0; }
+    public string uri { get; set; default = ""; }
+    public string metadata {
+        get { return this._metadata; }
+        set { this._metadata = this.unescape (value); }
+        default = "";
+    }
 
     private MediaPlayer player;
     private MediaCollection collection;
@@ -23,6 +29,9 @@ internal class Rygel.PlayerController : Object {
     private uint default_image_timeout;
     private Configuration config;
 
+    // Private property variables
+    private string _metadata;
+
     public PlayerController (MediaPlayer player, string protocol_info) {
         this.player = player;
         this.protocol_info = protocol_info;
@@ -163,4 +172,14 @@ internal class Rygel.PlayerController : Object {
 
         debug ("New image timeout: %lu", this.default_image_timeout);
     }
+
+    private string unescape (string input) {
+        var result = input.replace ("&quot;", "\"");
+        result = result.replace ("&lt;", "<");
+        result = result.replace ("&gt;", ">");
+        result = result.replace ("&apos;", "'");
+        result = result.replace ("&amp;", "&");
+
+        return result;
+    }
 }



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