/* link-personas.c generated by valac 0.13.1.106-1068, the Vala compiler
 * generated from link-personas.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: Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
 *
 */

#include <glib.h>
#include <glib-object.h>
#include <folks-test.h>
#include <eds-test.h>
#include <folks/folks.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gconf/gconf-client.h>
#include <gconf/gconf.h>
#include <gio/gio.h>
#include <folks/folks-eds.h>


#define TYPE_LINKING_METHOD (linking_method_get_type ())

#define TYPE_LINK_PERSONAS_TESTS (link_personas_tests_get_type ())
#define LINK_PERSONAS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LINK_PERSONAS_TESTS, LinkPersonasTests))
#define LINK_PERSONAS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LINK_PERSONAS_TESTS, LinkPersonasTestsClass))
#define IS_LINK_PERSONAS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LINK_PERSONAS_TESTS))
#define IS_LINK_PERSONAS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LINK_PERSONAS_TESTS))
#define LINK_PERSONAS_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LINK_PERSONAS_TESTS, LinkPersonasTestsClass))

typedef struct _LinkPersonasTests LinkPersonasTests;
typedef struct _LinkPersonasTestsClass LinkPersonasTestsClass;
typedef struct _LinkPersonasTestsPrivate LinkPersonasTestsPrivate;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _eds_test_backend_unref0(var) ((var == NULL) ? NULL : (var = (eds_test_backend_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _gconf_value_free0(var) ((var == NULL) ? NULL : (var = (gconf_value_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _LinkPersonasTestsTestLinkingPersonasAsyncData LinkPersonasTestsTestLinkingPersonasAsyncData;
#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _LinkPersonasTestsAddPersonasData LinkPersonasTestsAddPersonasData;
typedef struct _LinkPersonasTestsCheckPersonasData LinkPersonasTestsCheckPersonasData;

typedef enum  {
	LINKING_METHOD_IM_ADDRESSES,
	LINKING_METHOD_LOCAL_IDS,
	LINKING_METHOD_WEB_SERVICE_ADDRESSES
} LinkingMethod;

struct _LinkPersonasTests {
	FolksTestCase parent_instance;
	LinkPersonasTestsPrivate * priv;
};

struct _LinkPersonasTestsClass {
	FolksTestCaseClass parent_class;
};

struct _LinkPersonasTestsPrivate {
	GMainLoop* _main_loop;
	EdsTestBackend* _eds_backend;
	FolksIndividualAggregator* _aggregator;
	gchar* _persona_fullname_1;
	gchar* _persona_fullname_2;
	gchar* _im_address_1;
	gchar* _im_address_2;
	gboolean _linking_fired;
	gboolean _persona_found_1;
	gboolean _persona_found_2;
	gchar* _persona_iid_1;
	gchar* _persona_iid_2;
	GeeHashSet* _personas;
	gint _removed_individuals;
	gchar* _folks_config_key;
	GConfClient* _gconf_client;
	GeeHashMap* _linking_props;
	LinkingMethod _linking_method;
};

struct _LinkPersonasTestsTestLinkingPersonasAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	LinkPersonasTests* self;
	FolksBackendStore* _tmp0_;
	FolksBackendStore* store;
	FolksBackendStore* _tmp1_;
	FolksIndividualAggregator* _tmp2_;
	FolksIndividualAggregator* _tmp3_;
	FolksIndividualAggregator* _tmp4_;
	FolksPersonaStore* pstore;
	FolksBackendStore* _tmp5_;
	GeeMap* _tmp6_;
	GeeMap* _tmp7_;
	GeeCollection* _tmp8_;
	GeeCollection* _tmp9_;
	GeeCollection* _tmp10_;
	GeeIterator* _tmp11_;
	GeeIterator* _tmp12_;
	GeeIterator* _backend_it;
	GeeIterator* _tmp13_;
	gboolean _tmp14_;
	GeeIterator* _tmp15_;
	gpointer _tmp16_;
	FolksBackend* backend;
	FolksBackend* _tmp17_;
	GeeMap* _tmp18_;
	GeeMap* _tmp19_;
	gpointer _tmp20_;
	FolksPersonaStore* _tmp21_;
	FolksPersonaStore* _tmp22_;
	FolksPersonaStore* _tmp23_;
	GError* e;
	GError* _tmp24_;
	const gchar* _tmp25_;
	GError * _inner_error_;
};

struct _LinkPersonasTestsAddPersonasData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	LinkPersonasTests* self;
	FolksPersonaStore* pstore;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	GHashTable* details1;
	GValue* v1;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* wsk;
	LinkingMethod _tmp5_;
	GValue _tmp6_;
	GValue _tmp7_;
	GValue _tmp8_;
	GValue* _tmp9_;
	GeeHashMultiMap* _tmp10_;
	GeeHashMultiMap* im_addrs1;
	GeeHashMultiMap* _tmp11_;
	const gchar* _tmp12_;
	FolksImFieldDetails* _tmp13_;
	FolksImFieldDetails* _tmp14_;
	GValue* _tmp15_;
	GeeHashMultiMap* _tmp16_;
	GHashTable* _tmp17_;
	gchar* _tmp18_;
	GValue* _tmp19_;
	LinkingMethod _tmp20_;
	GValue _tmp21_;
	GValue _tmp22_;
	GValue _tmp23_;
	GValue* _tmp24_;
	GeeHashMultiMap* _tmp25_;
	GeeHashMultiMap* wsa1;
	GeeHashMultiMap* _tmp26_;
	const gchar* _tmp27_;
	FolksWebServiceFieldDetails* _tmp28_;
	FolksWebServiceFieldDetails* _tmp29_;
	GValue* _tmp30_;
	GeeHashMultiMap* _tmp31_;
	GHashTable* _tmp32_;
	const gchar* _tmp33_;
	gchar* _tmp34_;
	GValue* _tmp35_;
	GValue _tmp36_;
	GValue _tmp37_;
	GValue _tmp38_;
	GValue* _tmp39_;
	GValue* _tmp40_;
	GValue* v2;
	GValue* _tmp41_;
	const gchar* _tmp42_;
	GHashTable* _tmp43_;
	gchar* _tmp44_;
	GValue* _tmp45_;
	GHashFunc _tmp46_;
	GEqualFunc _tmp47_;
	GHashTable* _tmp48_;
	GHashTable* details2;
	GValue* v3;
	LinkingMethod _tmp49_;
	GValue _tmp50_;
	GValue _tmp51_;
	GValue _tmp52_;
	GValue* _tmp53_;
	GeeHashMultiMap* _tmp54_;
	GeeHashMultiMap* im_addrs2;
	GeeHashMultiMap* _tmp55_;
	const gchar* _tmp56_;
	FolksImFieldDetails* _tmp57_;
	FolksImFieldDetails* _tmp58_;
	GValue* _tmp59_;
	GeeHashMultiMap* _tmp60_;
	GHashTable* _tmp61_;
	gchar* _tmp62_;
	GValue* _tmp63_;
	LinkingMethod _tmp64_;
	GValue _tmp65_;
	GValue _tmp66_;
	GValue _tmp67_;
	GValue* _tmp68_;
	GeeHashMultiMap* _tmp69_;
	GeeHashMultiMap* wsa2;
	GeeHashMultiMap* _tmp70_;
	const gchar* _tmp71_;
	FolksWebServiceFieldDetails* _tmp72_;
	FolksWebServiceFieldDetails* _tmp73_;
	GValue* _tmp74_;
	GeeHashMultiMap* _tmp75_;
	GHashTable* _tmp76_;
	const gchar* _tmp77_;
	gchar* _tmp78_;
	GValue* _tmp79_;
	GValue _tmp80_;
	GValue _tmp81_;
	GValue _tmp82_;
	GValue* _tmp83_;
	GValue* _tmp84_;
	GValue* v4;
	GValue* _tmp85_;
	const gchar* _tmp86_;
	GHashTable* _tmp87_;
	gchar* _tmp88_;
	GValue* _tmp89_;
	FolksIndividualAggregator* _tmp90_;
	FolksPersonaStore* _tmp91_;
	GHashTable* _tmp92_;
	FolksPersona* _tmp93_;
	FolksPersona* _tmp94_;
	FolksIndividualAggregator* _tmp95_;
	FolksPersonaStore* _tmp96_;
	GHashTable* _tmp97_;
	FolksPersona* _tmp98_;
	FolksPersona* _tmp99_;
	GError* e;
	GError* _tmp100_;
	const gchar* _tmp101_;
	GError * _inner_error_;
};

struct _LinkPersonasTestsCheckPersonasData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	LinkPersonasTests* self;
	FolksIndividual* i;
	FolksPersona* first_persona;
	FolksIndividual* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeIterator* _tmp3_;
	GeeIterator* _p_it;
	GeeIterator* _tmp4_;
	gboolean _tmp5_;
	GeeIterator* _tmp6_;
	gpointer _tmp7_;
	FolksPersona* p;
	FolksPersona* _tmp8_;
	FolksPersona* _tmp9_;
	gboolean _tmp10_;
	FolksIndividual* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	gboolean _tmp16_;
	FolksPersona* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	GeeHashSet* _tmp21_;
	FolksPersona* _tmp22_;
	LinkingMethod _tmp23_;
	FolksPersona* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* contact_id1;
	GeeHashMap* _tmp28_;
	const gchar* _tmp29_;
	gboolean _tmp30_;
	FolksIndividual* _tmp31_;
	const gchar* _tmp32_;
	const gchar* _tmp33_;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	gboolean _tmp36_;
	FolksPersona* _tmp37_;
	const gchar* _tmp38_;
	const gchar* _tmp39_;
	gchar* _tmp40_;
	GeeHashSet* _tmp41_;
	FolksPersona* _tmp42_;
	LinkingMethod _tmp43_;
	FolksPersona* _tmp44_;
	const gchar* _tmp45_;
	const gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* contact_id2;
	GeeHashMap* _tmp48_;
	const gchar* _tmp49_;
	FolksIndividual* _tmp50_;
	GeeSet* _tmp51_;
	GeeSet* _tmp52_;
	gint _tmp53_;
	gint _tmp54_;
	LinkingMethod _tmp55_;
	FolksIndividual* _tmp56_;
	GeeMultiMap* _tmp57_;
	GeeMultiMap* _tmp58_;
	GeeSet* _tmp59_;
	GeeSet* _tmp60_;
	GeeIterator* _tmp61_;
	GeeIterator* _tmp62_;
	GeeIterator* _proto_it;
	GeeIterator* _tmp63_;
	gboolean _tmp64_;
	GeeIterator* _tmp65_;
	gpointer _tmp66_;
	gchar* proto;
	FolksIndividual* _tmp67_;
	GeeMultiMap* _tmp68_;
	GeeMultiMap* _tmp69_;
	const gchar* _tmp70_;
	GeeCollection* _tmp71_;
	GeeCollection* im_fds;
	GeeCollection* _tmp72_;
	GeeIterator* _tmp73_;
	GeeIterator* _im_fd_it;
	GeeIterator* _tmp74_;
	gboolean _tmp75_;
	GeeIterator* _tmp76_;
	gpointer _tmp77_;
	FolksImFieldDetails* im_fd;
	FolksImFieldDetails* _tmp78_;
	gconstpointer _tmp79_;
	const gchar* _tmp80_;
	GeeHashMap* _tmp81_;
	gpointer _tmp82_;
	gchar* _tmp83_;
	gboolean _tmp84_;
	GeeHashMap* _tmp85_;
	FolksImFieldDetails* _tmp86_;
	gconstpointer _tmp87_;
	const gchar* _tmp88_;
	GeeHashMap* _tmp89_;
	gpointer _tmp90_;
	gchar* _tmp91_;
	gboolean _tmp92_;
	GeeHashMap* _tmp93_;
	LinkingMethod _tmp94_;
	FolksIndividual* _tmp95_;
	GeeSet* _tmp96_;
	GeeSet* _tmp97_;
	GeeIterator* _tmp98_;
	GeeIterator* _local_id_it;
	GeeIterator* _tmp99_;
	gboolean _tmp100_;
	GeeIterator* _tmp101_;
	gpointer _tmp102_;
	gchar* local_id;
	const gchar* _tmp103_;
	GeeHashMap* _tmp104_;
	gpointer _tmp105_;
	gchar* _tmp106_;
	gboolean _tmp107_;
	GeeHashMap* _tmp108_;
	const gchar* _tmp109_;
	GeeHashMap* _tmp110_;
	gpointer _tmp111_;
	gchar* _tmp112_;
	gboolean _tmp113_;
	GeeHashMap* _tmp114_;
	LinkingMethod _tmp115_;
	FolksIndividual* _tmp116_;
	GeeMultiMap* _tmp117_;
	GeeMultiMap* _tmp118_;
	GeeSet* _tmp119_;
	GeeSet* _tmp120_;
	GeeIterator* _tmp121_;
	GeeIterator* _tmp122_;
	GeeIterator* _service_it;
	GeeIterator* _tmp123_;
	gboolean _tmp124_;
	GeeIterator* _tmp125_;
	gpointer _tmp126_;
	gchar* service;
	FolksIndividual* _tmp127_;
	GeeMultiMap* _tmp128_;
	GeeMultiMap* _tmp129_;
	const gchar* _tmp130_;
	GeeCollection* _tmp131_;
	GeeCollection* ws_fds;
	GeeCollection* _tmp132_;
	GeeIterator* _tmp133_;
	GeeIterator* _ws_fd_it;
	GeeIterator* _tmp134_;
	gboolean _tmp135_;
	GeeIterator* _tmp136_;
	gpointer _tmp137_;
	FolksWebServiceFieldDetails* ws_fd;
	FolksWebServiceFieldDetails* _tmp138_;
	GeeHashMap* _tmp139_;
	gpointer _tmp140_;
	gchar* _tmp141_;
	FolksWebServiceFieldDetails* _tmp142_;
	FolksWebServiceFieldDetails* _tmp143_;
	gboolean _tmp144_;
	gboolean _tmp145_;
	GeeHashMap* _tmp146_;
	FolksWebServiceFieldDetails* _tmp147_;
	GeeHashMap* _tmp148_;
	gpointer _tmp149_;
	gchar* _tmp150_;
	FolksWebServiceFieldDetails* _tmp151_;
	FolksWebServiceFieldDetails* _tmp152_;
	gboolean _tmp153_;
	gboolean _tmp154_;
	GeeHashMap* _tmp155_;
	GeeHashMap* _tmp156_;
	gint _tmp157_;
	gint _tmp158_;
	GMainLoop* _tmp159_;
	gboolean _tmp160_;
	GeeHashSet* _tmp161_;
	gint _tmp162_;
	gint _tmp163_;
	gboolean _tmp164_;
	gboolean _tmp165_;
	FolksIndividualAggregator* _tmp166_;
	GeeHashSet* _tmp167_;
	GError* e;
	GError* _tmp168_;
	const gchar* _tmp169_;
	GError * _inner_error_;
};


static gpointer link_personas_tests_parent_class = NULL;

GType linking_method_get_type (void) G_GNUC_CONST;
GType link_personas_tests_get_type (void) G_GNUC_CONST;
#define LINK_PERSONAS_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_LINK_PERSONAS_TESTS, LinkPersonasTestsPrivate))
enum  {
	LINK_PERSONAS_TESTS_DUMMY_PROPERTY
};
LinkPersonasTests* link_personas_tests_new (void);
LinkPersonasTests* link_personas_tests_construct (GType object_type);
void link_personas_tests_test_linking_personas_via_im_addresses (LinkPersonasTests* self);
static void _link_personas_tests_test_linking_personas_via_im_addresses_folks_test_case_test_method (gpointer self);
void link_personas_tests_test_linking_personas_via_local_ids (LinkPersonasTests* self);
static void _link_personas_tests_test_linking_personas_via_local_ids_folks_test_case_test_method (gpointer self);
void link_personas_tests_test_linking_personas_via_web_service_addresses (LinkPersonasTests* self);
static void _link_personas_tests_test_linking_personas_via_web_service_addresses_folks_test_case_test_method (gpointer self);
static void link_personas_tests_real_set_up (FolksTestCase* base);
static void link_personas_tests_real_tear_down (FolksTestCase* base);
static void _link_personas_tests_test_linking_personas (LinkPersonasTests* self);
static void _link_personas_tests_test_linking_personas_async (LinkPersonasTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _link_personas_tests_test_linking_personas_finish (LinkPersonasTests* self, GAsyncResult* _res_);
static gboolean _lambda0_ (LinkPersonasTests* self);
static gboolean __lambda0__gsource_func (gpointer self);
static void _link_personas_tests_test_linking_personas_async_data_free (gpointer _data);
static gboolean _link_personas_tests_test_linking_personas_async_co (LinkPersonasTestsTestLinkingPersonasAsyncData* _data_);
static void _link_personas_tests_test_linking_personas_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void _link_personas_tests_individuals_changed_cb (LinkPersonasTests* self, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason);
static void __link_personas_tests_individuals_changed_cb_folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self);
static void _link_personas_tests_add_personas (LinkPersonasTests* self, FolksPersonaStore* pstore, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _link_personas_tests_add_personas_finish (LinkPersonasTests* self, GAsyncResult* _res_);
static void _link_personas_tests_add_personas_data_free (gpointer _data);
static gboolean _link_personas_tests_add_personas_co (LinkPersonasTestsAddPersonasData* _data_);
static void _g_free0_ (gpointer var);
static void _vala_GValue_free (GValue* self);
static void __vala_GValue_free0_ (gpointer var);
static GValue* _g_value_dup (GValue* self);
static void _link_personas_tests_add_personas_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void _link_personas_tests_check_personas (LinkPersonasTests* self, FolksIndividual* i, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _link_personas_tests_check_personas_finish (LinkPersonasTests* self, GAsyncResult* _res_);
static void _link_personas_tests_check_personas_data_free (gpointer _data);
static gboolean _link_personas_tests_check_personas_co (LinkPersonasTestsCheckPersonasData* _data_);
static void _link_personas_tests_check_personas_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void link_personas_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


GType linking_method_get_type (void) {
	static volatile gsize linking_method_type_id__volatile = 0;
	if (g_once_init_enter (&linking_method_type_id__volatile)) {
		static const GEnumValue values[] = {{LINKING_METHOD_IM_ADDRESSES, "LINKING_METHOD_IM_ADDRESSES", "im-addresses"}, {LINKING_METHOD_LOCAL_IDS, "LINKING_METHOD_LOCAL_IDS", "local-ids"}, {LINKING_METHOD_WEB_SERVICE_ADDRESSES, "LINKING_METHOD_WEB_SERVICE_ADDRESSES", "web-service-addresses"}, {0, NULL, NULL}};
		GType linking_method_type_id;
		linking_method_type_id = g_enum_register_static ("LinkingMethod", values);
		g_once_init_leave (&linking_method_type_id__volatile, linking_method_type_id);
	}
	return linking_method_type_id__volatile;
}


static void _link_personas_tests_test_linking_personas_via_im_addresses_folks_test_case_test_method (gpointer self) {
	link_personas_tests_test_linking_personas_via_im_addresses (self);
}


static void _link_personas_tests_test_linking_personas_via_local_ids_folks_test_case_test_method (gpointer self) {
	link_personas_tests_test_linking_personas_via_local_ids (self);
}


static void _link_personas_tests_test_linking_personas_via_web_service_addresses_folks_test_case_test_method (gpointer self) {
	link_personas_tests_test_linking_personas_via_web_service_addresses (self);
}


LinkPersonasTests* link_personas_tests_construct (GType object_type) {
	LinkPersonasTests * self = NULL;
	EdsTestBackend* _tmp0_;
	self = (LinkPersonasTests*) folks_test_case_construct (object_type, "LinkPersonasTests");
	_tmp0_ = eds_test_backend_new ();
	_eds_test_backend_unref0 (self->priv->_eds_backend);
	self->priv->_eds_backend = _tmp0_;
	folks_test_case_add_test ((FolksTestCase*) self, "test linking personas via IM addresses", _link_personas_tests_test_linking_personas_via_im_addresses_folks_test_case_test_method, self);
	folks_test_case_add_test ((FolksTestCase*) self, "test linking personas via local IDs", _link_personas_tests_test_linking_personas_via_local_ids_folks_test_case_test_method, self);
	folks_test_case_add_test ((FolksTestCase*) self, "test linking personas via web service addresses", _link_personas_tests_test_linking_personas_via_web_service_addresses_folks_test_case_test_method, self);
	return self;
}


LinkPersonasTests* link_personas_tests_new (void) {
	return link_personas_tests_construct (TYPE_LINK_PERSONAS_TESTS);
}


static void link_personas_tests_real_set_up (FolksTestCase* base) {
	LinkPersonasTests * self;
	GConfClient* _tmp0_ = NULL;
	EdsTestBackend* _tmp10_;
	GError * _inner_error_ = NULL;
	self = (LinkPersonasTests*) base;
	_tmp0_ = gconf_client_get_default ();
	self->priv->_gconf_client = _tmp0_;
	{
		GConfValue* _tmp1_;
		GConfValue* val;
		GConfValue* _tmp2_;
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_;
		GConfClient* _tmp5_;
		const gchar* _tmp6_;
		GConfValue* _tmp7_;
		_tmp1_ = gconf_value_new (GCONF_VALUE_STRING);
		val = _tmp1_;
		_tmp2_ = val;
		_tmp3_ = g_strdup_printf ("eds:%s", EDS_TEST_BACKEND_address_book_uri);
		_tmp4_ = _tmp3_;
		gconf_value_set_string (_tmp2_, _tmp4_);
		_g_free0 (_tmp4_);
		_tmp5_ = self->priv->_gconf_client;
		_tmp6_ = self->priv->_folks_config_key;
		_tmp7_ = val;
		gconf_client_set (_tmp5_, _tmp6_, _tmp7_, &_inner_error_);
		if (_inner_error_ != NULL) {
			_gconf_value_free0 (val);
			goto __catch0_g_error;
		}
		_gconf_value_free0 (val);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp8_;
		const gchar* _tmp9_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp8_ = e;
		_tmp9_ = _tmp8_->message;
		g_warning ("link-personas.vala:79: Couldn't set primary store: %s\n", _tmp9_);
		_g_error_free0 (e);
	}
	__finally0:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp10_ = self->priv->_eds_backend;
	eds_test_backend_set_up (_tmp10_);
}


static void link_personas_tests_real_tear_down (FolksTestCase* base) {
	LinkPersonasTests * self;
	EdsTestBackend* _tmp0_;
	GError * _inner_error_ = NULL;
	self = (LinkPersonasTests*) base;
	_tmp0_ = self->priv->_eds_backend;
	eds_test_backend_tear_down (_tmp0_);
	{
		GConfClient* _tmp1_;
		const gchar* _tmp2_;
		_tmp1_ = self->priv->_gconf_client;
		_tmp2_ = self->priv->_folks_config_key;
		gconf_client_unset (_tmp1_, _tmp2_, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("link-personas.vala:95: Couldn't unset primary store: %s\n", _tmp4_);
		_g_error_free0 (e);
	}
	__finally1:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


void link_personas_tests_test_linking_personas_via_im_addresses (LinkPersonasTests* self) {
	g_return_if_fail (self != NULL);
	self->priv->_linking_method = LINKING_METHOD_IM_ADDRESSES;
	_link_personas_tests_test_linking_personas (self);
}


void link_personas_tests_test_linking_personas_via_local_ids (LinkPersonasTests* self) {
	g_return_if_fail (self != NULL);
	self->priv->_linking_method = LINKING_METHOD_LOCAL_IDS;
	_link_personas_tests_test_linking_personas (self);
}


void link_personas_tests_test_linking_personas_via_web_service_addresses (LinkPersonasTests* self) {
	g_return_if_fail (self != NULL);
	self->priv->_linking_method = LINKING_METHOD_WEB_SERVICE_ADDRESSES;
	_link_personas_tests_test_linking_personas (self);
}


static gboolean _lambda0_ (LinkPersonasTests* self) {
	gboolean result = FALSE;
	GMainLoop* _tmp0_;
	_tmp0_ = self->priv->_main_loop;
	g_main_loop_quit (_tmp0_);
	g_assert_not_reached ();
	return result;
}


static gboolean __lambda0__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda0_ (self);
	return result;
}


static void _link_personas_tests_test_linking_personas (LinkPersonasTests* self) {
	GMainLoop* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GeeHashSet* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GeeHashMap* _tmp6_;
	gboolean _tmp7_ = FALSE;
	LinkingMethod _tmp8_;
	gboolean _tmp10_;
	guint _tmp15_ = 0U;
	guint timer_id;
	GMainLoop* _tmp16_;
	GeeHashMap* _tmp17_;
	gint _tmp18_;
	gint _tmp19_;
	gint _tmp20_;
	guint _tmp21_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (self->priv->_main_loop);
	self->priv->_main_loop = _tmp0_;
	_tmp1_ = g_strdup ("persona #1");
	_g_free0 (self->priv->_persona_fullname_1);
	self->priv->_persona_fullname_1 = _tmp1_;
	_tmp2_ = g_strdup ("persona #2");
	_g_free0 (self->priv->_persona_fullname_2);
	self->priv->_persona_fullname_2 = _tmp2_;
	_tmp3_ = gee_hash_set_new (FOLKS_TYPE_PERSONA, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL);
	_g_object_unref0 (self->priv->_personas);
	self->priv->_personas = _tmp3_;
	self->priv->_removed_individuals = 0;
	self->priv->_persona_found_1 = FALSE;
	self->priv->_persona_found_2 = FALSE;
	self->priv->_linking_fired = FALSE;
	_tmp4_ = g_strdup ("");
	_g_free0 (self->priv->_persona_iid_1);
	self->priv->_persona_iid_1 = _tmp4_;
	_tmp5_ = g_strdup ("");
	_g_free0 (self->priv->_persona_iid_2);
	self->priv->_persona_iid_2 = _tmp5_;
	_tmp6_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->_linking_props);
	self->priv->_linking_props = _tmp6_;
	_tmp8_ = self->priv->_linking_method;
	if (_tmp8_ == LINKING_METHOD_IM_ADDRESSES) {
		_tmp7_ = TRUE;
	} else {
		LinkingMethod _tmp9_;
		_tmp9_ = self->priv->_linking_method;
		_tmp7_ = _tmp9_ == LINKING_METHOD_WEB_SERVICE_ADDRESSES;
	}
	_tmp10_ = _tmp7_;
	if (_tmp10_) {
		GeeHashMap* _tmp11_;
		const gchar* _tmp12_;
		GeeHashMap* _tmp13_;
		const gchar* _tmp14_;
		_tmp11_ = self->priv->_linking_props;
		_tmp12_ = self->priv->_im_address_1;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp11_, "prop1", _tmp12_);
		_tmp13_ = self->priv->_linking_props;
		_tmp14_ = self->priv->_im_address_2;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp13_, "prop2", _tmp14_);
	}
	_link_personas_tests_test_linking_personas_async (self, NULL, NULL);
	_tmp15_ = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 8, __lambda0__gsource_func, g_object_ref (self), g_object_unref);
	timer_id = _tmp15_;
	_tmp16_ = self->priv->_main_loop;
	g_main_loop_run (_tmp16_);
	_tmp17_ = self->priv->_linking_props;
	_tmp18_ = gee_map_get_size ((GeeMap*) _tmp17_);
	_tmp19_ = _tmp18_;
	g_assert (_tmp19_ == 0);
	_tmp20_ = self->priv->_removed_individuals;
	g_assert (_tmp20_ == 2);
	_tmp21_ = timer_id;
	g_source_remove (_tmp21_);
	_g_object_unref0 (self->priv->_aggregator);
	self->priv->_aggregator = NULL;
	_g_main_loop_unref0 (self->priv->_main_loop);
	self->priv->_main_loop = NULL;
}


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


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


static void _link_personas_tests_test_linking_personas_async (LinkPersonasTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	LinkPersonasTestsTestLinkingPersonasAsyncData* _data_;
	LinkPersonasTests* _tmp0_;
	_data_ = g_slice_new0 (LinkPersonasTestsTestLinkingPersonasAsyncData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _link_personas_tests_test_linking_personas_async);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _link_personas_tests_test_linking_personas_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_link_personas_tests_test_linking_personas_async_co (_data_);
}


static void _link_personas_tests_test_linking_personas_finish (LinkPersonasTests* self, GAsyncResult* _res_) {
	LinkPersonasTestsTestLinkingPersonasAsyncData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void _link_personas_tests_test_linking_personas_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	LinkPersonasTestsTestLinkingPersonasAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_link_personas_tests_test_linking_personas_async_co (_data_);
}


static void __link_personas_tests_individuals_changed_cb_folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self) {
	_link_personas_tests_individuals_changed_cb (self, added, removed, message, actor, reason);
}


static gboolean _link_personas_tests_test_linking_personas_async_co (LinkPersonasTestsTestLinkingPersonasAsyncData* _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_ = NULL;
	_data_->_tmp0_ = folks_backend_store_dup ();
	_data_->store = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->store;
	_data_->_state_ = 1;
	folks_backend_store_prepare (_data_->_tmp1_, _link_personas_tests_test_linking_personas_async_ready, _data_);
	return FALSE;
	_state_1:
	folks_backend_store_prepare_finish (_data_->_tmp1_, _data_->_res_);
	_data_->_tmp2_ = folks_individual_aggregator_new ();
	_g_object_unref0 (_data_->self->priv->_aggregator);
	_data_->self->priv->_aggregator = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->self->priv->_aggregator;
	g_signal_connect_object (_data_->_tmp3_, "individuals-changed", (GCallback) __link_personas_tests_individuals_changed_cb_folks_individual_aggregator_individuals_changed, _data_->self, 0);
	{
		_data_->_tmp4_ = _data_->self->priv->_aggregator;
		_data_->_state_ = 2;
		folks_individual_aggregator_prepare (_data_->_tmp4_, _link_personas_tests_test_linking_personas_async_ready, _data_);
		return FALSE;
		_state_2:
		folks_individual_aggregator_prepare_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch2_g_error;
		}
		_data_->pstore = NULL;
		{
			_data_->_tmp5_ = _data_->store;
			_data_->_tmp6_ = folks_backend_store_get_enabled_backends (_data_->_tmp5_);
			_data_->_tmp7_ = _data_->_tmp6_;
			_data_->_tmp8_ = gee_map_get_values (_data_->_tmp7_);
			_data_->_tmp9_ = _data_->_tmp8_;
			_data_->_tmp10_ = _data_->_tmp9_;
			_data_->_tmp11_ = NULL;
			_data_->_tmp11_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp10_);
			_data_->_tmp12_ = _data_->_tmp11_;
			_g_object_unref0 (_data_->_tmp10_);
			_data_->_backend_it = _data_->_tmp12_;
			while (TRUE) {
				_data_->_tmp13_ = _data_->_backend_it;
				_data_->_tmp14_ = FALSE;
				_data_->_tmp14_ = gee_iterator_next (_data_->_tmp13_);
				if (!_data_->_tmp14_) {
					break;
				}
				_data_->_tmp15_ = _data_->_backend_it;
				_data_->_tmp16_ = NULL;
				_data_->_tmp16_ = gee_iterator_get (_data_->_tmp15_);
				_data_->backend = (FolksBackend*) _data_->_tmp16_;
				_data_->_tmp17_ = _data_->backend;
				_data_->_tmp18_ = folks_backend_get_persona_stores (_data_->_tmp17_);
				_data_->_tmp19_ = _data_->_tmp18_;
				_data_->_tmp20_ = NULL;
				_data_->_tmp20_ = gee_map_get (_data_->_tmp19_, "local://test");
				_g_object_unref0 (_data_->pstore);
				_data_->pstore = (FolksPersonaStore*) _data_->_tmp20_;
				_data_->_tmp21_ = _data_->pstore;
				if (_data_->_tmp21_ != NULL) {
					_g_object_unref0 (_data_->backend);
					break;
				}
				_g_object_unref0 (_data_->backend);
			}
			_g_object_unref0 (_data_->_backend_it);
		}
		_data_->_tmp22_ = _data_->pstore;
		g_assert (_data_->_tmp22_ != NULL);
		_data_->_tmp23_ = _data_->pstore;
		_data_->_state_ = 3;
		_link_personas_tests_add_personas (_data_->self, _data_->_tmp23_, _link_personas_tests_test_linking_personas_async_ready, _data_);
		return FALSE;
		_state_3:
		_link_personas_tests_add_personas_finish (_data_->self, _data_->_res_);
		_g_object_unref0 (_data_->pstore);
	}
	goto __finally2;
	__catch2_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp24_ = _data_->e;
		_data_->_tmp25_ = _data_->_tmp24_->message;
		g_warning ("link-personas.vala:182: Error when calling prepare: %s\n", _data_->_tmp25_);
		_g_error_free0 (_data_->e);
	}
	__finally2:
	if (_data_->_inner_error_ != NULL) {
		_g_object_unref0 (_data_->store);
		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;
	}
	_g_object_unref0 (_data_->store);
	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 _link_personas_tests_add_personas_data_free (gpointer _data) {
	LinkPersonasTestsAddPersonasData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->pstore);
	_g_object_unref0 (_data_->self);
	g_slice_free (LinkPersonasTestsAddPersonasData, _data_);
}


