From: Jens Georg Date: Tue, 30 Apr 2013 02:24:43 +0000 (+0200) Subject: ui: Fix half-empty user files on first start X-Git-Tag: RYGEL_0_19_1~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ddd5b7cd0b1cc12f5d0f4f944eecca1aac51272;p=profile%2Fivi%2Frygel.git ui: Fix half-empty user files on first start --- diff --git a/src/ui/rygel-writable-user-config.vala b/src/ui/rygel-writable-user-config.vala index d702370..cec92a6 100644 --- a/src/ui/rygel-writable-user-config.vala +++ b/src/ui/rygel-writable-user-config.vala @@ -32,7 +32,7 @@ public class Rygel.WritableUserConfig : Rygel.UserConfig { private const string RYGEL_PATH = "/org/gnome/Rygel1"; private const string RYGEL_INTERFACE = "org.gnome.Rygel1"; - private string user_config; + private File user_config; public WritableUserConfig () throws Error { var path = Path.build_filename (Environment.get_user_config_dir (), @@ -40,14 +40,27 @@ public class Rygel.WritableUserConfig : Rygel.UserConfig { base (path); - this.user_config = path; + this.user_config = File.new_for_path (path); + + // Copy contents of system config file into user config file + if (!this.user_config.query_exists ()) { + try { + this.key_file.load_from_data (this.sys_key_file.to_data (), + -1, + KeyFileFlags.KEEP_COMMENTS | + KeyFileFlags.KEEP_TRANSLATIONS); + } catch (Error error) { + // must not happen as we parsed sys_key_file successfully + // already + assert_not_reached (); + } + } } public bool is_upnp_enabled () { try { - var file = File.new_for_path (this.user_config); var autostart_file = this.get_autostart_file (); - if (file.query_exists () && autostart_file.query_exists ()) { + if (this.user_config.query_exists () && autostart_file.query_exists ()) { return this.get_upnp_enabled (); }