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

/*
 * Copyright (C) 2008 Zeeshan Ali <zeenix@gmail.com>.
 * Copyright (C) 2010-2011 Nokia Corporation.
 * Copyright (C) 2012 Intel Corporation.
 *
 * Author: Zeeshan Ali <zeenix@gmail.com>
 *         Jens Georg <jensg@openismus.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 <glib.h>
#include <glib-object.h>
#include "rygel-server.h"
#include <stdlib.h>
#include <string.h>
#include "rygel-core.h"
#include <glib/gi18n-lib.h>
#include <gio/gio.h>

#define TYPE_THUMBNAILER_ERROR (thumbnailer_error_get_type ())

#define RYGEL_TYPE_THUMBNAILER (rygel_thumbnailer_get_type ())
#define RYGEL_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_THUMBNAILER, RygelThumbnailer))
#define RYGEL_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_THUMBNAILER, RygelThumbnailerClass))
#define RYGEL_IS_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_THUMBNAILER))
#define RYGEL_IS_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_THUMBNAILER))
#define RYGEL_THUMBNAILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_THUMBNAILER, RygelThumbnailerClass))

typedef struct _RygelThumbnailer RygelThumbnailer;
typedef struct _RygelThumbnailerClass RygelThumbnailerClass;
typedef struct _RygelThumbnailerPrivate RygelThumbnailerPrivate;

#define RYGEL_TYPE_DBUS_THUMBNAILER (rygel_dbus_thumbnailer_get_type ())
#define RYGEL_DBUS_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_DBUS_THUMBNAILER, RygelDbusThumbnailer))
#define RYGEL_DBUS_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_DBUS_THUMBNAILER, RygelDbusThumbnailerClass))
#define RYGEL_IS_DBUS_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_DBUS_THUMBNAILER))
#define RYGEL_IS_DBUS_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_DBUS_THUMBNAILER))
#define RYGEL_DBUS_THUMBNAILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_DBUS_THUMBNAILER, RygelDbusThumbnailerClass))

typedef struct _RygelDbusThumbnailer RygelDbusThumbnailer;
typedef struct _RygelDbusThumbnailerClass RygelDbusThumbnailerClass;
enum  {
	RYGEL_THUMBNAILER_0_PROPERTY,
	RYGEL_THUMBNAILER_NUM_PROPERTIES
};
static GParamSpec* rygel_thumbnailer_properties[RYGEL_THUMBNAILER_NUM_PROPERTIES];
#define _rygel_icon_info_unref0(var) ((var == NULL) ? NULL : (var = (rygel_icon_info_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

typedef enum  {
	THUMBNAILER_ERROR_NO_DIR,
	THUMBNAILER_ERROR_NO_THUMBNAIL
} ThumbnailerError;
#define THUMBNAILER_ERROR thumbnailer_error_quark ()

struct _RygelThumbnailer {
	GObject parent_instance;
	RygelThumbnailerPrivate * priv;
};

struct _RygelThumbnailerClass {
	GObjectClass parent_class;
};

struct _RygelThumbnailerPrivate {
	RygelThumbnail* template;
	gchar* extension;
	RygelDbusThumbnailer* thumbler;
};

static gint RygelThumbnailer_private_offset;
static gpointer rygel_thumbnailer_parent_class = NULL;
static RygelThumbnailer* rygel_thumbnailer_thumbnailer;
static RygelThumbnailer* rygel_thumbnailer_thumbnailer = NULL;
static gboolean rygel_thumbnailer_first_time;
static gboolean rygel_thumbnailer_first_time = TRUE;

VALA_EXTERN GQuark thumbnailer_error_quark (void);
GType thumbnailer_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_thumbnailer_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType rygel_dbus_thumbnailer_get_type (void) G_GNUC_CONST ;
static RygelThumbnailer* rygel_thumbnailer_new (GError** error);
static RygelThumbnailer* rygel_thumbnailer_construct (GType object_type,
                                               GError** error);
VALA_EXTERN RygelDbusThumbnailer* rygel_dbus_thumbnailer_new (const gchar* flavor,
                                                  GError** error);
VALA_EXTERN RygelDbusThumbnailer* rygel_dbus_thumbnailer_construct (GType object_type,
                                                        const gchar* flavor,
                                                        GError** error);
static void rygel_thumbnailer_on_dbus_thumbnailer_ready (RygelThumbnailer* self,
                                                  gboolean available);
static void _rygel_thumbnailer_on_dbus_thumbnailer_ready_rygel_dbus_thumbnailer_ready (RygelDbusThumbnailer* _sender,
                                                                                gboolean available,
                                                                                gpointer self);
VALA_EXTERN RygelThumbnailer* rygel_thumbnailer_get_default (void);
VALA_EXTERN RygelThumbnail* rygel_thumbnailer_get_thumbnail (RygelThumbnailer* self,
                                                 const gchar* uri,
                                                 const gchar* mime_type,
                                                 GError** error);
VALA_EXTERN void rygel_dbus_thumbnailer_queue_thumbnail_task (RygelDbusThumbnailer* self,
                                                  const gchar* uri,
                                                  const gchar* mime);
static void rygel_thumbnailer_finalize (GObject * obj);
static GType rygel_thumbnailer_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

GQuark
thumbnailer_error_quark (void)
{
	return g_quark_from_static_string ("thumbnailer-error-quark");
}

static GType
thumbnailer_error_get_type_once (void)
{
	static const GEnumValue values[] = {{THUMBNAILER_ERROR_NO_DIR, "THUMBNAILER_ERROR_NO_DIR", "no-dir"}, {THUMBNAILER_ERROR_NO_THUMBNAIL, "THUMBNAILER_ERROR_NO_THUMBNAIL", "no-thumbnail"}, {0, NULL, NULL}};
	GType thumbnailer_error_type_id;
	thumbnailer_error_type_id = g_enum_register_static ("ThumbnailerError", values);
	return thumbnailer_error_type_id;
}

GType
thumbnailer_error_get_type (void)
{
	static volatile gsize thumbnailer_error_type_id__once = 0;
	if (g_once_init_enter (&thumbnailer_error_type_id__once)) {
		GType thumbnailer_error_type_id;
		thumbnailer_error_type_id = thumbnailer_error_get_type_once ();
		g_once_init_leave (&thumbnailer_error_type_id__once, thumbnailer_error_type_id);
	}
	return thumbnailer_error_type_id__once;
}

static inline gpointer
rygel_thumbnailer_get_instance_private (RygelThumbnailer* self)
{
	return G_STRUCT_MEMBER_P (self, RygelThumbnailer_private_offset);
}

static void
_rygel_thumbnailer_on_dbus_thumbnailer_ready_rygel_dbus_thumbnailer_ready (RygelDbusThumbnailer* _sender,
                                                                           gboolean available,
                                                                           gpointer self)
{
	rygel_thumbnailer_on_dbus_thumbnailer_ready ((RygelThumbnailer*) self, available);
}

static RygelThumbnailer*
rygel_thumbnailer_construct (GType object_type,
                             GError** error)
{
	RygelThumbnailer * self = NULL;
	RygelThumbnail* _tmp0_;
	RygelThumbnail* _tmp1_;
	RygelThumbnail* _tmp2_;
	RygelThumbnail* _tmp3_;
	RygelThumbnail* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	GError* _inner_error0_ = NULL;
	self = (RygelThumbnailer*) g_object_new (object_type, NULL);
	_tmp0_ = rygel_thumbnail_new ("image/png", "PNG_TN", "png");
	_rygel_icon_info_unref0 (self->priv->template);
	self->priv->template = _tmp0_;
	_tmp1_ = self->priv->template;
	((RygelIconInfo*) _tmp1_)->width = 128;
	_tmp2_ = self->priv->template;
	((RygelIconInfo*) _tmp2_)->height = 128;
	_tmp3_ = self->priv->template;
	((RygelIconInfo*) _tmp3_)->depth = 24;
	_tmp4_ = self->priv->template;
	_tmp5_ = ((RygelIconInfo*) _tmp4_)->file_extension;
	_tmp6_ = g_strconcat (".", _tmp5_, NULL);
	_g_free0 (self->priv->extension);
	self->priv->extension = _tmp6_;
	{
		RygelDbusThumbnailer* _tmp7_ = NULL;
		RygelDbusThumbnailer* _tmp8_;
		RygelDbusThumbnailer* _tmp9_;
		RygelDbusThumbnailer* _tmp10_;
		_tmp8_ = rygel_dbus_thumbnailer_new ("normal", &_inner_error0_);
		_tmp7_ = _tmp8_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp9_ = _tmp7_;
		_tmp7_ = NULL;
		_g_object_unref0 (self->priv->thumbler);
		self->priv->thumbler = _tmp9_;
		_tmp10_ = self->priv->thumbler;
		g_signal_connect_object (_tmp10_, "ready", (GCallback) _rygel_thumbnailer_on_dbus_thumbnailer_ready_rygel_dbus_thumbnailer_ready, self, 0);
		_g_object_unref0 (_tmp7_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == THUMBNAILER_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (self);
			return NULL;
		} else {
			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;
		}
	}
	return self;
}

static RygelThumbnailer*
rygel_thumbnailer_new (GError** error)
{
	return rygel_thumbnailer_construct (RYGEL_TYPE_THUMBNAILER, error);
}

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

RygelThumbnailer*
rygel_thumbnailer_get_default (void)
{
	RygelThumbnailer* _tmp5_;
	RygelThumbnailer* _tmp6_;
	GError* _inner_error0_ = NULL;
	RygelThumbnailer* result;
	if (rygel_thumbnailer_first_time) {
		{
			RygelThumbnailer* _tmp0_ = NULL;
			RygelThumbnailer* _tmp1_;
			RygelThumbnailer* _tmp2_;
			_tmp1_ = rygel_thumbnailer_new (&_inner_error0_);
			_tmp0_ = _tmp1_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == THUMBNAILER_ERROR) {
					goto __catch0_thumbnailer_error;
				}
				g_critical ("file %s: line %d: unexpected 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;
			}
			_tmp2_ = _tmp0_;
			_tmp0_ = NULL;
			_g_object_unref0 (rygel_thumbnailer_thumbnailer);
			rygel_thumbnailer_thumbnailer = _tmp2_;
			_g_object_unref0 (_tmp0_);
		}
		goto __finally0;
		__catch0_thumbnailer_error:
		{
			GError* err = NULL;
			GError* _tmp3_;
			const gchar* _tmp4_;
			err = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp3_ = err;
			_tmp4_ = _tmp3_->message;
			g_warning (_ ("No thumbnailer available: %s"), _tmp4_);
			_g_error_free0 (err);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			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;
		}
		rygel_thumbnailer_first_time = FALSE;
	}
	_tmp5_ = rygel_thumbnailer_thumbnailer;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	result = _tmp6_;
	return result;
}

RygelThumbnail*
rygel_thumbnailer_get_thumbnail (RygelThumbnailer* self,
                                 const gchar* uri,
                                 const gchar* mime_type,
                                 GError** error)
{
	GFile* file = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GFileInfo* info = NULL;
	GFile* _tmp3_;
	GFileInfo* _tmp4_;
	gchar* path = NULL;
	GFileInfo* _tmp5_;
	gchar* _tmp6_;
	gboolean failed = FALSE;
	GFileInfo* _tmp7_;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	RygelDbusThumbnailer* _tmp11_;
	const gchar* _tmp15_;
	const gchar* _tmp17_;
	GFile* _tmp18_;
	GFileInfo* _tmp19_ = NULL;
	GFile* _tmp20_;
	GFileInfo* _tmp21_;
	GFileInfo* _tmp22_;
	GFileInfo* _tmp23_;
	RygelThumbnail* thumbnail = NULL;
	RygelThumbnail* _tmp25_;
	const gchar* _tmp26_;
	RygelThumbnail* _tmp27_;
	const gchar* _tmp28_;
	RygelThumbnail* _tmp29_;
	const gchar* _tmp30_;
	RygelThumbnail* _tmp31_;
	RygelThumbnail* _tmp32_;
	RygelThumbnail* _tmp33_;
	RygelThumbnail* _tmp34_;
	RygelThumbnail* _tmp35_;
	RygelThumbnail* _tmp36_;
	RygelThumbnail* _tmp37_;
	gchar* _tmp38_ = NULL;
	const gchar* _tmp39_;
	gchar* _tmp40_;
	RygelThumbnail* _tmp41_;
	gchar* _tmp42_;
	RygelThumbnail* _tmp43_;
	GFileInfo* _tmp44_;
	GError* _inner_error0_ = NULL;
	RygelThumbnail* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = g_file_new_for_uri (uri);
	file = _tmp0_;
	_tmp1_ = file;
	if (!g_file_is_native (_tmp1_)) {
		GError* _tmp2_;
		_tmp2_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _ ("Thumbnailing not supported"));
		_inner_error0_ = _tmp2_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp3_ = file;
	_tmp4_ = g_file_query_info (_tmp3_, G_FILE_ATTRIBUTE_THUMBNAIL_PATH "," G_FILE_ATTRIBUTE_THUMBNAILING_FAILED, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
	info = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp5_ = info;
	_tmp6_ = g_file_info_get_attribute_as_string (_tmp5_, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
	path = _tmp6_;
	_tmp7_ = info;
	failed = g_file_info_get_attribute_boolean (_tmp7_, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
	if (failed) {
		GError* _tmp8_;
		_tmp8_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _ ("No thumbnail available"));
		_inner_error0_ = _tmp8_;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp11_ = self->priv->thumbler;
	if (_tmp11_ != NULL) {
		const gchar* _tmp12_;
		_tmp12_ = path;
		_tmp10_ = _tmp12_ == NULL;
	} else {
		_tmp10_ = FALSE;
	}
	if (_tmp10_) {
		_tmp9_ = mime_type != NULL;
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		RygelDbusThumbnailer* _tmp13_;
		GError* _tmp14_;
		_tmp13_ = self->priv->thumbler;
		rygel_dbus_thumbnailer_queue_thumbnail_task (_tmp13_, uri, mime_type);
		_tmp14_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _ ("No thumbnail available. Generation requested."));
		_inner_error0_ = _tmp14_;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp15_ = path;
	if (_tmp15_ == NULL) {
		GError* _tmp16_;
		_tmp16_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _ ("No thumbnail available"));
		_inner_error0_ = _tmp16_;
		g_propagate_error (error, _inner_error0_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp17_ = path;
	_tmp18_ = g_file_new_for_path (_tmp17_);
	_g_object_unref0 (file);
	file = _tmp18_;
	_tmp20_ = file;
	_tmp21_ = g_file_query_info (_tmp20_, G_FILE_ATTRIBUTE_ACCESS_CAN_READ "," G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
	_tmp19_ = _tmp21_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp22_ = _tmp19_;
	_tmp19_ = NULL;
	_g_object_unref0 (info);
	info = _tmp22_;
	_tmp23_ = info;
	if (!g_file_info_get_attribute_boolean (_tmp23_, G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) {
		GError* _tmp24_;
		_tmp24_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _ ("No thumbnail available"));
		_inner_error0_ = _tmp24_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (_tmp19_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp25_ = self->priv->template;
	_tmp26_ = ((RygelIconInfo*) _tmp25_)->mime_type;
	_tmp27_ = self->priv->template;
	_tmp28_ = _tmp27_->dlna_profile;
	_tmp29_ = self->priv->template;
	_tmp30_ = ((RygelIconInfo*) _tmp29_)->file_extension;
	_tmp31_ = rygel_thumbnail_new (_tmp26_, _tmp28_, _tmp30_);
	thumbnail = _tmp31_;
	_tmp32_ = thumbnail;
	_tmp33_ = self->priv->template;
	((RygelIconInfo*) _tmp32_)->width = ((RygelIconInfo*) _tmp33_)->width;
	_tmp34_ = thumbnail;
	_tmp35_ = self->priv->template;
	((RygelIconInfo*) _tmp34_)->height = ((RygelIconInfo*) _tmp35_)->height;
	_tmp36_ = thumbnail;
	_tmp37_ = self->priv->template;
	((RygelIconInfo*) _tmp36_)->depth = ((RygelIconInfo*) _tmp37_)->depth;
	_tmp39_ = path;
	_tmp40_ = g_filename_to_uri (_tmp39_, NULL, &_inner_error0_);
	_tmp38_ = _tmp40_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_rygel_icon_info_unref0 (thumbnail);
		_g_object_unref0 (_tmp19_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp41_ = thumbnail;
	_tmp42_ = _tmp38_;
	_tmp38_ = NULL;
	_g_free0 (((RygelIconInfo*) _tmp41_)->uri);
	((RygelIconInfo*) _tmp41_)->uri = _tmp42_;
	_tmp43_ = thumbnail;
	_tmp44_ = info;
	((RygelIconInfo*) _tmp43_)->size = (gint64) g_file_info_get_attribute_uint64 (_tmp44_, G_FILE_ATTRIBUTE_STANDARD_SIZE);
	result = thumbnail;
	_g_free0 (_tmp38_);
	_g_object_unref0 (_tmp19_);
	_g_free0 (path);
	_g_object_unref0 (info);
	_g_object_unref0 (file);
	return result;
}

static void
rygel_thumbnailer_on_dbus_thumbnailer_ready (RygelThumbnailer* self,
                                             gboolean available)
{
	g_return_if_fail (self != NULL);
	if (!available) {
		_g_object_unref0 (self->priv->thumbler);
		self->priv->thumbler = NULL;
		g_message ("rygel-thumbnailer.vala:132: %s", _ ("No D-Bus thumbnailer available"));
	}
}

static void
rygel_thumbnailer_class_init (RygelThumbnailerClass * klass,
                              gpointer klass_data)
{
	rygel_thumbnailer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelThumbnailer_private_offset);
	G_OBJECT_CLASS (klass)->finalize = rygel_thumbnailer_finalize;
}

static void
rygel_thumbnailer_instance_init (RygelThumbnailer * self,
                                 gpointer klass)
{
	self->priv = rygel_thumbnailer_get_instance_private (self);
	self->priv->thumbler = NULL;
}

static void
rygel_thumbnailer_finalize (GObject * obj)
{
	RygelThumbnailer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_THUMBNAILER, RygelThumbnailer);
	_rygel_icon_info_unref0 (self->priv->template);
	_g_free0 (self->priv->extension);
	_g_object_unref0 (self->priv->thumbler);
	G_OBJECT_CLASS (rygel_thumbnailer_parent_class)->finalize (obj);
}

/**
 * Provides thumbnails for images and videos.
 */
static GType
rygel_thumbnailer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelThumbnailerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_thumbnailer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelThumbnailer), 0, (GInstanceInitFunc) rygel_thumbnailer_instance_init, NULL };
	GType rygel_thumbnailer_type_id;
	rygel_thumbnailer_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelThumbnailer", &g_define_type_info, 0);
	RygelThumbnailer_private_offset = g_type_add_instance_private (rygel_thumbnailer_type_id, sizeof (RygelThumbnailerPrivate));
	return rygel_thumbnailer_type_id;
}

GType
rygel_thumbnailer_get_type (void)
{
	static volatile gsize rygel_thumbnailer_type_id__once = 0;
	if (g_once_init_enter (&rygel_thumbnailer_type_id__once)) {
		GType rygel_thumbnailer_type_id;
		rygel_thumbnailer_type_id = rygel_thumbnailer_get_type_once ();
		g_once_init_leave (&rygel_thumbnailer_type_id__once, rygel_thumbnailer_type_id);
	}
	return rygel_thumbnailer_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

