/* rygel-tracker-item-factory.c generated by valac 0.56.1, the Vala compiler
 * generated from rygel-tracker-item-factory.vala, do not modify */

/*
 * Copyright (C) 2008 Zeeshan Ali <zeenix@gmail.com>.
 * Copyright (C) 2008-2012 Nokia Corporation.
 * Copyright (C) 2010 MediaNet Inh.
 * Copyright (C) 2012 Intel Corporation.
 * Copyright (C) 2013 Cable Television Laboratories, Inc.
 *
 * Authors: Zeeshan Ali <zeenix@gmail.com>
 *          Sunil Mohan Adapa <sunil@medhas.org>
 *          Jens Georg <jensg@openismus.com>
 *          Doug Galligan <doug@sentosatech.com>
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Rygel is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "rygel-tracker3.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <libtracker-sparql/tracker-sparql.h>
#include "rygel-server.h"
#include <gee.h>
#include <glib-object.h>
#include <gobject/gvaluecollector.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _RygelTrackerParamSpecItemFactory RygelTrackerParamSpecItemFactory;

struct _RygelTrackerParamSpecItemFactory {
	GParamSpec parent_instance;
};

static gpointer rygel_tracker_item_factory_parent_class = NULL;

static RygelMediaFileItem* rygel_tracker_item_factory_real_create (RygelTrackerItemFactory* self,
                                                            const gchar* id,
                                                            const gchar* uri,
                                                            RygelTrackerSearchContainer* parent,
                                                            TrackerSparqlCursor* metadata,
                                                            GError** error);
static void rygel_tracker_item_factory_real_set_metadata (RygelTrackerItemFactory* self,
                                                   RygelMediaFileItem* item,
                                                   const gchar* uri,
                                                   TrackerSparqlCursor* metadata,
                                                   GError** error);
static void rygel_tracker_item_factory_real_add_resources (RygelTrackerItemFactory* self,
                                                    RygelMediaFileItem* item,
                                                    GError** error);
static void rygel_tracker_item_factory_finalize (RygelTrackerItemFactory * obj);
static GType rygel_tracker_item_factory_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static GType
rygel_tracker_item_factory_metadata_get_type_once (void)
{
	static const GEnumValue values[] = {{RYGEL_TRACKER_ITEM_FACTORY_METADATA_TRACKER_ID, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_TRACKER_ID", "tracker-id"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_URL, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_URL", "url"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_PLACE_HOLDER, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_PLACE_HOLDER", "place-holder"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_FILE_NAME, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_FILE_NAME", "file-name"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_TITLE, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_TITLE", "title"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_DLNA_PROFILE, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_DLNA_PROFILE", "dlna-profile"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_MIME, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_MIME", "mime"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_SIZE, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_SIZE", "size"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_DATE, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_DATE", "date"}, {RYGEL_TRACKER_ITEM_FACTORY_METADATA_LAST_KEY, "RYGEL_TRACKER_ITEM_FACTORY_METADATA_LAST_KEY", "last-key"}, {0, NULL, NULL}};
	GType rygel_tracker_item_factory_metadata_type_id;
	rygel_tracker_item_factory_metadata_type_id = g_enum_register_static ("RygelTrackerItemFactoryMetadata", values);
	return rygel_tracker_item_factory_metadata_type_id;
}

GType
rygel_tracker_item_factory_metadata_get_type (void)
{
	static volatile gsize rygel_tracker_item_factory_metadata_type_id__once = 0;
	if (g_once_init_enter (&rygel_tracker_item_factory_metadata_type_id__once)) {
		GType rygel_tracker_item_factory_metadata_type_id;
		rygel_tracker_item_factory_metadata_type_id = rygel_tracker_item_factory_metadata_get_type_once ();
		g_once_init_leave (&rygel_tracker_item_factory_metadata_type_id__once, rygel_tracker_item_factory_metadata_type_id);
	}
	return rygel_tracker_item_factory_metadata_type_id__once;
}

RygelTrackerItemFactory*
rygel_tracker_item_factory_construct (GType object_type,
                                      const gchar* category,
                                      const gchar* category_iri,
                                      const gchar* graph,
                                      const gchar* upnp_class,
                                      const gchar* upload_dir)
{
	RygelTrackerItemFactory* self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_ = NULL;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeArrayList* _tmp8_;
	GeeArrayList* _tmp9_;
	GeeArrayList* _tmp10_;
	GeeArrayList* _tmp11_;
	GeeArrayList* _tmp12_;
	GeeArrayList* _tmp13_;
	GeeArrayList* _tmp14_;
	g_return_val_if_fail (category != NULL, NULL);
	g_return_val_if_fail (category_iri != NULL, NULL);
	g_return_val_if_fail (graph != NULL, NULL);
	g_return_val_if_fail (upnp_class != NULL, NULL);
	self = (RygelTrackerItemFactory*) g_type_create_instance (object_type);
	_tmp0_ = g_strdup (category);
	_g_free0 (self->category);
	self->category = _tmp0_;
	_tmp1_ = g_strdup (category_iri);
	_g_free0 (self->category_iri);
	self->category_iri = _tmp1_;
	_tmp2_ = g_strdup (graph);
	_g_free0 (self->graph);
	self->graph = _tmp2_;
	_tmp3_ = g_strdup (upnp_class);
	_g_free0 (self->upnp_class);
	self->upnp_class = _tmp3_;
	_tmp4_ = g_strdup (upload_dir);
	_g_free0 (self->upload_dir);
	self->upload_dir = _tmp4_;
	if (upload_dir == NULL) {
		_tmp5_ = "none";
	} else {
		_tmp5_ = upload_dir;
	}
	g_message ("rygel-tracker-item-factory.vala:71: Using %s as upload directory for %" \
"s", _tmp5_, upnp_class);
	_tmp6_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->properties);
	self->properties = _tmp6_;
	_tmp7_ = self->properties;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp7_, "res");
	_tmp8_ = self->properties;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, "place_holder");
	_tmp9_ = self->properties;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, "fileName");
	_tmp10_ = self->properties;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, "dc:title");
	_tmp11_ = self->properties;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, "dlnaProfile");
	_tmp12_ = self->properties;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, "mimeType");
	_tmp13_ = self->properties;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp13_, "res@size");
	_tmp14_ = self->properties;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp14_, "date");
	return self;
}

static RygelMediaFileItem*
rygel_tracker_item_factory_real_create (RygelTrackerItemFactory* self,
                                        const gchar* id,
                                        const gchar* uri,
                                        RygelTrackerSearchContainer* parent,
                                        TrackerSparqlCursor* metadata,
                                        GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `rygel_tracker_item_factory_create'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

RygelMediaFileItem*
rygel_tracker_item_factory_create (RygelTrackerItemFactory* self,
                                   const gchar* id,
                                   const gchar* uri,
                                   RygelTrackerSearchContainer* parent,
                                   TrackerSparqlCursor* metadata,
                                   GError** error)
{
	RygelTrackerItemFactoryClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = RYGEL_TRACKER_ITEM_FACTORY_GET_CLASS (self);
	if (_klass_->create) {
		return _klass_->create (self, id, uri, parent, metadata, error);
	}
	return NULL;
}

void
rygel_tracker_item_factory_set_ref_id (RygelTrackerItemFactory* self,
                                       RygelMediaFileItem* item,
                                       const gchar* prefix)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar** split_id = NULL;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint split_id_length1;
	gint _split_id_size_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	g_return_if_fail (prefix != NULL);
	_tmp0_ = rygel_media_object_get_id ((RygelMediaObject*) item);
	_tmp1_ = _tmp0_;
	if (g_str_has_prefix (_tmp1_, prefix)) {
		return;
	}
	_tmp2_ = rygel_media_object_get_id ((RygelMediaObject*) item);
	_tmp3_ = _tmp2_;
	_tmp5_ = _tmp4_ = g_strsplit (_tmp3_, ",", 0);
	split_id = _tmp5_;
	split_id_length1 = _vala_array_length (_tmp4_);
	_split_id_size_ = split_id_length1;
	_tmp6_ = split_id;
	_tmp6__length1 = split_id_length1;
	if (_tmp6__length1 != 2) {
		split_id = (_vala_array_free (split_id, split_id_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_tmp7_ = g_strconcat (prefix, ",", NULL);
	_tmp8_ = _tmp7_;
	_tmp9_ = split_id;
	_tmp9__length1 = split_id_length1;
	_tmp10_ = _tmp9_[1];
	_tmp11_ = g_strconcat (_tmp8_, _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	rygel_media_object_set_ref_id ((RygelMediaObject*) item, _tmp12_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp8_);
	split_id = (_vala_array_free (split_id, split_id_length1, (GDestroyNotify) g_free), NULL);
}

static void
rygel_tracker_item_factory_real_set_metadata (RygelTrackerItemFactory* self,
                                              RygelMediaFileItem* item,
                                              const gchar* uri,
                                              TrackerSparqlCursor* metadata,
                                              GError** error)
{
	g_return_if_fail (item != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (metadata != NULL);
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_TITLE)) {
		const gchar* _tmp0_;
		_tmp0_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_TITLE, NULL);
		rygel_media_object_set_title ((RygelMediaObject*) item, _tmp0_);
	} else {
		const gchar* _tmp1_;
		_tmp1_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_FILE_NAME, NULL);
		rygel_media_object_set_title ((RygelMediaObject*) item, _tmp1_);
	}
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_SIZE)) {
		rygel_media_file_item_set_size (item, tracker_sparql_cursor_get_integer (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_SIZE));
	} else {
		rygel_media_file_item_set_size (item, (gint64) 0);
	}
	rygel_media_file_item_set_place_holder (item, tracker_sparql_cursor_get_boolean (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_PLACE_HOLDER));
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_DATE)) {
		const gchar* _tmp2_;
		_tmp2_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_DATE, NULL);
		rygel_media_object_set_date ((RygelMediaObject*) item, _tmp2_);
	}
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_DLNA_PROFILE)) {
		const gchar* _tmp3_;
		_tmp3_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_DLNA_PROFILE, NULL);
		rygel_media_file_item_set_dlna_profile (item, _tmp3_);
	}
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_MIME)) {
		const gchar* _tmp4_;
		_tmp4_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_MIME, NULL);
		rygel_media_file_item_set_mime_type (item, _tmp4_);
	}
	rygel_media_object_add_uri ((RygelMediaObject*) item, uri);
}

void
rygel_tracker_item_factory_set_metadata (RygelTrackerItemFactory* self,
                                         RygelMediaFileItem* item,
                                         const gchar* uri,
                                         TrackerSparqlCursor* metadata,
                                         GError** error)
{
	RygelTrackerItemFactoryClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = RYGEL_TRACKER_ITEM_FACTORY_GET_CLASS (self);
	if (_klass_->set_metadata) {
		_klass_->set_metadata (self, item, uri, metadata, error);
	}
}

static void
rygel_tracker_item_factory_real_add_resources (RygelTrackerItemFactory* self,
                                               RygelMediaFileItem* item,
                                               GError** error)
{
	g_return_if_fail (item != NULL);
	rygel_media_file_item_add_engine_resources (item, NULL, NULL);
}

void
rygel_tracker_item_factory_add_resources (RygelTrackerItemFactory* self,
                                          RygelMediaFileItem* item,
                                          GError** error)
{
	RygelTrackerItemFactoryClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = RYGEL_TRACKER_ITEM_FACTORY_GET_CLASS (self);
	if (_klass_->add_resources) {
		_klass_->add_resources (self, item, error);
	}
}

static void
rygel_tracker_value_item_factory_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
rygel_tracker_value_item_factory_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		rygel_tracker_item_factory_unref (value->data[0].v_pointer);
	}
}

static void
rygel_tracker_value_item_factory_copy_value (const GValue* src_value,
                                             GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = rygel_tracker_item_factory_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
rygel_tracker_value_item_factory_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
rygel_tracker_value_item_factory_collect_value (GValue* value,
                                                guint n_collect_values,
                                                GTypeCValue* collect_values,
                                                guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		RygelTrackerItemFactory * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = rygel_tracker_item_factory_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
rygel_tracker_value_item_factory_lcopy_value (const GValue* value,
                                              guint n_collect_values,
                                              GTypeCValue* collect_values,
                                              guint collect_flags)
{
	RygelTrackerItemFactory ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = rygel_tracker_item_factory_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
rygel_tracker_param_spec_item_factory (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags)
{
	RygelTrackerParamSpecItemFactory* spec;
	g_return_val_if_fail (g_type_is_a (object_type, RYGEL_TRACKER_TYPE_ITEM_FACTORY), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
rygel_tracker_value_get_item_factory (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_TRACKER_TYPE_ITEM_FACTORY), NULL);
	return value->data[0].v_pointer;
}

void
rygel_tracker_value_set_item_factory (GValue* value,
                                      gpointer v_object)
{
	RygelTrackerItemFactory * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_TRACKER_TYPE_ITEM_FACTORY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_TRACKER_TYPE_ITEM_FACTORY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		rygel_tracker_item_factory_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		rygel_tracker_item_factory_unref (old);
	}
}

void
rygel_tracker_value_take_item_factory (GValue* value,
                                       gpointer v_object)
{
	RygelTrackerItemFactory * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_TRACKER_TYPE_ITEM_FACTORY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_TRACKER_TYPE_ITEM_FACTORY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		rygel_tracker_item_factory_unref (old);
	}
}

static void
rygel_tracker_item_factory_class_init (RygelTrackerItemFactoryClass * klass,
                                       gpointer klass_data)
{
	rygel_tracker_item_factory_parent_class = g_type_class_peek_parent (klass);
	((RygelTrackerItemFactoryClass *) klass)->finalize = rygel_tracker_item_factory_finalize;
	((RygelTrackerItemFactoryClass *) klass)->create = (RygelMediaFileItem* (*) (RygelTrackerItemFactory*, const gchar*, const gchar*, RygelTrackerSearchContainer*, TrackerSparqlCursor*, GError**)) rygel_tracker_item_factory_real_create;
	((RygelTrackerItemFactoryClass *) klass)->set_metadata = (void (*) (RygelTrackerItemFactory*, RygelMediaFileItem*, const gchar*, TrackerSparqlCursor*, GError**)) rygel_tracker_item_factory_real_set_metadata;
	((RygelTrackerItemFactoryClass *) klass)->add_resources = (void (*) (RygelTrackerItemFactory*, RygelMediaFileItem*, GError**)) rygel_tracker_item_factory_real_add_resources;
}

static void
rygel_tracker_item_factory_instance_init (RygelTrackerItemFactory * self,
                                          gpointer klass)
{
	self->ref_count = 1;
}

static void
rygel_tracker_item_factory_finalize (RygelTrackerItemFactory * obj)
{
	RygelTrackerItemFactory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TRACKER_TYPE_ITEM_FACTORY, RygelTrackerItemFactory);
	g_signal_handlers_destroy (self);
	_g_free0 (self->category);
	_g_free0 (self->category_iri);
	_g_free0 (self->graph);
	_g_free0 (self->upnp_class);
	_g_free0 (self->upload_dir);
	_g_object_unref0 (self->properties);
}

/**
 * Abstract Tracker item factory.
 */
