/* nintendo-ds-plugin.c generated by valac 0.36.6.6-c7bee, the Vala compiler
 * generated from nintendo-ds-plugin.vala, do not modify */

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

#include <glib.h>
#include <glib-object.h>
#include <libgnome-games.h>
#include <stdlib.h>
#include <string.h>


#define GAMES_TYPE_NINTENDO_DS_PLUGIN (games_nintendo_ds_plugin_get_type ())
#define GAMES_NINTENDO_DS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_NINTENDO_DS_PLUGIN, GamesNintendoDsPlugin))
#define GAMES_NINTENDO_DS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_NINTENDO_DS_PLUGIN, GamesNintendoDsPluginClass))
#define GAMES_IS_NINTENDO_DS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_NINTENDO_DS_PLUGIN))
#define GAMES_IS_NINTENDO_DS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_NINTENDO_DS_PLUGIN))
#define GAMES_NINTENDO_DS_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_NINTENDO_DS_PLUGIN, GamesNintendoDsPluginClass))

typedef struct _GamesNintendoDsPlugin GamesNintendoDsPlugin;
typedef struct _GamesNintendoDsPluginClass GamesNintendoDsPluginClass;
typedef struct _GamesNintendoDsPluginPrivate GamesNintendoDsPluginPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GAMES_TYPE_NINTENDO_DS_ICON (games_nintendo_ds_icon_get_type ())
#define GAMES_NINTENDO_DS_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_NINTENDO_DS_ICON, GamesNintendoDsIcon))
#define GAMES_NINTENDO_DS_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_NINTENDO_DS_ICON, GamesNintendoDsIconClass))
#define GAMES_IS_NINTENDO_DS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_NINTENDO_DS_ICON))
#define GAMES_IS_NINTENDO_DS_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_NINTENDO_DS_ICON))
#define GAMES_NINTENDO_DS_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_NINTENDO_DS_ICON, GamesNintendoDsIconClass))

typedef struct _GamesNintendoDsIcon GamesNintendoDsIcon;
typedef struct _GamesNintendoDsIconClass GamesNintendoDsIconClass;

struct _GamesNintendoDsPlugin {
	GObject parent_instance;
	GamesNintendoDsPluginPrivate * priv;
};

struct _GamesNintendoDsPluginClass {
	GObjectClass parent_class;
};


static gpointer games_nintendo_ds_plugin_parent_class = NULL;
static GamesPluginIface * games_nintendo_ds_plugin_games_plugin_parent_iface = NULL;
static GType games_nintendo_ds_plugin_type_id = 0;

GType games_nintendo_ds_plugin_get_type (void) G_GNUC_CONST;
enum  {
	GAMES_NINTENDO_DS_PLUGIN_0_PROPERTY
};
#define GAMES_NINTENDO_DS_PLUGIN_FINGERPRINT_PREFIX "nintendo-ds"
#define GAMES_NINTENDO_DS_PLUGIN_MIME_TYPE "application/x-nintendo-ds-rom"
#define GAMES_NINTENDO_DS_PLUGIN_PLATFORM "NintendoDS"
static gchar** games_nintendo_ds_plugin_real_get_mime_types (GamesPlugin* base, int* result_length1);
static GamesUriGameFactory** games_nintendo_ds_plugin_real_get_uri_game_factories (GamesPlugin* base, int* result_length1);
static GamesGame* games_nintendo_ds_plugin_game_for_uri (GamesUri* uri, GError** error);
static GamesGame* _games_nintendo_ds_plugin_game_for_uri_games_generic_game_uri_adapter_game_for_uri (GamesUri* uri, gpointer self, GError** error);
GType games_nintendo_ds_icon_get_type (void) G_GNUC_CONST;
GamesNintendoDsIcon* games_nintendo_ds_icon_new (GamesUri* uri);
GamesNintendoDsIcon* games_nintendo_ds_icon_construct (GType object_type, GamesUri* uri);
GamesNintendoDsPlugin* games_nintendo_ds_plugin_new (void);
GamesNintendoDsPlugin* games_nintendo_ds_plugin_construct (GType object_type);
GType register_games_plugin (GTypeModule* module);
GType games_nintendo_ds_icon_register_type (GTypeModule * module);
GType games_nintendo_ds_plugin_register_type (GTypeModule * module);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static gchar** games_nintendo_ds_plugin_real_get_mime_types (GamesPlugin* base, int* result_length1) {
	GamesNintendoDsPlugin * self;
	gchar** result = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	self = (GamesNintendoDsPlugin*) base;
	_tmp0_ = g_strdup (GAMES_NINTENDO_DS_PLUGIN_MIME_TYPE);
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = 1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}


