/* rygel-thumbnailer.c generated by valac 0.32.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-core.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>


#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_THUMBNAIL (rygel_thumbnail_get_type ())
#define RYGEL_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_THUMBNAIL, RygelThumbnail))
#define RYGEL_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_THUMBNAIL, RygelThumbnailClass))
#define RYGEL_IS_THUMBNAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_THUMBNAIL))
#define RYGEL_IS_THUMBNAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_THUMBNAIL))
#define RYGEL_THUMBNAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_THUMBNAIL, RygelThumbnailClass))

typedef struct _RygelThumbnail RygelThumbnail;
typedef struct _RygelThumbnailClass RygelThumbnailClass;

#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;
#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 struct _RygelThumbnailPrivate RygelThumbnailPrivate;

#define RYGEL_TYPE_MEDIA_RESOURCE (rygel_media_resource_get_type ())
#define RYGEL_MEDIA_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_RESOURCE, RygelMediaResource))
#define RYGEL_MEDIA_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_RESOURCE, RygelMediaResourceClass))
#define RYGEL_IS_MEDIA_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_RESOURCE))
#define RYGEL_IS_MEDIA_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_RESOURCE))
#define RYGEL_MEDIA_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_RESOURCE, RygelMediaResourceClass))

typedef struct _RygelMediaResource RygelMediaResource;
typedef struct _RygelMediaResourceClass RygelMediaResourceClass;

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

struct _RygelThumbnail {
	RygelIconInfo parent_instance;
	RygelThumbnailPrivate * priv;
	gchar* dlna_profile;
};

struct _RygelThumbnailClass {
	RygelIconInfoClass parent_class;
	RygelMediaResource* (*get_resource) (RygelThumbnail* self, const gchar* protocol, gint index);
};


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;

GQuark thumbnailer_error_quark (void);
GType rygel_thumbnailer_get_type (void) G_GNUC_CONST;
GType rygel_thumbnail_get_type (void) G_GNUC_CONST;
GType rygel_dbus_thumbnailer_get_type (void) G_GNUC_CONST;
#define RYGEL_THUMBNAILER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_TYPE_THUMBNAILER, RygelThumbnailerPrivate))
enum  {
	RYGEL_THUMBNAILER_DUMMY_PROPERTY
};
static RygelThumbnailer* rygel_thumbnailer_new (GError** error);
static RygelThumbnailer* rygel_thumbnailer_construct (GType object_type, GError** error);
RygelThumbnail* rygel_thumbnail_new (const gchar* mime_type, const gchar* dlna_profile, const gchar* file_extension);
RygelThumbnail* rygel_thumbnail_construct (GType object_type, const gchar* mime_type, const gchar* dlna_profile, const gchar* file_extension);
RygelDbusThumbnailer* rygel_dbus_thumbnailer_new (const gchar* flavor, GError** error);
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);
RygelThumbnailer* rygel_thumbnailer_get_default (void);
RygelThumbnail* rygel_thumbnailer_get_thumbnail (RygelThumbnailer* self, const gchar* uri, const gchar* mime_type, GError** error);
void rygel_dbus_thumbnailer_queue_thumbnail_task (RygelDbusThumbnailer* self, const gchar* uri, const gchar* mime);
GType rygel_media_resource_get_type (void) G_GNUC_CONST;
static void rygel_thumbnailer_finalize (GObject* obj);


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


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_ = NULL;
	RygelThumbnail* _tmp1_ = NULL;
	RygelThumbnail* _tmp2_ = NULL;
	RygelThumbnail* _tmp3_ = NULL;
	RygelThumbnail* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	GError * _inner_error_ = 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_ = NULL;
		RygelDbusThumbnailer* _tmp9_ = NULL;
		RygelDbusThumbnailer* _tmp10_ = NULL;
		_tmp8_ = rygel_dbus_thumbnailer_new ("normal", &_inner_error_);
		_tmp7_ = _tmp8_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch80_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 __finally80;
	__catch80_g_error:
	{
		GError* _error_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_g_error_free0 (_error_);
	}
	__finally80:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		if (_inner_error_->domain == THUMBNAILER_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (self);
			return NULL;
		} else {
			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;
		}
	}
	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* result = NULL;
	gboolean _tmp0_ = FALSE;
	RygelThumbnailer* _tmp7_ = NULL;
	RygelThumbnailer* _tmp8_ = NULL;
	GError * _inner_error_ = NULL;
	_tmp0_ = rygel_thumbnailer_first_time;
	if (_tmp0_) {
		{
			RygelThumbnailer* _tmp1_ = NULL;
			RygelThumbnailer* _tmp2_ = NULL;
			RygelThumbnailer* _tmp3_ = NULL;
			_tmp2_ = rygel_thumbnailer_new (&_inner_error_);
			_tmp1_ = _tmp2_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				if (_inner_error_->domain == THUMBNAILER_ERROR) {
					goto __catch81_thumbnailer_error;
				}
				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;
			}
			_tmp3_ = _tmp1_;
			_tmp1_ = NULL;
			_g_object_unref0 (rygel_thumbnailer_thumbnailer);
			rygel_thumbnailer_thumbnailer = _tmp3_;
			_g_object_unref0 (_tmp1_);
		}
		goto __finally81;
		__catch81_thumbnailer_error:
		{
			GError* err = NULL;
			const gchar* _tmp4_ = NULL;
			GError* _tmp5_ = NULL;
			const gchar* _tmp6_ = NULL;
			err = _inner_error_;
			_inner_error_ = NULL;
			_tmp4_ = _ ("No thumbnailer available: %s");
			_tmp5_ = err;
			_tmp6_ = _tmp5_->message;
			g_warning (_tmp4_, _tmp6_);
			_g_error_free0 (err);
		}
		__finally81:
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			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;
		}
		rygel_thumbnailer_first_time = FALSE;
	}
	_tmp7_ = rygel_thumbnailer_thumbnailer;
	_tmp8_ = _g_object_ref0 (_tmp7_);
	result = _tmp8_;
	return result;
}


RygelThumbnail* rygel_thumbnailer_get_thumbnail (RygelThumbnailer* self, const gchar* uri, const gchar* mime_type, GError** error) {
	RygelThumbnail* result = NULL;
	GFile* file = NULL;
	const gchar* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	GFile* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	GFileInfo* info = NULL;
	GFile* _tmp6_ = NULL;
	GFileInfo* _tmp7_ = NULL;
	gchar* path = NULL;
	GFileInfo* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gboolean failed = FALSE;
	GFileInfo* _tmp10_ = NULL;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp15_ = FALSE;
	gboolean _tmp16_ = FALSE;
	RygelDbusThumbnailer* _tmp17_ = NULL;
	const gchar* _tmp25_ = NULL;
	const gchar* _tmp28_ = NULL;
	GFile* _tmp29_ = NULL;
	GFileInfo* _tmp30_ = NULL;
	GFile* _tmp31_ = NULL;
	GFileInfo* _tmp32_ = NULL;
	GFileInfo* _tmp33_ = NULL;
	GFileInfo* _tmp34_ = NULL;
	gboolean _tmp35_ = FALSE;
	RygelThumbnail* thumbnail = NULL;
	RygelThumbnail* _tmp38_ = NULL;
	const gchar* _tmp39_ = NULL;
	RygelThumbnail* _tmp40_ = NULL;
	const gchar* _tmp41_ = NULL;
	RygelThumbnail* _tmp42_ = NULL;
	const gchar* _tmp43_ = NULL;
	RygelThumbnail* _tmp44_ = NULL;
	RygelThumbnail* _tmp45_ = NULL;
	RygelThumbnail* _tmp46_ = NULL;
	gint _tmp47_ = 0;
	RygelThumbnail* _tmp48_ = NULL;
	RygelThumbnail* _tmp49_ = NULL;
	gint _tmp50_ = 0;
	RygelThumbnail* _tmp51_ = NULL;
	RygelThumbnail* _tmp52_ = NULL;
	gint _tmp53_ = 0;
	gchar* _tmp54_ = NULL;
	const gchar* _tmp55_ = NULL;
	gchar* _tmp56_ = NULL;
	RygelThumbnail* _tmp57_ = NULL;
	gchar* _tmp58_ = NULL;
	RygelThumbnail* _tmp59_ = NULL;
	GFileInfo* _tmp60_ = NULL;
	guint64 _tmp61_ = 0ULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	_tmp1_ = g_file_new_for_uri (_tmp0_);
	file = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = g_file_is_native (_tmp2_);
	if (!_tmp3_) {
		const gchar* _tmp4_ = NULL;
		GError* _tmp5_ = NULL;
		_tmp4_ = _ ("Thumbnailing not supported");
		_tmp5_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _tmp4_);
		_inner_error_ = _tmp5_;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp6_ = file;
	_tmp7_ = g_file_query_info (_tmp6_, G_FILE_ATTRIBUTE_THUMBNAIL_PATH "," G_FILE_ATTRIBUTE_THUMBNAILING_FAILED, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error_);
	info = _tmp7_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp8_ = info;
	_tmp9_ = g_file_info_get_attribute_as_string (_tmp8_, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
	path = _tmp9_;
	_tmp10_ = info;
	_tmp11_ = g_file_info_get_attribute_boolean (_tmp10_, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
	failed = _tmp11_;
	_tmp12_ = failed;
	if (_tmp12_) {
		const gchar* _tmp13_ = NULL;
		GError* _tmp14_ = NULL;
		_tmp13_ = _ ("No thumbnail available");
		_tmp14_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _tmp13_);
		_inner_error_ = _tmp14_;
		g_propagate_error (error, _inner_error_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp17_ = self->priv->thumbler;
	if (_tmp17_ != NULL) {
		const gchar* _tmp18_ = NULL;
		_tmp18_ = path;
		_tmp16_ = _tmp18_ == NULL;
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		const gchar* _tmp19_ = NULL;
		_tmp19_ = mime_type;
		_tmp15_ = _tmp19_ != NULL;
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		RygelDbusThumbnailer* _tmp20_ = NULL;
		const gchar* _tmp21_ = NULL;
		const gchar* _tmp22_ = NULL;
		const gchar* _tmp23_ = NULL;
		GError* _tmp24_ = NULL;
		_tmp20_ = self->priv->thumbler;
		_tmp21_ = uri;
		_tmp22_ = mime_type;
		rygel_dbus_thumbnailer_queue_thumbnail_task (_tmp20_, _tmp21_, _tmp22_);
		_tmp23_ = _ ("No thumbnail available. Generation requested.");
		_tmp24_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _tmp23_);
		_inner_error_ = _tmp24_;
		g_propagate_error (error, _inner_error_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp25_ = path;
	if (_tmp25_ == NULL) {
		const gchar* _tmp26_ = NULL;
		GError* _tmp27_ = NULL;
		_tmp26_ = _ ("No thumbnail available");
		_tmp27_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _tmp26_);
		_inner_error_ = _tmp27_;
		g_propagate_error (error, _inner_error_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp28_ = path;
	_tmp29_ = g_file_new_for_path (_tmp28_);
	_g_object_unref0 (file);
	file = _tmp29_;
	_tmp31_ = file;
	_tmp32_ = g_file_query_info (_tmp31_, G_FILE_ATTRIBUTE_ACCESS_CAN_READ "," G_FILE_ATTRIBUTE_STANDARD_SIZE, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error_);
	_tmp30_ = _tmp32_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp33_ = _tmp30_;
	_tmp30_ = NULL;
	_g_object_unref0 (info);
	info = _tmp33_;
	_tmp34_ = info;
	_tmp35_ = g_file_info_get_attribute_boolean (_tmp34_, G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
	if (!_tmp35_) {
		const gchar* _tmp36_ = NULL;
		GError* _tmp37_ = NULL;
		_tmp36_ = _ ("No thumbnail available");
		_tmp37_ = g_error_new_literal (THUMBNAILER_ERROR, THUMBNAILER_ERROR_NO_THUMBNAIL, _tmp36_);
		_inner_error_ = _tmp37_;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (_tmp30_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp38_ = self->priv->template;
	_tmp39_ = ((RygelIconInfo*) _tmp38_)->mime_type;
	_tmp40_ = self->priv->template;
	_tmp41_ = _tmp40_->dlna_profile;
	_tmp42_ = self->priv->template;
	_tmp43_ = ((RygelIconInfo*) _tmp42_)->file_extension;
	_tmp44_ = rygel_thumbnail_new (_tmp39_, _tmp41_, _tmp43_);
	thumbnail = _tmp44_;
	_tmp45_ = thumbnail;
	_tmp46_ = self->priv->template;
	_tmp47_ = ((RygelIconInfo*) _tmp46_)->width;
	((RygelIconInfo*) _tmp45_)->width = _tmp47_;
	_tmp48_ = thumbnail;
	_tmp49_ = self->priv->template;
	_tmp50_ = ((RygelIconInfo*) _tmp49_)->height;
	((RygelIconInfo*) _tmp48_)->height = _tmp50_;
	_tmp51_ = thumbnail;
	_tmp52_ = self->priv->template;
	_tmp53_ = ((RygelIconInfo*) _tmp52_)->depth;
	((RygelIconInfo*) _tmp51_)->depth = _tmp53_;
	_tmp55_ = path;
	_tmp56_ = g_filename_to_uri (_tmp55_, NULL, &_inner_error_);
	_tmp54_ = _tmp56_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_rygel_icon_info_unref0 (thumbnail);
		_g_object_unref0 (_tmp30_);
		_g_free0 (path);
		_g_object_unref0 (info);
		_g_object_unref0 (file);
		return NULL;
	}
	_tmp57_ = thumbnail;
	_tmp58_ = _tmp54_;
	_tmp54_ = NULL;
	_g_free0 (((RygelIconInfo*) _tmp57_)->uri);
	((RygelIconInfo*) _tmp57_)->uri = _tmp58_;
	_tmp59_ = thumbnail;
	_tmp60_ = info;
	_tmp61_ = g_file_info_get_attribute_uint64 (_tmp60_, G_FILE_ATTRIBUTE_STANDARD_SIZE);
	((RygelIconInfo*) _tmp59_)->size = (gint64) _tmp61_;
	result = thumbnail;
	_g_free0 (_tmp54_);
	_g_object_unref0 (_tmp30_);
	_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) {
	gboolean _tmp0_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = available;
	if (!_tmp0_) {
		const gchar* _tmp1_ = NULL;
		_g_object_unref0 (self->priv->thumbler);
		self->priv->thumbler = NULL;
		_tmp1_ = _ ("No D-Bus thumbnailer available");
		g_message ("rygel-thumbnailer.vala:132: %s", _tmp1_);
	}
}


static void rygel_thumbnailer_class_init (RygelThumbnailerClass * klass) {
	rygel_thumbnailer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelThumbnailerPrivate));
	G_OBJECT_CLASS (klass)->finalize = rygel_thumbnailer_finalize;
}


static void rygel_thumbnailer_instance_init (RygelThumbnailer * self) {
	self->priv = RYGEL_THUMBNAILER_GET_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.
 */
GType rygel_thumbnailer_get_type (void) {
	static volatile gsize rygel_thumbnailer_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_thumbnailer_type_id__volatile)) {
		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);
		g_once_init_leave (&rygel_thumbnailer_type_id__volatile, rygel_thumbnailer_type_id);
	}
	return rygel_thumbnailer_type_id__volatile;
}



