[rygel] all: Plugin to GObject-style construct



commit 1c229883eb66696c0496a38bdaffbd4eac32f5b4
Author: Jens Georg <jensg openismus com>
Date:   Thu Dec 6 23:11:05 2012 +0100

    all: Plugin to GObject-style construct

 src/librygel-core/rygel-plugin.vala                |   28 +++++++++++--------
 .../rygel-media-renderer-plugin.vala               |   10 ++++++-
 src/librygel-server/rygel-media-server-plugin.vala |   18 ++++++++-----
 3 files changed, 36 insertions(+), 20 deletions(-)
---
diff --git a/src/librygel-core/rygel-plugin.vala b/src/librygel-core/rygel-plugin.vala
index 072b149..94adb31 100644
--- a/src/librygel-core/rygel-plugin.vala
+++ b/src/librygel-core/rygel-plugin.vala
@@ -91,14 +91,14 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
     private static const int ICON_SMALL_WIDTH = 48;
     private static const int ICON_SMALL_HEIGHT = 48;
 
-    public PluginCapabilities capabilities { get; protected set; }
+    public PluginCapabilities capabilities { get; construct set; }
 
-    public string name { get; private set; }
-    public string title { get; set; }
-    public string description { get; private set; }
+    public string name { get; construct; }
+    public string title { get; construct set; }
+    public string description { get; construct; }
 
     // Path to description document
-    public string desc_path { get; private set; }
+    public string desc_path { get; construct; }
 
     public bool active { get; set; }
 
@@ -126,16 +126,20 @@ public class Rygel.Plugin : GUPnP.ResourceFactory {
                    string? title,
                    string? description = null,
                    PluginCapabilities capabilities = PluginCapabilities.NONE) {
-        this.desc_path = desc_path;
-        this.name = name;
-        this.title = title;
-        this.description = description;
-        this.capabilities = capabilities;
+        Object (desc_path : desc_path,
+                name : name,
+                title : title,
+                description : description,
+                capabilities : capabilities);
+    }
+
+    public override void constructed () {
+        base.constructed ();
 
         this.active = true;
 
-        if (title == null) {
-            this.title = name;
+        if (this.title == null) {
+            this.title = this.name;
         }
 
         this.resource_infos = new ArrayList<ResourceInfo> ();
diff --git a/src/librygel-renderer/rygel-media-renderer-plugin.vala b/src/librygel-renderer/rygel-media-renderer-plugin.vala
index 03eda7d..aa93852 100644
--- a/src/librygel-renderer/rygel-media-renderer-plugin.vala
+++ b/src/librygel-renderer/rygel-media-renderer-plugin.vala
@@ -50,7 +50,15 @@ public class Rygel.MediaRendererPlugin : Rygel.Plugin {
                                 string? description = null,
                                 PluginCapabilities capabilities =
                                         PluginCapabilities.NONE) {
-        base (MEDIA_RENDERER_DESC_PATH, name, title, description, capabilities);
+        Object (desc_path : MEDIA_RENDERER_DESC_PATH,
+                name : name,
+                title : title,
+                description : description,
+                capabilities : capabilities);
+    }
+
+    public override void constructed () {
+        base.constructed ();
 
         var resource = new ResourceInfo (ConnectionManager.UPNP_ID,
                                          ConnectionManager.UPNP_TYPE,
diff --git a/src/librygel-server/rygel-media-server-plugin.vala b/src/librygel-server/rygel-media-server-plugin.vala
index 973e04b..7ae451c 100644
--- a/src/librygel-server/rygel-media-server-plugin.vala
+++ b/src/librygel-server/rygel-media-server-plugin.vala
@@ -31,7 +31,7 @@ public abstract class Rygel.MediaServerPlugin : Rygel.Plugin {
     private static const string MEDIA_SERVER_DESC_PATH =
                                 BuildConfig.DATA_DIR + "/xml/MediaServer3.xml";
 
-    public MediaContainer root_container { get; private set; }
+    public MediaContainer root_container { get; construct; }
 
     /**
      * Create an instance of the plugin.
@@ -46,13 +46,17 @@ public abstract class Rygel.MediaServerPlugin : Rygel.Plugin {
                               string?        description = null,
                               PluginCapabilities capabilities =
                                         PluginCapabilities.NONE) {
-        base (MEDIA_SERVER_DESC_PATH,
-              name,
-              root_container.title,
-              description,
-              capabilities);
+        Object (desc_path : MEDIA_SERVER_DESC_PATH,
+                name : name,
+                title : root_container.title,
+                description : description,
+                capabilities : capabilities,
+                root_container : root_container);
+    }
+
+    public override void constructed () {
+        base.constructed ();
 
-        this.root_container = root_container;
         var path = ContentDirectory.DESCRIPTION_PATH_NO_TRACK;
 
         // MediaServer implementations must implement ContentDirectory service



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