/* Cache.c generated by valac 0.52.4, the Vala compiler
 * generated from Cache.vala, do not modify */

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <libsoup/soup.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gio/gio.h>

#define TOOTLE_TYPE_CACHE (tootle_cache_get_type ())
#define TOOTLE_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_CACHE, TootleCache))
#define TOOTLE_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_CACHE, TootleCacheClass))
#define TOOTLE_IS_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_CACHE))
#define TOOTLE_IS_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_CACHE))
#define TOOTLE_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_CACHE, TootleCacheClass))

typedef struct _TootleCache TootleCache;
typedef struct _TootleCacheClass TootleCacheClass;
typedef struct _TootleCachePrivate TootleCachePrivate;

#define TOOTLE_CACHE_TYPE_ITEM (tootle_cache_item_get_type ())
#define TOOTLE_CACHE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_CACHE_TYPE_ITEM, TootleCacheItem))
#define TOOTLE_CACHE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_CACHE_TYPE_ITEM, TootleCacheItemClass))
#define TOOTLE_CACHE_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_CACHE_TYPE_ITEM))
#define TOOTLE_CACHE_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_CACHE_TYPE_ITEM))
#define TOOTLE_CACHE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_CACHE_TYPE_ITEM, TootleCacheItemClass))

typedef struct _TootleCacheItem TootleCacheItem;
typedef struct _TootleCacheItemClass TootleCacheItemClass;
enum  {
	TOOTLE_CACHE_0_PROPERTY,
	TOOTLE_CACHE_ITEMS_PROPERTY,
	TOOTLE_CACHE_ITEMS_IN_PROGRESS_PROPERTY,
	TOOTLE_CACHE_SIZE_PROPERTY,
	TOOTLE_CACHE_NUM_PROPERTIES
};
static GParamSpec* tootle_cache_properties[TOOTLE_CACHE_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))

#define TOOTLE_CACHE_TYPE_REFERENCE (tootle_cache_reference_get_type ())
typedef struct _TootleCacheReference TootleCacheReference;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _tootle_cache_reference_free0(var) ((var == NULL) ? NULL : (var = (tootle_cache_reference_free (var), NULL)))
typedef void (*TootleCacheCachedResultCallback) (TootleCacheReference* _result_, gpointer user_data);
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block12Data Block12Data;
typedef struct _Block13Data Block13Data;

#define TOOTLE_TYPE_NETWORK (tootle_network_get_type ())
#define TOOTLE_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_NETWORK, TootleNetwork))
#define TOOTLE_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_NETWORK, TootleNetworkClass))
#define TOOTLE_IS_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_NETWORK))
#define TOOTLE_IS_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_NETWORK))
#define TOOTLE_NETWORK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_NETWORK, TootleNetworkClass))

typedef struct _TootleNetwork TootleNetwork;
typedef struct _TootleNetworkClass TootleNetworkClass;
#define __vala_SoupBuffer_free0(var) ((var == NULL) ? NULL : (var = (_vala_SoupBuffer_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef void (*TootleNetworkSuccessCallback) (SoupSession* session, SoupMessage* msg, gpointer user_data, GError** error);
typedef void (*TootleNetworkErrorCallback) (gint32 code, const gchar* reason, gpointer user_data);
typedef struct _Block14Data Block14Data;
typedef struct _TootleCacheItemPrivate TootleCacheItemPrivate;
enum  {
	TOOTLE_CACHE_ITEM_0_PROPERTY,
	TOOTLE_CACHE_ITEM_DATA_PROPERTY,
	TOOTLE_CACHE_ITEM_REFERENCES_PROPERTY,
	TOOTLE_CACHE_ITEM_NUM_PROPERTIES
};
static GParamSpec* tootle_cache_item_properties[TOOTLE_CACHE_ITEM_NUM_PROPERTIES];

struct _TootleCache {
	GObject parent_instance;
	TootleCachePrivate * priv;
};

struct _TootleCacheClass {
	GObjectClass parent_class;
};

struct _TootleCachePrivate {
	GHashTable* _items;
	GHashTable* _items_in_progress;
};

struct _TootleCacheReference {
	gchar* key;
	GdkPixbuf* data;
	gboolean loading;
};

struct _Block12Data {
	int _ref_count_;
	TootleCache* self;
	gchar* key;
	SoupMessage* msg;
	gchar* url;
	TootleCacheCachedResultCallback cb;
	gpointer cb_target;
	GDestroyNotify cb_target_destroy_notify;
};

struct _Block13Data {
	int _ref_count_;
	Block12Data * _data12_;
	gulong id;
};

typedef enum  {
	TOOTLE_OOPSIE_USER,
	TOOTLE_OOPSIE_PARSING,
	TOOTLE_OOPSIE_INSTANCE,
	TOOTLE_OOPSIE_INTERNAL
} TootleOopsie;
#define TOOTLE_OOPSIE tootle_oopsie_quark ()
struct _Block14Data {
	int _ref_count_;
	Block12Data * _data12_;
	gulong id;
};

struct _TootleCacheItem {
	GObject parent_instance;
	TootleCacheItemPrivate * priv;
};

struct _TootleCacheItemClass {
	GObjectClass parent_class;
};

struct _TootleCacheItemPrivate {
	GdkPixbuf* _data;
	gint _references;
};

static gint TootleCache_private_offset;
static gpointer tootle_cache_parent_class = NULL;
extern TootleNetwork* tootle_network;
static gint TootleCacheItem_private_offset;
static gpointer tootle_cache_item_parent_class = NULL;

