/* localsearch-item-factory.c generated by valac 0.56.19, the Vala compiler
 * generated from localsearch-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-localsearch.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <tinysparql.h>
#include "rygel-server.h"
#include <glib-object.h>
#include <gee.h>
#include <gobject/gvaluecollector.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#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 _RygelLocalSearchParamSpecItemFactory RygelLocalSearchParamSpecItemFactory;

struct _RygelLocalSearchParamSpecItemFactory {
	GParamSpec parent_instance;
};

static gpointer rygel_local_search_item_factory_parent_class = NULL;

static RygelMediaFileItem* rygel_local_search_item_factory_real_create (RygelLocalSearchItemFactory* self,
                                                                 const gchar* id,
                                                                 const gchar* uri,
                                                                 RygelLocalSearchSearchContainer* parent,
                                                                 TrackerSparqlCursor* metadata,
                                                                 GError** error);
static void rygel_local_search_item_factory_real_set_metadata (RygelLocalSearchItemFactory* self,
                                                        RygelMediaFileItem* item,
                                                        const gchar* uri,
                                                        TrackerSparqlCursor* metadata,
                                                        GError** error);
static void rygel_local_search_item_factory_real_add_resources (RygelLocalSearchItemFactory* self,
                                                         RygelMediaFileItem* item,
                                                         GError** error);
static void rygel_local_search_item_factory_finalize (RygelLocalSearchItemFactory * obj);
static GType rygel_local_search_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);

 G_GNUC_NO_INLINE static GType
rygel_local_search_item_factory_metadata_get_type_once (void)
{
	static const GEnumValue values[] = {{RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_TRACKER_ID, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_TRACKER_ID", "tracker-id"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_URL, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_URL", "url"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_PLACE_HOLDER, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_PLACE_HOLDER", "place-holder"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_FILE_NAME, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_FILE_NAME", "file-name"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_TITLE, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_TITLE", "title"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_DLNA_PROFILE, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_DLNA_PROFILE", "dlna-profile"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_MIME, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_MIME", "mime"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_SIZE, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_SIZE", "size"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_DATE, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_DATE", "date"}, {RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_LAST_KEY, "RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_LAST_KEY", "last-key"}, {0, NULL, NULL}};
	GType rygel_local_search_item_factory_metadata_type_id;
	rygel_local_search_item_factory_metadata_type_id = g_enum_register_static ("RygelLocalSearchItemFactoryMetadata", values);
	return rygel_local_search_item_factory_metadata_type_id;
}

GType
rygel_local_search_item_factory_metadata_get_type (void)
{
	static volatile gsize rygel_local_search_item_factory_metadata_type_id__once = 0;
	if (g_once_init_enter (&rygel_local_search_item_factory_metadata_type_id__once)) {
		GType rygel_local_search_item_factory_metadata_type_id;
		rygel_local_search_item_factory_metadata_type_id = rygel_local_search_item_factory_metadata_get_type_once ();
		g_once_init_leave (&rygel_local_search_item_factory_metadata_type_id__once, rygel_local_search_item_factory_metadata_type_id);
	}
	return rygel_local_search_item_factory_metadata_type_id__once;
}

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

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

RygelMediaFileItem*
rygel_local_search_item_factory_create (RygelLocalSearchItemFactory* self,
                                        const gchar* id,
                                        const gchar* uri,
                                        RygelLocalSearchSearchContainer* parent,
                                        TrackerSparqlCursor* metadata,
                                        GError** error)
{
	RygelLocalSearchItemFactoryClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = RYGEL_LOCAL_SEARCH_ITEM_FACTORY_GET_CLASS (self);
	if (_klass_->create) {
		return _klass_->create (self, id, uri, parent, metadata, error);
	}
	return NULL;
}

void
rygel_local_search_item_factory_set_ref_id (RygelLocalSearchItemFactory* 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_local_search_item_factory_real_set_metadata (RygelLocalSearchItemFactory* 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_LOCAL_SEARCH_ITEM_FACTORY_METADATA_TITLE)) {
		const gchar* _tmp0_;
		_tmp0_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_LOCAL_SEARCH_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_LOCAL_SEARCH_ITEM_FACTORY_METADATA_FILE_NAME, NULL);
		rygel_media_object_set_title ((RygelMediaObject*) item, _tmp1_);
	}
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_SIZE)) {
		rygel_media_file_item_set_size (item, tracker_sparql_cursor_get_integer (metadata, (gint) RYGEL_LOCAL_SEARCH_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_LOCAL_SEARCH_ITEM_FACTORY_METADATA_PLACE_HOLDER));
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_DATE)) {
		const gchar* _tmp2_;
		_tmp2_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_DATE, NULL);
		rygel_media_object_set_date ((RygelMediaObject*) item, _tmp2_);
	}
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_DLNA_PROFILE)) {
		const gchar* _tmp3_;
		_tmp3_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_DLNA_PROFILE, NULL);
		rygel_media_file_item_set_dlna_profile (item, _tmp3_);
	}
	if (tracker_sparql_cursor_is_bound (metadata, (gint) RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_MIME)) {
		const gchar* _tmp4_;
		_tmp4_ = tracker_sparql_cursor_get_string (metadata, (gint) RYGEL_LOCAL_SEARCH_ITEM_FACTORY_METADATA_MIME, NULL);
		rygel_media_file_item_set_mime_type (item, _tmp4_);
	}
	rygel_media_object_add_uri ((RygelMediaObject*) item, uri);
}

void
rygel_local_search_item_factory_set_metadata (RygelLocalSearchItemFactory* self,
                                              RygelMediaFileItem* item,
                                              const gchar* uri,
                                              TrackerSparqlCursor* metadata,
                                              GError** error)
{
	RygelLocalSearchItemFactoryClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = RYGEL_LOCAL_SEARCH_ITEM_FACTORY_GET_CLASS (self);
	if (_klass_->set_metadata) {
		_klass_->set_metadata (self, item, uri, metadata, error);
	}
}

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

void
rygel_local_search_item_factory_add_resources (RygelLocalSearchItemFactory* self,
                                               RygelMediaFileItem* item,
                                               GError** error)
{
	RygelLocalSearchItemFactoryClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = RYGEL_LOCAL_SEARCH_ITEM_FACTORY_GET_CLASS (self);
	if (_klass_->add_resources) {
		_klass_->add_resources (self, item, error);
	}
}

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

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

static void
rygel_local_search_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_local_search_item_factory_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

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

static gchar*
rygel_local_search_value_item_factory_collect_value (GValue* value,
                                                     guint n_collect_values,
                                                     GTypeCValue* collect_values,
                                                     guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		RygelLocalSearchItemFactory * 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_local_search_item_factory_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
rygel_local_search_value_item_factory_lcopy_value (const GValue* value,
                                                   guint n_collect_values,
                                                   GTypeCValue* collect_values,
                                                   guint collect_flags)
{
	RygelLocalSearchItemFactory ** 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_local_search_item_factory_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
rygel_local_search_param_spec_item_factory (const gchar* name,
                                            const gchar* nick,
                                            const gchar* blurb,
                                            GType object_type,
                                            GParamFlags flags)
{
	RygelLocalSearchParamSpecItemFactory* spec;
	g_return_val_if_fail (g_type_is_a (object_type, RYGEL_LOCAL_SEARCH_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_local_search_value_get_item_factory (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_LOCAL_SEARCH_TYPE_ITEM_FACTORY), NULL);
	return value->data[0].v_pointer;
}

void
rygel_local_search_value_set_item_factory (GValue* value,
                                           gpointer v_object)
{
	RygelLocalSearchItemFactory * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_LOCAL_SEARCH_TYPE_ITEM_FACTORY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_LOCAL_SEARCH_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_local_search_item_factory_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		rygel_local_search_item_factory_unref (old);
	}
}

void
rygel_local_search_value_take_item_factory (GValue* value,
                                            gpointer v_object)
{
	RygelLocalSearchItemFactory * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_LOCAL_SEARCH_TYPE_ITEM_FACTORY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_LOCAL_SEARCH_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_local_search_item_factory_unref (old);
	}
}

static void
rygel_local_search_item_factory_class_init (RygelLocalSearchItemFactoryClass * klass,
                                            gpointer klass_data)
{
	rygel_local_search_item_factory_parent_class = g_type_class_peek_parent (klass);
	((RygelLocalSearchItemFactoryClass *) klass)->finalize = rygel_local_search_item_factory_finalize;
	((RygelLocalSearchItemFactoryClass *) klass)->create = (RygelMediaFileItem* (*) (RygelLocalSearchItemFactory*, const gchar*, const gchar*, RygelLocalSearchSearchContainer*, TrackerSparqlCursor*, GError**)) rygel_local_search_item_factory_real_create;
	((RygelLocalSearchItemFactoryClass *) klass)->set_metadata = (void (*) (RygelLocalSearchItemFactory*, RygelMediaFileItem*, const gchar*, TrackerSparqlCursor*, GError**)) rygel_local_search_item_factory_real_set_metadata;
	((RygelLocalSearchItemFactoryClass *) klass)->add_resources = (void (*) (RygelLocalSearchItemFactory*, RygelMediaFileItem*, GError**)) rygel_local_search_item_factory_real_add_resources;
}

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

static void
rygel_local_search_item_factory_finalize (RygelLocalSearchItemFactory * obj)
{
	RygelLocalSearchItemFactory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_LOCAL_SEARCH_TYPE_ITEM_FACTORY, RygelLocalSearchItemFactory);
	g_signal_handlers_destroy (self);
	_g_free0 (self->category);
	_g_free0 (self->category_iri);
	_g_free0 (self->graph);
	_g_free0 (self->graph_iri);
	_g_free0 (self->upnp_class);
	_g_free0 (self->upload_dir);
	_g_object_unref0 (self->properties);
}

/**
 * Abstract LocalSearch item factory.
 */
 G_GNUC_NO_INLINE static GType
