diff options
author | Rob Taylor <rob.taylor@codethink.co.uk> | 2007-08-09 14:18:36 +0100 |
---|---|---|
committer | Rob Taylor <rob.taylor@codethink.co.uk> | 2007-08-22 15:57:35 +0100 |
commit | 8cbeb877f00f2e59080eb07cd422c40388474b60 (patch) | |
tree | 0074e149f4c2c61261cbf55d3e0744e44c54ac6c | |
parent | 34ca4e70414db7e75205500a7bbb10428d9e1e8e (diff) |
covert OhmKeystore to use new OhmCOnf key iterator
Covert OhmKeystore to use new ohm_conf_keys_foreach.
-rw-r--r-- | ohmd/ohm-keystore.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/ohmd/ohm-keystore.c b/ohmd/ohm-keystore.c index f680a83..caa94f7 100644 --- a/ohmd/ohm-keystore.c +++ b/ohmd/ohm-keystore.c @@ -99,6 +99,18 @@ ohm_keystore_set_key (OhmKeystore *keystore, (dbus_g_type_get_struct ("GValueArray", \ G_TYPE_STRING, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_INVALID)) +static void +get_key_foreach (const char *key, gboolean public, gint value, gpointer user_data) +{ + GPtrArray *data = (GPtrArray *) user_data; + GValue gv ={0,}; + + g_value_init (&gv, OHM_DBUS_STRUCT_STRING_INT_BOOL); + g_value_take_boxed (&gv, dbus_g_type_specialized_construct (OHM_DBUS_STRUCT_STRING_INT_BOOL)); + dbus_g_type_struct_set (&gv, 0, key, 1, value, 2, public, -1); + g_ptr_array_add (data, g_value_get_boxed (&gv)); +} + /** * ohm_keystore_get_keys: * @@ -109,30 +121,16 @@ ohm_keystore_get_keys (OhmKeystore *keystore, GPtrArray **data, GError **error) { - GSList *keys; - GSList *l; - OhmConfKeyValue *new; - GValue *value; - g_return_val_if_fail (keystore != NULL, FALSE); g_return_val_if_fail (OHM_IS_KEYSTORE (keystore), FALSE); g_return_val_if_fail (data != NULL, FALSE); ohm_debug ("Getting list of keys"); - keys = NULL; - ohm_conf_get_keys (keystore->priv->conf, &keys); - *data = g_ptr_array_sized_new (g_slist_length (keys)); - - for (l=keys; l != NULL; l=l->next) { - new = (OhmConfKeyValue *) l->data; - value = g_new0 (GValue, 1); - g_value_init (value, OHM_DBUS_STRUCT_STRING_INT_BOOL); - g_value_take_boxed (value, dbus_g_type_specialized_construct (OHM_DBUS_STRUCT_STRING_INT_BOOL)); - dbus_g_type_struct_set (value, 0, new->name, 1, new->value, 2, new->public, -1); - g_ptr_array_add (*data, g_value_get_boxed (value)); - g_free (value); - } + *data = g_ptr_array_sized_new (ohm_conf_keys_length (keystore->priv->conf)); + + ohm_conf_keys_foreach (keystore->priv->conf, get_key_foreach, *data); + return TRUE; } |