/* generic-game-uri-adapter.c generated by valac 0.36.12.13-3ae08, the Vala compiler
 * generated from generic-game-uri-adapter.vala, do not modify */

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

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


#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 GAMES_TYPE_URI (games_uri_get_type ())
#define GAMES_URI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_URI, GamesUri))
#define GAMES_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_URI, GamesUriClass))
#define GAMES_IS_URI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_URI))
#define GAMES_IS_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_URI))
#define GAMES_URI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_URI, GamesUriClass))

typedef struct _GamesUri GamesUri;
typedef struct _GamesUriClass GamesUriClass;

#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_GAME_URI_ADAPTER (games_generic_game_uri_adapter_get_type ())
#define GAMES_GENERIC_GAME_URI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GENERIC_GAME_URI_ADAPTER, GamesGenericGameUriAdapter))
#define GAMES_GENERIC_GAME_URI_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GENERIC_GAME_URI_ADAPTER, GamesGenericGameUriAdapterClass))
#define GAMES_IS_GENERIC_GAME_URI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GENERIC_GAME_URI_ADAPTER))
#define GAMES_IS_GENERIC_GAME_URI_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GENERIC_GAME_URI_ADAPTER))
#define GAMES_GENERIC_GAME_URI_ADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GENERIC_GAME_URI_ADAPTER, GamesGenericGameUriAdapterClass))

typedef struct _GamesGenericGameUriAdapter GamesGenericGameUriAdapter;
typedef struct _GamesGenericGameUriAdapterClass GamesGenericGameUriAdapterClass;
typedef struct _GamesGenericGameUriAdapterPrivate GamesGenericGameUriAdapterPrivate;
#define _games_uri_unref0(var) ((var == NULL) ? NULL : (var = (games_uri_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _GamesGenericGameUriAdapterGameForUriData GamesGenericGameUriAdapterGameForUriData;

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

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

struct _GamesGenericGameUriAdapter {
	GObject parent_instance;
	GamesGenericGameUriAdapterPrivate * priv;
};

struct _GamesGenericGameUriAdapterClass {
	GObjectClass parent_class;
};

typedef GamesGame* (*GamesGenericGameUriAdapterGameForUri) (GamesUri* uri, void* user_data, GError** error);
struct _GamesGenericGameUriAdapterPrivate {
	GamesGenericGameUriAdapterGameForUri callback;
	gpointer callback_target;
	GDestroyNotify callback_target_destroy_notify;
};

struct _GamesGenericGameUriAdapterGameForUriData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GAsyncReadyCallback _callback_;
	gboolean _task_complete_;
	GamesGenericGameUriAdapter* self;
	GamesUri* uri;
	GamesGame* result;
	GamesGame* _tmp0_;
	GamesGenericGameUriAdapterGameForUri _tmp1_;
	void* _tmp1__target;
	GamesUri* _tmp2_;
	GamesGame* _tmp3_;
	GamesGame* _tmp4_;
	GError * _inner_error_;
};


static gpointer games_generic_game_uri_adapter_parent_class = NULL;
static GamesGameUriAdapterIface * games_generic_game_uri_adapter_games_game_uri_adapter_parent_iface = NULL;

