/* generic-uri-game-factory.c generated by valac 0.35.5, the Vala compiler
 * generated from generic-uri-game-factory.vala, do not modify */

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

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gtk/gtk.h>


#define GAMES_TYPE_URI_GAME_FACTORY (games_uri_game_factory_get_type ())
#define GAMES_URI_GAME_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_URI_GAME_FACTORY, GamesUriGameFactory))
#define GAMES_IS_URI_GAME_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_URI_GAME_FACTORY))
#define GAMES_URI_GAME_FACTORY_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_URI_GAME_FACTORY, GamesUriGameFactoryIface))

typedef struct _GamesUriGameFactory GamesUriGameFactory;
typedef struct _GamesUriGameFactoryIface GamesUriGameFactoryIface;

#define GAMES_TYPE_GAME (games_game_get_type ())
#define GAMES_GAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAME, GamesGame))
#define GAMES_IS_GAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAME))
#define GAMES_GAME_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_GAME, GamesGameIface))

typedef struct _GamesGame GamesGame;
typedef struct _GamesGameIface GamesGameIface;

#define GAMES_TYPE_ICON (games_icon_get_type ())
#define GAMES_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_ICON, GamesIcon))
#define GAMES_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_ICON))
#define GAMES_ICON_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_ICON, GamesIconIface))

typedef struct _GamesIcon GamesIcon;
typedef struct _GamesIconIface GamesIconIface;

#define GAMES_TYPE_COVER (games_cover_get_type ())
#define GAMES_COVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_COVER, GamesCover))
#define GAMES_IS_COVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_COVER))
#define GAMES_COVER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_COVER, GamesCoverIface))

typedef struct _GamesCover GamesCover;
typedef struct _GamesCoverIface GamesCoverIface;

#define GAMES_TYPE_RUNNER (games_runner_get_type ())
#define GAMES_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_RUNNER, GamesRunner))
#define GAMES_IS_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_RUNNER))
#define GAMES_RUNNER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_RUNNER, GamesRunnerIface))

typedef struct _GamesRunner GamesRunner;
typedef struct _GamesRunnerIface GamesRunnerIface;

#define GAMES_TYPE_MEDIA_SET (games_media_set_get_type ())
#define GAMES_MEDIA_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_MEDIA_SET, GamesMediaSet))
#define GAMES_MEDIA_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_MEDIA_SET, GamesMediaSetClass))
#define GAMES_IS_MEDIA_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_MEDIA_SET))
#define GAMES_IS_MEDIA_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_MEDIA_SET))
#define GAMES_MEDIA_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_MEDIA_SET, GamesMediaSetClass))

typedef struct _GamesMediaSet GamesMediaSet;
typedef struct _GamesMediaSetClass GamesMediaSetClass;

#define GAMES_TYPE_GENERIC_URI_GAME_FACTORY (games_generic_uri_game_factory_get_type ())
#define GAMES_GENERIC_URI_GAME_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GENERIC_URI_GAME_FACTORY, GamesGenericUriGameFactory))
#define GAMES_GENERIC_URI_GAME_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GENERIC_URI_GAME_FACTORY, GamesGenericUriGameFactoryClass))
#define GAMES_IS_GENERIC_URI_GAME_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GENERIC_URI_GAME_FACTORY))
#define GAMES_IS_GENERIC_URI_GAME_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GENERIC_URI_GAME_FACTORY))
#define GAMES_GENERIC_URI_GAME_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GENERIC_URI_GAME_FACTORY, GamesGenericUriGameFactoryClass))

typedef struct _GamesGenericUriGameFactory GamesGenericUriGameFactory;
typedef struct _GamesGenericUriGameFactoryClass GamesGenericUriGameFactoryClass;
typedef struct _GamesGenericUriGameFactoryPrivate GamesGenericUriGameFactoryPrivate;

#define GAMES_TYPE_GAME_URI_ADAPTER (games_game_uri_adapter_get_type ())
#define GAMES_GAME_URI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAME_URI_ADAPTER, GamesGameUriAdapter))
#define GAMES_IS_GAME_URI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAME_URI_ADAPTER))
#define GAMES_GAME_URI_ADAPTER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_GAME_URI_ADAPTER, GamesGameUriAdapterIface))