GType tootle_cache_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleCache, g_object_unref)
GType tootle_cache_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleCacheItem, g_object_unref)
GType tootle_cache_reference_get_type (void) G_GNUC_CONST ;
TootleCacheReference* tootle_cache_reference_dup (const TootleCacheReference* self);
void tootle_cache_reference_free (TootleCacheReference* self);
void tootle_cache_reference_copy (const TootleCacheReference* self,
                                  TootleCacheReference* dest);
void tootle_cache_reference_destroy (TootleCacheReference* self);
void tootle_cache_unload (TootleCache* self,
                          TootleCacheReference** r);
GHashTable* tootle_cache_get_items (TootleCache* self);
gint tootle_cache_item_get_references (TootleCacheItem* self);
void tootle_cache_item_set_references (TootleCacheItem* self,
                                       gint value);
GHashTable* tootle_cache_get_items_in_progress (TootleCache* self);
void tootle_cache_load (TootleCache* self,
                        const gchar* url,
                        TootleCacheCachedResultCallback cb,
                        gpointer cb_target,
                        GDestroyNotify cb_target_destroy_notify);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
GdkPixbuf* tootle_cache_item_get_data (TootleCacheItem* self);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
static void ___lambda15_ (Block13Data* _data13_);
GType tootle_network_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleNetwork, g_object_unref)
gchar* tootle_network_describe_error (TootleNetwork* self,
                                      guint code);
GQuark tootle_oopsie_quark (void);
static guint8* _vala_array_dup2 (guint8* self,
                          gint length);
static void _vala_SoupBuffer_free (SoupBuffer* self);
static guint8* _vala_array_dup3 (guint8* self,
                          gint length);
GdkPixbuf* tootle_desktop_icon_to_pixbuf (const gchar* name);
TootleCacheItem* tootle_cache_item_new (GdkPixbuf* d,
                                        gint r);
TootleCacheItem* tootle_cache_item_construct (GType object_type,
                                              GdkPixbuf* d,
                                              gint r);
static void ____lambda15__soup_message_finished (SoupMessage* _sender,
                                          gpointer self);
void tootle_network_queue (TootleNetwork* self,
                           SoupMessage* mess,
                           TootleNetworkSuccessCallback cb,
                           gpointer cb_target,
                           GDestroyNotify cb_target_destroy_notify,
                           TootleNetworkErrorCallback ecb,
                           gpointer ecb_target,
                           GDestroyNotify ecb_target_destroy_notify);
static void ___lambda25_ (Block13Data* _data13_,
                   SoupSession* sess,
                   SoupMessage* mess,
                   GError** error);
static void ____lambda25__tootle_network_success_callback (SoupSession* session,
                                                    SoupMessage* msg,
                                                    gpointer self,
                                                    GError** error);
static void ___lambda26_ (Block13Data* _data13_,
                   gint32 code,
                   const gchar* reason);
static void ____lambda26__tootle_network_error_callback (gint32 code,
                                                  const gchar* reason,
                                                  gpointer self);
static Block14Data* block14_data_ref (Block14Data* _data14_);
static void block14_data_unref (void * _userdata_);
static void ___lambda27_ (Block14Data* _data14_);
static void ____lambda27__soup_message_finished (SoupMessage* _sender,
                                          gpointer self);
void tootle_cache_clear (TootleCache* self);
TootleCache* tootle_cache_new (void);
TootleCache* tootle_cache_construct (GType object_type);
void tootle_cache_set_items (TootleCache* self,
                             GHashTable* value);
void tootle_cache_set_items_in_progress (TootleCache* self,
                                         GHashTable* value);
guint tootle_cache_get_size (TootleCache* self);
void tootle_cache_item_set_data (TootleCacheItem* self,
                                 GdkPixbuf* value);
static void tootle_cache_item_finalize (GObject * obj);
static GType tootle_cache_item_get_type_once (void);
static void _vala_tootle_cache_item_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_tootle_cache_item_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);
static GObject * tootle_cache_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties);
static void _g_free0_ (gpointer var);
static void _g_object_unref0_ (gpointer var);
static void tootle_cache_finalize (GObject * obj);
static GType tootle_cache_get_type_once (void);
static void _vala_tootle_cache_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_tootle_cache_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
tootle_cache_get_instance_private (TootleCache* self)
{
	return G_STRUCT_MEMBER_P (self, TootleCache_private_offset);
}

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

void
tootle_cache_unload (TootleCache* self,
                     TootleCacheReference** r)
{
	GdkPixbuf* _tmp0_;
	TootleCacheItem* item = NULL;
	GHashTable* _tmp1_;
	const gchar* _tmp2_;
	gconstpointer _tmp3_;
	TootleCacheItem* _tmp4_;
	TootleCacheItem* _tmp5_;
	TootleCacheItem* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	TootleCacheItem* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	g_return_if_fail (self != NULL);
	if ((*r) == NULL) {
		return;
	}
	_tmp0_ = (*(*r)).data;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->_items;
	_tmp2_ = (*(*r)).key;
	_tmp3_ = g_hash_table_lookup (_tmp1_, _tmp2_);
	_tmp4_ = _g_object_ref0 ((TootleCacheItem*) _tmp3_);
	item = _tmp4_;
	_tmp5_ = item;
	if (_tmp5_ == NULL) {
		_g_object_unref0 (item);
		return;
	}
	_tmp6_ = item;
	_tmp7_ = tootle_cache_item_get_references (_tmp6_);
	_tmp8_ = _tmp7_;
	tootle_cache_item_set_references (_tmp6_, _tmp8_ - 1);
	_tmp9_ = item;
	_tmp10_ = tootle_cache_item_get_references (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ <= 0) {
		GHashTable* _tmp12_;
		const gchar* _tmp13_;
		GHashTable* _tmp14_;
		const gchar* _tmp15_;
		_tmp12_ = self->priv->_items;
		_tmp13_ = (*(*r)).key;
		g_hash_table_remove (_tmp12_, _tmp13_);
		_tmp14_ = self->priv->_items_in_progress;
		_tmp15_ = (*(*r)).key;
		g_hash_table_remove (_tmp14_, _tmp15_);
	}
	_tootle_cache_reference_free0 (*r);
	*r = NULL;
	_g_object_unref0 (item);
}

