comparison libpurple/prefs.c @ 19144:0e30dfac1f46

Added a function to the prefs API to get a list of children names.
author Eric Polino <aluink@pidgin.im>
date Mon, 09 Jul 2007 21:29:08 +0000
parents c4518bbca240
children d201f6967183 3eb794691fae
comparison
equal deleted inserted replaced
19143:3bec25803a00 19144:0e30dfac1f46
33 #include <glib.h> 33 #include <glib.h>
34 #include "internal.h" 34 #include "internal.h"
35 #include "prefs.h" 35 #include "prefs.h"
36 #include "debug.h" 36 #include "debug.h"
37 #include "util.h" 37 #include "util.h"
38 #include "xmlnode.h"
38 39
39 #ifdef _WIN32 40 #ifdef _WIN32
40 #include "win32dep.h" 41 #include "win32dep.h"
41 #endif 42 #endif
42 43
124 /* Create a new node */ 125 /* Create a new node */
125 node = xmlnode_new_child(parent, "pref"); 126 node = xmlnode_new_child(parent, "pref");
126 xmlnode_set_attrib(node, "name", pref->name); 127 xmlnode_set_attrib(node, "name", pref->name);
127 128
128 /* Set the type of this node (if type == PURPLE_PREF_NONE then do nothing) */ 129 /* Set the type of this node (if type == PURPLE_PREF_NONE then do nothing) */
130 /* XXX: Why aren't we using a switch here? */
129 if (pref->type == PURPLE_PREF_INT) { 131 if (pref->type == PURPLE_PREF_INT) {
130 xmlnode_set_attrib(node, "type", "int"); 132 xmlnode_set_attrib(node, "type", "int");
131 snprintf(buf, sizeof(buf), "%d", pref->value.integer); 133 snprintf(buf, sizeof(buf), "%d", pref->value.integer);
132 xmlnode_set_attrib(node, "value", buf); 134 xmlnode_set_attrib(node, "value", buf);
133 } 135 }
1321 purple_prefs_disconnect_by_handle(void *handle) 1323 purple_prefs_disconnect_by_handle(void *handle)
1322 { 1324 {
1323 g_return_if_fail(handle != NULL); 1325 g_return_if_fail(handle != NULL);
1324 1326
1325 disco_callback_helper_handle(&prefs, handle); 1327 disco_callback_helper_handle(&prefs, handle);
1328 }
1329
1330 static xmlnode*
1331 single_pref_to_xmlnode(const struct purple_pref *pref)
1332 {
1333 xmlnode *node;
1334 struct purple_pref *child;
1335
1336 node = xmlnode_new("pref");
1337 xmlnode_set_attrib(node,"name",pref->name);
1338
1339 for(child = pref->first_child; child != NULL; child = child->sibling)
1340 pref_to_xmlnode(node, child);
1341
1342 return node;
1343 }
1344
1345 GList *
1346 purple_prefs_get_children_names(const char *name)
1347 {
1348 struct purple_pref *pref = find_pref(name);
1349 xmlnode * node = single_pref_to_xmlnode(pref);
1350 xmlnode * child = node->child;
1351 GList * list = NULL;
1352
1353 for(child = node->child;child;child = child->next){
1354 list = g_list_append(list,xmlnode_get_attrib(child,"name"));
1355 }
1356 return list;
1357
1326 } 1358 }
1327 1359
1328 void 1360 void
1329 purple_prefs_update_old() 1361 purple_prefs_update_old()
1330 { 1362 {