/* rygel-lms-root-container.c generated by valac 0.30.0.35-2c9e8, 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 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 <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;
#define _rygel_lms_database_unref0(var) ((var == NULL) ? NULL : (var = (rygel_lms_database_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)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (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;

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

struct _RygelLMSRootContainerClass {
	RygelSimpleContainerClass parent_class;
};

struct _RygelLMSRootContainerPrivate {
	RygelLMSDatabase* lms_db;
};

typedef enum  {
	RYGEL_LMS_DATABASE_ERROR_OPEN,
	RYGEL_LMS_DATABASE_ERROR_PREPARE,
	RYGEL_LMS_DATABASE_ERROR_BIND,
	RYGEL_LMS_DATABASE_ERROR_STEP,
	RYGEL_LMS_DATABASE_ERROR_NOT_FOUND
} RygelLMSDatabaseError;
#define RYGEL_LMS_DATABASE_ERROR rygel_lms_database_error_quark ()

static gpointer rygel_lms_root_container_parent_class = NULL;

GType rygel_lms_root_container_get_type (void) G_GNUC_CONST;
gpointer rygel_lms_database_ref (gpointer instance);
void rygel_lms_database_unref (gpointer instance);
GParamSpec* rygel_lms_param_spec_database (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_lms_value_set_database (GValue* value, gpointer v_object);
void rygel_lms_value_take_database (GValue* value, gpointer v_object);
gpointer rygel_lms_value_get_database (const GValue* value);
GType rygel_lms_database_get_type (void) G_GNUC_CONST;
#define RYGEL_LMS_ROOT_CONTAINER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_LMS_TYPE_ROOT_CONTAINER, RygelLMSRootContainerPrivate))
enum  {
	RYGEL_LMS_ROOT_CONTAINER_DUMMY_PROPERTY
};
RygelLMSRootContainer* rygel_lms_root_container_new (void);
RygelLMSRootContainer* rygel_lms_root_container_construct (GType object_type);
GQuark rygel_lms_database_error_quark (void);
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;
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;
GType rygel_lms_all_videos_get_type (void) G_GNUC_CONST;
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;
static void rygel_lms_root_container_finalize (GObject* obj);


RygelLMSRootContainer* rygel_lms_root_container_construct (GType object_type) {
	RygelLMSRootContainer * self = NULL;
	RygelMetaConfig* config = NULL;
	RygelMetaConfig* _tmp0_ = NULL;
	gchar* title = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp6_ = NULL;
	GError * _inner_error_ = NULL;
	_tmp0_ = rygel_meta_config_get_default ();
	config = _tmp0_;
	_tmp1_ = _ ("Shared media");
	_tmp2_ = g_strdup (_tmp1_);
	title = _tmp2_;
	{
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		_tmp4_ = rygel_configuration_get_string ((RygelConfiguration*) config, "LightMediaScanner", "title", &_inner_error_);
		_tmp3_ = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp5_ = _tmp3_;
		_tmp3_ = NULL;
		_g_free0 (title);
		title = _tmp5_;
		_g_free0 (_tmp3_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_g_error_free0 (_error_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (title);
		_g_object_unref0 (config);
		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;
	}
	_tmp6_ = title;
	self = (RygelLMSRootContainer*) rygel_simple_container_construct_root (object_type, _tmp6_);
	{
		RygelLMSDatabase* _tmp7_ = NULL;
		RygelLMSDatabase* _tmp8_ = NULL;
		RygelLMSDatabase* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		RygelLMSDatabase* _tmp11_ = NULL;
		RygelLMSMusicRoot* _tmp12_ = NULL;
		RygelLMSMusicRoot* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		RygelLMSDatabase* _tmp15_ = NULL;
		RygelLMSAllVideos* _tmp16_ = NULL;
		RygelLMSAllVideos* _tmp17_ = NULL;
		const gchar* _tmp18_ = NULL;
		RygelLMSDatabase* _tmp19_ = NULL;
		RygelLMSImageRoot* _tmp20_ = NULL;
		RygelLMSImageRoot* _tmp21_ = NULL;
		_tmp8_ = rygel_lms_database_new (&_inner_error_);
		_tmp7_ = _tmp8_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == RYGEL_LMS_DATABASE_ERROR) {
				goto __catch1_rygel_lms_database_error;
			}
			_g_free0 (title);
			_g_object_unref0 (config);
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp9_ = _tmp7_;
		_tmp7_ = NULL;
		_rygel_lms_database_unref0 (self->priv->lms_db);
		self->priv->lms_db = _tmp9_;
		_tmp10_ = _ ("Music");
		_tmp11_ = self->priv->lms_db;
		_tmp12_ = rygel_lms_music_root_new ("music", (RygelMediaContainer*) self, _tmp10_, _tmp11_);
		_tmp13_ = _tmp12_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp13_);
		_g_object_unref0 (_tmp13_);
		_tmp14_ = _ ("Videos");
		_tmp15_ = self->priv->lms_db;
		_tmp16_ = rygel_lms_all_videos_new ("all-videos", (RygelMediaContainer*) self, _tmp14_, _tmp15_);
		_tmp17_ = _tmp16_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp17_);
		_g_object_unref0 (_tmp17_);
		_tmp18_ = _ ("Pictures");
		_tmp19_ = self->priv->lms_db;
		_tmp20_ = rygel_lms_image_root_new ("images", (RygelMediaContainer*) self, _tmp18_, _tmp19_);
		_tmp21_ = _tmp20_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp21_);
		_g_object_unref0 (_tmp21_);
		_rygel_lms_database_unref0 (_tmp7_);
	}
	goto __finally1;
	__catch1_rygel_lms_database_error:
	{
		GError* e = NULL;
		GError* _tmp22_ = NULL;
		const gchar* _tmp23_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp22_ = e;
		_tmp23_ = _tmp22_->message;
		g_warning ("rygel-lms-root-container.vala:58: %s\n", _tmp23_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (title);
		_g_object_unref0 (config);
		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;
	}
	_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) {
	rygel_lms_root_container_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelLMSRootContainerPrivate));
	G_OBJECT_CLASS (klass)->finalize = rygel_lms_root_container_finalize;
}


static void rygel_lms_root_container_instance_init (RygelLMSRootContainer * self) {
	self->priv = RYGEL_LMS_ROOT_CONTAINER_GET_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);
	_rygel_lms_database_unref0 (self->priv->lms_db);
	G_OBJECT_CLASS (rygel_lms_root_container_parent_class)->finalize (obj);
}


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



