gboolean
gkd_secret_property_parse_all (GVariant *array,
			       const gchar *interface,
			       GckBuilder *builder)
{
	CK_ATTRIBUTE_TYPE attr_type;
	const char *name;
	DataType data_type;
	GVariantIter iter;
	GVariant *variant;

	g_return_val_if_fail (array != NULL, FALSE);
	g_return_val_if_fail (builder != NULL, FALSE);

	g_variant_iter_init (&iter, array);

	while (g_variant_iter_next (&iter, "{&sv}", &name, &variant)) {
		/* Property interface.name */
		if (!property_to_attribute (name, interface, &attr_type, &data_type))
			return FALSE;

		/* Property value */
		if (!iter_get_variant (variant, data_type, attr_type, builder)) {
			g_variant_unref (variant);
			return FALSE;
		}

		g_variant_unref (variant);
	}

	return TRUE;
}
gboolean
gkd_secret_property_parse_all (DBusMessageIter *array,
                               const gchar *interface,
                               GckBuilder *builder)
{
	DBusMessageIter dict;
	CK_ATTRIBUTE_TYPE attr_type;
	const char *name;
	DataType data_type;

	g_return_val_if_fail (array != NULL, FALSE);
	g_return_val_if_fail (builder != NULL, FALSE);

	while (dbus_message_iter_get_arg_type (array) == DBUS_TYPE_DICT_ENTRY) {
		dbus_message_iter_recurse (array, &dict);

		/* Property interface.name */
		g_return_val_if_fail (dbus_message_iter_get_arg_type (&dict) == DBUS_TYPE_STRING, FALSE);
		dbus_message_iter_get_basic (&dict, &name);
		dbus_message_iter_next (&dict);

		if (!property_to_attribute (name, interface, &attr_type, &data_type))
			return FALSE;

		/* Property value */
		g_return_val_if_fail (dbus_message_iter_get_arg_type (&dict) == DBUS_TYPE_VARIANT, FALSE);
		if (!iter_get_variant (&dict, data_type, attr_type, builder))
			return FALSE;

		dbus_message_iter_next (array);
	}

	return TRUE;
}
gboolean
gkd_secret_property_get_type (const gchar *property, CK_ATTRIBUTE_TYPE *type)
{
	DataType data_type;

	g_return_val_if_fail (property, FALSE);
	g_return_val_if_fail (type, FALSE);

	return property_to_attribute (property, NULL, type, &data_type);
}
gboolean
gkd_secret_property_parse_variant (GVariant *variant,
				   const gchar *property,
				   GckBuilder *builder)
{
	CK_ATTRIBUTE_TYPE attr_type;
	DataType data_type;

	g_return_val_if_fail (variant, FALSE);
	g_return_val_if_fail (property, FALSE);
	g_return_val_if_fail (builder != NULL, FALSE);

	if (!property_to_attribute (property, NULL, &attr_type, &data_type))
		return FALSE;

	return iter_get_variant (variant, data_type, attr_type, builder);
}