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

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

#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_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_SYNC_GAME_URI_ADAPTER (games_generic_sync_game_uri_adapter_get_type ())
#define GAMES_GENERIC_SYNC_GAME_URI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GENERIC_SYNC_GAME_URI_ADAPTER, GamesGenericSyncGameUriAdapter))
#define GAMES_GENERIC_SYNC_GAME_URI_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GENERIC_SYNC_GAME_URI_ADAPTER, GamesGenericSyncGameUriAdapterClass))
#define GAMES_IS_GENERIC_SYNC_GAME_URI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GENERIC_SYNC_GAME_URI_ADAPTER))
#define GAMES_IS_GENERIC_SYNC_GAME_URI_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GENERIC_SYNC_GAME_URI_ADAPTER))
#define GAMES_GENERIC_SYNC_GAME_URI_ADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GENERIC_SYNC_GAME_URI_ADAPTER, GamesGenericSyncGameUriAdapterClass))

typedef struct _GamesGenericSyncGameUriAdapter GamesGenericSyncGameUriAdapter;
typedef struct _GamesGenericSyncGameUriAdapterClass GamesGenericSyncGameUriAdapterClass;
typedef struct _GamesGenericSyncGameUriAdapterPrivate GamesGenericSyncGameUriAdapterPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _GamesGenericSyncGameUriAdapterGameForUriData GamesGenericSyncGameUriAdapterGameForUriData;

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, const gchar* uri, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GamesGame* (*game_for_uri_finish) (GamesGameUriAdapter* self, GAsyncResult* _res_, GError** error);
};

struct _GamesGenericSyncGameUriAdapter {
	GObject parent_instance;
	GamesGenericSyncGameUriAdapterPrivate * priv;
};

struct _GamesGenericSyncGameUriAdapterClass {
	GObjectClass parent_class;
};

typedef GamesGame* (*GamesGenericSyncGameUriAdapterGameForUri) (const gchar* uri, void* user_data, GError** error);
struct _GamesGenericSyncGameUriAdapterPrivate {
	GamesGenericSyncGameUriAdapterGameForUri callback;
	gpointer callback_target;
	GDestroyNotify callback_target_destroy_notify;
};

struct _GamesGenericSyncGameUriAdapterGameForUriData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gboolean _task_complete_;
	GamesGenericSyncGameUriAdapter* self;
	gchar* uri;
	GamesGame* result;
	GamesGame* _tmp0_;
	GamesGenericSyncGameUriAdapterGameForUri _tmp1_;
	void* _tmp1__target;
	const gchar* _tmp2_;
	GamesGame* _tmp3_;
	GamesGame* _tmp4_;
	GError * _inner_error_;
};


static gpointer games_generic_sync_game_uri_adapter_parent_class = NULL;
static GamesGameUriAdapterIface * games_generic_sync_game_uri_adapter_games_game_uri_adapter_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_game_uri_adapter_get_type (void) G_GNUC_CONST;
GType games_generic_sync_game_uri_adapter_get_type (void) G_GNUC_CONST;
#define GAMES_GENERIC_SYNC_GAME_URI_ADAPTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_GENERIC_SYNC_GAME_URI_ADAPTER, GamesGenericSyncGameUriAdapterPrivate))
enum  {
	GAMES_GENERIC_SYNC_GAME_URI_ADAPTER_DUMMY_PROPERTY
};
GamesGenericSyncGameUriAdapter* games_generic_sync_game_uri_adapter_new (GamesGenericSyncGameUriAdapterGameForUri callback, void* callback_target, GDestroyNotify callback_target_destroy_notify);
GamesGenericSyncGameUriAdapter* games_generic_sync_game_uri_adapter_construct (GType object_type, GamesGenericSyncGameUriAdapterGameForUri callback, void* callback_target, GDestroyNotify callback_target_destroy_notify);
static void games_generic_sync_game_uri_adapter_real_game_for_uri_data_free (gpointer _data);
static void games_generic_sync_game_uri_adapter_real_game_for_uri (GamesGameUriAdapter* base, const gchar* uri, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean games_generic_sync_game_uri_adapter_real_game_for_uri_co (GamesGenericSyncGameUriAdapterGameForUriData* _data_);
static void games_generic_sync_game_uri_adapter_finalize (GObject * obj);


GamesGenericSyncGameUriAdapter* games_generic_sync_game_uri_adapter_construct (GType object_type, GamesGenericSyncGameUriAdapterGameForUri callback, void* callback_target, GDestroyNotify callback_target_destroy_notify) {
	GamesGenericSyncGameUriAdapter * self = NULL;
	GamesGenericSyncGameUriAdapterGameForUri _tmp0_;
	void* _tmp0__target;
	GDestroyNotify _tmp0__target_destroy_notify;
	self = (GamesGenericSyncGameUriAdapter*) g_object_new (object_type, NULL);
	_tmp0_ = callback;
	_tmp0__target = callback_target;
	_tmp0__target_destroy_notify = callback_target_destroy_notify;
	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;
}


GamesGenericSyncGameUriAdapter* games_generic_sync_game_uri_adapter_new (GamesGenericSyncGameUriAdapterGameForUri callback, void* callback_target, GDestroyNotify callback_target_destroy_notify) {
	return games_generic_sync_game_uri_adapter_construct (GAMES_TYPE_GENERIC_SYNC_GAME_URI_ADAPTER, callback, callback_target, callback_target_destroy_notify);
}


static void games_generic_sync_game_uri_adapter_real_game_for_uri_data_free (gpointer _data) {
	GamesGenericSyncGameUriAdapterGameForUriData* _data_;
	_data_ = _data;
	_g_free0 (_data_->uri);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GamesGenericSyncGameUriAdapterGameForUriData, _data_);
}


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


