/* sega-saturn-plugin.c generated by valac 0.35.5, the Vala compiler
 * generated from sega-saturn-plugin.vala, do not modify */

/* This file is part of GNOME Games. License: GPLv3*/

#include <glib.h>
#include <glib-object.h>
#include <libgnome-games.h>
#include <stdlib.h>
#include <string.h>
#include <libtracker-sparql/tracker-sparql.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>


#define GAMES_TYPE_SEGA_SATURN_PLUGIN (games_sega_saturn_plugin_get_type ())
#define GAMES_SEGA_SATURN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_SEGA_SATURN_PLUGIN, GamesSegaSaturnPlugin))
#define GAMES_SEGA_SATURN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_SEGA_SATURN_PLUGIN, GamesSegaSaturnPluginClass))
#define GAMES_IS_SEGA_SATURN_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_SEGA_SATURN_PLUGIN))
#define GAMES_IS_SEGA_SATURN_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_SEGA_SATURN_PLUGIN))
#define GAMES_SEGA_SATURN_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_SEGA_SATURN_PLUGIN, GamesSegaSaturnPluginClass))

typedef struct _GamesSegaSaturnPlugin GamesSegaSaturnPlugin;
typedef struct _GamesSegaSaturnPluginClass GamesSegaSaturnPluginClass;
typedef struct _GamesSegaSaturnPluginPrivate GamesSegaSaturnPluginPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GAMES_TYPE_SEGA_SATURN_HEADER (games_sega_saturn_header_get_type ())
#define GAMES_SEGA_SATURN_HEADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_SEGA_SATURN_HEADER, GamesSegaSaturnHeader))
#define GAMES_SEGA_SATURN_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_SEGA_SATURN_HEADER, GamesSegaSaturnHeaderClass))
#define GAMES_IS_SEGA_SATURN_HEADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_SEGA_SATURN_HEADER))
#define GAMES_IS_SEGA_SATURN_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_SEGA_SATURN_HEADER))
#define GAMES_SEGA_SATURN_HEADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_SEGA_SATURN_HEADER, GamesSegaSaturnHeaderClass))

typedef struct _GamesSegaSaturnHeader GamesSegaSaturnHeader;
typedef struct _GamesSegaSaturnHeaderClass GamesSegaSaturnHeaderClass;

#define GAMES_TYPE_SEGA_SATURN_UID (games_sega_saturn_uid_get_type ())
#define GAMES_SEGA_SATURN_UID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_SEGA_SATURN_UID, GamesSegaSaturnUid))
#define GAMES_SEGA_SATURN_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_SEGA_SATURN_UID, GamesSegaSaturnUidClass))
#define GAMES_IS_SEGA_SATURN_UID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_SEGA_SATURN_UID))
#define GAMES_IS_SEGA_SATURN_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_SEGA_SATURN_UID))
#define GAMES_SEGA_SATURN_UID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_SEGA_SATURN_UID, GamesSegaSaturnUidClass))

typedef struct _GamesSegaSaturnUid GamesSegaSaturnUid;
typedef struct _GamesSegaSaturnUidClass GamesSegaSaturnUidClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesSegaSaturnPlugin {
	GObject parent_instance;
	GamesSegaSaturnPluginPrivate * priv;
};

struct _GamesSegaSaturnPluginClass {
	GObjectClass parent_class;
};

typedef enum  {
	GAMES_SEGA_SATURN_ERROR_INVALID_CUE_SHEET,
	GAMES_SEGA_SATURN_ERROR_INVALID_FILE_TYPE,
	GAMES_SEGA_SATURN_ERROR_CANT_READ_FILE,
	GAMES_SEGA_SATURN_ERROR_INVALID_HEADER
} GamesSegaSaturnError;
#define GAMES_SEGA_SATURN_ERROR games_sega_saturn_error_quark ()

static gpointer games_sega_saturn_plugin_parent_class = NULL;
static GamesPluginIface * games_sega_saturn_plugin_games_plugin_parent_iface = NULL;
static GType games_sega_saturn_plugin_type_id = 0;

