/* rygel-lms-root-container.c generated by valac 0.48.5, 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-server.h>
#include <glib-object.h>
#include <rygel-db.h>
#include <glib.h>
#include <rygel-core.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>

#define RYGEL_LMS_TYPE_ROOT_CONTAINER (rygel_lms_root_container_get_type ())
#define RYGEL_LMS_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_LMS_TYPE_ROOT_CONTAINER, RygelLMSRootContainer))
#define RYGEL_LMS_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_LMS_TYPE_ROOT_CONTAINER, RygelLMSRootContainerClass))
#define RYGEL_LMS_IS_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_LMS_TYPE_ROOT_CONTAINER))
#define RYGEL_LMS_IS_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_LMS_TYPE_ROOT_CONTAINER))
#define RYGEL_LMS_ROOT_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_LMS_TYPE_ROOT_CONTAINER, RygelLMSRootContainerClass))

typedef struct _RygelLMSRootContainer RygelLMSRootContainer;
typedef struct _RygelLMSRootContainerClass RygelLMSRootContainerClass;
typedef struct _RygelLMSRootContainerPrivate RygelLMSRootContainerPrivate;

#define RYGEL_LMS_TYPE_DATABASE (rygel_lms_database_get_type ())
#define RYGEL_LMS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_LMS_TYPE_DATABASE, RygelLMSDatabase))
#define RYGEL_LMS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_LMS_TYPE_DATABASE, RygelLMSDatabaseClass))
#define RYGEL_LMS_IS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_LMS_TYPE_DATABASE))
#define RYGEL_LMS_IS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_LMS_TYPE_DATABASE))
#define RYGEL_LMS_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_LMS_TYPE_DATABASE, RygelLMSDatabaseClass))

typedef struct _RygelLMSDatabase RygelLMSDatabase;
typedef struct _RygelLMSDatabaseClass RygelLMSDatabaseClass;
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 RYGEL_LMS_TYPE_MUSIC_ROOT (rygel_lms_music_root_get_type ())
#define RYGEL_LMS_MUSIC_ROOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_LMS_TYPE_MUSIC_ROOT, RygelLMSMusicRoot))
#define RYGEL_LMS_MUSIC_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_LMS_TYPE_MUSIC_ROOT, RygelLMSMusicRootClass))
#define RYGEL_LMS_IS_MUSIC_ROOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_LMS_TYPE_MUSIC_ROOT))
#define RYGEL_LMS_IS_MUSIC_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_LMS_TYPE_MUSIC_ROOT))
#define RYGEL_LMS_MUSIC_ROOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_LMS_TYPE_MUSIC_ROOT, RygelLMSMusicRootClass))

typedef struct _RygelLMSMusicRoot RygelLMSMusicRoot;
typedef struct _RygelLMSMusicRootClass RygelLMSMusicRootClass;

#define RYGEL_LMS_TYPE_CATEGORY_CONTAINER (rygel_lms_category_container_get_type ())
#define RYGEL_LMS_CATEGORY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_LMS_TYPE_CATEGORY_CONTAINER, RygelLMSCategoryContainer))
#define RYGEL_LMS_CATEGORY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_LMS_TYPE_CATEGORY_CONTAINER, RygelLMSCategoryContainerClass))
#define RYGEL_LMS_IS_CATEGORY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_LMS_TYPE_CATEGORY_CONTAINER))
#define RYGEL_LMS_IS_CATEGORY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_LMS_TYPE_CATEGORY_CONTAINER))
#define RYGEL_LMS_CATEGORY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_LMS_TYPE_CATEGORY_CONTAINER, RygelLMSCategoryContainerClass))

typedef struct _RygelLMSCategoryContainer RygelLMSCategoryContainer;
typedef struct _RygelLMSCategoryContainerClass RygelLMSCategoryContainerClass;

#define RYGEL_LMS_TYPE_ALL_VIDEOS (rygel_lms_all_videos_get_type ())
#define RYGEL_LMS_ALL_VIDEOS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_LMS_TYPE_ALL_VIDEOS, RygelLMSAllVideos))
#define RYGEL_LMS_ALL_VIDEOS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_LMS_TYPE_ALL_VIDEOS, RygelLMSAllVideosClass))
#define RYGEL_LMS_IS_ALL_VIDEOS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_LMS_TYPE_ALL_VIDEOS))
#define RYGEL_LMS_IS_ALL_VIDEOS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_LMS_TYPE_ALL_VIDEOS))
#define RYGEL_LMS_ALL_VIDEOS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_LMS_TYPE_ALL_VIDEOS, RygelLMSAllVideosClass))

typedef struct _RygelLMSAllVideos RygelLMSAllVideos;
typedef struct _RygelLMSAllVideosClass RygelLMSAllVideosClass;

#define RYGEL_LMS_TYPE_IMAGE_ROOT (rygel_lms_image_root_get_type ())
#define RYGEL_LMS_IMAGE_ROOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_LMS_TYPE_IMAGE_ROOT, RygelLMSImageRoot))
#define RYGEL_LMS_IMAGE_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_LMS_TYPE_IMAGE_ROOT, RygelLMSImageRootClass))
#define RYGEL_LMS_IS_IMAGE_ROOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_LMS_TYPE_IMAGE_ROOT))
#define RYGEL_LMS_IS_IMAGE_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_LMS_TYPE_IMAGE_ROOT))
#define RYGEL_LMS_IMAGE_ROOT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_LMS_TYPE_IMAGE_ROOT, RygelLMSImageRootClass))

typedef struct _RygelLMSImageRoot RygelLMSImageRoot;
typedef struct _RygelLMSImageRootClass RygelLMSImageRootClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _RygelLMSRootContainer {
	RygelSimpleContainer parent_instance;
	RygelLMSRootContainerPrivate * priv;
};

struct _RygelLMSRootContainerClass {
	RygelSimpleContainerClass parent_class;
};

struct _RygelLMSRootContainerPrivate {
	RygelLMSDatabase* lms_db;
};

static gint RygelLMSRootContainer_private_offset;
static gpointer rygel_lms_root_container_parent_class = NULL;

GType rygel_lms_root_container_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelLMSRootContainer, g_object_unref)
GType rygel_lms_database_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelLMSDatabase, g_object_unref)
RygelLMSRootContainer* rygel_lms_root_container_new (void);
RygelLMSRootContainer* rygel_lms_root_container_construct (GType object_type);
#define RYGEL_LMS_PLUGIN_NAME "LMS"
RygelLMSDatabase* rygel_lms_database_new (GError** error);
RygelLMSDatabase* rygel_lms_database_construct (GType object_type,
                                                GError** error);
RygelLMSMusicRoot* rygel_lms_music_root_new (const gchar* id,
                                             RygelMediaContainer* parent,
                                             const gchar* title,
                                             RygelLMSDatabase* lms_db);
RygelLMSMusicRoot* rygel_lms_music_root_construct (GType object_type,
                                                   const gchar* id,
                                                   RygelMediaContainer* parent,
                                                   const gchar* title,
                                                   RygelLMSDatabase* lms_db);
GType rygel_lms_music_root_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelLMSMusicRoot, g_object_unref)
RygelLMSAllVideos* rygel_lms_all_videos_new (const gchar* id,
                                             RygelMediaContainer* parent,
                                             const gchar* title,
                                             RygelLMSDatabase* lms_db);
RygelLMSAllVideos* rygel_lms_all_videos_construct (GType object_type,
                                                   const gchar* id,
                                                   RygelMediaContainer* parent,
                                                   const gchar* title,
                                                   RygelLMSDatabase* lms_db);
GType rygel_lms_category_container_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelLMSCategoryContainer, g_object_unref)
GType rygel_lms_all_videos_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelLMSAllVideos, g_object_unref)
RygelLMSImageRoot* rygel_lms_image_root_new (const gchar* id,
                                             RygelMediaContainer* parent,
                                             const gchar* title,
                                             RygelLMSDatabase* lms_db);
RygelLMSImageRoot* rygel_lms_image_root_construct (GType object_type,
                                                   const gchar* id,
                                                   RygelMediaContainer* parent,
                                                   const gchar* title,
                                                   RygelLMSDatabase* lms_db);
GType rygel_lms_image_root_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelLMSImageRoot, g_object_unref)
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__volatile = 0;
	if (g_once_init_enter (&rygel_lms_root_container_type_id__volatile)) {
		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__volatile, rygel_lms_root_container_type_id);
	}
	return rygel_lms_root_container_type_id__volatile;
}