static GType
rygel_tracker_item_factory_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { rygel_tracker_value_item_factory_init, rygel_tracker_value_item_factory_free_value, rygel_tracker_value_item_factory_copy_value, rygel_tracker_value_item_factory_peek_pointer, "p", rygel_tracker_value_item_factory_collect_value, "p", rygel_tracker_value_item_factory_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (RygelTrackerItemFactoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_tracker_item_factory_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelTrackerItemFactory), 0, (GInstanceInitFunc) rygel_tracker_item_factory_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType rygel_tracker_item_factory_type_id;
	rygel_tracker_item_factory_type_id = g_type_register_fundamental (g_type_fundamental_next (), "RygelTrackerItemFactory", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
	return rygel_tracker_item_factory_type_id;
}

GType
rygel_tracker_item_factory_get_type (void)
{
	static volatile gsize rygel_tracker_item_factory_type_id__once = 0;
	if (g_once_init_enter (&rygel_tracker_item_factory_type_id__once)) {
		GType rygel_tracker_item_factory_type_id;
		rygel_tracker_item_factory_type_id = rygel_tracker_item_factory_get_type_once ();
		g_once_init_leave (&rygel_tracker_item_factory_type_id__once, rygel_tracker_item_factory_type_id);
	}
	return rygel_tracker_item_factory_type_id__once;
}

gpointer
rygel_tracker_item_factory_ref (gpointer instance)
{
	RygelTrackerItemFactory * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
rygel_tracker_item_factory_unref (gpointer instance)
{
	RygelTrackerItemFactory * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		RYGEL_TRACKER_ITEM_FACTORY_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

