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

/*
 * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
 * Copyright (C) 2008 Nokia Corporation.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *                               <zeeshan.ali@nokia.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 <stdlib.h>
#include <string.h>
#include <rygel-core.h>


#define RYGEL_TRACKER_TYPE_ROOT_CONTAINER (rygel_tracker_root_container_get_type ())
#define RYGEL_TRACKER_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TRACKER_TYPE_ROOT_CONTAINER, RygelTrackerRootContainer))
#define RYGEL_TRACKER_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TRACKER_TYPE_ROOT_CONTAINER, RygelTrackerRootContainerClass))
#define RYGEL_TRACKER_IS_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TRACKER_TYPE_ROOT_CONTAINER))
#define RYGEL_TRACKER_IS_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TRACKER_TYPE_ROOT_CONTAINER))
#define RYGEL_TRACKER_ROOT_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TRACKER_TYPE_ROOT_CONTAINER, RygelTrackerRootContainerClass))

typedef struct _RygelTrackerRootContainer RygelTrackerRootContainer;
typedef struct _RygelTrackerRootContainerClass RygelTrackerRootContainerClass;
typedef struct _RygelTrackerRootContainerPrivate RygelTrackerRootContainerPrivate;

#define RYGEL_TRACKER_TYPE_CATEGORY_CONTAINER (rygel_tracker_category_container_get_type ())
#define RYGEL_TRACKER_CATEGORY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TRACKER_TYPE_CATEGORY_CONTAINER, RygelTrackerCategoryContainer))
#define RYGEL_TRACKER_CATEGORY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TRACKER_TYPE_CATEGORY_CONTAINER, RygelTrackerCategoryContainerClass))
#define RYGEL_TRACKER_IS_CATEGORY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TRACKER_TYPE_CATEGORY_CONTAINER))
#define RYGEL_TRACKER_IS_CATEGORY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TRACKER_TYPE_CATEGORY_CONTAINER))
#define RYGEL_TRACKER_CATEGORY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TRACKER_TYPE_CATEGORY_CONTAINER, RygelTrackerCategoryContainerClass))

typedef struct _RygelTrackerCategoryContainer RygelTrackerCategoryContainer;
typedef struct _RygelTrackerCategoryContainerClass RygelTrackerCategoryContainerClass;

#define RYGEL_TRACKER_TYPE_MUSIC (rygel_tracker_music_get_type ())
#define RYGEL_TRACKER_MUSIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TRACKER_TYPE_MUSIC, RygelTrackerMusic))
#define RYGEL_TRACKER_MUSIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TRACKER_TYPE_MUSIC, RygelTrackerMusicClass))
#define RYGEL_TRACKER_IS_MUSIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TRACKER_TYPE_MUSIC))
#define RYGEL_TRACKER_IS_MUSIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TRACKER_TYPE_MUSIC))
#define RYGEL_TRACKER_MUSIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TRACKER_TYPE_MUSIC, RygelTrackerMusicClass))

typedef struct _RygelTrackerMusic RygelTrackerMusic;
typedef struct _RygelTrackerMusicClass RygelTrackerMusicClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define RYGEL_TRACKER_TYPE_VIDEOS (rygel_tracker_videos_get_type ())
#define RYGEL_TRACKER_VIDEOS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TRACKER_TYPE_VIDEOS, RygelTrackerVideos))
#define RYGEL_TRACKER_VIDEOS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TRACKER_TYPE_VIDEOS, RygelTrackerVideosClass))
#define RYGEL_TRACKER_IS_VIDEOS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TRACKER_TYPE_VIDEOS))
#define RYGEL_TRACKER_IS_VIDEOS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TRACKER_TYPE_VIDEOS))
#define RYGEL_TRACKER_VIDEOS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TRACKER_TYPE_VIDEOS, RygelTrackerVideosClass))

typedef struct _RygelTrackerVideos RygelTrackerVideos;
typedef struct _RygelTrackerVideosClass RygelTrackerVideosClass;

#define RYGEL_TRACKER_TYPE_PICTURES (rygel_tracker_pictures_get_type ())
#define RYGEL_TRACKER_PICTURES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TRACKER_TYPE_PICTURES, RygelTrackerPictures))
#define RYGEL_TRACKER_PICTURES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TRACKER_TYPE_PICTURES, RygelTrackerPicturesClass))
#define RYGEL_TRACKER_IS_PICTURES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TRACKER_TYPE_PICTURES))
#define RYGEL_TRACKER_IS_PICTURES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TRACKER_TYPE_PICTURES))
#define RYGEL_TRACKER_PICTURES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TRACKER_TYPE_PICTURES, RygelTrackerPicturesClass))

typedef struct _RygelTrackerPictures RygelTrackerPictures;
typedef struct _RygelTrackerPicturesClass RygelTrackerPicturesClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _RygelTrackerRootContainer {
	RygelSimpleContainer parent_instance;
	RygelTrackerRootContainerPrivate * priv;
};

struct _RygelTrackerRootContainerClass {
	RygelSimpleContainerClass parent_class;
};


static gpointer rygel_tracker_root_container_parent_class = NULL;

GType rygel_tracker_root_container_get_type (void) G_GNUC_CONST;
enum  {
	RYGEL_TRACKER_ROOT_CONTAINER_DUMMY_PROPERTY
};
RygelTrackerRootContainer* rygel_tracker_root_container_new (const gchar* title);
RygelTrackerRootContainer* rygel_tracker_root_container_construct (GType object_type, const gchar* title);
static gboolean rygel_tracker_root_container_get_bool_config_without_error (RygelTrackerRootContainer* self, const gchar* key);
RygelTrackerMusic* rygel_tracker_music_new (const gchar* id, RygelMediaContainer* parent, const gchar* title);
RygelTrackerMusic* rygel_tracker_music_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title);
GType rygel_tracker_category_container_get_type (void) G_GNUC_CONST;
GType rygel_tracker_music_get_type (void) G_GNUC_CONST;
RygelTrackerVideos* rygel_tracker_videos_new (const gchar* id, RygelMediaContainer* parent, const gchar* title);
RygelTrackerVideos* rygel_tracker_videos_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title);
GType rygel_tracker_videos_get_type (void) G_GNUC_CONST;
RygelTrackerPictures* rygel_tracker_pictures_new (const gchar* id, RygelMediaContainer* parent, const gchar* title);
RygelTrackerPictures* rygel_tracker_pictures_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title);
GType rygel_tracker_pictures_get_type (void) G_GNUC_CONST;


RygelTrackerRootContainer* rygel_tracker_root_container_construct (GType object_type, const gchar* title) {
	RygelTrackerRootContainer * self = NULL;
	const gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp7_ = FALSE;
	g_return_val_if_fail (title != NULL, NULL);
	_tmp0_ = title;
	self = (RygelTrackerRootContainer*) rygel_simple_container_construct_root (object_type, _tmp0_);
	_tmp1_ = rygel_tracker_root_container_get_bool_config_without_error (self, "share-music");
	if (_tmp1_) {
		RygelTrackerMusic* _tmp2_;
		RygelTrackerMusic* _tmp3_;
		_tmp2_ = rygel_tracker_music_new ("Music", (RygelMediaContainer*) self, "Music");
		_tmp3_ = _tmp2_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp3_);
		_g_object_unref0 (_tmp3_);
	}
	_tmp4_ = rygel_tracker_root_container_get_bool_config_without_error (self, "share-videos");
	if (_tmp4_) {
		RygelTrackerVideos* _tmp5_;
		RygelTrackerVideos* _tmp6_;
		_tmp5_ = rygel_tracker_videos_new ("Videos", (RygelMediaContainer*) self, "Videos");
		_tmp6_ = _tmp5_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp6_);
		_g_object_unref0 (_tmp6_);
	}
	_tmp7_ = rygel_tracker_root_container_get_bool_config_without_error (self, "share-pictures");
	if (_tmp7_) {
		RygelTrackerPictures* _tmp8_;
		RygelTrackerPictures* _tmp9_;
		_tmp8_ = rygel_tracker_pictures_new ("Pictures", (RygelMediaContainer*) self, "Pictures");
		_tmp9_ = _tmp8_;
		rygel_simple_container_add_child_container ((RygelSimpleContainer*) self, (RygelMediaContainer*) _tmp9_);
		_g_object_unref0 (_tmp9_);
	}
	return self;
}


RygelTrackerRootContainer* rygel_tracker_root_container_new (const gchar* title) {
	return rygel_tracker_root_container_construct (RYGEL_TRACKER_TYPE_ROOT_CONTAINER, title);
}


static gboolean rygel_tracker_root_container_get_bool_config_without_error (RygelTrackerRootContainer* self, const gchar* key) {
	gboolean result = FALSE;
	gboolean value;
	RygelMetaConfig* _tmp0_ = NULL;
	RygelMetaConfig* config;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	value = TRUE;
	_tmp0_ = rygel_meta_config_get_default ();
	config = _tmp0_;
	{
		const gchar* _tmp1_;
		gboolean _tmp2_ = FALSE;
		gboolean _tmp3_;
		_tmp1_ = key;
		_tmp2_ = rygel_configuration_get_bool ((RygelConfiguration*) config, "Tracker", _tmp1_, &_inner_error_);
		_tmp3_ = _tmp2_;
		if (_inner_error_ != NULL) {
			goto __catch0_g_error;
		}
		value = _tmp3_;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_g_error_free0 (_error_);
	}
	__finally0:
	if (_inner_error_ != NULL) {
		_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 FALSE;
	}
	result = value;
	_g_object_unref0 (config);
	return result;
}


static void rygel_tracker_root_container_class_init (RygelTrackerRootContainerClass * klass) {
	rygel_tracker_root_container_parent_class = g_type_class_peek_parent (klass);
}


static void rygel_tracker_root_container_instance_init (RygelTrackerRootContainer * self) {
}


/**
 * Represents the root container for Tracker media content hierarchy.
 */
GType rygel_tracker_root_container_get_type (void) {
	static volatile gsize rygel_tracker_root_container_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_tracker_root_container_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelTrackerRootContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_tracker_root_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelTrackerRootContainer), 0, (GInstanceInitFunc) rygel_tracker_root_container_instance_init, NULL };
		GType rygel_tracker_root_container_type_id;
		rygel_tracker_root_container_type_id = g_type_register_static (RYGEL_TYPE_SIMPLE_CONTAINER, "RygelTrackerRootContainer", &g_define_type_info, 0);
		g_once_init_leave (&rygel_tracker_root_container_type_id__volatile, rygel_tracker_root_container_type_id);
	}
	return rygel_tracker_root_container_type_id__volatile;
}