static Block12Data*
block12_data_ref (Block12Data* _data12_)
{
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}

static void
block12_data_unref (void * _userdata_)
{
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		TootleCache* self;
		self = _data12_->self;
		_g_object_unref0 (_data12_->msg);
		_g_free0 (_data12_->key);
		_g_free0 (_data12_->url);
		(_data12_->cb_target_destroy_notify == NULL) ? NULL : (_data12_->cb_target_destroy_notify (_data12_->cb_target), NULL);
		_data12_->cb = NULL;
		_data12_->cb_target = NULL;
		_data12_->cb_target_destroy_notify = NULL;
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}

static Block13Data*
block13_data_ref (Block13Data* _data13_)
{
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}

static void
block13_data_unref (void * _userdata_)
{
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		TootleCache* self;
		self = _data13_->_data12_->self;
		block12_data_unref (_data13_->_data12_);
		_data13_->_data12_ = NULL;
		g_slice_free (Block13Data, _data13_);
	}
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static guint8*
_vala_array_dup2 (guint8* self,
                  gint length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

static void
_vala_SoupBuffer_free (SoupBuffer* self)
{
	g_boxed_free (soup_buffer_get_type (), self);
}

static guint8*
_vala_array_dup3 (guint8* self,
                  gint length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

static void
___lambda15_ (Block13Data* _data13_)
{
	Block12Data* _data12_;
	TootleCache* self;
	GdkPixbuf* pixbuf = NULL;
	GHashTable* _tmp34_;
	const gchar* _tmp35_;
	gchar* _tmp36_;
	GdkPixbuf* _tmp37_;
	TootleCacheItem* _tmp38_;
	GHashTable* _tmp39_;
	const gchar* _tmp40_;
	GHashTable* _tmp41_;
	const gchar* _tmp42_;
	gconstpointer _tmp43_;
	GdkPixbuf* _tmp44_;
	GdkPixbuf* _tmp45_;
	const gchar* _tmp46_;
	gchar* _tmp47_;
	TootleCacheReference _tmp48_ = {0};
	TootleCacheReference _tmp49_;
	TootleCacheReference _tmp50_;
	SoupMessage* _tmp51_;
	GError* _inner_error0_ = NULL;
	_data12_ = _data13_->_data12_;
	self = _data12_->self;
	pixbuf = NULL;
	{
		guint code = 0U;
		SoupMessage* _tmp0_;
		guint _tmp1_;
		guint _tmp2_;
		guint8* data = NULL;
		SoupMessage* _tmp11_;
		SoupMessageBody* _tmp12_;
		SoupBuffer* _tmp13_;
		SoupBuffer* _tmp14_;
		guint8* _tmp15_;
		gint _tmp15__length1;
		guint8* _tmp16_;
		gint _tmp16__length1;
		guint8* _tmp17_;
		gint _tmp17__length1;
		gint data_length1;
		gint _data_size_;
		GMemoryInputStream* stream = NULL;
		guint8* _tmp18_;
		gint _tmp18__length1;
		guint8* _tmp19_;
		gint _tmp19__length1;
		GDestroyNotify _tmp20_;
		GMemoryInputStream* _tmp21_;
		GdkPixbuf* _tmp22_ = NULL;
		GMemoryInputStream* _tmp23_;
		GdkPixbuf* _tmp24_;
		GdkPixbuf* _tmp25_;
		GMemoryInputStream* _tmp26_;
		_tmp0_ = _data12_->msg;
		g_object_get (_tmp0_, "status-code", &_tmp1_, NULL);
		_tmp2_ = _tmp1_;
		code = _tmp2_;
		if (code != ((guint) SOUP_STATUS_OK)) {
			gchar* _error_ = NULL;
			TootleNetwork* _tmp3_;
			gchar* _tmp4_;
			const gchar* _tmp5_;
			const gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			GError* _tmp9_;
			GError* _tmp10_;
			_tmp3_ = tootle_network;
			_tmp4_ = tootle_network_describe_error (_tmp3_, code);
			_error_ = _tmp4_;
			_tmp5_ = _error_;
			_tmp6_ = string_to_string (_tmp5_);
			_tmp7_ = g_strconcat ("Server returned ", _tmp6_, NULL);
			_tmp8_ = _tmp7_;
			_tmp9_ = g_error_new_literal (TOOTLE_OOPSIE, TOOTLE_OOPSIE_INSTANCE, _tmp8_);
			_tmp10_ = _tmp9_;
			_g_free0 (_tmp8_);
			_inner_error0_ = _tmp10_;
			_g_free0 (_error_);
			goto __catch0_g_error;
		}
		_tmp11_ = _data12_->msg;
		_tmp12_ = _tmp11_->response_body;
		_tmp13_ = soup_message_body_flatten (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_->data;
		_tmp15__length1 = _tmp14_->length;
		_tmp16_ = (_tmp15_ != NULL) ? _vala_array_dup2 (_tmp15_, _tmp15__length1) : _tmp15_;
		_tmp16__length1 = _tmp15__length1;
		_tmp17_ = _tmp16_;
		_tmp17__length1 = _tmp16__length1;
		__vala_SoupBuffer_free0 (_tmp14_);
		data = _tmp17_;
		data_length1 = _tmp17__length1;
		_data_size_ = data_length1;
		_tmp18_ = data;
		_tmp18__length1 = data_length1;
		_tmp19_ = (_tmp18_ != NULL) ? _vala_array_dup3 (_tmp18_, _tmp18__length1) : _tmp18_;
		_tmp19__length1 = _tmp18__length1;
		_tmp20_ = g_free;
		_tmp21_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_tmp19_, _tmp19__length1, _tmp20_);
		stream = _tmp21_;
		_tmp23_ = stream;
		_tmp24_ = gdk_pixbuf_new_from_stream ((GInputStream*) _tmp23_, NULL, &_inner_error0_);
		_tmp22_ = _tmp24_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (stream);
			data = (g_free (data), NULL);
			goto __catch0_g_error;
		}
		_tmp25_ = _tmp22_;
		_tmp22_ = NULL;
		_g_object_unref0 (pixbuf);
		pixbuf = _tmp25_;
		_tmp26_ = stream;
		g_input_stream_close ((GInputStream*) _tmp26_, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (_tmp22_);
			_g_object_unref0 (stream);
			data = (g_free (data), NULL);
			goto __catch0_g_error;
		}
		_g_object_unref0 (_tmp22_);
		_g_object_unref0 (stream);
		data = (g_free (data), NULL);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp27_;
		GError* _tmp28_;
		const gchar* _tmp29_;
		const gchar* _tmp30_;
		gchar* _tmp31_;
		gchar* _tmp32_;
		GdkPixbuf* _tmp33_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp27_ = string_to_string (_data12_->url);
		_tmp28_ = e;
		_tmp29_ = _tmp28_->message;
		_tmp30_ = string_to_string (_tmp29_);
		_tmp31_ = g_strconcat ("\"", _tmp27_, "\" -> Pixbuf: FAIL (", _tmp30_, ")", NULL);
		_tmp32_ = _tmp31_;
		g_warning ("Cache.vala:101: %s", _tmp32_);
		_g_free0 (_tmp32_);
		_tmp33_ = tootle_desktop_icon_to_pixbuf ("image-x-generic-symbolic");
		_g_object_unref0 (pixbuf);
		pixbuf = _tmp33_;
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (pixbuf);
		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;
	}
	_tmp34_ = self->priv->_items;
	_tmp35_ = _data12_->key;
	_tmp36_ = g_strdup (_tmp35_);
	_tmp37_ = pixbuf;
	_tmp38_ = tootle_cache_item_new (_tmp37_, 1);
	g_hash_table_insert (_tmp34_, _tmp36_, _tmp38_);
	_tmp39_ = self->priv->_items_in_progress;
	_tmp40_ = _data12_->key;
	g_hash_table_remove (_tmp39_, _tmp40_);
	_tmp41_ = self->priv->_items;
	_tmp42_ = _data12_->key;
	_tmp43_ = g_hash_table_lookup (_tmp41_, _tmp42_);
	_tmp44_ = tootle_cache_item_get_data ((TootleCacheItem*) _tmp43_);
	_tmp45_ = _tmp44_;
	_tmp46_ = _data12_->key;
	_tmp47_ = g_strdup (_tmp46_);
	memset (&_tmp48_, 0, sizeof (TootleCacheReference));
	_tmp48_.data = _tmp45_;
	_g_free0 (_tmp48_.key);
	_tmp48_.key = _tmp47_;
	_tmp48_.loading = FALSE;
	_tmp49_ = _tmp48_;
	_tmp50_ = _tmp49_;
	_data12_->cb (&_tmp50_, _data12_->cb_target);
	tootle_cache_reference_destroy (&_tmp49_);
	_tmp51_ = _data12_->msg;
	g_signal_handler_disconnect ((GObject*) _tmp51_, _data13_->id);
	_g_object_unref0 (pixbuf);
}

static void
____lambda15__soup_message_finished (SoupMessage* _sender,
                                     gpointer self)
{
	___lambda15_ (self);
}

static void
___lambda25_ (Block13Data* _data13_,
              SoupSession* sess,
              SoupMessage* mess,
              GError** error)
{
	Block12Data* _data12_;
	TootleCache* self;
	_data12_ = _data13_->_data12_;
	self = _data12_->self;
	g_return_if_fail (sess != NULL);
	g_return_if_fail (mess != NULL);
}

static void
____lambda25__tootle_network_success_callback (SoupSession* session,
                                               SoupMessage* msg,
                                               gpointer self,
                                               GError** error)
{
	___lambda25_ (self, session, msg, error);
}

static void
___lambda26_ (Block13Data* _data13_,
              gint32 code,
              const gchar* reason)
{
	Block12Data* _data12_;
	TootleCache* self;
	_data12_ = _data13_->_data12_;
	self = _data12_->self;
	g_return_if_fail (reason != NULL);
	_data12_->cb (NULL, _data12_->cb_target);
}

static void
____lambda26__tootle_network_error_callback (gint32 code,
                                             const gchar* reason,
                                             gpointer self)
{
	___lambda26_ (self, code, reason);
}

static Block14Data*
block14_data_ref (Block14Data* _data14_)
{
	g_atomic_int_inc (&_data14_->_ref_count_);
	return _data14_;
}

static void
block14_data_unref (void * _userdata_)
{
	Block14Data* _data14_;
	_data14_ = (Block14Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data14_->_ref_count_)) {
		TootleCache* self;
		self = _data14_->_data12_->self;
		block12_data_unref (_data14_->_data12_);
		_data14_->_data12_ = NULL;
		g_slice_free (Block14Data, _data14_);
	}
}