static GamesGame* _games_nintendo_ds_plugin_game_for_uri_games_generic_game_uri_adapter_game_for_uri (GamesUri* uri, gpointer self, GError** error) {
	GamesGame* result;
	result = games_nintendo_ds_plugin_game_for_uri (uri, error);
	return result;
}


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


static GamesUriGameFactory** games_nintendo_ds_plugin_real_get_uri_game_factories (GamesPlugin* base, int* result_length1) {
	GamesNintendoDsPlugin * self;
	GamesUriGameFactory** result = NULL;
	GamesGenericGameUriAdapter* game_uri_adapter = NULL;
	GamesGenericGameUriAdapter* _tmp0_;
	GamesGenericUriGameFactory* factory = NULL;
	GamesGenericUriGameFactory* _tmp1_;
	GamesUriGameFactory* _tmp2_;
	GamesUriGameFactory** _tmp3_;
	GamesUriGameFactory** _tmp4_;
	gint _tmp4__length1;
	self = (GamesNintendoDsPlugin*) base;
	_tmp0_ = games_generic_game_uri_adapter_new (_games_nintendo_ds_plugin_game_for_uri_games_generic_game_uri_adapter_game_for_uri, NULL, NULL);
	game_uri_adapter = _tmp0_;
	_tmp1_ = games_generic_uri_game_factory_new ((GamesGameUriAdapter*) game_uri_adapter);
	factory = _tmp1_;
	games_generic_uri_game_factory_add_mime_type (factory, GAMES_NINTENDO_DS_PLUGIN_MIME_TYPE);
	_tmp2_ = _g_object_ref0 ((GamesUriGameFactory*) factory);
	_tmp3_ = g_new0 (GamesUriGameFactory*, 1 + 1);
	_tmp3_[0] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	_g_object_unref0 (factory);
	_g_object_unref0 (game_uri_adapter);
	return result;
}


static GamesGame* games_nintendo_ds_plugin_game_for_uri (GamesUri* uri, GError** error) {
	GamesGame* result = NULL;
	GamesFingerprintUid* uid = NULL;
	GamesUri* _tmp0_;
	GamesFingerprintUid* _tmp1_;
	GamesFilenameTitle* title = NULL;
	GamesUri* _tmp2_;
	GamesFilenameTitle* _tmp3_;
	GamesNintendoDsIcon* icon = NULL;
	GamesUri* _tmp4_;
	GamesNintendoDsIcon* _tmp5_;
	GamesGriloMedia* media = NULL;
	GamesGriloMedia* _tmp6_;
	GamesCompositeCover* cover = NULL;
	GamesUri* _tmp7_;
	GamesLocalCover* _tmp8_;
	GamesGriloCover* _tmp9_;
	GamesCover** _tmp10_;
	GamesCover** _tmp11_;
	gint _tmp11__length1;
	GamesCompositeCover* _tmp12_;
	GamesCompositeCover* _tmp13_;
	GamesRetroCoreSource* core_source = NULL;
	gchar* _tmp14_;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	GamesRetroCoreSource* _tmp17_;
	GamesRetroCoreSource* _tmp18_;
	GamesRetroRunner* runner = NULL;
	GamesUri* _tmp19_;
	GamesRetroRunner* _tmp20_;
	GamesGenericGame* _tmp21_;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	_tmp1_ = games_fingerprint_uid_new (_tmp0_, GAMES_NINTENDO_DS_PLUGIN_FINGERPRINT_PREFIX);
	uid = _tmp1_;
	_tmp2_ = uri;
	_tmp3_ = games_filename_title_new (_tmp2_);
	title = _tmp3_;
	_tmp4_ = uri;
	_tmp5_ = games_nintendo_ds_icon_new (_tmp4_);
	icon = _tmp5_;
	_tmp6_ = games_grilo_media_new ((GamesTitle*) title, GAMES_NINTENDO_DS_PLUGIN_MIME_TYPE);
	media = _tmp6_;
	_tmp7_ = uri;
	_tmp8_ = games_local_cover_new (_tmp7_);
	_tmp9_ = games_grilo_cover_new (media, (GamesUid*) uid);
	_tmp10_ = g_new0 (GamesCover*, 2 + 1);
	_tmp10_[0] = (GamesCover*) _tmp8_;
	_tmp10_[1] = (GamesCover*) _tmp9_;
	_tmp11_ = _tmp10_;
	_tmp11__length1 = 2;
	_tmp12_ = games_composite_cover_new (_tmp11_, 2);
	_tmp13_ = _tmp12_;
	_tmp11_ = (_vala_array_free (_tmp11_, _tmp11__length1, (GDestroyNotify) g_object_unref), NULL);
	cover = _tmp13_;
	_tmp14_ = g_strdup (GAMES_NINTENDO_DS_PLUGIN_MIME_TYPE);
	_tmp15_ = g_new0 (gchar*, 1 + 1);
	_tmp15_[0] = _tmp14_;
	_tmp16_ = _tmp15_;
	_tmp16__length1 = 1;
	_tmp17_ = games_retro_core_source_new (GAMES_NINTENDO_DS_PLUGIN_PLATFORM, _tmp16_, 1);
	_tmp18_ = _tmp17_;
	_tmp16_ = (_vala_array_free (_tmp16_, _tmp16__length1, (GDestroyNotify) g_free), NULL);
	core_source = _tmp18_;
	_tmp19_ = uri;
	_tmp20_ = games_retro_runner_new (core_source, _tmp19_, (GamesUid*) uid, (GamesTitle*) title);
	runner = _tmp20_;
	_tmp21_ = games_generic_game_new ((GamesTitle*) title, (GamesIcon*) icon, (GamesCover*) cover, (GamesRunner*) runner);
	result = (GamesGame*) _tmp21_;
	_g_object_unref0 (runner);
	_g_object_unref0 (core_source);
	_g_object_unref0 (cover);
	_g_object_unref0 (media);
	_g_object_unref0 (icon);
	_g_object_unref0 (title);
	_g_object_unref0 (uid);
	return result;
}