static void _link_personas_tests_add_personas (LinkPersonasTests* self, FolksPersonaStore* pstore, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	LinkPersonasTestsAddPersonasData* _data_;
	LinkPersonasTests* _tmp0_;
	FolksPersonaStore* _tmp1_;
	FolksPersonaStore* _tmp2_;
	_data_ = g_slice_new0 (LinkPersonasTestsAddPersonasData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _link_personas_tests_add_personas);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _link_personas_tests_add_personas_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = pstore;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data_->pstore = _tmp2_;
	_link_personas_tests_add_personas_co (_data_);
}


static void _link_personas_tests_add_personas_finish (LinkPersonasTests* self, GAsyncResult* _res_) {
	LinkPersonasTestsAddPersonasData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


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


static void _vala_GValue_free (GValue* self) {
	g_value_unset (self);
	g_free (self);
}


static void __vala_GValue_free0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL));
}


static GValue* _g_value_dup (GValue* self) {
	return g_boxed_copy (G_TYPE_VALUE, self);
}


static gpointer __g_value_dup0 (gpointer self) {
	return self ? _g_value_dup (self) : NULL;
}


static void _link_personas_tests_add_personas_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	LinkPersonasTestsAddPersonasData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_link_personas_tests_add_personas_co (_data_);
}