static void
___lambda27_ (Block14Data* _data14_)
{
	Block12Data* _data12_;
	TootleCache* self;
	TootleCacheItem* it = NULL;
	GHashTable* _tmp0_;
	const gchar* _tmp1_;
	gconstpointer _tmp2_;
	TootleCacheItem* _tmp3_;
	GdkPixbuf* _tmp4_;
	GdkPixbuf* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	TootleCacheReference _tmp8_ = {0};
	TootleCacheReference _tmp9_;
	TootleCacheReference _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	SoupMessage* _tmp13_;
	_data12_ = _data14_->_data12_;
	self = _data12_->self;
	_tmp0_ = self->priv->_items;
	_tmp1_ = _data12_->key;
	_tmp2_ = g_hash_table_lookup (_tmp0_, _tmp1_);
	_tmp3_ = _g_object_ref0 ((TootleCacheItem*) _tmp2_);
	it = _tmp3_;
	_tmp4_ = tootle_cache_item_get_data (it);
	_tmp5_ = _tmp4_;
	_tmp6_ = _data12_->key;
	_tmp7_ = g_strdup (_tmp6_);
	memset (&_tmp8_, 0, sizeof (TootleCacheReference));
	_tmp8_.data = _tmp5_;
	_g_free0 (_tmp8_.key);
	_tmp8_.key = _tmp7_;
	_tmp8_.loading = FALSE;
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_data12_->cb (&_tmp10_, _data12_->cb_target);
	tootle_cache_reference_destroy (&_tmp9_);
	_tmp11_ = tootle_cache_item_get_references (it);
	_tmp12_ = _tmp11_;
	tootle_cache_item_set_references (it, _tmp12_ + 1);
	_tmp13_ = _data12_->msg;
	g_signal_handler_disconnect ((GObject*) _tmp13_, _data14_->id);
	_g_object_unref0 (it);
}

