/* game-cube-uid.c generated by valac 0.35.5, the Vala compiler
 * generated from game-cube-uid.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>


#define GAMES_TYPE_GAME_CUBE_UID (games_game_cube_uid_get_type ())
#define GAMES_GAME_CUBE_UID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAME_CUBE_UID, GamesGameCubeUid))
#define GAMES_GAME_CUBE_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAME_CUBE_UID, GamesGameCubeUidClass))
#define GAMES_IS_GAME_CUBE_UID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAME_CUBE_UID))
#define GAMES_IS_GAME_CUBE_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAME_CUBE_UID))
#define GAMES_GAME_CUBE_UID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAME_CUBE_UID, GamesGameCubeUidClass))

typedef struct _GamesGameCubeUid GamesGameCubeUid;
typedef struct _GamesGameCubeUidClass GamesGameCubeUidClass;
typedef struct _GamesGameCubeUidPrivate GamesGameCubeUidPrivate;

#define GAMES_TYPE_GAME_CUBE_HEADER (games_game_cube_header_get_type ())
#define GAMES_GAME_CUBE_HEADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_GAME_CUBE_HEADER, GamesGameCubeHeader))
#define GAMES_GAME_CUBE_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_GAME_CUBE_HEADER, GamesGameCubeHeaderClass))
#define GAMES_IS_GAME_CUBE_HEADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_GAME_CUBE_HEADER))
#define GAMES_IS_GAME_CUBE_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_GAME_CUBE_HEADER))
#define GAMES_GAME_CUBE_HEADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_GAME_CUBE_HEADER, GamesGameCubeHeaderClass))

typedef struct _GamesGameCubeHeader GamesGameCubeHeader;
typedef struct _GamesGameCubeHeaderClass GamesGameCubeHeaderClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesGameCubeUid {
	GObject parent_instance;
	GamesGameCubeUidPrivate * priv;
};

struct _GamesGameCubeUidClass {
	GObjectClass parent_class;
};

struct _GamesGameCubeUidPrivate {
	GamesGameCubeHeader* header;
	gchar* uid;
};


static gpointer games_game_cube_uid_parent_class = NULL;
static GamesUidIface * games_game_cube_uid_games_uid_parent_iface = NULL;
static GType games_game_cube_uid_type_id = 0;

GType games_game_cube_uid_get_type (void) G_GNUC_CONST;
GType games_game_cube_header_get_type (void) G_GNUC_CONST;
#define GAMES_GAME_CUBE_UID_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_GAME_CUBE_UID, GamesGameCubeUidPrivate))
enum  {
	GAMES_GAME_CUBE_UID_DUMMY_PROPERTY
};
GamesGameCubeUid* games_game_cube_uid_new (GamesGameCubeHeader* header);
GamesGameCubeUid* games_game_cube_uid_construct (GType object_type, GamesGameCubeHeader* header);
static gchar* games_game_cube_uid_real_get_uid (GamesUid* base, GError** error);
gchar* games_game_cube_header_get_game_id (GamesGameCubeHeader* self, GError** error);
static void games_game_cube_uid_finalize (GObject * obj);


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


GamesGameCubeUid* games_game_cube_uid_construct (GType object_type, GamesGameCubeHeader* header) {
	GamesGameCubeUid * self = NULL;
	GamesGameCubeHeader* _tmp0_;
	GamesGameCubeHeader* _tmp1_;
	g_return_val_if_fail (header != NULL, NULL);
	self = (GamesGameCubeUid*) g_object_new (object_type, NULL);
	_tmp0_ = header;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->header);
	self->priv->header = _tmp1_;
	return self;
}


GamesGameCubeUid* games_game_cube_uid_new (GamesGameCubeHeader* header) {
	return games_game_cube_uid_construct (GAMES_TYPE_GAME_CUBE_UID, header);
}


static const gchar* string_to_string (const gchar* self) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}


static gchar* games_game_cube_uid_real_get_uid (GamesUid* base, GError** error) {
	GamesGameCubeUid * self;
	gchar* result = NULL;
	const gchar* _tmp0_;
	gchar* game_id;
	GamesGameCubeHeader* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	GError * _inner_error_ = NULL;
	self = (GamesGameCubeUid*) base;
	_tmp0_ = self->priv->uid;
	if (_tmp0_ != NULL) {
		const gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = self->priv->uid;
		_tmp2_ = g_strdup (_tmp1_);
		result = _tmp2_;
		return result;
	}
	_tmp3_ = self->priv->header;
	_tmp4_ = games_game_cube_header_get_game_id (_tmp3_, &_inner_error_);
	game_id = _tmp4_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp5_ = game_id;
	_tmp6_ = string_to_string (_tmp5_);
	_tmp7_ = g_strconcat ("game-cube-", _tmp6_, NULL);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_utf8_strdown (_tmp8_, (gssize) -1);
	_g_free0 (self->priv->uid);
	self->priv->uid = _tmp9_;
	_g_free0 (_tmp8_);
	_tmp10_ = self->priv->uid;
	_tmp11_ = g_strdup (_tmp10_);
	result = _tmp11_;
	_g_free0 (game_id);
	return result;
}


static void games_game_cube_uid_class_init (GamesGameCubeUidClass * klass) {
	games_game_cube_uid_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesGameCubeUidPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_game_cube_uid_finalize;
}


static void games_game_cube_uid_games_uid_interface_init (GamesUidIface * iface) {
	games_game_cube_uid_games_uid_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_uid = (gchar* (*) (GamesUid *, GError**)) games_game_cube_uid_real_get_uid;
}


static void games_game_cube_uid_instance_init (GamesGameCubeUid * self) {
	self->priv = GAMES_GAME_CUBE_UID_GET_PRIVATE (self);
}


static void games_game_cube_uid_finalize (GObject * obj) {
	GamesGameCubeUid * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GAME_CUBE_UID, GamesGameCubeUid);
	_g_object_unref0 (self->priv->header);
	_g_free0 (self->priv->uid);
	G_OBJECT_CLASS (games_game_cube_uid_parent_class)->finalize (obj);
}


GType games_game_cube_uid_get_type (void) {
	return games_game_cube_uid_type_id;
}


GType games_game_cube_uid_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesGameCubeUidClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_game_cube_uid_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGameCubeUid), 0, (GInstanceInitFunc) games_game_cube_uid_instance_init, NULL };
	static const GInterfaceInfo games_uid_info = { (GInterfaceInitFunc) games_game_cube_uid_games_uid_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_game_cube_uid_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesGameCubeUid", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_game_cube_uid_type_id, GAMES_TYPE_UID, &games_uid_info);
	return games_game_cube_uid_type_id;
}



