/* object-cache.c generated by valac 0.14.0.50-58097f, the Vala compiler
 * generated from object-cache.vala, do not modify */

/*
 * Copyright (C) 2011 Collabora Ltd.
 *
 * This library 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.
 *
 * This library 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, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *       Philip Withnall <philip.withnall@collabora.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>


#define FOLKS_TYPE_OBJECT_CACHE (folks_object_cache_get_type ())
#define FOLKS_OBJECT_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_OBJECT_CACHE, FolksObjectCache))
#define FOLKS_OBJECT_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_TYPE_OBJECT_CACHE, FolksObjectCacheClass))
#define FOLKS_IS_OBJECT_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_OBJECT_CACHE))
#define FOLKS_IS_OBJECT_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_TYPE_OBJECT_CACHE))
#define FOLKS_OBJECT_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_TYPE_OBJECT_CACHE, FolksObjectCacheClass))

typedef struct _FolksObjectCache FolksObjectCache;
typedef struct _FolksObjectCacheClass FolksObjectCacheClass;
typedef struct _FolksObjectCachePrivate FolksObjectCachePrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_variant_type_free0(var) ((var == NULL) ? NULL : (var = (g_variant_type_free (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
typedef struct _FolksObjectCacheLoadObjectsData FolksObjectCacheLoadObjectsData;
typedef struct _FolksObjectCacheStoreObjectsData FolksObjectCacheStoreObjectsData;
typedef struct _FolksObjectCacheClearCacheData FolksObjectCacheClearCacheData;
typedef struct _FolksObjectCacheCreateCacheDirectoryData FolksObjectCacheCreateCacheDirectoryData;

struct _FolksObjectCache {
	GObject parent_instance;
	FolksObjectCachePrivate * priv;
};

struct _FolksObjectCacheClass {
	GObjectClass parent_class;
	GVariantType* (*get_serialised_object_type) (FolksObjectCache* self, guint8 object_version);
	guint8 (*get_serialised_object_version) (FolksObjectCache* self);
	GVariant* (*serialise_object) (FolksObjectCache* self, gconstpointer object);
	gpointer (*deserialise_object) (FolksObjectCache* self, GVariant* variant, guint8 object_version);
};

struct _FolksObjectCachePrivate {
	GType t_type;
	GBoxedCopyFunc t_dup_func;
	GDestroyNotify t_destroy_func;
	GFile* _cache_directory;
	GFile* _cache_file;
	gchar* _type_id;
	gchar* _id;
};

struct _FolksObjectCacheLoadObjectsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FolksObjectCache* self;
	GCancellable* cancellable;
	GeeSet* result;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GFile* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	guint8* data;
	gint data_length1;
	gint _data_size_;
	GFile* _tmp5_;
	GCancellable* _tmp6_;
	guint8* _tmp7_;
	gint _tmp8_;
	GError* e;
	GError* _tmp9_;
	GError* _tmp10_;
	GFile* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GError* _tmp14_;
	const gchar* _tmp15_;
	GFile* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	GError* _tmp19_;
	const gchar* _tmp20_;
	guint8* _tmp21_;
	gint _tmp21__length1;
	GFile* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	guint8* _tmp25_;
	gint _tmp25__length1;
	guint8 _tmp26_;
	guint8 wrapper_version;
	guint8* _tmp27_;
	gint _tmp27__length1;
	guint8 _tmp28_;
	guint8 object_version;
	guint8 _tmp29_;
	GFile* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	guint8 _tmp33_;
	guint8* _tmp34_;
	gint _tmp34__length1;
	guint8* _tmp35_;
	gint _tmp35__length1;
	guint8* variant_data;
	gint variant_data_length1;
	gint _variant_data_size_;
	guint8 _tmp36_;
	guint8 _tmp37_;
	GVariantType* _tmp38_;
	GVariantType* variant_type;
	const GVariantType* _tmp39_;
	GFile* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	guint8 _tmp43_;
	const GVariantType* _tmp44_;
	guint8* _tmp45_;
	gint _tmp45__length1;
	guint8* _tmp46_;
	gint _tmp46__length1;
	guint8* _tmp47_;
	gint _tmp47__length1;
	GVariant* _tmp48_;
	GVariant* _tmp49_;
	GVariant* variant;
	GVariant* _tmp50_;
	gboolean _tmp51_;
	GFile* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	GVariant* _tmp55_;
	GVariant* _tmp56_;
	GVariant* _tmp57_;
	const gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	gchar* type_id;
	const gchar* _tmp61_;
	const gchar* _tmp62_;
	GFile* _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	const gchar* _tmp66_;
	const gchar* _tmp67_;
	GVariant* _tmp68_;
	GVariant* _tmp69_;
	GVariant* _tmp70_;
	const gchar* _tmp71_;
	gchar* _tmp72_;
	gchar* _tmp73_;
	gchar* id;
	const gchar* _tmp74_;
	const gchar* _tmp75_;
	GFile* _tmp76_;
	gchar* _tmp77_;
	gchar* _tmp78_;
	const gchar* _tmp79_;
	const gchar* _tmp80_;
	GVariant* _tmp81_;
	GVariant* _tmp82_;
	GVariant* objects_variant;
	GeeHashSet* _tmp83_;
	GeeHashSet* objects;
	guint i;
	gboolean _tmp84_;
	gboolean _tmp85_;
	guint _tmp86_;
	guint _tmp87_;
	GVariant* _tmp88_;
	gsize _tmp89_;
	GVariant* _tmp90_;
	guint _tmp91_;
	GVariant* _tmp92_;
	GVariant* object_variant;
	GVariant* _tmp93_;
	guint8 _tmp94_;
	gpointer _tmp95_;
	gpointer object;
	GeeHashSet* _tmp96_;
	gconstpointer _tmp97_;
	GError * _inner_error_;
};

struct _FolksObjectCacheStoreObjectsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FolksObjectCache* self;
	GeeSet* objects;
	GCancellable* cancellable;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GFile* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	guint8 _tmp5_;
	GVariantType* _tmp6_;
	GVariantType* child_type;
	const GVariantType* _tmp7_;
	GeeSet* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	GVariant** _tmp11_;
	GVariant** children;
	gint children_length1;
	gint _children_size_;
	guint i;
	GeeSet* _tmp12_;
	GeeIterator* _tmp13_;
	GeeIterator* _object_it;
	GeeIterator* _tmp14_;
	gboolean _tmp15_;
	GeeIterator* _tmp16_;
	gpointer _tmp17_;
	gpointer object;
	GVariant** _tmp18_;
	gint _tmp18__length1;
	guint _tmp19_;
	gconstpointer _tmp20_;
	GVariant* _tmp21_;
	GVariant* _tmp22_;
	guint8 wrapper_version;
	guint8 _tmp23_;
	guint8 object_version;
	const gchar* _tmp24_;
	GVariant* _tmp25_;
	GVariant* _tmp26_;
	const gchar* _tmp27_;
	GVariant* _tmp28_;
	GVariant* _tmp29_;
	const GVariantType* _tmp30_;
	GVariant** _tmp31_;
	gint _tmp31__length1;
	GVariant* _tmp32_;
	GVariant* _tmp33_;
	GVariant** _tmp34_;
	GVariant** _tmp35_;
	gint _tmp35__length1;
	GVariant* _tmp36_;
	GVariant* _tmp37_;
	GVariant* _tmp38_;
	GVariant* variant;
	GVariant* _tmp39_;
	const GVariantType* _tmp40_;
	guint8 _tmp41_;
	guint8 _tmp42_;
	GVariantType* _tmp43_;
	GVariantType* _tmp44_;
	gboolean _tmp45_;
	GVariant* _tmp46_;
	gsize _tmp47_;
	guint8* _tmp48_;
	guint8* data;
	gint data_length1;
	gint _data_size_;
	guint8* _tmp49_;
	gint _tmp49__length1;
	guint8 _tmp50_;
	guint8 _tmp51_;
	guint8* _tmp52_;
	gint _tmp52__length1;
	guint8 _tmp53_;
	guint8 _tmp54_;
	GVariant* _tmp55_;
	guint8* _tmp56_;
	gint _tmp56__length1;
	guint8* _tmp57_;
	gint _tmp57__length1;
	GFile* _tmp58_;
	guint8* _tmp59_;
	gint _tmp59__length1;
	guint8* _tmp60_;
	gint _tmp60__length1;
	GCancellable* _tmp61_;
	GError* e;
	GError* _tmp62_;
	GError* e2;
	GFile* _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	GError* _tmp66_;
	const gchar* _tmp67_;
	GError* _tmp68_;
	GFile* _tmp69_;
	gchar* _tmp70_;
	gchar* _tmp71_;
	GError* _tmp72_;
	const gchar* _tmp73_;
	GError * _inner_error_;
};

struct _FolksObjectCacheClearCacheData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FolksObjectCache* self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GFile* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GFile* _tmp5_;
	GError* e;
	GError * _inner_error_;
};

struct _FolksObjectCacheCreateCacheDirectoryData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FolksObjectCache* self;
	GFile* _tmp0_;
	GError* e;
	GError* _tmp1_;
	GError* _tmp2_;
	GError* _tmp3_;
	GError * _inner_error_;
};


static gpointer folks_object_cache_parent_class = NULL;

GType folks_object_cache_get_type (void) G_GNUC_CONST;
#define FOLKS_OBJECT_CACHE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), FOLKS_TYPE_OBJECT_CACHE, FolksObjectCachePrivate))
enum  {
	FOLKS_OBJECT_CACHE_DUMMY_PROPERTY,
	FOLKS_OBJECT_CACHE_T_TYPE,
	FOLKS_OBJECT_CACHE_T_DUP_FUNC,
	FOLKS_OBJECT_CACHE_T_DESTROY_FUNC,
	FOLKS_OBJECT_CACHE_TYPE_ID,
	FOLKS_OBJECT_CACHE_ID
};
#define FOLKS_OBJECT_CACHE__FILE_FORMAT_VERSION ((guint8) 1)
#define FOLKS_OBJECT_CACHE__HEADER_WIDTH ((gsize) 8)
GVariantType* folks_object_cache_get_serialised_object_type (FolksObjectCache* self, guint8 object_version);
static GVariantType* folks_object_cache_real_get_serialised_object_type (FolksObjectCache* self, guint8 object_version);
guint8 folks_object_cache_get_serialised_object_version (FolksObjectCache* self);
static guint8 folks_object_cache_real_get_serialised_object_version (FolksObjectCache* self);
GVariant* folks_object_cache_serialise_object (FolksObjectCache* self, gconstpointer object);
static GVariant* folks_object_cache_real_serialise_object (FolksObjectCache* self, gconstpointer object);
gpointer folks_object_cache_deserialise_object (FolksObjectCache* self, GVariant* variant, guint8 object_version);
static gpointer folks_object_cache_real_deserialise_object (FolksObjectCache* self, GVariant* variant, guint8 object_version);
FolksObjectCache* folks_object_cache_construct (GType object_type, GType t_type, GBoxedCopyFunc t_dup_func, GDestroyNotify t_destroy_func, const gchar* type_id, const gchar* id);
static void folks_object_cache_load_objects_data_free (gpointer _data);
void folks_object_cache_load_objects (FolksObjectCache* self, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
GeeSet* folks_object_cache_load_objects_finish (FolksObjectCache* self, GAsyncResult* _res_);
static gboolean folks_object_cache_load_objects_co (FolksObjectCacheLoadObjectsData* _data_);
const gchar* folks_object_cache_get_type_id (FolksObjectCache* self);
static void folks_object_cache_load_objects_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void folks_object_cache_clear_cache (FolksObjectCache* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
void folks_object_cache_clear_cache_finish (FolksObjectCache* self, GAsyncResult* _res_);
static GVariantType* _folks_object_cache_get_cache_file_variant_type (FolksObjectCache* self, guint8 wrapper_version, guint8 object_version);
static guint8* _vala_array_dup1 (guint8* self, int length);
static void folks_object_cache_store_objects_data_free (gpointer _data);
void folks_object_cache_store_objects (FolksObjectCache* self, GeeSet* objects, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
void folks_object_cache_store_objects_finish (FolksObjectCache* self, GAsyncResult* _res_);
static gboolean folks_object_cache_store_objects_co (FolksObjectCacheStoreObjectsData* _data_);
static void folks_object_cache_store_objects_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void _folks_object_cache_create_cache_directory (FolksObjectCache* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _folks_object_cache_create_cache_directory_finish (FolksObjectCache* self, GAsyncResult* _res_, GError** error);
static void folks_object_cache_clear_cache_data_free (gpointer _data);
static gboolean folks_object_cache_clear_cache_co (FolksObjectCacheClearCacheData* _data_);
static void _folks_object_cache_create_cache_directory_data_free (gpointer _data);
static gboolean _folks_object_cache_create_cache_directory_co (FolksObjectCacheCreateCacheDirectoryData* _data_);
static void folks_object_cache_set_type_id (FolksObjectCache* self, const gchar* value);
const gchar* folks_object_cache_get_id (FolksObjectCache* self);
static void folks_object_cache_set_id (FolksObjectCache* self, const gchar* value);
static GObject * folks_object_cache_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void folks_object_cache_finalize (GObject* obj);
static void _vala_folks_object_cache_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_folks_object_cache_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
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);


/**
   * Get the {@link GLib.VariantType} of the serialised form of an object stored
   * in this cache.
   *
   * If a smooth upgrade path is needed in future due to cache file format
   * changes, this may be modified to take a version parameter.
   *
   * @param object_version the version of the object format to use, or
   * `uint8.MAX` for the latest version
   * @return variant type for that object version, or `null` if the version is
   * unsupported
   * @since 0.6.0
   */
