/* rygel-tracker-item-factory.c generated by valac 0.24.0.74-2894, 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.
 *
 * Authors: Zeeshan Ali <zeenix@gmail.com>
 *          Sunil Mohan Adapa <sunil@medhas.org>
 *          Jens Georg <jensg@openismus.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 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 program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

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


#define RYGEL_TRACKER_TYPE_ITEM_FACTORY (rygel_tracker_item_factory_get_type ())
#define RYGEL_TRACKER_ITEM_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TRACKER_TYPE_ITEM_FACTORY, RygelTrackerItemFactory))
#define RYGEL_TRACKER_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TRACKER_TYPE_ITEM_FACTORY, RygelTrackerItemFactoryClass))
#define RYGEL_TRACKER_IS_ITEM_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TRACKER_TYPE_ITEM_FACTORY))
#define RYGEL_TRACKER_IS_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TRACKER_TYPE_ITEM_FACTORY))
#define RYGEL_TRACKER_ITEM_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TRACKER_TYPE_ITEM_FACTORY, RygelTrackerItemFactoryClass))

typedef struct _RygelTrackerItemFactory RygelTrackerItemFactory;
typedef struct _RygelTrackerItemFactoryClass RygelTrackerItemFactoryClass;
typedef struct _RygelTrackerItemFactoryPrivate RygelTrackerItemFactoryPrivate;

#define RYGEL_TRACKER_TYPE_SEARCH_CONTAINER (rygel_tracker_search_container_get_type ())
#define RYGEL_TRACKER_SEARCH_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TRACKER_TYPE_SEARCH_CONTAINER, RygelTrackerSearchContainer))
#define RYGEL_TRACKER_SEARCH_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TRACKER_TYPE_SEARCH_CONTAINER, RygelTrackerSearchContainerClass))
#define RYGEL_TRACKER_IS_SEARCH_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TRACKER_TYPE_SEARCH_CONTAINER))
#define RYGEL_TRACKER_IS_SEARCH_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TRACKER_TYPE_SEARCH_CONTAINER))
#define RYGEL_TRACKER_SEARCH_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TRACKER_TYPE_SEARCH_CONTAINER, RygelTrackerSearchContainerClass))

typedef struct _RygelTrackerSearchContainer RygelTrackerSearchContainer;
typedef struct _RygelTrackerSearchContainerClass RygelTrackerSearchContainerClass;

#define RYGEL_TRACKER_ITEM_FACTORY_TYPE_METADATA (rygel_tracker_item_factory_metadata_get_type ())
#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 _RygelTrackerItemFactory {
	GTypeInstance parent_instance;
	volatile int ref_count;
	RygelTrackerItemFactoryPrivate * priv;
	gchar* category;
	gchar* category_iri;
	gchar* upnp_class;
	gchar* upload_dir;
	GeeArrayList* properties;
};

struct _RygelTrackerItemFactoryClass {
	GTypeClass parent_class;
	void (*finalize) (RygelTrackerItemFactory *self);
	RygelMediaItem* (*create) (RygelTrackerItemFactory* self, const gchar* id, const gchar* uri, RygelTrackerSearchContainer* parent, TrackerSparqlCursor* metadata, GError** error);
	void (*set_metadata) (RygelTrackerItemFactory* self, RygelMediaItem* item, const gchar* uri, TrackerSparqlCursor* metadata, GError** error);
};

typedef enum  {
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_TRACKER_ID,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_URL,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_PLACE_HOLDER,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_FILE_NAME,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_TITLE,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_DLNA_PROFILE,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_MIME,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_SIZE,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_DATE,
	RYGEL_TRACKER_ITEM_FACTORY_METADATA_LAST_KEY
} RygelTrackerItemFactoryMetadata;

struct _RygelTrackerParamSpecItemFactory {
	GParamSpec parent_instance;
};


static gpointer rygel_tracker_item_factory_parent_class = NULL;

gpointer rygel_tracker_item_factory_ref (gpointer instance);
void rygel_tracker_item_factory_unref (gpointer instance);
GParamSpec* rygel_tracker_param_spec_item_factory (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_tracker_value_set_item_factory (GValue* value, gpointer v_object);
void rygel_tracker_value_take_item_factory (GValue* value, gpointer v_object);
gpointer rygel_tracker_value_get_item_factory (const GValue* value);
GType rygel_tracker_item_factory_get_type (void) G_GNUC_CONST;
GType rygel_tracker_search_container_get_type (void) G_GNUC_CONST;
enum  {
	RYGEL_TRACKER_ITEM_FACTORY_DUMMY_PROPERTY
};
GType rygel_tracker_item_factory_metadata_get_type (void) G_GNUC_CONST;
RygelTrackerItemFactory* rygel_tracker_item_factory_construct (GType object_type, const gchar* category, const gchar* category_iri, const gchar* upnp_class, const gchar* upload_dir);
RygelMediaItem* rygel_tracker_item_factory_create (RygelTrackerItemFactory* self, const gchar* id, const gchar* uri, RygelTrackerSearchContainer* parent, TrackerSparqlCursor* metadata, GError** error);
static RygelMediaItem* rygel_tracker_item_factory_real_create (RygelTrackerItemFactory* self, const gchar* id, const gchar* uri, RygelTrackerSearchContainer* parent, TrackerSparqlCursor* metadata, GError** error);
void rygel_tracker_item_factory_set_ref_id (RygelTrackerItemFactory* self, RygelMediaItem* item, const gchar* prefix);
void rygel_tracker_item_factory_set_metadata (RygelTrackerItemFactory* self, RygelMediaItem* item, const gchar* uri, TrackerSparqlCursor* metadata, GError** error);
static void rygel_tracker_item_factory_real_set_metadata (RygelTrackerItemFactory* self, RygelMediaItem* item, const gchar* uri, TrackerSparqlCursor* metadata, GError** error);
static void rygel_tracker_item_factory_finalize (RygelTrackerItemFactory* 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 gint _vala_array_length (gpointer array);


GType rygel_tracker_item_factory_metadata_get_type (void) {
	static volatile gsize rygel_tracker_item_factory_metadata_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_tracker_item_factory_metadata_type_id__volatile)) {
		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);
		g_once_init_leave (&rygel_tracker_item_factory_metadata_type_id__volatile, rygel_tracker_item_factory_metadata_type_id);
	}
	return rygel_tracker_item_factory_metadata_type_id__volatile;
}


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


static RygelMediaItem* 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;
}


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


void rygel_tracker_item_factory_set_ref_id (RygelTrackerItemFactory* self, RygelMediaItem* item, const gchar* prefix) {
	RygelMediaItem* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gboolean _tmp4_ = FALSE;
	gchar** split_id = NULL;
	RygelMediaItem* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	gchar** _tmp8_ = NULL;
	gchar** _tmp9_ = NULL;
	gint split_id_length1 = 0;
	gint _split_id_size_ = 0;
	gchar** _tmp10_ = NULL;
	gint _tmp10__length1 = 0;
	RygelMediaItem* _tmp11_ = NULL;
	const gchar* _tmp12_ = NULL;
	gchar* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	gchar** _tmp15_ = NULL;
	gint _tmp15__length1 = 0;
	const gchar* _tmp16_ = NULL;
	gchar* _tmp17_ = NULL;
	gchar* _tmp18_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	g_return_if_fail (prefix != NULL);
	_tmp0_ = item;
	_tmp1_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = prefix;
	_tmp4_ = g_str_has_prefix (_tmp2_, _tmp3_);
	if (_tmp4_) {
		return;
	}
	_tmp5_ = item;
	_tmp6_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp5_);
	_tmp7_ = _tmp6_;
	_tmp9_ = _tmp8_ = g_strsplit (_tmp7_, ",", 0);
	split_id = _tmp9_;
	split_id_length1 = _vala_array_length (_tmp8_);
	_split_id_size_ = split_id_length1;
	_tmp10_ = split_id;
	_tmp10__length1 = split_id_length1;
	if (_tmp10__length1 != 2) {
		split_id = (_vala_array_free (split_id, split_id_length1, (GDestroyNotify) g_free), NULL);
		return;
	}
	_tmp11_ = item;
	_tmp12_ = prefix;
	_tmp13_ = g_strconcat (_tmp12_, ",", NULL);
	_tmp14_ = _tmp13_;
	_tmp15_ = split_id;
	_tmp15__length1 = split_id_length1;
	_tmp16_ = _tmp15_[1];
	_tmp17_ = g_strconcat (_tmp14_, _tmp16_, NULL);
	_tmp18_ = _tmp17_;
	rygel_media_object_set_ref_id ((RygelMediaObject*) _tmp11_, _tmp18_);
	_g_free0 (_tmp18_);
	_g_free0 (_tmp14_);
	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, RygelMediaItem* item, const gchar* uri, TrackerSparqlCursor* metadata, GError** error) {
	TrackerSparqlCursor* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	TrackerSparqlCursor* _tmp8_ = NULL;
	gboolean _tmp9_ = FALSE;
	RygelMediaItem* _tmp14_ = NULL;
	TrackerSparqlCursor* _tmp15_ = NULL;
	gboolean _tmp16_ = FALSE;
	TrackerSparqlCursor* _tmp17_ = NULL;
	gboolean _tmp18_ = FALSE;
	TrackerSparqlCursor* _tmp22_ = NULL;
	gboolean _tmp23_ = FALSE;
	RygelMediaItem* _tmp27_ = NULL;
	TrackerSparqlCursor* _tmp28_ = NULL;
	const gchar* _tmp29_ = NULL;
	RygelMediaItem* _tmp30_ = NULL;
	const gchar* _tmp31_ = NULL;
	g_return_if_fail (item != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (metadata != NULL);
	_tmp0_ = metadata;
	_tmp1_ = tracker_sparql_cursor_is_bound (_tmp0_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_TITLE);
	if (_tmp1_) {
		RygelMediaItem* _tmp2_ = NULL;
		TrackerSparqlCursor* _tmp3_ = NULL;
		const gchar* _tmp4_ = NULL;
		_tmp2_ = item;
		_tmp3_ = metadata;
		_tmp4_ = tracker_sparql_cursor_get_string (_tmp3_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_TITLE, NULL);
		rygel_media_object_set_title ((RygelMediaObject*) _tmp2_, _tmp4_);
	} else {
		RygelMediaItem* _tmp5_ = NULL;
		TrackerSparqlCursor* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		_tmp5_ = item;
		_tmp6_ = metadata;
		_tmp7_ = tracker_sparql_cursor_get_string (_tmp6_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_FILE_NAME, NULL);
		rygel_media_object_set_title ((RygelMediaObject*) _tmp5_, _tmp7_);
	}
	_tmp8_ = metadata;
	_tmp9_ = tracker_sparql_cursor_is_bound (_tmp8_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_SIZE);
	if (_tmp9_) {
		RygelMediaItem* _tmp10_ = NULL;
		TrackerSparqlCursor* _tmp11_ = NULL;
		gint64 _tmp12_ = 0LL;
		_tmp10_ = item;
		_tmp11_ = metadata;
		_tmp12_ = tracker_sparql_cursor_get_integer (_tmp11_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_SIZE);
		rygel_media_item_set_size (_tmp10_, _tmp12_);
	} else {
		RygelMediaItem* _tmp13_ = NULL;
		_tmp13_ = item;
		rygel_media_item_set_size (_tmp13_, (gint64) 0);
	}
	_tmp14_ = item;
	_tmp15_ = metadata;
	_tmp16_ = tracker_sparql_cursor_get_boolean (_tmp15_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_PLACE_HOLDER);
	rygel_media_item_set_place_holder (_tmp14_, _tmp16_);
	_tmp17_ = metadata;
	_tmp18_ = tracker_sparql_cursor_is_bound (_tmp17_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_DATE);
	if (_tmp18_) {
		RygelMediaItem* _tmp19_ = NULL;
		TrackerSparqlCursor* _tmp20_ = NULL;
		const gchar* _tmp21_ = NULL;
		_tmp19_ = item;
		_tmp20_ = metadata;
		_tmp21_ = tracker_sparql_cursor_get_string (_tmp20_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_DATE, NULL);
		rygel_media_item_set_date (_tmp19_, _tmp21_);
	}
	_tmp22_ = metadata;
	_tmp23_ = tracker_sparql_cursor_is_bound (_tmp22_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_DLNA_PROFILE);
	if (_tmp23_) {
		RygelMediaItem* _tmp24_ = NULL;
		TrackerSparqlCursor* _tmp25_ = NULL;
		const gchar* _tmp26_ = NULL;
		_tmp24_ = item;
		_tmp25_ = metadata;
		_tmp26_ = tracker_sparql_cursor_get_string (_tmp25_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_DLNA_PROFILE, NULL);
		rygel_media_item_set_dlna_profile (_tmp24_, _tmp26_);
	}
	_tmp27_ = item;
	_tmp28_ = metadata;
	_tmp29_ = tracker_sparql_cursor_get_string (_tmp28_, (gint) RYGEL_TRACKER_ITEM_FACTORY_METADATA_MIME, NULL);
	rygel_media_item_set_mime_type (_tmp27_, _tmp29_);
	_tmp30_ = item;
	_tmp31_ = uri;
	rygel_media_item_add_uri (_tmp30_, _tmp31_);
}


void rygel_tracker_item_factory_set_metadata (RygelTrackerItemFactory* self, RygelMediaItem* item, const gchar* uri, TrackerSparqlCursor* metadata, GError** error) {
	g_return_if_fail (self != NULL);
	RYGEL_TRACKER_ITEM_FACTORY_GET_CLASS (self)->set_metadata (self, item, uri, metadata, 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) {
	rygel_tracker_item_factory_parent_class = g_type_class_peek_parent (klass);
	RYGEL_TRACKER_ITEM_FACTORY_CLASS (klass)->finalize = rygel_tracker_item_factory_finalize;
	RYGEL_TRACKER_ITEM_FACTORY_CLASS (klass)->create = rygel_tracker_item_factory_real_create;
	RYGEL_TRACKER_ITEM_FACTORY_CLASS (klass)->set_metadata = rygel_tracker_item_factory_real_set_metadata;
}


static void rygel_tracker_item_factory_instance_init (RygelTrackerItemFactory * self) {
	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_free0 (self->category);
	_g_free0 (self->category_iri);
	_g_free0 (self->upnp_class);
	_g_free0 (self->upload_dir);
	_g_object_unref0 (self->properties);
}


/**
 * Abstract Tracker item factory.
 */
GType rygel_tracker_item_factory_get_type (void) {
	static volatile gsize rygel_tracker_item_factory_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_tracker_item_factory_type_id__volatile)) {
		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);
		g_once_init_leave (&rygel_tracker_item_factory_type_id__volatile, rygel_tracker_item_factory_type_id);
	}
	return rygel_tracker_item_factory_type_id__volatile;
}


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


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



