/* media.c generated by valac 0.36.12.13-3ae08, the Vala compiler
 * generated from media.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>


#define GAMES_TYPE_MEDIA (games_media_get_type ())
#define GAMES_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_MEDIA, GamesMedia))
#define GAMES_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_MEDIA, GamesMediaClass))
#define GAMES_IS_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_MEDIA))
#define GAMES_IS_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_MEDIA))
#define GAMES_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_MEDIA, GamesMediaClass))

typedef struct _GamesMedia GamesMedia;
typedef struct _GamesMediaClass GamesMediaClass;
typedef struct _GamesMediaPrivate GamesMediaPrivate;

#define GAMES_TYPE_TITLE (games_title_get_type ())
#define GAMES_TITLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_TITLE, GamesTitle))
#define GAMES_IS_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_TITLE))
#define GAMES_TITLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_TITLE, GamesTitleIface))

typedef struct _GamesTitle GamesTitle;
typedef struct _GamesTitleIface GamesTitleIface;

#define GAMES_TYPE_MEDIA_INFO (games_media_info_get_type ())
#define GAMES_MEDIA_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_MEDIA_INFO, GamesMediaInfo))
#define GAMES_MEDIA_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_MEDIA_INFO, GamesMediaInfoClass))
#define GAMES_IS_MEDIA_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_MEDIA_INFO))
#define GAMES_IS_MEDIA_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_MEDIA_INFO))
#define GAMES_MEDIA_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_MEDIA_INFO, GamesMediaInfoClass))

typedef struct _GamesMediaInfo GamesMediaInfo;
typedef struct _GamesMediaInfoClass GamesMediaInfoClass;

#define GAMES_TYPE_URI (games_uri_get_type ())
#define GAMES_URI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_URI, GamesUri))
#define GAMES_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_URI, GamesUriClass))
#define GAMES_IS_URI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_URI))
#define GAMES_IS_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_URI))
#define GAMES_URI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_URI, GamesUriClass))

typedef struct _GamesUri GamesUri;
typedef struct _GamesUriClass GamesUriClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesMedia {
	GObject parent_instance;
	GamesMediaPrivate * priv;
};

struct _GamesMediaClass {
	GObjectClass parent_class;
};

struct _GamesTitleIface {
	GTypeInterface parent_iface;
	gchar* (*get_title) (GamesTitle* self, GError** error);
};

struct _GamesMediaPrivate {
	GamesTitle* _title;
	GamesMediaInfo* media_info;
	GamesUri** uris;
	gint uris_length1;
	gint _uris_size_;
};


static gpointer games_media_parent_class = NULL;

GType games_media_get_type (void) G_GNUC_CONST;
GType games_title_get_type (void) G_GNUC_CONST;
GType games_media_info_get_type (void) G_GNUC_CONST;
gpointer games_uri_ref (gpointer instance);
void games_uri_unref (gpointer instance);
GParamSpec* games_param_spec_uri (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void games_value_set_uri (GValue* value, gpointer v_object);
void games_value_take_uri (GValue* value, gpointer v_object);
gpointer games_value_get_uri (const GValue* value);
GType games_uri_get_type (void) G_GNUC_CONST;
#define GAMES_MEDIA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_MEDIA, GamesMediaPrivate))
enum  {
	GAMES_MEDIA_0_PROPERTY,
	GAMES_MEDIA_TITLE_PROPERTY
};
GamesMedia* games_media_new (GamesTitle* title);
GamesMedia* games_media_construct (GType object_type, GamesTitle* title);
GamesMediaInfo* games_media_info_new (const gchar* platform, const gchar* game_id, const gchar* media_id, guint media_index);
GamesMediaInfo* games_media_info_construct (GType object_type, const gchar* platform, const gchar* game_id, const gchar* media_id, guint media_index);
static void games_media_set_title (GamesMedia* self, GamesTitle* value);
GamesMediaInfo* games_media_get_media_info (GamesMedia* self);
GamesUri** games_media_get_uris (GamesMedia* self, int* result_length1);
static GamesUri** _vala_array_dup4 (GamesUri** self, int length);
void games_media_add_uri (GamesMedia* self, GamesUri* uri);
static void _vala_array_add6 (GamesUri** * array, int* length, int* size, GamesUri* value);
GamesTitle* games_media_get_title (GamesMedia* self);
static void games_media_finalize (GObject * obj);
static void _vala_games_media_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_games_media_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
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);


GamesMedia* games_media_construct (GType object_type, GamesTitle* title) {
	GamesMedia * self = NULL;
	GamesMediaInfo* _tmp0_;
	GamesTitle* _tmp1_;
	GamesUri** _tmp2_;
	self = (GamesMedia*) g_object_new (object_type, NULL);
	_tmp0_ = games_media_info_new ("Dummy", "dummy", NULL, (guint) 0);
	_g_object_unref0 (self->priv->media_info);
	self->priv->media_info = _tmp0_;
	_tmp1_ = title;
	games_media_set_title (self, _tmp1_);
	_tmp2_ = g_new0 (GamesUri*, 0 + 1);
	self->priv->uris = (_vala_array_free (self->priv->uris, self->priv->uris_length1, (GDestroyNotify) games_uri_unref), NULL);
	self->priv->uris = _tmp2_;
	self->priv->uris_length1 = 0;
	self->priv->_uris_size_ = self->priv->uris_length1;
	return self;
}


GamesMedia* games_media_new (GamesTitle* title) {
	return games_media_construct (GAMES_TYPE_MEDIA, title);
}


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


GamesMediaInfo* games_media_get_media_info (GamesMedia* self) {
	GamesMediaInfo* result = NULL;
	GamesMediaInfo* _tmp0_ = NULL;
	GamesMediaInfo* _tmp1_;
	GamesMediaInfo* _tmp2_;
	GamesMediaInfo* _tmp4_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->media_info;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_tmp0_ = _tmp2_;
	if (_tmp0_ == NULL) {
		GamesMediaInfo* _tmp3_;
		_tmp3_ = games_media_info_new ("Dummy", "dummy", NULL, (guint) 0);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = _tmp3_;
	}
	_tmp4_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp4_;
	_g_object_unref0 (_tmp0_);
	return result;
}


static gpointer _games_uri_ref0 (gpointer self) {
	return self ? games_uri_ref (self) : NULL;
}


static GamesUri** _vala_array_dup4 (GamesUri** self, int length) {
	GamesUri** result;
	int i;
	result = g_new0 (GamesUri*, length + 1);
	for (i = 0; i < length; i++) {
		GamesUri* _tmp0_;
		_tmp0_ = _games_uri_ref0 (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


GamesUri** games_media_get_uris (GamesMedia* self, int* result_length1) {
	GamesUri** result = NULL;
	GamesUri** _tmp0_;
	gint _tmp0__length1;
	GamesUri** _tmp1_;
	gint _tmp1__length1;
	GamesUri** _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->uris;
	_tmp0__length1 = self->priv->uris_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup4 (_tmp0_, _tmp0__length1) : ((gpointer) _tmp0_);
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}


static void _vala_array_add6 (GamesUri** * array, int* length, int* size, GamesUri* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GamesUri*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


void games_media_add_uri (GamesMedia* self, GamesUri* uri) {
	GamesUri** _tmp0_;
	gint _tmp0__length1;
	GamesUri* _tmp1_;
	GamesUri* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	_tmp0_ = self->priv->uris;
	_tmp0__length1 = self->priv->uris_length1;
	_tmp1_ = uri;
	_tmp2_ = _games_uri_ref0 (_tmp1_);
	_vala_array_add6 (&self->priv->uris, &self->priv->uris_length1, &self->priv->_uris_size_, _tmp2_);
}


GamesTitle* games_media_get_title (GamesMedia* self) {
	GamesTitle* result;
	GamesTitle* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_title;
	result = _tmp0_;
	return result;
}


static void games_media_set_title (GamesMedia* self, GamesTitle* value) {
	g_return_if_fail (self != NULL);
	if (games_media_get_title (self) != value) {
		GamesTitle* _tmp0_;
		GamesTitle* _tmp1_;
		_tmp0_ = value;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_g_object_unref0 (self->priv->_title);
		self->priv->_title = _tmp1_;
		g_object_notify ((GObject *) self, "title");
	}
}


static void games_media_class_init (GamesMediaClass * klass) {
	games_media_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesMediaPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_games_media_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_media_set_property;
	G_OBJECT_CLASS (klass)->finalize = games_media_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_MEDIA_TITLE_PROPERTY, g_param_spec_object ("title", "title", "title", GAMES_TYPE_TITLE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void games_media_instance_init (GamesMedia * self) {
	self->priv = GAMES_MEDIA_GET_PRIVATE (self);
}


static void games_media_finalize (GObject * obj) {
	GamesMedia * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_MEDIA, GamesMedia);
	_g_object_unref0 (self->priv->_title);
	_g_object_unref0 (self->priv->media_info);
	self->priv->uris = (_vala_array_free (self->priv->uris, self->priv->uris_length1, (GDestroyNotify) games_uri_unref), NULL);
	G_OBJECT_CLASS (games_media_parent_class)->finalize (obj);
}


GType games_media_get_type (void) {
	static volatile gsize games_media_type_id__volatile = 0;
	if (g_once_init_enter (&games_media_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesMediaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_media_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesMedia), 0, (GInstanceInitFunc) games_media_instance_init, NULL };
		GType games_media_type_id;
		games_media_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesMedia", &g_define_type_info, 0);
		g_once_init_leave (&games_media_type_id__volatile, games_media_type_id);
	}
	return games_media_type_id__volatile;
}


static void _vala_games_media_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GamesMedia * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_MEDIA, GamesMedia);
	switch (property_id) {
		case GAMES_MEDIA_TITLE_PROPERTY:
		g_value_set_object (value, games_media_get_title (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_games_media_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GamesMedia * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_MEDIA, GamesMedia);
	switch (property_id) {
		case GAMES_MEDIA_TITLE_PROPERTY:
		games_media_set_title (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


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



