core,plugins,ui: Move from GConf to .ini file usage
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 24 Jun 2009 13:49:07 +0000 (16:49 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Fri, 3 Jul 2009 21:44:57 +0000 (00:44 +0300)
configure.ac
src/plugins/external/Makefile.am
src/plugins/media-export/Makefile.am
src/plugins/mediathek/Makefile.am
src/plugins/test/Makefile.am
src/plugins/tracker/Makefile.am
src/rygel/Makefile.am
src/rygel/rygel-meta-config.vala
src/rygel/rygel-user-config.vala
src/ui/Makefile.am

index e8c42a9..c814a1e 100644 (file)
@@ -22,7 +22,6 @@ VALA_REQUIRED=0.7.4
 GUPNP_REQUIRED=0.12.5
 GUPNP_AV_REQUIRED=0.4
 GUPNP_VALA_REQUIRED=0.5.3
-GCONF_REQUIRED=2.16
 DBUS_GLIB_REQUIRED=0.74
 GSTREAMER_REQUIRED=0.10.23
 GIO_REQUIRED=2.16
@@ -34,7 +33,6 @@ LIBSQLITE3_REQUIRED=3.5
 
 PKG_CHECK_MODULES(LIBGUPNP, gupnp-1.0 >= $GUPNP_REQUIRED)
 PKG_CHECK_MODULES(LIBGUPNP_AV, gupnp-av-1.0 >= $GUPNP_AV_REQUIRED)
-PKG_CHECK_MODULES(LIBGCONF, gconf-2.0 >= $GCONF_REQUIRED)
 PKG_CHECK_MODULES(LIBDBUS_GLIB, dbus-glib-1 >= $DBUS_GLIB_REQUIRED)
 PKG_CHECK_MODULES(LIBGSTREAMER, gstreamer-0.10 >= $GSTREAMER_REQUIRED)
 PKG_CHECK_MODULES(LIBGIO, gio-2.0 >= $GIO_REQUIRED)
@@ -85,10 +83,6 @@ if test x$enable_vala = xyes ; then
                   true,
                   [AC_MSG_ERROR("Unable to find Vala bindings for dbus-glib-1")])
 
-    AC_CHECK_FILE("${VAPIDIR}/gconf-2.0.vapi",
-                  true,
-                  [AC_MSG_ERROR("Unable to find Vala bindings for gconf-2.0")])
-
     AC_CHECK_FILE("${VAPIDIR}/gstreamer-0.10.vapi",
                   true,
                   [AC_MSG_ERROR("Unable to find Vala bindings for gstreamer-0.10")])
index 66e660a..7fac14c 100644 (file)
@@ -7,7 +7,6 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
            $(LIBDBUS_GLIB_CFLAGS) \
            $(GEE_CFLAGS) \
            $(LIBGSTREAMER_CFLAGS) \
-           $(LIBGCONF_CFLAGS) \
            -I$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"'
 
 BUILT_SOURCES = rygel-external-content-dir.c \
@@ -40,8 +39,7 @@ librygel_external_la_LIBADD = $(LIBGUPNP_LIBS) \
                               $(LIBGUPNP_AV_LIBS) \
                              $(LIBDBUS_GLIB_LIBS) \
                              $(LIBGSTREAMER_LIBS) \
-                             $(GEE_LIBS) \
-                             $(LIBGCONF_LIBS)
+                             $(GEE_LIBS)
 librygel_external_la_LDFLAGS = -shared -fPIC -module -avoid-version
 
 CLEANFILES = rygel-external.stamp
index 8765673..8bdbff0 100644 (file)
@@ -6,7 +6,6 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
        $(LIBGUPNP_AV_CFLAGS) \
        $(LIBDBUS_GLIB_CFLAGS) \
        $(LIBGSTREAMER_CFLAGS) \
-       $(LIBGCONF_CFLAGS) \
        $(GEE_CFLAGS) \
        -I$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"'
 
