[rygel/config: 19/25] Methods to get/set list of strings configuration



commit 1a4ebad397aee1f20fbf5f9ed326c0ace94c45dd
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed May 27 17:54:02 2009 +0300

    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 files changed, 40 insertions(+), 0 deletions(-)

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<string> get_string_list (string section,
+                                                  string key) {
+        var str_list = new Gee.ArrayList<string> ();
+        var path = ROOT_GCONF_PATH + section + "/" + key;
+
+        try {
+            unowned SList<string> 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<string> str_list) {
+        var path = ROOT_GCONF_PATH + section + "/" + key;
+
+        // GConf requires us to provide it GLib.SList
+        SList<string> 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) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]