/* steam-title.c generated by valac 0.36.6.6-c7bee, the Vala compiler
 * generated from steam-title.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>
#include <glib/gi18n-lib.h>


#define GAMES_TYPE_STEAM_TITLE (games_steam_title_get_type ())
#define GAMES_STEAM_TITLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_STEAM_TITLE, GamesSteamTitle))
#define GAMES_STEAM_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_STEAM_TITLE, GamesSteamTitleClass))
#define GAMES_IS_STEAM_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_STEAM_TITLE))
#define GAMES_IS_STEAM_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_STEAM_TITLE))
#define GAMES_STEAM_TITLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_STEAM_TITLE, GamesSteamTitleClass))

typedef struct _GamesSteamTitle GamesSteamTitle;
typedef struct _GamesSteamTitleClass GamesSteamTitleClass;
typedef struct _GamesSteamTitlePrivate GamesSteamTitlePrivate;

#define GAMES_TYPE_STEAM_REGISTRY (games_steam_registry_get_type ())
#define GAMES_STEAM_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_STEAM_REGISTRY, GamesSteamRegistry))
#define GAMES_STEAM_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_STEAM_REGISTRY, GamesSteamRegistryClass))
#define GAMES_IS_STEAM_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_STEAM_REGISTRY))
#define GAMES_IS_STEAM_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_STEAM_REGISTRY))
#define GAMES_STEAM_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_STEAM_REGISTRY, GamesSteamRegistryClass))

typedef struct _GamesSteamRegistry GamesSteamRegistry;
typedef struct _GamesSteamRegistryClass GamesSteamRegistryClass;
#define _games_steam_registry_unref0(var) ((var == NULL) ? NULL : (var = (games_steam_registry_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesSteamTitle {
	GObject parent_instance;
	GamesSteamTitlePrivate * priv;
};

struct _GamesSteamTitleClass {
	GObjectClass parent_class;
};

struct _GamesSteamTitlePrivate {
	GamesSteamRegistry* registry;
	gchar* name;
};

typedef enum  {
	GAMES_STEAM_ERROR_NO_APPID,
	GAMES_STEAM_ERROR_NO_NAME
} GamesSteamError;
#define GAMES_STEAM_ERROR games_steam_error_quark ()

static gpointer games_steam_title_parent_class = NULL;
static GamesTitleIface * games_steam_title_games_title_parent_iface = NULL;
static GType games_steam_title_type_id = 0;

GType games_steam_title_get_type (void) G_GNUC_CONST;
gpointer games_steam_registry_ref (gpointer instance);
void games_steam_registry_unref (gpointer instance);
GParamSpec* games_param_spec_steam_registry (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void games_value_set_steam_registry (GValue* value, gpointer v_object);
void games_value_take_steam_registry (GValue* value, gpointer v_object);
gpointer games_value_get_steam_registry (const GValue* value);
GType games_steam_registry_get_type (void) G_GNUC_CONST;
#define GAMES_STEAM_TITLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_STEAM_TITLE, GamesSteamTitlePrivate))
enum  {
	GAMES_STEAM_TITLE_0_PROPERTY
};
GamesSteamTitle* games_steam_title_new (GamesSteamRegistry* registry);
GamesSteamTitle* games_steam_title_construct (GType object_type, GamesSteamRegistry* registry);
static gchar* games_steam_title_real_get_title (GamesTitle* base, GError** error);
gchar* games_steam_registry_get_data (GamesSteamRegistry* self, gchar** path, int path_length1);
GQuark games_steam_error_quark (void);
static void games_steam_title_finalize (GObject * obj);
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 gpointer _games_steam_registry_ref0 (gpointer self) {
	return self ? games_steam_registry_ref (self) : NULL;
}


GamesSteamTitle* games_steam_title_construct (GType object_type, GamesSteamRegistry* registry) {
	GamesSteamTitle * self = NULL;
	GamesSteamRegistry* _tmp0_;
	GamesSteamRegistry* _tmp1_;
	g_return_val_if_fail (registry != NULL, NULL);
	self = (GamesSteamTitle*) g_object_new (object_type, NULL);
	_tmp0_ = registry;
	_tmp1_ = _games_steam_registry_ref0 (_tmp0_);
	_games_steam_registry_unref0 (self->priv->registry);
	self->priv->registry = _tmp1_;
	return self;
}


GamesSteamTitle* games_steam_title_new (GamesSteamRegistry* registry) {
	return games_steam_title_construct (GAMES_TYPE_STEAM_TITLE, registry);
}


static gchar* games_steam_title_real_get_title (GamesTitle* base, GError** error) {
	GamesSteamTitle * self;
	gchar* result = NULL;
	const gchar* _tmp0_;
	GamesSteamRegistry* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	GError * _inner_error_ = NULL;
	self = (GamesSteamTitle*) base;
	_tmp0_ = self->priv->name;
	if (_tmp0_ != NULL) {
		const gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = self->priv->name;
		_tmp2_ = g_strdup (_tmp1_);
		result = _tmp2_;
		return result;
	}
	_tmp3_ = self->priv->registry;
	_tmp4_ = g_strdup ("AppState");
	_tmp5_ = g_strdup ("name");
	_tmp6_ = g_new0 (gchar*, 2 + 1);
	_tmp6_[0] = _tmp4_;
	_tmp6_[1] = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp7__length1 = 2;
	_tmp8_ = games_steam_registry_get_data (_tmp3_, _tmp7_, 2);
	_g_free0 (self->priv->name);
	self->priv->name = _tmp8_;
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_tmp9_ = self->priv->name;
	if (_tmp9_ == NULL) {
		GError* _tmp10_;
		_tmp10_ = g_error_new_literal (GAMES_STEAM_ERROR, GAMES_STEAM_ERROR_NO_NAME, _ ("Couldn’t get name from Steam registry."));
		_inner_error_ = _tmp10_;
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp11_ = self->priv->name;
	_tmp12_ = g_strdup (_tmp11_);
	result = _tmp12_;
	return result;
}


static void games_steam_title_class_init (GamesSteamTitleClass * klass) {
	games_steam_title_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesSteamTitlePrivate));
	G_OBJECT_CLASS (klass)->finalize = games_steam_title_finalize;
}


static void games_steam_title_games_title_interface_init (GamesTitleIface * iface) {
	games_steam_title_games_title_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_title = (gchar* (*) (GamesTitle *, GError**)) games_steam_title_real_get_title;
}


static void games_steam_title_instance_init (GamesSteamTitle * self) {
	self->priv = GAMES_STEAM_TITLE_GET_PRIVATE (self);
}


static void games_steam_title_finalize (GObject * obj) {
	GamesSteamTitle * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_STEAM_TITLE, GamesSteamTitle);
	_games_steam_registry_unref0 (self->priv->registry);
	_g_free0 (self->priv->name);
	G_OBJECT_CLASS (games_steam_title_parent_class)->finalize (obj);
}


GType games_steam_title_get_type (void) {
	return games_steam_title_type_id;
}


GType games_steam_title_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesSteamTitleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_steam_title_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesSteamTitle), 0, (GInstanceInitFunc) games_steam_title_instance_init, NULL };
	static const GInterfaceInfo games_title_info = { (GInterfaceInitFunc) games_steam_title_games_title_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_steam_title_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesSteamTitle", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_steam_title_type_id, GAMES_TYPE_TITLE, &games_title_info);
	return games_steam_title_type_id;
}


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



