GHashTable *signon_hash_table_from_variant (GVariant *variant) { GHashTable *hash_table; GVariantIter iter; GVariant *value; gchar *key; if (variant == NULL) return NULL; hash_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, signon_gvalue_free); g_variant_iter_init (&iter, variant); while (g_variant_iter_next (&iter, "{sv}", &key, &value)) { GValue *val = g_slice_new0 (GValue); g_dbus_gvariant_to_gvalue (value, val); g_variant_unref (value); g_hash_table_insert (hash_table, key, val); } return hash_table; }
static void dbus_signal_meta_marshal (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data) { NMDBusSignalData *sd = marshal_data; const char *signal_name; GVariant *parameters, *param; GValue *closure_params; gsize n_params, i; g_return_if_fail (n_param_values == 4); signal_name = g_value_get_string (¶m_values[2]); parameters = g_value_get_variant (¶m_values[3]); if (strcmp (signal_name, sd->signal_name) != 0) return; if (sd->signature) { if (!g_variant_is_of_type (parameters, sd->signature)) { g_warning ("%p: got signal '%s' but parameters were of type '%s', not '%s'", g_value_get_object (¶m_values[0]), signal_name, g_variant_get_type_string (parameters), g_variant_type_peek_string (sd->signature)); return; } n_params = g_variant_n_children (parameters) + 1; } else n_params = 1; closure_params = g_new0 (GValue, n_params); g_value_init (&closure_params[0], G_TYPE_OBJECT); g_value_copy (¶m_values[0], &closure_params[0]); for (i = 1; i < n_params; i++) { param = g_variant_get_child_value (parameters, i - 1); if ( g_variant_is_of_type (param, G_VARIANT_TYPE ("ay")) || g_variant_is_of_type (param, G_VARIANT_TYPE ("aay"))) { /* g_dbus_gvariant_to_gvalue() thinks 'ay' means "non-UTF-8 NUL-terminated string" */ g_value_init (&closure_params[i], G_TYPE_VARIANT); g_value_set_variant (&closure_params[i], param); } else g_dbus_gvariant_to_gvalue (param, &closure_params[i]); g_variant_unref (param); } g_cclosure_marshal_generic (closure, NULL, n_params, closure_params, invocation_hint, NULL); for (i = 0; i < n_params; i++) g_value_unset (&closure_params[i]); g_free (closure_params); }