/* rygel-media-export-dummy-container.c generated by valac 0.56.19, 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.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-media-export.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "rygel-server.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 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;
enum  {
	RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER_0_PROPERTY,
	RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER_NUM_PROPERTIES
};
static GParamSpec* rygel_media_export_dummy_container_properties[RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

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

struct _RygelMediaExportDummyContainerClass {
	RygelMediaExportTrackableDbContainerClass parent_class;
};

static gpointer rygel_media_export_dummy_container_parent_class = NULL;

VALA_EXTERN GType rygel_media_export_dummy_container_get_type (void) G_GNUC_CONST ;
VALA_EXTERN RygelMediaExportDummyContainer* rygel_media_export_dummy_container_new (GFile* file,
                                                                        RygelMediaContainer* parent);
VALA_EXTERN RygelMediaExportDummyContainer* rygel_media_export_dummy_container_construct (GType object_type,
                                                                              GFile* file,
                                                                              RygelMediaContainer* parent);
VALA_EXTERN void rygel_media_export_dummy_container_seen (RygelMediaExportDummyContainer* self,
                                              GFile* file);
static void rygel_media_export_dummy_container_finalize (GObject * obj);
static GType rygel_media_export_dummy_container_get_type_once (void);

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;
	RygelMediaExportMediaCache* cache = NULL;
	RygelMediaExportMediaCache* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	guint32 object_update_id = 0U;
	guint32 container_update_id = 0U;
	guint32 total_deleted_child_count = 0U;
	RygelMediaExportMediaCache* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	guint32 _tmp8_ = 0U;
	guint32 _tmp9_ = 0U;
	guint32 _tmp10_ = 0U;
	GFile* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (file != NULL, NULL);
	g_return_val_if_fail (parent != NULL, NULL);
	_tmp0_ = rygel_media_export_media_cache_get_default ();
	cache = _tmp0_;
	_tmp1_ = rygel_media_export_media_cache_get_id (file);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_file_get_basename (file);
	_tmp4_ = _tmp3_;
	self = (RygelMediaExportDummyContainer*) rygel_media_export_trackable_db_container_construct (object_type, _tmp2_, _tmp4_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp5_ = ((RygelMediaExportDBContainer*) self)->media_db;
	_tmp6_ = rygel_media_object_get_id ((RygelMediaObject*) self);
	_tmp7_ = _tmp6_;
	rygel_media_export_media_cache_get_track_properties (_tmp5_, _tmp7_, &_tmp8_, &_tmp9_, &_tmp10_);
	object_update_id = _tmp8_;
	container_update_id = _tmp9_;
	total_deleted_child_count = _tmp10_;
	rygel_media_object_set_object_update_id ((RygelMediaObject*) self, (guint) object_update_id);
	((RygelMediaContainer*) self)->update_id = container_update_id;
	((RygelMediaContainer*) self)->total_deleted_child_count = (gint64) total_deleted_child_count;
	rygel_media_object_set_parent_ref ((RygelMediaObject*) self, parent);
	_tmp11_ = _g_object_ref0 (file);
	_g_object_unref0 (self->file);
	self->file = _tmp11_;
	_tmp12_ = g_file_get_uri (file);
	_tmp13_ = _tmp12_;
	rygel_media_object_add_uri ((RygelMediaObject*) self, _tmp13_);
	_g_free0 (_tmp13_);
	{
		GeeArrayList* _tmp14_ = NULL;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		GeeArrayList* _tmp17_;
		GeeArrayList* _tmp18_;
		GeeList* _tmp19_;
		gint _tmp20_;
		gint _tmp21_;
		_tmp15_ = rygel_media_object_get_id ((RygelMediaObject*) self);
		_tmp16_ = _tmp15_;
		_tmp17_ = rygel_media_export_media_cache_get_child_ids (cache, _tmp16_, &_inner_error0_);
		_tmp14_ = _tmp17_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp18_ = _tmp14_;
		_tmp14_ = NULL;
		_g_object_unref0 (self->children);
		self->children = (GeeList*) _tmp18_;
		_tmp19_ = self->children;
		_tmp20_ = gee_collection_get_size ((GeeCollection*) _tmp19_);
		_tmp21_ = _tmp20_;
		rygel_media_container_set_child_count ((RygelMediaContainer*) self, _tmp21_);
		_g_object_unref0 (_tmp14_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GeeArrayList* _tmp22_;
		g_clear_error (&_inner_error0_);
		_tmp22_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
		_g_object_unref0 (self->children);
		self->children = (GeeList*) _tmp22_;
		rygel_media_container_set_child_count ((RygelMediaContainer*) self, 0);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (cache);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_g_object_unref0 (cache);
	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_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	_tmp0_ = self->children;
	_tmp1_ = rygel_media_export_media_cache_get_id (file);
	_tmp2_ = _tmp1_;
	gee_collection_remove ((GeeCollection*) _tmp0_, _tmp2_);
	_g_free0 (_tmp2_);
}

static void
rygel_media_export_dummy_container_class_init (RygelMediaExportDummyContainerClass * klass,
                                               gpointer klass_data)
{
	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,
                                                  gpointer klass)
{
}

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

 G_GNUC_NO_INLINE static GType
rygel_media_export_dummy_container_get_type_once (void)
{
	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_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, "RygelMediaExportDummyContainer", &g_define_type_info, 0);
	return rygel_media_export_dummy_container_type_id;
}

GType
rygel_media_export_dummy_container_get_type (void)
{
	static volatile gsize rygel_media_export_dummy_container_type_id__once = 0;
	if (g_once_init_enter (&rygel_media_export_dummy_container_type_id__once)) {
		GType rygel_media_export_dummy_container_type_id;
		rygel_media_export_dummy_container_type_id = rygel_media_export_dummy_container_get_type_once ();
		g_once_init_leave (&rygel_media_export_dummy_container_type_id__once, rygel_media_export_dummy_container_type_id);
	}
	return rygel_media_export_dummy_container_type_id__once;
}