@@ -45,7 +44,6 @@ librygel_media_export_la_LIBADD = \
        $(LIBGUPNP_AV_LIBS) \
        $(LIBDBUS_GLIB_LIBS) \
        $(LIBGSTREAMER_LIBS) \
-       $(LIBGCONF_LIBS) \
        $(GEE_LIBS)
 librygel_media_export_la_LDFLAGS = -shared -fPIC -module -avoid-version
 
index 6eec825..fb138b4 100644 (file)
@@ -7,7 +7,6 @@ AM_CFLAGS = \
        $(LIBGUPNP_AV_CFLAGS) \
        $(LIBDBUS_GLIB_CFLAGS) \
        $(LIBGSTREAMER_CFLAGS) \
-       $(LIBGCONF_CFLAGS) \
        $(GEE_CFLAGS) \
        -I$(top_srcdir)/src/rygel \
        -DDATA_DIR='"$(datadir)"'
@@ -51,7 +50,6 @@ librygel_mediathek_la_LIBADD = \
        $(LIBGUPNP_AV_LIBS) \
        $(LIBDBUS_GLIB_LIBS) \
        $(LIBGSTREAMER_LIBS) \
-       $(LIBGCONF_LIBS) \
        $(GEE_LIBS)
 
 librygel_mediathek_la_LDFLAGS = -shared -fPIC -module -avoid-version
index 2b7d1cd..9fd4548 100644 (file)
@@ -7,7 +7,6 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
            $(LIBDBUS_GLIB_CFLAGS) \
            $(GEE_CFLAGS) \
            $(LIBGSTREAMER_CFLAGS) \
-           $(LIBGCONF_CFLAGS) \
            -I$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"'
 
 BUILT_SOURCES = rygel-test-content-dir.c \
@@ -43,8 +42,7 @@ librygel_test_la_LIBADD = $(LIBGUPNP_LIBS) \
                          $(LIBGUPNP_AV_LIBS) \
                           $(LIBDBUS_GLIB_LIBS) \
                          $(LIBGSTREAMER_LIBS) \
-                          $(GEE_LIBS) \
-                         $(LIBGCONF_LIBS)
+                          $(GEE_LIBS)
 librygel_test_la_LDFLAGS = -shared -fPIC -module -avoid-version
 
 CLEANFILES = rygel-test.stamp
index 3e3210a..39fa0e1 100644 (file)
@@ -7,7 +7,6 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
            $(LIBDBUS_GLIB_CFLAGS) \
             $(LIBGSTREAMER_CFLAGS) \
            $(GEE_CFLAGS) \
-           $(LIBGCONF_CFLAGS) \
            -I$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"'
 
 BUILT_SOURCES = rygel-media-tracker.c \
@@ -67,8 +66,7 @@ librygel_media_tracker_la_LIBADD = $(LIBGUPNP_LIBS) \
                                   $(LIBGUPNP_AV_LIBS) \
                                   $(LIBDBUS_GLIB_LIBS) \
                                   $(LIBGSTREAMER_LIBS) \
-                                  $(GEE_LIBS) \
-                                  $(LIBGCONF_LIBS)
+                                  $(GEE_LIBS)
 librygel_media_tracker_la_LDFLAGS = -shared -fPIC -module -avoid-version
 
 CLEANFILES = rygel-media-tracker.stamp
index 8178223..ad0c7de 100644 (file)
@@ -14,7 +14,6 @@ endif
 
 AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
            $(LIBGUPNP_AV_CFLAGS) \
-           $(LIBGCONF_CFLAGS) \
            $(LIBGSTREAMER_CFLAGS) \
            $(GIO_CFLAGS) \
            $(GEE_CFLAGS) \
@@ -128,7 +127,6 @@ rygel.stamp: $(filter %.vala,$(rygel_SOURCES))
 
 rygel_LDADD = $(LIBGUPNP_LIBS) \
              $(LIBGUPNP_AV_LIBS) \
