/* link-personas-via-local-ids.c generated by valac 0.13.1.106-1068, the Vala compiler
 * generated from link-personas-via-local-ids.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 <tracker-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>


#define TYPE_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS (link_personas_via_local_ids_tests_get_type ())
#define LINK_PERSONAS_VIA_LOCAL_IDS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS, LinkPersonasViaLocalIDsTests))
#define LINK_PERSONAS_VIA_LOCAL_IDS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS, LinkPersonasViaLocalIDsTestsClass))
#define IS_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS))
#define IS_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS))
#define LINK_PERSONAS_VIA_LOCAL_IDS_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS, LinkPersonasViaLocalIDsTestsClass))

typedef struct _LinkPersonasViaLocalIDsTests LinkPersonasViaLocalIDsTests;
typedef struct _LinkPersonasViaLocalIDsTestsClass LinkPersonasViaLocalIDsTestsClass;
typedef struct _LinkPersonasViaLocalIDsTestsPrivate LinkPersonasViaLocalIDsTestsPrivate;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _tracker_test_backend_unref0(var) ((var == NULL) ? NULL : (var = (tracker_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 _LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData;
#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 _LinkPersonasViaLocalIdsTestsAddPersonasData LinkPersonasViaLocalIdsTestsAddPersonasData;

struct _LinkPersonasViaLocalIDsTests {
	FolksTestCase parent_instance;
	LinkPersonasViaLocalIDsTestsPrivate * priv;
};

struct _LinkPersonasViaLocalIDsTestsClass {
	FolksTestCaseClass parent_class;
};

struct _LinkPersonasViaLocalIDsTestsPrivate {
	GMainLoop* _main_loop;
	TrackerTestBackend* _tracker_backend;
	FolksIndividualAggregator* _aggregator;
	gchar* _persona_fullname_1;
	gchar* _persona_fullname_2;
	gboolean _linking_fired;
	gboolean _persona_found_1;
	gboolean _persona_found_2;
	gchar* _persona_uid_1;
	gchar* _persona_uid_2;
	GeeHashSet* _personas;
	gint _removed_individuals;
	gchar* _folks_config_key;
	GConfClient* _gconf_client;
	GeeHashSet* _local_ids;
};

struct _LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	LinkPersonasViaLocalIDsTests* 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 _LinkPersonasViaLocalIdsTestsAddPersonasData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	LinkPersonasViaLocalIDsTests* self;
	FolksPersonaStore* pstore;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	GHashTable* details1;
	GValue _tmp3_;
	GValue _tmp4_;
	GValue _tmp5_;
	GValue* _tmp6_;
	GValue* _tmp7_;
	GValue* v1;
	GValue* _tmp8_;
	const gchar* _tmp9_;
	GHashTable* _tmp10_;
	gchar* _tmp11_;
	GValue* _tmp12_;
	GHashFunc _tmp13_;
	GEqualFunc _tmp14_;
	GHashTable* _tmp15_;
	GHashTable* details2;
	GValue _tmp16_;
	GValue _tmp17_;
	GValue _tmp18_;
	GValue* _tmp19_;
	GValue* _tmp20_;
	GValue* v2;
	GValue* _tmp21_;
	const gchar* _tmp22_;
	GHashTable* _tmp23_;
	gchar* _tmp24_;
	GValue* _tmp25_;
	FolksIndividualAggregator* _tmp26_;
	FolksPersonaStore* _tmp27_;
	GHashTable* _tmp28_;
	FolksPersona* _tmp29_;
	FolksPersona* _tmp30_;
	FolksIndividualAggregator* _tmp31_;
	FolksPersonaStore* _tmp32_;
	GHashTable* _tmp33_;
	FolksPersona* _tmp34_;
	FolksPersona* _tmp35_;
	GError* e;
	GError* _tmp36_;
	const gchar* _tmp37_;
	GError * _inner_error_;
};


static gpointer link_personas_via_local_ids_tests_parent_class = NULL;

GType link_personas_via_local_ids_tests_get_type (void) G_GNUC_CONST;
#define LINK_PERSONAS_VIA_LOCAL_IDS_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS, LinkPersonasViaLocalIDsTestsPrivate))
enum  {
	LINK_PERSONAS_VIA_LOCAL_IDS_TESTS_DUMMY_PROPERTY
};
LinkPersonasViaLocalIDsTests* link_personas_via_local_ids_tests_new (void);
LinkPersonasViaLocalIDsTests* link_personas_via_local_ids_tests_construct (GType object_type);
void link_personas_via_local_ids_tests_test_linking_personas_via_local_ids (LinkPersonasViaLocalIDsTests* self);
static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_folks_test_case_test_method (gpointer self);
static void link_personas_via_local_ids_tests_real_set_up (FolksTestCase* base);
static void link_personas_via_local_ids_tests_real_tear_down (FolksTestCase* base);
static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async (LinkPersonasViaLocalIDsTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_finish (LinkPersonasViaLocalIDsTests* self, GAsyncResult* _res_);
static gboolean _lambda1_ (LinkPersonasViaLocalIDsTests* self);
static gboolean __lambda1__gsource_func (gpointer self);
static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_data_free (gpointer _data);
static gboolean _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_co (LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData* _data_);
static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void _link_personas_via_local_ids_tests_individuals_changed_cb (LinkPersonasViaLocalIDsTests* self, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason);
static void __link_personas_via_local_ids_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_via_local_ids_tests_add_personas (LinkPersonasViaLocalIDsTests* self, FolksPersonaStore* pstore, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _link_personas_via_local_ids_tests_add_personas_finish (LinkPersonasViaLocalIDsTests* self, GAsyncResult* _res_);
static void _link_personas_via_local_ids_tests_add_personas_data_free (gpointer _data);
static gboolean _link_personas_via_local_ids_tests_add_personas_co (LinkPersonasViaLocalIdsTestsAddPersonasData* _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_via_local_ids_tests_add_personas_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void _link_personas_via_local_ids_tests_notify_cb (LinkPersonasViaLocalIDsTests* self, GObject* individual_obj, GParamSpec* ps);
static void __link_personas_via_local_ids_tests_notify_cb_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void _link_personas_via_local_ids_tests_check_personas (LinkPersonasViaLocalIDsTests* self, FolksIndividual* i);
static gboolean _lambda0_ (LinkPersonasViaLocalIDsTests* self);
static gboolean __lambda0__gsource_func (gpointer self);
static void link_personas_via_local_ids_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_folks_test_case_test_method (gpointer self) {
	link_personas_via_local_ids_tests_test_linking_personas_via_local_ids (self);
}


LinkPersonasViaLocalIDsTests* link_personas_via_local_ids_tests_construct (GType object_type) {
	LinkPersonasViaLocalIDsTests * self = NULL;
	TrackerTestBackend* _tmp0_;
	self = (LinkPersonasViaLocalIDsTests*) folks_test_case_construct (object_type, "LinkPersonasViaLocalIDsTests");
	_tmp0_ = tracker_test_backend_new ();
	_tracker_test_backend_unref0 (self->priv->_tracker_backend);
	self->priv->_tracker_backend = _tmp0_;
	folks_test_case_add_test ((FolksTestCase*) self, "test linking personas", _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_folks_test_case_test_method, self);
	return self;
}


LinkPersonasViaLocalIDsTests* link_personas_via_local_ids_tests_new (void) {
	return link_personas_via_local_ids_tests_construct (TYPE_LINK_PERSONAS_VIA_LOCAL_IDS_TESTS);
}


static void link_personas_via_local_ids_tests_real_set_up (FolksTestCase* base) {
	LinkPersonasViaLocalIDsTests * self;
	GConfClient* _tmp0_ = NULL;
	TrackerTestBackend* _tmp8_;
	GError * _inner_error_ = NULL;
	self = (LinkPersonasViaLocalIDsTests*) base;
	_tmp0_ = gconf_client_get_default ();
	self->priv->_gconf_client = _tmp0_;
	{
		GConfValue* _tmp1_;
		GConfValue* val;
		GConfValue* _tmp2_;
		GConfClient* _tmp3_;
		const gchar* _tmp4_;
		GConfValue* _tmp5_;
		_tmp1_ = gconf_value_new (GCONF_VALUE_STRING);
		val = _tmp1_;
		_tmp2_ = val;
		gconf_value_set_string (_tmp2_, "tracker");
		_tmp3_ = self->priv->_gconf_client;
		_tmp4_ = self->priv->_folks_config_key;
		_tmp5_ = val;
		gconf_client_set (_tmp3_, _tmp4_, _tmp5_, &_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* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_warning ("link-personas-via-local-ids.vala:68: Couldn't set primary store: %s\n", _tmp7_);
		_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;
	}
	_tmp8_ = self->priv->_tracker_backend;
	tracker_test_backend_set_up (_tmp8_);
}


static void link_personas_via_local_ids_tests_real_tear_down (FolksTestCase* base) {
	LinkPersonasViaLocalIDsTests * self;
	TrackerTestBackend* _tmp0_;
	GError * _inner_error_ = NULL;
	self = (LinkPersonasViaLocalIDsTests*) base;
	_tmp0_ = self->priv->_tracker_backend;
	tracker_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-via-local-ids.vala:90: 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;
	}
}


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


static gboolean __lambda1__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda1_ (self);
	return result;
}


void link_personas_via_local_ids_tests_test_linking_personas_via_local_ids (LinkPersonasViaLocalIDsTests* self) {
	GMainLoop* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GeeHashSet* _tmp3_;
	GeeHashSet* _tmp4_;
	GMainLoop* _tmp5_;
	GeeHashSet* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	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->_persona_found_1 = FALSE;
	self->priv->_persona_found_2 = FALSE;
	self->priv->_linking_fired = FALSE;
	_tmp4_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
	_g_object_unref0 (self->priv->_local_ids);
	self->priv->_local_ids = _tmp4_;
	_link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async (self, NULL, NULL);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 8, __lambda1__gsource_func, g_object_ref (self), g_object_unref);
	_tmp5_ = self->priv->_main_loop;
	g_main_loop_run (_tmp5_);
	_tmp6_ = self->priv->_local_ids;
	_tmp7_ = gee_collection_get_size ((GeeCollection*) _tmp6_);
	_tmp8_ = _tmp7_;
	g_assert (_tmp8_ == 0);
	_tmp9_ = self->priv->_removed_individuals;
	g_assert (_tmp9_ == 2);
}


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


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


static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async (LinkPersonasViaLocalIDsTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData* _data_;
	LinkPersonasViaLocalIDsTests* _tmp0_;
	_data_ = g_slice_new0 (LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_co (_data_);
}


static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_finish (LinkPersonasViaLocalIDsTests* self, GAsyncResult* _res_) {
	LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_co (_data_);
}


static void __link_personas_via_local_ids_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_via_local_ids_tests_individuals_changed_cb (self, added, removed, message, actor, reason);
}


static gboolean _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_co (LinkPersonasViaLocalIdsTestsTestLinkingPersonasViaLocalIdsAsyncData* _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_via_local_ids_tests_test_linking_personas_via_local_ids_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_via_local_ids_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_via_local_ids_tests_test_linking_personas_via_local_ids_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_, "tracker");
				_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_via_local_ids_tests_add_personas (_data_->self, _data_->_tmp23_, _link_personas_via_local_ids_tests_test_linking_personas_via_local_ids_async_ready, _data_);
		return FALSE;
		_state_3:
		_link_personas_via_local_ids_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-via-local-ids.vala:150: 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_via_local_ids_tests_add_personas_data_free (gpointer _data) {
	LinkPersonasViaLocalIdsTestsAddPersonasData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->pstore);
	_g_object_unref0 (_data_->self);
	g_slice_free (LinkPersonasViaLocalIdsTestsAddPersonasData, _data_);
}


static void _link_personas_via_local_ids_tests_add_personas (LinkPersonasViaLocalIDsTests* self, FolksPersonaStore* pstore, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	LinkPersonasViaLocalIdsTestsAddPersonasData* _data_;
	LinkPersonasViaLocalIDsTests* _tmp0_;
	FolksPersonaStore* _tmp1_;
	FolksPersonaStore* _tmp2_;
	_data_ = g_slice_new0 (LinkPersonasViaLocalIdsTestsAddPersonasData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _link_personas_via_local_ids_tests_add_personas);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _link_personas_via_local_ids_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_via_local_ids_tests_add_personas_co (_data_);
}


static void _link_personas_via_local_ids_tests_add_personas_finish (LinkPersonasViaLocalIDsTests* self, GAsyncResult* _res_) {
	LinkPersonasViaLocalIdsTestsAddPersonasData* _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_via_local_ids_tests_add_personas_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	LinkPersonasViaLocalIdsTestsAddPersonasData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_link_personas_via_local_ids_tests_add_personas_co (_data_);
}


static gboolean _link_personas_via_local_ids_tests_add_personas_co (LinkPersonasViaLocalIdsTestsAddPersonasData* _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_;
	memset (&_data_->_tmp3_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp3_, G_TYPE_STRING);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = __g_value_dup0 (&_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	G_IS_VALUE (&_data_->_tmp5_) ? (g_value_unset (&_data_->_tmp5_), NULL) : NULL;
	_data_->v1 = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->v1;
	_data_->_tmp9_ = _data_->self->priv->_persona_fullname_1;
	g_value_set_string (_data_->_tmp8_, _data_->_tmp9_);
	_data_->_tmp10_ = _data_->details1;
	_data_->_tmp11_ = g_strdup ("full-name");
	_data_->_tmp12_ = _data_->v1;
	_data_->v1 = NULL;
	g_hash_table_insert (_data_->_tmp10_, _data_->_tmp11_, _data_->_tmp12_);
	_data_->_tmp13_ = g_str_hash;
	_data_->_tmp14_ = g_str_equal;
	_data_->_tmp15_ = g_hash_table_new_full (_data_->_tmp13_, _data_->_tmp14_, _g_free0_, __vala_GValue_free0_);
	_data_->details2 = _data_->_tmp15_;
	memset (&_data_->_tmp16_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp16_, G_TYPE_STRING);
	_data_->_tmp17_ = _data_->_tmp16_;
	_data_->_tmp18_ = _data_->_tmp17_;
	_data_->_tmp19_ = __g_value_dup0 (&_data_->_tmp18_);
	_data_->_tmp20_ = _data_->_tmp19_;
	G_IS_VALUE (&_data_->_tmp18_) ? (g_value_unset (&_data_->_tmp18_), NULL) : NULL;
	_data_->v2 = _data_->_tmp20_;
	_data_->_tmp21_ = _data_->v2;
	_data_->_tmp22_ = _data_->self->priv->_persona_fullname_2;
	g_value_set_string (_data_->_tmp21_, _data_->_tmp22_);
	_data_->_tmp23_ = _data_->details2;
	_data_->_tmp24_ = g_strdup ("full-name");
	_data_->_tmp25_ = _data_->v2;
	_data_->v2 = NULL;
	g_hash_table_insert (_data_->_tmp23_, _data_->_tmp24_, _data_->_tmp25_);
	{
		_data_->_tmp26_ = _data_->self->priv->_aggregator;
		_data_->_tmp27_ = _data_->pstore;
		_data_->_tmp28_ = _data_->details1;
		_data_->_state_ = 1;
		folks_individual_aggregator_add_persona_from_details (_data_->_tmp26_, NULL, _data_->_tmp27_, _data_->_tmp28_, _link_personas_via_local_ids_tests_add_personas_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp29_ = NULL;
		_data_->_tmp29_ = folks_individual_aggregator_add_persona_from_details_finish (_data_->_tmp26_, _data_->_res_, &_data_->_inner_error_);
		_data_->_tmp30_ = _data_->_tmp29_;
		_g_object_unref0 (_data_->_tmp30_);
		if (_data_->_inner_error_ != NULL) {
			if (_data_->_inner_error_->domain == FOLKS_INDIVIDUAL_AGGREGATOR_ERROR) {
				goto __catch3_folks_individual_aggregator_error;
			}
			__vala_GValue_free0 (_data_->v2);
			_g_hash_table_unref0 (_data_->details2);
			__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_->_tmp31_ = _data_->self->priv->_aggregator;
		_data_->_tmp32_ = _data_->pstore;
		_data_->_tmp33_ = _data_->details2;
		_data_->_state_ = 2;
		folks_individual_aggregator_add_persona_from_details (_data_->_tmp31_, NULL, _data_->_tmp32_, _data_->_tmp33_, _link_personas_via_local_ids_tests_add_personas_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp34_ = NULL;
		_data_->_tmp34_ = folks_individual_aggregator_add_persona_from_details_finish (_data_->_tmp31_, _data_->_res_, &_data_->_inner_error_);
		_data_->_tmp35_ = _data_->_tmp34_;
		_g_object_unref0 (_data_->_tmp35_);
		if (_data_->_inner_error_ != NULL) {
			if (_data_->_inner_error_->domain == FOLKS_INDIVIDUAL_AGGREGATOR_ERROR) {
				goto __catch3_folks_individual_aggregator_error;
			}
			__vala_GValue_free0 (_data_->v2);
			_g_hash_table_unref0 (_data_->details2);
			__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_->_tmp36_ = _data_->e;
		_data_->_tmp37_ = _data_->_tmp36_->message;
		g_warning ("link-personas-via-local-ids.vala:186: [AddPersonaError] add_persona_fr" \
"om_details: %s\n", _data_->_tmp37_);
		_g_error_free0 (_data_->e);
	}
	__finally3:
	if (_data_->_inner_error_ != NULL) {
		__vala_GValue_free0 (_data_->v2);
		_g_hash_table_unref0 (_data_->details2);
		__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_->v2);
	_g_hash_table_unref0 (_data_->details2);
	__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_via_local_ids_tests_notify_cb_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	_link_personas_via_local_ids_tests_notify_cb (self, _sender, pspec);
}


static void _link_personas_via_local_ids_tests_individuals_changed_cb (LinkPersonasViaLocalIDsTests* self, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason) {
	GeeSet* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	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_;
			gboolean _tmp7_;
			gboolean _tmp8_;
			_tmp2_ = _i_it;
			_tmp3_ = gee_iterator_next (_tmp2_);
			if (!_tmp3_) {
				break;
			}
			_tmp4_ = _i_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			i = (FolksIndividual*) _tmp5_;
			_tmp6_ = i;
			_tmp7_ = folks_individual_get_is_user (_tmp6_);
			_tmp8_ = _tmp7_;
			if (!_tmp8_) {
				FolksIndividual* _tmp9_;
				FolksIndividual* _tmp10_;
				FolksIndividual* _tmp11_;
				_tmp9_ = i;
				g_signal_connect_object ((GObject*) _tmp9_, "notify::full-name", (GCallback) __link_personas_via_local_ids_tests_notify_cb_g_object_notify, self, 0);
				_tmp10_ = i;
				g_signal_connect_object ((GObject*) _tmp10_, "notify::local-ids", (GCallback) __link_personas_via_local_ids_tests_notify_cb_g_object_notify, self, 0);
				_tmp11_ = i;
				_link_personas_via_local_ids_tests_check_personas (self, _tmp11_);
			}
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp12_ = removed;
	_tmp13_ = gee_collection_get_size ((GeeCollection*) _tmp12_);
	_tmp14_ = _tmp13_;
	if (_tmp14_ > 0) {
		gint _tmp15_;
		GeeSet* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		_tmp15_ = self->priv->_removed_individuals;
		_tmp16_ = removed;
		_tmp17_ = gee_collection_get_size ((GeeCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		self->priv->_removed_individuals = _tmp15_ + ((gint) _tmp18_);
	}
}


static void _link_personas_via_local_ids_tests_notify_cb (LinkPersonasViaLocalIDsTests* self, GObject* individual_obj, GParamSpec* ps) {
	GObject* _tmp0_;
	FolksIndividual* _tmp1_;
	FolksIndividual* i;
	FolksIndividual* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (individual_obj != NULL);
	g_return_if_fail (ps != NULL);
	_tmp0_ = individual_obj;
	_tmp1_ = _g_object_ref0 (FOLKS_INDIVIDUAL (_tmp0_));
	i = _tmp1_;
	_tmp2_ = i;
	_link_personas_via_local_ids_tests_check_personas (self, _tmp2_);
	_g_object_unref0 (i);
}


static gboolean _lambda0_ (LinkPersonasViaLocalIDsTests* self) {
	gboolean result = FALSE;
	FolksIndividualAggregator* _tmp0_;
	GeeHashSet* _tmp1_;
	_tmp0_ = self->priv->_aggregator;
	_tmp1_ = self->priv->_personas;
	folks_individual_aggregator_link_personas (_tmp0_, (GeeSet*) _tmp1_, NULL, NULL);
	result = FALSE;
	return result;
}


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


static void _link_personas_via_local_ids_tests_check_personas (LinkPersonasViaLocalIDsTests* self, FolksIndividual* i) {
	FolksPersona* first_persona;
	gboolean _tmp10_ = FALSE;
	FolksIndividual* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gboolean _tmp16_;
	gboolean _tmp62_ = FALSE;
	GeeHashSet* _tmp63_;
	gint _tmp64_;
	gint _tmp65_;
	gboolean _tmp67_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (i != NULL);
	first_persona = NULL;
	{
		FolksIndividual* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeIterator* _tmp3_ = NULL;
		GeeIterator* _p_it;
		_tmp0_ = i;
		_tmp1_ = folks_individual_get_personas (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = gee_iterable_iterator ((GeeIterable*) _tmp2_);
		_p_it = _tmp3_;
		while (TRUE) {
			GeeIterator* _tmp4_;
			gboolean _tmp5_ = FALSE;
			GeeIterator* _tmp6_;
			gpointer _tmp7_ = NULL;
			FolksPersona* p;
			FolksPersona* _tmp8_;
			FolksPersona* _tmp9_;
			_tmp4_ = _p_it;
			_tmp5_ = gee_iterator_next (_tmp4_);
			if (!_tmp5_) {
				break;
			}
			_tmp6_ = _p_it;
			_tmp7_ = gee_iterator_get (_tmp6_);
			p = (FolksPersona*) _tmp7_;
			_tmp8_ = p;
			_tmp9_ = _g_object_ref0 (_tmp8_);
			_g_object_unref0 (first_persona);
			first_persona = _tmp9_;
			_g_object_unref0 (p);
			break;
		}
		_g_object_unref0 (_p_it);
	}
	_tmp11_ = i;
	_tmp12_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = self->priv->_persona_fullname_1;
	if (g_strcmp0 (_tmp13_, _tmp14_) == 0) {
		const gchar* _tmp15_;
		_tmp15_ = self->priv->_persona_uid_1;
		_tmp10_ = g_strcmp0 (_tmp15_, "") == 0;
	} else {
		_tmp10_ = FALSE;
	}
	_tmp16_ = _tmp10_;
	if (_tmp16_) {
		FolksPersona* _tmp17_;
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		GeeHashSet* _tmp21_;
		FolksPersona* _tmp22_;
		GeeHashSet* _tmp23_;
		const gchar* _tmp24_;
		_tmp17_ = first_persona;
		_tmp18_ = folks_persona_get_uid (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp20_ = g_strdup (_tmp19_);
		_g_free0 (self->priv->_persona_uid_1);
		self->priv->_persona_uid_1 = _tmp20_;
		_tmp21_ = self->priv->_personas;
		_tmp22_ = first_persona;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp21_, _tmp22_);
		_tmp23_ = self->priv->_local_ids;
		_tmp24_ = self->priv->_persona_uid_1;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp23_, _tmp24_);
	} else {
		gboolean _tmp25_ = FALSE;
		FolksIndividual* _tmp26_;
		const gchar* _tmp27_;
		const gchar* _tmp28_;
		const gchar* _tmp29_;
		gboolean _tmp31_;
		_tmp26_ = i;
		_tmp27_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = self->priv->_persona_fullname_2;
		if (g_strcmp0 (_tmp28_, _tmp29_) == 0) {
			const gchar* _tmp30_;
			_tmp30_ = self->priv->_persona_uid_2;
			_tmp25_ = g_strcmp0 (_tmp30_, "") == 0;
		} else {
			_tmp25_ = FALSE;
		}
		_tmp31_ = _tmp25_;
		if (_tmp31_) {
			FolksPersona* _tmp32_;
			const gchar* _tmp33_;
			const gchar* _tmp34_;
			gchar* _tmp35_;
			GeeHashSet* _tmp36_;
			FolksPersona* _tmp37_;
			GeeHashSet* _tmp38_;
			const gchar* _tmp39_;
			_tmp32_ = first_persona;
			_tmp33_ = folks_persona_get_uid (_tmp32_);
			_tmp34_ = _tmp33_;
			_tmp35_ = g_strdup (_tmp34_);
			_g_free0 (self->priv->_persona_uid_2);
			self->priv->_persona_uid_2 = _tmp35_;
			_tmp36_ = self->priv->_personas;
			_tmp37_ = first_persona;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp36_, _tmp37_);
			_tmp38_ = self->priv->_local_ids;
			_tmp39_ = self->priv->_persona_uid_2;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp38_, _tmp39_);
		} else {
			FolksIndividual* _tmp40_;
			GeeSet* _tmp41_;
			GeeSet* _tmp42_;
			gint _tmp43_;
			gint _tmp44_;
			_tmp40_ = i;
			_tmp41_ = folks_individual_get_personas (_tmp40_);
			_tmp42_ = _tmp41_;
			_tmp43_ = gee_collection_get_size ((GeeCollection*) _tmp42_);
			_tmp44_ = _tmp43_;
			if (_tmp44_ > 1) {
				GeeHashSet* _tmp58_;
				gint _tmp59_;
				gint _tmp60_;
				{
					FolksIndividual* _tmp45_;
					GeeSet* _tmp46_;
					GeeSet* _tmp47_;
					GeeIterator* _tmp48_ = NULL;
					GeeIterator* _id_it;
					_tmp45_ = i;
					_tmp46_ = folks_local_id_details_get_local_ids ((FolksLocalIdDetails*) _tmp45_);
					_tmp47_ = _tmp46_;
					_tmp48_ = gee_iterable_iterator ((GeeIterable*) _tmp47_);
					_id_it = _tmp48_;
					while (TRUE) {
						GeeIterator* _tmp49_;
						gboolean _tmp50_ = FALSE;
						GeeIterator* _tmp51_;
						gpointer _tmp52_ = NULL;
						gchar* id;
						GeeHashSet* _tmp53_;
						const gchar* _tmp54_;
						gboolean _tmp55_ = FALSE;
						_tmp49_ = _id_it;
						_tmp50_ = gee_iterator_next (_tmp49_);
						if (!_tmp50_) {
							break;
						}
						_tmp51_ = _id_it;
						_tmp52_ = gee_iterator_get (_tmp51_);
						id = (gchar*) _tmp52_;
						_tmp53_ = self->priv->_local_ids;
						_tmp54_ = id;
						_tmp55_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp53_, _tmp54_);
						if (_tmp55_) {
							GeeHashSet* _tmp56_;
							const gchar* _tmp57_;
							_tmp56_ = self->priv->_local_ids;
							_tmp57_ = id;
							gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp56_, _tmp57_);
						}
						_g_free0 (id);
					}
					_g_object_unref0 (_id_it);
				}
				_tmp58_ = self->priv->_local_ids;
				_tmp59_ = gee_collection_get_size ((GeeCollection*) _tmp58_);
				_tmp60_ = _tmp59_;
				if (_tmp60_ == 0) {
					GMainLoop* _tmp61_;
					_tmp61_ = self->priv->_main_loop;
					g_main_loop_quit (_tmp61_);
				}
			}
		}
	}
	_tmp63_ = self->priv->_personas;
	_tmp64_ = gee_collection_get_size ((GeeCollection*) _tmp63_);
	_tmp65_ = _tmp64_;
	if (_tmp65_ == 2) {
		gboolean _tmp66_;
		_tmp66_ = self->priv->_linking_fired;
		_tmp62_ = _tmp66_ == FALSE;
	} else {
		_tmp62_ = FALSE;
	}
	_tmp67_ = _tmp62_;
	if (_tmp67_) {
		self->priv->_linking_fired = TRUE;
		g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 2, __lambda0__gsource_func, g_object_ref (self), g_object_unref);
	}
	_g_object_unref0 (first_persona);
}


static void link_personas_via_local_ids_tests_class_init (LinkPersonasViaLocalIDsTestsClass * klass) {
	link_personas_via_local_ids_tests_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (LinkPersonasViaLocalIDsTestsPrivate));
	FOLKS_TEST_CASE_CLASS (klass)->set_up = link_personas_via_local_ids_tests_real_set_up;
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = link_personas_via_local_ids_tests_real_tear_down;
	G_OBJECT_CLASS (klass)->finalize = link_personas_via_local_ids_tests_finalize;
}


static void link_personas_via_local_ids_tests_instance_init (LinkPersonasViaLocalIDsTests * self) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	self->priv = LINK_PERSONAS_VIA_LOCAL_IDS_TESTS_GET_PRIVATE (self);
	_tmp0_ = g_strdup ("");
	self->priv->_persona_uid_1 = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_persona_uid_2 = _tmp1_;
	self->priv->_removed_individuals = 0;
	_tmp2_ = g_strdup ("/system/folks/backends/primary_store");
	self->priv->_folks_config_key = _tmp2_;
}


static void link_personas_via_local_ids_tests_finalize (GObject* obj) {
	LinkPersonasViaLocalIDsTests * self;
	self = LINK_PERSONAS_VIA_LOCAL_IDS_TESTS (obj);
	_g_main_loop_unref0 (self->priv->_main_loop);
	_tracker_test_backend_unref0 (self->priv->_tracker_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->_persona_uid_1);
	_g_free0 (self->priv->_persona_uid_2);
	_g_object_unref0 (self->priv->_personas);
	_g_free0 (self->priv->_folks_config_key);
	_g_object_unref0 (self->priv->_local_ids);
	G_OBJECT_CLASS (link_personas_via_local_ids_tests_parent_class)->finalize (obj);
}


GType link_personas_via_local_ids_tests_get_type (void) {
	static volatile gsize link_personas_via_local_ids_tests_type_id__volatile = 0;
	if (g_once_init_enter (&link_personas_via_local_ids_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (LinkPersonasViaLocalIDsTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) link_personas_via_local_ids_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LinkPersonasViaLocalIDsTests), 0, (GInstanceInitFunc) link_personas_via_local_ids_tests_instance_init, NULL };
		GType link_personas_via_local_ids_tests_type_id;
		link_personas_via_local_ids_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "LinkPersonasViaLocalIDsTests", &g_define_type_info, 0);
		g_once_init_leave (&link_personas_via_local_ids_tests_type_id__volatile, link_personas_via_local_ids_tests_type_id);
	}
	return link_personas_via_local_ids_tests_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GTestSuite* _tmp0_ = NULL;
	GTestSuite* root;
	GTestSuite* _tmp1_;
	LinkPersonasViaLocalIDsTests* _tmp2_;
	LinkPersonasViaLocalIDsTests* _tmp3_;
	GTestSuite* _tmp4_ = NULL;
	g_test_init (&args_length1, &args, NULL);
	_tmp0_ = g_test_get_root ();
	root = _tmp0_;
	_tmp1_ = root;
	_tmp2_ = link_personas_via_local_ids_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);
}