static void
____lambda27__soup_message_finished (SoupMessage* _sender,
                                     gpointer self)
{
	___lambda27_ (self);
}

void
tootle_cache_load (TootleCache* self,
                   const gchar* url,
                   TootleCacheCachedResultCallback cb,
                   gpointer cb_target,
                   GDestroyNotify cb_target_destroy_notify)
{
	Block12Data* _data12_;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GHashTable* _tmp2_;
	const gchar* _tmp3_;
	GHashTable* _tmp19_;
	const gchar* _tmp20_;
	gconstpointer _tmp21_;
	SoupMessage* _tmp22_;
	SoupMessage* _tmp23_;
	g_return_if_fail (self != NULL);
	_data12_ = g_slice_new0 (Block12Data);
	_data12_->_ref_count_ = 1;
	_data12_->self = g_object_ref (self);
	_tmp0_ = g_strdup (url);
	_g_free0 (_data12_->url);
	_data12_->url = _tmp0_;
	(_data12_->cb_target_destroy_notify == NULL) ? NULL : (_data12_->cb_target_destroy_notify (_data12_->cb_target), NULL);
	_data12_->cb = NULL;
	_data12_->cb_target = NULL;
	_data12_->cb_target_destroy_notify = NULL;
	_data12_->cb = cb;
	_data12_->cb_target = cb_target;
	_data12_->cb_target_destroy_notify = cb_target_destroy_notify;
	if (_data12_->url == NULL) {
		_data12_->cb (NULL, _data12_->cb_target);
		block12_data_unref (_data12_);
		_data12_ = NULL;
		return;
	}
	_tmp1_ = g_strdup (_data12_->url);
	_data12_->key = _tmp1_;
	_tmp2_ = self->priv->_items;
	_tmp3_ = _data12_->key;
	if (g_hash_table_contains (_tmp2_, _tmp3_)) {
		TootleCacheItem* item = NULL;
		GHashTable* _tmp4_;
		const gchar* _tmp5_;
		gconstpointer _tmp6_;
		TootleCacheItem* _tmp7_;
		TootleCacheItem* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		TootleCacheItem* _tmp11_;
		GdkPixbuf* _tmp12_;
		GdkPixbuf* _tmp13_;
		const gchar* _tmp14_;
		gchar* _tmp15_;
		TootleCacheReference _tmp16_ = {0};
		TootleCacheReference _tmp17_;
		TootleCacheReference _tmp18_;
		_tmp4_ = self->priv->_items;
		_tmp5_ = _data12_->key;
		_tmp6_ = g_hash_table_lookup (_tmp4_, _tmp5_);
		_tmp7_ = _g_object_ref0 ((TootleCacheItem*) _tmp6_);
		item = _tmp7_;
		_tmp8_ = item;
		_tmp9_ = tootle_cache_item_get_references (_tmp8_);
		_tmp10_ = _tmp9_;
		tootle_cache_item_set_references (_tmp8_, _tmp10_ + 1);
		_tmp11_ = item;
		_tmp12_ = tootle_cache_item_get_data (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = _data12_->key;
		_tmp15_ = g_strdup (_tmp14_);
		memset (&_tmp16_, 0, sizeof (TootleCacheReference));
		_tmp16_.data = _tmp13_;
		_g_free0 (_tmp16_.key);
		_tmp16_.key = _tmp15_;
		_tmp16_.loading = FALSE;
		_tmp17_ = _tmp16_;
		_tmp18_ = _tmp17_;
		_data12_->cb (&_tmp18_, _data12_->cb_target);
		tootle_cache_reference_destroy (&_tmp17_);
		_g_object_unref0 (item);
		block12_data_unref (_data12_);
		_data12_ = NULL;
		return;
	}
	_tmp19_ = self->priv->_items_in_progress;
	_tmp20_ = _data12_->key;
	_tmp21_ = g_hash_table_lookup (_tmp19_, _tmp20_);
	_tmp22_ = _g_object_ref0 ((SoupMessage*) _tmp21_);
	_data12_->msg = _tmp22_;
	_tmp23_ = _data12_->msg;
	if (_tmp23_ == NULL) {
		Block13Data* _data13_;
		SoupMessage* _tmp24_;
		SoupMessage* _tmp25_;
		gulong _tmp26_;
		TootleNetwork* _tmp27_;
		SoupMessage* _tmp28_;
		SoupMessage* _tmp29_;
		const gchar* _tmp30_;
		gchar* _tmp31_;
		TootleCacheReference _tmp32_ = {0};
		TootleCacheReference _tmp33_;
		TootleCacheReference _tmp34_;
		GHashTable* _tmp35_;
		const gchar* _tmp36_;
		gchar* _tmp37_;
		SoupMessage* _tmp38_;
		SoupMessage* _tmp39_;
		_data13_ = g_slice_new0 (Block13Data);
		_data13_->_ref_count_ = 1;
		_data13_->_data12_ = block12_data_ref (_data12_);
		_tmp24_ = soup_message_new ("GET", _data12_->url);
		_g_object_unref0 (_data12_->msg);
		_data12_->msg = _tmp24_;
		_data13_->id = (gulong) 0;
		_tmp25_ = _data12_->msg;
		_tmp26_ = g_signal_connect_data (_tmp25_, "finished", (GCallback) ____lambda15__soup_message_finished, block13_data_ref (_data13_), (GClosureNotify) block13_data_unref, 0);
		_data13_->id = _tmp26_;
		_tmp27_ = tootle_network;
		_tmp28_ = _data12_->msg;
		_tmp29_ = _g_object_ref0 (_tmp28_);
		tootle_network_queue (_tmp27_, _tmp29_, ____lambda25__tootle_network_success_callback, block13_data_ref (_data13_), block13_data_unref, ____lambda26__tootle_network_error_callback, block13_data_ref (_data13_), block13_data_unref);
		_tmp30_ = _data12_->key;
		_tmp31_ = g_strdup (_tmp30_);
		memset (&_tmp32_, 0, sizeof (TootleCacheReference));
		_tmp32_.data = NULL;
		_g_free0 (_tmp32_.key);
		_tmp32_.key = _tmp31_;
		_tmp32_.loading = TRUE;
		_tmp33_ = _tmp32_;
		_tmp34_ = _tmp33_;
		_data12_->cb (&_tmp34_, _data12_->cb_target);
		tootle_cache_reference_destroy (&_tmp33_);
		_tmp35_ = self->priv->_items_in_progress;
		_tmp36_ = _data12_->key;
		_tmp37_ = g_strdup (_tmp36_);
		_tmp38_ = _data12_->msg;
		_tmp39_ = _g_object_ref0 (_tmp38_);
		g_hash_table_insert (_tmp35_, _tmp37_, _tmp39_);
		block13_data_unref (_data13_);
		_data13_ = NULL;
	} else {
		Block14Data* _data14_;
		SoupMessage* _tmp40_;
		gulong _tmp41_;
		_data14_ = g_slice_new0 (Block14Data);
		_data14_->_ref_count_ = 1;
		_data14_->_data12_ = block12_data_ref (_data12_);
		_data14_->id = (gulong) 0;
		_tmp40_ = _data12_->msg;
		_tmp41_ = g_signal_connect_data (_tmp40_, "finished", (GCallback) ____lambda27__soup_message_finished, block14_data_ref (_data14_), (GClosureNotify) block14_data_unref, G_CONNECT_AFTER);
		_data14_->id = _tmp41_;
		block14_data_unref (_data14_);
		_data14_ = NULL;
	}
	block12_data_unref (_data12_);
	_data12_ = NULL;
}

void
tootle_cache_clear (TootleCache* self)
{
	GHashTable* _tmp0_;
	GHashTable* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_items;
	g_hash_table_remove_all (_tmp0_);
	_tmp1_ = self->priv->_items_in_progress;
	g_hash_table_remove_all (_tmp1_);
}

TootleCache*
tootle_cache_construct (GType object_type)
{
	TootleCache * self = NULL;
	self = (TootleCache*) g_object_new (object_type, NULL);
	return self;
}

TootleCache*
tootle_cache_new (void)
{
	return tootle_cache_construct (TOOTLE_TYPE_CACHE);
}

GHashTable*
tootle_cache_get_items (TootleCache* self)
{
	GHashTable* result;
	GHashTable* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_items;
	result = _tmp0_;
	return result;
}

static gpointer
_g_hash_table_ref0 (gpointer self)
{
	return self ? g_hash_table_ref (self) : NULL;
}

void
tootle_cache_set_items (TootleCache* self,
                        GHashTable* value)
{
	GHashTable* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_cache_get_items (self);
	if (old_value != value) {
		GHashTable* _tmp0_;
		_tmp0_ = _g_hash_table_ref0 (value);
		_g_hash_table_unref0 (self->priv->_items);
		self->priv->_items = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_cache_properties[TOOTLE_CACHE_ITEMS_PROPERTY]);
	}
}

