/* individual-retrieval.c generated by valac 0.13.1.106-1068, the Vala compiler
 * generated from individual-retrieval.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: Travis Reitter <travis.reitter@collabora.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <folks-test.h>
#include <tp-test-contactlist.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <folks/folks.h>
#include <gio/gio.h>
#include <folks/folks-telepathy.h>


#define TYPE_INDIVIDUAL_RETRIEVAL_TESTS (individual_retrieval_tests_get_type ())
#define INDIVIDUAL_RETRIEVAL_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_INDIVIDUAL_RETRIEVAL_TESTS, IndividualRetrievalTests))
#define INDIVIDUAL_RETRIEVAL_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_INDIVIDUAL_RETRIEVAL_TESTS, IndividualRetrievalTestsClass))
#define IS_INDIVIDUAL_RETRIEVAL_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_INDIVIDUAL_RETRIEVAL_TESTS))
#define IS_INDIVIDUAL_RETRIEVAL_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_INDIVIDUAL_RETRIEVAL_TESTS))
#define INDIVIDUAL_RETRIEVAL_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_INDIVIDUAL_RETRIEVAL_TESTS, IndividualRetrievalTestsClass))

typedef struct _IndividualRetrievalTests IndividualRetrievalTests;
typedef struct _IndividualRetrievalTestsClass IndividualRetrievalTestsClass;
typedef struct _IndividualRetrievalTestsPrivate IndividualRetrievalTestsPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block2Data Block2Data;
typedef struct _Block3Data Block3Data;
typedef struct _Block4Data Block4Data;
typedef struct _Block5Data Block5Data;
typedef struct _Block6Data Block6Data;
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
typedef struct _IndividualRetrievalTestsAddPersonasData IndividualRetrievalTestsAddPersonasData;

struct _IndividualRetrievalTests {
	FolksTestCase parent_instance;
	IndividualRetrievalTestsPrivate * priv;
};

struct _IndividualRetrievalTestsClass {
	FolksTestCaseClass parent_class;
};

struct _IndividualRetrievalTestsPrivate {
	TpTestBackend* tp_backend;
	void* _account_handle;
	GeeHashSet* default_individuals;
	gint _test_timeout;
};

struct _Block1Data {
	int _ref_count_;
	IndividualRetrievalTests * self;
	GMainLoop* main_loop;
	GeeHashSet* expected_individuals;
	FolksIndividualAggregator* aggregator;
};

struct _Block2Data {
	int _ref_count_;
	IndividualRetrievalTests * self;
	GMainLoop* main_loop;
	GeeHashSet* added_individuals;
	FolksIndividualAggregator* aggregator;
};

struct _Block3Data {
	int _ref_count_;
	Block2Data * _data2_;
	gboolean adding_done;
};

struct _Block4Data {
	int _ref_count_;
	IndividualRetrievalTests * self;
	TpfPersonaStore* store;
	gpointer _async_data_;
};

struct _Block5Data {
	int _ref_count_;
	Block4Data * _data4_;
	GeeHashSet* ids_remaining;
};

struct _Block6Data {
	int _ref_count_;
	Block5Data * _data5_;
	GHashTable* details;
};

struct _IndividualRetrievalTestsAddPersonasData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	IndividualRetrievalTests* self;
	TpfPersonaStore* store;
	GeeHashSet* ids_add;
	Block4Data* _data4_;
	TpfPersonaStore* _tmp0_;
	TpfPersonaStore* _tmp1_;
	Block5Data* _data5_;
	TpfPersonaStore* _tmp2_;
	GHashFunc _tmp3_;
	GEqualFunc _tmp4_;
	GeeHashSet* _tmp5_;
	GeeHashSet* _tmp6_;
	GeeIterator* _tmp7_;
	GeeIterator* _contact_id_it;
	GeeIterator* _tmp8_;
	gboolean _tmp9_;
	GeeIterator* _tmp10_;
	gpointer _tmp11_;
	gchar* contact_id;
	GeeHashSet* _tmp12_;
	const gchar* _tmp13_;
	GError* e2;
	TpfPersonaStore* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	GError* _tmp17_;
	const gchar* _tmp18_;
	GError * _inner_error_;
};


static gpointer individual_retrieval_tests_parent_class = NULL;

GType individual_retrieval_tests_get_type (void) G_GNUC_CONST;
#define INDIVIDUAL_RETRIEVAL_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_INDIVIDUAL_RETRIEVAL_TESTS, IndividualRetrievalTestsPrivate))
enum  {
	INDIVIDUAL_RETRIEVAL_TESTS_DUMMY_PROPERTY
};
IndividualRetrievalTests* individual_retrieval_tests_new (void);
IndividualRetrievalTests* individual_retrieval_tests_construct (GType object_type);
void individual_retrieval_tests_test_aggregator (IndividualRetrievalTests* self);
static void _individual_retrieval_tests_test_aggregator_folks_test_case_test_method (gpointer self);
void individual_retrieval_tests_test_aggregator_add (IndividualRetrievalTests* self);
static void _individual_retrieval_tests_test_aggregator_add_folks_test_case_test_method (gpointer self);
static void individual_retrieval_tests_real_set_up (FolksTestCase* base);
static void individual_retrieval_tests_real_tear_down (FolksTestCase* base);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (Block1Data* _data1_);
static void _lambda0_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, Block1Data* _data1_);
static void __lambda0__folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self);
static gboolean _lambda1_ (Block1Data* _data1_);
static gboolean __lambda1__gsource_func (gpointer self);
static gboolean _lambda2_ (Block1Data* _data1_);
static void _lambda3_ (GObject* s, GAsyncResult* r, Block1Data* _data1_);
static void __lambda3__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static gboolean __lambda2__gsource_func (gpointer self);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (Block2Data* _data2_);
static void _lambda4_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, Block2Data* _data2_);
static void __lambda4__folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self);
static gboolean _lambda5_ (Block2Data* _data2_);
static gboolean __lambda5__gsource_func (gpointer self);
static gboolean _lambda6_ (Block2Data* _data2_);
static void _lambda7_ (GObject* s, GAsyncResult* r, Block2Data* _data2_);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (Block3Data* _data3_);
static void _lambda8_ (FolksPersonaStore* store, Block3Data* _data3_);
static void individual_retrieval_tests_add_personas (IndividualRetrievalTests* self, TpfPersonaStore* store, GeeHashSet* ids_add, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void individual_retrieval_tests_add_personas_finish (IndividualRetrievalTests* self, GAsyncResult* _res_);
static void __lambda8__folks_backend_persona_store_added (FolksBackend* _sender, FolksPersonaStore* store, gpointer self);
static void __lambda7__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static gboolean __lambda6__gsource_func (gpointer self);
static void individual_retrieval_tests_add_personas_data_free (gpointer _data);
static gboolean individual_retrieval_tests_add_personas_co (IndividualRetrievalTestsAddPersonasData* _data_);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (Block4Data* _data4_);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (Block5Data* _data5_);
static void individual_retrieval_tests_add_personas_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static gboolean _lambda9_ (Block5Data* _data5_);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (Block6Data* _data6_);
static void _g_free0_ (gpointer var);
static void _vala_GValue_free (GValue* self);
static void __vala_GValue_free0_ (gpointer var);
static void _lambda10_ (GObject* s2, GAsyncResult* res, Block6Data* _data6_);
static GValue* _g_value_dup (GValue* self);
static void __lambda10__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static gboolean __lambda9__gsource_func (gpointer self);
static void individual_retrieval_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


static void _individual_retrieval_tests_test_aggregator_folks_test_case_test_method (gpointer self) {
	individual_retrieval_tests_test_aggregator (self);
}


static void _individual_retrieval_tests_test_aggregator_add_folks_test_case_test_method (gpointer self) {
	individual_retrieval_tests_test_aggregator_add (self);
}


IndividualRetrievalTests* individual_retrieval_tests_construct (GType object_type) {
	IndividualRetrievalTests * self = NULL;
	TpTestBackend* _tmp0_;
	GHashFunc _tmp1_;
	GEqualFunc _tmp2_;
	GeeHashSet* _tmp3_;
	GeeHashSet* _tmp4_;
	GeeHashSet* _tmp5_;
	GeeHashSet* _tmp6_;
	GeeHashSet* _tmp7_;
	GeeHashSet* _tmp8_;
	GeeHashSet* _tmp9_;
	GeeHashSet* _tmp10_;
	GeeHashSet* _tmp11_;
	GeeHashSet* _tmp12_;
	const gchar* _tmp13_ = NULL;
	self = (IndividualRetrievalTests*) folks_test_case_construct (object_type, "IndividualRetrieval");
	_tmp0_ = tp_test_backend_new ();
	_g_object_unref0 (self->priv->tp_backend);
	self->priv->tp_backend = _tmp0_;
	_tmp1_ = g_str_hash;
	_tmp2_ = g_str_equal;
	_tmp3_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _tmp1_, _tmp2_);
	_g_object_unref0 (self->priv->default_individuals);
	self->priv->default_individuals = _tmp3_;
	_tmp4_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp4_, "48fa372a81026063187255e3f5c184665d2ed7ce");
	_tmp5_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp5_, "60c91326018f6a60604f8d260fc24a60a5b8512c");
	_tmp6_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp6_, "6380b17dc511b21a1defd4811f1add97b278f92c");
	_tmp7_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp7_, "0e46c5e74f61908f49550d241f2a1651892a1695");
	_tmp8_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, "6b08188cb2ef8cbaca140b277780069b5af8add6");
	_tmp9_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, "f948d4d2af79085ab860f0ef67bf0c201c4602d4");
	_tmp10_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, "f34529a442577b840a75271b464e90666c38c464");
	_tmp11_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, "467d13f955e62bf30ebf9620fa052aaee2160260");
	_tmp12_ = self->priv->default_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, "07b913b8977c04d2f2011e26a46ea3e3dcfe3e3d");
	folks_test_case_add_test ((FolksTestCase*) self, "aggregator", _individual_retrieval_tests_test_aggregator_folks_test_case_test_method, self);
	folks_test_case_add_test ((FolksTestCase*) self, "aggregator:add", _individual_retrieval_tests_test_aggregator_add_folks_test_case_test_method, self);
	_tmp13_ = g_getenv ("FOLKS_TEST_VALGRIND");
	if (_tmp13_ != NULL) {
		self->priv->_test_timeout = 10;
	}
	return self;
}


IndividualRetrievalTests* individual_retrieval_tests_new (void) {
	return individual_retrieval_tests_construct (TYPE_INDIVIDUAL_RETRIEVAL_TESTS);
}


static void individual_retrieval_tests_real_set_up (FolksTestCase* base) {
	IndividualRetrievalTests * self;
	TpTestBackend* _tmp0_;
	TpTestBackend* _tmp1_;
	void* _tmp2_ = NULL;
	self = (IndividualRetrievalTests*) base;
	_tmp0_ = self->priv->tp_backend;
	tp_test_backend_set_up (_tmp0_);
	_tmp1_ = self->priv->tp_backend;
	_tmp2_ = tp_test_backend_add_account (_tmp1_, "protocol", "me@example.com", "cm", "account");
	self->priv->_account_handle = _tmp2_;
}


static void individual_retrieval_tests_real_tear_down (FolksTestCase* base) {
	IndividualRetrievalTests * self;
	TpTestBackend* _tmp0_;
	void* _tmp1_;
	TpTestBackend* _tmp2_;
	self = (IndividualRetrievalTests*) base;
	_tmp0_ = self->priv->tp_backend;
	_tmp1_ = self->priv->_account_handle;
	tp_test_backend_remove_account (_tmp0_, _tmp1_);
	_tmp2_ = self->priv->tp_backend;
	tp_test_backend_tear_down (_tmp2_);
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (Block1Data* _data1_) {
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		_g_object_unref0 (_data1_->self);
		_g_object_unref0 (_data1_->aggregator);
		_g_object_unref0 (_data1_->expected_individuals);
		_g_main_loop_unref0 (_data1_->main_loop);
		g_slice_free (Block1Data, _data1_);
	}
}


static void _lambda0_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, Block1Data* _data1_) {
	IndividualRetrievalTests * self;
	GeeSet* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	self = _data1_->self;
	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;
			GeeHashSet* _tmp6_;
			FolksIndividual* _tmp7_;
			const gchar* _tmp8_;
			const gchar* _tmp9_;
			_tmp2_ = _i_it;
			_tmp3_ = gee_iterator_next (_tmp2_);
			if (!_tmp3_) {
				break;
			}
			_tmp4_ = _i_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			i = (FolksIndividual*) _tmp5_;
			_tmp6_ = _data1_->expected_individuals;
			_tmp7_ = i;
			_tmp8_ = folks_individual_get_id (_tmp7_);
			_tmp9_ = _tmp8_;
			gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp6_, _tmp9_);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp10_ = removed;
	_tmp11_ = gee_collection_get_size ((GeeCollection*) _tmp10_);
	_tmp12_ = _tmp11_;
	g_assert (_tmp12_ == 0);
}


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


static gboolean _lambda1_ (Block1Data* _data1_) {
	IndividualRetrievalTests * self;
	gboolean result = FALSE;
	GMainLoop* _tmp0_;
	self = _data1_->self;
	_tmp0_ = _data1_->main_loop;
	g_main_loop_quit (_tmp0_);
	result = FALSE;
	return result;
}


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


static void _lambda3_ (GObject* s, GAsyncResult* r, Block1Data* _data1_) {
	IndividualRetrievalTests * self;
	GError * _inner_error_ = NULL;
	self = _data1_->self;
	g_return_if_fail (r != NULL);
	{
		FolksIndividualAggregator* _tmp0_;
		GAsyncResult* _tmp1_;
		_tmp0_ = _data1_->aggregator;
		_tmp1_ = r;
		folks_individual_aggregator_prepare_finish (_tmp0_, _tmp1_, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e1 = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e1 = _inner_error_;
		_inner_error_ = NULL;
		_tmp2_ = e1;
		_tmp3_ = _tmp2_->message;
		g_critical ("individual-retrieval.vala:126: failed to prepare aggregator: %s", _tmp3_);
		g_assert_not_reached ();
		_g_error_free0 (e1);
	}
	__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;
	}
}


static void __lambda3__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
	_lambda3_ (source_object, res, self);
	block1_data_unref (self);
}


static gboolean _lambda2_ (Block1Data* _data1_) {
	IndividualRetrievalTests * self;
	gboolean result = FALSE;
	FolksIndividualAggregator* _tmp0_;
	self = _data1_->self;
	_tmp0_ = _data1_->aggregator;
	folks_individual_aggregator_prepare (_tmp0_, __lambda3__gasync_ready_callback, block1_data_ref (_data1_));
	result = FALSE;
	return result;
}


static gboolean __lambda2__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda2_ (self);
	return result;
}


void individual_retrieval_tests_test_aggregator (IndividualRetrievalTests* self) {
	Block1Data* _data1_;
	GMainLoop* _tmp0_;
	GeeHashSet* _tmp1_;
	FolksIndividualAggregator* _tmp10_;
	FolksIndividualAggregator* _tmp11_;
	gint _tmp12_;
	GMainLoop* _tmp13_;
	GeeHashSet* _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	g_return_if_fail (self != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_data1_->main_loop = _tmp0_;
	_tmp1_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
	_data1_->expected_individuals = _tmp1_;
	{
		GeeHashSet* _tmp2_;
		GeeIterator* _tmp3_ = NULL;
		GeeIterator* _id_it;
		_tmp2_ = self->priv->default_individuals;
		_tmp3_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _tmp2_);
		_id_it = _tmp3_;
		while (TRUE) {
			GeeIterator* _tmp4_;
			gboolean _tmp5_ = FALSE;
			GeeIterator* _tmp6_;
			gpointer _tmp7_ = NULL;
			gchar* id;
			GeeHashSet* _tmp8_;
			const gchar* _tmp9_;
			_tmp4_ = _id_it;
			_tmp5_ = gee_iterator_next (_tmp4_);
			if (!_tmp5_) {
				break;
			}
			_tmp6_ = _id_it;
			_tmp7_ = gee_iterator_get (_tmp6_);
			id = (gchar*) _tmp7_;
			_tmp8_ = _data1_->expected_individuals;
			_tmp9_ = id;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, _tmp9_);
			_g_free0 (id);
		}
		_g_object_unref0 (_id_it);
	}
	_tmp10_ = folks_individual_aggregator_new ();
	_data1_->aggregator = _tmp10_;
	_tmp11_ = _data1_->aggregator;
	g_signal_connect_data (_tmp11_, "individuals-changed", (GCallback) __lambda0__folks_individual_aggregator_individuals_changed, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_tmp12_ = self->priv->_test_timeout;
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) _tmp12_, __lambda1__gsource_func, block1_data_ref (_data1_), block1_data_unref);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, __lambda2__gsource_func, block1_data_ref (_data1_), block1_data_unref);
	_tmp13_ = _data1_->main_loop;
	g_main_loop_run (_tmp13_);
	_tmp14_ = _data1_->expected_individuals;
	_tmp15_ = gee_collection_get_size ((GeeCollection*) _tmp14_);
	_tmp16_ = _tmp15_;
	g_assert (_tmp16_ == 0);
	_g_object_unref0 (_data1_->aggregator);
	_data1_->aggregator = NULL;
	block1_data_unref (_data1_);
	_data1_ = NULL;
}


static Block2Data* block2_data_ref (Block2Data* _data2_) {
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void block2_data_unref (Block2Data* _data2_) {
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		_g_object_unref0 (_data2_->self);
		_g_object_unref0 (_data2_->aggregator);
		_g_object_unref0 (_data2_->added_individuals);
		_g_main_loop_unref0 (_data2_->main_loop);
		g_slice_free (Block2Data, _data2_);
	}
}


static void _lambda4_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, Block2Data* _data2_) {
	IndividualRetrievalTests * self;
	GeeSet* _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	self = _data2_->self;
	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;
			_tmp2_ = _i_it;
			_tmp3_ = gee_iterator_next (_tmp2_);
			if (!_tmp3_) {
				break;
			}
			_tmp4_ = _i_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			i = (FolksIndividual*) _tmp5_;
			{
				FolksIndividual* _tmp6_;
				GeeSet* _tmp7_;
				GeeSet* _tmp8_;
				GeeIterator* _tmp9_ = NULL;
				GeeIterator* _p_it;
				_tmp6_ = i;
				_tmp7_ = folks_individual_get_personas (_tmp6_);
				_tmp8_ = _tmp7_;
				_tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_);
				_p_it = _tmp9_;
				while (TRUE) {
					GeeIterator* _tmp10_;
					gboolean _tmp11_ = FALSE;
					GeeIterator* _tmp12_;
					gpointer _tmp13_ = NULL;
					FolksPersona* p;
					FolksPersona* _tmp14_;
					_tmp10_ = _p_it;
					_tmp11_ = gee_iterator_next (_tmp10_);
					if (!_tmp11_) {
						break;
					}
					_tmp12_ = _p_it;
					_tmp13_ = gee_iterator_get (_tmp12_);
					p = (FolksPersona*) _tmp13_;
					_tmp14_ = p;
					if (TPF_IS_PERSONA (_tmp14_)) {
						GeeHashSet* _tmp15_;
						FolksPersona* _tmp16_;
						const gchar* _tmp17_;
						const gchar* _tmp18_;
						gboolean _tmp19_ = FALSE;
						_tmp15_ = _data2_->added_individuals;
						_tmp16_ = p;
						_tmp17_ = folks_persona_get_display_id ((FolksPersona*) TPF_PERSONA (_tmp16_));
						_tmp18_ = _tmp17_;
						_tmp19_ = gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp15_, _tmp18_);
						if (_tmp19_) {
							_g_object_unref0 (p);
							break;
						}
					}
					_g_object_unref0 (p);
				}
				_g_object_unref0 (_p_it);
			}
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp20_ = removed;
	_tmp21_ = gee_collection_get_size ((GeeCollection*) _tmp20_);
	_tmp22_ = _tmp21_;
	g_assert (_tmp22_ == 0);
}


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


static gboolean _lambda5_ (Block2Data* _data2_) {
	IndividualRetrievalTests * self;
	gboolean result = FALSE;
	GMainLoop* _tmp0_;
	self = _data2_->self;
	_tmp0_ = _data2_->main_loop;
	g_main_loop_quit (_tmp0_);
	result = FALSE;
	return result;
}


static gboolean __lambda5__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda5_ (self);
	return result;
}


static Block3Data* block3_data_ref (Block3Data* _data3_) {
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}


static void block3_data_unref (Block3Data* _data3_) {
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		block2_data_unref (_data3_->_data2_);
		_data3_->_data2_ = NULL;
		g_slice_free (Block3Data, _data3_);
	}
}


static void _lambda8_ (FolksPersonaStore* store, Block3Data* _data3_) {
	Block2Data* _data2_;
	IndividualRetrievalTests * self;
	gboolean _tmp0_ = FALSE;
	FolksPersonaStore* _tmp1_;
	gboolean _tmp3_;
	_data2_ = _data3_->_data2_;
	self = _data2_->self;
	g_return_if_fail (store != NULL);
	_tmp1_ = store;
	if (TPF_IS_PERSONA_STORE (_tmp1_)) {
		gboolean _tmp2_;
		_tmp2_ = _data3_->adding_done;
		_tmp0_ = !_tmp2_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp3_ = _tmp0_;
	if (_tmp3_) {
		FolksPersonaStore* _tmp4_;
		GeeHashSet* _tmp5_;
		_tmp4_ = store;
		_tmp5_ = _data2_->added_individuals;
		individual_retrieval_tests_add_personas (self, TPF_PERSONA_STORE (_tmp4_), _tmp5_, NULL, NULL);
		_data3_->adding_done = TRUE;
	}
}


static void __lambda8__folks_backend_persona_store_added (FolksBackend* _sender, FolksPersonaStore* store, gpointer self) {
	_lambda8_ (store, self);
}


static void _lambda7_ (GObject* s, GAsyncResult* r, Block2Data* _data2_) {
	IndividualRetrievalTests * self;
	Block3Data* _data3_;
	FolksBackendStore* _tmp4_ = NULL;
	FolksBackendStore* backend_store;
	GError * _inner_error_ = NULL;
	self = _data2_->self;
	g_return_if_fail (r != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->_data2_ = block2_data_ref (_data2_);
	{
		FolksIndividualAggregator* _tmp0_;
		GAsyncResult* _tmp1_;
		_tmp0_ = _data2_->aggregator;
		_tmp1_ = r;
		folks_individual_aggregator_prepare_finish (_tmp0_, _tmp1_, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e1 = NULL;
		GError* _tmp2_;
		const gchar* _tmp3_;
		e1 = _inner_error_;
		_inner_error_ = NULL;
		_tmp2_ = e1;
		_tmp3_ = _tmp2_->message;
		g_critical ("individual-retrieval.vala:196: failed to prepare aggregator: %s", _tmp3_);
		g_assert_not_reached ();
		_g_error_free0 (e1);
	}
	__finally1:
	if (_inner_error_ != NULL) {
		block3_data_unref (_data3_);
		_data3_ = 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;
	}
	_data3_->adding_done = FALSE;
	_tmp4_ = folks_backend_store_dup ();
	backend_store = _tmp4_;
	{
		FolksBackendStore* _tmp5_;
		GeeMap* _tmp6_;
		GeeMap* _tmp7_;
		GeeCollection* _tmp8_;
		GeeCollection* _tmp9_;
		GeeCollection* _tmp10_;
		GeeIterator* _tmp11_ = NULL;
		GeeIterator* _tmp12_;
		GeeIterator* _backend_it;
		_tmp5_ = backend_store;
		_tmp6_ = folks_backend_store_get_enabled_backends (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = gee_map_get_values (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = _tmp9_;
		_tmp11_ = gee_iterable_iterator ((GeeIterable*) _tmp10_);
		_tmp12_ = _tmp11_;
		_g_object_unref0 (_tmp10_);
		_backend_it = _tmp12_;
		while (TRUE) {
			GeeIterator* _tmp13_;
			gboolean _tmp14_ = FALSE;
			GeeIterator* _tmp15_;
			gpointer _tmp16_ = NULL;
			FolksBackend* backend;
			FolksBackend* _tmp17_;
			_tmp13_ = _backend_it;
			_tmp14_ = gee_iterator_next (_tmp13_);
			if (!_tmp14_) {
				break;
			}
			_tmp15_ = _backend_it;
			_tmp16_ = gee_iterator_get (_tmp15_);
			backend = (FolksBackend*) _tmp16_;
			_tmp17_ = backend;
			g_signal_connect_data (_tmp17_, "persona-store-added", (GCallback) __lambda8__folks_backend_persona_store_added, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
			{
				FolksBackend* _tmp18_;
				GeeMap* _tmp19_;
				GeeMap* _tmp20_;
				GeeCollection* _tmp21_;
				GeeCollection* _tmp22_;
				GeeCollection* _tmp23_;
				GeeIterator* _tmp24_ = NULL;
				GeeIterator* _tmp25_;
				GeeIterator* _store_it;
				_tmp18_ = backend;
				_tmp19_ = folks_backend_get_persona_stores (_tmp18_);
				_tmp20_ = _tmp19_;
				_tmp21_ = gee_map_get_values (_tmp20_);
				_tmp22_ = _tmp21_;
				_tmp23_ = _tmp22_;
				_tmp24_ = gee_iterable_iterator ((GeeIterable*) _tmp23_);
				_tmp25_ = _tmp24_;
				_g_object_unref0 (_tmp23_);
				_store_it = _tmp25_;
				while (TRUE) {
					GeeIterator* _tmp26_;
					gboolean _tmp27_ = FALSE;
					GeeIterator* _tmp28_;
					gpointer _tmp29_ = NULL;
					FolksPersonaStore* store;
					gboolean _tmp30_ = FALSE;
					FolksPersonaStore* _tmp31_;
					gboolean _tmp33_;
					_tmp26_ = _store_it;
					_tmp27_ = gee_iterator_next (_tmp26_);
					if (!_tmp27_) {
						break;
					}
					_tmp28_ = _store_it;
					_tmp29_ = gee_iterator_get (_tmp28_);
					store = (FolksPersonaStore*) _tmp29_;
					_tmp31_ = store;
					if (TPF_IS_PERSONA_STORE (_tmp31_)) {
						gboolean _tmp32_;
						_tmp32_ = _data3_->adding_done;
						_tmp30_ = !_tmp32_;
					} else {
						_tmp30_ = FALSE;
					}
					_tmp33_ = _tmp30_;
					if (_tmp33_) {
						FolksPersonaStore* _tmp34_;
						GeeHashSet* _tmp35_;
						_tmp34_ = store;
						_tmp35_ = _data2_->added_individuals;
						individual_retrieval_tests_add_personas (self, TPF_PERSONA_STORE (_tmp34_), _tmp35_, NULL, NULL);
						_data3_->adding_done = TRUE;
					}
					_g_object_unref0 (store);
				}
				_g_object_unref0 (_store_it);
			}
			_g_object_unref0 (backend);
		}
		_g_object_unref0 (_backend_it);
	}
	_g_object_unref0 (backend_store);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}


static void __lambda7__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
	_lambda7_ (source_object, res, self);
	block2_data_unref (self);
}


static gboolean _lambda6_ (Block2Data* _data2_) {
	IndividualRetrievalTests * self;
	gboolean result = FALSE;
	FolksIndividualAggregator* _tmp0_;
	self = _data2_->self;
	_tmp0_ = _data2_->aggregator;
	folks_individual_aggregator_prepare (_tmp0_, __lambda7__gasync_ready_callback, block2_data_ref (_data2_));
	result = FALSE;
	return result;
}


static gboolean __lambda6__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda6_ (self);
	return result;
}


void individual_retrieval_tests_test_aggregator_add (IndividualRetrievalTests* self) {
	Block2Data* _data2_;
	GMainLoop* _tmp0_;
	GeeHashSet* _tmp1_;
	GeeHashSet* _tmp2_;
	GeeHashSet* _tmp3_;
	GeeHashSet* _tmp4_;
	FolksIndividualAggregator* _tmp5_;
	FolksIndividualAggregator* _tmp6_;
	gint _tmp7_;
	GMainLoop* _tmp8_;
	GeeHashSet* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	g_return_if_fail (self != NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_data2_->main_loop = _tmp0_;
	_tmp1_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
	_data2_->added_individuals = _tmp1_;
	_tmp2_ = _data2_->added_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp2_, "master.shake@example.com");
	_tmp3_ = _data2_->added_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp3_, "2wycked@example.com");
	_tmp4_ = _data2_->added_individuals;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp4_, "carl-brutananadilewski@example.com");
	_tmp5_ = folks_individual_aggregator_new ();
	_data2_->aggregator = _tmp5_;
	_tmp6_ = _data2_->aggregator;
	g_signal_connect_data (_tmp6_, "individuals-changed", (GCallback) __lambda4__folks_individual_aggregator_individuals_changed, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp7_ = self->priv->_test_timeout;
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) _tmp7_, __lambda5__gsource_func, block2_data_ref (_data2_), block2_data_unref);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, __lambda6__gsource_func, block2_data_ref (_data2_), block2_data_unref);
	_tmp8_ = _data2_->main_loop;
	g_main_loop_run (_tmp8_);
	_tmp9_ = _data2_->added_individuals;
	_tmp10_ = gee_collection_get_size ((GeeCollection*) _tmp9_);
	_tmp11_ = _tmp10_;
	g_assert (_tmp11_ == 0);
	_g_object_unref0 (_data2_->aggregator);
	_data2_->aggregator = NULL;
	block2_data_unref (_data2_);
	_data2_ = NULL;
}


static void individual_retrieval_tests_add_personas_data_free (gpointer _data) {
	IndividualRetrievalTestsAddPersonasData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->store);
	_g_object_unref0 (_data_->ids_add);
	_g_object_unref0 (_data_->self);
	g_slice_free (IndividualRetrievalTestsAddPersonasData, _data_);
}


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


static void individual_retrieval_tests_add_personas (IndividualRetrievalTests* self, TpfPersonaStore* store, GeeHashSet* ids_add, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	IndividualRetrievalTestsAddPersonasData* _data_;
	IndividualRetrievalTests* _tmp0_;
	TpfPersonaStore* _tmp1_;
	TpfPersonaStore* _tmp2_;
	GeeHashSet* _tmp3_;
	GeeHashSet* _tmp4_;
	_data_ = g_slice_new0 (IndividualRetrievalTestsAddPersonasData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, individual_retrieval_tests_add_personas);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, individual_retrieval_tests_add_personas_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = store;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data_->store = _tmp2_;
	_tmp3_ = ids_add;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_data_->ids_add = _tmp4_;
	individual_retrieval_tests_add_personas_co (_data_);
}


static void individual_retrieval_tests_add_personas_finish (IndividualRetrievalTests* self, GAsyncResult* _res_) {
	IndividualRetrievalTestsAddPersonasData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static Block4Data* block4_data_ref (Block4Data* _data4_) {
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}


static void block4_data_unref (Block4Data* _data4_) {
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		_g_object_unref0 (_data4_->self);
		_g_object_unref0 (_data4_->store);
		g_slice_free (Block4Data, _data4_);
	}
}


static Block5Data* block5_data_ref (Block5Data* _data5_) {
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}


static void block5_data_unref (Block5Data* _data5_) {
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		block4_data_unref (_data5_->_data4_);
		_data5_->_data4_ = NULL;
		_g_object_unref0 (_data5_->ids_remaining);
		g_slice_free (Block5Data, _data5_);
	}
}


static void individual_retrieval_tests_add_personas_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	IndividualRetrievalTestsAddPersonasData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	individual_retrieval_tests_add_personas_co (_data_);
}


static Block6Data* block6_data_ref (Block6Data* _data6_) {
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}


static void block6_data_unref (Block6Data* _data6_) {
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		block5_data_unref (_data6_->_data5_);
		_data6_->_data5_ = NULL;
		_g_hash_table_unref0 (_data6_->details);
		g_slice_free (Block6Data, _data6_);
	}
}


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 _lambda10_ (GObject* s2, GAsyncResult* res, Block6Data* _data6_) {
	Block5Data* _data5_;
	Block4Data* _data4_;
	IndividualRetrievalTests * self;
	GError * _inner_error_ = NULL;
	_data5_ = _data6_->_data5_;
	_data4_ = _data5_->_data4_;
	self = _data4_->self;
	g_return_if_fail (res != NULL);
	{
		TpfPersonaStore* _tmp0_;
		GAsyncResult* _tmp1_;
		FolksPersona* _tmp2_ = NULL;
		FolksPersona* _tmp3_;
		GHashTable* _tmp4_;
		gconstpointer _tmp5_ = NULL;
		GValue* _tmp6_;
		GValue* id_added_value;
		GValue* _tmp7_;
		const gchar* _tmp8_ = NULL;
		gchar* _tmp9_;
		gchar* id_added;
		const gchar* _tmp10_;
		_tmp0_ = _data4_->store;
		_tmp1_ = res;
		_tmp2_ = folks_persona_store_add_persona_from_details_finish ((FolksPersonaStore*) _tmp0_, _tmp1_, &_inner_error_);
		_tmp3_ = _tmp2_;
		_g_object_unref0 (_tmp3_);
		if (_inner_error_ != NULL) {
			goto __catch3_g_error;
		}
		_tmp4_ = _data6_->details;
		_tmp5_ = g_hash_table_lookup (_tmp4_, "contact");
		_tmp6_ = __g_value_dup0 ((GValue*) _tmp5_);
		id_added_value = _tmp6_;
		_tmp7_ = id_added_value;
		_tmp8_ = g_value_get_string (_tmp7_);
		_tmp9_ = g_strdup (_tmp8_);
		id_added = _tmp9_;
		_tmp10_ = id_added;
		if (_tmp10_ != NULL) {
			GeeHashSet* _tmp11_;
			const gchar* _tmp12_;
			_tmp11_ = _data5_->ids_remaining;
			_tmp12_ = id_added;
			gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp11_, _tmp12_);
		}
		_g_free0 (id_added);
		__vala_GValue_free0 (id_added_value);
	}
	goto __finally3;
	__catch3_g_error:
	{
		GError* e1 = NULL;
		GError* _tmp13_;
		e1 = _inner_error_;
		_inner_error_ = NULL;
		_tmp13_ = e1;
		if (!g_error_matches (_tmp13_, FOLKS_PERSONA_STORE_ERROR, FOLKS_PERSONA_STORE_ERROR_STORE_OFFLINE)) {
			GError* _tmp14_;
			const gchar* _tmp15_;
			_tmp14_ = e1;
			_tmp15_ = _tmp14_->message;
			g_critical ("individual-retrieval.vala:292: failed to add persona: %s", _tmp15_);
			g_assert_not_reached ();
		}
		_g_error_free0 (e1);
	}
	__finally3:
	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 void __lambda10__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
	_lambda10_ (source_object, res, self);
	block6_data_unref (self);
}


static gboolean _lambda9_ (Block5Data* _data5_) {
	Block4Data* _data4_;
	IndividualRetrievalTests * self;
	gboolean result = FALSE;
	gboolean try_again;
	_data4_ = _data5_->_data4_;
	self = _data4_->self;
	try_again = FALSE;
	{
		GeeHashSet* _tmp0_;
		GeeIterator* _tmp1_ = NULL;
		GeeIterator* _id_it;
		_tmp0_ = _data5_->ids_remaining;
		_tmp1_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _tmp0_);
		_id_it = _tmp1_;
		while (TRUE) {
			Block6Data* _data6_;
			GeeIterator* _tmp2_;
			gboolean _tmp3_ = FALSE;
			GeeIterator* _tmp4_;
			gpointer _tmp5_ = NULL;
			gchar* id;
			GHashFunc _tmp6_;
			GEqualFunc _tmp7_;
			GHashTable* _tmp8_;
			GHashTable* _tmp9_;
			gchar* _tmp10_;
			const gchar* _tmp11_;
			GValue* _tmp12_ = NULL;
			TpfPersonaStore* _tmp13_;
			GHashTable* _tmp14_;
			GeeHashSet* _tmp15_;
			gint _tmp16_;
			gint _tmp17_;
			gboolean _tmp18_;
			_data6_ = g_slice_new0 (Block6Data);
			_data6_->_ref_count_ = 1;
			_data6_->_data5_ = block5_data_ref (_data5_);
			_tmp2_ = _id_it;
			_tmp3_ = gee_iterator_next (_tmp2_);
			if (!_tmp3_) {
				block6_data_unref (_data6_);
				_data6_ = NULL;
				break;
			}
			_tmp4_ = _id_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			id = (gchar*) _tmp5_;
			_tmp6_ = g_str_hash;
			_tmp7_ = g_str_equal;
			_tmp8_ = g_hash_table_new_full (_tmp6_, _tmp7_, _g_free0_, __vala_GValue_free0_);
			_data6_->details = _tmp8_;
			_tmp9_ = _data6_->details;
			_tmp10_ = g_strdup ("contact");
			_tmp11_ = id;
			_tmp12_ = g_new0 (GValue, 1);
			g_value_init (_tmp12_, G_TYPE_STRING);
			g_value_set_string (_tmp12_, _tmp11_);
			g_hash_table_insert (_tmp9_, _tmp10_, _tmp12_);
			_tmp13_ = _data4_->store;
			_tmp14_ = _data6_->details;
			folks_persona_store_add_persona_from_details ((FolksPersonaStore*) _tmp13_, _tmp14_, __lambda10__gasync_ready_callback, block6_data_ref (_data6_));
			_tmp15_ = _data5_->ids_remaining;
			_tmp16_ = gee_collection_get_size ((GeeCollection*) _tmp15_);
			_tmp17_ = _tmp16_;
			try_again = _tmp17_ > 0;
			_tmp18_ = try_again;
			if (_tmp18_) {
				_g_free0 (id);
				block6_data_unref (_data6_);
				_data6_ = NULL;
				break;
			}
			_g_free0 (id);
			block6_data_unref (_data6_);
			_data6_ = NULL;
		}
		_g_object_unref0 (_id_it);
	}
	result = try_again;
	return result;
}


static gboolean __lambda9__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda9_ (self);
	return result;
}


static gboolean individual_retrieval_tests_add_personas_co (IndividualRetrievalTestsAddPersonasData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data4_ = g_slice_new0 (Block4Data);
	_data_->_data4_->_ref_count_ = 1;
	_data_->_data4_->self = g_object_ref (_data_->self);
	_data_->_tmp0_ = _data_->store;
	_data_->_tmp1_ = _g_object_ref0 (_data_->_tmp0_);
	_data_->_data4_->store = _data_->_tmp1_;
	_data_->_data4_->_async_data_ = _data_;
	{
		_data_->_data5_ = g_slice_new0 (Block5Data);
		_data_->_data5_->_ref_count_ = 1;
		_data_->_data5_->_data4_ = block4_data_ref (_data_->_data4_);
		_data_->_tmp2_ = _data_->_data4_->store;
		_data_->_state_ = 1;
		folks_persona_store_prepare ((FolksPersonaStore*) _data_->_tmp2_, individual_retrieval_tests_add_personas_ready, _data_);
		return FALSE;
		_state_1:
		folks_persona_store_prepare_finish ((FolksPersonaStore*) _data_->_tmp2_, _data_->_res_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			block5_data_unref (_data_->_data5_);
			_data_->_data5_ = NULL;
			goto __catch2_g_error;
		}
		_data_->_tmp3_ = g_str_hash;
		_data_->_tmp4_ = g_str_equal;
		_data_->_tmp5_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _data_->_tmp3_, _data_->_tmp4_);
		_data_->_data5_->ids_remaining = _data_->_tmp5_;
		{
			_data_->_tmp6_ = _data_->ids_add;
			_data_->_tmp7_ = NULL;
			_data_->_tmp7_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _data_->_tmp6_);
			_data_->_contact_id_it = _data_->_tmp7_;
			while (TRUE) {
				_data_->_tmp8_ = _data_->_contact_id_it;
				_data_->_tmp9_ = FALSE;
				_data_->_tmp9_ = gee_iterator_next (_data_->_tmp8_);
				if (!_data_->_tmp9_) {
					break;
				}
				_data_->_tmp10_ = _data_->_contact_id_it;
				_data_->_tmp11_ = NULL;
				_data_->_tmp11_ = gee_iterator_get (_data_->_tmp10_);
				_data_->contact_id = (gchar*) _data_->_tmp11_;
				_data_->_tmp12_ = _data_->_data5_->ids_remaining;
				_data_->_tmp13_ = _data_->contact_id;
				gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp12_, _data_->_tmp13_);
				_g_free0 (_data_->contact_id);
			}
			_g_object_unref0 (_data_->_contact_id_it);
		}
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, __lambda9__gsource_func, block5_data_ref (_data_->_data5_), block5_data_unref);
		block5_data_unref (_data_->_data5_);
		_data_->_data5_ = NULL;
	}
	goto __finally2;
	__catch2_g_error:
	{
		_data_->e2 = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp14_ = _data_->_data4_->store;
		_data_->_tmp15_ = folks_persona_store_get_id ((FolksPersonaStore*) _data_->_tmp14_);
		_data_->_tmp16_ = _data_->_tmp15_;
		_data_->_tmp17_ = _data_->e2;
		_data_->_tmp18_ = _data_->_tmp17_->message;
		g_warning ("individual-retrieval.vala:309: Error preparing PersonaStore '%s': %s", _data_->_tmp16_, _data_->_tmp18_);
		g_assert_not_reached ();
		_g_error_free0 (_data_->e2);
	}
	__finally2:
	if (_data_->_inner_error_ != NULL) {
		block4_data_unref (_data_->_data4_);
		_data_->_data4_ = NULL;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	block4_data_unref (_data_->_data4_);
	_data_->_data4_ = NULL;
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void individual_retrieval_tests_class_init (IndividualRetrievalTestsClass * klass) {
	individual_retrieval_tests_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (IndividualRetrievalTestsPrivate));
	FOLKS_TEST_CASE_CLASS (klass)->set_up = individual_retrieval_tests_real_set_up;
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = individual_retrieval_tests_real_tear_down;
	G_OBJECT_CLASS (klass)->finalize = individual_retrieval_tests_finalize;
}


static void individual_retrieval_tests_instance_init (IndividualRetrievalTests * self) {
	self->priv = INDIVIDUAL_RETRIEVAL_TESTS_GET_PRIVATE (self);
	self->priv->_test_timeout = 3;
}


static void individual_retrieval_tests_finalize (GObject* obj) {
	IndividualRetrievalTests * self;
	self = INDIVIDUAL_RETRIEVAL_TESTS (obj);
	_g_object_unref0 (self->priv->tp_backend);
	_g_object_unref0 (self->priv->default_individuals);
	G_OBJECT_CLASS (individual_retrieval_tests_parent_class)->finalize (obj);
}


GType individual_retrieval_tests_get_type (void) {
	static volatile gsize individual_retrieval_tests_type_id__volatile = 0;
	if (g_once_init_enter (&individual_retrieval_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (IndividualRetrievalTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) individual_retrieval_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (IndividualRetrievalTests), 0, (GInstanceInitFunc) individual_retrieval_tests_instance_init, NULL };
		GType individual_retrieval_tests_type_id;
		individual_retrieval_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "IndividualRetrievalTests", &g_define_type_info, 0);
		g_once_init_leave (&individual_retrieval_tests_type_id__volatile, individual_retrieval_tests_type_id);
	}
	return individual_retrieval_tests_type_id__volatile;
}


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



