/* firmware-manager.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from firmware-manager.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include "gnome-games.h"
#include <glib.h>
#include <glib-object.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	GAMES_FIRMWARE_MANAGER_0_PROPERTY,
	GAMES_FIRMWARE_MANAGER_NUM_PROPERTIES
};
static GParamSpec* games_firmware_manager_properties[GAMES_FIRMWARE_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer games_firmware_manager_parent_class = NULL;

static GType games_firmware_manager_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

void
games_firmware_manager_is_all_firmware_valid (GamesFirmwareManager* self,
                                              GamesCore* core,
                                              GamesPlatform* platform,
                                              GError** error)
{
	GamesFirmware** _tmp0_ = NULL;
	gint _tmp1_ = 0;
	GamesFirmware** _tmp2_;
	gint _tmp0__length1;
	gint __tmp0__size_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (core != NULL);
	g_return_if_fail (platform != NULL);
	_tmp2_ = games_core_get_all_firmware (core, platform, &_tmp1_, &_inner_error0_);
	_tmp0_ = _tmp2_;
	_tmp0__length1 = _tmp1_;
	__tmp0__size_ = _tmp0__length1;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	{
		GamesFirmware** firmware_collection = NULL;
		gint firmware_collection_length1 = 0;
		gint _firmware_collection_size_ = 0;
		gint firmware_it = 0;
		firmware_collection = _tmp0_;
		firmware_collection_length1 = _tmp0__length1;
		for (firmware_it = 0; firmware_it < firmware_collection_length1; firmware_it = firmware_it + 1) {
			GamesFirmware* _tmp3_;
			GamesFirmware* firmware = NULL;
			_tmp3_ = _g_object_ref0 (firmware_collection[firmware_it]);
			firmware = _tmp3_;
			{
				GamesFirmware* _tmp4_;
				GamesFirmware* _tmp5_;
				_tmp4_ = firmware;
				if (!games_firmware_get_is_mandatory (_tmp4_)) {
					_g_object_unref0 (firmware);
					continue;
				}
				_tmp5_ = firmware;
				games_firmware_check_is_valid (_tmp5_, platform, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (firmware);
					_tmp0_ = (_vala_array_free (_tmp0_, _tmp0__length1, (GDestroyNotify) g_object_unref), NULL);
					return;
				}
				_g_object_unref0 (firmware);
			}
		}
	}
	_tmp0_ = (_vala_array_free (_tmp0_, _tmp0__length1, (GDestroyNotify) g_object_unref), NULL);
}

GamesFirmwareManager*
games_firmware_manager_construct (GType object_type)
{
	GamesFirmwareManager * self = NULL;
	self = (GamesFirmwareManager*) g_object_new (object_type, NULL);
	return self;
}

GamesFirmwareManager*
games_firmware_manager_new (void)
{
	return games_firmware_manager_construct (GAMES_TYPE_FIRMWARE_MANAGER);
}

static void
games_firmware_manager_class_init (GamesFirmwareManagerClass * klass,
                                   gpointer klass_data)
{
	games_firmware_manager_parent_class = g_type_class_peek_parent (klass);
}

static void
games_firmware_manager_instance_init (GamesFirmwareManager * self,
                                      gpointer klass)
{
}

static GType
games_firmware_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesFirmwareManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_firmware_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesFirmwareManager), 0, (GInstanceInitFunc) games_firmware_manager_instance_init, NULL };
	GType games_firmware_manager_type_id;
	games_firmware_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesFirmwareManager", &g_define_type_info, 0);
	return games_firmware_manager_type_id;
}

GType
games_firmware_manager_get_type (void)
{
	static volatile gsize games_firmware_manager_type_id__once = 0;
	if (g_once_init_enter (&games_firmware_manager_type_id__once)) {
		GType games_firmware_manager_type_id;
		games_firmware_manager_type_id = games_firmware_manager_get_type_once ();
		g_once_init_leave (&games_firmware_manager_type_id__once, games_firmware_manager_type_id);
	}
	return games_firmware_manager_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

