/* rygel-media-export-dummy-container.c generated by valac 0.17.4.16-52707, the Vala compiler
 * generated from rygel-media-export-dummy-container.vala, do not modify */

/*
 * Copyright (C) 2009,2010 Jens Georg <mail@jensge.org>.
 *
 * 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 <rygel-server.h>
#include <gio/gio.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>


#define RYGEL_TYPE_NULL_CONTAINER (rygel_null_container_get_type ())
#define RYGEL_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainer))
#define RYGEL_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainerClass))
#define RYGEL_IS_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_NULL_CONTAINER))
#define RYGEL_IS_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_NULL_CONTAINER))
#define RYGEL_NULL_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainerClass))

typedef struct _RygelNullContainer RygelNullContainer;
typedef struct _RygelNullContainerClass RygelNullContainerClass;
typedef struct _RygelNullContainerPrivate RygelNullContainerPrivate;

#define RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER (rygel_media_export_dummy_container_get_type ())
#define RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, RygelMediaExportDummyContainer))
#define RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, RygelMediaExportDummyContainerClass))
#define RYGEL_MEDIA_EXPORT_IS_DUMMY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER))
#define RYGEL_MEDIA_EXPORT_IS_DUMMY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER))
#define RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, RygelMediaExportDummyContainerClass))

typedef struct _RygelMediaExportDummyContainer RygelMediaExportDummyContainer;
typedef struct _RygelMediaExportDummyContainerClass RygelMediaExportDummyContainerClass;
typedef struct _RygelMediaExportDummyContainerPrivate RygelMediaExportDummyContainerPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE (rygel_media_export_media_cache_get_type ())
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache))
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))

typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _RygelNullContainer {
	RygelMediaContainer parent_instance;
	RygelNullContainerPrivate * priv;
};

struct _RygelNullContainerClass {
	RygelMediaContainerClass parent_class;
};

struct _RygelMediaExportDummyContainer {
	RygelNullContainer parent_instance;
	RygelMediaExportDummyContainerPrivate * priv;
	GFile* file;
	GeeList* children;
};

struct _RygelMediaExportDummyContainerClass {
	RygelNullContainerClass parent_class;
};

typedef enum  {
	RYGEL_MEDIA_EXPORT_DATABASE_ERROR_IO_ERROR,
	RYGEL_MEDIA_EXPORT_DATABASE_ERROR_SQLITE_ERROR
} RygelMediaExportDatabaseError;
#define RYGEL_MEDIA_EXPORT_DATABASE_ERROR rygel_media_export_database_error_quark ()

static gpointer rygel_media_export_dummy_container_parent_class = NULL;

GType rygel_null_container_get_type (void) G_GNUC_CONST;
GType rygel_media_export_dummy_container_get_type (void) G_GNUC_CONST;
enum  {
	RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER_DUMMY_PROPERTY
};
RygelMediaExportDummyContainer* rygel_media_export_dummy_container_new (GFile* file, RygelMediaContainer* parent);
RygelMediaExportDummyContainer* rygel_media_export_dummy_container_construct (GType object_type, GFile* file, RygelMediaContainer* parent);
RygelNullContainer* rygel_null_container_new (void);
RygelNullContainer* rygel_null_container_construct (GType object_type);
gchar* rygel_media_export_media_cache_get_id (GFile* file);
GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
GQuark rygel_media_export_database_error_quark (void);
GeeArrayList* rygel_media_export_media_cache_get_child_ids (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
void rygel_media_export_dummy_container_seen (RygelMediaExportDummyContainer* self, GFile* file);
static void rygel_media_export_dummy_container_finalize (GObject* obj);


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


RygelMediaExportDummyContainer* rygel_media_export_dummy_container_construct (GType object_type, GFile* file, RygelMediaContainer* parent) {
	RygelMediaExportDummyContainer * self = NULL;
	GFile* _tmp0_;
	gchar* _tmp1_ = NULL;
	GFile* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	RygelMediaContainer* _tmp5_;
	GFile* _tmp6_;
	GFile* _tmp7_;
	GeeArrayList* _tmp8_;
	GFile* _tmp9_;
	gchar* _tmp10_ = NULL;
	gchar* _tmp11_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	g_return_val_if_fail (parent != NULL, NULL);
	self = (RygelMediaExportDummyContainer*) rygel_null_container_construct (object_type);
	_tmp0_ = file;
	_tmp1_ = rygel_media_export_media_cache_get_id (_tmp0_);
	_g_free0 (((RygelMediaObject*) self)->id);
	((RygelMediaObject*) self)->id = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = g_file_get_basename (_tmp2_);
	_tmp4_ = _tmp3_;
	rygel_media_object_set_title ((RygelMediaObject*) self, _tmp4_);
	_g_free0 (_tmp4_);
	_tmp5_ = parent;
	rygel_media_object_set_parent_ref ((RygelMediaObject*) self, _tmp5_);
	_tmp6_ = file;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_g_object_unref0 (self->file);
	self->file = _tmp7_;
	_tmp8_ = ((RygelMediaObject*) self)->uris;
	_tmp9_ = file;
	_tmp10_ = g_file_get_uri (_tmp9_);
	_tmp11_ = _tmp10_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, _tmp11_);
	_g_free0 (_tmp11_);
	{
		RygelMediaExportMediaCache* _tmp12_ = NULL;
		RygelMediaExportMediaCache* _tmp13_;
		RygelMediaExportMediaCache* _tmp14_;
		const gchar* _tmp15_;
		GeeArrayList* _tmp16_ = NULL;
		GeeArrayList* _tmp17_;
		GeeArrayList* _tmp18_;
		GeeList* _tmp19_;
		gint _tmp20_;
		gint _tmp21_;
		_tmp12_ = rygel_media_export_media_cache_get_default (&_inner_error_);
		_tmp13_ = _tmp12_;
		if (_inner_error_ != NULL) {
			goto __catch25_g_error;
		}
		_tmp14_ = _tmp13_;
		_tmp15_ = ((RygelMediaObject*) self)->id;
		_tmp16_ = rygel_media_export_media_cache_get_child_ids (_tmp14_, _tmp15_, &_inner_error_);
		_tmp17_ = _tmp16_;
		_g_object_unref0 (_tmp14_);
		_tmp18_ = _tmp17_;
		if (_inner_error_ != NULL) {
			goto __catch25_g_error;
		}
		_g_object_unref0 (self->children);
		self->children = (GeeList*) _tmp18_;
		_tmp19_ = self->children;
		_tmp20_ = gee_collection_get_size ((GeeCollection*) _tmp19_);
		_tmp21_ = _tmp20_;
		((RygelMediaContainer*) self)->child_count = _tmp21_;
	}
	goto __finally25;
	__catch25_g_error:
	{
		GError* _error_ = NULL;
		GeeArrayList* _tmp22_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp22_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
		_g_object_unref0 (self->children);
		self->children = (GeeList*) _tmp22_;
		((RygelMediaContainer*) self)->child_count = 0;
		_g_error_free0 (_error_);
	}
	__finally25:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	return self;
}


RygelMediaExportDummyContainer* rygel_media_export_dummy_container_new (GFile* file, RygelMediaContainer* parent) {
	return rygel_media_export_dummy_container_construct (RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, file, parent);
}


void rygel_media_export_dummy_container_seen (RygelMediaExportDummyContainer* self, GFile* file) {
	GeeList* _tmp0_;
	GFile* _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	_tmp0_ = self->children;
	_tmp1_ = file;
	_tmp2_ = rygel_media_export_media_cache_get_id (_tmp1_);
	_tmp3_ = _tmp2_;
	gee_collection_remove ((GeeCollection*) _tmp0_, _tmp3_);
	_g_free0 (_tmp3_);
}


static void rygel_media_export_dummy_container_class_init (RygelMediaExportDummyContainerClass * klass) {
	rygel_media_export_dummy_container_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = rygel_media_export_dummy_container_finalize;
}


static void rygel_media_export_dummy_container_instance_init (RygelMediaExportDummyContainer * self) {
}


static void rygel_media_export_dummy_container_finalize (GObject* obj) {
	RygelMediaExportDummyContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, RygelMediaExportDummyContainer);
	_g_object_unref0 (self->file);
	_g_object_unref0 (self->children);
	G_OBJECT_CLASS (rygel_media_export_dummy_container_parent_class)->finalize (obj);
}


GType rygel_media_export_dummy_container_get_type (void) {
	static volatile gsize rygel_media_export_dummy_container_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_dummy_container_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportDummyContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_dummy_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportDummyContainer), 0, (GInstanceInitFunc) rygel_media_export_dummy_container_instance_init, NULL };
		GType rygel_media_export_dummy_container_type_id;
		rygel_media_export_dummy_container_type_id = g_type_register_static (RYGEL_TYPE_NULL_CONTAINER, "RygelMediaExportDummyContainer", &g_define_type_info, 0);
		g_once_init_leave (&rygel_media_export_dummy_container_type_id__volatile, rygel_media_export_dummy_container_type_id);
	}
	return rygel_media_export_dummy_container_type_id__volatile;
}



