/* rygel-dbus-thumbnailer.c generated by valac 0.42.1.67-6c68, the Vala compiler
 * generated from rygel-dbus-thumbnailer.vala, do not modify */

/*
 * Copyright (C) 2011 Nokia Corporation.
 *
 * 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-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib/gi18n-lib.h>

#define RYGEL_TYPE_TUMBLER (rygel_tumbler_get_type ())
#define RYGEL_TUMBLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_TUMBLER, RygelTumbler))
#define RYGEL_IS_TUMBLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_TUMBLER))
#define RYGEL_TUMBLER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RYGEL_TYPE_TUMBLER, RygelTumblerIface))

typedef struct _RygelTumbler RygelTumbler;
typedef struct _RygelTumblerIface RygelTumblerIface;

#define RYGEL_TYPE_TUMBLER_PROXY (rygel_tumbler_proxy_get_type ())
typedef GDBusProxy RygelTumblerProxy;
typedef GDBusProxyClass RygelTumblerProxyClass;
typedef struct _rygel_tumbler_QueueReadyData rygel_tumbler_QueueReadyData;
#define _g_free0(var) (var = (g_free (var), NULL))

#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;
typedef struct _RygelDbusThumbnailerPrivate RygelDbusThumbnailerPrivate;

#define RYGEL_FREE_DESKTOP_TYPE_DBUS_OBJECT (rygel_free_desktop_dbus_object_get_type ())
#define RYGEL_FREE_DESKTOP_DBUS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_FREE_DESKTOP_TYPE_DBUS_OBJECT, RygelFreeDesktopDBusObject))
#define RYGEL_FREE_DESKTOP_IS_DBUS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_FREE_DESKTOP_TYPE_DBUS_OBJECT))
#define RYGEL_FREE_DESKTOP_DBUS_OBJECT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RYGEL_FREE_DESKTOP_TYPE_DBUS_OBJECT, RygelFreeDesktopDBusObjectIface))

typedef struct _RygelFreeDesktopDBusObject RygelFreeDesktopDBusObject;
typedef struct _RygelFreeDesktopDBusObjectIface RygelFreeDesktopDBusObjectIface;

#define RYGEL_FREE_DESKTOP_TYPE_DBUS_OBJECT_PROXY (rygel_free_desktop_dbus_object_proxy_get_type ())
enum  {
	RYGEL_DBUS_THUMBNAILER_0_PROPERTY,
	RYGEL_DBUS_THUMBNAILER_NUM_PROPERTIES
};
static GParamSpec* rygel_dbus_thumbnailer_properties[RYGEL_DBUS_THUMBNAILER_NUM_PROPERTIES];
#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)))
enum  {
	RYGEL_DBUS_THUMBNAILER_READY_SIGNAL,
	RYGEL_DBUS_THUMBNAILER_NUM_SIGNALS
};
static guint rygel_dbus_thumbnailer_signals[RYGEL_DBUS_THUMBNAILER_NUM_SIGNALS] = {0};

struct _RygelTumblerIface {
	GTypeInterface parent_iface;
	void (*Queue) (RygelTumbler* self, gchar** uris, gint uris_length1, gchar** mime_types, gint mime_types_length1, const gchar* flavor, const gchar* sheduler, guint handle, GAsyncReadyCallback _callback_, gpointer _user_data_);
	guint (*Queue_finish) (RygelTumbler* self, GAsyncResult* _res_, GError** error);
};

struct _rygel_tumbler_QueueReadyData {
	GDBusMethodInvocation* _invocation_;
	gchar** uris;
	gint uris_length1;
	gchar** mime_types;
	gint mime_types_length1;
	gchar* flavor;
	gchar* sheduler;
	guint handle;
};

struct _RygelDbusThumbnailer {
	GObject parent_instance;
	RygelDbusThumbnailerPrivate * priv;
};

struct _RygelDbusThumbnailerClass {
	GObjectClass parent_class;
};

struct _RygelFreeDesktopDBusObjectIface {
	GTypeInterface parent_iface;
	void (*list_activatable_names) (RygelFreeDesktopDBusObject* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	gchar** (*list_activatable_names_finish) (RygelFreeDesktopDBusObject* self, GAsyncResult* _res_, gint* result_length1, GError** error);
};

struct _RygelDbusThumbnailerPrivate {
	RygelTumbler* tumbler;
	GeeArrayList* uris;
	GeeArrayList* mimes;
	guint timeout_id;
	gchar* flavor;
	RygelFreeDesktopDBusObject* fdo;
};

static gint RygelDbusThumbnailer_private_offset;
static gpointer rygel_dbus_thumbnailer_parent_class = NULL;

GType rygel_tumbler_proxy_get_type (void) G_GNUC_CONST;
guint rygel_tumbler_register_object (void* object,
                                     GDBusConnection* connection,
                                     const gchar* path,
                                     GError** error);
GType rygel_tumbler_get_type (void) G_GNUC_CONST;
void rygel_tumbler_Queue (RygelTumbler* self,
                          gchar** uris,
                          gint uris_length1,
                          gchar** mime_types,
                          gint mime_types_length1,
                          const gchar* flavor,
                          const gchar* sheduler,
                          guint handle,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_);
guint rygel_tumbler_Queue_finish (RygelTumbler* self,
                                  GAsyncResult* _res_,
                                  GError** error);
static void rygel_tumbler_proxy_g_signal (GDBusProxy* proxy,
                                   const gchar* sender_name,
                                   const gchar* signal_name,
                                   GVariant* parameters);
static void _vala_g_async_ready_callback (GObject *source_object,
                                   GAsyncResult *res,
                                   void *user_data);
static void rygel_tumbler_proxy_Queue_async (RygelTumbler* self,
                                      gchar** uris,
                                      gint uris_length1,
                                      gchar** mime_types,
                                      gint mime_types_length1,
                                      const gchar* flavor,
                                      const gchar* sheduler,
                                      guint handle,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
static guint rygel_tumbler_proxy_Queue_finish (RygelTumbler* self,
                                        GAsyncResult* _res_,
                                        GError** error);
static void rygel_tumbler_proxy_rygel_tumbler_interface_init (RygelTumblerIface* iface);
static void _dbus_rygel_tumbler_Queue (RygelTumbler* self,
                                GVariant* _parameters_,
                                GDBusMethodInvocation* invocation);
static void _dbus_rygel_tumbler_Queue_ready (GObject * source_object,
                                      GAsyncResult * _res_,
                                      gpointer _user_data_);
static void rygel_tumbler_dbus_interface_method_call (GDBusConnection* connection,
                                               const gchar* sender,
                                               const gchar* object_path,
                                               const gchar* interface_name,
                                               const gchar* method_name,
                                               GVariant* parameters,
                                               GDBusMethodInvocation* invocation,
                                               gpointer user_data);
static GVariant* rygel_tumbler_dbus_interface_get_property (GDBusConnection* connection,
                                                     const gchar* sender,
                                                     const gchar* object_path,
                                                     const gchar* interface_name,
                                                     const gchar* property_name,
                                                     GError** error,
                                                     gpointer user_data);
static gboolean rygel_tumbler_dbus_interface_set_property (GDBusConnection* connection,
                                                    const gchar* sender,
                                                    const gchar* object_path,
                                                    const gchar* interface_name,
                                                    const gchar* property_name,
                                                    GVariant* value,
                                                    GError** error,
                                                    gpointer user_data);
static void _rygel_tumbler_unregister_object (gpointer user_data);
GType rygel_dbus_thumbnailer_get_type (void) G_GNUC_CONST;
GType rygel_free_desktop_dbus_object_proxy_get_type (void) G_GNUC_CONST;
guint rygel_free_desktop_dbus_object_register_object (void* object,
                                                      GDBusConnection* connection,
                                                      const gchar* path,
                                                      GError** error);
GType rygel_free_desktop_dbus_object_get_type (void) G_GNUC_CONST;
#define RYGEL_DBUS_THUMBNAILER_THUMBNAILER_IFACE "org.freedesktop.thumbnails.Thumbnailer1"
#define RYGEL_DBUS_THUMBNAILER_THUMBNAILER_SERVICE "/org/freedesktop/thumbnails/Thumbnailer1"
#define RYGEL_DBUS_THUMBNAILER_THUMBNAIL_MAX_QUEUE_SIZE ((guint) 50)
RygelDbusThumbnailer* rygel_dbus_thumbnailer_new (const gchar* flavor,
                                                  GError** error);
RygelDbusThumbnailer* rygel_dbus_thumbnailer_construct (GType object_type,
                                                        const gchar* flavor,
                                                        GError** error);
#define RYGEL_FREE_DESKTOP_DBUS_SERVICE "org.freedesktop.DBus"
#define RYGEL_FREE_DESKTOP_DBUS_OBJECT_PATH "/org/freedesktop/DBus"
void rygel_free_desktop_dbus_object_list_activatable_names (RygelFreeDesktopDBusObject* self,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
gchar** rygel_free_desktop_dbus_object_list_activatable_names_finish (RygelFreeDesktopDBusObject* self,
                                                                      GAsyncResult* _res_,
                                                                      gint* result_length1,
                                                                      GError** error);
static void rygel_dbus_thumbnailer_on_activatable_names (RygelDbusThumbnailer* self,
                                                  GObject* source,
                                                  GAsyncResult* res);
static void _rygel_dbus_thumbnailer_on_activatable_names_gasync_ready_callback (GObject* source_object,
                                                                         GAsyncResult* res,
                                                                         gpointer self);
void rygel_dbus_thumbnailer_queue_thumbnail_task (RygelDbusThumbnailer* self,
                                                  const gchar* uri,
                                                  const gchar* mime);
static gboolean rygel_dbus_thumbnailer_on_timeout (RygelDbusThumbnailer* self);
static gboolean _rygel_dbus_thumbnailer_on_timeout_gsource_func (gpointer self);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      int stack_length,
                                      const gchar* needle);
static void rygel_dbus_thumbnailer_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array,
                          gint array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gint array_length,
                       GDestroyNotify destroy_func);

static const GDBusArgInfo _rygel_tumbler_dbus_arg_info_Queue_uris = {-1, "uris", "as"};
static const GDBusArgInfo _rygel_tumbler_dbus_arg_info_Queue_mime_types = {-1, "mime_types", "as"};
static const GDBusArgInfo _rygel_tumbler_dbus_arg_info_Queue_flavor = {-1, "flavor", "s"};
static const GDBusArgInfo _rygel_tumbler_dbus_arg_info_Queue_sheduler = {-1, "sheduler", "s"};
static const GDBusArgInfo _rygel_tumbler_dbus_arg_info_Queue_handle = {-1, "handle", "u"};
static const GDBusArgInfo _rygel_tumbler_dbus_arg_info_Queue_result = {-1, "result", "u"};
static const GDBusArgInfo * const _rygel_tumbler_dbus_arg_info_Queue_in[] = {&_rygel_tumbler_dbus_arg_info_Queue_uris, &_rygel_tumbler_dbus_arg_info_Queue_mime_types, &_rygel_tumbler_dbus_arg_info_Queue_flavor, &_rygel_tumbler_dbus_arg_info_Queue_sheduler, &_rygel_tumbler_dbus_arg_info_Queue_handle, NULL};
static const GDBusArgInfo * const _rygel_tumbler_dbus_arg_info_Queue_out[] = {&_rygel_tumbler_dbus_arg_info_Queue_result, NULL};
static const GDBusMethodInfo _rygel_tumbler_dbus_method_info_Queue = {-1, "Queue", (GDBusArgInfo **) (&_rygel_tumbler_dbus_arg_info_Queue_in), (GDBusArgInfo **) (&_rygel_tumbler_dbus_arg_info_Queue_out)};
static const GDBusMethodInfo * const _rygel_tumbler_dbus_method_info[] = {&_rygel_tumbler_dbus_method_info_Queue, NULL};
static const GDBusSignalInfo * const _rygel_tumbler_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo * const _rygel_tumbler_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _rygel_tumbler_dbus_interface_info = {-1, "org.freedesktop.thumbnails.Thumbnailer1", (GDBusMethodInfo **) (&_rygel_tumbler_dbus_method_info), (GDBusSignalInfo **) (&_rygel_tumbler_dbus_signal_info), (GDBusPropertyInfo **) (&_rygel_tumbler_dbus_property_info)};
static const GDBusInterfaceVTable _rygel_tumbler_dbus_interface_vtable = {rygel_tumbler_dbus_interface_method_call, rygel_tumbler_dbus_interface_get_property, rygel_tumbler_dbus_interface_set_property};

void
rygel_tumbler_Queue (RygelTumbler* self,
                     gchar** uris,
                     gint uris_length1,
                     gchar** mime_types,
                     gint mime_types_length1,
                     const gchar* flavor,
                     const gchar* sheduler,
                     guint handle,
                     GAsyncReadyCallback _callback_,
                     gpointer _user_data_)
{
	RYGEL_TUMBLER_GET_INTERFACE (self)->Queue (self, uris, uris_length1, mime_types, mime_types_length1, flavor, sheduler, handle, _callback_, _user_data_);
}

guint
rygel_tumbler_Queue_finish (RygelTumbler* self,
                            GAsyncResult* _res_,
                            GError** error)
{
	return RYGEL_TUMBLER_GET_INTERFACE (self)->Queue_finish (self, _res_, error);
}

static void
rygel_tumbler_default_init (RygelTumblerIface * iface)
{
}

GType
rygel_tumbler_get_type (void)
{
	static volatile gsize rygel_tumbler_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_tumbler_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelTumblerIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_tumbler_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType rygel_tumbler_type_id;
		rygel_tumbler_type_id = g_type_register_static (G_TYPE_INTERFACE, "RygelTumbler", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (rygel_tumbler_type_id, G_TYPE_OBJECT);
		g_type_set_qdata (rygel_tumbler_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) rygel_tumbler_proxy_get_type);
		g_type_set_qdata (rygel_tumbler_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.thumbnails.Thumbnailer1");
		g_type_set_qdata (rygel_tumbler_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_rygel_tumbler_dbus_interface_info));
		g_type_set_qdata (rygel_tumbler_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) rygel_tumbler_register_object);
		g_once_init_leave (&rygel_tumbler_type_id__volatile, rygel_tumbler_type_id);
	}
	return rygel_tumbler_type_id__volatile;
}

G_DEFINE_TYPE_EXTENDED (RygelTumblerProxy, rygel_tumbler_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (RYGEL_TYPE_TUMBLER, rygel_tumbler_proxy_rygel_tumbler_interface_init) )
static void
rygel_tumbler_proxy_class_init (RygelTumblerProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = rygel_tumbler_proxy_g_signal;
}

static void
rygel_tumbler_proxy_g_signal (GDBusProxy* proxy,
                              const gchar* sender_name,
                              const gchar* signal_name,
                              GVariant* parameters)
{
}

static void
rygel_tumbler_proxy_init (RygelTumblerProxy* self)
{
}

static void
_vala_g_async_ready_callback (GObject *source_object,
                              GAsyncResult *res,
                              void *user_data)
{
	g_task_return_pointer (user_data, g_object_ref (res), g_object_unref);
	g_object_unref (user_data);
}

static void
rygel_tumbler_proxy_Queue_async (RygelTumbler* self,
                                 gchar** uris,
                                 gint uris_length1,
                                 gchar** mime_types,
                                 gint mime_types_length1,
                                 const gchar* flavor,
                                 const gchar* sheduler,
                                 guint handle,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	GDBusMessage *_message;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	gchar** _tmp0_;
	GVariantBuilder _tmp1_;
	gint _tmp2_;
	gchar** _tmp3_;
	GVariantBuilder _tmp4_;
	gint _tmp5_;
	G_IO_ERROR;
	G_DBUS_ERROR;
	_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.freedesktop.thumbnails.Thumbnailer1", "Queue");
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	_tmp0_ = uris;
	g_variant_builder_init (&_tmp1_, G_VARIANT_TYPE ("as"));
	for (_tmp2_ = 0; _tmp2_ < uris_length1; _tmp2_++) {
		g_variant_builder_add_value (&_tmp1_, g_variant_new_string (*_tmp0_));
		_tmp0_++;
	}
	g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp1_));
	_tmp3_ = mime_types;
	g_variant_builder_init (&_tmp4_, G_VARIANT_TYPE ("as"));
	for (_tmp5_ = 0; _tmp5_ < mime_types_length1; _tmp5_++) {
		g_variant_builder_add_value (&_tmp4_, g_variant_new_string (*_tmp3_));
		_tmp3_++;
	}
	g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp4_));
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (flavor));
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (sheduler));
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (handle));
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_message_set_body (_message, _arguments);
	g_dbus_connection_send_message_with_reply (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, _vala_g_async_ready_callback, g_task_new ((GObject *) self, NULL, _callback_, _user_data_));
	g_object_unref (_message);
}

static guint
rygel_tumbler_proxy_Queue_finish (RygelTumbler* self,
                                  GAsyncResult* _res_,
                                  GError** error)
{
	GAsyncResult *_inner_res;
	GDBusMessage *_reply_message;
	GVariant *_reply;
	GVariantIter _reply_iter;
	guint _result = 0U;
	GVariant* _tmp8_;
	_inner_res = g_task_propagate_pointer ((GTask *) _res_, NULL);
	_reply_message = g_dbus_connection_send_message_with_reply_finish (g_dbus_proxy_get_connection ((GDBusProxy *) self), _inner_res, error);
	g_object_unref (_inner_res);
	if (!_reply_message) {
		guint _tmp6_ = 0U;
		return _tmp6_;
	}
	if (g_dbus_message_to_gerror (_reply_message, error)) {
		guint _tmp7_ = 0U;
		g_object_unref (_reply_message);
		return _tmp7_;
	}
	_reply = g_dbus_message_get_body (_reply_message);
	g_variant_iter_init (&_reply_iter, _reply);
	_tmp8_ = g_variant_iter_next_value (&_reply_iter);
	_result = g_variant_get_uint32 (_tmp8_);
	g_variant_unref (_tmp8_);
	g_object_unref (_reply_message);
	return _result;
}

static void
rygel_tumbler_proxy_rygel_tumbler_interface_init (RygelTumblerIface* iface)
{
	iface->Queue = rygel_tumbler_proxy_Queue_async;
	iface->Queue_finish = rygel_tumbler_proxy_Queue_finish;
}

static void
_dbus_rygel_tumbler_Queue (RygelTumbler* self,
                           GVariant* _parameters_,
                           GDBusMethodInvocation* invocation)
{
	GVariantIter _arguments_iter;
	rygel_tumbler_QueueReadyData* _ready_data;
	GVariant* _tmp9_;
	gchar** _tmp10_;
	gint _tmp10__length;
	gint _tmp10__size;
	gint _tmp10__length1;
	GVariantIter _tmp11_;
	GVariant* _tmp12_;
	GVariant* _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length;
	gint _tmp14__size;
	gint _tmp14__length1;
	GVariantIter _tmp15_;
	GVariant* _tmp16_;
	GVariant* _tmp17_;
	GVariant* _tmp18_;
	GVariant* _tmp19_;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_ready_data = g_slice_new0 (rygel_tumbler_QueueReadyData);
	_ready_data->_invocation_ = invocation;
	_tmp9_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp10_ = g_new (gchar*, 5);
	_tmp10__length = 0;
	_tmp10__size = 4;
	_tmp10__length1 = 0;
	g_variant_iter_init (&_tmp11_, _tmp9_);
	for (; (_tmp12_ = g_variant_iter_next_value (&_tmp11_)) != NULL; _tmp10__length1++) {
		if (_tmp10__size == _tmp10__length) {
			_tmp10__size = 2 * _tmp10__size;
			_tmp10_ = g_renew (gchar*, _tmp10_, _tmp10__size + 1);
		}
		_tmp10_[_tmp10__length++] = g_variant_dup_string (_tmp12_, NULL);
		g_variant_unref (_tmp12_);
	}
	_ready_data->uris_length1 = _tmp10__length1;
	_tmp10_[_tmp10__length] = NULL;
	_ready_data->uris = _tmp10_;
	g_variant_unref (_tmp9_);
	_tmp13_ = g_variant_iter_next_value (&_arguments_iter);
	_tmp14_ = g_new (gchar*, 5);
	_tmp14__length = 0;
	_tmp14__size = 4;
	_tmp14__length1 = 0;
	g_variant_iter_init (&_tmp15_, _tmp13_);
	for (; (_tmp16_ = g_variant_iter_next_value (&_tmp15_)) != NULL; _tmp14__length1++) {
		if (_tmp14__size == _tmp14__length) {
			_tmp14__size = 2 * _tmp14__size;
			_tmp14_ = g_renew (gchar*, _tmp14_, _tmp14__size + 1);
		}
		_tmp14_[_tmp14__length++] = g_variant_dup_string (_tmp16_, NULL);
		g_variant_unref (_tmp16_);
	}
	_ready_data->mime_types_length1 = _tmp14__length1;
	_tmp14_[_tmp14__length] = NULL;
	_ready_data->mime_types = _tmp14_;
	g_variant_unref (_tmp13_);
	_tmp17_ = g_variant_iter_next_value (&_arguments_iter);
	_ready_data->flavor = g_variant_dup_string (_tmp17_, NULL);
	g_variant_unref (_tmp17_);
	_tmp18_ = g_variant_iter_next_value (&_arguments_iter);
	_ready_data->sheduler = g_variant_dup_string (_tmp18_, NULL);
	g_variant_unref (_tmp18_);
	_tmp19_ = g_variant_iter_next_value (&_arguments_iter);
	_ready_data->handle = g_variant_get_uint32 (_tmp19_);
	g_variant_unref (_tmp19_);
	rygel_tumbler_Queue (self, _ready_data->uris, _ready_data->uris_length1, _ready_data->mime_types, _ready_data->mime_types_length1, _ready_data->flavor, _ready_data->sheduler, _ready_data->handle, (GAsyncReadyCallback) _dbus_rygel_tumbler_Queue_ready, _ready_data);
}

static void
_dbus_rygel_tumbler_Queue_ready (GObject * source_object,
                                 GAsyncResult * _res_,
                                 gpointer _user_data_)
{
	rygel_tumbler_QueueReadyData* _ready_data;
	GDBusMethodInvocation* invocation;
	GError* error = NULL;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	guint result;
	_ready_data = _user_data_;
	invocation = _ready_data->_invocation_;
	result = rygel_tumbler_Queue_finish ((RygelTumbler*) source_object, _res_, &error);
	if (error) {
		g_dbus_method_invocation_return_gerror (invocation, error);
		g_error_free (error);
		goto _error;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_reply_builder, g_variant_new_uint32 (result));
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
	_error:
	_ready_data->uris = (_vala_array_free (_ready_data->uris, _ready_data->uris_length1, (GDestroyNotify) g_free), NULL);
	_ready_data->mime_types = (_vala_array_free (_ready_data->mime_types, _ready_data->mime_types_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (_ready_data->flavor);
	_g_free0 (_ready_data->sheduler);
	g_slice_free (rygel_tumbler_QueueReadyData, _ready_data);
}

static void
rygel_tumbler_dbus_interface_method_call (GDBusConnection* connection,
                                          const gchar* sender,
                                          const gchar* object_path,
                                          const gchar* interface_name,
                                          const gchar* method_name,
                                          GVariant* parameters,
                                          GDBusMethodInvocation* invocation,
                                          gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (method_name, "Queue") == 0) {
		_dbus_rygel_tumbler_Queue (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
rygel_tumbler_dbus_interface_get_property (GDBusConnection* connection,
                                           const gchar* sender,
                                           const gchar* object_path,
                                           const gchar* interface_name,
                                           const gchar* property_name,
                                           GError** error,
                                           gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return NULL;
}

static gboolean
rygel_tumbler_dbus_interface_set_property (GDBusConnection* connection,
                                           const gchar* sender,
                                           const gchar* object_path,
                                           const gchar* interface_name,
                                           const gchar* property_name,
                                           GVariant* value,
                                           GError** error,
                                           gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return FALSE;
}

guint
rygel_tumbler_register_object (gpointer object,
                               GDBusConnection* connection,
                               const gchar* path,
                               GError** error)
{
	guint result;
	gpointer *data;
	data = g_new (gpointer, 3);
	data[0] = g_object_ref (object);
	data[1] = g_object_ref (connection);
	data[2] = g_strdup (path);
	result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_rygel_tumbler_dbus_interface_info), &_rygel_tumbler_dbus_interface_vtable, data, _rygel_tumbler_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

static void
_rygel_tumbler_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_object_unref (data[0]);
	g_object_unref (data[1]);
	g_free (data[2]);
	g_free (data);
}

static inline gpointer
rygel_dbus_thumbnailer_get_instance_private (RygelDbusThumbnailer* self)
{
	return G_STRUCT_MEMBER_P (self, RygelDbusThumbnailer_private_offset);
}

static void
_rygel_dbus_thumbnailer_on_activatable_names_gasync_ready_callback (GObject* source_object,
                                                                    GAsyncResult* res,
                                                                    gpointer self)
{
	rygel_dbus_thumbnailer_on_activatable_names ((RygelDbusThumbnailer*) self, source_object, res);
	g_object_unref (self);
}

RygelDbusThumbnailer*
rygel_dbus_thumbnailer_construct (GType object_type,
                                  const gchar* flavor,
                                  GError** error)
{
	RygelDbusThumbnailer * self = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	gchar* _tmp2_;
	RygelFreeDesktopDBusObject* _tmp3_ = NULL;
	RygelFreeDesktopDBusObject* _tmp4_;
	RygelFreeDesktopDBusObject* _tmp5_;
	RygelFreeDesktopDBusObject* _tmp6_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (flavor != NULL, NULL);
	self = (RygelDbusThumbnailer*) g_object_new (object_type, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->uris);
	self->priv->uris = _tmp0_;
	_tmp1_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->mimes);
	self->priv->mimes = _tmp1_;
	self->priv->timeout_id = (guint) 0;
	_tmp2_ = g_strdup (flavor);
	_g_free0 (self->priv->flavor);
	self->priv->flavor = _tmp2_;
	_tmp4_ = g_initable_new (RYGEL_FREE_DESKTOP_TYPE_DBUS_OBJECT_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", RYGEL_FREE_DESKTOP_DBUS_SERVICE, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", RYGEL_FREE_DESKTOP_DBUS_OBJECT_PATH, "g-interface-name", "org.freedesktop.DBus", "g-interface-info", g_type_get_qdata (RYGEL_FREE_DESKTOP_TYPE_DBUS_OBJECT, g_quark_from_static_string ("vala-dbus-interface-info")), NULL);
	_tmp3_ = (RygelFreeDesktopDBusObject*) _tmp4_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp5_ = _tmp3_;
	_tmp3_ = NULL;
	_g_object_unref0 (self->priv->fdo);
	self->priv->fdo = _tmp5_;
	_tmp6_ = self->priv->fdo;
	rygel_free_desktop_dbus_object_list_activatable_names (_tmp6_, _rygel_dbus_thumbnailer_on_activatable_names_gasync_ready_callback, g_object_ref (self));
	_g_object_unref0 (_tmp3_);
	return self;
}

RygelDbusThumbnailer*
rygel_dbus_thumbnailer_new (const gchar* flavor,
                            GError** error)
{
	return rygel_dbus_thumbnailer_construct (RYGEL_TYPE_DBUS_THUMBNAILER, flavor, error);
}

static gboolean
_rygel_dbus_thumbnailer_on_timeout_gsource_func (gpointer self)
{
	gboolean result;
	result = rygel_dbus_thumbnailer_on_timeout ((RygelDbusThumbnailer*) self);
	return result;
}

void
rygel_dbus_thumbnailer_queue_thumbnail_task (RygelDbusThumbnailer* self,
                                             const gchar* uri,
                                             const gchar* mime)
{
	GFile* file = NULL;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeArrayList* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (uri != NULL);
	g_return_if_fail (mime != NULL);
	_tmp0_ = g_file_new_for_uri (uri);
	file = _tmp0_;
	_tmp1_ = file;
	if (!g_file_is_native (_tmp1_)) {
		_g_object_unref0 (file);
		return;
	}
	_tmp2_ = self->priv->uris;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp2_, uri);
	_tmp3_ = self->priv->mimes;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp3_, mime);
	if (self->priv->timeout_id != ((guint) 0)) {
		g_source_remove (self->priv->timeout_id);
		self->priv->timeout_id = (guint) 0;
	}
	_tmp4_ = self->priv->uris;
	_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
	_tmp6_ = _tmp5_;
	if (((guint) _tmp6_) < RYGEL_DBUS_THUMBNAILER_THUMBNAIL_MAX_QUEUE_SIZE) {
		self->priv->timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 100, _rygel_dbus_thumbnailer_on_timeout_gsource_func, g_object_ref (self), g_object_unref);
	} else {
		rygel_dbus_thumbnailer_on_timeout (self);
	}
	_g_object_unref0 (file);
}

static gboolean
rygel_dbus_thumbnailer_on_timeout (RygelDbusThumbnailer* self)
{
	gboolean result = FALSE;
	RygelTumbler* _tmp0_;
	GeeArrayList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	RygelTumbler* _tmp4_;
	GeeArrayList* _tmp5_;
	gint _tmp6_;
	gpointer* _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	GeeArrayList* _tmp9_;
	gint _tmp10_;
	gpointer* _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	const gchar* _tmp13_;
	GeeArrayList* _tmp14_;
	GeeArrayList* _tmp15_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->tumbler;
	if (_tmp0_ == NULL) {
		result = TRUE;
		return result;
	}
	_tmp1_ = self->priv->uris;
	_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	g_debug ("rygel-dbus-thumbnailer.vala:92: Queueing thumbnail creation for %d fil" \
"es", _tmp3_);
	_tmp4_ = self->priv->tumbler;
	_tmp5_ = self->priv->uris;
	_tmp7_ = gee_collection_to_array ((GeeCollection*) _tmp5_, &_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp8__length1 = _tmp6_;
	_tmp9_ = self->priv->mimes;
	_tmp11_ = gee_collection_to_array ((GeeCollection*) _tmp9_, &_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp12__length1 = _tmp10_;
	_tmp13_ = self->priv->flavor;
	rygel_tumbler_Queue (_tmp4_, _tmp8_, (gint) _tmp6_, _tmp12_, (gint) _tmp10_, _tmp13_, "default", (guint) 0, NULL, NULL);
	_tmp12_ = (_vala_array_free (_tmp12_, _tmp12__length1, (GDestroyNotify) g_free), NULL);
	_tmp8_ = (_vala_array_free (_tmp8_, _tmp8__length1, (GDestroyNotify) g_free), NULL);
	_tmp14_ = self->priv->uris;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp14_);
	_tmp15_ = self->priv->mimes;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp15_);
	self->priv->timeout_id = (guint) 0;
	result = FALSE;
	return result;
}

static gboolean
_vala_string_array_contains (gchar* * stack,
                             int stack_length,
                             const gchar* needle)
{
	int i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}

static void
rygel_dbus_thumbnailer_on_activatable_names (RygelDbusThumbnailer* self,
                                             GObject* source,
                                             GAsyncResult* res)
{
	RygelTumbler* _tmp11_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (res != NULL);
	{
		gchar** names = NULL;
		RygelFreeDesktopDBusObject* _tmp0_;
		gint _tmp1_;
		gchar** _tmp2_;
		gint names_length1;
		gint _names_size_;
		gchar** _tmp3_;
		gint _tmp3__length1;
		_tmp0_ = self->priv->fdo;
		_tmp2_ = rygel_free_desktop_dbus_object_list_activatable_names_finish (_tmp0_, res, &_tmp1_, &_inner_error_);
		names = _tmp2_;
		names_length1 = _tmp1_;
		_names_size_ = names_length1;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_DBUS_ERROR) {
				goto __catch36_g_dbus_error;
			}
			if (_inner_error_->domain == G_IO_ERROR) {
				goto __catch36_g_io_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;
		}
		_tmp3_ = names;
		_tmp3__length1 = names_length1;
		if (_vala_string_array_contains (_tmp3_, _tmp3__length1, RYGEL_DBUS_THUMBNAILER_THUMBNAILER_IFACE)) {
			RygelTumbler* _tmp4_ = NULL;
			RygelTumbler* _tmp5_;
			RygelTumbler* _tmp6_;
			_tmp5_ = g_initable_new (RYGEL_TYPE_TUMBLER_PROXY, NULL, &_inner_error_, "g-flags", 0, "g-name", RYGEL_DBUS_THUMBNAILER_THUMBNAILER_IFACE, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", RYGEL_DBUS_THUMBNAILER_THUMBNAILER_SERVICE, "g-interface-name", "org.freedesktop.thumbnails.Thumbnailer1", "g-interface-info", g_type_get_qdata (RYGEL_TYPE_TUMBLER, g_quark_from_static_string ("vala-dbus-interface-info")), NULL);
			_tmp4_ = (RygelTumbler*) _tmp5_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				names = (_vala_array_free (names, names_length1, (GDestroyNotify) g_free), NULL);
				if (_inner_error_->domain == G_DBUS_ERROR) {
					goto __catch36_g_dbus_error;
				}
				if (_inner_error_->domain == G_IO_ERROR) {
					goto __catch36_g_io_error;
				}
				names = (_vala_array_free (names, names_length1, (GDestroyNotify) g_free), NULL);
				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;
			}
			_tmp6_ = _tmp4_;
			_tmp4_ = NULL;
			_g_object_unref0 (self->priv->tumbler);
			self->priv->tumbler = _tmp6_;
			_g_object_unref0 (_tmp4_);
		} else {
			g_debug ("rygel-dbus-thumbnailer.vala:116: %s", _ ("No D-Bus thumbnailer service available"));
		}
		names = (_vala_array_free (names, names_length1, (GDestroyNotify) g_free), NULL);
	}
	goto __finally36;
	__catch36_g_dbus_error:
	{
		GError* _error_ = NULL;
		GError* _tmp7_;
		const gchar* _tmp8_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp7_ = _error_;
		_tmp8_ = _tmp7_->message;
		g_debug ("DBus error while trying to connect to thumbmailer service:" " %s", _tmp8_);
		_g_error_free0 (_error_);
	}
	goto __finally36;
	__catch36_g_io_error:
	{
		GError* io_error = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
		io_error = _inner_error_;
		_inner_error_ = NULL;
		_tmp9_ = io_error;
		_tmp10_ = _tmp9_->message;
		g_debug ("I/O error while trying to connect to thumbmailer service:" " %s", _tmp10_);
		_g_error_free0 (io_error);
	}
	__finally36:
	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;
	}
	_tmp11_ = self->priv->tumbler;
	g_signal_emit (self, rygel_dbus_thumbnailer_signals[RYGEL_DBUS_THUMBNAILER_READY_SIGNAL], 0, _tmp11_ != NULL);
}

static void
rygel_dbus_thumbnailer_class_init (RygelDbusThumbnailerClass * klass)
{
	rygel_dbus_thumbnailer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelDbusThumbnailer_private_offset);
	G_OBJECT_CLASS (klass)->finalize = rygel_dbus_thumbnailer_finalize;
	rygel_dbus_thumbnailer_signals[RYGEL_DBUS_THUMBNAILER_READY_SIGNAL] = g_signal_new ("ready", RYGEL_TYPE_DBUS_THUMBNAILER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
rygel_dbus_thumbnailer_instance_init (RygelDbusThumbnailer * self)
{
	self->priv = rygel_dbus_thumbnailer_get_instance_private (self);
}

static void
rygel_dbus_thumbnailer_finalize (GObject * obj)
{
	RygelDbusThumbnailer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_DBUS_THUMBNAILER, RygelDbusThumbnailer);
	_g_object_unref0 (self->priv->tumbler);
	_g_object_unref0 (self->priv->uris);
	_g_object_unref0 (self->priv->mimes);
	_g_free0 (self->priv->flavor);
	_g_object_unref0 (self->priv->fdo);
	G_OBJECT_CLASS (rygel_dbus_thumbnailer_parent_class)->finalize (obj);
}

GType
rygel_dbus_thumbnailer_get_type (void)
{
	static volatile gsize rygel_dbus_thumbnailer_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_dbus_thumbnailer_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelDbusThumbnailerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_dbus_thumbnailer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelDbusThumbnailer), 0, (GInstanceInitFunc) rygel_dbus_thumbnailer_instance_init, NULL };
		GType rygel_dbus_thumbnailer_type_id;
		rygel_dbus_thumbnailer_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelDbusThumbnailer", &g_define_type_info, 0);
		RygelDbusThumbnailer_private_offset = g_type_add_instance_private (rygel_dbus_thumbnailer_type_id, sizeof (RygelDbusThumbnailerPrivate));
		g_once_init_leave (&rygel_dbus_thumbnailer_type_id__volatile, rygel_dbus_thumbnailer_type_id);
	}
	return rygel_dbus_thumbnailer_type_id__volatile;
}

static void
_vala_array_destroy (gpointer array,
                     gint array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gint array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