GType games_sega_saturn_plugin_get_type (void) G_GNUC_CONST;
enum  {
	GAMES_SEGA_SATURN_PLUGIN_DUMMY_PROPERTY
};
#define GAMES_SEGA_SATURN_PLUGIN_SEARCHED_MIME_TYPE "application/x-cue"
#define GAMES_SEGA_SATURN_PLUGIN_SPECIFIC_MIME_TYPE "application/x-saturn-rom"
#define GAMES_SEGA_SATURN_PLUGIN_PLATFORM "SegaSaturn"
static GamesGameSource* games_sega_saturn_plugin_real_get_game_source (GamesPlugin* base, GError** error);
static GamesGame* games_sega_saturn_plugin_game_for_uri (const gchar* uri, GError** error);
static GamesGame* _games_sega_saturn_plugin_game_for_uri_games_generic_sync_game_uri_adapter_game_for_uri (const gchar* uri, gpointer self, GError** error);
static GFile* games_sega_saturn_plugin_get_binary_file (GamesCueSheet* cue, GError** error);
GType games_sega_saturn_header_get_type (void) G_GNUC_CONST;
GamesSegaSaturnHeader* games_sega_saturn_header_new (GFile* file);
GamesSegaSaturnHeader* games_sega_saturn_header_construct (GType object_type, GFile* file);
void games_sega_saturn_header_check_validity (GamesSegaSaturnHeader* self, GError** error);
GType games_sega_saturn_uid_get_type (void) G_GNUC_CONST;
GamesSegaSaturnUid* games_sega_saturn_uid_new (GamesSegaSaturnHeader* header);
GamesSegaSaturnUid* games_sega_saturn_uid_construct (GType object_type, GamesSegaSaturnHeader* header);
GQuark games_sega_saturn_error_quark (void);
GamesSegaSaturnPlugin* games_sega_saturn_plugin_new (void);
GamesSegaSaturnPlugin* games_sega_saturn_plugin_construct (GType object_type);
GType register_games_plugin (GTypeModule* module);
GType games_sega_saturn_header_register_type (GTypeModule * module);
GType games_sega_saturn_plugin_register_type (GTypeModule * module);
GType games_sega_saturn_uid_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 GamesGame* _games_sega_saturn_plugin_game_for_uri_games_generic_sync_game_uri_adapter_game_for_uri (const gchar* uri, gpointer self, GError** error) {
	GamesGame* result;
	result = games_sega_saturn_plugin_game_for_uri (uri, error);
	return result;
}


static GamesGameSource* games_sega_saturn_plugin_real_get_game_source (GamesPlugin* base, GError** error) {
	GamesSegaSaturnPlugin * self;
	GamesGameSource* result = NULL;
	GamesGenericSyncGameUriAdapter* game_uri_adapter;
	GamesGenericSyncGameUriAdapter* _tmp0_;
	GamesGenericUriGameFactory* factory;
	GamesGenericUriGameFactory* _tmp1_;
	GamesMimeTypeTrackerQuery* query;
	GamesMimeTypeTrackerQuery* _tmp2_;
	TrackerSparqlConnection* connection;
	TrackerSparqlConnection* _tmp3_;
	GamesTrackerGameSource* source;
	GamesTrackerGameSource* _tmp4_;
	GamesTrackerGameSource* _tmp5_;
	GError * _inner_error_ = NULL;
	self = (GamesSegaSaturnPlugin*) base;
	_tmp0_ = games_generic_sync_game_uri_adapter_new (_games_sega_saturn_plugin_game_for_uri_games_generic_sync_game_uri_adapter_game_for_uri, NULL, NULL);
	game_uri_adapter = _tmp0_;
	_tmp1_ = games_generic_uri_game_factory_new ((GamesGameUriAdapter*) game_uri_adapter, NULL, NULL, NULL);
	factory = _tmp1_;
	_tmp2_ = games_mime_type_tracker_query_new (GAMES_SEGA_SATURN_PLUGIN_SEARCHED_MIME_TYPE, (GamesUriGameFactory*) factory);
	query = _tmp2_;
	_tmp3_ = tracker_sparql_connection_get (NULL, &_inner_error_);
	connection = _tmp3_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (query);
		_g_object_unref0 (factory);
		_g_object_unref0 (game_uri_adapter);
		return NULL;
	}
	_tmp4_ = games_tracker_game_source_new (connection);
	source = _tmp4_;
	_tmp5_ = source;
	games_tracker_game_source_add_query (_tmp5_, (GamesTrackerQuery*) query);
	result = (GamesGameSource*) source;
	_g_object_unref0 (connection);
	_g_object_unref0 (query);
	_g_object_unref0 (factory);
	_g_object_unref0 (game_uri_adapter);
	return result;
}