static void games_generic_sync_game_uri_adapter_real_game_for_uri (GamesGameUriAdapter* base, const gchar* uri, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	GamesGenericSyncGameUriAdapter * self;
	GamesGenericSyncGameUriAdapterGameForUriData* _data_;
	GamesGenericSyncGameUriAdapter* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	self = (GamesGenericSyncGameUriAdapter*) base;
	_data_ = g_slice_new0 (GamesGenericSyncGameUriAdapterGameForUriData);
	_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_sync_game_uri_adapter_real_game_for_uri_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = uri;
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (_data_->uri);
	_data_->uri = _tmp2_;
	games_generic_sync_game_uri_adapter_real_game_for_uri_co (_data_);
}


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


static gboolean games_generic_sync_game_uri_adapter_real_game_for_uri_co (GamesGenericSyncGameUriAdapterGameForUriData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_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_sync_game_uri_adapter_class_init (GamesGenericSyncGameUriAdapterClass * klass) {
	games_generic_sync_game_uri_adapter_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesGenericSyncGameUriAdapterPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_generic_sync_game_uri_adapter_finalize;
}


static void games_generic_sync_game_uri_adapter_games_game_uri_adapter_interface_init (GamesGameUriAdapterIface * iface) {
	games_generic_sync_game_uri_adapter_games_game_uri_adapter_parent_iface = g_type_interface_peek_parent (iface);
	iface->game_for_uri = (GamesGame* (*) (GamesGameUriAdapter *, const gchar*, GError**)) games_generic_sync_game_uri_adapter_real_game_for_uri;
	iface->game_for_uri_finish = games_generic_sync_game_uri_adapter_real_game_for_uri_finish;
}


static void games_generic_sync_game_uri_adapter_instance_init (GamesGenericSyncGameUriAdapter * self) {
	self->priv = GAMES_GENERIC_SYNC_GAME_URI_ADAPTER_GET_PRIVATE (self);
}


static void games_generic_sync_game_uri_adapter_finalize (GObject * obj) {
	GamesGenericSyncGameUriAdapter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GENERIC_SYNC_GAME_URI_ADAPTER, GamesGenericSyncGameUriAdapter);
	(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_sync_game_uri_adapter_parent_class)->finalize (obj);
}


GType games_generic_sync_game_uri_adapter_get_type (void) {
	static volatile gsize games_generic_sync_game_uri_adapter_type_id__volatile = 0;
	if (g_once_init_enter (&games_generic_sync_game_uri_adapter_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesGenericSyncGameUriAdapterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_generic_sync_game_uri_adapter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGenericSyncGameUriAdapter), 0, (GInstanceInitFunc) games_generic_sync_game_uri_adapter_instance_init, NULL };
		static const GInterfaceInfo games_game_uri_adapter_info = { (GInterfaceInitFunc) games_generic_sync_game_uri_adapter_games_game_uri_adapter_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType games_generic_sync_game_uri_adapter_type_id;
		games_generic_sync_game_uri_adapter_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesGenericSyncGameUriAdapter", &g_define_type_info, 0);
		g_type_add_interface_static (games_generic_sync_game_uri_adapter_type_id, GAMES_TYPE_GAME_URI_ADAPTER, &games_game_uri_adapter_info);
		g_once_init_leave (&games_generic_sync_game_uri_adapter_type_id__volatile, games_generic_sync_game_uri_adapter_type_id);
	}
	return games_generic_sync_game_uri_adapter_type_id__volatile;
}



