/* rygel-root-device.c generated by valac 0.15.1.36-84b2b, the Vala compiler
 * generated from rygel-root-device.vala, do not modify */

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


#define RYGEL_TYPE_ROOT_DEVICE (rygel_root_device_get_type ())
#define RYGEL_ROOT_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_ROOT_DEVICE, RygelRootDevice))
#define RYGEL_ROOT_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_ROOT_DEVICE, RygelRootDeviceClass))
#define RYGEL_IS_ROOT_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_ROOT_DEVICE))
#define RYGEL_IS_ROOT_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_ROOT_DEVICE))
#define RYGEL_ROOT_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_ROOT_DEVICE, RygelRootDeviceClass))

typedef struct _RygelRootDevice RygelRootDevice;
typedef struct _RygelRootDeviceClass RygelRootDeviceClass;
typedef struct _RygelRootDevicePrivate RygelRootDevicePrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define RYGEL_TYPE_PLUGIN (rygel_plugin_get_type ())
#define RYGEL_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_PLUGIN, RygelPlugin))
#define RYGEL_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_PLUGIN, RygelPluginClass))
#define RYGEL_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_PLUGIN))
#define RYGEL_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_PLUGIN))
#define RYGEL_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_PLUGIN, RygelPluginClass))

typedef struct _RygelPlugin RygelPlugin;
typedef struct _RygelPluginClass RygelPluginClass;
typedef struct _RygelPluginPrivate RygelPluginPrivate;

#define RYGEL_TYPE_RESOURCE_INFO (rygel_resource_info_get_type ())
#define RYGEL_RESOURCE_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_RESOURCE_INFO, RygelResourceInfo))
#define RYGEL_RESOURCE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_RESOURCE_INFO, RygelResourceInfoClass))
#define RYGEL_IS_RESOURCE_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_RESOURCE_INFO))
#define RYGEL_IS_RESOURCE_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_RESOURCE_INFO))
#define RYGEL_RESOURCE_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_RESOURCE_INFO, RygelResourceInfoClass))

typedef struct _RygelResourceInfo RygelResourceInfo;
typedef struct _RygelResourceInfoClass RygelResourceInfoClass;

#define RYGEL_TYPE_ICON_INFO (rygel_icon_info_get_type ())
#define RYGEL_ICON_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_ICON_INFO, RygelIconInfo))
#define RYGEL_ICON_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_ICON_INFO, RygelIconInfoClass))
#define RYGEL_IS_ICON_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_ICON_INFO))
#define RYGEL_IS_ICON_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_ICON_INFO))
#define RYGEL_ICON_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_ICON_INFO, RygelIconInfoClass))

typedef struct _RygelIconInfo RygelIconInfo;
typedef struct _RygelIconInfoClass RygelIconInfoClass;
typedef struct _RygelResourceInfoPrivate RygelResourceInfoPrivate;
#define _rygel_resource_info_unref0(var) ((var == NULL) ? NULL : (var = (rygel_resource_info_unref (var), NULL)))

struct _RygelRootDevice {
	GUPnPRootDevice parent_instance;
	RygelRootDevicePrivate * priv;
	GeeArrayList* services;
};

struct _RygelRootDeviceClass {
	GUPnPRootDeviceClass parent_class;
};

struct _RygelPlugin {
	GUPnPResourceFactory parent_instance;
	RygelPluginPrivate * priv;
	gchar* name;
	gchar* title;
	gchar* description;
	gchar* desc_path;
	GeeArrayList* resource_infos;
	GeeArrayList* icon_infos;
	GeeArrayList* default_icons;
};

struct _RygelPluginClass {
	GUPnPResourceFactoryClass parent_class;
};

struct _RygelResourceInfo {
	GTypeInstance parent_instance;
	volatile int ref_count;
	RygelResourceInfoPrivate * priv;
	gchar* upnp_type;
	gchar* upnp_id;
	gchar* description_path;
	GType type;
};

struct _RygelResourceInfoClass {
	GTypeClass parent_class;
	void (*finalize) (RygelResourceInfo *self);
};


static gpointer rygel_root_device_parent_class = NULL;

