/* playstation-uid.c generated by valac 0.35.5, the Vala compiler
 * generated from playstation-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_PLAY_STATION_UID (games_play_station_uid_get_type ())
#define GAMES_PLAY_STATION_UID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLAY_STATION_UID, GamesPlayStationUid))
#define GAMES_PLAY_STATION_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLAY_STATION_UID, GamesPlayStationUidClass))
#define GAMES_IS_PLAY_STATION_UID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLAY_STATION_UID))
#define GAMES_IS_PLAY_STATION_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLAY_STATION_UID))
#define GAMES_PLAY_STATION_UID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLAY_STATION_UID, GamesPlayStationUidClass))

typedef struct _GamesPlayStationUid GamesPlayStationUid;
typedef struct _GamesPlayStationUidClass GamesPlayStationUidClass;
typedef struct _GamesPlayStationUidPrivate GamesPlayStationUidPrivate;

#define GAMES_TYPE_PLAY_STATION_HEADER (games_play_station_header_get_type ())
#define GAMES_PLAY_STATION_HEADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLAY_STATION_HEADER, GamesPlayStationHeader))
#define GAMES_PLAY_STATION_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLAY_STATION_HEADER, GamesPlayStationHeaderClass))
#define GAMES_IS_PLAY_STATION_HEADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLAY_STATION_HEADER))
#define GAMES_IS_PLAY_STATION_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLAY_STATION_HEADER))
#define GAMES_PLAY_STATION_HEADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLAY_STATION_HEADER, GamesPlayStationHeaderClass))

typedef struct _GamesPlayStationHeader GamesPlayStationHeader;
typedef struct _GamesPlayStationHeaderClass GamesPlayStationHeaderClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesPlayStationUid {
	GObject parent_instance;
	GamesPlayStationUidPrivate * priv;
};

struct _GamesPlayStationUidClass {
	GObjectClass parent_class;
};

struct _GamesPlayStationUidPrivate {
	GamesPlayStationHeader* header;
	gchar* uid;
};


static gpointer games_play_station_uid_parent_class = NULL;
static GamesUidIface * games_play_station_uid_games_uid_parent_iface = NULL;
static GType games_play_station_uid_type_id = 0;

GType games_play_station_uid_get_type (void) G_GNUC_CONST;
GType games_play_station_header_get_type (void) G_GNUC_CONST;
#define GAMES_PLAY_STATION_UID_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_PLAY_STATION_UID, GamesPlayStationUidPrivate))
enum  {
	GAMES_PLAY_STATION_UID_DUMMY_PROPERTY
};
GamesPlayStationUid* games_play_station_uid_new (GamesPlayStationHeader* header);
GamesPlayStationUid* games_play_station_uid_construct (GType object_type, GamesPlayStationHeader* header);
static gchar* games_play_station_uid_real_get_uid (GamesUid* base, GError** error);
const gchar* games_play_station_header_get_disc_id (GamesPlayStationHeader* self);
static void games_play_station_uid_finalize (GObject * obj);


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


GamesPlayStationUid* games_play_station_uid_construct (GType object_type, GamesPlayStationHeader* header) {
	GamesPlayStationUid * self = NULL;
	GamesPlayStationHeader* _tmp0_;
	GamesPlayStationHeader* _tmp1_;
	g_return_val_if_fail (header != NULL, NULL);
	self = (GamesPlayStationUid*) 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;
}


GamesPlayStationUid* games_play_station_uid_new (GamesPlayStationHeader* header) {
	return games_play_station_uid_construct (GAMES_TYPE_PLAY_STATION_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_play_station_uid_real_get_uid (GamesUid* base, GError** error) {
	GamesPlayStationUid * self;
	gchar* result = NULL;
	const gchar* _tmp0_;
	gchar* disc_id;
	GamesPlayStationHeader* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	self = (GamesPlayStationUid*) 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_play_station_header_get_disc_id (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strdup (_tmp5_);
	disc_id = _tmp6_;
	_tmp7_ = disc_id;
	_tmp8_ = string_to_string (_tmp7_);
	_tmp9_ = g_strconcat ("playstation-", _tmp8_, NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_utf8_strdown (_tmp10_, (gssize) -1);
	_g_free0 (self->priv->uid);
	self->priv->uid = _tmp11_;
	_g_free0 (_tmp10_);
	_tmp12_ = self->priv->uid;
	_tmp13_ = g_strdup (_tmp12_);
	result = _tmp13_;
	_g_free0 (disc_id);
	return result;
}


static void games_play_station_uid_class_init (GamesPlayStationUidClass * klass) {
	games_play_station_uid_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesPlayStationUidPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_play_station_uid_finalize;
}


static void games_play_station_uid_games_uid_interface_init (GamesUidIface * iface) {
	games_play_station_uid_games_uid_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_uid = (gchar* (*) (GamesUid *, GError**)) games_play_station_uid_real_get_uid;
}


static void games_play_station_uid_instance_init (GamesPlayStationUid * self) {
	self->priv = GAMES_PLAY_STATION_UID_GET_PRIVATE (self);
}


static void games_play_station_uid_finalize (GObject * obj) {
	GamesPlayStationUid * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PLAY_STATION_UID, GamesPlayStationUid);
	_g_object_unref0 (self->priv->header);
	_g_free0 (self->priv->uid);
	G_OBJECT_CLASS (games_play_station_uid_parent_class)->finalize (obj);
}


GType games_play_station_uid_get_type (void) {
	return games_play_station_uid_type_id;
}


GType games_play_station_uid_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesPlayStationUidClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_play_station_uid_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesPlayStationUid), 0, (GInstanceInitFunc) games_play_station_uid_instance_init, NULL };
	static const GInterfaceInfo games_uid_info = { (GInterfaceInitFunc) games_play_station_uid_games_uid_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_play_station_uid_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesPlayStationUid", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_play_station_uid_type_id, GAMES_TYPE_UID, &games_uid_info);
	return games_play_station_uid_type_id;
}