gpointer games_uri_ref (gpointer instance);
void games_uri_unref (gpointer instance);
GParamSpec* games_param_spec_uri (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void games_value_set_uri (GValue* value, gpointer v_object);
void games_value_take_uri (GValue* value, gpointer v_object);
gpointer games_value_get_uri (const GValue* value);
GType games_uri_get_type (void) G_GNUC_CONST;
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_game_uri_adapter_get_type (void) G_GNUC_CONST;
GType games_generic_game_uri_adapter_get_type (void) G_GNUC_CONST;
#define GAMES_GENERIC_GAME_URI_ADAPTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_GENERIC_GAME_URI_ADAPTER, GamesGenericGameUriAdapterPrivate))
enum  {
	GAMES_GENERIC_GAME_URI_ADAPTER_0_PROPERTY
};
GamesGenericGameUriAdapter* games_generic_game_uri_adapter_new (GamesGenericGameUriAdapterGameForUri callback, void* callback_target, GDestroyNotify callback_target_destroy_notify);
GamesGenericGameUriAdapter* games_generic_game_uri_adapter_construct (GType object_type, GamesGenericGameUriAdapterGameForUri callback, void* callback_target, GDestroyNotify callback_target_destroy_notify);
static void games_generic_game_uri_adapter_real_game_for_uri_data_free (gpointer _data);
static void games_generic_game_uri_adapter_real_game_for_uri_async_ready_wrapper (GObject *source_object, GAsyncResult *res, void *user_data);
static void games_generic_game_uri_adapter_real_game_for_uri (GamesGameUriAdapter* base, GamesUri* uri, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean games_generic_game_uri_adapter_real_game_for_uri_co (GamesGenericGameUriAdapterGameForUriData* _data_);
void games_game_uri_adapter_game_for_uri (GamesGameUriAdapter* self, GamesUri* uri, GAsyncReadyCallback _callback_, gpointer _user_data_);
GamesGame* games_game_uri_adapter_game_for_uri_finish (GamesGameUriAdapter* self, GAsyncResult* _res_, GError** error);
static gboolean _games_generic_game_uri_adapter_real_game_for_uri_co_gsource_func (gpointer self);
static void games_generic_game_uri_adapter_finalize (GObject * obj);


GamesGenericGameUriAdapter* games_generic_game_uri_adapter_construct (GType object_type, GamesGenericGameUriAdapterGameForUri callback, void* callback_target, GDestroyNotify callback_target_destroy_notify) {
	GamesGenericGameUriAdapter * self = NULL;
	GamesGenericGameUriAdapterGameForUri _tmp0_;
	void* _tmp0__target;
	GDestroyNotify _tmp0__target_destroy_notify;
	self = (GamesGenericGameUriAdapter*) g_object_new (object_type, NULL);
	_tmp0_ = callback;
	_tmp0__target = callback_target;
	_tmp0__target_destroy_notify = callback_target_destroy_notify;
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	(self->priv->callback_target_destroy_notify == NULL) ? NULL : (self->priv->callback_target_destroy_notify (self->priv->callback_target), NULL);
	self->priv->callback = NULL;
	self->priv->callback_target = NULL;
	self->priv->callback_target_destroy_notify = NULL;
	self->priv->callback = _tmp0_;
	self->priv->callback_target = _tmp0__target;
	self->priv->callback_target_destroy_notify = _tmp0__target_destroy_notify;
	(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	return self;
}


GamesGenericGameUriAdapter* games_generic_game_uri_adapter_new (GamesGenericGameUriAdapterGameForUri callback, void* callback_target, GDestroyNotify callback_target_destroy_notify) {
	return games_generic_game_uri_adapter_construct (GAMES_TYPE_GENERIC_GAME_URI_ADAPTER, callback, callback_target, callback_target_destroy_notify);
}


static void games_generic_game_uri_adapter_real_game_for_uri_data_free (gpointer _data) {
	GamesGenericGameUriAdapterGameForUriData* _data_;
	_data_ = _data;
	_games_uri_unref0 (_data_->uri);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GamesGenericGameUriAdapterGameForUriData, _data_);
}


static void games_generic_game_uri_adapter_real_game_for_uri_async_ready_wrapper (GObject *source_object, GAsyncResult *res, void *user_data) {
	GamesGenericGameUriAdapterGameForUriData* _task_data_;
	_task_data_ = g_task_get_task_data (G_TASK (res));
	if (_task_data_->_callback_ != NULL) {
		_task_data_->_callback_ (source_object, res, user_data);
	}
	_task_data_->_task_complete_ = TRUE;
}


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


static gpointer _games_uri_ref0 (gpointer self) {
	return self ? games_uri_ref (self) : NULL;
}


static void games_generic_game_uri_adapter_real_game_for_uri (GamesGameUriAdapter* base, GamesUri* uri, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	GamesGenericGameUriAdapter * self;
	GamesGenericGameUriAdapterGameForUriData* _data_;
	GamesGenericGameUriAdapter* _tmp0_;
	GamesUri* _tmp1_;
	GamesUri* _tmp2_;
	self = (GamesGenericGameUriAdapter*) base;
	_data_ = g_slice_new0 (GamesGenericGameUriAdapterGameForUriData);
	_data_->_callback_ = _callback_;
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, games_generic_game_uri_adapter_real_game_for_uri_async_ready_wrapper, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, games_generic_game_uri_adapter_real_game_for_uri_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = uri;
	_tmp2_ = _games_uri_ref0 (_tmp1_);
	_games_uri_unref0 (_data_->uri);
	_data_->uri = _tmp2_;
	games_generic_game_uri_adapter_real_game_for_uri_co (_data_);
}


static GamesGame* games_generic_game_uri_adapter_real_game_for_uri_finish (GamesGameUriAdapter* base, GAsyncResult* _res_, GError** error) {
	GamesGame* result;
	GamesGenericGameUriAdapterGameForUriData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}


static gboolean _games_generic_game_uri_adapter_real_game_for_uri_co_gsource_func (gpointer self) {
	gboolean result;
	result = games_generic_game_uri_adapter_real_game_for_uri_co (self);
	return result;
}


static gboolean games_generic_game_uri_adapter_real_game_for_uri_co (GamesGenericGameUriAdapterGameForUriData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _games_generic_game_uri_adapter_real_game_for_uri_co_gsource_func, _data_, NULL);
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	_data_->_tmp1_ = _data_->self->priv->callback;
	_data_->_tmp1__target = _data_->self->priv->callback_target;
	_data_->_tmp2_ = _data_->uri;
	_data_->_tmp3_ = _data_->_tmp1_ (_data_->_tmp2_, _data_->_tmp1__target, &_data_->_inner_error_);
	_data_->_tmp0_ = _data_->_tmp3_;
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_data_->result = _data_->_tmp4_;
	_g_object_unref0 (_data_->_tmp0_);
	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_game_uri_adapter_class_init (GamesGenericGameUriAdapterClass * klass) {
	games_generic_game_uri_adapter_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesGenericGameUriAdapterPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_generic_game_uri_adapter_finalize;
}


static void games_generic_game_uri_adapter_games_game_uri_adapter_interface_init (GamesGameUriAdapterIface * iface) {
	games_generic_game_uri_adapter_games_game_uri_adapter_parent_iface = g_type_interface_peek_parent (iface);
	iface->game_for_uri = (void (*) (GamesGameUriAdapter *, GamesUri*, GAsyncReadyCallback, gpointer)) games_generic_game_uri_adapter_real_game_for_uri;
	iface->game_for_uri_finish = (GamesGame* (*) (GamesGameUriAdapter *, GAsyncResult*, GError**)) games_generic_game_uri_adapter_real_game_for_uri_finish;
}


static void games_generic_game_uri_adapter_instance_init (GamesGenericGameUriAdapter * self) {
	self->priv = GAMES_GENERIC_GAME_URI_ADAPTER_GET_PRIVATE (self);
}


static void games_generic_game_uri_adapter_finalize (GObject * obj) {
	GamesGenericGameUriAdapter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GENERIC_GAME_URI_ADAPTER, GamesGenericGameUriAdapter);
	(self->priv->callback_target_destroy_notify == NULL) ? NULL : (self->priv->callback_target_destroy_notify (self->priv->callback_target), NULL);
	self->priv->callback = NULL;
	self->priv->callback_target = NULL;
	self->priv->callback_target_destroy_notify = NULL;
	G_OBJECT_CLASS (games_generic_game_uri_adapter_parent_class)->finalize (obj);
}


GType games_generic_game_uri_adapter_get_type (void) {
	static volatile gsize games_generic_game_uri_adapter_type_id__volatile = 0;
	if (g_once_init_enter (&games_generic_game_uri_adapter_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesGenericGameUriAdapterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_generic_game_uri_adapter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGenericGameUriAdapter), 0, (GInstanceInitFunc) games_generic_game_uri_adapter_instance_init, NULL };
		static const GInterfaceInfo games_game_uri_adapter_info = { (GInterfaceInitFunc) games_generic_game_uri_adapter_games_game_uri_adapter_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType games_generic_game_uri_adapter_type_id;
		games_generic_game_uri_adapter_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesGenericGameUriAdapter", &g_define_type_info, 0);
		g_type_add_interface_static (games_generic_game_uri_adapter_type_id, GAMES_TYPE_GAME_URI_ADAPTER, &games_game_uri_adapter_info);
		g_once_init_leave (&games_generic_game_uri_adapter_type_id__volatile, games_generic_game_uri_adapter_type_id);
	}
	return games_generic_game_uri_adapter_type_id__volatile;
}