static gboolean _link_personas_tests_add_personas_co (LinkPersonasTestsAddPersonasData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_str_hash;
	_data_->_tmp1_ = g_str_equal;
	_data_->_tmp2_ = g_hash_table_new_full (_data_->_tmp0_, _data_->_tmp1_, _g_free0_, __vala_GValue_free0_);
	_data_->details1 = _data_->_tmp2_;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = folks_persona_store_detail_key (FOLKS_PERSONA_DETAIL_WEB_SERVICE_ADDRESSES);
	_data_->_tmp4_ = g_strdup (_data_->_tmp3_);
	_data_->wsk = _data_->_tmp4_;
	_data_->_tmp5_ = _data_->self->priv->_linking_method;
	if (_data_->_tmp5_ == LINKING_METHOD_IM_ADDRESSES) {
		memset (&_data_->_tmp6_, 0, sizeof (GValue));
		g_value_init (&_data_->_tmp6_, GEE_TYPE_MULTI_MAP);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_tmp9_ = __g_value_dup0 (&_data_->_tmp8_);
		__vala_GValue_free0 (_data_->v1);
		_data_->v1 = _data_->_tmp9_;
		G_IS_VALUE (&_data_->_tmp8_) ? (g_value_unset (&_data_->_tmp8_), NULL) : NULL;
		_data_->_tmp10_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, FOLKS_TYPE_IM_FIELD_DETAILS, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, (GHashFunc) folks_abstract_field_details_hash, (GEqualFunc) folks_abstract_field_details_equal);
		_data_->im_addrs1 = _data_->_tmp10_;
		_data_->_tmp11_ = _data_->im_addrs1;
		_data_->_tmp12_ = _data_->self->priv->_im_address_1;
		_data_->_tmp13_ = folks_im_field_details_new (_data_->_tmp12_, NULL);
		_data_->_tmp14_ = _data_->_tmp13_;
		gee_multi_map_set ((GeeMultiMap*) _data_->_tmp11_, "jabber", _data_->_tmp14_);
		_g_object_unref0 (_data_->_tmp14_);
		_data_->_tmp15_ = _data_->v1;
		_data_->_tmp16_ = _data_->im_addrs1;
		g_value_set_object (_data_->_tmp15_, (GObject*) _data_->_tmp16_);
		_data_->_tmp17_ = _data_->details1;
		_data_->_tmp18_ = g_strdup ("im-addresses");
		_data_->_tmp19_ = _data_->v1;
		_data_->v1 = NULL;
		g_hash_table_insert (_data_->_tmp17_, _data_->_tmp18_, _data_->_tmp19_);
		_g_object_unref0 (_data_->im_addrs1);
	} else {
		_data_->_tmp20_ = _data_->self->priv->_linking_method;
		if (_data_->_tmp20_ == LINKING_METHOD_WEB_SERVICE_ADDRESSES) {
			memset (&_data_->_tmp21_, 0, sizeof (GValue));
			g_value_init (&_data_->_tmp21_, GEE_TYPE_MULTI_MAP);
			_data_->_tmp22_ = _data_->_tmp21_;
			_data_->_tmp23_ = _data_->_tmp22_;
			_data_->_tmp24_ = __g_value_dup0 (&_data_->_tmp23_);
			__vala_GValue_free0 (_data_->v1);
			_data_->v1 = _data_->_tmp24_;
			G_IS_VALUE (&_data_->_tmp23_) ? (g_value_unset (&_data_->_tmp23_), NULL) : NULL;
			_data_->_tmp25_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, FOLKS_TYPE_WEB_SERVICE_FIELD_DETAILS, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, (GHashFunc) folks_abstract_field_details_hash, (GEqualFunc) folks_abstract_field_details_equal);
			_data_->wsa1 = _data_->_tmp25_;
			_data_->_tmp26_ = _data_->wsa1;
			_data_->_tmp27_ = _data_->self->priv->_im_address_1;
			_data_->_tmp28_ = folks_web_service_field_details_new (_data_->_tmp27_, NULL);
			_data_->_tmp29_ = _data_->_tmp28_;
			gee_multi_map_set ((GeeMultiMap*) _data_->_tmp26_, "twitter", _data_->_tmp29_);
			_g_object_unref0 (_data_->_tmp29_);
			_data_->_tmp30_ = _data_->v1;
			_data_->_tmp31_ = _data_->wsa1;
			g_value_set_object (_data_->_tmp30_, (GObject*) _data_->_tmp31_);
			_data_->_tmp32_ = _data_->details1;
			_data_->_tmp33_ = _data_->wsk;
			_data_->_tmp34_ = g_strdup (_data_->_tmp33_);
			_data_->_tmp35_ = _data_->v1;
			_data_->v1 = NULL;
			g_hash_table_insert (_data_->_tmp32_, _data_->_tmp34_, _data_->_tmp35_);
			_g_object_unref0 (_data_->wsa1);
		}
	}
	memset (&_data_->_tmp36_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp36_, G_TYPE_STRING);
	_data_->_tmp37_ = _data_->_tmp36_;
	_data_->_tmp38_ = _data_->_tmp37_;
	_data_->_tmp39_ = __g_value_dup0 (&_data_->_tmp38_);
	_data_->_tmp40_ = _data_->_tmp39_;
	G_IS_VALUE (&_data_->_tmp38_) ? (g_value_unset (&_data_->_tmp38_), NULL) : NULL;
	_data_->v2 = _data_->_tmp40_;
	_data_->_tmp41_ = _data_->v2;
	_data_->_tmp42_ = _data_->self->priv->_persona_fullname_1;
	g_value_set_string (_data_->_tmp41_, _data_->_tmp42_);
	_data_->_tmp43_ = _data_->details1;
	_data_->_tmp44_ = g_strdup ("full-name");
	_data_->_tmp45_ = _data_->v2;
	_data_->v2 = NULL;
	g_hash_table_insert (_data_->_tmp43_, _data_->_tmp44_, _data_->_tmp45_);
	_data_->_tmp46_ = g_str_hash;
	_data_->_tmp47_ = g_str_equal;
	_data_->_tmp48_ = g_hash_table_new_full (_data_->_tmp46_, _data_->_tmp47_, _g_free0_, __vala_GValue_free0_);
	_data_->details2 = _data_->_tmp48_;
	_data_->_tmp49_ = _data_->self->priv->_linking_method;
	if (_data_->_tmp49_ == LINKING_METHOD_IM_ADDRESSES) {
		memset (&_data_->_tmp50_, 0, sizeof (GValue));
		g_value_init (&_data_->_tmp50_, GEE_TYPE_MULTI_MAP);
		_data_->_tmp51_ = _data_->_tmp50_;
		_data_->_tmp52_ = _data_->_tmp51_;
		_data_->_tmp53_ = __g_value_dup0 (&_data_->_tmp52_);
		__vala_GValue_free0 (_data_->v3);
		_data_->v3 = _data_->_tmp53_;
		G_IS_VALUE (&_data_->_tmp52_) ? (g_value_unset (&_data_->_tmp52_), NULL) : NULL;
		_data_->_tmp54_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, FOLKS_TYPE_IM_FIELD_DETAILS, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, (GHashFunc) folks_abstract_field_details_hash, (GEqualFunc) folks_abstract_field_details_equal);
		_data_->im_addrs2 = _data_->_tmp54_;
		_data_->_tmp55_ = _data_->im_addrs2;
		_data_->_tmp56_ = _data_->self->priv->_im_address_2;
		_data_->_tmp57_ = folks_im_field_details_new (_data_->_tmp56_, NULL);
		_data_->_tmp58_ = _data_->_tmp57_;
		gee_multi_map_set ((GeeMultiMap*) _data_->_tmp55_, "yahoo", _data_->_tmp58_);
		_g_object_unref0 (_data_->_tmp58_);
		_data_->_tmp59_ = _data_->v3;
		_data_->_tmp60_ = _data_->im_addrs2;
		g_value_set_object (_data_->_tmp59_, (GObject*) _data_->_tmp60_);
		_data_->_tmp61_ = _data_->details2;
		_data_->_tmp62_ = g_strdup ("im-addresses");
		_data_->_tmp63_ = _data_->v3;
		_data_->v3 = NULL;
		g_hash_table_insert (_data_->_tmp61_, _data_->_tmp62_, _data_->_tmp63_);
		_g_object_unref0 (_data_->im_addrs2);
	} else {
		_data_->_tmp64_ = _data_->self->priv->_linking_method;
		if (_data_->_tmp64_ == LINKING_METHOD_WEB_SERVICE_ADDRESSES) {
			memset (&_data_->_tmp65_, 0, sizeof (GValue));
			g_value_init (&_data_->_tmp65_, GEE_TYPE_MULTI_MAP);
			_data_->_tmp66_ = _data_->_tmp65_;
			_data_->_tmp67_ = _data_->_tmp66_;
			_data_->_tmp68_ = __g_value_dup0 (&_data_->_tmp67_);
			__vala_GValue_free0 (_data_->v3);
			_data_->v3 = _data_->_tmp68_;
			G_IS_VALUE (&_data_->_tmp67_) ? (g_value_unset (&_data_->_tmp67_), NULL) : NULL;
			_data_->_tmp69_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, FOLKS_TYPE_WEB_SERVICE_FIELD_DETAILS, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, (GHashFunc) folks_abstract_field_details_hash, (GEqualFunc) folks_abstract_field_details_equal);
			_data_->wsa2 = _data_->_tmp69_;
			_data_->_tmp70_ = _data_->wsa2;
			_data_->_tmp71_ = _data_->self->priv->_im_address_2;
			_data_->_tmp72_ = folks_web_service_field_details_new (_data_->_tmp71_, NULL);
			_data_->_tmp73_ = _data_->_tmp72_;
			gee_multi_map_set ((GeeMultiMap*) _data_->_tmp70_, "lastfm", _data_->_tmp73_);
			_g_object_unref0 (_data_->_tmp73_);
			_data_->_tmp74_ = _data_->v3;
			_data_->_tmp75_ = _data_->wsa2;
			g_value_set_object (_data_->_tmp74_, (GObject*) _data_->_tmp75_);
			_data_->_tmp76_ = _data_->details2;
			_data_->_tmp77_ = _data_->wsk;
			_data_->_tmp78_ = g_strdup (_data_->_tmp77_);
			_data_->_tmp79_ = _data_->v3;
			_data_->v3 = NULL;
			g_hash_table_insert (_data_->_tmp76_, _data_->_tmp78_, _data_->_tmp79_);
			_g_object_unref0 (_data_->wsa2);
		}
	}
	memset (&_data_->_tmp80_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp80_, G_TYPE_STRING);
	_data_->_tmp81_ = _data_->_tmp80_;
	_data_->_tmp82_ = _data_->_tmp81_;
	_data_->_tmp83_ = __g_value_dup0 (&_data_->_tmp82_);
	_data_->_tmp84_ = _data_->_tmp83_;
	G_IS_VALUE (&_data_->_tmp82_) ? (g_value_unset (&_data_->_tmp82_), NULL) : NULL;
	_data_->v4 = _data_->_tmp84_;
	_data_->_tmp85_ = _data_->v4;
	_data_->_tmp86_ = _data_->self->priv->_persona_fullname_2;
	g_value_set_string (_data_->_tmp85_, _data_->_tmp86_);
	_data_->_tmp87_ = _data_->details2;
	_data_->_tmp88_ = g_strdup ("full-name");
	_data_->_tmp89_ = _data_->v4;
	_data_->v4 = NULL;
	g_hash_table_insert (_data_->_tmp87_, _data_->_tmp88_, _data_->_tmp89_);
	{
		_data_->_tmp90_ = _data_->self->priv->_aggregator;
		_data_->_tmp91_ = _data_->pstore;
		_data_->_tmp92_ = _data_->details1;
		_data_->_state_ = 1;
		folks_individual_aggregator_add_persona_from_details (_data_->_tmp90_, NULL, _data_->_tmp91_, _data_->_tmp92_, _link_personas_tests_add_personas_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp93_ = NULL;
		_data_->_tmp93_ = folks_individual_aggregator_add_persona_from_details_finish (_data_->_tmp90_, _data_->_res_, &_data_->_inner_error_);
		_data_->_tmp94_ = _data_->_tmp93_;
		_g_object_unref0 (_data_->_tmp94_);
		if (_data_->_inner_error_ != NULL) {
			if (_data_->_inner_error_->domain == FOLKS_INDIVIDUAL_AGGREGATOR_ERROR) {
				goto __catch3_folks_individual_aggregator_error;
			}
			__vala_GValue_free0 (_data_->v4);
			__vala_GValue_free0 (_data_->v3);
			_g_hash_table_unref0 (_data_->details2);
			__vala_GValue_free0 (_data_->v2);
			_g_free0 (_data_->wsk);
			__vala_GValue_free0 (_data_->v1);
			_g_hash_table_unref0 (_data_->details1);
			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;
		}
		_data_->_tmp95_ = _data_->self->priv->_aggregator;
		_data_->_tmp96_ = _data_->pstore;
		_data_->_tmp97_ = _data_->details2;
		_data_->_state_ = 2;
		folks_individual_aggregator_add_persona_from_details (_data_->_tmp95_, NULL, _data_->_tmp96_, _data_->_tmp97_, _link_personas_tests_add_personas_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp98_ = NULL;
		_data_->_tmp98_ = folks_individual_aggregator_add_persona_from_details_finish (_data_->_tmp95_, _data_->_res_, &_data_->_inner_error_);
		_data_->_tmp99_ = _data_->_tmp98_;
		_g_object_unref0 (_data_->_tmp99_);
		if (_data_->_inner_error_ != NULL) {
			if (_data_->_inner_error_->domain == FOLKS_INDIVIDUAL_AGGREGATOR_ERROR) {
				goto __catch3_folks_individual_aggregator_error;
			}
			__vala_GValue_free0 (_data_->v4);
			__vala_GValue_free0 (_data_->v3);
			_g_hash_table_unref0 (_data_->details2);
			__vala_GValue_free0 (_data_->v2);
			_g_free0 (_data_->wsk);
			__vala_GValue_free0 (_data_->v1);
			_g_hash_table_unref0 (_data_->details1);
			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;
		}
	}
	goto __finally3;
	__catch3_folks_individual_aggregator_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp100_ = _data_->e;
		_data_->_tmp101_ = _data_->_tmp100_->message;
		g_warning ("link-personas.vala:270: [AddPersonaError] add_persona_from_details: %s" \
"\n", _data_->_tmp101_);
		_g_error_free0 (_data_->e);
	}
	__finally3:
	if (_data_->_inner_error_ != NULL) {
		__vala_GValue_free0 (_data_->v4);
		__vala_GValue_free0 (_data_->v3);
		_g_hash_table_unref0 (_data_->details2);
		__vala_GValue_free0 (_data_->v2);
		_g_free0 (_data_->wsk);
		__vala_GValue_free0 (_data_->v1);
		_g_hash_table_unref0 (_data_->details1);
		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;
	}
	__vala_GValue_free0 (_data_->v4);
	__vala_GValue_free0 (_data_->v3);
	_g_hash_table_unref0 (_data_->details2);
	__vala_GValue_free0 (_data_->v2);
	_g_free0 (_data_->wsk);
	__vala_GValue_free0 (_data_->v1);
	_g_hash_table_unref0 (_data_->details1);
	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 _link_personas_tests_individuals_changed_cb (LinkPersonasTests* self, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason) {
	GeeSet* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (added != NULL);
	g_return_if_fail (removed != NULL);
	{
		GeeSet* _tmp0_;
		GeeIterator* _tmp1_ = NULL;
		GeeIterator* _i_it;
		_tmp0_ = added;
		_tmp1_ = gee_iterable_iterator ((GeeIterable*) _tmp0_);
		_i_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			gboolean _tmp3_ = FALSE;
			GeeIterator* _tmp4_;
			gpointer _tmp5_ = NULL;
			FolksIndividual* i;
			FolksIndividual* _tmp6_;
			_tmp2_ = _i_it;
			_tmp3_ = gee_iterator_next (_tmp2_);
			if (!_tmp3_) {
				break;
			}
			_tmp4_ = _i_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			i = (FolksIndividual*) _tmp5_;
			_tmp6_ = i;
			_link_personas_tests_check_personas (self, _tmp6_, NULL, NULL);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp7_ = removed;
	_tmp8_ = gee_collection_get_size ((GeeCollection*) _tmp7_);
	_tmp9_ = _tmp8_;
	if (_tmp9_ > 0) {
		gint _tmp10_;
		GeeSet* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		_tmp10_ = self->priv->_removed_individuals;
		_tmp11_ = removed;
		_tmp12_ = gee_collection_get_size ((GeeCollection*) _tmp11_);
		_tmp13_ = _tmp12_;
		self->priv->_removed_individuals = _tmp10_ + ((gint) _tmp13_);
	}
}


static void _link_personas_tests_check_personas_data_free (gpointer _data) {
	LinkPersonasTestsCheckPersonasData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->i);
	_g_object_unref0 (_data_->self);
	g_slice_free (LinkPersonasTestsCheckPersonasData, _data_);
}


static void _link_personas_tests_check_personas (LinkPersonasTests* self, FolksIndividual* i, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	LinkPersonasTestsCheckPersonasData* _data_;
	LinkPersonasTests* _tmp0_;
	FolksIndividual* _tmp1_;
	FolksIndividual* _tmp2_;
	_data_ = g_slice_new0 (LinkPersonasTestsCheckPersonasData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _link_personas_tests_check_personas);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _link_personas_tests_check_personas_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = i;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data_->i = _tmp2_;
	_link_personas_tests_check_personas_co (_data_);
}


static void _link_personas_tests_check_personas_finish (LinkPersonasTests* self, GAsyncResult* _res_) {
	LinkPersonasTestsCheckPersonasData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void _link_personas_tests_check_personas_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	LinkPersonasTestsCheckPersonasData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_link_personas_tests_check_personas_co (_data_);
}


static gboolean _link_personas_tests_check_personas_co (LinkPersonasTestsCheckPersonasData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->first_persona = NULL;
	{
		_data_->_tmp0_ = _data_->i;
		_data_->_tmp1_ = folks_individual_get_personas (_data_->_tmp0_);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp3_ = NULL;
		_data_->_tmp3_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp2_);
		_data_->_p_it = _data_->_tmp3_;
		while (TRUE) {
			_data_->_tmp4_ = _data_->_p_it;
			_data_->_tmp5_ = FALSE;
			_data_->_tmp5_ = gee_iterator_next (_data_->_tmp4_);
			if (!_data_->_tmp5_) {
				break;
			}
			_data_->_tmp6_ = _data_->_p_it;
			_data_->_tmp7_ = NULL;
			_data_->_tmp7_ = gee_iterator_get (_data_->_tmp6_);
			_data_->p = (FolksPersona*) _data_->_tmp7_;
			_data_->_tmp8_ = _data_->p;
			_data_->_tmp9_ = _g_object_ref0 (_data_->_tmp8_);
			_g_object_unref0 (_data_->first_persona);
			_data_->first_persona = _data_->_tmp9_;
			_g_object_unref0 (_data_->p);
			break;
		}
		_g_object_unref0 (_data_->_p_it);
	}
	_data_->_tmp11_ = _data_->i;
	_data_->_tmp12_ = folks_name_details_get_full_name ((FolksNameDetails*) _data_->_tmp11_);
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_tmp14_ = _data_->self->priv->_persona_fullname_1;
	if (g_strcmp0 (_data_->_tmp13_, _data_->_tmp14_) == 0) {
		_data_->_tmp15_ = _data_->self->priv->_persona_iid_1;
		_data_->_tmp10_ = g_strcmp0 (_data_->_tmp15_, "") == 0;
	} else {
		_data_->_tmp10_ = FALSE;
	}
	_data_->_tmp16_ = _data_->_tmp10_;
	if (_data_->_tmp16_) {
		_data_->_tmp17_ = _data_->first_persona;
		_data_->_tmp18_ = folks_persona_get_iid (_data_->_tmp17_);
		_data_->_tmp19_ = _data_->_tmp18_;
		_data_->_tmp20_ = g_strdup (_data_->_tmp19_);
		_g_free0 (_data_->self->priv->_persona_iid_1);
		_data_->self->priv->_persona_iid_1 = _data_->_tmp20_;
		_data_->_tmp21_ = _data_->self->priv->_personas;
		_data_->_tmp22_ = _data_->first_persona;
		gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp21_, _data_->_tmp22_);
		_data_->_tmp23_ = _data_->self->priv->_linking_method;
		if (_data_->_tmp23_ == LINKING_METHOD_LOCAL_IDS) {
			_data_->_tmp24_ = _data_->first_persona;
			_data_->_tmp25_ = edsf_persona_get_contact_id (EDSF_PERSONA (_data_->_tmp24_));
			_data_->_tmp26_ = _data_->_tmp25_;
			_data_->_tmp27_ = g_strdup (_data_->_tmp26_);
			_data_->contact_id1 = _data_->_tmp27_;
			_data_->_tmp28_ = _data_->self->priv->_linking_props;
			_data_->_tmp29_ = _data_->contact_id1;
			gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp28_, "prop1", _data_->_tmp29_);
			_g_free0 (_data_->contact_id1);
		}
	} else {
		_data_->_tmp31_ = _data_->i;
		_data_->_tmp32_ = folks_name_details_get_full_name ((FolksNameDetails*) _data_->_tmp31_);
		_data_->_tmp33_ = _data_->_tmp32_;
		_data_->_tmp34_ = _data_->self->priv->_persona_fullname_2;
		if (g_strcmp0 (_data_->_tmp33_, _data_->_tmp34_) == 0) {
			_data_->_tmp35_ = _data_->self->priv->_persona_iid_2;
			_data_->_tmp30_ = g_strcmp0 (_data_->_tmp35_, "") == 0;
		} else {
			_data_->_tmp30_ = FALSE;
		}
		_data_->_tmp36_ = _data_->_tmp30_;
		if (_data_->_tmp36_) {
			_data_->_tmp37_ = _data_->first_persona;
			_data_->_tmp38_ = folks_persona_get_iid (_data_->_tmp37_);
			_data_->_tmp39_ = _data_->_tmp38_;
			_data_->_tmp40_ = g_strdup (_data_->_tmp39_);
			_g_free0 (_data_->self->priv->_persona_iid_2);
			_data_->self->priv->_persona_iid_2 = _data_->_tmp40_;
			_data_->_tmp41_ = _data_->self->priv->_personas;
			_data_->_tmp42_ = _data_->first_persona;
			gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp41_, _data_->_tmp42_);
			_data_->_tmp43_ = _data_->self->priv->_linking_method;
			if (_data_->_tmp43_ == LINKING_METHOD_LOCAL_IDS) {
				_data_->_tmp44_ = _data_->first_persona;
				_data_->_tmp45_ = edsf_persona_get_contact_id (EDSF_PERSONA (_data_->_tmp44_));
				_data_->_tmp46_ = _data_->_tmp45_;
				_data_->_tmp47_ = g_strdup (_data_->_tmp46_);
				_data_->contact_id2 = _data_->_tmp47_;
				_data_->_tmp48_ = _data_->self->priv->_linking_props;
				_data_->_tmp49_ = _data_->contact_id2;
				gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp48_, "prop2", _data_->_tmp49_);
				_g_free0 (_data_->contact_id2);
			}
		} else {
			_data_->_tmp50_ = _data_->i;
			_data_->_tmp51_ = folks_individual_get_personas (_data_->_tmp50_);
			_data_->_tmp52_ = _data_->_tmp51_;
			_data_->_tmp53_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp52_);
			_data_->_tmp54_ = _data_->_tmp53_;
			if (_data_->_tmp54_ > 1) {
				_data_->_tmp55_ = _data_->self->priv->_linking_method;
				if (_data_->_tmp55_ == LINKING_METHOD_IM_ADDRESSES) {
					{
						_data_->_tmp56_ = _data_->i;
						_data_->_tmp57_ = folks_im_details_get_im_addresses ((FolksImDetails*) _data_->_tmp56_);
						_data_->_tmp58_ = _data_->_tmp57_;
						_data_->_tmp59_ = NULL;
						_data_->_tmp59_ = gee_multi_map_get_keys (_data_->_tmp58_);
						_data_->_tmp60_ = _data_->_tmp59_;
						_data_->_tmp61_ = NULL;
						_data_->_tmp61_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp60_);
						_data_->_tmp62_ = _data_->_tmp61_;
						_g_object_unref0 (_data_->_tmp60_);
						_data_->_proto_it = _data_->_tmp62_;
						while (TRUE) {
							_data_->_tmp63_ = _data_->_proto_it;
							_data_->_tmp64_ = FALSE;
							_data_->_tmp64_ = gee_iterator_next (_data_->_tmp63_);
							if (!_data_->_tmp64_) {
								break;
							}
							_data_->_tmp65_ = _data_->_proto_it;
							_data_->_tmp66_ = NULL;
							_data_->_tmp66_ = gee_iterator_get (_data_->_tmp65_);
							_data_->proto = (gchar*) _data_->_tmp66_;
							_data_->_tmp67_ = _data_->i;
							_data_->_tmp68_ = folks_im_details_get_im_addresses ((FolksImDetails*) _data_->_tmp67_);
							_data_->_tmp69_ = _data_->_tmp68_;
							_data_->_tmp70_ = _data_->proto;
							_data_->_tmp71_ = NULL;
							_data_->_tmp71_ = gee_multi_map_get (_data_->_tmp69_, _data_->_tmp70_);
							_data_->im_fds = _data_->_tmp71_;
							{
								_data_->_tmp72_ = _data_->im_fds;
								_data_->_tmp73_ = NULL;
								_data_->_tmp73_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp72_);
								_data_->_im_fd_it = _data_->_tmp73_;
								while (TRUE) {
									_data_->_tmp74_ = _data_->_im_fd_it;
									_data_->_tmp75_ = FALSE;
									_data_->_tmp75_ = gee_iterator_next (_data_->_tmp74_);
									if (!_data_->_tmp75_) {
										break;
									}
									_data_->_tmp76_ = _data_->_im_fd_it;
									_data_->_tmp77_ = NULL;
									_data_->_tmp77_ = gee_iterator_get (_data_->_tmp76_);
									_data_->im_fd = (FolksImFieldDetails*) _data_->_tmp77_;
									_data_->_tmp78_ = _data_->im_fd;
									_data_->_tmp79_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _data_->_tmp78_);
									_data_->_tmp80_ = _data_->_tmp79_;
									_data_->_tmp81_ = _data_->self->priv->_linking_props;
									_data_->_tmp82_ = NULL;
									_data_->_tmp82_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp81_, "prop1");
									_data_->_tmp83_ = (gchar*) _data_->_tmp82_;
									_data_->_tmp84_ = g_strcmp0 ((const gchar*) _data_->_tmp80_, _data_->_tmp83_) == 0;
									_g_free0 (_data_->_tmp83_);
									if (_data_->_tmp84_) {
										_data_->_tmp85_ = _data_->self->priv->_linking_props;
										gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp85_, "prop1", NULL);
									} else {
										_data_->_tmp86_ = _data_->im_fd;
										_data_->_tmp87_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _data_->_tmp86_);
										_data_->_tmp88_ = _data_->_tmp87_;
										_data_->_tmp89_ = _data_->self->priv->_linking_props;
										_data_->_tmp90_ = NULL;
										_data_->_tmp90_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp89_, "prop2");
										_data_->_tmp91_ = (gchar*) _data_->_tmp90_;
										_data_->_tmp92_ = g_strcmp0 ((const gchar*) _data_->_tmp88_, _data_->_tmp91_) == 0;
										_g_free0 (_data_->_tmp91_);
										if (_data_->_tmp92_) {
											_data_->_tmp93_ = _data_->self->priv->_linking_props;
											gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp93_, "prop2", NULL);
										}
									}
									_g_object_unref0 (_data_->im_fd);
								}
								_g_object_unref0 (_data_->_im_fd_it);
							}
							_g_object_unref0 (_data_->im_fds);
							_g_free0 (_data_->proto);
						}
						_g_object_unref0 (_data_->_proto_it);
					}
				} else {
					_data_->_tmp94_ = _data_->self->priv->_linking_method;
					if (_data_->_tmp94_ == LINKING_METHOD_LOCAL_IDS) {
						{
							_data_->_tmp95_ = _data_->i;
							_data_->_tmp96_ = folks_local_id_details_get_local_ids ((FolksLocalIdDetails*) _data_->_tmp95_);
							_data_->_tmp97_ = _data_->_tmp96_;
							_data_->_tmp98_ = NULL;
							_data_->_tmp98_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp97_);
							_data_->_local_id_it = _data_->_tmp98_;
							while (TRUE) {
								_data_->_tmp99_ = _data_->_local_id_it;
								_data_->_tmp100_ = FALSE;
								_data_->_tmp100_ = gee_iterator_next (_data_->_tmp99_);
								if (!_data_->_tmp100_) {
									break;
								}
								_data_->_tmp101_ = _data_->_local_id_it;
								_data_->_tmp102_ = NULL;
								_data_->_tmp102_ = gee_iterator_get (_data_->_tmp101_);
								_data_->local_id = (gchar*) _data_->_tmp102_;
								_data_->_tmp103_ = _data_->local_id;
								_data_->_tmp104_ = _data_->self->priv->_linking_props;
								_data_->_tmp105_ = NULL;
								_data_->_tmp105_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp104_, "prop1");
								_data_->_tmp106_ = (gchar*) _data_->_tmp105_;
								_data_->_tmp107_ = g_strcmp0 (_data_->_tmp103_, _data_->_tmp106_) == 0;
								_g_free0 (_data_->_tmp106_);
								if (_data_->_tmp107_) {
									_data_->_tmp108_ = _data_->self->priv->_linking_props;
									gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp108_, "prop1", NULL);
								} else {
									_data_->_tmp109_ = _data_->local_id;
									_data_->_tmp110_ = _data_->self->priv->_linking_props;
									_data_->_tmp111_ = NULL;
									_data_->_tmp111_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp110_, "prop2");
									_data_->_tmp112_ = (gchar*) _data_->_tmp111_;
									_data_->_tmp113_ = g_strcmp0 (_data_->_tmp109_, _data_->_tmp112_) == 0;
									_g_free0 (_data_->_tmp112_);
									if (_data_->_tmp113_) {
										_data_->_tmp114_ = _data_->self->priv->_linking_props;
										gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp114_, "prop2", NULL);
									}
								}
								_g_free0 (_data_->local_id);
							}
							_g_object_unref0 (_data_->_local_id_it);
						}
					} else {
						_data_->_tmp115_ = _data_->self->priv->_linking_method;
						if (_data_->_tmp115_ == LINKING_METHOD_WEB_SERVICE_ADDRESSES) {
							{
								_data_->_tmp116_ = _data_->i;
								_data_->_tmp117_ = folks_web_service_details_get_web_service_addresses ((FolksWebServiceDetails*) _data_->_tmp116_);
								_data_->_tmp118_ = _data_->_tmp117_;
								_data_->_tmp119_ = NULL;
								_data_->_tmp119_ = gee_multi_map_get_keys (_data_->_tmp118_);
								_data_->_tmp120_ = _data_->_tmp119_;
								_data_->_tmp121_ = NULL;
								_data_->_tmp121_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp120_);
								_data_->_tmp122_ = _data_->_tmp121_;
								_g_object_unref0 (_data_->_tmp120_);
								_data_->_service_it = _data_->_tmp122_;
								while (TRUE) {
									_data_->_tmp123_ = _data_->_service_it;
									_data_->_tmp124_ = FALSE;
									_data_->_tmp124_ = gee_iterator_next (_data_->_tmp123_);
									if (!_data_->_tmp124_) {
										break;
									}
									_data_->_tmp125_ = _data_->_service_it;
									_data_->_tmp126_ = NULL;
									_data_->_tmp126_ = gee_iterator_get (_data_->_tmp125_);
									_data_->service = (gchar*) _data_->_tmp126_;
									_data_->_tmp127_ = _data_->i;
									_data_->_tmp128_ = folks_web_service_details_get_web_service_addresses ((FolksWebServiceDetails*) _data_->_tmp127_);
									_data_->_tmp129_ = _data_->_tmp128_;
									_data_->_tmp130_ = _data_->service;
									_data_->_tmp131_ = NULL;
									_data_->_tmp131_ = gee_multi_map_get (_data_->_tmp129_, _data_->_tmp130_);
									_data_->ws_fds = _data_->_tmp131_;
									{
										_data_->_tmp132_ = _data_->ws_fds;
										_data_->_tmp133_ = NULL;
										_data_->_tmp133_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp132_);
										_data_->_ws_fd_it = _data_->_tmp133_;
										while (TRUE) {
											_data_->_tmp134_ = _data_->_ws_fd_it;
											_data_->_tmp135_ = FALSE;
											_data_->_tmp135_ = gee_iterator_next (_data_->_tmp134_);
											if (!_data_->_tmp135_) {
												break;
											}
											_data_->_tmp136_ = _data_->_ws_fd_it;
											_data_->_tmp137_ = NULL;
											_data_->_tmp137_ = gee_iterator_get (_data_->_tmp136_);
											_data_->ws_fd = (FolksWebServiceFieldDetails*) _data_->_tmp137_;
											_data_->_tmp138_ = _data_->ws_fd;
											_data_->_tmp139_ = _data_->self->priv->_linking_props;
											_data_->_tmp140_ = NULL;
											_data_->_tmp140_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp139_, "prop1");
											_data_->_tmp141_ = (gchar*) _data_->_tmp140_;
											_data_->_tmp142_ = folks_web_service_field_details_new (_data_->_tmp141_, NULL);
											_data_->_tmp143_ = _data_->_tmp142_;
											_data_->_tmp144_ = FALSE;
											_data_->_tmp144_ = folks_abstract_field_details_equal ((FolksAbstractFieldDetails*) _data_->_tmp138_, (FolksAbstractFieldDetails*) _data_->_tmp143_);
											_data_->_tmp145_ = _data_->_tmp144_;
											_g_object_unref0 (_data_->_tmp143_);
											_g_free0 (_data_->_tmp141_);
											if (_data_->_tmp145_) {
												_data_->_tmp146_ = _data_->self->priv->_linking_props;
												gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp146_, "prop1", NULL);
											} else {
												_data_->_tmp147_ = _data_->ws_fd;
												_data_->_tmp148_ = _data_->self->priv->_linking_props;
												_data_->_tmp149_ = NULL;
												_data_->_tmp149_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp148_, "prop2");
												_data_->_tmp150_ = (gchar*) _data_->_tmp149_;
												_data_->_tmp151_ = folks_web_service_field_details_new (_data_->_tmp150_, NULL);
												_data_->_tmp152_ = _data_->_tmp151_;
												_data_->_tmp153_ = FALSE;
												_data_->_tmp153_ = folks_abstract_field_details_equal ((FolksAbstractFieldDetails*) _data_->_tmp147_, (FolksAbstractFieldDetails*) _data_->_tmp152_);
												_data_->_tmp154_ = _data_->_tmp153_;
												_g_object_unref0 (_data_->_tmp152_);
												_g_free0 (_data_->_tmp150_);
												if (_data_->_tmp154_) {
													_data_->_tmp155_ = _data_->self->priv->_linking_props;
													gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp155_, "prop2", NULL);
												}
											}
											_g_object_unref0 (_data_->ws_fd);
										}
										_g_object_unref0 (_data_->_ws_fd_it);
									}
									_g_object_unref0 (_data_->ws_fds);
									_g_free0 (_data_->service);
								}
								_g_object_unref0 (_data_->_service_it);
							}
						}
					}
				}
				_data_->_tmp156_ = _data_->self->priv->_linking_props;
				_data_->_tmp157_ = gee_map_get_size ((GeeMap*) _data_->_tmp156_);
				_data_->_tmp158_ = _data_->_tmp157_;
				if (_data_->_tmp158_ == 0) {
					_data_->_tmp159_ = _data_->self->priv->_main_loop;
					g_main_loop_quit (_data_->_tmp159_);
				}
			}
		}
	}
	_data_->_tmp161_ = _data_->self->priv->_personas;
	_data_->_tmp162_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp161_);
	_data_->_tmp163_ = _data_->_tmp162_;
	if (_data_->_tmp163_ == 2) {
		_data_->_tmp164_ = _data_->self->priv->_linking_fired;
		_data_->_tmp160_ = _data_->_tmp164_ == FALSE;
	} else {
		_data_->_tmp160_ = FALSE;
	}
	_data_->_tmp165_ = _data_->_tmp160_;
	if (_data_->_tmp165_) {
		_data_->self->priv->_linking_fired = TRUE;
		{
			_data_->_tmp166_ = _data_->self->priv->_aggregator;
			_data_->_tmp167_ = _data_->self->priv->_personas;
			_data_->_state_ = 1;
			folks_individual_aggregator_link_personas (_data_->_tmp166_, (GeeSet*) _data_->_tmp167_, _link_personas_tests_check_personas_ready, _data_);
			return FALSE;
			_state_1:
			folks_individual_aggregator_link_personas_finish (_data_->_tmp166_, _data_->_res_, &_data_->_inner_error_);
			if (_data_->_inner_error_ != NULL) {
				goto __catch4_g_error;
			}
		}
		goto __finally4;
		__catch4_g_error:
		{
			_data_->e = _data_->_inner_error_;
			_data_->_inner_error_ = NULL;
			_data_->_tmp168_ = _data_->e;
			_data_->_tmp169_ = _data_->_tmp168_->message;
			g_warning ("link-personas.vala:408: link_personas: %s\n", _data_->_tmp169_);
			_g_error_free0 (_data_->e);
		}
		__finally4:
		if (_data_->_inner_error_ != NULL) {
			_g_object_unref0 (_data_->first_persona);
			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;
		}
	}
	_g_object_unref0 (_data_->first_persona);
	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 link_personas_tests_class_init (LinkPersonasTestsClass * klass) {
	link_personas_tests_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (LinkPersonasTestsPrivate));
	FOLKS_TEST_CASE_CLASS (klass)->set_up = link_personas_tests_real_set_up;
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = link_personas_tests_real_tear_down;
	G_OBJECT_CLASS (klass)->finalize = link_personas_tests_finalize;
}


