From 1a4ebad397aee1f20fbf5f9ed326c0ace94c45dd Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Wed, 27 May 2009 17:54:02 +0300 Subject: [PATCH] Methods to get/set list of strings configuration Provide convenience methods to get/set list of strings from configuration --- src/rygel/rygel-configuration.vala | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/rygel/rygel-configuration.vala b/src/rygel/rygel-configuration.vala index b91ed28..b4f00df 100644 --- a/src/rygel/rygel-configuration.vala +++ b/src/rygel/rygel-configuration.vala @@ -134,6 +134,27 @@ public class Rygel.Configuration { return val; } + public Gee.ArrayList get_string_list (string section, + string key) { + var str_list = new Gee.ArrayList (); + var path = ROOT_GCONF_PATH + section + "/" + key; + + try { + unowned SList strings = this.gconf.get_list ( + path, + GConf.ValueType.STRING); + if (strings != null) { + foreach (var str in strings) { + str_list.add (str); + } + } + } catch (GLib.Error error) { + warning ("Failed to get value for key: %s\n", path); + } + + return str_list; + } + public int get_int (string section, string key, int min, @@ -187,6 +208,25 @@ public class Rygel.Configuration { } } + public void set_string_list (string section, + string key, + Gee.ArrayList str_list) { + var path = ROOT_GCONF_PATH + section + "/" + key; + + // GConf requires us to provide it GLib.SList + SList slist = null; + + foreach (var str in str_list) { + slist.append (str); + } + + try { + this.gconf.set_list (path, GConf.ValueType.STRING, slist); + } catch (GLib.Error error) { + // No big deal + } + } + public void set_int (string section, string key, int value) { -- 2.7.4