typedef struct _GamesGameUriAdapter GamesGameUriAdapter;
typedef struct _GamesGameUriAdapterIface GamesGameUriAdapterIface;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _GamesGenericUriGameFactoryForeachGameData GamesGenericUriGameFactoryForeachGameData;

struct _GamesIconIface {
	GTypeInterface parent_iface;
	GIcon* (*get_icon) (GamesIcon* self);
};

struct _GamesCoverIface {
	GTypeInterface parent_iface;
	GIcon* (*get_cover) (GamesCover* self);
};

struct _GamesRunnerIface {
	GTypeInterface parent_iface;
	gboolean (*check_is_valid) (GamesRunner* self, gchar* * error_message, GError** error);
	GtkWidget* (*get_display) (GamesRunner* self);
	void (*start) (GamesRunner* self, GError** error);
	void (*resume) (GamesRunner* self, GError** error);
	void (*pause) (GamesRunner* self);
	void (*stop) (GamesRunner* self);
	gboolean (*get_can_fullscreen) (GamesRunner* self);
	gboolean (*get_can_quit_safely) (GamesRunner* self);
	gboolean (*get_can_resume) (GamesRunner* self);
	GamesMediaSet* (*get_media_set) (GamesRunner* self);
};

struct _GamesGameIface {
	GTypeInterface parent_iface;
	GamesIcon* (*get_icon) (GamesGame* self);
	GamesCover* (*get_cover) (GamesGame* self);
	GamesRunner* (*get_runner) (GamesGame* self, GError** error);
	const gchar* (*get_name) (GamesGame* self);
};

typedef void (*GamesGameCallback) (GamesGame* game, void* user_data);
struct _GamesUriGameFactoryIface {
	GTypeInterface parent_iface;
	gboolean (*is_uri_valid) (GamesUriGameFactory* self, const gchar* uri);
	void (*add_uri) (GamesUriGameFactory* self, const gchar* uri);
	void (*foreach_game) (GamesUriGameFactory* self, GamesGameCallback game_callback, void* game_callback_target, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*foreach_game_finish) (GamesUriGameFactory* self, GAsyncResult* _res_);
};

struct _GamesGenericUriGameFactory {
	GObject parent_instance;
	GamesGenericUriGameFactoryPrivate * priv;
};

struct _GamesGenericUriGameFactoryClass {
	GObjectClass parent_class;
};

struct _GamesGameUriAdapterIface {
	GTypeInterface parent_iface;
	void (*game_for_uri) (GamesGameUriAdapter* self, const gchar* uri, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GamesGame* (*game_for_uri_finish) (GamesGameUriAdapter* self, GAsyncResult* _res_, GError** error);
};

typedef gboolean (*GamesGenericUriGameFactoryUriTest) (const gchar* uri, void* user_data);
struct _GamesGenericUriGameFactoryPrivate {
	GamesGameUriAdapter* game_uri_adapter;
	GamesGenericUriGameFactoryUriTest uri_validity_test;
	gpointer uri_validity_test_target;
	GDestroyNotify uri_validity_test_target_destroy_notify;
	gchar** uris;
	gint uris_length1;
	gint _uris_size_;
};

struct _GamesGenericUriGameFactoryForeachGameData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gboolean _task_complete_;
	GamesGenericUriGameFactory* self;
	GamesGameCallback game_callback;
	gpointer game_callback_target;
	guint handled_uris;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** uri_collection;
	gint uri_collection_length1;
	gint _uri_collection_size_;
	gint uri_it;
	gchar* _tmp1_;
	gchar* uri;
	GFile* file;
	const gchar* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	gboolean _tmp5_;
	GamesGame* game;
	GamesGameUriAdapter* _tmp6_;
	const gchar* _tmp7_;
	GamesGame* _tmp8_;
	GamesGameCallback _tmp9_;
	void* _tmp9__target;
	GamesGame* _tmp10_;
	GError* e;
	GError* _tmp11_;
	const gchar* _tmp12_;
	guint _tmp13_;
	guint _tmp14_;
	GError * _inner_error_;
};