static void link_personas_tests_instance_init (LinkPersonasTests * self) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	self->priv = LINK_PERSONAS_TESTS_GET_PRIVATE (self);
	_tmp0_ = g_strdup ("someone-1@jabber.example.org");
	self->priv->_im_address_1 = _tmp0_;
	_tmp1_ = g_strdup ("someone-2@jabber.example.org");
	self->priv->_im_address_2 = _tmp1_;
	_tmp2_ = g_strdup ("/system/folks/backends/primary_store");
	self->priv->_folks_config_key = _tmp2_;
}


static void link_personas_tests_finalize (GObject* obj) {
	LinkPersonasTests * self;
	self = LINK_PERSONAS_TESTS (obj);
	_g_main_loop_unref0 (self->priv->_main_loop);
	_eds_test_backend_unref0 (self->priv->_eds_backend);
	_g_object_unref0 (self->priv->_aggregator);
	_g_free0 (self->priv->_persona_fullname_1);
	_g_free0 (self->priv->_persona_fullname_2);
	_g_free0 (self->priv->_im_address_1);
	_g_free0 (self->priv->_im_address_2);
	_g_free0 (self->priv->_persona_iid_1);
	_g_free0 (self->priv->_persona_iid_2);
	_g_object_unref0 (self->priv->_personas);
	_g_free0 (self->priv->_folks_config_key);
	_g_object_unref0 (self->priv->_linking_props);
	G_OBJECT_CLASS (link_personas_tests_parent_class)->finalize (obj);
}