static GamesGame* games_sega_saturn_plugin_game_for_uri (const gchar* uri, GError** error) {
	GamesGame* result = NULL;
	GFile* file;
	const gchar* _tmp0_;
	GFile* _tmp1_;
	GamesCueSheet* cue;
	GFile* _tmp2_;
	GamesCueSheet* _tmp3_;
	GFile* bin_file;
	GamesCueSheet* _tmp4_;
	GFile* _tmp5_;
	GamesSegaSaturnHeader* header;
	GFile* _tmp6_;
	GamesSegaSaturnHeader* _tmp7_;
	GamesSegaSaturnHeader* _tmp8_;
	GamesSegaSaturnUid* uid;
	GamesSegaSaturnHeader* _tmp9_;
	GamesSegaSaturnUid* _tmp10_;
	GamesFilenameTitle* title;
	const gchar* _tmp11_;
	GamesFilenameTitle* _tmp12_;
	GamesDummyIcon* icon;
	GamesDummyIcon* _tmp13_;
	GamesGriloMedia* media;
	GamesFilenameTitle* _tmp14_;
	GamesGriloMedia* _tmp15_;
	GamesCompositeCover* cover;
	const gchar* _tmp16_;
	GamesLocalCover* _tmp17_;
	GamesGriloMedia* _tmp18_;
	GamesSegaSaturnUid* _tmp19_;
	GamesGriloCover* _tmp20_;
	GamesCover** _tmp21_;
	GamesCover** _tmp22_;
	gint _tmp22__length1;
	GamesCompositeCover* _tmp23_;
	GamesCompositeCover* _tmp24_;
	GamesRetroCoreSource* core_source;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar** _tmp27_;
	gchar** _tmp28_;
	gint _tmp28__length1;
	GamesRetroCoreSource* _tmp29_;
	GamesRetroCoreSource* _tmp30_;
	GamesRetroRunner* runner;
	GamesRetroCoreSource* _tmp31_;
	const gchar* _tmp32_;
	GamesSegaSaturnUid* _tmp33_;
	GamesFilenameTitle* _tmp34_;
	GamesRetroRunner* _tmp35_;
	GamesFilenameTitle* _tmp36_;
	GamesDummyIcon* _tmp37_;
	GamesCompositeCover* _tmp38_;
	GamesRetroRunner* _tmp39_;
	GamesGenericGame* _tmp40_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	_tmp1_ = g_file_new_for_uri (_tmp0_);
	file = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = games_cue_sheet_new (_tmp2_, &_inner_error_);
	cue = _tmp3_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp4_ = cue;
	_tmp5_ = games_sega_saturn_plugin_get_binary_file (_tmp4_, &_inner_error_);
	bin_file = _tmp5_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (cue);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp6_ = bin_file;
	_tmp7_ = games_sega_saturn_header_new (_tmp6_);
	header = _tmp7_;
	_tmp8_ = header;
	games_sega_saturn_header_check_validity (_tmp8_, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (header);
		_g_object_unref0 (bin_file);
		_g_object_unref0 (cue);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp9_ = header;
	_tmp10_ = games_sega_saturn_uid_new (_tmp9_);
	uid = _tmp10_;
	_tmp11_ = uri;
	_tmp12_ = games_filename_title_new (_tmp11_);
	title = _tmp12_;
	_tmp13_ = games_dummy_icon_new ();
	icon = _tmp13_;
	_tmp14_ = title;
	_tmp15_ = games_grilo_media_new ((GamesTitle*) _tmp14_, GAMES_SEGA_SATURN_PLUGIN_SPECIFIC_MIME_TYPE);
	media = _tmp15_;
	_tmp16_ = uri;
	_tmp17_ = games_local_cover_new (_tmp16_);
	_tmp18_ = media;
	_tmp19_ = uid;
	_tmp20_ = games_grilo_cover_new (_tmp18_, (GamesUid*) _tmp19_);
	_tmp21_ = g_new0 (GamesCover*, 2 + 1);
	_tmp21_[0] = (GamesCover*) _tmp17_;
	_tmp21_[1] = (GamesCover*) _tmp20_;
	_tmp22_ = _tmp21_;
	_tmp22__length1 = 2;
	_tmp23_ = games_composite_cover_new (_tmp22_, 2);
	_tmp24_ = _tmp23_;
	_tmp22_ = (_vala_array_free (_tmp22_, _tmp22__length1, (GDestroyNotify) g_object_unref), NULL);
	cover = _tmp24_;
	_tmp25_ = g_strdup (GAMES_SEGA_SATURN_PLUGIN_SEARCHED_MIME_TYPE);
	_tmp26_ = g_strdup (GAMES_SEGA_SATURN_PLUGIN_SPECIFIC_MIME_TYPE);
	_tmp27_ = g_new0 (gchar*, 2 + 1);
	_tmp27_[0] = _tmp25_;
	_tmp27_[1] = _tmp26_;
	_tmp28_ = _tmp27_;
	_tmp28__length1 = 2;
	_tmp29_ = games_retro_core_source_new (GAMES_SEGA_SATURN_PLUGIN_PLATFORM, _tmp28_, 2);
	_tmp30_ = _tmp29_;
	_tmp28_ = (_vala_array_free (_tmp28_, _tmp28__length1, (GDestroyNotify) g_free), NULL);
	core_source = _tmp30_;
	_tmp31_ = core_source;
	_tmp32_ = uri;
	_tmp33_ = uid;
	_tmp34_ = title;
	_tmp35_ = games_retro_runner_new (_tmp31_, _tmp32_, (GamesUid*) _tmp33_, (GamesTitle*) _tmp34_);
	runner = _tmp35_;
	_tmp36_ = title;
	_tmp37_ = icon;
	_tmp38_ = cover;
	_tmp39_ = runner;
	_tmp40_ = games_generic_game_new ((GamesTitle*) _tmp36_, (GamesIcon*) _tmp37_, (GamesCover*) _tmp38_, (GamesRunner*) _tmp39_);
	result = (GamesGame*) _tmp40_;
	_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);
	_g_object_unref0 (header);
	_g_object_unref0 (bin_file);
	_g_object_unref0 (cue);
	_g_object_unref0 (file);
	return result;
}


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