static gpointer games_generic_uri_game_factory_parent_class = NULL;
static GamesUriGameFactoryIface * games_generic_uri_game_factory_games_uri_game_factory_parent_iface = NULL;

GType games_icon_get_type (void) G_GNUC_CONST;
GType games_cover_get_type (void) G_GNUC_CONST;
GType games_media_set_get_type (void) G_GNUC_CONST;
GType games_runner_get_type (void) G_GNUC_CONST;
GType games_game_get_type (void) G_GNUC_CONST;
GType games_uri_game_factory_get_type (void) G_GNUC_CONST;
GType games_generic_uri_game_factory_get_type (void) G_GNUC_CONST;
GType games_game_uri_adapter_get_type (void) G_GNUC_CONST;
#define GAMES_GENERIC_URI_GAME_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_GENERIC_URI_GAME_FACTORY, GamesGenericUriGameFactoryPrivate))
enum  {
	GAMES_GENERIC_URI_GAME_FACTORY_DUMMY_PROPERTY
};
#define GAMES_GENERIC_URI_GAME_FACTORY_HANDLED_URIS_PER_CYCLE ((guint) 5)
GamesGenericUriGameFactory* games_generic_uri_game_factory_new (GamesGameUriAdapter* game_uri_adapter, GamesGenericUriGameFactoryUriTest uri_validity_test, void* uri_validity_test_target, GDestroyNotify uri_validity_test_target_destroy_notify);
GamesGenericUriGameFactory* games_generic_uri_game_factory_construct (GType object_type, GamesGameUriAdapter* game_uri_adapter, GamesGenericUriGameFactoryUriTest uri_validity_test, void* uri_validity_test_target, GDestroyNotify uri_validity_test_target_destroy_notify);
static gboolean games_generic_uri_game_factory_real_is_uri_valid (GamesUriGameFactory* base, const gchar* uri);
static void games_generic_uri_game_factory_real_add_uri (GamesUriGameFactory* base, const gchar* uri);
static void _vala_array_add4 (gchar** * array, int* length, int* size, gchar* value);
static void games_generic_uri_game_factory_real_foreach_game_data_free (gpointer _data);
static void games_generic_uri_game_factory_real_foreach_game (GamesUriGameFactory* base, GamesGameCallback game_callback, void* game_callback_target, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean games_generic_uri_game_factory_real_foreach_game_co (GamesGenericUriGameFactoryForeachGameData* _data_);
void games_game_uri_adapter_game_for_uri (GamesGameUriAdapter* self, const gchar* uri, GAsyncReadyCallback _callback_, gpointer _user_data_);
GamesGame* games_game_uri_adapter_game_for_uri_finish (GamesGameUriAdapter* self, GAsyncResult* _res_, GError** error);
static void games_generic_uri_game_factory_foreach_game_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void games_uri_game_factory_foreach_game (GamesUriGameFactory* self, GamesGameCallback game_callback, void* game_callback_target, GAsyncReadyCallback _callback_, gpointer _user_data_);
void games_uri_game_factory_foreach_game_finish (GamesUriGameFactory* self, GAsyncResult* _res_);
static gboolean _games_generic_uri_game_factory_real_foreach_game_co_gsource_func (gpointer self);
static void games_generic_uri_game_factory_finalize (GObject * obj);
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 gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


GamesGenericUriGameFactory* games_generic_uri_game_factory_construct (GType object_type, GamesGameUriAdapter* game_uri_adapter, GamesGenericUriGameFactoryUriTest uri_validity_test, void* uri_validity_test_target, GDestroyNotify uri_validity_test_target_destroy_notify) {
	GamesGenericUriGameFactory * self = NULL;
	GamesGameUriAdapter* _tmp0_;
	GamesGameUriAdapter* _tmp1_;
	GamesGenericUriGameFactoryUriTest _tmp2_;
	void* _tmp2__target;
	GDestroyNotify _tmp2__target_destroy_notify;
	gchar** _tmp3_;
	g_return_val_if_fail (game_uri_adapter != NULL, NULL);
	self = (GamesGenericUriGameFactory*) g_object_new (object_type, NULL);
	_tmp0_ = game_uri_adapter;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->game_uri_adapter);
	self->priv->game_uri_adapter = _tmp1_;
	_tmp2_ = uri_validity_test;
	_tmp2__target = uri_validity_test_target;
	_tmp2__target_destroy_notify = uri_validity_test_target_destroy_notify;
	uri_validity_test_target_destroy_notify = NULL;
	(self->priv->uri_validity_test_target_destroy_notify == NULL) ? NULL : (self->priv->uri_validity_test_target_destroy_notify (self->priv->uri_validity_test_target), NULL);
	self->priv->uri_validity_test = NULL;
	self->priv->uri_validity_test_target = NULL;
	self->priv->uri_validity_test_target_destroy_notify = NULL;
	self->priv->uri_validity_test = _tmp2_;
	self->priv->uri_validity_test_target = _tmp2__target;
	self->priv->uri_validity_test_target_destroy_notify = _tmp2__target_destroy_notify;
	_tmp3_ = g_new0 (gchar*, 0 + 1);
	self->priv->uris = (_vala_array_free (self->priv->uris, self->priv->uris_length1, (GDestroyNotify) g_free), NULL);
	self->priv->uris = _tmp3_;
	self->priv->uris_length1 = 0;
	self->priv->_uris_size_ = self->priv->uris_length1;
	(uri_validity_test_target_destroy_notify == NULL) ? NULL : (uri_validity_test_target_destroy_notify (uri_validity_test_target), NULL);
	uri_validity_test = NULL;
	uri_validity_test_target = NULL;
	uri_validity_test_target_destroy_notify = NULL;
	return self;
}


