Rygel.Configuration is now a singleton
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 28 May 2009 12:59:53 +0000 (15:59 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 28 May 2009 12:59:53 +0000 (15:59 +0300)
src/plugins/folder/rygel-folder-root-container.vala
src/plugins/mediathek/rygel-mediathek-root-container.vala
src/rygel/rygel-configuration.vala
src/rygel/rygel-media-server-factory.vala
src/ui/rygel-preferences-dialog.vala

index 533e164..5a5f6fa 100644 (file)
@@ -96,7 +96,7 @@ public class Rygel.FolderRootContainer : MediaContainer {
 
         this.items = new ArrayList<FolderContainer> ();
 
-        var config = new Rygel.Configuration ();
+        var config = Rygel.Configuration.get_default ();
         var dirs = config.get_string_list ("Folder", "folders");
 
         // either an error occured or the gconf key is not set
index ddca46f..ad0aa16 100644 (file)
@@ -100,7 +100,7 @@ public class Rygel.MediathekRootContainer : MediaContainer {
         this.session = new Soup.SessionAsync ();
         this.items = new ArrayList<MediathekRssContainer> ();
 
-        var config = new Rygel.Configuration ();
+        var config = Rygel.Configuration.get_default ();
         var feeds = config.get_int_list ("ZDFMediathek", "rss");
 
         if (feeds.size == 0) {
index 8268e50..59ca818 100644 (file)
@@ -41,6 +41,9 @@ public class Rygel.Configuration : GLib.Object {
     protected static const string LPCM_TRANSCODER_KEY =
                                                     "enable-lpcm-transcoder";
 
+    // Our singleton
+    private static Configuration config;
+
     protected GConf.Client gconf;
 
     private string _host_ip;
@@ -103,6 +106,14 @@ public class Rygel.Configuration : GLib.Object {
         }
     }
 
+    public static Configuration get_default () {
+        if (config == null) {
+            config = new Configuration ();
+        }
+
+        return config;
+    }
+
     public Configuration () {
         this.gconf = GConf.Client.get_default ();
     }
index cd24362..9c105b1 100644 (file)
@@ -43,7 +43,7 @@ public class Rygel.MediaServerFactory {
     private GUPnP.Context context;
 
     public MediaServerFactory () throws GLib.Error {
-        this.config = new Configuration ();
+        this.config = Configuration.get_default ();
 
         /* Set up GUPnP context */
         this.context = create_upnp_context ();
index c14fe9c..a96b939 100644 (file)
@@ -33,7 +33,7 @@ public class Rygel.PreferencesDialog : GLib.Object {
     ArrayList<PreferencesSection> sections;
 
     public PreferencesDialog () throws Error {
-        var config = new Configuration ();
+        var config = Configuration.get_default ();
 
         this.builder = new Builder ();