2007-12-05 Dan Williams <dcbw@redhat.com>

* libnm-util/nm-utils.c
		- (nm_utils_register_value_transformations,
		   nm_utils_convert_gvalue_hash_to_string): better debug output of
			GHashTables of GValues too



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3136 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2007-12-05 16:41:09 +00:00
parent 7155a6825e
commit 5ec181c20e
2 changed files with 40 additions and 0 deletions

View File

@@ -1,3 +1,10 @@
2007-12-05 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-utils.c
- (nm_utils_register_value_transformations,
nm_utils_convert_gvalue_hash_to_string): better debug output of
GHashTables of GValues too
2007-12-04 Dan Williams <dcbw@redhat.com> 2007-12-04 Dan Williams <dcbw@redhat.com>
* initscript/RedHat/NetworkManager.in * initscript/RedHat/NetworkManager.in

View File

@@ -432,6 +432,7 @@ nm_utils_string_slist_validate (GSList *list, const char **valid_values)
#define TYPE_GSLIST_OF_STRINGS dbus_g_type_get_collection ("GSList", G_TYPE_STRING) #define TYPE_GSLIST_OF_STRINGS dbus_g_type_get_collection ("GSList", G_TYPE_STRING)
#define TYPE_ARRAY_OF_IP4ADDR_STRUCTS dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_collection ("GArray", G_TYPE_UINT)) #define TYPE_ARRAY_OF_IP4ADDR_STRUCTS dbus_g_type_get_collection ("GPtrArray", dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
#define TYPE_HASH_OF_GVALUES dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE)
static void static void
nm_utils_convert_strv_to_slist (const GValue *src_value, GValue *dest_value) nm_utils_convert_strv_to_slist (const GValue *src_value, GValue *dest_value)
@@ -561,6 +562,35 @@ nm_utils_convert_ip4_addr_struct_array_to_string (const GValue *src_value, GValu
g_string_free (printable, FALSE); g_string_free (printable, FALSE);
} }
static void
convert_one_hash_entry (gpointer key, gpointer value, gpointer user_data)
{
GString *printable = (GString *) user_data;
char *value_as_string;
value_as_string = g_strdup_value_contents ((GValue *) value);
g_string_append_printf (printable, " { '%s': %s },", (const char *) key, value_as_string);
g_free (value_as_string);
}
static void
nm_utils_convert_gvalue_hash_to_string (const GValue *src_value, GValue *dest_value)
{
GHashTable *hash;
GString *printable;
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), TYPE_HASH_OF_GVALUES));
hash = (GHashTable *) g_value_get_boxed (src_value);
printable = g_string_new ("[");
g_hash_table_foreach (hash, convert_one_hash_entry, printable);
g_string_append (printable, " ]");
g_value_take_string (dest_value, printable->str);
g_string_free (printable, FALSE);
}
void void
nm_utils_register_value_transformations (void) nm_utils_register_value_transformations (void)
{ {
@@ -579,6 +609,9 @@ nm_utils_register_value_transformations (void)
g_value_register_transform_func (TYPE_ARRAY_OF_IP4ADDR_STRUCTS, g_value_register_transform_func (TYPE_ARRAY_OF_IP4ADDR_STRUCTS,
G_TYPE_STRING, G_TYPE_STRING,
nm_utils_convert_ip4_addr_struct_array_to_string); nm_utils_convert_ip4_addr_struct_array_to_string);
g_value_register_transform_func (TYPE_HASH_OF_GVALUES,
G_TYPE_STRING,
nm_utils_convert_gvalue_hash_to_string);
registered = TRUE; registered = TRUE;
} }
} }