static GVariantType* folks_object_cache_real_get_serialised_object_type (FolksObjectCache* self, guint8 object_version) {
	g_critical ("Type `%s' does not implement abstract method `folks_object_cache_get_serialised_object_type'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}


GVariantType* folks_object_cache_get_serialised_object_type (FolksObjectCache* self, guint8 object_version) {
	g_return_val_if_fail (self != NULL, NULL);
	return FOLKS_OBJECT_CACHE_GET_CLASS (self)->get_serialised_object_type (self, object_version);
}


/**
   * Get the version of the variant type returned by
   * {@link ObjectCache.get_serialised_object_type}. This must be incremented
   * every time the variant type changes so that old cache files aren't
   * misinterpreted.
   *
   * @since 0.6.0
   */
static guint8 folks_object_cache_real_get_serialised_object_version (FolksObjectCache* self) {
	g_critical ("Type `%s' does not implement abstract method `folks_object_cache_get_serialised_object_version'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return 0U;
}


guint8 folks_object_cache_get_serialised_object_version (FolksObjectCache* self) {
	g_return_val_if_fail (self != NULL, 0U);
	return FOLKS_OBJECT_CACHE_GET_CLASS (self)->get_serialised_object_version (self);
}


/**
   * Serialise the given `object` to a {@link GLib.Variant} and return the
   * variant. The variant must be of the type returned by
   * {@link ObjectCache.get_serialised_object_type}.
   *
   * @param object the object to serialise
   * @return serialised form of `object`
   *
   * @since 0.6.0
   */
static GVariant* folks_object_cache_real_serialise_object (FolksObjectCache* self, gconstpointer object) {
	g_critical ("Type `%s' does not implement abstract method `folks_object_cache_serialise_object'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}


GVariant* folks_object_cache_serialise_object (FolksObjectCache* self, gconstpointer object) {
	g_return_val_if_fail (self != NULL, NULL);
	return FOLKS_OBJECT_CACHE_GET_CLASS (self)->serialise_object (self, object);
}


/**
   * Deserialise the given `variant` to a new instance of an object. The variant
   * is guaranteed to have the type returned by
   * {@link ObjectCache.get_serialised_object_type}.
   *
   * @param variant the serialised form to deserialise
   * @param object_version the version of the object format to deserialise from
   * @return the deserialised object
   *
   * @since 0.6.0
   */
static gpointer folks_object_cache_real_deserialise_object (FolksObjectCache* self, GVariant* variant, guint8 object_version) {
	g_critical ("Type `%s' does not implement abstract method `folks_object_cache_deserialise_object'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}


gpointer folks_object_cache_deserialise_object (FolksObjectCache* self, GVariant* variant, guint8 object_version) {
	g_return_val_if_fail (self != NULL, NULL);
	return FOLKS_OBJECT_CACHE_GET_CLASS (self)->deserialise_object (self, variant, object_version);
}


/**
   * Create a new cache instance using the given type ID and ID. This is
   * protected as the `type_id` will typically be set statically by subclasses.
   *
   * @param type_id A string identifying the type of object being cached. This
   * has to be suitable for use as a directory name; i.e. lower case,
   * hyphen-separated.
   * @param id A string identifying the particular cache instance. This will
   * form the file name of the cache file, but will be escaped beforehand, so
   * can be an arbitrary non-empty string.
   * @return A new cache instance
   *
   * @since 0.6.0
   */
FolksObjectCache* folks_object_cache_construct (GType object_type, GType t_type, GBoxedCopyFunc t_dup_func, GDestroyNotify t_destroy_func, const gchar* type_id, const gchar* id) {
	FolksObjectCache * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (type_id != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	_tmp0_ = type_id;
	_tmp1_ = id;
	self = (FolksObjectCache*) g_object_new (object_type, "type-id", _tmp0_, "id", _tmp1_, NULL);
	self->priv->t_type = t_type;
	self->priv->t_dup_func = t_dup_func;
	self->priv->t_destroy_func = t_destroy_func;
	return self;
}


static void folks_object_cache_load_objects_data_free (gpointer _data) {
	FolksObjectCacheLoadObjectsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (FolksObjectCacheLoadObjectsData, _data_);
}


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


void folks_object_cache_load_objects (FolksObjectCache* self, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FolksObjectCacheLoadObjectsData* _data_;
	FolksObjectCache* _tmp0_;
	GCancellable* _tmp1_;
	GCancellable* _tmp2_;
	_data_ = g_slice_new0 (FolksObjectCacheLoadObjectsData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, folks_object_cache_load_objects);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, folks_object_cache_load_objects_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = cancellable;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data_->cancellable = _tmp2_;
	folks_object_cache_load_objects_co (_data_);
}


GeeSet* folks_object_cache_load_objects_finish (FolksObjectCache* self, GAsyncResult* _res_) {
	GeeSet* result;
	FolksObjectCacheLoadObjectsData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
	result = _data_->result;
	_data_->result = NULL;
	return result;
}


/**
   * Load a set of objects from the cache and return them as a new set. If the
   * cache file doesn't exist, `null` will be returned. An empty set will be
   * returned if the cache file existed but was empty (i.e. was stored with
   * an empty set originally).
   *
   * Loading the objects can be cancelled using `cancellable`. If it is, `null`
   * will be returned.
   *
   * If any errors are encountered while loading the objects, warnings will be
   * logged as appropriate and `null` will be returned.
   *
   * @param cancellable A {@link GLib.Cancellable} for the operation, or `null`.
   * @return A set of objects from the cache, or `null`.
   *
   * @since 0.6.0
   */
static void folks_object_cache_load_objects_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	FolksObjectCacheLoadObjectsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	folks_object_cache_load_objects_co (_data_);
}


static guint8* _vala_array_dup1 (guint8* self, int length) {
	return g_memdup (self, length * sizeof (guint8));
}


static gboolean folks_object_cache_load_objects_co (FolksObjectCacheLoadObjectsData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		case 5:
		goto _state_5;
		case 6:
		goto _state_6;
		case 7:
		goto _state_7;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_type_id;
	_data_->_tmp1_ = _data_->self->priv->_id;
	_data_->_tmp2_ = _data_->self->priv->_cache_file;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = g_file_get_path (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	g_debug ("object-cache.vala:186: Loading cache (type ID '%s', ID '%s') from file" \
" '%s'.", _data_->_tmp0_, _data_->_tmp1_, _data_->_tmp4_);
	_g_free0 (_data_->_tmp4_);
	_data_->data_length1 = 0;
	_data_->_data_size_ = 0;
	{
		_data_->_tmp5_ = _data_->self->priv->_cache_file;
		_data_->_tmp6_ = _data_->cancellable;
		_data_->_tmp7_ = NULL;
		_data_->_tmp8_ = 0;
		_data_->_state_ = 1;
		g_file_load_contents_async (_data_->_tmp5_, _data_->_tmp6_, folks_object_cache_load_objects_ready, _data_);
		return FALSE;
		_state_1:
		g_file_load_contents_finish (_data_->_tmp5_, _data_->_res_, &_data_->_tmp7_, &_data_->_tmp8_, NULL, &_data_->_inner_error_);
		_data_->data = (g_free (_data_->data), NULL);
		_data_->data = _data_->_tmp7_;
		_data_->data_length1 = _data_->_tmp8_;
		_data_->_data_size_ = _data_->data_length1;
		if (_data_->_inner_error_ != NULL) {
			goto __catch35_g_error;
		}
	}
	goto __finally35;
	__catch35_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp9_ = _data_->e;
		if (g_error_matches (_data_->_tmp9_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
		} else {
			_data_->_tmp10_ = _data_->e;
			if (g_error_matches (_data_->_tmp10_, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
				_data_->_tmp11_ = _data_->self->priv->_cache_file;
				_data_->_tmp12_ = NULL;
				_data_->_tmp12_ = g_file_get_path (_data_->_tmp11_);
				_data_->_tmp13_ = _data_->_tmp12_;
				_data_->_tmp14_ = _data_->e;
				_data_->_tmp15_ = _data_->_tmp14_->message;
				g_debug ("object-cache.vala:204: Couldn't load cache file '%s': %s", _data_->_tmp13_, _data_->_tmp15_);
				_g_free0 (_data_->_tmp13_);
			} else {
				_data_->_tmp16_ = _data_->self->priv->_cache_file;
				_data_->_tmp17_ = NULL;
				_data_->_tmp17_ = g_file_get_path (_data_->_tmp16_);
				_data_->_tmp18_ = _data_->_tmp17_;
				_data_->_tmp19_ = _data_->e;
				_data_->_tmp20_ = _data_->_tmp19_->message;
				g_warning ("object-cache.vala:209: Couldn't load cache file '%s': %s", _data_->_tmp18_, _data_->_tmp20_);
				_g_free0 (_data_->_tmp18_);
			}
		}
		_data_->result = NULL;
		_g_error_free0 (_data_->e);
		_data_->data = (g_free (_data_->data), NULL);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally35:
	if (_data_->_inner_error_ != NULL) {
		_data_->data = (g_free (_data_->data), NULL);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	_data_->_tmp21_ = _data_->data;
	_data_->_tmp21__length1 = _data_->data_length1;
	if (((gsize) _data_->_tmp21__length1) < FOLKS_OBJECT_CACHE__HEADER_WIDTH) {
		_data_->_tmp22_ = _data_->self->priv->_cache_file;
		_data_->_tmp23_ = NULL;
		_data_->_tmp23_ = g_file_get_path (_data_->_tmp22_);
		_data_->_tmp24_ = _data_->_tmp23_;
		g_warning ("object-cache.vala:219: Cache file '%s' was too small. The file was del" \
"eted.", _data_->_tmp24_);
		_g_free0 (_data_->_tmp24_);
		_data_->_state_ = 2;
		folks_object_cache_clear_cache (_data_->self, folks_object_cache_load_objects_ready, _data_);
		return FALSE;
		_state_2:
		folks_object_cache_clear_cache_finish (_data_->self, _data_->_res_);
		_data_->result = NULL;
		_data_->data = (g_free (_data_->data), NULL);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp25_ = _data_->data;
	_data_->_tmp25__length1 = _data_->data_length1;
	_data_->_tmp26_ = _data_->_tmp25_[0];
	_data_->wrapper_version = _data_->_tmp26_;
	_data_->_tmp27_ = _data_->data;
	_data_->_tmp27__length1 = _data_->data_length1;
	_data_->_tmp28_ = _data_->_tmp27_[1];
	_data_->object_version = _data_->_tmp28_;
	_data_->_tmp29_ = _data_->wrapper_version;
	if (_data_->_tmp29_ != FOLKS_OBJECT_CACHE__FILE_FORMAT_VERSION) {
		_data_->_tmp30_ = _data_->self->priv->_cache_file;
		_data_->_tmp31_ = NULL;
		_data_->_tmp31_ = g_file_get_path (_data_->_tmp30_);
		_data_->_tmp32_ = _data_->_tmp31_;
		_data_->_tmp33_ = _data_->wrapper_version;
		g_warning ("Cache file '%s' was version %u of the file format, " "but only version %u is supported. The file was deleted.", _data_->_tmp32_, _data_->_tmp33_, FOLKS_OBJECT_CACHE__FILE_FORMAT_VERSION);
		_g_free0 (_data_->_tmp32_);
		_data_->_state_ = 3;
		folks_object_cache_clear_cache (_data_->self, folks_object_cache_load_objects_ready, _data_);
		return FALSE;
		_state_3:
		folks_object_cache_clear_cache_finish (_data_->self, _data_->_res_);
		_data_->result = NULL;
		_data_->data = (g_free (_data_->data), NULL);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp34_ = _data_->data;
	_data_->_tmp34__length1 = _data_->data_length1;
	_data_->_tmp35_ = _data_->data;
	_data_->_tmp35__length1 = _data_->data_length1;
	_data_->variant_data = _data_->_tmp34_ + FOLKS_OBJECT_CACHE__HEADER_WIDTH;
	_data_->variant_data_length1 = _data_->_tmp35__length1 - FOLKS_OBJECT_CACHE__HEADER_WIDTH;
	_data_->_variant_data_size_ = _data_->variant_data_length1;
	_data_->_tmp36_ = _data_->wrapper_version;
	_data_->_tmp37_ = _data_->object_version;
	_data_->_tmp38_ = NULL;
	_data_->_tmp38_ = _folks_object_cache_get_cache_file_variant_type (_data_->self, _data_->_tmp36_, _data_->_tmp37_);
	_data_->variant_type = _data_->_tmp38_;
	_data_->_tmp39_ = _data_->variant_type;
	if (_data_->_tmp39_ == NULL) {
		_data_->_tmp40_ = _data_->self->priv->_cache_file;
		_data_->_tmp41_ = NULL;
		_data_->_tmp41_ = g_file_get_path (_data_->_tmp40_);
		_data_->_tmp42_ = _data_->_tmp41_;
		_data_->_tmp43_ = _data_->object_version;
		g_warning ("Cache file '%s' was version %u of the object file " "format, which is not supported. The file was deleted.", _data_->_tmp42_, _data_->_tmp43_, FOLKS_OBJECT_CACHE__FILE_FORMAT_VERSION);
		_g_free0 (_data_->_tmp42_);
		_data_->_state_ = 4;
		folks_object_cache_clear_cache (_data_->self, folks_object_cache_load_objects_ready, _data_);
		return FALSE;
		_state_4:
		folks_object_cache_clear_cache_finish (_data_->self, _data_->_res_);
		_data_->result = NULL;
		_g_variant_type_free0 (_data_->variant_type);
		_data_->data = (g_free (_data_->data), NULL);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp44_ = _data_->variant_type;
	_data_->_tmp45_ = _data_->variant_data;
	_data_->_tmp45__length1 = _data_->variant_data_length1;
	_data_->_tmp46_ = _data_->data;
	_data_->_tmp46__length1 = _data_->data_length1;
	_data_->_tmp47_ = (_data_->_tmp46_ != NULL) ? _vala_array_dup1 (_data_->_tmp46_, _data_->_tmp46__length1) : ((gpointer) _data_->_tmp46_);
	_data_->_tmp47__length1 = _data_->_tmp46__length1;
	_data_->_tmp48_ = NULL;
	_data_->_tmp48_ = g_variant_new_from_data (_data_->_tmp44_, _data_->_tmp45_, _data_->_tmp45__length1, FALSE, g_free, _data_->_tmp47_);
	_data_->_tmp49_ = g_variant_ref_sink (_data_->_tmp48_);
	_data_->variant = _data_->_tmp49_;
	_data_->_tmp50_ = _data_->variant;
	_data_->_tmp51_ = FALSE;
	_data_->_tmp51_ = g_variant_is_normal_form (_data_->_tmp50_);
	if (_data_->_tmp51_ == FALSE) {
		_data_->_tmp52_ = _data_->self->priv->_cache_file;
		_data_->_tmp53_ = NULL;
		_data_->_tmp53_ = g_file_get_path (_data_->_tmp52_);
		_data_->_tmp54_ = _data_->_tmp53_;
		g_warning ("object-cache.vala:265: Cache file '%s' was corrupt and was deleted.", _data_->_tmp54_);
		_g_free0 (_data_->_tmp54_);
		_data_->_state_ = 5;
		folks_object_cache_clear_cache (_data_->self, folks_object_cache_load_objects_ready, _data_);
		return FALSE;
		_state_5:
		folks_object_cache_clear_cache_finish (_data_->self, _data_->_res_);
		_data_->result = NULL;
		_g_variant_unref0 (_data_->variant);
		_g_variant_type_free0 (_data_->variant_type);
		_data_->data = (g_free (_data_->data), NULL);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp55_ = _data_->variant;
	_data_->_tmp56_ = NULL;
	_data_->_tmp56_ = g_variant_get_child_value (_data_->_tmp55_, (gsize) 0);
	_data_->_tmp57_ = _data_->_tmp56_;
	_data_->_tmp58_ = NULL;
	_data_->_tmp58_ = g_variant_get_string (_data_->_tmp57_, NULL);
	_data_->_tmp59_ = g_strdup (_data_->_tmp58_);
	_data_->_tmp60_ = _data_->_tmp59_;
	_g_variant_unref0 (_data_->_tmp57_);
	_data_->type_id = _data_->_tmp60_;
	_data_->_tmp61_ = _data_->type_id;
	_data_->_tmp62_ = _data_->self->priv->_type_id;
	if (g_strcmp0 (_data_->_tmp61_, _data_->_tmp62_) != 0) {
		_data_->_tmp63_ = _data_->self->priv->_cache_file;
		_data_->_tmp64_ = NULL;
		_data_->_tmp64_ = g_file_get_path (_data_->_tmp63_);
		_data_->_tmp65_ = _data_->_tmp64_;
		_data_->_tmp66_ = _data_->type_id;
		_data_->_tmp67_ = _data_->self->priv->_type_id;
		g_warning ("Cache file '%s' had type ID '%s', but '%s' was expected." "The file was deleted.", _data_->_tmp65_, _data_->_tmp66_, _data_->_tmp67_);
		_g_free0 (_data_->_tmp65_);
		_data_->_state_ = 6;
		folks_object_cache_clear_cache (_data_->self, folks_object_cache_load_objects_ready, _data_);
		return FALSE;
		_state_6:
		folks_object_cache_clear_cache_finish (_data_->self, _data_->_res_);
		_data_->result = NULL;
		_g_free0 (_data_->type_id);
		_g_variant_unref0 (_data_->variant);
		_g_variant_type_free0 (_data_->variant_type);
		_data_->data = (g_free (_data_->data), NULL);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp68_ = _data_->variant;
	_data_->_tmp69_ = NULL;
	_data_->_tmp69_ = g_variant_get_child_value (_data_->_tmp68_, (gsize) 1);
	_data_->_tmp70_ = _data_->_tmp69_;
	_data_->_tmp71_ = NULL;
	_data_->_tmp71_ = g_variant_get_string (_data_->_tmp70_, NULL);
	_data_->_tmp72_ = g_strdup (_data_->_tmp71_);
	_data_->_tmp73_ = _data_->_tmp72_;
	_g_variant_unref0 (_data_->_tmp70_);
	_data_->id = _data_->_tmp73_;
	_data_->_tmp74_ = _data_->id;
	_data_->_tmp75_ = _data_->self->priv->_id;
	if (g_strcmp0 (_data_->_tmp74_, _data_->_tmp75_) != 0) {
		_data_->_tmp76_ = _data_->self->priv->_cache_file;
		_data_->_tmp77_ = NULL;
		_data_->_tmp77_ = g_file_get_path (_data_->_tmp76_);
		_data_->_tmp78_ = _data_->_tmp77_;
		_data_->_tmp79_ = _data_->id;
		_data_->_tmp80_ = _data_->self->priv->_id;
		g_warning ("Cache file '%s' had ID '%s', but '%s' was expected." "The file was deleted.", _data_->_tmp78_, _data_->_tmp79_, _data_->_tmp80_);
		_g_free0 (_data_->_tmp78_);
		_data_->_state_ = 7;
		folks_object_cache_clear_cache (_data_->self, folks_object_cache_load_objects_ready, _data_);
		return FALSE;
		_state_7:
		folks_object_cache_clear_cache_finish (_data_->self, _data_->_res_);
		_data_->result = NULL;
		_g_free0 (_data_->id);
		_g_free0 (_data_->type_id);
		_g_variant_unref0 (_data_->variant);
		_g_variant_type_free0 (_data_->variant_type);
		_data_->data = (g_free (_data_->data), NULL);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp81_ = _data_->variant;
	_data_->_tmp82_ = NULL;
	_data_->_tmp82_ = g_variant_get_child_value (_data_->_tmp81_, (gsize) 2);
	_data_->objects_variant = _data_->_tmp82_;
	_data_->_tmp83_ = gee_hash_set_new (_data_->self->priv->t_type, (GBoxedCopyFunc) _data_->self->priv->t_dup_func, _data_->self->priv->t_destroy_func, NULL, NULL);
	_data_->objects = _data_->_tmp83_;
	{
		_data_->i = (guint) 0;
		{
			_data_->_tmp84_ = TRUE;
			while (TRUE) {
				_data_->_tmp85_ = _data_->_tmp84_;
				if (!_data_->_tmp85_) {
					_data_->_tmp86_ = _data_->i;
					_data_->i = _data_->_tmp86_ + 1;
				}
				_data_->_tmp84_ = FALSE;
				_data_->_tmp87_ = _data_->i;
				_data_->_tmp88_ = _data_->objects_variant;
				_data_->_tmp89_ = 0UL;
				_data_->_tmp89_ = g_variant_n_children (_data_->_tmp88_);
				if (!(((gsize) _data_->_tmp87_) < _data_->_tmp89_)) {
					break;
				}
				_data_->_tmp90_ = _data_->objects_variant;
				_data_->_tmp91_ = _data_->i;
				_data_->_tmp92_ = NULL;
				_data_->_tmp92_ = g_variant_get_child_value (_data_->_tmp90_, (gsize) _data_->_tmp91_);
				_data_->object_variant = _data_->_tmp92_;
				_data_->_tmp93_ = _data_->object_variant;
				_data_->_tmp94_ = _data_->object_version;
				_data_->_tmp95_ = NULL;
				_data_->_tmp95_ = folks_object_cache_deserialise_object (_data_->self, _data_->_tmp93_, _data_->_tmp94_);
				_data_->object = _data_->_tmp95_;
				_data_->_tmp96_ = _data_->objects;
				_data_->_tmp97_ = _data_->object;
				gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp96_, _data_->_tmp97_);
				((_data_->object == NULL) || (_data_->self->priv->t_destroy_func == NULL)) ? NULL : (_data_->object = (_data_->self->priv->t_destroy_func (_data_->object), NULL));
				_g_variant_unref0 (_data_->object_variant);
			}
		}
	}
	_data_->result = (GeeSet*) _data_->objects;
	_g_variant_unref0 (_data_->objects_variant);
	_g_free0 (_data_->id);
	_g_free0 (_data_->type_id);
	_g_variant_unref0 (_data_->variant);
	_g_variant_type_free0 (_data_->variant_type);
	_data_->data = (g_free (_data_->data), NULL);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
	_g_object_unref0 (_data_->objects);
	_g_variant_unref0 (_data_->objects_variant);
	_g_free0 (_data_->id);
	_g_free0 (_data_->type_id);
	_g_variant_unref0 (_data_->variant);
	_g_variant_type_free0 (_data_->variant_type);
	_data_->data = (g_free (_data_->data), NULL);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void folks_object_cache_store_objects_data_free (gpointer _data) {
	FolksObjectCacheStoreObjectsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->objects);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (FolksObjectCacheStoreObjectsData, _data_);
}


void folks_object_cache_store_objects (FolksObjectCache* self, GeeSet* objects, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FolksObjectCacheStoreObjectsData* _data_;
	FolksObjectCache* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GCancellable* _tmp3_;
	GCancellable* _tmp4_;
	_data_ = g_slice_new0 (FolksObjectCacheStoreObjectsData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, folks_object_cache_store_objects);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, folks_object_cache_store_objects_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = objects;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data_->objects = _tmp2_;
	_tmp3_ = cancellable;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_data_->cancellable = _tmp4_;
	folks_object_cache_store_objects_co (_data_);
}


void folks_object_cache_store_objects_finish (FolksObjectCache* self, GAsyncResult* _res_) {
	FolksObjectCacheStoreObjectsData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


/**
   * Store a set of objects to the cache file, overwriting any existing set of
   * objects in the cache, or creating the cache file from scratch if it didn't
   * previously exist.
   *
   * Storing the objects can be cancelled using `cancellable`. If it is, the
   * cache will be left in a consistent state, but may be storing the old set
   * of objects or the new set.
   *
   * @param objects A set of objects to store. This may be empty, but may not
   * be `null`.
   * @param cancellable A {@link GLib.Cancellable} for the operation, or `null`.
   *
   * @since 0.6.0
   */
static void folks_object_cache_store_objects_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	FolksObjectCacheStoreObjectsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	folks_object_cache_store_objects_co (_data_);
}


static gboolean folks_object_cache_store_objects_co (FolksObjectCacheStoreObjectsData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_type_id;
	_data_->_tmp1_ = _data_->self->priv->_id;
	_data_->_tmp2_ = _data_->self->priv->_cache_file;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = g_file_get_path (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	g_debug ("object-cache.vala:330: Storing cache (type ID '%s', ID '%s') to file '" \
"%s'.", _data_->_tmp0_, _data_->_tmp1_, _data_->_tmp4_);
	_g_free0 (_data_->_tmp4_);
	_data_->_tmp5_ = G_MAXUINT8;
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = folks_object_cache_get_serialised_object_type (_data_->self, _data_->_tmp5_);
	_data_->child_type = _data_->_tmp6_;
	_data_->_tmp7_ = _data_->child_type;
	g_assert (_data_->_tmp7_ != NULL);
	_data_->_tmp8_ = _data_->objects;
	_data_->_tmp9_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_tmp11_ = NULL;
	_data_->_tmp11_ = g_new0 (GVariant*, _data_->_tmp10_ + 1);
	_data_->children = _data_->_tmp11_;
	_data_->children_length1 = _data_->_tmp10_;
	_data_->_children_size_ = _data_->children_length1;
	_data_->i = (guint) 0;
	{
		_data_->_tmp12_ = _data_->objects;
		_data_->_tmp13_ = NULL;
		_data_->_tmp13_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp12_);
		_data_->_object_it = _data_->_tmp13_;
		while (TRUE) {
			_data_->_tmp14_ = _data_->_object_it;
			_data_->_tmp15_ = FALSE;
			_data_->_tmp15_ = gee_iterator_next (_data_->_tmp14_);
			if (!_data_->_tmp15_) {
				break;
			}
			_data_->_tmp16_ = _data_->_object_it;
			_data_->_tmp17_ = NULL;
			_data_->_tmp17_ = gee_iterator_get (_data_->_tmp16_);
			_data_->object = _data_->_tmp17_;
			_data_->_tmp18_ = _data_->children;
			_data_->_tmp18__length1 = _data_->children_length1;
			_data_->_tmp19_ = _data_->i;
			_data_->i = _data_->_tmp19_ + 1;
			_data_->_tmp20_ = _data_->object;
			_data_->_tmp21_ = NULL;
			_data_->_tmp21_ = folks_object_cache_serialise_object (_data_->self, _data_->_tmp20_);
			_g_variant_unref0 (_data_->_tmp18_[_data_->_tmp19_]);
			_data_->_tmp18_[_data_->_tmp19_] = _data_->_tmp21_;
			_data_->_tmp22_ = _data_->_tmp18_[_data_->_tmp19_];
			((_data_->object == NULL) || (_data_->self->priv->t_destroy_func == NULL)) ? NULL : (_data_->object = (_data_->self->priv->t_destroy_func (_data_->object), NULL));
		}
		_g_object_unref0 (_data_->_object_it);
	}
	_data_->wrapper_version = FOLKS_OBJECT_CACHE__FILE_FORMAT_VERSION;
	_data_->_tmp23_ = 0U;
	_data_->_tmp23_ = folks_object_cache_get_serialised_object_version (_data_->self);
	_data_->object_version = _data_->_tmp23_;
	_data_->_tmp24_ = _data_->self->priv->_type_id;
	_data_->_tmp25_ = g_variant_new_string (_data_->_tmp24_);
	_data_->_tmp26_ = g_variant_ref_sink (_data_->_tmp25_);
	_data_->_tmp27_ = _data_->self->priv->_id;
	_data_->_tmp28_ = g_variant_new_string (_data_->_tmp27_);
	_data_->_tmp29_ = g_variant_ref_sink (_data_->_tmp28_);
	_data_->_tmp30_ = _data_->child_type;
	_data_->_tmp31_ = _data_->children;
	_data_->_tmp31__length1 = _data_->children_length1;
	_data_->_tmp32_ = g_variant_new_array (_data_->_tmp30_, _data_->_tmp31_, _data_->_tmp31__length1);
	_data_->_tmp33_ = g_variant_ref_sink (_data_->_tmp32_);
	_data_->_tmp34_ = NULL;
	_data_->_tmp34_ = g_new0 (GVariant*, 3 + 1);
	_data_->_tmp34_[0] = _data_->_tmp26_;
	_data_->_tmp34_[1] = _data_->_tmp29_;
	_data_->_tmp34_[2] = _data_->_tmp33_;
	_data_->_tmp35_ = _data_->_tmp34_;
	_data_->_tmp35__length1 = 3;
	_data_->_tmp36_ = g_variant_new_tuple (_data_->_tmp35_, 3);
	_data_->_tmp37_ = g_variant_ref_sink (_data_->_tmp36_);
	_data_->_tmp38_ = _data_->_tmp37_;
	_data_->_tmp35_ = (_vala_array_free (_data_->_tmp35_, _data_->_tmp35__length1, (GDestroyNotify) g_variant_unref), NULL);
	_data_->variant = _data_->_tmp38_;
	_data_->_tmp39_ = _data_->variant;
	_data_->_tmp40_ = NULL;
	_data_->_tmp40_ = g_variant_get_type (_data_->_tmp39_);
	_data_->_tmp41_ = _data_->wrapper_version;
	_data_->_tmp42_ = _data_->object_version;
	_data_->_tmp43_ = NULL;
	_data_->_tmp43_ = _folks_object_cache_get_cache_file_variant_type (_data_->self, _data_->_tmp41_, _data_->_tmp42_);
	_data_->_tmp44_ = _data_->_tmp43_;
	_data_->_tmp45_ = FALSE;
	_data_->_tmp45_ = g_variant_type_equal (_data_->_tmp40_, _data_->_tmp44_);
	g_assert (_data_->_tmp45_);
	_g_variant_type_free0 (_data_->_tmp44_);
	_data_->_tmp46_ = _data_->variant;
	_data_->_tmp47_ = 0UL;
	_data_->_tmp47_ = g_variant_get_size (_data_->_tmp46_);
	_data_->_tmp48_ = NULL;
	_data_->_tmp48_ = g_new0 (guint8, FOLKS_OBJECT_CACHE__HEADER_WIDTH + _data_->_tmp47_);
	_data_->data = _data_->_tmp48_;
	_data_->data_length1 = FOLKS_OBJECT_CACHE__HEADER_WIDTH + _data_->_tmp47_;
	_data_->_data_size_ = _data_->data_length1;
	_data_->_tmp49_ = _data_->data;
	_data_->_tmp49__length1 = _data_->data_length1;
	_data_->_tmp50_ = _data_->wrapper_version;
	_data_->_tmp49_[0] = _data_->_tmp50_;
	_data_->_tmp51_ = _data_->_tmp49_[0];
	_data_->_tmp52_ = _data_->data;
	_data_->_tmp52__length1 = _data_->data_length1;
	_data_->_tmp53_ = _data_->object_version;
	_data_->_tmp52_[1] = _data_->_tmp53_;
	_data_->_tmp54_ = _data_->_tmp52_[1];
	_data_->_tmp55_ = _data_->variant;
	_data_->_tmp56_ = _data_->data;
	_data_->_tmp56__length1 = _data_->data_length1;
	_data_->_tmp57_ = _data_->data;
	_data_->_tmp57__length1 = _data_->data_length1;
	g_variant_store (_data_->_tmp55_, _data_->_tmp56_ + FOLKS_OBJECT_CACHE__HEADER_WIDTH);
	while (TRUE) {
		{
			_data_->_tmp58_ = _data_->self->priv->_cache_file;
			_data_->_tmp59_ = _data_->data;
			_data_->_tmp59__length1 = _data_->data_length1;
			_data_->_tmp60_ = _data_->data;
			_data_->_tmp60__length1 = _data_->data_length1;
			_data_->_tmp61_ = _data_->cancellable;
			_data_->_state_ = 1;
			g_file_replace_contents_async (_data_->_tmp58_, (const gchar*) _data_->_tmp59_, (gsize) _data_->_tmp60__length1, NULL, FALSE, G_FILE_CREATE_PRIVATE, _data_->_tmp61_, folks_object_cache_store_objects_ready, _data_);
			return FALSE;
			_state_1:
			g_file_replace_contents_finish (_data_->_tmp58_, _data_->_res_, NULL, &_data_->_inner_error_);
			if (_data_->_inner_error_ != NULL) {
				goto __catch36_g_error;
			}
			break;
		}
		goto __finally36;
		__catch36_g_error:
		{
			_data_->e = _data_->_inner_error_;
			_data_->_inner_error_ = NULL;
			_data_->_tmp62_ = _data_->e;
			if (g_error_matches (_data_->_tmp62_, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
				{
					_data_->_state_ = 2;
					_folks_object_cache_create_cache_directory (_data_->self, folks_object_cache_store_objects_ready, _data_);
					return FALSE;
					_state_2:
					_folks_object_cache_create_cache_directory_finish (_data_->self, _data_->_res_, &_data_->_inner_error_);
					if (_data_->_inner_error_ != NULL) {
						goto __catch37_g_error;
					}
					_g_error_free0 (_data_->e);
					continue;
				}
				goto __finally37;
				__catch37_g_error:
				{
					_data_->e2 = _data_->_inner_error_;
					_data_->_inner_error_ = NULL;
					_data_->_tmp63_ = _data_->self->priv->_cache_directory;
					_data_->_tmp64_ = NULL;
					_data_->_tmp64_ = g_file_get_path (_data_->_tmp63_);
					_data_->_tmp65_ = _data_->_tmp64_;
					_data_->_tmp66_ = _data_->e;
					_data_->_tmp67_ = _data_->_tmp66_->message;
					g_warning ("object-cache.vala:384: Couldn't create cache directory '%s': %s", _data_->_tmp65_, _data_->_tmp67_);
					_g_free0 (_data_->_tmp65_);
					_g_error_free0 (_data_->e2);
					_g_error_free0 (_data_->e);
					_data_->data = (g_free (_data_->data), NULL);
					_g_variant_unref0 (_data_->variant);
					_data_->children = (_vala_array_free (_data_->children, _data_->children_length1, (GDestroyNotify) g_variant_unref), NULL);
					_g_variant_type_free0 (_data_->child_type);
					if (_data_->_state_ == 0) {
						g_simple_async_result_complete_in_idle (_data_->_async_result);
					} else {
						g_simple_async_result_complete (_data_->_async_result);
					}
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				__finally37:
				_g_error_free0 (_data_->e);
				_g_error_free0 (_data_->e);
				_data_->data = (g_free (_data_->data), NULL);
				_g_variant_unref0 (_data_->variant);
				_data_->children = (_vala_array_free (_data_->children, _data_->children_length1, (GDestroyNotify) g_variant_unref), NULL);
				_g_variant_type_free0 (_data_->child_type);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
				g_clear_error (&_data_->_inner_error_);
				return FALSE;
			} else {
				_data_->_tmp68_ = _data_->e;
				if (g_error_matches (_data_->_tmp68_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
					_g_error_free0 (_data_->e);
					_data_->data = (g_free (_data_->data), NULL);
					_g_variant_unref0 (_data_->variant);
					_data_->children = (_vala_array_free (_data_->children, _data_->children_length1, (GDestroyNotify) g_variant_unref), NULL);
					_g_variant_type_free0 (_data_->child_type);
					if (_data_->_state_ == 0) {
						g_simple_async_result_complete_in_idle (_data_->_async_result);
					} else {
						g_simple_async_result_complete (_data_->_async_result);
					}
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
			}
			_data_->_tmp69_ = _data_->self->priv->_cache_file;
			_data_->_tmp70_ = NULL;
			_data_->_tmp70_ = g_file_get_path (_data_->_tmp69_);
			_data_->_tmp71_ = _data_->_tmp70_;
			_data_->_tmp72_ = _data_->e;
			_data_->_tmp73_ = _data_->_tmp72_->message;
			g_warning ("object-cache.vala:398: Couldn't write to cache file '%s', so deleting " \
"it: %s", _data_->_tmp71_, _data_->_tmp73_);
			_g_free0 (_data_->_tmp71_);
			_data_->_state_ = 3;
			folks_object_cache_clear_cache (_data_->self, folks_object_cache_store_objects_ready, _data_);
			return FALSE;
			_state_3:
			folks_object_cache_clear_cache_finish (_data_->self, _data_->_res_);
			_g_error_free0 (_data_->e);
			_data_->data = (g_free (_data_->data), NULL);
			_g_variant_unref0 (_data_->variant);
			_data_->children = (_vala_array_free (_data_->children, _data_->children_length1, (GDestroyNotify) g_variant_unref), NULL);
			_g_variant_type_free0 (_data_->child_type);
			if (_data_->_state_ == 0) {
				g_simple_async_result_complete_in_idle (_data_->_async_result);
			} else {
				g_simple_async_result_complete (_data_->_async_result);
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		__finally36:
		_data_->data = (g_free (_data_->data), NULL);
		_g_variant_unref0 (_data_->variant);
		_data_->children = (_vala_array_free (_data_->children, _data_->children_length1, (GDestroyNotify) g_variant_unref), NULL);
		_g_variant_type_free0 (_data_->child_type);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	_data_->data = (g_free (_data_->data), NULL);
	_g_variant_unref0 (_data_->variant);
	_data_->children = (_vala_array_free (_data_->children, _data_->children_length1, (GDestroyNotify) g_variant_unref), NULL);
	_g_variant_type_free0 (_data_->child_type);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void folks_object_cache_clear_cache_data_free (gpointer _data) {
	FolksObjectCacheClearCacheData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FolksObjectCacheClearCacheData, _data_);
}


void folks_object_cache_clear_cache (FolksObjectCache* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FolksObjectCacheClearCacheData* _data_;
	FolksObjectCache* _tmp0_;
	_data_ = g_slice_new0 (FolksObjectCacheClearCacheData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, folks_object_cache_clear_cache);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, folks_object_cache_clear_cache_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	folks_object_cache_clear_cache_co (_data_);
}


void folks_object_cache_clear_cache_finish (FolksObjectCache* self, GAsyncResult* _res_) {
	FolksObjectCacheClearCacheData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


/**
   * Clear this cache object, deleting its backing file.
   *
   * @since 0.6.0
   */
static gboolean folks_object_cache_clear_cache_co (FolksObjectCacheClearCacheData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_type_id;
	_data_->_tmp1_ = _data_->self->priv->_id;
	_data_->_tmp2_ = _data_->self->priv->_cache_file;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = g_file_get_path (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	g_debug ("object-cache.vala:414: Clearing cache (type ID '%s', ID '%s'); deletin" \
"g file '%s'.", _data_->_tmp0_, _data_->_tmp1_, _data_->_tmp4_);
	_g_free0 (_data_->_tmp4_);
	{
		_data_->_tmp5_ = _data_->self->priv->_cache_file;
		g_file_delete (_data_->_tmp5_, NULL, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch38_g_error;
		}
	}
	goto __finally38;
	__catch38_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_g_error_free0 (_data_->e);
	}
	__finally38:
	if (_data_->_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static gpointer _g_variant_type_copy0 (gpointer self) {
	return self ? g_variant_type_copy (self) : NULL;
}


static GVariantType* _folks_object_cache_get_cache_file_variant_type (FolksObjectCache* self, guint8 wrapper_version, guint8 object_version) {
	GVariantType* result = NULL;
	guint8 _tmp0_;
	GVariantType* _tmp1_ = NULL;
	GVariantType* object_type;
	const GVariantType* _tmp2_;
	const GVariantType* _tmp3_;
	GVariantType* _tmp4_;
	const GVariantType* _tmp5_;
	GVariantType* _tmp6_;
	const GVariantType* _tmp7_;
	GVariantType* _tmp8_;
	GVariantType** _tmp9_ = NULL;
	GVariantType** _tmp10_;
	gint _tmp10__length1;
	GVariantType* _tmp11_;
	GVariantType* _tmp12_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = object_version;
	_tmp1_ = folks_object_cache_get_serialised_object_type (self, _tmp0_);
	object_type = _tmp1_;
	_tmp2_ = object_type;
	if (_tmp2_ == NULL) {
		result = NULL;
		_g_variant_type_free0 (object_type);
		return result;
	}
	_tmp3_ = G_VARIANT_TYPE_STRING;
	_tmp4_ = _g_variant_type_copy0 (_tmp3_);
	_tmp5_ = G_VARIANT_TYPE_STRING;
	_tmp6_ = _g_variant_type_copy0 (_tmp5_);
	_tmp7_ = object_type;
	_tmp8_ = g_variant_type_new_array (_tmp7_);
	_tmp9_ = g_new0 (GVariantType*, 3 + 1);
	_tmp9_[0] = _tmp4_;
	_tmp9_[1] = _tmp6_;
	_tmp9_[2] = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp10__length1 = 3;
	_tmp11_ = g_variant_type_new_tuple (_tmp10_, 3);
	_tmp12_ = _tmp11_;
	_tmp10_ = (_vala_array_free (_tmp10_, _tmp10__length1, (GDestroyNotify) g_variant_type_free), NULL);
	result = _tmp12_;
	_g_variant_type_free0 (object_type);
	return result;
}


static void _folks_object_cache_create_cache_directory_data_free (gpointer _data) {
	FolksObjectCacheCreateCacheDirectoryData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FolksObjectCacheCreateCacheDirectoryData, _data_);
}


static void _folks_object_cache_create_cache_directory (FolksObjectCache* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FolksObjectCacheCreateCacheDirectoryData* _data_;
	FolksObjectCache* _tmp0_;
	_data_ = g_slice_new0 (FolksObjectCacheCreateCacheDirectoryData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _folks_object_cache_create_cache_directory);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _folks_object_cache_create_cache_directory_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_folks_object_cache_create_cache_directory_co (_data_);
}


static void _folks_object_cache_create_cache_directory_finish (FolksObjectCache* self, GAsyncResult* _res_, GError** error) {
	FolksObjectCacheCreateCacheDirectoryData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gpointer _g_error_copy0 (gpointer self) {
	return self ? g_error_copy (self) : NULL;
}


static gboolean _folks_object_cache_create_cache_directory_co (FolksObjectCacheCreateCacheDirectoryData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->_cache_directory;
		g_file_make_directory_with_parents (_data_->_tmp0_, NULL, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch39_g_error;
		}
	}
	goto __finally39;
	__catch39_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp1_ = _data_->e;
		if (!g_error_matches (_data_->_tmp1_, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
			_data_->_tmp2_ = _data_->e;
			_data_->_tmp3_ = _g_error_copy0 (_data_->_tmp2_);
			_data_->_inner_error_ = _data_->_tmp3_;
			_g_error_free0 (_data_->e);
			goto __finally39;
		}
		_g_error_free0 (_data_->e);
	}
	__finally39:
	if (_data_->_inner_error_ != NULL) {
		g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
		g_error_free (_data_->_inner_error_);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


const gchar* folks_object_cache_get_type_id (FolksObjectCache* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_type_id;
	result = _tmp0_;
	return result;
}


static void folks_object_cache_set_type_id (FolksObjectCache* self, const gchar* value) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_type_id);
	self->priv->_type_id = _tmp1_;
	g_object_notify ((GObject *) self, "type-id");
}


const gchar* folks_object_cache_get_id (FolksObjectCache* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_id;
	result = _tmp0_;
	return result;
}


static void folks_object_cache_set_id (FolksObjectCache* self, const gchar* value) {
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	g_assert (g_strcmp0 (_tmp0_, "") != 0);
	_tmp1_ = value;
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (self->priv->_id);
	self->priv->_id = _tmp2_;
	g_object_notify ((GObject *) self, "id");
}


static GObject * folks_object_cache_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	FolksObjectCache * self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_ = NULL;
	GFile* _tmp4_ = NULL;
	GFile* _tmp5_;
	GFile* _tmp6_ = NULL;
	GFile* _tmp7_;
	const gchar* _tmp8_;
	GFile* _tmp9_ = NULL;
	GFile* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_ = NULL;
	gchar* _tmp14_;
	GFile* _tmp15_ = NULL;
	parent_class = G_OBJECT_CLASS (folks_object_cache_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = FOLKS_OBJECT_CACHE (obj);
	_tmp0_ = self->priv->_type_id;
	_tmp1_ = folks_object_cache_get_id (self);
	_tmp2_ = _tmp1_;
	g_debug ("object-cache.vala:155: Creating object cache for type ID '%s' with ID " \
"'%s'.", _tmp0_, _tmp2_);
	_tmp3_ = g_get_user_cache_dir ();
	_tmp4_ = g_file_new_for_path (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_file_get_child (_tmp5_, "folks");
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->_type_id;
	_tmp9_ = g_file_get_child (_tmp7_, _tmp8_);
	_g_object_unref0 (self->priv->_cache_directory);
	self->priv->_cache_directory = _tmp9_;
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (_tmp5_);
	_tmp10_ = self->priv->_cache_directory;
	_tmp11_ = folks_object_cache_get_id (self);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_uri_escape_string (_tmp12_, "", FALSE);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_file_get_child (_tmp10_, _tmp14_);
	_g_object_unref0 (self->priv->_cache_file);
	self->priv->_cache_file = _tmp15_;
	_g_free0 (_tmp14_);
	return obj;
}


static void folks_object_cache_class_init (FolksObjectCacheClass * klass) {
	folks_object_cache_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (FolksObjectCachePrivate));
	FOLKS_OBJECT_CACHE_CLASS (klass)->get_serialised_object_type = folks_object_cache_real_get_serialised_object_type;
	FOLKS_OBJECT_CACHE_CLASS (klass)->get_serialised_object_version = folks_object_cache_real_get_serialised_object_version;
	FOLKS_OBJECT_CACHE_CLASS (klass)->serialise_object = folks_object_cache_real_serialise_object;
	FOLKS_OBJECT_CACHE_CLASS (klass)->deserialise_object = folks_object_cache_real_deserialise_object;
	G_OBJECT_CLASS (klass)->get_property = _vala_folks_object_cache_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_folks_object_cache_set_property;
	G_OBJECT_CLASS (klass)->constructor = folks_object_cache_constructor;
	G_OBJECT_CLASS (klass)->finalize = folks_object_cache_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FOLKS_OBJECT_CACHE_T_TYPE, g_param_spec_gtype ("t-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FOLKS_OBJECT_CACHE_T_DUP_FUNC, g_param_spec_pointer ("t-dup-func", "dup func", "dup func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FOLKS_OBJECT_CACHE_T_DESTROY_FUNC, g_param_spec_pointer ("t-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	   * A string identifying the type of object being cached.
	   *
	   * This has to be suitable for use as a directory name; i.e. lower case,
	   * hyphen-separated tokens.
	   *
	   * @since 0.6.6
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), FOLKS_OBJECT_CACHE_TYPE_ID, g_param_spec_string ("type-id", "type-id", "type-id", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	   * A string identifying the particular cache instance.
	   *
	   * This will form the file name of the cache file, but will be escaped
	   * beforehand, so can be an arbitrary non-empty string.
	   *
	   * @since 0.6.6
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), FOLKS_OBJECT_CACHE_ID, g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void folks_object_cache_instance_init (FolksObjectCache * self) {
	self->priv = FOLKS_OBJECT_CACHE_GET_PRIVATE (self);
}


static void folks_object_cache_finalize (GObject* obj) {
	FolksObjectCache * self;
	self = FOLKS_OBJECT_CACHE (obj);
	_g_object_unref0 (self->priv->_cache_directory);
	_g_object_unref0 (self->priv->_cache_file);
	_g_free0 (self->priv->_type_id);
	_g_free0 (self->priv->_id);
	G_OBJECT_CLASS (folks_object_cache_parent_class)->finalize (obj);
}


/**
 * A generic abstract cache for sets of objects. This can be used by subclasses
 * to implement caching of homogeneous sets of objects. Subclasses simply have
 * to implement serialisation and deserialisation of the objects to and from
 * {@link GLib.Variant}s.
 *
 * It's intended that this class be used for providing caching layers for
 * {@link PersonaStore}s, for example.
 *
 * @since 0.6.0
 */
GType folks_object_cache_get_type (void) {
	static volatile gsize folks_object_cache_type_id__volatile = 0;
	if (g_once_init_enter (&folks_object_cache_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FolksObjectCacheClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) folks_object_cache_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FolksObjectCache), 0, (GInstanceInitFunc) folks_object_cache_instance_init, NULL };
		GType folks_object_cache_type_id;
		folks_object_cache_type_id = g_type_register_static (G_TYPE_OBJECT, "FolksObjectCache", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
		g_once_init_leave (&folks_object_cache_type_id__volatile, folks_object_cache_type_id);
	}
	return folks_object_cache_type_id__volatile;
}


static void _vala_folks_object_cache_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	FolksObjectCache * self;
	self = FOLKS_OBJECT_CACHE (object);
	switch (property_id) {
		case FOLKS_OBJECT_CACHE_TYPE_ID:
		g_value_set_string (value, folks_object_cache_get_type_id (self));
		break;
		case FOLKS_OBJECT_CACHE_ID:
		g_value_set_string (value, folks_object_cache_get_id (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_folks_object_cache_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	FolksObjectCache * self;
	self = FOLKS_OBJECT_CACHE (object);
	switch (property_id) {
		case FOLKS_OBJECT_CACHE_TYPE_ID:
		folks_object_cache_set_type_id (self, g_value_get_string (value));
		break;
		case FOLKS_OBJECT_CACHE_ID:
		folks_object_cache_set_id (self, g_value_get_string (value));
		break;
		case FOLKS_OBJECT_CACHE_T_TYPE:
		self->priv->t_type = g_value_get_gtype (value);
		break;
		case FOLKS_OBJECT_CACHE_T_DUP_FUNC:
		self->priv->t_dup_func = g_value_get_pointer (value);
		break;
		case FOLKS_OBJECT_CACHE_T_DESTROY_FUNC:
		self->priv->t_destroy_func = g_value_get_pointer (value);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


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