GHashTable*
tootle_cache_get_items_in_progress (TootleCache* self)
{
	GHashTable* result;
	GHashTable* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_items_in_progress;
	result = _tmp0_;
	return result;
}

void
tootle_cache_set_items_in_progress (TootleCache* self,
                                    GHashTable* value)
{
	GHashTable* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_cache_get_items_in_progress (self);
	if (old_value != value) {
		GHashTable* _tmp0_;
		_tmp0_ = _g_hash_table_ref0 (value);
		_g_hash_table_unref0 (self->priv->_items_in_progress);
		self->priv->_items_in_progress = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_cache_properties[TOOTLE_CACHE_ITEMS_IN_PROGRESS_PROPERTY]);
	}
}

guint
tootle_cache_get_size (TootleCache* self)
{
	guint result;
	GHashTable* _tmp0_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->_items;
	result = g_hash_table_size (_tmp0_);
	return result;
}

static inline gpointer
tootle_cache_item_get_instance_private (TootleCacheItem* self)
{
	return G_STRUCT_MEMBER_P (self, TootleCacheItem_private_offset);
}

TootleCacheItem*
tootle_cache_item_construct (GType object_type,
                             GdkPixbuf* d,
                             gint r)
{
	TootleCacheItem * self = NULL;
	g_return_val_if_fail (d != NULL, NULL);
	self = (TootleCacheItem*) g_object_new (object_type, "data", d, "references", r, NULL);
	return self;
}

