/* tpf-persona-store-cache.c generated by valac 0.13.1.106-1068, the Vala compiler
 * generated from tpf-persona-store-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 <folks/folks.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>


#define TPF_TYPE_PERSONA_STORE_CACHE (tpf_persona_store_cache_get_type ())
#define TPF_PERSONA_STORE_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPF_TYPE_PERSONA_STORE_CACHE, TpfPersonaStoreCache))
#define TPF_PERSONA_STORE_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPF_TYPE_PERSONA_STORE_CACHE, TpfPersonaStoreCacheClass))
#define TPF_IS_PERSONA_STORE_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPF_TYPE_PERSONA_STORE_CACHE))
#define TPF_IS_PERSONA_STORE_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPF_TYPE_PERSONA_STORE_CACHE))
#define TPF_PERSONA_STORE_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPF_TYPE_PERSONA_STORE_CACHE, TpfPersonaStoreCacheClass))

typedef struct _TpfPersonaStoreCache TpfPersonaStoreCache;
typedef struct _TpfPersonaStoreCacheClass TpfPersonaStoreCacheClass;
typedef struct _TpfPersonaStoreCachePrivate TpfPersonaStoreCachePrivate;

#define TPF_TYPE_PERSONA_STORE (tpf_persona_store_get_type ())
#define TPF_PERSONA_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPF_TYPE_PERSONA_STORE, TpfPersonaStore))
#define TPF_PERSONA_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPF_TYPE_PERSONA_STORE, TpfPersonaStoreClass))
#define TPF_IS_PERSONA_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPF_TYPE_PERSONA_STORE))
#define TPF_IS_PERSONA_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPF_TYPE_PERSONA_STORE))
#define TPF_PERSONA_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPF_TYPE_PERSONA_STORE, TpfPersonaStoreClass))

typedef struct _TpfPersonaStore TpfPersonaStore;
typedef struct _TpfPersonaStoreClass TpfPersonaStoreClass;

#define TPF_TYPE_PERSONA (tpf_persona_get_type ())
#define TPF_PERSONA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPF_TYPE_PERSONA, TpfPersona))
#define TPF_PERSONA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPF_TYPE_PERSONA, TpfPersonaClass))
#define TPF_IS_PERSONA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPF_TYPE_PERSONA))
#define TPF_IS_PERSONA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPF_TYPE_PERSONA))
#define TPF_PERSONA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPF_TYPE_PERSONA, TpfPersonaClass))

typedef struct _TpfPersona TpfPersona;
typedef struct _TpfPersonaClass TpfPersonaClass;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _TpfPersonaStoreCache {
	FolksObjectCache parent_instance;
	TpfPersonaStoreCachePrivate * priv;
};

struct _TpfPersonaStoreCacheClass {
	FolksObjectCacheClass parent_class;
};

struct _TpfPersonaStoreCachePrivate {
	TpfPersonaStore* _store;
};


static gpointer tpf_persona_store_cache_parent_class = NULL;

GType tpf_persona_store_cache_get_type (void) G_GNUC_CONST;
GType tpf_persona_store_get_type (void) G_GNUC_CONST;
#define TPF_PERSONA_STORE_CACHE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TPF_TYPE_PERSONA_STORE_CACHE, TpfPersonaStoreCachePrivate))
enum  {
	TPF_PERSONA_STORE_CACHE_DUMMY_PROPERTY
};
#define TPF_PERSONA_STORE_CACHE__FILE_FORMAT_VERSION ((guint8) 1)
TpfPersonaStoreCache* tpf_persona_store_cache_new (TpfPersonaStore* store);
TpfPersonaStoreCache* tpf_persona_store_cache_construct (GType object_type, TpfPersonaStore* store);
GType tpf_persona_get_type (void) G_GNUC_CONST;
static GVariantType* tpf_persona_store_cache_real_get_serialised_object_type (FolksObjectCache* base);
static guint8 tpf_persona_store_cache_real_get_serialised_object_version (FolksObjectCache* base);
static GVariant* tpf_persona_store_cache_real_serialise_object (FolksObjectCache* base, TpfPersona* persona);
gboolean tpf_persona_get_is_in_contact_list (TpfPersona* self);
static TpfPersona* tpf_persona_store_cache_real_deserialise_object (FolksObjectCache* base, GVariant* variant);
TpfPersona* tpf_persona_new_from_cache (TpfPersonaStore* store, const gchar* uid, const gchar* iid, const gchar* im_address, const gchar* protocol, GeeHashSet* groups, gboolean is_favourite, const gchar* alias, gboolean is_in_contact_list, gboolean is_user, GLoadableIcon* avatar);
TpfPersona* tpf_persona_construct_from_cache (GType object_type, TpfPersonaStore* store, const gchar* uid, const gchar* iid, const gchar* im_address, const gchar* protocol, GeeHashSet* groups, gboolean is_favourite, const gchar* alias, gboolean is_in_contact_list, gboolean is_user, GLoadableIcon* avatar);
static void tpf_persona_store_cache_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


TpfPersonaStoreCache* tpf_persona_store_cache_construct (GType object_type, TpfPersonaStore* store) {
	TpfPersonaStoreCache * self = NULL;
	TpfPersonaStore* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	TpfPersonaStore* _tmp3_;
	g_return_val_if_fail (store != NULL, NULL);
	_tmp0_ = store;
	_tmp1_ = folks_persona_store_get_id ((FolksPersonaStore*) _tmp0_);
	_tmp2_ = _tmp1_;
	self = (TpfPersonaStoreCache*) folks_object_cache_construct (object_type, TPF_TYPE_PERSONA, (GBoxedCopyFunc) g_object_ref, g_object_unref, "tpf-persona-stores", _tmp2_);
	_tmp3_ = store;
	self->priv->_store = _tmp3_;
	return self;
}


TpfPersonaStoreCache* tpf_persona_store_cache_new (TpfPersonaStore* store) {
	return tpf_persona_store_cache_construct (TPF_TYPE_PERSONA_STORE_CACHE, store);
}


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


static GVariantType* tpf_persona_store_cache_real_get_serialised_object_type (FolksObjectCache* base) {
	TpfPersonaStoreCache * self;
	GVariantType* result = NULL;
	const GVariantType* _tmp0_;
	GVariantType* _tmp1_;
	const GVariantType* _tmp2_;
	GVariantType* _tmp3_;
	const GVariantType* _tmp4_;
	GVariantType* _tmp5_;
	const GVariantType* _tmp6_;
	GVariantType* _tmp7_;
	const GVariantType* _tmp8_;
	GVariantType* _tmp9_;
	const GVariantType* _tmp10_;
	GVariantType* _tmp11_;
	const GVariantType* _tmp12_;
	GVariantType* _tmp13_;
	const GVariantType* _tmp14_;
	GVariantType* _tmp15_;
	const GVariantType* _tmp16_;
	GVariantType* _tmp17_;
	const GVariantType* _tmp18_;
	GVariantType* _tmp19_;
	GVariantType** _tmp20_ = NULL;
	GVariantType** _tmp21_;
	gint _tmp21__length1;
	GVariantType* _tmp22_;
	GVariantType* _tmp23_;
	self = (TpfPersonaStoreCache*) base;
	_tmp0_ = G_VARIANT_TYPE_STRING;
	_tmp1_ = _g_variant_type_copy0 (_tmp0_);
	_tmp2_ = G_VARIANT_TYPE_STRING;
	_tmp3_ = _g_variant_type_copy0 (_tmp2_);
	_tmp4_ = G_VARIANT_TYPE_STRING;
	_tmp5_ = _g_variant_type_copy0 (_tmp4_);
	_tmp6_ = G_VARIANT_TYPE_STRING;
	_tmp7_ = _g_variant_type_copy0 (_tmp6_);
	_tmp8_ = G_VARIANT_TYPE_STRING;
	_tmp9_ = g_variant_type_new_array (_tmp8_);
	_tmp10_ = G_VARIANT_TYPE_BOOLEAN;
	_tmp11_ = _g_variant_type_copy0 (_tmp10_);
	_tmp12_ = G_VARIANT_TYPE_STRING;
	_tmp13_ = _g_variant_type_copy0 (_tmp12_);
	_tmp14_ = G_VARIANT_TYPE_BOOLEAN;
	_tmp15_ = _g_variant_type_copy0 (_tmp14_);
	_tmp16_ = G_VARIANT_TYPE_BOOLEAN;
	_tmp17_ = _g_variant_type_copy0 (_tmp16_);
	_tmp18_ = G_VARIANT_TYPE_STRING;
	_tmp19_ = g_variant_type_new_maybe (_tmp18_);
	_tmp20_ = g_new0 (GVariantType*, 10 + 1);
	_tmp20_[0] = _tmp1_;
	_tmp20_[1] = _tmp3_;
	_tmp20_[2] = _tmp5_;
	_tmp20_[3] = _tmp7_;
	_tmp20_[4] = _tmp9_;
	_tmp20_[5] = _tmp11_;
	_tmp20_[6] = _tmp13_;
	_tmp20_[7] = _tmp15_;
	_tmp20_[8] = _tmp17_;
	_tmp20_[9] = _tmp19_;
	_tmp21_ = _tmp20_;
	_tmp21__length1 = 10;
	_tmp22_ = g_variant_type_new_tuple (_tmp21_, 10);
	_tmp23_ = _tmp22_;
	_tmp21_ = (_vala_array_free (_tmp21_, _tmp21__length1, (GDestroyNotify) g_variant_type_free), NULL);
	result = _tmp23_;
	return result;
}


static guint8 tpf_persona_store_cache_real_get_serialised_object_version (FolksObjectCache* base) {
	TpfPersonaStoreCache * self;
	guint8 result = 0U;
	self = (TpfPersonaStoreCache*) base;
	result = TPF_PERSONA_STORE_CACHE__FILE_FORMAT_VERSION;
	return result;
}


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


static gpointer _g_variant_ref0 (gpointer self) {
	return self ? g_variant_ref (self) : NULL;
}


static GVariant* tpf_persona_store_cache_real_serialise_object (FolksObjectCache* base, TpfPersona* persona) {
	TpfPersonaStoreCache * self;
	GVariant* result = NULL;
	TpfPersona* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	GVariant** _tmp5_ = NULL;
	GVariant** groups;
	gint groups_length1;
	gint _groups_size_;
	guint i;
	gchar* im_protocol;
	GFile* _tmp33_ = NULL;
	gboolean _tmp34_ = FALSE;
	TpfPersona* _tmp35_;
	GLoadableIcon* _tmp36_;
	GLoadableIcon* _tmp37_;
	gboolean _tmp41_;
	GFile* _tmp46_;
	GFile* _tmp47_;
	GFile* avatar_file;
	GVariant* _tmp48_ = NULL;
	GFile* _tmp49_;
	GVariant* _tmp55_;
	GVariant* _tmp56_;
	GVariant* avatar_variant;
	TpfPersona* _tmp57_;
	const gchar* _tmp58_;
	const gchar* _tmp59_;
	GVariant* _tmp60_;
	GVariant* _tmp61_;
	TpfPersona* _tmp62_;
	const gchar* _tmp63_;
	const gchar* _tmp64_;
	GVariant* _tmp65_;
	GVariant* _tmp66_;
	TpfPersona* _tmp67_;
	const gchar* _tmp68_;
	const gchar* _tmp69_;
	GVariant* _tmp70_;
	GVariant* _tmp71_;
	const gchar* _tmp72_;
	GVariant* _tmp73_;
	GVariant* _tmp74_;
	const GVariantType* _tmp75_;
	GVariant** _tmp76_;
	gint _tmp76__length1;
	GVariant* _tmp77_;
	GVariant* _tmp78_;
	TpfPersona* _tmp79_;
	gboolean _tmp80_;
	gboolean _tmp81_;
	GVariant* _tmp82_;
	GVariant* _tmp83_;
	TpfPersona* _tmp84_;
	const gchar* _tmp85_;
	const gchar* _tmp86_;
	GVariant* _tmp87_;
	GVariant* _tmp88_;
	TpfPersona* _tmp89_;
	gboolean _tmp90_;
	gboolean _tmp91_;
	GVariant* _tmp92_;
	GVariant* _tmp93_;
	TpfPersona* _tmp94_;
	gboolean _tmp95_;
	gboolean _tmp96_;
	GVariant* _tmp97_;
	GVariant* _tmp98_;
	const GVariantType* _tmp99_;
	GVariant* _tmp100_;
	GVariant* _tmp101_;
	GVariant* _tmp102_;
	GVariant** _tmp103_ = NULL;
	GVariant** _tmp104_;
	gint _tmp104__length1;
	GVariant* _tmp105_;
	GVariant* _tmp106_;
	GVariant* _tmp107_;
	self = (TpfPersonaStoreCache*) base;
	g_return_val_if_fail (persona != NULL, NULL);
	_tmp0_ = persona;
	_tmp1_ = folks_group_details_get_groups ((FolksGroupDetails*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_new0 (GVariant*, _tmp4_ + 1);
	groups = _tmp5_;
	groups_length1 = _tmp4_;
	_groups_size_ = groups_length1;
	i = (guint) 0;
	{
		TpfPersona* _tmp6_;
		GeeSet* _tmp7_;
		GeeSet* _tmp8_;
		GeeIterator* _tmp9_ = NULL;
		GeeIterator* _group_it;
		_tmp6_ = persona;
		_tmp7_ = folks_group_details_get_groups ((FolksGroupDetails*) _tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_);
		_group_it = _tmp9_;
		while (TRUE) {
			GeeIterator* _tmp10_;
			gboolean _tmp11_ = FALSE;
			GeeIterator* _tmp12_;
			gpointer _tmp13_ = NULL;
			gchar* group;
			GVariant** _tmp14_;
			gint _tmp14__length1;
			guint _tmp15_;
			const gchar* _tmp16_;
			GVariant* _tmp17_;
			GVariant* _tmp18_;
			GVariant* _tmp19_;
			_tmp10_ = _group_it;
			_tmp11_ = gee_iterator_next (_tmp10_);
			if (!_tmp11_) {
				break;
			}
			_tmp12_ = _group_it;
			_tmp13_ = gee_iterator_get (_tmp12_);
			group = (gchar*) _tmp13_;
			_tmp14_ = groups;
			_tmp14__length1 = groups_length1;
			_tmp15_ = i;
			i = _tmp15_ + 1;
			_tmp16_ = group;
			_tmp17_ = g_variant_new_string (_tmp16_);
			_tmp18_ = g_variant_ref_sink (_tmp17_);
			_g_variant_unref0 (_tmp14_[_tmp15_]);
			_tmp14_[_tmp15_] = _tmp18_;
			_tmp19_ = _tmp14_[_tmp15_];
			_g_free0 (group);
		}
		_g_object_unref0 (_group_it);
	}
	im_protocol = NULL;
	{
		TpfPersona* _tmp20_;
		GeeMultiMap* _tmp21_;
		GeeMultiMap* _tmp22_;
		GeeSet* _tmp23_ = NULL;
		GeeSet* _tmp24_;
		GeeIterator* _tmp25_ = NULL;
		GeeIterator* _tmp26_;
		GeeIterator* _protocol_it;
		_tmp20_ = persona;
		_tmp21_ = folks_im_details_get_im_addresses ((FolksImDetails*) _tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = gee_multi_map_get_keys (_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = gee_iterable_iterator ((GeeIterable*) _tmp24_);
		_tmp26_ = _tmp25_;
		_g_object_unref0 (_tmp24_);
		_protocol_it = _tmp26_;
		while (TRUE) {
			GeeIterator* _tmp27_;
			gboolean _tmp28_ = FALSE;
			GeeIterator* _tmp29_;
			gpointer _tmp30_ = NULL;
			gchar* protocol;
			const gchar* _tmp31_;
			gchar* _tmp32_;
			_tmp27_ = _protocol_it;
			_tmp28_ = gee_iterator_next (_tmp27_);
			if (!_tmp28_) {
				break;
			}
			_tmp29_ = _protocol_it;
			_tmp30_ = gee_iterator_get (_tmp29_);
			protocol = (gchar*) _tmp30_;
			_tmp31_ = protocol;
			_tmp32_ = g_strdup (_tmp31_);
			_g_free0 (im_protocol);
			im_protocol = _tmp32_;
			_g_free0 (protocol);
			break;
		}
		_g_object_unref0 (_protocol_it);
	}
	_tmp35_ = persona;
	_tmp36_ = folks_avatar_details_get_avatar ((FolksAvatarDetails*) _tmp35_);
	_tmp37_ = _tmp36_;
	if (_tmp37_ != NULL) {
		TpfPersona* _tmp38_;
		GLoadableIcon* _tmp39_;
		GLoadableIcon* _tmp40_;
		_tmp38_ = persona;
		_tmp39_ = folks_avatar_details_get_avatar ((FolksAvatarDetails*) _tmp38_);
		_tmp40_ = _tmp39_;
		_tmp34_ = G_IS_FILE_ICON (_tmp40_);
	} else {
		_tmp34_ = FALSE;
	}
	_tmp41_ = _tmp34_;
	if (_tmp41_) {
		TpfPersona* _tmp42_;
		GLoadableIcon* _tmp43_;
		GLoadableIcon* _tmp44_;
		GFile* _tmp45_ = NULL;
		_tmp42_ = persona;
		_tmp43_ = folks_avatar_details_get_avatar ((FolksAvatarDetails*) _tmp42_);
		_tmp44_ = _tmp43_;
		_tmp45_ = g_file_icon_get_file (G_IS_FILE_ICON (_tmp44_) ? ((GFileIcon*) _tmp44_) : NULL);
		_tmp33_ = _tmp45_;
	} else {
		_tmp33_ = NULL;
	}
	_tmp46_ = _tmp33_;
	_tmp47_ = _g_object_ref0 (_tmp46_);
	avatar_file = _tmp47_;
	_tmp49_ = avatar_file;
	if (_tmp49_ != NULL) {
		GFile* _tmp50_;
		gchar* _tmp51_ = NULL;
		gchar* _tmp52_;
		GVariant* _tmp53_;
		GVariant* _tmp54_;
		_tmp50_ = avatar_file;
		_tmp51_ = g_file_get_uri (_tmp50_);
		_tmp52_ = _tmp51_;
		_tmp53_ = g_variant_new_string (_tmp52_);
		_tmp54_ = g_variant_ref_sink (_tmp53_);
		_g_variant_unref0 (_tmp48_);
		_tmp48_ = _tmp54_;
		_g_free0 (_tmp52_);
	} else {
		_g_variant_unref0 (_tmp48_);
		_tmp48_ = NULL;
	}
	_tmp55_ = _tmp48_;
	_tmp56_ = _g_variant_ref0 (_tmp55_);
	avatar_variant = _tmp56_;
	_tmp57_ = persona;
	_tmp58_ = folks_persona_get_uid ((FolksPersona*) _tmp57_);
	_tmp59_ = _tmp58_;
	_tmp60_ = g_variant_new_string (_tmp59_);
	_tmp61_ = g_variant_ref_sink (_tmp60_);
	_tmp62_ = persona;
	_tmp63_ = folks_persona_get_iid ((FolksPersona*) _tmp62_);
	_tmp64_ = _tmp63_;
	_tmp65_ = g_variant_new_string (_tmp64_);
	_tmp66_ = g_variant_ref_sink (_tmp65_);
	_tmp67_ = persona;
	_tmp68_ = folks_persona_get_display_id ((FolksPersona*) _tmp67_);
	_tmp69_ = _tmp68_;
	_tmp70_ = g_variant_new_string (_tmp69_);
	_tmp71_ = g_variant_ref_sink (_tmp70_);
	_tmp72_ = im_protocol;
	_tmp73_ = g_variant_new_string (_tmp72_);
	_tmp74_ = g_variant_ref_sink (_tmp73_);
	_tmp75_ = G_VARIANT_TYPE_STRING;
	_tmp76_ = groups;
	_tmp76__length1 = groups_length1;
	_tmp77_ = g_variant_new_array (_tmp75_, _tmp76_, _tmp76__length1);
	_tmp78_ = g_variant_ref_sink (_tmp77_);
	_tmp79_ = persona;
	_tmp80_ = folks_favourite_details_get_is_favourite ((FolksFavouriteDetails*) _tmp79_);
	_tmp81_ = _tmp80_;
	_tmp82_ = g_variant_new_boolean (_tmp81_);
	_tmp83_ = g_variant_ref_sink (_tmp82_);
	_tmp84_ = persona;
	_tmp85_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp84_);
	_tmp86_ = _tmp85_;
	_tmp87_ = g_variant_new_string (_tmp86_);
	_tmp88_ = g_variant_ref_sink (_tmp87_);
	_tmp89_ = persona;
	_tmp90_ = tpf_persona_get_is_in_contact_list (_tmp89_);
	_tmp91_ = _tmp90_;
	_tmp92_ = g_variant_new_boolean (_tmp91_);
	_tmp93_ = g_variant_ref_sink (_tmp92_);
	_tmp94_ = persona;
	_tmp95_ = folks_persona_get_is_user ((FolksPersona*) _tmp94_);
	_tmp96_ = _tmp95_;
	_tmp97_ = g_variant_new_boolean (_tmp96_);
	_tmp98_ = g_variant_ref_sink (_tmp97_);
	_tmp99_ = G_VARIANT_TYPE_STRING;
	_tmp100_ = avatar_variant;
	_tmp101_ = g_variant_new_maybe (_tmp99_, _tmp100_);
	_tmp102_ = g_variant_ref_sink (_tmp101_);
	_tmp103_ = g_new0 (GVariant*, 10 + 1);
	_tmp103_[0] = _tmp61_;
	_tmp103_[1] = _tmp66_;
	_tmp103_[2] = _tmp71_;
	_tmp103_[3] = _tmp74_;
	_tmp103_[4] = _tmp78_;
	_tmp103_[5] = _tmp83_;
	_tmp103_[6] = _tmp88_;
	_tmp103_[7] = _tmp93_;
	_tmp103_[8] = _tmp98_;
	_tmp103_[9] = _tmp102_;
	_tmp104_ = _tmp103_;
	_tmp104__length1 = 10;
	_tmp105_ = g_variant_new_tuple (_tmp104_, 10);
	_tmp106_ = g_variant_ref_sink (_tmp105_);
	_tmp107_ = _tmp106_;
	_tmp104_ = (_vala_array_free (_tmp104_, _tmp104__length1, (GDestroyNotify) g_variant_unref), NULL);
	result = _tmp107_;
	_g_variant_unref0 (avatar_variant);
	_g_variant_unref0 (_tmp48_);
	_g_object_unref0 (avatar_file);
	_g_free0 (im_protocol);
	groups = (_vala_array_free (groups, groups_length1, (GDestroyNotify) g_variant_unref), NULL);
	return result;
}


static TpfPersona* tpf_persona_store_cache_real_deserialise_object (FolksObjectCache* base, GVariant* variant) {
	TpfPersonaStoreCache * self;
	TpfPersona* result = NULL;
	GVariant* _tmp0_;
	GVariant* _tmp1_ = NULL;
	GVariant* _tmp2_;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* uid;
	GVariant* _tmp6_;
	GVariant* _tmp7_ = NULL;
	GVariant* _tmp8_;
	const gchar* _tmp9_ = NULL;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* iid;
	GVariant* _tmp12_;
	GVariant* _tmp13_ = NULL;
	GVariant* _tmp14_;
	const gchar* _tmp15_ = NULL;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* display_id;
	GVariant* _tmp18_;
	GVariant* _tmp19_ = NULL;
	GVariant* _tmp20_;
	const gchar* _tmp21_ = NULL;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* im_protocol;
	GVariant* _tmp24_;
	GVariant* _tmp25_ = NULL;
	GVariant* groups;
	GVariant* _tmp26_;
	GVariant* _tmp27_ = NULL;
	GVariant* _tmp28_;
	gboolean _tmp29_ = FALSE;
	gboolean _tmp30_;
	gboolean is_favourite;
	GVariant* _tmp31_;
	GVariant* _tmp32_ = NULL;
	GVariant* _tmp33_;
	const gchar* _tmp34_ = NULL;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* alias;
	GVariant* _tmp37_;
	GVariant* _tmp38_ = NULL;
	GVariant* _tmp39_;
	gboolean _tmp40_ = FALSE;
	gboolean _tmp41_;
	gboolean is_in_contact_list;
	GVariant* _tmp42_;
	GVariant* _tmp43_ = NULL;
	GVariant* _tmp44_;
	gboolean _tmp45_ = FALSE;
	gboolean _tmp46_;
	gboolean is_user;
	GVariant* _tmp47_;
	GVariant* _tmp48_ = NULL;
	GVariant* _tmp49_;
	GVariant* _tmp50_ = NULL;
	GVariant* _tmp51_;
	GVariant* avatar_variant;
	GeeHashSet* _tmp52_;
	GeeHashSet* group_set;
	GFileIcon* _tmp65_ = NULL;
	GVariant* _tmp66_;
	GFileIcon* _tmp72_;
	GFileIcon* _tmp73_;
	GFileIcon* avatar;
	TpfPersonaStore* _tmp74_;
	const gchar* _tmp75_;
	const gchar* _tmp76_;
	const gchar* _tmp77_;
	const gchar* _tmp78_;
	GeeHashSet* _tmp79_;
	gboolean _tmp80_;
	const gchar* _tmp81_;
	gboolean _tmp82_;
	gboolean _tmp83_;
	GFileIcon* _tmp84_;
	TpfPersona* _tmp85_;
	self = (TpfPersonaStoreCache*) base;
	g_return_val_if_fail (variant != NULL, NULL);
	_tmp0_ = variant;
	_tmp1_ = g_variant_get_child_value (_tmp0_, (gsize) 0);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_variant_get_string (_tmp2_, NULL);
	_tmp4_ = g_strdup (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_variant_unref0 (_tmp2_);
	uid = _tmp5_;
	_tmp6_ = variant;
	_tmp7_ = g_variant_get_child_value (_tmp6_, (gsize) 1);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_variant_get_string (_tmp8_, NULL);
	_tmp10_ = g_strdup (_tmp9_);
	_tmp11_ = _tmp10_;
	_g_variant_unref0 (_tmp8_);
	iid = _tmp11_;
	_tmp12_ = variant;
	_tmp13_ = g_variant_get_child_value (_tmp12_, (gsize) 2);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_variant_get_string (_tmp14_, NULL);
	_tmp16_ = g_strdup (_tmp15_);
	_tmp17_ = _tmp16_;
	_g_variant_unref0 (_tmp14_);
	display_id = _tmp17_;
	_tmp18_ = variant;
	_tmp19_ = g_variant_get_child_value (_tmp18_, (gsize) 3);
	_tmp20_ = _tmp19_;
	_tmp21_ = g_variant_get_string (_tmp20_, NULL);
	_tmp22_ = g_strdup (_tmp21_);
	_tmp23_ = _tmp22_;
	_g_variant_unref0 (_tmp20_);
	im_protocol = _tmp23_;
	_tmp24_ = variant;
	_tmp25_ = g_variant_get_child_value (_tmp24_, (gsize) 4);
	groups = _tmp25_;
	_tmp26_ = variant;
	_tmp27_ = g_variant_get_child_value (_tmp26_, (gsize) 5);
	_tmp28_ = _tmp27_;
	_tmp29_ = g_variant_get_boolean (_tmp28_);
	_tmp30_ = _tmp29_;
	_g_variant_unref0 (_tmp28_);
	is_favourite = _tmp30_;
	_tmp31_ = variant;
	_tmp32_ = g_variant_get_child_value (_tmp31_, (gsize) 6);
	_tmp33_ = _tmp32_;
	_tmp34_ = g_variant_get_string (_tmp33_, NULL);
	_tmp35_ = g_strdup (_tmp34_);
	_tmp36_ = _tmp35_;
	_g_variant_unref0 (_tmp33_);
	alias = _tmp36_;
	_tmp37_ = variant;
	_tmp38_ = g_variant_get_child_value (_tmp37_, (gsize) 7);
	_tmp39_ = _tmp38_;
	_tmp40_ = g_variant_get_boolean (_tmp39_);
	_tmp41_ = _tmp40_;
	_g_variant_unref0 (_tmp39_);
	is_in_contact_list = _tmp41_;
	_tmp42_ = variant;
	_tmp43_ = g_variant_get_child_value (_tmp42_, (gsize) 8);
	_tmp44_ = _tmp43_;
	_tmp45_ = g_variant_get_boolean (_tmp44_);
	_tmp46_ = _tmp45_;
	_g_variant_unref0 (_tmp44_);
	is_user = _tmp46_;
	_tmp47_ = variant;
	_tmp48_ = g_variant_get_child_value (_tmp47_, (gsize) 9);
	_tmp49_ = _tmp48_;
	_tmp50_ = g_variant_get_maybe (_tmp49_);
	_tmp51_ = _tmp50_;
	_g_variant_unref0 (_tmp49_);
	avatar_variant = _tmp51_;
	_tmp52_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
	group_set = _tmp52_;
	{
		guint i;
		i = (guint) 0;
		{
			gboolean _tmp53_;
			_tmp53_ = TRUE;
			while (TRUE) {
				gboolean _tmp54_;
				guint _tmp56_;
				GVariant* _tmp57_;
				gsize _tmp58_ = 0UL;
				GeeHashSet* _tmp59_;
				GVariant* _tmp60_;
				guint _tmp61_;
				GVariant* _tmp62_ = NULL;
				GVariant* _tmp63_;
				const gchar* _tmp64_ = NULL;
				_tmp54_ = _tmp53_;
				if (!_tmp54_) {
					guint _tmp55_;
					_tmp55_ = i;
					i = _tmp55_ + 1;
				}
				_tmp53_ = FALSE;
				_tmp56_ = i;
				_tmp57_ = groups;
				_tmp58_ = g_variant_n_children (_tmp57_);
				if (!(((gsize) _tmp56_) < _tmp58_)) {
					break;
				}
				_tmp59_ = group_set;
				_tmp60_ = groups;
				_tmp61_ = i;
				_tmp62_ = g_variant_get_child_value (_tmp60_, (gsize) _tmp61_);
				_tmp63_ = _tmp62_;
				_tmp64_ = g_variant_get_string (_tmp63_, NULL);
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp59_, _tmp64_);
				_g_variant_unref0 (_tmp63_);
			}
		}
	}
	_tmp66_ = avatar_variant;
	if (_tmp66_ != NULL) {
		GVariant* _tmp67_;
		const gchar* _tmp68_ = NULL;
		GFile* _tmp69_ = NULL;
		GFile* _tmp70_;
		GFileIcon* _tmp71_;
		_tmp67_ = avatar_variant;
		_tmp68_ = g_variant_get_string (_tmp67_, NULL);
		_tmp69_ = g_file_new_for_uri (_tmp68_);
		_tmp70_ = _tmp69_;
		_tmp71_ = (GFileIcon*) g_file_icon_new (_tmp70_);
		_g_object_unref0 (_tmp65_);
		_tmp65_ = _tmp71_;
		_g_object_unref0 (_tmp70_);
	} else {
		_g_object_unref0 (_tmp65_);
		_tmp65_ = NULL;
	}
	_tmp72_ = _tmp65_;
	_tmp73_ = _g_object_ref0 (_tmp72_);
	avatar = _tmp73_;
	_tmp74_ = self->priv->_store;
	_tmp75_ = uid;
	_tmp76_ = iid;
	_tmp77_ = display_id;
	_tmp78_ = im_protocol;
	_tmp79_ = group_set;
	_tmp80_ = is_favourite;
	_tmp81_ = alias;
	_tmp82_ = is_in_contact_list;
	_tmp83_ = is_user;
	_tmp84_ = avatar;
	_tmp85_ = tpf_persona_new_from_cache (_tmp74_, _tmp75_, _tmp76_, _tmp77_, _tmp78_, _tmp79_, _tmp80_, _tmp81_, _tmp82_, _tmp83_, (GLoadableIcon*) _tmp84_);
	result = _tmp85_;
	_g_object_unref0 (avatar);
	_g_object_unref0 (_tmp65_);
	_g_object_unref0 (group_set);
	_g_variant_unref0 (avatar_variant);
	_g_free0 (alias);
	_g_variant_unref0 (groups);
	_g_free0 (im_protocol);
	_g_free0 (display_id);
	_g_free0 (iid);
	_g_free0 (uid);
	return result;
}


static void tpf_persona_store_cache_class_init (TpfPersonaStoreCacheClass * klass) {
	tpf_persona_store_cache_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (TpfPersonaStoreCachePrivate));
	FOLKS_OBJECT_CACHE_CLASS (klass)->get_serialised_object_type = tpf_persona_store_cache_real_get_serialised_object_type;
	FOLKS_OBJECT_CACHE_CLASS (klass)->get_serialised_object_version = tpf_persona_store_cache_real_get_serialised_object_version;
	FOLKS_OBJECT_CACHE_CLASS (klass)->serialise_object = tpf_persona_store_cache_real_serialise_object;
	FOLKS_OBJECT_CACHE_CLASS (klass)->deserialise_object = tpf_persona_store_cache_real_deserialise_object;
	G_OBJECT_CLASS (klass)->finalize = tpf_persona_store_cache_finalize;
}


static void tpf_persona_store_cache_instance_init (TpfPersonaStoreCache * self) {
	self->priv = TPF_PERSONA_STORE_CACHE_GET_PRIVATE (self);
}


static void tpf_persona_store_cache_finalize (GObject* obj) {
	TpfPersonaStoreCache * self;
	self = TPF_PERSONA_STORE_CACHE (obj);
	G_OBJECT_CLASS (tpf_persona_store_cache_parent_class)->finalize (obj);
}


/**
 * An object cache class which implements caching of sets of
 * {@link Tpf.Persona}s from a given {@link Tpf.PersonaStore}.
 *
 * Each {@link Tpf.Persona} is stored as a serialised {@link Variant} which is
 * a tuple containing the following fields:
 *  # UID (`s`)
 *  # IID (`s`)
 *  # IM address (`s`)
 *  # Protocol (`s`)
 *  # Set of group names (`as`)
 *  # Favourite? (`b`)
 *  # Alias (`s`)
 *  # In contact list? (`b`)
 *  # Avatar file URI (`s`)
 *
 * @since 0.6.0
 */
GType tpf_persona_store_cache_get_type (void) {
	static volatile gsize tpf_persona_store_cache_type_id__volatile = 0;
	if (g_once_init_enter (&tpf_persona_store_cache_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (TpfPersonaStoreCacheClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tpf_persona_store_cache_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TpfPersonaStoreCache), 0, (GInstanceInitFunc) tpf_persona_store_cache_instance_init, NULL };
		GType tpf_persona_store_cache_type_id;
		tpf_persona_store_cache_type_id = g_type_register_static (FOLKS_TYPE_OBJECT_CACHE, "TpfPersonaStoreCache", &g_define_type_info, 0);
		g_once_init_leave (&tpf_persona_store_cache_type_id__volatile, tpf_persona_store_cache_type_id);
	}
	return tpf_persona_store_cache_type_id__volatile;
}


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


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



