/* rygel-lms-root-container.c generated by valac 0.56.1, the Vala compiler
 * generated from rygel-lms-root-container.vala, do not modify */

/*
 * Copyright (C) 2013 Intel Corporation.
 *
 * Author: Jussi Kukkonen <jussi.kukkonen@intel.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-lms.h"
#include <glib.h>
#include "rygel-core.h"
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include "rygel-server.h"

enum  {
	RYGEL_LMS_ROOT_CONTAINER_0_PROPERTY,
	RYGEL_LMS_ROOT_CONTAINER_NUM_PROPERTIES
};
static GParamSpec* rygel_lms_root_container_properties[RYGEL_LMS_ROOT_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))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _RygelLMSRootContainerPrivate {
	RygelLMSDatabase* lms_db;
};

static gint RygelLMSRootContainer_private_offset;
static gpointer rygel_lms_root_container_parent_class = NULL;

static void rygel_lms_root_container_finalize (GObject * obj);
static GType rygel_lms_root_container_get_type_once (void);

static inline gpointer
rygel_lms_root_container_get_instance_private (RygelLMSRootContainer* self)
{
	return G_STRUCT_MEMBER_P (self, RygelLMSRootContainer_private_offset);
}

RygelLMSRootContainer*
rygel_lms_root_container_construct (GType object_type)
{
	RygelLMSRootContainer * self = NULL;
	RygelMetaConfig* config = NULL;
	RygelMetaConfig* _tmp0_;
	gchar* title = NULL;
	gchar* _tmp1_;
	const gchar* _tmp5_;
	GError* _inner_error0_ = NULL;
	_tmp0_ = rygel_meta_config_get_default ();
	config = _tmp0_;
	_tmp1_ = g_strdup (_ ("Shared media"));
	title = _tmp1_;
	{
		gchar* _tmp2_ = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = rygel_configuration_get_string ((RygelConfiguration*) config, RYGEL_LMS_PLUGIN_NAME, "title", &_inner_error0_);
		_tmp2_ = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp4_ = _tmp2_;
		_tmp2_ = NULL;
		_g_free0 (title);
		title = _tmp4_;
		_g_free0 (_tmp2_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (title);
		_g_object_unref0 (config);
		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;
	}
	_tmp5_ = title;
	self = (RygelLMSRootContainer*) rygel_simple_container_construct_root (object_type, _tmp5_);
	{
		RygelLMSDatabase* _tmp6_ = NULL;
		RygelLMSDatabase* _tmp7_;
		RygelLMSDatabase* _tmp8_;
		RygelLMSDatabase* _tmp9_;
		RygelLMSMusicRoot* _tmp10_;
		RygelLMSMusicRoot* _tmp11_;
		RygelLMSDatabase* _tmp12_;
		RygelLMSAllVideos* _tmp13_;
		RygelLMSAllVideos* _tmp14_;
		RygelLMSDatabase* _tmp15_;
		RygelLMSImageRoot* _tmp16_;
		RygelLMSImageRoot* _tmp17_;
		_tmp7_ = rygel_lms_database_new (&_inner_error0_);
		_tmp6_ = _tmp7_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp8_ = _tmp6_;
		_tmp6_ = NULL;
		_g_object_unref0 (self->priv->lms_db);
		self->priv->lms_db = _tmp8_;
		_tmp9_ = self->priv->lms_db;
		_tmp10_ = rygel_lms_music_root_new ("music", (RygelMediaContainer*) self, _ ("Music"), _tmp9_);
		_tmp11_ = _tmp10_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp11_);
		_g_object_unref0 (_tmp11_);
		_tmp12_ = self->priv->lms_db;
		_tmp13_ = rygel_lms_all_videos_new ("all-videos", (RygelMediaContainer*) self, _ ("Videos"), _tmp12_);
		_tmp14_ = _tmp13_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp14_);
		_g_object_unref0 (_tmp14_);
		_tmp15_ = self->priv->lms_db;
		_tmp16_ = rygel_lms_image_root_new ("images", (RygelMediaContainer*) self, _ ("Pictures"), _tmp15_);
		_tmp17_ = _tmp16_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp17_);
		_g_object_unref0 (_tmp17_);
		_g_object_unref0 (_tmp6_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp18_;
		const gchar* _tmp19_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp18_ = e;
		_tmp19_ = _tmp18_->message;
		g_warning ("rygel-lms-root-container.vala:57: %s\n", _tmp19_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (title);
		_g_object_unref0 (config);
		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_free0 (title);
	_g_object_unref0 (config);
	return self;
}

RygelLMSRootContainer*
rygel_lms_root_container_new (void)
{
	return rygel_lms_root_container_construct (RYGEL_LMS_TYPE_ROOT_CONTAINER);
}

static void
rygel_lms_root_container_class_init (RygelLMSRootContainerClass * klass,
                                     gpointer klass_data)
{
	rygel_lms_root_container_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelLMSRootContainer_private_offset);
	G_OBJECT_CLASS (klass)->finalize = rygel_lms_root_container_finalize;
}

static void
rygel_lms_root_container_instance_init (RygelLMSRootContainer * self,
                                        gpointer klass)
{
	self->priv = rygel_lms_root_container_get_instance_private (self);
	self->priv->lms_db = NULL;
}

static void
rygel_lms_root_container_finalize (GObject * obj)
{
	RygelLMSRootContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_LMS_TYPE_ROOT_CONTAINER, RygelLMSRootContainer);
	_g_object_unref0 (self->priv->lms_db);
	G_OBJECT_CLASS (rygel_lms_root_container_parent_class)->finalize (obj);
}

static GType
rygel_lms_root_container_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelLMSRootContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_lms_root_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelLMSRootContainer), 0, (GInstanceInitFunc) rygel_lms_root_container_instance_init, NULL };
	GType rygel_lms_root_container_type_id;
	rygel_lms_root_container_type_id = g_type_register_static (RYGEL_TYPE_SIMPLE_CONTAINER, "RygelLMSRootContainer", &g_define_type_info, 0);
	RygelLMSRootContainer_private_offset = g_type_add_instance_private (rygel_lms_root_container_type_id, sizeof (RygelLMSRootContainerPrivate));
	return rygel_lms_root_container_type_id;
}

GType
rygel_lms_root_container_get_type (void)
{
	static volatile gsize rygel_lms_root_container_type_id__once = 0;
	if (g_once_init_enter (&rygel_lms_root_container_type_id__once)) {
		GType rygel_lms_root_container_type_id;
		rygel_lms_root_container_type_id = rygel_lms_root_container_get_type_once ();
		g_once_init_leave (&rygel_lms_root_container_type_id__once, rygel_lms_root_container_type_id);
	}
	return rygel_lms_root_container_type_id__once;
}