TootleCacheItem*
tootle_cache_item_new (GdkPixbuf* d,
                       gint r)
{
	return tootle_cache_item_construct (TOOTLE_CACHE_TYPE_ITEM, d, r);
}

GdkPixbuf*
tootle_cache_item_get_data (TootleCacheItem* self)
{
	GdkPixbuf* result;
	GdkPixbuf* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_data;
	result = _tmp0_;
	return result;
}

void
tootle_cache_item_set_data (TootleCacheItem* self,
                            GdkPixbuf* value)
{
	GdkPixbuf* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_cache_item_get_data (self);
	if (old_value != value) {
		GdkPixbuf* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_data);
		self->priv->_data = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_cache_item_properties[TOOTLE_CACHE_ITEM_DATA_PROPERTY]);
	}
}

gint
tootle_cache_item_get_references (TootleCacheItem* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_references;
	return result;
}

void
tootle_cache_item_set_references (TootleCacheItem* self,
                                  gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_cache_item_get_references (self);
	if (old_value != value) {
		self->priv->_references = value;
		g_object_notify_by_pspec ((GObject *) self, tootle_cache_item_properties[TOOTLE_CACHE_ITEM_REFERENCES_PROPERTY]);
	}
}

static void
tootle_cache_item_class_init (TootleCacheItemClass * klass,
                              gpointer klass_data)
{
	tootle_cache_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleCacheItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_cache_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_cache_item_set_property;
	G_OBJECT_CLASS (klass)->finalize = tootle_cache_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_CACHE_ITEM_DATA_PROPERTY, tootle_cache_item_properties[TOOTLE_CACHE_ITEM_DATA_PROPERTY] = g_param_spec_object ("data", "data", "data", gdk_pixbuf_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_CACHE_ITEM_REFERENCES_PROPERTY, tootle_cache_item_properties[TOOTLE_CACHE_ITEM_REFERENCES_PROPERTY] = g_param_spec_int ("references", "references", "references", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
tootle_cache_item_instance_init (TootleCacheItem * self,
                                 gpointer klass)
{
	self->priv = tootle_cache_item_get_instance_private (self);
}

static void
tootle_cache_item_finalize (GObject * obj)
{
	TootleCacheItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_CACHE_TYPE_ITEM, TootleCacheItem);
	_g_object_unref0 (self->priv->_data);
	G_OBJECT_CLASS (tootle_cache_item_parent_class)->finalize (obj);
}

static GType
tootle_cache_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleCacheItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_cache_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleCacheItem), 0, (GInstanceInitFunc) tootle_cache_item_instance_init, NULL };
	GType tootle_cache_item_type_id;
	tootle_cache_item_type_id = g_type_register_static (G_TYPE_OBJECT, "TootleCacheItem", &g_define_type_info, 0);
	TootleCacheItem_private_offset = g_type_add_instance_private (tootle_cache_item_type_id, sizeof (TootleCacheItemPrivate));
	return tootle_cache_item_type_id;
}

GType
tootle_cache_item_get_type (void)
{
	static volatile gsize tootle_cache_item_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_cache_item_type_id__volatile)) {
		GType tootle_cache_item_type_id;
		tootle_cache_item_type_id = tootle_cache_item_get_type_once ();
		g_once_init_leave (&tootle_cache_item_type_id__volatile, tootle_cache_item_type_id);
	}
	return tootle_cache_item_type_id__volatile;
}