rygel_local_search_item_factory_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { rygel_local_search_value_item_factory_init, rygel_local_search_value_item_factory_free_value, rygel_local_search_value_item_factory_copy_value, rygel_local_search_value_item_factory_peek_pointer, "p", rygel_local_search_value_item_factory_collect_value, "p", rygel_local_search_value_item_factory_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (RygelLocalSearchItemFactoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_local_search_item_factory_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelLocalSearchItemFactory), 0, (GInstanceInitFunc) rygel_local_search_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_local_search_item_factory_type_id;
	rygel_local_search_item_factory_type_id = g_type_register_fundamental (g_type_fundamental_next (), "RygelLocalSearchItemFactory", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
	return rygel_local_search_item_factory_type_id;
}

GType
rygel_local_search_item_factory_get_type (void)
{
	static volatile gsize rygel_local_search_item_factory_type_id__once = 0;
	if (g_once_init_enter (&rygel_local_search_item_factory_type_id__once)) {
		GType rygel_local_search_item_factory_type_id;
		rygel_local_search_item_factory_type_id = rygel_local_search_item_factory_get_type_once ();
		g_once_init_leave (&rygel_local_search_item_factory_type_id__once, rygel_local_search_item_factory_type_id);
	}
	return rygel_local_search_item_factory_type_id__once;
}

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

void
rygel_local_search_item_factory_unref (gpointer instance)
{
	RygelLocalSearchItemFactory * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		RYGEL_LOCAL_SEARCH_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;
}

