From: Zeeshan Ali (Khattak) Date: Wed, 24 Jun 2009 15:38:52 +0000 (+0300) Subject: core: Provide configuration saving API X-Git-Tag: RYGEL_0_4~235 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd72bff5bd2b537210058fa6fb677bd3738e3a1d;p=profile%2Fivi%2Frygel.git core: Provide configuration saving API --- diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala index 353e514..c38801c 100644 --- a/src/rygel/rygel-user-config.vala +++ b/src/rygel/rygel-user-config.vala @@ -52,6 +52,7 @@ public class Rygel.UserConfig : GLib.Object, Configuration { private static UserConfig config; protected KeyFile key_file; + private string path; // Path to configuration file private dynamic DBus.Object dbus_obj; private dynamic DBus.Object rygel_obj; @@ -128,13 +129,12 @@ public class Rygel.UserConfig : GLib.Object, Configuration { 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, + out this.path, KeyFileFlags.NONE); - debug ("Loaded user configuration from file '%s'", full_path); + debug ("Loaded user configuration from file '%s'", this.path); DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION); @@ -148,6 +148,19 @@ public class Rygel.UserConfig : GLib.Object, Configuration { DBUS_INTERFACE); } + public void save () { + size_t length; + var data = this.key_file.to_data (out length); + + try { + FileUtils.set_contents (this.path, data, (long) length); + } catch (FileError err) { + critical ("Failed to save configuration data to file '%s': %s", + this.path, + err.message); + } + } + public bool get_enabled (string section) throws GLib.Error { return this.get_bool (section, ENABLED_KEY); }