GType link_personas_tests_get_type (void) {
	static volatile gsize link_personas_tests_type_id__volatile = 0;
	if (g_once_init_enter (&link_personas_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (LinkPersonasTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) link_personas_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LinkPersonasTests), 0, (GInstanceInitFunc) link_personas_tests_instance_init, NULL };
		GType link_personas_tests_type_id;
		link_personas_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "LinkPersonasTests", &g_define_type_info, 0);
		g_once_init_leave (&link_personas_tests_type_id__volatile, link_personas_tests_type_id);
	}
	return link_personas_tests_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GTestSuite* _tmp0_ = NULL;
	GTestSuite* root;
	GTestSuite* _tmp1_;
	LinkPersonasTests* _tmp2_;
	LinkPersonasTests* _tmp3_;
	GTestSuite* _tmp4_ = NULL;
	g_test_init (&args_length1, &args, NULL);
	_tmp0_ = g_test_get_root ();
	root = _tmp0_;
	_tmp1_ = root;
	_tmp2_ = link_personas_tests_new ();
	_tmp3_ = _tmp2_;
	_tmp4_ = folks_test_case_get_suite ((FolksTestCase*) _tmp3_);
	g_test_suite_add_suite (_tmp1_, _tmp4_);
	_g_object_unref0 (_tmp3_);
	g_test_run ();
	result = 0;
	return result;
}


int main (int argc, char ** argv) {
	g_type_init ();
	return _vala_main (argv, argc);
}