static GFile* games_sega_saturn_plugin_get_binary_file (GamesCueSheet* cue, GError** error) {
	GFile* result = NULL;
	GamesCueSheet* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	GamesCueSheetTrackNode* track;
	GamesCueSheet* _tmp10_;
	GamesCueSheetTrackNode* _tmp11_;
	GamesCueSheetFileNode* file;
	GamesCueSheetTrackNode* _tmp12_;
	GamesCueSheetFileNode* _tmp13_;
	GamesCueSheetFileNode* _tmp14_;
	GamesCueSheetFileNode* _tmp15_;
	gboolean _tmp16_ = FALSE;
	GamesCueSheetFileNode* _tmp17_;
	GamesCueSheetFileFormat _tmp18_;
	GamesCueSheetFileFormat _tmp19_;
	GamesCueSheetTrackNode* _tmp30_;
	GamesCueSheetTrackMode _tmp31_;
	GamesCueSheetTrackMode _tmp32_;
	gboolean _tmp33_;
	GFileInfo* file_info;
	GamesCueSheetFileNode* _tmp44_;
	GFile* _tmp45_;
	GFile* _tmp46_;
	GFileInfo* _tmp47_;
	GFileInfo* _tmp48_;
	const gchar* _tmp49_;
	GamesCueSheetFileNode* _tmp57_;
	GFile* _tmp58_;
	GFile* _tmp59_;
	GFile* _tmp60_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (cue != NULL, NULL);
	_tmp0_ = cue;
	_tmp1_ = games_cue_sheet_get_tracks_number (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == ((guint) 0)) {
		GamesCueSheet* _tmp3_;
		GFile* _tmp4_;
		GFile* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		GError* _tmp8_;
		GError* _tmp9_;
		_tmp3_ = cue;
		_tmp4_ = games_cue_sheet_get_file (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = g_file_get_uri (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_error_new (GAMES_SEGA_SATURN_ERROR, GAMES_SEGA_SATURN_ERROR_INVALID_CUE_SHEET, _ ("The file “%s” doesn’t have a track."), _tmp7_);
		_tmp9_ = _tmp8_;
		_g_free0 (_tmp7_);
		_inner_error_ = _tmp9_;
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp10_ = cue;
	_tmp11_ = games_cue_sheet_get_track (_tmp10_, (guint) 0, &_inner_error_);
	track = _tmp11_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp12_ = track;
	_tmp13_ = games_cue_sheet_track_node_get_file (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = _g_object_ref0 (_tmp14_);
	file = _tmp15_;
	_tmp17_ = file;
	_tmp18_ = games_cue_sheet_file_node_get_file_format (_tmp17_);
	_tmp19_ = _tmp18_;
	if (_tmp19_ != GAMES_CUE_SHEET_FILE_FORMAT_BINARY) {
		GamesCueSheetFileNode* _tmp20_;
		GamesCueSheetFileFormat _tmp21_;
		GamesCueSheetFileFormat _tmp22_;
		_tmp20_ = file;
		_tmp21_ = games_cue_sheet_file_node_get_file_format (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp16_ = _tmp22_ != GAMES_CUE_SHEET_FILE_FORMAT_UNKNOWN;
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		GamesCueSheet* _tmp23_;
		GFile* _tmp24_;
		GFile* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		GError* _tmp28_;
		GError* _tmp29_;
		_tmp23_ = cue;
		_tmp24_ = games_cue_sheet_get_file (_tmp23_);
		_tmp25_ = _tmp24_;
		_tmp26_ = g_file_get_uri (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = g_error_new (GAMES_SEGA_SATURN_ERROR, GAMES_SEGA_SATURN_ERROR_INVALID_CUE_SHEET, _ ("The file “%s” doesn’t have a valid binary file format."), _tmp27_);
		_tmp29_ = _tmp28_;
		_g_free0 (_tmp27_);
		_inner_error_ = _tmp29_;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (file);
		_g_object_unref0 (track);
		return NULL;
	}
	_tmp30_ = track;
	_tmp31_ = games_cue_sheet_track_node_get_track_mode (_tmp30_);
	_tmp32_ = _tmp31_;
	_tmp33_ = games_cue_sheet_track_mode_is_mode1 (_tmp32_);
	if (!_tmp33_) {
		GamesCueSheet* _tmp34_;
		GFile* _tmp35_;
		GFile* _tmp36_;
		gchar* _tmp37_;
		gchar* _tmp38_;
		GamesCueSheetTrackNode* _tmp39_;
		gint _tmp40_;
		gint _tmp41_;
		GError* _tmp42_;
		GError* _tmp43_;
		_tmp34_ = cue;
		_tmp35_ = games_cue_sheet_get_file (_tmp34_);
		_tmp36_ = _tmp35_;
		_tmp37_ = g_file_get_uri (_tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = track;
		_tmp40_ = games_cue_sheet_track_node_get_track_number (_tmp39_);
		_tmp41_ = _tmp40_;
		_tmp42_ = g_error_new (GAMES_SEGA_SATURN_ERROR, GAMES_SEGA_SATURN_ERROR_INVALID_CUE_SHEET, _ ("The file “%s” doesn’t have a valid track mode for track %d."), _tmp38_, _tmp41_);
		_tmp43_ = _tmp42_;
		_g_free0 (_tmp38_);
		_inner_error_ = _tmp43_;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (file);
		_g_object_unref0 (track);
		return NULL;
	}
	_tmp44_ = file;
	_tmp45_ = games_cue_sheet_file_node_get_file (_tmp44_);
	_tmp46_ = _tmp45_;
	_tmp47_ = g_file_query_info (_tmp46_, "*", G_FILE_QUERY_INFO_NONE, NULL, &_inner_error_);
	file_info = _tmp47_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (file);
		_g_object_unref0 (track);
		return NULL;
	}
	_tmp48_ = file_info;
	_tmp49_ = g_file_info_get_content_type (_tmp48_);
	if (g_strcmp0 (_tmp49_, GAMES_SEGA_SATURN_PLUGIN_SPECIFIC_MIME_TYPE) != 0) {
		GamesCueSheet* _tmp50_;
		GFile* _tmp51_;
		GFile* _tmp52_;
		gchar* _tmp53_;
		gchar* _tmp54_;
		GError* _tmp55_;
		GError* _tmp56_;
		_tmp50_ = cue;
		_tmp51_ = games_cue_sheet_get_file (_tmp50_);
		_tmp52_ = _tmp51_;
		_tmp53_ = g_file_get_uri (_tmp52_);
		_tmp54_ = _tmp53_;
		_tmp55_ = g_error_new (GAMES_SEGA_SATURN_ERROR, GAMES_SEGA_SATURN_ERROR_INVALID_FILE_TYPE, _ ("The file “%s” doesn’t have a valid Sega Saturn binary file."), _tmp54_);
		_tmp56_ = _tmp55_;
		_g_free0 (_tmp54_);
		_inner_error_ = _tmp56_;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (file_info);
		_g_object_unref0 (file);
		_g_object_unref0 (track);
		return NULL;
	}
	_tmp57_ = file;
	_tmp58_ = games_cue_sheet_file_node_get_file (_tmp57_);
	_tmp59_ = _tmp58_;
	_tmp60_ = _g_object_ref0 (_tmp59_);
	result = _tmp60_;
	_g_object_unref0 (file_info);
	_g_object_unref0 (file);
	_g_object_unref0 (track);
	return result;
}


GamesSegaSaturnPlugin* games_sega_saturn_plugin_construct (GType object_type) {
	GamesSegaSaturnPlugin * self = NULL;
	self = (GamesSegaSaturnPlugin*) g_object_new (object_type, NULL);
	return self;
}


GamesSegaSaturnPlugin* games_sega_saturn_plugin_new (void) {
	return games_sega_saturn_plugin_construct (GAMES_TYPE_SEGA_SATURN_PLUGIN);
}


static void games_sega_saturn_plugin_class_init (GamesSegaSaturnPluginClass * klass) {
	games_sega_saturn_plugin_parent_class = g_type_class_peek_parent (klass);
}


static void games_sega_saturn_plugin_games_plugin_interface_init (GamesPluginIface * iface) {
	games_sega_saturn_plugin_games_plugin_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_game_source = (GamesGameSource* (*) (GamesPlugin *, GError**)) games_sega_saturn_plugin_real_get_game_source;
}


static void games_sega_saturn_plugin_instance_init (GamesSegaSaturnPlugin * self) {
}


GType games_sega_saturn_plugin_get_type (void) {
	return games_sega_saturn_plugin_type_id;
}


GType games_sega_saturn_plugin_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesSegaSaturnPluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_sega_saturn_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesSegaSaturnPlugin), 0, (GInstanceInitFunc) games_sega_saturn_plugin_instance_init, NULL };
	static const GInterfaceInfo games_plugin_info = { (GInterfaceInitFunc) games_sega_saturn_plugin_games_plugin_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_sega_saturn_plugin_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesSegaSaturnPlugin", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_sega_saturn_plugin_type_id, GAMES_TYPE_PLUGIN, &games_plugin_info);
	return games_sega_saturn_plugin_type_id;
}


GType register_games_plugin (GTypeModule* module) {
	GType result = 0UL;
	g_return_val_if_fail (module != NULL, 0UL);
	games_sega_saturn_header_register_type (module);
	games_sega_saturn_plugin_register_type (module);
	games_sega_saturn_uid_register_type (module);
	result = GAMES_TYPE_SEGA_SATURN_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);
}



