/* love-plugin.c generated by valac 0.36.9, the Vala compiler
 * generated from love-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_LOVE_PLUGIN (games_love_plugin_get_type ())
#define GAMES_LOVE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LOVE_PLUGIN, GamesLovePlugin))
#define GAMES_LOVE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LOVE_PLUGIN, GamesLovePluginClass))
#define GAMES_IS_LOVE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LOVE_PLUGIN))
#define GAMES_IS_LOVE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LOVE_PLUGIN))
#define GAMES_LOVE_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LOVE_PLUGIN, GamesLovePluginClass))

typedef struct _GamesLovePlugin GamesLovePlugin;
typedef struct _GamesLovePluginClass GamesLovePluginClass;
typedef struct _GamesLovePluginPrivate GamesLovePluginPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GAMES_TYPE_LOVE_PACKAGE (games_love_package_get_type ())
#define GAMES_LOVE_PACKAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackage))
#define GAMES_LOVE_PACKAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackageClass))
#define GAMES_IS_LOVE_PACKAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LOVE_PACKAGE))
#define GAMES_IS_LOVE_PACKAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LOVE_PACKAGE))
#define GAMES_LOVE_PACKAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackageClass))

typedef struct _GamesLovePackage GamesLovePackage;
typedef struct _GamesLovePackageClass GamesLovePackageClass;

#define GAMES_TYPE_LOVE_TITLE (games_love_title_get_type ())
#define GAMES_LOVE_TITLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LOVE_TITLE, GamesLoveTitle))
#define GAMES_LOVE_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LOVE_TITLE, GamesLoveTitleClass))
#define GAMES_IS_LOVE_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LOVE_TITLE))
#define GAMES_IS_LOVE_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LOVE_TITLE))
#define GAMES_LOVE_TITLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LOVE_TITLE, GamesLoveTitleClass))

typedef struct _GamesLoveTitle GamesLoveTitle;
typedef struct _GamesLoveTitleClass GamesLoveTitleClass;

#define GAMES_TYPE_LOVE_ICON (games_love_icon_get_type ())
#define GAMES_LOVE_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LOVE_ICON, GamesLoveIcon))
#define GAMES_LOVE_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LOVE_ICON, GamesLoveIconClass))
#define GAMES_IS_LOVE_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LOVE_ICON))
#define GAMES_IS_LOVE_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LOVE_ICON))
#define GAMES_LOVE_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LOVE_ICON, GamesLoveIconClass))

typedef struct _GamesLoveIcon GamesLoveIcon;
typedef struct _GamesLoveIconClass GamesLoveIconClass;

struct _GamesLovePlugin {
	GObject parent_instance;
	GamesLovePluginPrivate * priv;
};

struct _GamesLovePluginClass {
	GObjectClass parent_class;
};


static gpointer games_love_plugin_parent_class = NULL;
static GamesPluginIface * games_love_plugin_games_plugin_parent_iface = NULL;
static GType games_love_plugin_type_id = 0;

GType games_love_plugin_get_type (void) G_GNUC_CONST;
enum  {
	GAMES_LOVE_PLUGIN_0_PROPERTY
};
#define GAMES_LOVE_PLUGIN_MIME_TYPE "application/x-love-game"
static gchar** games_love_plugin_real_get_mime_types (GamesPlugin* base, int* result_length1);
static GamesUriGameFactory** games_love_plugin_real_get_uri_game_factories (GamesPlugin* base, int* result_length1);
static GamesGame* games_love_plugin_game_for_uri (GamesUri* uri, GError** error);
static GamesGame* _games_love_plugin_game_for_uri_games_generic_game_uri_adapter_game_for_uri (GamesUri* uri, gpointer self, GError** error);
GType games_love_package_get_type (void) G_GNUC_CONST;
GamesLovePackage* games_love_package_new (GamesUri* uri, GError** error);
GamesLovePackage* games_love_package_construct (GType object_type, GamesUri* uri, GError** error);
GType games_love_title_get_type (void) G_GNUC_CONST;
GamesLoveTitle* games_love_title_new (GamesLovePackage* package);
GamesLoveTitle* games_love_title_construct (GType object_type, GamesLovePackage* package);
GType games_love_icon_get_type (void) G_GNUC_CONST;
GamesLoveIcon* games_love_icon_new (GamesLovePackage* package);
GamesLoveIcon* games_love_icon_construct (GType object_type, GamesLovePackage* package);
GamesLovePlugin* games_love_plugin_new (void);
GamesLovePlugin* games_love_plugin_construct (GType object_type);
GType register_games_plugin (GTypeModule* module);
GType games_love_icon_register_type (GTypeModule * module);
GType games_love_package_register_type (GTypeModule * module);
GType games_love_plugin_register_type (GTypeModule * module);
GType games_love_title_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_love_plugin_real_get_mime_types (GamesPlugin* base, int* result_length1) {
	GamesLovePlugin * self;
	gchar** result = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	self = (GamesLovePlugin*) base;
	_tmp0_ = g_strdup (GAMES_LOVE_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_love_plugin_game_for_uri_games_generic_game_uri_adapter_game_for_uri (GamesUri* uri, gpointer self, GError** error) {
	GamesGame* result;
	result = games_love_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_love_plugin_real_get_uri_game_factories (GamesPlugin* base, int* result_length1) {
	GamesLovePlugin * 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 = (GamesLovePlugin*) base;
	_tmp0_ = games_generic_game_uri_adapter_new (_games_love_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_LOVE_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_love_plugin_game_for_uri (GamesUri* uri, GError** error) {
	GamesGame* result = NULL;
	GamesLovePackage* package = NULL;
	GamesUri* _tmp0_;
	GamesLovePackage* _tmp1_;
	GamesLoveTitle* title = NULL;
	GamesLoveTitle* _tmp2_;
	GamesLoveIcon* icon = NULL;
	GamesLoveIcon* _tmp3_;
	GamesLocalCover* cover = NULL;
	GamesUri* _tmp4_;
	GamesLocalCover* _tmp5_;
	gchar** args = NULL;
	gchar* _tmp6_;
	GamesUri* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_;
	gint args_length1;
	gint _args_size_;
	GamesCommandRunner* runner = NULL;
	gchar** _tmp10_;
	gint _tmp10__length1;
	GamesCommandRunner* _tmp11_;
	GamesLoveTitle* _tmp12_;
	GamesLoveIcon* _tmp13_;
	GamesLocalCover* _tmp14_;
	GamesCommandRunner* _tmp15_;
	GamesGenericGame* _tmp16_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	_tmp1_ = games_love_package_new (_tmp0_, &_inner_error_);
	package = _tmp1_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp2_ = games_love_title_new (package);
	title = _tmp2_;
	_tmp3_ = games_love_icon_new (package);
	icon = _tmp3_;
	_tmp4_ = uri;
	_tmp5_ = games_local_cover_new (_tmp4_);
	cover = _tmp5_;
	_tmp6_ = g_strdup ("love");
	_tmp7_ = uri;
	_tmp8_ = games_uri_to_string (_tmp7_);
	_tmp9_ = g_new0 (gchar*, 2 + 1);
	_tmp9_[0] = _tmp6_;
	_tmp9_[1] = _tmp8_;
	args = _tmp9_;
	args_length1 = 2;
	_args_size_ = args_length1;
	_tmp10_ = args;
	_tmp10__length1 = args_length1;
	_tmp11_ = games_command_runner_new (_tmp10_, _tmp10__length1, TRUE);
	runner = _tmp11_;
	_tmp12_ = title;
	_tmp13_ = icon;
	_tmp14_ = cover;
	_tmp15_ = runner;
	_tmp16_ = games_generic_game_new ((GamesTitle*) _tmp12_, (GamesIcon*) _tmp13_, (GamesCover*) _tmp14_, (GamesRunner*) _tmp15_);
	result = (GamesGame*) _tmp16_;
	_g_object_unref0 (runner);
	args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (cover);
	_g_object_unref0 (icon);
	_g_object_unref0 (title);
	_g_object_unref0 (package);
	return result;
}


GamesLovePlugin* games_love_plugin_construct (GType object_type) {
	GamesLovePlugin * self = NULL;
	self = (GamesLovePlugin*) g_object_new (object_type, NULL);
	return self;
}


GamesLovePlugin* games_love_plugin_new (void) {
	return games_love_plugin_construct (GAMES_TYPE_LOVE_PLUGIN);
}


static void games_love_plugin_class_init (GamesLovePluginClass * klass) {
	games_love_plugin_parent_class = g_type_class_peek_parent (klass);
}


static void games_love_plugin_games_plugin_interface_init (GamesPluginIface * iface) {
	games_love_plugin_games_plugin_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_mime_types = (gchar** (*) (GamesPlugin *, int*)) games_love_plugin_real_get_mime_types;
	iface->get_uri_game_factories = (GamesUriGameFactory** (*) (GamesPlugin *, int*)) games_love_plugin_real_get_uri_game_factories;
}


static void games_love_plugin_instance_init (GamesLovePlugin * self) {
}


GType games_love_plugin_get_type (void) {
	return games_love_plugin_type_id;
}


GType games_love_plugin_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesLovePluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_love_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesLovePlugin), 0, (GInstanceInitFunc) games_love_plugin_instance_init, NULL };
	static const GInterfaceInfo games_plugin_info = { (GInterfaceInitFunc) games_love_plugin_games_plugin_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_love_plugin_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesLovePlugin", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_love_plugin_type_id, GAMES_TYPE_PLUGIN, &games_plugin_info);
	return games_love_plugin_type_id;
}


GType register_games_plugin (GTypeModule* module) {
	GType result = 0UL;
	g_return_val_if_fail (module != NULL, 0UL);
	games_love_icon_register_type (module);
	games_love_package_register_type (module);
	games_love_plugin_register_type (module);
	games_love_title_register_type (module);
	result = GAMES_TYPE_LOVE_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);
}