GamesGenericUriGameFactory* games_generic_uri_game_factory_new (GamesGameUriAdapter* game_uri_adapter, GamesGenericUriGameFactoryUriTest uri_validity_test, void* uri_validity_test_target, GDestroyNotify uri_validity_test_target_destroy_notify) {
	return games_generic_uri_game_factory_construct (GAMES_TYPE_GENERIC_URI_GAME_FACTORY, game_uri_adapter, uri_validity_test, uri_validity_test_target, uri_validity_test_target_destroy_notify);
}


static gboolean games_generic_uri_game_factory_real_is_uri_valid (GamesUriGameFactory* base, const gchar* uri) {
	GamesGenericUriGameFactory * self;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GamesGenericUriGameFactoryUriTest _tmp1_;
	void* _tmp1__target;
	self = (GamesGenericUriGameFactory*) base;
	g_return_val_if_fail (uri != NULL, FALSE);
	_tmp1_ = self->priv->uri_validity_test;
	_tmp1__target = self->priv->uri_validity_test_target;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GamesGenericUriGameFactoryUriTest _tmp2_;
		void* _tmp2__target;
		const gchar* _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->priv->uri_validity_test;
		_tmp2__target = self->priv->uri_validity_test_target;
		_tmp3_ = uri;
		_tmp4_ = _tmp2_ (_tmp3_, _tmp2__target);
		_tmp0_ = _tmp4_;
	}
	result = _tmp0_;
	return result;
}


static void _vala_array_add4 (gchar** * array, int* length, int* size, gchar* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


static void games_generic_uri_game_factory_real_add_uri (GamesUriGameFactory* base, const gchar* uri) {
	GamesGenericUriGameFactory * self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	self = (GamesGenericUriGameFactory*) base;
	g_return_if_fail (uri != NULL);
	_tmp0_ = self->priv->uris;
	_tmp0__length1 = self->priv->uris_length1;
	_tmp1_ = uri;
	_tmp2_ = g_strdup (_tmp1_);
	_vala_array_add4 (&self->priv->uris, &self->priv->uris_length1, &self->priv->_uris_size_, _tmp2_);
}


static void games_generic_uri_game_factory_real_foreach_game_data_free (gpointer _data) {
	GamesGenericUriGameFactoryForeachGameData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GamesGenericUriGameFactoryForeachGameData, _data_);
}