GType rygel_root_device_get_type (void) G_GNUC_CONST;
enum  {
	RYGEL_ROOT_DEVICE_DUMMY_PROPERTY
};
GType rygel_plugin_get_type (void) G_GNUC_CONST;
RygelRootDevice* rygel_root_device_new (GUPnPContext* context, RygelPlugin* plugin, GUPnPXMLDoc* description_doc, const gchar* description_path, const gchar* description_dir);
RygelRootDevice* rygel_root_device_construct (GType object_type, GUPnPContext* context, RygelPlugin* plugin, GUPnPXMLDoc* description_doc, const gchar* description_path, const gchar* description_dir);
gpointer rygel_resource_info_ref (gpointer instance);
void rygel_resource_info_unref (gpointer instance);
GParamSpec* rygel_param_spec_resource_info (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_value_set_resource_info (GValue* value, gpointer v_object);
void rygel_value_take_resource_info (GValue* value, gpointer v_object);
gpointer rygel_value_get_resource_info (const GValue* value);
GType rygel_resource_info_get_type (void) G_GNUC_CONST;
gpointer rygel_icon_info_ref (gpointer instance);
void rygel_icon_info_unref (gpointer instance);
GParamSpec* rygel_param_spec_icon_info (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_value_set_icon_info (GValue* value, gpointer v_object);
void rygel_value_take_icon_info (GValue* value, gpointer v_object);
gpointer rygel_value_get_icon_info (const GValue* value);
GType rygel_icon_info_get_type (void) G_GNUC_CONST;
static void rygel_root_device_finalize (GObject* obj);


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


RygelRootDevice* rygel_root_device_construct (GType object_type, GUPnPContext* context, RygelPlugin* plugin, GUPnPXMLDoc* description_doc, const gchar* description_path, const gchar* description_dir) {
	RygelRootDevice * self = NULL;
	GUPnPContext* _tmp0_;
	RygelPlugin* _tmp1_;
	GUPnPXMLDoc* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_val_if_fail (context != NULL, NULL);
	g_return_val_if_fail (plugin != NULL, NULL);
	g_return_val_if_fail (description_doc != NULL, NULL);
	g_return_val_if_fail (description_path != NULL, NULL);
	g_return_val_if_fail (description_dir != NULL, NULL);
	_tmp0_ = context;
	_tmp1_ = plugin;
	_tmp2_ = description_doc;
	_tmp3_ = description_path;
	_tmp4_ = description_dir;
	self = (RygelRootDevice*) g_object_new (object_type, "context", _tmp0_, "resource-factory", _tmp1_, "description-doc", _tmp2_, "description-path", _tmp3_, "description-dir", _tmp4_, NULL);
	if (self != NULL) {
		GeeArrayList* _tmp5_;
		_tmp5_ = gee_array_list_new (GUPNP_TYPE_SERVICE_INFO, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
		_g_object_unref0 (self->services);
		self->services = _tmp5_;
		{
			RygelPlugin* _tmp6_;
			GeeArrayList* _tmp7_;
			GeeArrayList* _tmp8_;
			GeeArrayList* _info_list;
			GeeArrayList* _tmp9_;
			gint _tmp10_;
			gint _tmp11_;
			gint _info_size;
			gint _info_index;
			_tmp6_ = plugin;
			_tmp7_ = _tmp6_->resource_infos;
			_tmp8_ = _g_object_ref0 (_tmp7_);
			_info_list = _tmp8_;
			_tmp9_ = _info_list;
			_tmp10_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp9_);
			_tmp11_ = _tmp10_;
			_info_size = _tmp11_;
			_info_index = -1;
			while (TRUE) {
				gint _tmp12_;
				gint _tmp13_;
				gint _tmp14_;
				GeeArrayList* _tmp15_;
				gint _tmp16_;
				gpointer _tmp17_ = NULL;
				RygelResourceInfo* info;
				RygelResourceInfo* _tmp18_;
				GType _tmp19_;
				gboolean _tmp20_ = FALSE;
				_tmp12_ = _info_index;
				_info_index = _tmp12_ + 1;
				_tmp13_ = _info_index;
				_tmp14_ = _info_size;
				if (!(_tmp13_ < _tmp14_)) {
					break;
				}
				_tmp15_ = _info_list;
				_tmp16_ = _info_index;
				_tmp17_ = gee_abstract_list_get ((GeeAbstractList*) _tmp15_, _tmp16_);
				info = (RygelResourceInfo*) _tmp17_;
				_tmp18_ = info;
				_tmp19_ = _tmp18_->type;
				_tmp20_ = g_type_is_a (_tmp19_, GUPNP_TYPE_SERVICE);
				if (_tmp20_) {
					RygelResourceInfo* _tmp21_;
					const gchar* _tmp22_;
					GUPnPServiceInfo* _tmp23_ = NULL;
					GUPnPServiceInfo* service;
					GeeArrayList* _tmp24_;
					GUPnPServiceInfo* _tmp25_;
					_tmp21_ = info;
					_tmp22_ = _tmp21_->upnp_type;
					_tmp23_ = gupnp_device_info_get_service ((GUPnPDeviceInfo*) self, _tmp22_);
					service = _tmp23_;
					_tmp24_ = self->services;
					_tmp25_ = service;
					gee_abstract_collection_add ((GeeAbstractCollection*) _tmp24_, _tmp25_);
					_g_object_unref0 (service);
				}
				_rygel_resource_info_unref0 (info);
			}
			_g_object_unref0 (_info_list);
		}
	}
	return self;
}


RygelRootDevice* rygel_root_device_new (GUPnPContext* context, RygelPlugin* plugin, GUPnPXMLDoc* description_doc, const gchar* description_path, const gchar* description_dir) {
	return rygel_root_device_construct (RYGEL_TYPE_ROOT_DEVICE, context, plugin, description_doc, description_path, description_dir);
}


static void rygel_root_device_class_init (RygelRootDeviceClass * klass) {
	rygel_root_device_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = rygel_root_device_finalize;
}


static void rygel_root_device_instance_init (RygelRootDevice * self) {
}


static void rygel_root_device_finalize (GObject* obj) {
	RygelRootDevice * self;
	self = RYGEL_ROOT_DEVICE (obj);
	_g_object_unref0 (self->services);
	G_OBJECT_CLASS (rygel_root_device_parent_class)->finalize (obj);
}


/**
 * Represents a Root device.
 */
GType rygel_root_device_get_type (void) {
	static volatile gsize rygel_root_device_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_root_device_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelRootDeviceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_root_device_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelRootDevice), 0, (GInstanceInitFunc) rygel_root_device_instance_init, NULL };
		GType rygel_root_device_type_id;
		rygel_root_device_type_id = g_type_register_static (GUPNP_TYPE_ROOT_DEVICE, "RygelRootDevice", &g_define_type_info, 0);
		g_once_init_leave (&rygel_root_device_type_id__volatile, rygel_root_device_type_id);
	}
	return rygel_root_device_type_id__volatile;
}



