/* tpf-persona-store-cache.c generated by valac 0.14.0.15-f8b5, 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* _tmp31_ = NULL;
	gboolean _tmp32_ = FALSE;
	TpfPersona* _tmp33_;
	GLoadableIcon* _tmp34_;
	GLoadableIcon* _tmp35_;
	gboolean _tmp39_;
	GFile* _tmp44_;
	GFile* _tmp45_;
	GFile* avatar_file;
	GVariant* _tmp46_ = NULL;
	GFile* _tmp47_;
	GVariant* _tmp53_;
	GVariant* _tmp54_;
	GVariant* avatar_variant;
	TpfPersona* _tmp55_;
	const gchar* _tmp56_;
	const gchar* _tmp57_;
	GVariant* _tmp58_;
	GVariant* _tmp59_;
	TpfPersona* _tmp60_;
	const gchar* _tmp61_;
	const gchar* _tmp62_;
	GVariant* _tmp63_;
	GVariant* _tmp64_;
	TpfPersona* _tmp65_;
	const gchar* _tmp66_;
	const gchar* _tmp67_;
	GVariant* _tmp68_;
	GVariant* _tmp69_;
	const gchar* _tmp70_;
	GVariant* _tmp71_;
	GVariant* _tmp72_;
	const GVariantType* _tmp73_;
	GVariant** _tmp74_;
	gint _tmp74__length1;
	GVariant* _tmp75_;
	GVariant* _tmp76_;
	TpfPersona* _tmp77_;
	gboolean _tmp78_;
	gboolean _tmp79_;
	GVariant* _tmp80_;
	GVariant* _tmp81_;
	TpfPersona* _tmp82_;
	const gchar* _tmp83_;
	const gchar* _tmp84_;
	GVariant* _tmp85_;
	GVariant* _tmp86_;
	TpfPersona* _tmp87_;
	gboolean _tmp88_;
	gboolean _tmp89_;
	GVariant* _tmp90_;
	GVariant* _tmp91_;
	TpfPersona* _tmp92_;
	gboolean _tmp93_;
	gboolean _tmp94_;
	GVariant* _tmp95_;
	GVariant* _tmp96_;
	const GVariantType* _tmp97_;
	GVariant* _tmp98_;
	GVariant* _tmp99_;
	GVariant** _tmp100_ = NULL;
	GVariant** _tmp101_;
	gint _tmp101__length1;
	GVariant* _tmp102_;
	GVariant* _tmp103_;
	GVariant* _tmp104_;
	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) {
			gboolean _tmp27_ = FALSE;
			gpointer _tmp28_ = NULL;
			gchar* protocol;
			const gchar* _tmp29_;
			gchar* _tmp30_;
			_tmp27_ = gee_iterator_next (_protocol_it);
			if (!_tmp27_) {
				break;
			}
			_tmp28_ = gee_iterator_get (_protocol_it);
			protocol = (gchar*) _tmp28_;
			_tmp29_ = protocol;
			_tmp30_ = g_strdup (_tmp29_);
			_g_free0 (im_protocol);
			im_protocol = _tmp30_;
			_g_free0 (protocol);
			break;
		}
		_g_object_unref0 (_protocol_it);
	}
	_tmp33_ = persona;
	_tmp34_ = folks_avatar_details_get_avatar ((FolksAvatarDetails*) _tmp33_);
	_tmp35_ = _tmp34_;
	if (_tmp35_ != NULL) {
		TpfPersona* _tmp36_;
		GLoadableIcon* _tmp37_;
		GLoadableIcon* _tmp38_;
		_tmp36_ = persona;
		_tmp37_ = folks_avatar_details_get_avatar ((FolksAvatarDetails*) _tmp36_);
		_tmp38_ = _tmp37_;
		_tmp32_ = G_IS_FILE_ICON (_tmp38_);
	} else {
		_tmp32_ = FALSE;
	}
	_tmp39_ = _tmp32_;
	if (_tmp39_) {
		TpfPersona* _tmp40_;
		GLoadableIcon* _tmp41_;
		GLoadableIcon* _tmp42_;
		GFile* _tmp43_ = NULL;
		_tmp40_ = persona;
		_tmp41_ = folks_avatar_details_get_avatar ((FolksAvatarDetails*) _tmp40_);
		_tmp42_ = _tmp41_;
		_tmp43_ = g_file_icon_get_file (G_IS_FILE_ICON (_tmp42_) ? ((GFileIcon*) _tmp42_) : NULL);
		_tmp31_ = _tmp43_;
	} else {
		_tmp31_ = NULL;
	}
	_tmp44_ = _tmp31_;
	_tmp45_ = _g_object_ref0 (_tmp44_);
	avatar_file = _tmp45_;
	_tmp47_ = avatar_file;
	if (_tmp47_ != NULL) {
		GFile* _tmp48_;
		gchar* _tmp49_ = NULL;
		gchar* _tmp50_;
		GVariant* _tmp51_;
		GVariant* _tmp52_;
		_tmp48_ = avatar_file;
		_tmp49_ = g_file_get_uri (_tmp48_);
		_tmp50_ = _tmp49_;
		_tmp51_ = g_variant_new_string (_tmp50_);
		_tmp52_ = g_variant_ref_sink (_tmp51_);
		_g_variant_unref0 (_tmp46_);
		_tmp46_ = _tmp52_;
		_g_free0 (_tmp50_);
	} else {
		_g_variant_unref0 (_tmp46_);
		_tmp46_ = NULL;
	}
	_tmp53_ = _tmp46_;
	_tmp54_ = _g_variant_ref0 (_tmp53_);
	avatar_variant = _tmp54_;
	_tmp55_ = persona;
	_tmp56_ = folks_persona_get_uid ((FolksPersona*) _tmp55_);
	_tmp57_ = _tmp56_;
	_tmp58_ = g_variant_new_string (_tmp57_);
	_tmp59_ = g_variant_ref_sink (_tmp58_);
	_tmp60_ = persona;
	_tmp61_ = folks_persona_get_iid ((FolksPersona*) _tmp60_);
	_tmp62_ = _tmp61_;
	_tmp63_ = g_variant_new_string (_tmp62_);
	_tmp64_ = g_variant_ref_sink (_tmp63_);
	_tmp65_ = persona;
	_tmp66_ = folks_persona_get_display_id ((FolksPersona*) _tmp65_);
	_tmp67_ = _tmp66_;
	_tmp68_ = g_variant_new_string (_tmp67_);
	_tmp69_ = g_variant_ref_sink (_tmp68_);
	_tmp70_ = im_protocol;
	_tmp71_ = g_variant_new_string (_tmp70_);
	_tmp72_ = g_variant_ref_sink (_tmp71_);
	_tmp73_ = G_VARIANT_TYPE_STRING;
	_tmp74_ = groups;
	_tmp74__length1 = groups_length1;
	_tmp75_ = g_variant_new_array (_tmp73_, _tmp74_, _tmp74__length1);
	_tmp76_ = g_variant_ref_sink (_tmp75_);
	_tmp77_ = persona;
	_tmp78_ = folks_favourite_details_get_is_favourite ((FolksFavouriteDetails*) _tmp77_);
	_tmp79_ = _tmp78_;
	_tmp80_ = g_variant_new_boolean (_tmp79_);
	_tmp81_ = g_variant_ref_sink (_tmp80_);
	_tmp82_ = persona;
	_tmp83_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp82_);
	_tmp84_ = _tmp83_;
	_tmp85_ = g_variant_new_string (_tmp84_);
	_tmp86_ = g_variant_ref_sink (_tmp85_);
	_tmp87_ = persona;
	_tmp88_ = tpf_persona_get_is_in_contact_list (_tmp87_);
	_tmp89_ = _tmp88_;
	_tmp90_ = g_variant_new_boolean (_tmp89_);
	_tmp91_ = g_variant_ref_sink (_tmp90_);
	_tmp92_ = persona;
	_tmp93_ = folks_persona_get_is_user ((FolksPersona*) _tmp92_);
	_tmp94_ = _tmp93_;
	_tmp95_ = g_variant_new_boolean (_tmp94_);
	_tmp96_ = g_variant_ref_sink (_tmp95_);
	_tmp97_ = G_VARIANT_TYPE_STRING;
	_tmp98_ = g_variant_new_maybe (_tmp97_, avatar_variant);
	_tmp99_ = g_variant_ref_sink (_tmp98_);
	_tmp100_ = g_new0 (GVariant*, 10 + 1);
	_tmp100_[0] = _tmp59_;
	_tmp100_[1] = _tmp64_;
	_tmp100_[2] = _tmp69_;
	_tmp100_[3] = _tmp72_;
	_tmp100_[4] = _tmp76_;
	_tmp100_[5] = _tmp81_;
	_tmp100_[6] = _tmp86_;
	_tmp100_[7] = _tmp91_;
	_tmp100_[8] = _tmp96_;
	_tmp100_[9] = _tmp99_;
	_tmp101_ = _tmp100_;
	_tmp101__length1 = 10;
	_tmp102_ = g_variant_new_tuple (_tmp101_, 10);
	_tmp103_ = g_variant_ref_sink (_tmp102_);
	_tmp104_ = _tmp103_;
	_tmp101_ = (_vala_array_free (_tmp101_, _tmp101__length1, (GDestroyNotify) g_variant_unref), NULL);
	result = _tmp104_;
	_g_variant_unref0 (avatar_variant);
	_g_variant_unref0 (_tmp46_);
	_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_;
	TpfPersona* _tmp84_;
	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_ = tpf_persona_new_from_cache (_tmp74_, _tmp75_, _tmp76_, _tmp77_, _tmp78_, _tmp79_, _tmp80_, _tmp81_, _tmp82_, _tmp83_, (GLoadableIcon*) avatar);
	result = _tmp84_;
	_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);
}