-             $(LIBGCONF_LIBS) \
              $(LIBGSTREAMER_LIBS) \
              $(GIO_LIBS) \
              $(GEE_LIBS) \
index 137e595..ac830e6 100644 (file)
@@ -50,7 +50,12 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
         this.configs = new ArrayList<Configuration> ();
 
         this.configs.add (CmdlineConfig.get_default ());
-        this.configs.add (UserConfig.get_default ());
+        try {
+            var user_config = UserConfig.get_default ();
+            this.configs.add (user_config);
+        } catch (Error err) {
+            warning ("Failed to load user configuration: %s", err.message);
+        }
     }
 
     public bool get_upnp_enabled () throws GLib.Error {
index c7762d5..353e514 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-using GConf;
 using CStuff;
 
 /**
  * Manages the user configuration for Rygel.
  */
 public class Rygel.UserConfig : GLib.Object, Configuration {
-    protected static const string ROOT_GCONF_PATH = "/apps/rygel/";
+    protected static const string CONFIG_FILE = "rygel.conf";
     protected static const string IP_KEY = "host-ip";
     protected static const string PORT_KEY = "port";
     protected static const string ENABLED_KEY = "enabled";
@@ -52,7 +51,7 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
     // Our singleton
     private static UserConfig config;
 
-    protected GConf.Client gconf;
+    protected KeyFile key_file;
 
     private dynamic DBus.Object dbus_obj;
     private dynamic DBus.Object rygel_obj;
@@ -115,7 +114,7 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
         this.set_bool ("general", LPCM_TRANSCODER_KEY, value);
     }
 
-    public static UserConfig get_default () {
+    public static UserConfig get_default () throws Error {
         if (config == null) {
             config = new UserConfig ();
         }
@@ -123,8 +122,19 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
         return config;
     }
 
-    public UserConfig () {
-        this.gconf = GConf.Client.get_default ();
+    public UserConfig () throws Error {
+        this.key_file = new KeyFile ();
+
+        var dirs = new string[2];
+        dirs[0] = Environment.get_user_config_dir ();
+        dirs[1] = BuildConfig.SYS_CONFIG_DIR;
+        string full_path;
+
+        this.key_file.load_from_dirs (CONFIG_FILE,
+                                      dirs,
+                                      out full_path,
+                                      KeyFileFlags.NONE);
+        debug ("Loaded user configuration from file '%s'", full_path);
 
         DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION);
 
@@ -148,10 +158,7 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
 
     public string get_string (string section,
                               string key) throws GLib.Error {
-        string val;
-        var path = ROOT_GCONF_PATH + section + "/" + key;
-
-        val = this.gconf.get_string (path);
+        var val = this.key_file.get_string (section, key);
 
         if (val == null || val == "") {
             throw new ConfigurationError.NO_VALUE_SET (
@@ -165,18 +172,10 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
                                                   string key)
                                                   throws GLib.Error {
         var str_list = new Gee.ArrayList<string> ();
-        var path = ROOT_GCONF_PATH + section + "/" + key;
-
-        unowned SList<string> strings = this.gconf.get_list (
-                path,
-                GConf.ValueType.STRING);
-        if (strings != null) {
-            foreach (var str in strings) {
-                str_list.add (str);
-            }
-        } else {
-            throw new ConfigurationError.NO_VALUE_SET (
-                                        "No value available for '%s'", key);
+        var strings = this.key_file.get_string_list (section, key);
+
+        foreach (var str in strings) {
+            str_list.add (str);
         }
 
         return str_list;
@@ -187,10 +186,7 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
                         int    min,
                         int    max)
                         throws GLib.Error {
-        int val;
-        var path = ROOT_GCONF_PATH + section + "/" + key;
-
-        val = this.gconf.get_int (path);
+        int val = this.key_file.get_integer (section, key);
 
         if (val < min || val > max) {
             throw new ConfigurationError.VALUE_OUT_OF_RANGE (
@@ -204,17 +200,10 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
                                             string key)
                                             throws GLib.Error {
         var int_list = new Gee.ArrayList<int> ();
-        var path = ROOT_GCONF_PATH + section + "/" + key;
+        var ints = this.key_file.get_integer_list (section, key);
 
-        unowned SList<int> ints = this.gconf.get_list (path,
-                                                       GConf.ValueType.INT);
-        if (ints != null) {
-            foreach (var num in ints) {
-                int_list.add (num);
-            }
-        } else {
-            throw new ConfigurationError.NO_VALUE_SET (
-                                        "No value available for '%s'", key);
+        foreach (var num in ints) {
+            int_list.add (num);
         }
 
         return int_list;
@@ -223,75 +212,41 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
     public bool get_bool (string section,
                           string key)
                           throws GLib.Error {
-        bool val;
-        var path = ROOT_GCONF_PATH + section + "/" + key;
-
-        unowned GConf.Value value = this.gconf.get (path);
-        if (value != null) {
-            val = value.get_bool ();
-        } else {
-            throw new ConfigurationError.NO_VALUE_SET (
-                                        "No value available for '%s'", key);
-        }
-
-        return val;
+        return this.key_file.get_boolean (section, key);
     }
 
     public void set_string (string section,
                             string key,
                             string value) {
-        var path = ROOT_GCONF_PATH + section + "/" + key;
-
-        try {
-            this.gconf.set_string (path, value);
-        } catch (GLib.Error error) {
-            // No big deal
-        }
+        this.key_file.set_string (section, key, value);
     }
 
     public void set_string_list (string                section,
                                  string                key,
                                  Gee.ArrayList<string> str_list) {
-        var path = ROOT_GCONF_PATH + section + "/" + key;
-
         // GConf requires us to provide it GLib.SList
-        SList<string> slist = null;
+        var strings = new string[str_list.size];
+        int i = 0;
 
         foreach (var str in str_list) {
             if (str != "") {
-                slist.append (str);
+                strings[i++] = str;
             }
         }
 
-        try {
-            this.gconf.set_list (path, GConf.ValueType.STRING, slist);
-        } catch (GLib.Error error) {
-            // No big deal
-        }
+        this.key_file.set_string_list (section, key, strings);
     }
 
     public void set_int (string section,
                          string key,
                          int    value) {
-        var path = ROOT_GCONF_PATH + section + "/" + key;
-
-        try {
-            this.gconf.set_int (path, value);
-        } catch (GLib.Error error) {
-            // No big deal
-        }
+        this.key_file.set_integer (section, key, value);
     }
 
     public void set_bool (string section,
                           string key,
                           bool   value) {
-        var path = ROOT_GCONF_PATH + section + "/" + key;
-
-        try {
-            this.gconf.set_bool (path, value);
-        } catch (GLib.Error error) {
-            // No big deal
-        }
+        this.key_file.set_boolean (section, key, value);
     }
 
     private void enable_upnp (bool enable) {
index 7f20dc8..5e4ac66 100644 (file)
@@ -8,7 +8,6 @@ rygeldir = $(top_srcdir)/src/rygel
 
 AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
            $(LIBGUPNP_AV_CFLAGS) \
-           $(LIBGCONF_CFLAGS) \
            $(LIBGSTREAMER_CFLAGS) \
            $(GIO_CFLAGS) \
             $(GTK_CFLAGS) \
@@ -51,7 +50,6 @@ rygel.stamp: $(filter %.vala,$(rygel_preferences_SOURCES))
 
 rygel_preferences_LDADD = $(LIBGUPNP_LIBS) \
                          $(LIBGUPNP_AV_LIBS) \
-                          $(LIBGCONF_LIBS) \
                           $(LIBGSTREAMER_LIBS) \
                           $(GIO_LIBS) \
                           $(GEE_LIBS) \