GamesNintendoDsPlugin* games_nintendo_ds_plugin_construct (GType object_type) {
	GamesNintendoDsPlugin * self = NULL;
	self = (GamesNintendoDsPlugin*) g_object_new (object_type, NULL);
	return self;
}


GamesNintendoDsPlugin* games_nintendo_ds_plugin_new (void) {
	return games_nintendo_ds_plugin_construct (GAMES_TYPE_NINTENDO_DS_PLUGIN);
}


static void games_nintendo_ds_plugin_class_init (GamesNintendoDsPluginClass * klass) {
	games_nintendo_ds_plugin_parent_class = g_type_class_peek_parent (klass);
}


static void games_nintendo_ds_plugin_games_plugin_interface_init (GamesPluginIface * iface) {
	games_nintendo_ds_plugin_games_plugin_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_mime_types = (gchar** (*) (GamesPlugin *, int*)) games_nintendo_ds_plugin_real_get_mime_types;
	iface->get_uri_game_factories = (GamesUriGameFactory** (*) (GamesPlugin *, int*)) games_nintendo_ds_plugin_real_get_uri_game_factories;
}


static void games_nintendo_ds_plugin_instance_init (GamesNintendoDsPlugin * self) {
}


GType games_nintendo_ds_plugin_get_type (void) {
	return games_nintendo_ds_plugin_type_id;
}


GType games_nintendo_ds_plugin_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesNintendoDsPluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_nintendo_ds_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesNintendoDsPlugin), 0, (GInstanceInitFunc) games_nintendo_ds_plugin_instance_init, NULL };
	static const GInterfaceInfo games_plugin_info = { (GInterfaceInitFunc) games_nintendo_ds_plugin_games_plugin_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_nintendo_ds_plugin_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesNintendoDsPlugin", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_nintendo_ds_plugin_type_id, GAMES_TYPE_PLUGIN, &games_plugin_info);
	return games_nintendo_ds_plugin_type_id;
}


GType register_games_plugin (GTypeModule* module) {
	GType result = 0UL;
	g_return_val_if_fail (module != NULL, 0UL);
	games_nintendo_ds_icon_register_type (module);
	games_nintendo_ds_plugin_register_type (module);
	result = GAMES_TYPE_NINTENDO_DS_PLUGIN;
	return result;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