static void
_vala_tootle_cache_item_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	TootleCacheItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_CACHE_TYPE_ITEM, TootleCacheItem);
	switch (property_id) {
		case TOOTLE_CACHE_ITEM_DATA_PROPERTY:
		g_value_set_object (value, tootle_cache_item_get_data (self));
		break;
		case TOOTLE_CACHE_ITEM_REFERENCES_PROPERTY:
		g_value_set_int (value, tootle_cache_item_get_references (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_cache_item_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	TootleCacheItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_CACHE_TYPE_ITEM, TootleCacheItem);
	switch (property_id) {
		case TOOTLE_CACHE_ITEM_DATA_PROPERTY:
		tootle_cache_item_set_data (self, g_value_get_object (value));
		break;
		case TOOTLE_CACHE_ITEM_REFERENCES_PROPERTY:
		tootle_cache_item_set_references (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

void
tootle_cache_reference_copy (const TootleCacheReference* self,
                             TootleCacheReference* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	GdkPixbuf* _tmp2_;
	_tmp0_ = (*self).key;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).key);
	(*dest).key = _tmp1_;
	_tmp2_ = (*self).data;
	(*dest).data = _tmp2_;
	(*dest).loading = (*self).loading;
}

void
tootle_cache_reference_destroy (TootleCacheReference* self)
{
	_g_free0 ((*self).key);
}

TootleCacheReference*
tootle_cache_reference_dup (const TootleCacheReference* self)
{
	TootleCacheReference* dup;
	dup = g_new0 (TootleCacheReference, 1);
	tootle_cache_reference_copy (self, dup);
	return dup;
}

void
tootle_cache_reference_free (TootleCacheReference* self)
{
	tootle_cache_reference_destroy (self);
	g_free (self);
}

static GType
tootle_cache_reference_get_type_once (void)
{
	GType tootle_cache_reference_type_id;
	tootle_cache_reference_type_id = g_boxed_type_register_static ("TootleCacheReference", (GBoxedCopyFunc) tootle_cache_reference_dup, (GBoxedFreeFunc) tootle_cache_reference_free);
	return tootle_cache_reference_type_id;
}

GType
tootle_cache_reference_get_type (void)
{
	static volatile gsize tootle_cache_reference_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_cache_reference_type_id__volatile)) {
		GType tootle_cache_reference_type_id;
		tootle_cache_reference_type_id = tootle_cache_reference_get_type_once ();
		g_once_init_leave (&tootle_cache_reference_type_id__volatile, tootle_cache_reference_type_id);
	}
	return tootle_cache_reference_type_id__volatile;
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static GObject *
tootle_cache_constructor (GType type,
                          guint n_construct_properties,
                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TootleCache * self;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	GHashTable* _tmp3_;
	GHashFunc _tmp4_;
	GEqualFunc _tmp5_;
	GHashTable* _tmp6_;
	GHashTable* _tmp7_;
	parent_class = G_OBJECT_CLASS (tootle_cache_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_TYPE_CACHE, TootleCache);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_object_unref0_);
	_tmp3_ = _tmp2_;
	tootle_cache_set_items (self, _tmp3_);
	_g_hash_table_unref0 (_tmp3_);
	_tmp4_ = g_str_hash;
	_tmp5_ = g_str_equal;
	_tmp6_ = g_hash_table_new_full (_tmp4_, _tmp5_, _g_free0_, _g_object_unref0_);
	_tmp7_ = _tmp6_;
	tootle_cache_set_items_in_progress (self, _tmp7_);
	_g_hash_table_unref0 (_tmp7_);
	return obj;
}

static void
tootle_cache_class_init (TootleCacheClass * klass,
                         gpointer klass_data)
{
	tootle_cache_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleCache_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_cache_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_cache_set_property;
	G_OBJECT_CLASS (klass)->constructor = tootle_cache_constructor;
	G_OBJECT_CLASS (klass)->finalize = tootle_cache_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_CACHE_ITEMS_PROPERTY, tootle_cache_properties[TOOTLE_CACHE_ITEMS_PROPERTY] = g_param_spec_boxed ("items", "items", "items", G_TYPE_HASH_TABLE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_CACHE_ITEMS_IN_PROGRESS_PROPERTY, tootle_cache_properties[TOOTLE_CACHE_ITEMS_IN_PROGRESS_PROPERTY] = g_param_spec_boxed ("items-in-progress", "items-in-progress", "items-in-progress", G_TYPE_HASH_TABLE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_CACHE_SIZE_PROPERTY, tootle_cache_properties[TOOTLE_CACHE_SIZE_PROPERTY] = g_param_spec_uint ("size", "size", "size", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
tootle_cache_instance_init (TootleCache * self,
                            gpointer klass)
{
	self->priv = tootle_cache_get_instance_private (self);
}

static void
tootle_cache_finalize (GObject * obj)
{
	TootleCache * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_TYPE_CACHE, TootleCache);
	_g_hash_table_unref0 (self->priv->_items);
	_g_hash_table_unref0 (self->priv->_items_in_progress);
	G_OBJECT_CLASS (tootle_cache_parent_class)->finalize (obj);
}

static GType
tootle_cache_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleCacheClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_cache_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleCache), 0, (GInstanceInitFunc) tootle_cache_instance_init, NULL };
	GType tootle_cache_type_id;
	tootle_cache_type_id = g_type_register_static (G_TYPE_OBJECT, "TootleCache", &g_define_type_info, 0);
	TootleCache_private_offset = g_type_add_instance_private (tootle_cache_type_id, sizeof (TootleCachePrivate));
	return tootle_cache_type_id;
}

GType
tootle_cache_get_type (void)
{
	static volatile gsize tootle_cache_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_cache_type_id__volatile)) {
		GType tootle_cache_type_id;
		tootle_cache_type_id = tootle_cache_get_type_once ();
		g_once_init_leave (&tootle_cache_type_id__volatile, tootle_cache_type_id);
	}
	return tootle_cache_type_id__volatile;
}

static void
_vala_tootle_cache_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	TootleCache * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_TYPE_CACHE, TootleCache);
	switch (property_id) {
		case TOOTLE_CACHE_ITEMS_PROPERTY:
		g_value_set_boxed (value, tootle_cache_get_items (self));
		break;
		case TOOTLE_CACHE_ITEMS_IN_PROGRESS_PROPERTY:
		g_value_set_boxed (value, tootle_cache_get_items_in_progress (self));
		break;
		case TOOTLE_CACHE_SIZE_PROPERTY:
		g_value_set_uint (value, tootle_cache_get_size (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_cache_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	TootleCache * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_TYPE_CACHE, TootleCache);
	switch (property_id) {
		case TOOTLE_CACHE_ITEMS_PROPERTY:
		tootle_cache_set_items (self, g_value_get_boxed (value));
		break;
		case TOOTLE_CACHE_ITEMS_IN_PROGRESS_PROPERTY:
		tootle_cache_set_items_in_progress (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