static void games_generic_uri_game_factory_real_foreach_game (GamesUriGameFactory* base, GamesGameCallback game_callback, void* game_callback_target, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	GamesGenericUriGameFactory * self;
	GamesGenericUriGameFactoryForeachGameData* _data_;
	GamesGenericUriGameFactory* _tmp0_;
	GamesGameCallback _tmp1_;
	void* _tmp1__target;
	self = (GamesGenericUriGameFactory*) base;
	_data_ = g_slice_new0 (GamesGenericUriGameFactoryForeachGameData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, games_generic_uri_game_factory_real_foreach_game_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = game_callback;
	_tmp1__target = game_callback_target;
	_data_->game_callback = _tmp1_;
	_data_->game_callback_target = _tmp1__target;
	games_generic_uri_game_factory_real_foreach_game_co (_data_);
}


static void games_generic_uri_game_factory_real_foreach_game_finish (GamesUriGameFactory* base, GAsyncResult* _res_) {
	GamesGenericUriGameFactoryForeachGameData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	_data_->_task_complete_ = TRUE;
}


static void games_generic_uri_game_factory_foreach_game_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	GamesGenericUriGameFactoryForeachGameData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_data_->_task_complete_ = TRUE;
	games_generic_uri_game_factory_real_foreach_game_co (_data_);
}


static gboolean _games_generic_uri_game_factory_real_foreach_game_co_gsource_func (gpointer self) {
	gboolean result;
	result = games_generic_uri_game_factory_real_foreach_game_co (self);
	return result;
}


static gboolean games_generic_uri_game_factory_real_foreach_game_co (GamesGenericUriGameFactoryForeachGameData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->handled_uris = (guint) 0;
	_data_->_tmp0_ = _data_->self->priv->uris;
	_data_->_tmp0__length1 = _data_->self->priv->uris_length1;
	{
		_data_->uri_collection_length1 = 0;
		_data_->_uri_collection_size_ = 0;
		_data_->uri_collection = _data_->_tmp0_;
		_data_->uri_collection_length1 = _data_->_tmp0__length1;
		for (_data_->uri_it = 0; _data_->uri_it < _data_->_tmp0__length1; _data_->uri_it = _data_->uri_it + 1) {
			_data_->_tmp1_ = g_strdup (_data_->uri_collection[_data_->uri_it]);
			_data_->uri = _data_->_tmp1_;
			{
				_data_->_tmp2_ = _data_->uri;
				_data_->_tmp3_ = g_file_new_for_uri (_data_->_tmp2_);
				_data_->file = _data_->_tmp3_;
				_data_->_tmp4_ = _data_->file;
				_data_->_tmp5_ = g_file_query_exists (_data_->_tmp4_, NULL);
				if (!_data_->_tmp5_) {
					_g_object_unref0 (_data_->file);
					_g_free0 (_data_->uri);
					continue;
				}
				{
					_data_->_tmp6_ = _data_->self->priv->game_uri_adapter;
					_data_->_tmp7_ = _data_->uri;
					_data_->_state_ = 1;
					games_game_uri_adapter_game_for_uri (_data_->_tmp6_, _data_->_tmp7_, games_generic_uri_game_factory_foreach_game_ready, _data_);
					return FALSE;
					_state_1:
					_data_->_tmp8_ = games_game_uri_adapter_game_for_uri_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error_);
					_data_->game = _data_->_tmp8_;
					if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
						goto __catch9_g_error;
					}
					_data_->_tmp9_ = _data_->game_callback;
					_data_->_tmp9__target = _data_->game_callback_target;
					_data_->_tmp10_ = _data_->game;
					_data_->_tmp9_ (_data_->_tmp10_, _data_->_tmp9__target);
					_g_object_unref0 (_data_->game);
				}
				goto __finally9;
				__catch9_g_error:
				{
					_data_->e = _data_->_inner_error_;
					_data_->_inner_error_ = NULL;
					_data_->_tmp11_ = _data_->e;
					_data_->_tmp12_ = _data_->_tmp11_->message;
					g_debug ("generic-uri-game-factory.vala:37: %s", _data_->_tmp12_);
					_g_error_free0 (_data_->e);
					_g_object_unref0 (_data_->file);
					_g_free0 (_data_->uri);
					continue;
				}
				__finally9:
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					_g_object_unref0 (_data_->file);
					_g_free0 (_data_->uri);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
					g_clear_error (&_data_->_inner_error_);
					return FALSE;
				}
				_data_->_tmp13_ = _data_->handled_uris;
				_data_->handled_uris = _data_->_tmp13_ + 1;
				_data_->_tmp14_ = _data_->handled_uris;
				if (_data_->_tmp14_ >= GAMES_GENERIC_URI_GAME_FACTORY_HANDLED_URIS_PER_CYCLE) {
					_data_->handled_uris = (guint) 0;
					g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _games_generic_uri_game_factory_real_foreach_game_co_gsource_func, _data_, NULL);
					_data_->_state_ = 2;
					return FALSE;
					_state_2:
					;
				}
				_g_object_unref0 (_data_->file);
				_g_free0 (_data_->uri);
			}
		}
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (_data_->_task_complete_ != TRUE) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void games_generic_uri_game_factory_class_init (GamesGenericUriGameFactoryClass * klass) {
	games_generic_uri_game_factory_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesGenericUriGameFactoryPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_generic_uri_game_factory_finalize;
}


static void games_generic_uri_game_factory_games_uri_game_factory_interface_init (GamesUriGameFactoryIface * iface) {
	games_generic_uri_game_factory_games_uri_game_factory_parent_iface = g_type_interface_peek_parent (iface);
	iface->is_uri_valid = (gboolean (*) (GamesUriGameFactory *, const gchar*)) games_generic_uri_game_factory_real_is_uri_valid;
	iface->add_uri = (void (*) (GamesUriGameFactory *, const gchar*)) games_generic_uri_game_factory_real_add_uri;
	iface->foreach_game = (void (*) (GamesUriGameFactory *, GamesGameCallback, void*)) games_generic_uri_game_factory_real_foreach_game;
	iface->foreach_game_finish = games_generic_uri_game_factory_real_foreach_game_finish;
}


static void games_generic_uri_game_factory_instance_init (GamesGenericUriGameFactory * self) {
	self->priv = GAMES_GENERIC_URI_GAME_FACTORY_GET_PRIVATE (self);
}


static void games_generic_uri_game_factory_finalize (GObject * obj) {
	GamesGenericUriGameFactory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GENERIC_URI_GAME_FACTORY, GamesGenericUriGameFactory);
	_g_object_unref0 (self->priv->game_uri_adapter);
	(self->priv->uri_validity_test_target_destroy_notify == NULL) ? NULL : (self->priv->uri_validity_test_target_destroy_notify (self->priv->uri_validity_test_target), NULL);
	self->priv->uri_validity_test = NULL;
	self->priv->uri_validity_test_target = NULL;
	self->priv->uri_validity_test_target_destroy_notify = NULL;
	self->priv->uris = (_vala_array_free (self->priv->uris, self->priv->uris_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (games_generic_uri_game_factory_parent_class)->finalize (obj);
}


GType games_generic_uri_game_factory_get_type (void) {
	static volatile gsize games_generic_uri_game_factory_type_id__volatile = 0;
	if (g_once_init_enter (&games_generic_uri_game_factory_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesGenericUriGameFactoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_generic_uri_game_factory_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGenericUriGameFactory), 0, (GInstanceInitFunc) games_generic_uri_game_factory_instance_init, NULL };
		static const GInterfaceInfo games_uri_game_factory_info = { (GInterfaceInitFunc) games_generic_uri_game_factory_games_uri_game_factory_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType games_generic_uri_game_factory_type_id;
		games_generic_uri_game_factory_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesGenericUriGameFactory", &g_define_type_info, 0);
		g_type_add_interface_static (games_generic_uri_game_factory_type_id, GAMES_TYPE_URI_GAME_FACTORY, &games_uri_game_factory_info);
		g_once_init_leave (&games_generic_uri_game_factory_type_id__volatile, games_generic_uri_game_factory_type_id);
	}
	return games_generic_uri_game_factory_type_id__volatile;
}


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);
}



