/* backend-loading.c generated by valac 0.13.1.106-1068, the Vala compiler
 * generated from backend-loading.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 <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gio/gio.h>
#include <gee.h>
#include <folks/folks.h>


#define TYPE_BACKEND_LOADING_TESTS (backend_loading_tests_get_type ())
#define BACKEND_LOADING_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BACKEND_LOADING_TESTS, BackendLoadingTests))
#define BACKEND_LOADING_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BACKEND_LOADING_TESTS, BackendLoadingTestsClass))
#define IS_BACKEND_LOADING_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BACKEND_LOADING_TESTS))
#define IS_BACKEND_LOADING_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BACKEND_LOADING_TESTS))
#define BACKEND_LOADING_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BACKEND_LOADING_TESTS, BackendLoadingTestsClass))

typedef struct _BackendLoadingTests BackendLoadingTests;
typedef struct _BackendLoadingTestsClass BackendLoadingTestsClass;
typedef struct _BackendLoadingTestsPrivate BackendLoadingTestsPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#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)))
#define _g_key_file_free0(var) ((var == NULL) ? NULL : (var = (g_key_file_free (var), NULL)))
typedef struct _Block1Data Block1Data;
typedef struct _BackendLoadingTestsTestDisablingAsyncData BackendLoadingTestsTestDisablingAsyncData;
typedef struct _BackendLoadingTestsTestReloadingAsyncData BackendLoadingTestsTestReloadingAsyncData;

struct _BackendLoadingTests {
	FolksTestCase parent_instance;
	BackendLoadingTestsPrivate * priv;
};

struct _BackendLoadingTestsClass {
	FolksTestCaseClass parent_class;
};

struct _BackendLoadingTestsPrivate {
	TpTestBackend* _tp_backend;
	void* _account_handle;
	GMainLoop* main_loop;
};

struct _Block1Data {
	int _ref_count_;
	BackendLoadingTests * self;
	GMainLoop* main_loop;
	GeeHashSet* backends_expected;
	FolksBackendStore* store;
};

struct _BackendLoadingTestsTestDisablingAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	BackendLoadingTests* self;
	FolksBackendStore* store;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GeeHashSet* _tmp2_;
	GeeHashSet* backends_expected;
	GeeHashSet* _tmp3_;
	FolksBackendStore* _tmp4_;
	FolksBackendStore* _tmp5_;
	FolksBackendStore* _tmp6_;
	FolksBackendStore* _tmp7_;
	GeeMap* _tmp8_;
	GeeMap* _tmp9_;
	GeeCollection* _tmp10_;
	GeeCollection* _tmp11_;
	GeeCollection* _tmp12_;
	GeeIterator* _tmp13_;
	GeeIterator* _tmp14_;
	GeeIterator* _backend_it;
	GeeIterator* _tmp15_;
	gboolean _tmp16_;
	GeeIterator* _tmp17_;
	gpointer _tmp18_;
	FolksBackend* backend;
	GeeHashSet* _tmp19_;
	FolksBackend* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	gboolean _tmp23_;
	GeeHashSet* _tmp24_;
	FolksBackend* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	GeeHashSet* _tmp28_;
	gint _tmp29_;
	gint _tmp30_;
	GMainLoop* _tmp31_;
	GError* e;
	GError* _tmp32_;
	const gchar* _tmp33_;
	GError * _inner_error_;
};

struct _BackendLoadingTestsTestReloadingAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	BackendLoadingTests* self;
	FolksBackendStore* store;
	GeeHashSet* backends_expected;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GeeHashSet* _tmp2_;
	GeeHashSet* _tmp3_;
	GeeHashSet* _tmp4_;
	FolksBackendStore* _tmp5_;
	FolksBackendStore* _tmp6_;
	GeeMap* _tmp7_;
	GeeMap* _tmp8_;
	GeeCollection* _tmp9_;
	GeeCollection* _tmp10_;
	GeeCollection* _tmp11_;
	GeeIterator* _tmp12_;
	GeeIterator* _tmp13_;
	GeeIterator* _backend1_it;
	GeeIterator* _tmp14_;
	gboolean _tmp15_;
	GeeIterator* _tmp16_;
	gpointer _tmp17_;
	FolksBackend* backend1;
	GeeHashSet* _tmp18_;
	FolksBackend* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	gboolean _tmp22_;
	GeeHashSet* _tmp23_;
	FolksBackend* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	GeeHashSet* _tmp27_;
	gint _tmp28_;
	gint _tmp29_;
	GError* e1;
	GError* _tmp30_;
	const gchar* _tmp31_;
	GHashFunc _tmp32_;
	GEqualFunc _tmp33_;
	GeeHashSet* _tmp34_;
	GeeHashSet* _tmp35_;
	FolksBackendStore* _tmp36_;
	FolksBackendStore* _tmp37_;
	FolksBackendStore* _tmp38_;
	GeeMap* _tmp39_;
	GeeMap* _tmp40_;
	GeeCollection* _tmp41_;
	GeeCollection* _tmp42_;
	GeeCollection* _tmp43_;
	GeeIterator* _tmp44_;
	GeeIterator* _tmp45_;
	GeeIterator* _backend2_it;
	GeeIterator* _tmp46_;
	gboolean _tmp47_;
	GeeIterator* _tmp48_;
	gpointer _tmp49_;
	FolksBackend* backend2;
	GeeHashSet* _tmp50_;
	FolksBackend* _tmp51_;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	gboolean _tmp54_;
	GeeHashSet* _tmp55_;
	FolksBackend* _tmp56_;
	const gchar* _tmp57_;
	const gchar* _tmp58_;
	GeeHashSet* _tmp59_;
	gint _tmp60_;
	gint _tmp61_;
	GError* e2;
	GError* _tmp62_;
	const gchar* _tmp63_;
	GHashFunc _tmp64_;
	GEqualFunc _tmp65_;
	GeeHashSet* _tmp66_;
	GeeHashSet* _tmp67_;
	GeeHashSet* _tmp68_;
	FolksBackendStore* _tmp69_;
	FolksBackendStore* _tmp70_;
	FolksBackendStore* _tmp71_;
	GeeMap* _tmp72_;
	GeeMap* _tmp73_;
	GeeCollection* _tmp74_;
	GeeCollection* _tmp75_;
	GeeCollection* _tmp76_;
	GeeIterator* _tmp77_;
	GeeIterator* _tmp78_;
	GeeIterator* _backend3_it;
	GeeIterator* _tmp79_;
	gboolean _tmp80_;
	GeeIterator* _tmp81_;
	gpointer _tmp82_;
	FolksBackend* backend3;
	GeeHashSet* _tmp83_;
	FolksBackend* _tmp84_;
	const gchar* _tmp85_;
	const gchar* _tmp86_;
	gboolean _tmp87_;
	GeeHashSet* _tmp88_;
	FolksBackend* _tmp89_;
	const gchar* _tmp90_;
	const gchar* _tmp91_;
	GeeHashSet* _tmp92_;
	gint _tmp93_;
	gint _tmp94_;
	GError* e3;
	GError* _tmp95_;
	const gchar* _tmp96_;
	GHashFunc _tmp97_;
	GEqualFunc _tmp98_;
	GeeHashSet* _tmp99_;
	GeeHashSet* _tmp100_;
	GeeHashSet* _tmp101_;
	FolksBackendStore* _tmp102_;
	FolksBackendStore* _tmp103_;
	GeeMap* _tmp104_;
	GeeMap* _tmp105_;
	GeeCollection* _tmp106_;
	GeeCollection* _tmp107_;
	GeeCollection* _tmp108_;
	GeeIterator* _tmp109_;
	GeeIterator* _tmp110_;
	GeeIterator* _backend_it;
	GeeIterator* _tmp111_;
	gboolean _tmp112_;
	GeeIterator* _tmp113_;
	gpointer _tmp114_;
	FolksBackend* backend;
	GeeHashSet* _tmp115_;
	FolksBackend* _tmp116_;
	const gchar* _tmp117_;
	const gchar* _tmp118_;
	gboolean _tmp119_;
	GeeHashSet* _tmp120_;
	FolksBackend* _tmp121_;
	const gchar* _tmp122_;
	const gchar* _tmp123_;
	GeeHashSet* _tmp124_;
	gint _tmp125_;
	gint _tmp126_;
	GError* e4;
	GError* _tmp127_;
	const gchar* _tmp128_;
	GMainLoop* _tmp129_;
	GError * _inner_error_;
};


static gpointer backend_loading_tests_parent_class = NULL;

GType backend_loading_tests_get_type (void) G_GNUC_CONST;
#define BACKEND_LOADING_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_BACKEND_LOADING_TESTS, BackendLoadingTestsPrivate))
enum  {
	BACKEND_LOADING_TESTS_DUMMY_PROPERTY
};
#define BACKEND_LOADING_TESTS_STORE_FILE_PATH "folks-test-backend-store.ini"
BackendLoadingTests* backend_loading_tests_new (void);
BackendLoadingTests* backend_loading_tests_construct (GType object_type);
void backend_loading_tests_test_load_and_prep (BackendLoadingTests* self);
static void _backend_loading_tests_test_load_and_prep_folks_test_case_test_method (gpointer self);
void backend_loading_tests_test_disabling (BackendLoadingTests* self);
static void _backend_loading_tests_test_disabling_folks_test_case_test_method (gpointer self);
void backend_loading_tests_test_reloading (BackendLoadingTests* self);
static void _backend_loading_tests_test_reloading_folks_test_case_test_method (gpointer self);
static void backend_loading_tests_real_set_up (FolksTestCase* base);
static void backend_loading_tests_real_tear_down (FolksTestCase* base);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (Block1Data* _data1_);
static void _lambda0_ (GObject* o, GAsyncResult* r, Block1Data* _data1_);
static void __lambda0__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static void _lambda1_ (GObject* o, GAsyncResult* r, Block1Data* _data1_);
static void __lambda1__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static void backend_loading_tests_test_disabling_async (BackendLoadingTests* self, FolksBackendStore* store, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void backend_loading_tests_test_disabling_finish (BackendLoadingTests* self, GAsyncResult* _res_);
static void _lambda2_ (GObject* o, GAsyncResult* r, BackendLoadingTests* self);
static void __lambda2__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static void backend_loading_tests_test_disabling_async_data_free (gpointer _data);
static gboolean backend_loading_tests_test_disabling_async_co (BackendLoadingTestsTestDisablingAsyncData* _data_);
static void backend_loading_tests_test_disabling_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void backend_loading_tests_test_reloading_async (BackendLoadingTests* self, FolksBackendStore* store, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void backend_loading_tests_test_reloading_finish (BackendLoadingTests* self, GAsyncResult* _res_);
static void _lambda3_ (GObject* o, GAsyncResult* r, BackendLoadingTests* self);
static void __lambda3__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self);
static void backend_loading_tests_test_reloading_async_data_free (gpointer _data);
static gboolean backend_loading_tests_test_reloading_async_co (BackendLoadingTestsTestReloadingAsyncData* _data_);
static void backend_loading_tests_test_reloading_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void backend_loading_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


static void _backend_loading_tests_test_load_and_prep_folks_test_case_test_method (gpointer self) {
	backend_loading_tests_test_load_and_prep (self);
}


static void _backend_loading_tests_test_disabling_folks_test_case_test_method (gpointer self) {
	backend_loading_tests_test_disabling (self);
}


static void _backend_loading_tests_test_reloading_folks_test_case_test_method (gpointer self) {
	backend_loading_tests_test_reloading (self);
}


BackendLoadingTests* backend_loading_tests_construct (GType object_type) {
	BackendLoadingTests * self = NULL;
	TpTestBackend* _tmp0_;
	self = (BackendLoadingTests*) folks_test_case_construct (object_type, "BackendLoading");
	_tmp0_ = tp_test_backend_new ();
	_g_object_unref0 (self->priv->_tp_backend);
	self->priv->_tp_backend = _tmp0_;
	folks_test_case_add_test ((FolksTestCase*) self, "load and prep", _backend_loading_tests_test_load_and_prep_folks_test_case_test_method, self);
	folks_test_case_add_test ((FolksTestCase*) self, "disabling", _backend_loading_tests_test_disabling_folks_test_case_test_method, self);
	folks_test_case_add_test ((FolksTestCase*) self, "reloading", _backend_loading_tests_test_reloading_folks_test_case_test_method, self);
	return self;
}


BackendLoadingTests* backend_loading_tests_new (void) {
	return backend_loading_tests_construct (TYPE_BACKEND_LOADING_TESTS);
}


static void backend_loading_tests_real_set_up (FolksTestCase* base) {
	BackendLoadingTests * self;
	TpTestBackend* _tmp0_;
	TpTestBackend* _tmp1_;
	void* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* kf_path;
	const gchar* _tmp5_;
	GKeyFile* _tmp6_;
	GKeyFile* kf;
	GKeyFile* _tmp7_;
	GKeyFile* _tmp8_;
	GKeyFile* _tmp9_;
	const gchar* _tmp22_;
	GError * _inner_error_ = NULL;
	self = (BackendLoadingTests*) 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_;
	_tmp3_ = g_get_tmp_dir ();
	_tmp4_ = g_build_filename (_tmp3_, BACKEND_LOADING_TESTS_STORE_FILE_PATH, NULL, NULL);
	kf_path = _tmp4_;
	_tmp5_ = kf_path;
	g_remove (_tmp5_);
	_tmp6_ = g_key_file_new ();
	kf = _tmp6_;
	_tmp7_ = kf;
	g_key_file_set_boolean (_tmp7_, "all-others", "enabled", FALSE);
	_tmp8_ = kf;
	g_key_file_set_boolean (_tmp8_, "telepathy", "enabled", TRUE);
	_tmp9_ = kf;
	g_key_file_set_boolean (_tmp9_, "key-file", "enabled", TRUE);
	{
		const gchar* _tmp10_;
		GFile* _tmp11_ = NULL;
		GFile* backend_f;
		GKeyFile* _tmp12_;
		gchar* _tmp13_ = NULL;
		gchar* data;
		GFile* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		_tmp10_ = kf_path;
		_tmp11_ = g_file_new_for_path (_tmp10_);
		backend_f = _tmp11_;
		_tmp12_ = kf;
		_tmp13_ = g_key_file_to_data (_tmp12_, NULL, NULL);
		data = _tmp13_;
		_tmp14_ = backend_f;
		_tmp15_ = data;
		_tmp16_ = data;
		_tmp17_ = strlen (_tmp16_);
		_tmp18_ = _tmp17_;
		g_file_replace_contents (_tmp14_, _tmp15_, (gsize) _tmp18_, NULL, FALSE, G_FILE_CREATE_PRIVATE, NULL, NULL, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_free0 (data);
			_g_object_unref0 (backend_f);
			goto __catch0_g_error;
		}
		_g_free0 (data);
		_g_object_unref0 (backend_f);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp19_;
		GError* _tmp20_;
		const gchar* _tmp21_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp19_ = kf_path;
		_tmp20_ = e;
		_tmp21_ = _tmp20_->message;
		g_warning ("backend-loading.vala:68: Could not write updated backend key file '%s'" \
": %s", _tmp19_, _tmp21_);
		_g_error_free0 (e);
	}
	__finally0:
	if (_inner_error_ != NULL) {
		_g_key_file_free0 (kf);
		_g_free0 (kf_path);
		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;
	}
	_tmp22_ = kf_path;
	g_setenv ("FOLKS_BACKEND_STORE_KEY_FILE_PATH", _tmp22_, TRUE);
	_g_key_file_free0 (kf);
	_g_free0 (kf_path);
}


static void backend_loading_tests_real_tear_down (FolksTestCase* base) {
	BackendLoadingTests * self;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	TpTestBackend* _tmp3_;
	void* _tmp4_;
	TpTestBackend* _tmp5_;
	self = (BackendLoadingTests*) base;
	_tmp0_ = g_get_tmp_dir ();
	_tmp1_ = g_build_filename (_tmp0_, BACKEND_LOADING_TESTS_STORE_FILE_PATH, NULL, NULL);
	_tmp2_ = _tmp1_;
	g_remove (_tmp2_);
	_g_free0 (_tmp2_);
	_tmp3_ = self->priv->_tp_backend;
	_tmp4_ = self->priv->_account_handle;
	tp_test_backend_remove_account (_tmp3_, _tmp4_);
	_tmp5_ = self->priv->_tp_backend;
	tp_test_backend_tear_down (_tmp5_);
}


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_->store);
		_g_object_unref0 (_data1_->backends_expected);
		_g_main_loop_unref0 (_data1_->main_loop);
		g_slice_free (Block1Data, _data1_);
	}
}


static void _lambda0_ (GObject* o, GAsyncResult* r, Block1Data* _data1_) {
	BackendLoadingTests * self;
	FolksBackendStore* _tmp0_;
	GAsyncResult* _tmp1_;
	self = _data1_->self;
	g_return_if_fail (r != NULL);
	_tmp0_ = _data1_->store;
	_tmp1_ = r;
	folks_backend_store_prepare_finish (_tmp0_, _tmp1_);
}


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


static void _lambda1_ (GObject* o, GAsyncResult* r, Block1Data* _data1_) {
	BackendLoadingTests * self;
	GError * _inner_error_ = NULL;
	self = _data1_->self;
	g_return_if_fail (r != NULL);
	{
		FolksBackendStore* _tmp0_;
		GAsyncResult* _tmp1_;
		GeeHashSet* _tmp23_;
		gint _tmp24_;
		gint _tmp25_;
		GMainLoop* _tmp26_;
		_tmp0_ = _data1_->store;
		_tmp1_ = r;
		folks_backend_store_load_backends_finish (_tmp0_, _tmp1_, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch1_g_error;
		}
		{
			FolksBackendStore* _tmp2_;
			GeeMap* _tmp3_;
			GeeMap* _tmp4_;
			GeeCollection* _tmp5_;
			GeeCollection* _tmp6_;
			GeeCollection* _tmp7_;
			GeeIterator* _tmp8_ = NULL;
			GeeIterator* _tmp9_;
			GeeIterator* _backend_it;
			_tmp2_ = _data1_->store;
			_tmp3_ = folks_backend_store_get_enabled_backends (_tmp2_);
			_tmp4_ = _tmp3_;
			_tmp5_ = gee_map_get_values (_tmp4_);
			_tmp6_ = _tmp5_;
			_tmp7_ = _tmp6_;
			_tmp8_ = gee_iterable_iterator ((GeeIterable*) _tmp7_);
			_tmp9_ = _tmp8_;
			_g_object_unref0 (_tmp7_);
			_backend_it = _tmp9_;
			while (TRUE) {
				GeeIterator* _tmp10_;
				gboolean _tmp11_ = FALSE;
				GeeIterator* _tmp12_;
				gpointer _tmp13_ = NULL;
				FolksBackend* backend;
				GeeHashSet* _tmp14_;
				FolksBackend* _tmp15_;
				const gchar* _tmp16_;
				const gchar* _tmp17_;
				gboolean _tmp18_ = FALSE;
				GeeHashSet* _tmp19_;
				FolksBackend* _tmp20_;
				const gchar* _tmp21_;
				const gchar* _tmp22_;
				_tmp10_ = _backend_it;
				_tmp11_ = gee_iterator_next (_tmp10_);
				if (!_tmp11_) {
					break;
				}
				_tmp12_ = _backend_it;
				_tmp13_ = gee_iterator_get (_tmp12_);
				backend = (FolksBackend*) _tmp13_;
				_tmp14_ = _data1_->backends_expected;
				_tmp15_ = backend;
				_tmp16_ = folks_backend_get_name (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp14_, _tmp17_);
				g_assert (_tmp18_);
				_tmp19_ = _data1_->backends_expected;
				_tmp20_ = backend;
				_tmp21_ = folks_backend_get_name (_tmp20_);
				_tmp22_ = _tmp21_;
				gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp19_, _tmp22_);
				_g_object_unref0 (backend);
			}
			_g_object_unref0 (_backend_it);
		}
		_tmp23_ = _data1_->backends_expected;
		_tmp24_ = gee_collection_get_size ((GeeCollection*) _tmp23_);
		_tmp25_ = _tmp24_;
		g_assert (_tmp25_ == 0);
		_tmp26_ = _data1_->main_loop;
		g_main_loop_quit (_tmp26_);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp27_;
		const gchar* _tmp28_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp27_ = e;
		_tmp28_ = _tmp27_->message;
		g_error ("backend-loading.vala:116: Failed to load backends: %s", _tmp28_);
		_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 void __lambda1__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
	_lambda1_ (source_object, res, self);
	block1_data_unref (self);
}


void backend_loading_tests_test_load_and_prep (BackendLoadingTests* self) {
	Block1Data* _data1_;
	GMainLoop* _tmp0_;
	GHashFunc _tmp1_;
	GEqualFunc _tmp2_;
	GeeHashSet* _tmp3_;
	GeeHashSet* _tmp4_;
	GeeHashSet* _tmp5_;
	FolksBackendStore* _tmp6_ = NULL;
	FolksBackendStore* _tmp7_;
	FolksBackendStore* _tmp8_;
	GMainLoop* _tmp9_;
	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_ = g_str_hash;
	_tmp2_ = g_str_equal;
	_tmp3_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _tmp1_, _tmp2_);
	_data1_->backends_expected = _tmp3_;
	_tmp4_ = _data1_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp4_, "key-file");
	_tmp5_ = _data1_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp5_, "telepathy");
	_tmp6_ = folks_backend_store_dup ();
	_data1_->store = _tmp6_;
	_tmp7_ = _data1_->store;
	folks_backend_store_prepare (_tmp7_, __lambda0__gasync_ready_callback, block1_data_ref (_data1_));
	_tmp8_ = _data1_->store;
	folks_backend_store_load_backends (_tmp8_, __lambda1__gasync_ready_callback, block1_data_ref (_data1_));
	_tmp9_ = _data1_->main_loop;
	g_main_loop_run (_tmp9_);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}


static void _lambda2_ (GObject* o, GAsyncResult* r, BackendLoadingTests* self) {
	GAsyncResult* _tmp0_;
	g_return_if_fail (r != NULL);
	_tmp0_ = r;
	backend_loading_tests_test_disabling_finish (self, _tmp0_);
}


static void __lambda2__gasync_ready_callback (GObject* source_object, GAsyncResult* res, gpointer self) {
	_lambda2_ (source_object, res, self);
	g_object_unref (self);
}


void backend_loading_tests_test_disabling (BackendLoadingTests* self) {
	GMainLoop* _tmp0_;
	FolksBackendStore* _tmp1_ = NULL;
	FolksBackendStore* store;
	FolksBackendStore* _tmp2_;
	GMainLoop* _tmp3_;
	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_ = folks_backend_store_dup ();
	store = _tmp1_;
	_tmp2_ = store;
	backend_loading_tests_test_disabling_async (self, _tmp2_, __lambda2__gasync_ready_callback, g_object_ref (self));
	_tmp3_ = self->priv->main_loop;
	g_main_loop_run (_tmp3_);
	_g_object_unref0 (store);
}


static void backend_loading_tests_test_disabling_async_data_free (gpointer _data) {
	BackendLoadingTestsTestDisablingAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->store);
	_g_object_unref0 (_data_->self);
	g_slice_free (BackendLoadingTestsTestDisablingAsyncData, _data_);
}


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


static void backend_loading_tests_test_disabling_async (BackendLoadingTests* self, FolksBackendStore* store, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	BackendLoadingTestsTestDisablingAsyncData* _data_;
	BackendLoadingTests* _tmp0_;
	FolksBackendStore* _tmp1_;
	FolksBackendStore* _tmp2_;
	_data_ = g_slice_new0 (BackendLoadingTestsTestDisablingAsyncData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, backend_loading_tests_test_disabling_async);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, backend_loading_tests_test_disabling_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = store;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data_->store = _tmp2_;
	backend_loading_tests_test_disabling_async_co (_data_);
}


static void backend_loading_tests_test_disabling_finish (BackendLoadingTests* self, GAsyncResult* _res_) {
	BackendLoadingTestsTestDisablingAsyncData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void backend_loading_tests_test_disabling_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	BackendLoadingTestsTestDisablingAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	backend_loading_tests_test_disabling_async_co (_data_);
}


static gboolean backend_loading_tests_test_disabling_async_co (BackendLoadingTestsTestDisablingAsyncData* _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_ = g_str_hash;
	_data_->_tmp1_ = g_str_equal;
	_data_->_tmp2_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _data_->_tmp0_, _data_->_tmp1_);
	_data_->backends_expected = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp3_, "key-file");
	_data_->_tmp4_ = _data_->store;
	_data_->_state_ = 1;
	folks_backend_store_prepare (_data_->_tmp4_, backend_loading_tests_test_disabling_async_ready, _data_);
	return FALSE;
	_state_1:
	folks_backend_store_prepare_finish (_data_->_tmp4_, _data_->_res_);
	_data_->_tmp5_ = _data_->store;
	_data_->_state_ = 2;
	folks_backend_store_disable_backend (_data_->_tmp5_, "telepathy", backend_loading_tests_test_disabling_async_ready, _data_);
	return FALSE;
	_state_2:
	folks_backend_store_disable_backend_finish (_data_->_tmp5_, _data_->_res_);
	{
		_data_->_tmp6_ = _data_->store;
		_data_->_state_ = 3;
		folks_backend_store_load_backends (_data_->_tmp6_, backend_loading_tests_test_disabling_async_ready, _data_);
		return FALSE;
		_state_3:
		folks_backend_store_load_backends_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch2_g_error;
		}
		{
			_data_->_tmp7_ = _data_->store;
			_data_->_tmp8_ = folks_backend_store_get_enabled_backends (_data_->_tmp7_);
			_data_->_tmp9_ = _data_->_tmp8_;
			_data_->_tmp10_ = gee_map_get_values (_data_->_tmp9_);
			_data_->_tmp11_ = _data_->_tmp10_;
			_data_->_tmp12_ = _data_->_tmp11_;
			_data_->_tmp13_ = NULL;
			_data_->_tmp13_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp12_);
			_data_->_tmp14_ = _data_->_tmp13_;
			_g_object_unref0 (_data_->_tmp12_);
			_data_->_backend_it = _data_->_tmp14_;
			while (TRUE) {
				_data_->_tmp15_ = _data_->_backend_it;
				_data_->_tmp16_ = FALSE;
				_data_->_tmp16_ = gee_iterator_next (_data_->_tmp15_);
				if (!_data_->_tmp16_) {
					break;
				}
				_data_->_tmp17_ = _data_->_backend_it;
				_data_->_tmp18_ = NULL;
				_data_->_tmp18_ = gee_iterator_get (_data_->_tmp17_);
				_data_->backend = (FolksBackend*) _data_->_tmp18_;
				_data_->_tmp19_ = _data_->backends_expected;
				_data_->_tmp20_ = _data_->backend;
				_data_->_tmp21_ = folks_backend_get_name (_data_->_tmp20_);
				_data_->_tmp22_ = _data_->_tmp21_;
				_data_->_tmp23_ = FALSE;
				_data_->_tmp23_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _data_->_tmp19_, _data_->_tmp22_);
				g_assert (_data_->_tmp23_);
				_data_->_tmp24_ = _data_->backends_expected;
				_data_->_tmp25_ = _data_->backend;
				_data_->_tmp26_ = folks_backend_get_name (_data_->_tmp25_);
				_data_->_tmp27_ = _data_->_tmp26_;
				gee_abstract_collection_remove ((GeeAbstractCollection*) _data_->_tmp24_, _data_->_tmp27_);
				_g_object_unref0 (_data_->backend);
			}
			_g_object_unref0 (_data_->_backend_it);
		}
		_data_->_tmp28_ = _data_->backends_expected;
		_data_->_tmp29_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp28_);
		_data_->_tmp30_ = _data_->_tmp29_;
		g_assert (_data_->_tmp30_ == 0);
		_data_->_tmp31_ = _data_->self->priv->main_loop;
		g_main_loop_quit (_data_->_tmp31_);
	}
	goto __finally2;
	__catch2_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp32_ = _data_->e;
		_data_->_tmp33_ = _data_->_tmp32_->message;
		g_error ("backend-loading.vala:160: Failed to load backends: %s", _data_->_tmp33_);
		_g_error_free0 (_data_->e);
	}
	__finally2:
	if (_data_->_inner_error_ != NULL) {
		_g_object_unref0 (_data_->backends_expected);
		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_->backends_expected);
	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 _lambda3_ (GObject* o, GAsyncResult* r, BackendLoadingTests* self) {
	GAsyncResult* _tmp0_;
	g_return_if_fail (r != NULL);
	_tmp0_ = r;
	backend_loading_tests_test_reloading_finish (self, _tmp0_);
}


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


void backend_loading_tests_test_reloading (BackendLoadingTests* self) {
	GMainLoop* _tmp0_;
	FolksBackendStore* _tmp1_ = NULL;
	FolksBackendStore* store;
	FolksBackendStore* _tmp2_;
	GMainLoop* _tmp3_;
	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_ = folks_backend_store_dup ();
	store = _tmp1_;
	_tmp2_ = store;
	backend_loading_tests_test_reloading_async (self, _tmp2_, __lambda3__gasync_ready_callback, g_object_ref (self));
	_tmp3_ = self->priv->main_loop;
	g_main_loop_run (_tmp3_);
	_g_object_unref0 (store);
}


static void backend_loading_tests_test_reloading_async_data_free (gpointer _data) {
	BackendLoadingTestsTestReloadingAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->store);
	_g_object_unref0 (_data_->self);
	g_slice_free (BackendLoadingTestsTestReloadingAsyncData, _data_);
}


static void backend_loading_tests_test_reloading_async (BackendLoadingTests* self, FolksBackendStore* store, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	BackendLoadingTestsTestReloadingAsyncData* _data_;
	BackendLoadingTests* _tmp0_;
	FolksBackendStore* _tmp1_;
	FolksBackendStore* _tmp2_;
	_data_ = g_slice_new0 (BackendLoadingTestsTestReloadingAsyncData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, backend_loading_tests_test_reloading_async);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, backend_loading_tests_test_reloading_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = store;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_data_->store = _tmp2_;
	backend_loading_tests_test_reloading_async_co (_data_);
}


static void backend_loading_tests_test_reloading_finish (BackendLoadingTests* self, GAsyncResult* _res_) {
	BackendLoadingTestsTestReloadingAsyncData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void backend_loading_tests_test_reloading_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	BackendLoadingTestsTestReloadingAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	backend_loading_tests_test_reloading_async_co (_data_);
}


static gboolean backend_loading_tests_test_reloading_async_co (BackendLoadingTestsTestReloadingAsyncData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		case 5:
		goto _state_5;
		case 6:
		goto _state_6;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_str_hash;
	_data_->_tmp1_ = g_str_equal;
	_data_->_tmp2_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _data_->_tmp0_, _data_->_tmp1_);
	_g_object_unref0 (_data_->backends_expected);
	_data_->backends_expected = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp3_, "key-file");
	_data_->_tmp4_ = _data_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp4_, "telepathy");
	{
		_data_->_tmp5_ = _data_->store;
		_data_->_state_ = 1;
		folks_backend_store_load_backends (_data_->_tmp5_, backend_loading_tests_test_reloading_async_ready, _data_);
		return FALSE;
		_state_1:
		folks_backend_store_load_backends_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch3_g_error;
		}
		{
			_data_->_tmp6_ = _data_->store;
			_data_->_tmp7_ = folks_backend_store_get_enabled_backends (_data_->_tmp6_);
			_data_->_tmp8_ = _data_->_tmp7_;
			_data_->_tmp9_ = gee_map_get_values (_data_->_tmp8_);
			_data_->_tmp10_ = _data_->_tmp9_;
			_data_->_tmp11_ = _data_->_tmp10_;
			_data_->_tmp12_ = NULL;
			_data_->_tmp12_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp11_);
			_data_->_tmp13_ = _data_->_tmp12_;
			_g_object_unref0 (_data_->_tmp11_);
			_data_->_backend1_it = _data_->_tmp13_;
			while (TRUE) {
				_data_->_tmp14_ = _data_->_backend1_it;
				_data_->_tmp15_ = FALSE;
				_data_->_tmp15_ = gee_iterator_next (_data_->_tmp14_);
				if (!_data_->_tmp15_) {
					break;
				}
				_data_->_tmp16_ = _data_->_backend1_it;
				_data_->_tmp17_ = NULL;
				_data_->_tmp17_ = gee_iterator_get (_data_->_tmp16_);
				_data_->backend1 = (FolksBackend*) _data_->_tmp17_;
				_data_->_tmp18_ = _data_->backends_expected;
				_data_->_tmp19_ = _data_->backend1;
				_data_->_tmp20_ = folks_backend_get_name (_data_->_tmp19_);
				_data_->_tmp21_ = _data_->_tmp20_;
				_data_->_tmp22_ = FALSE;
				_data_->_tmp22_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _data_->_tmp18_, _data_->_tmp21_);
				g_assert (_data_->_tmp22_);
				_data_->_tmp23_ = _data_->backends_expected;
				_data_->_tmp24_ = _data_->backend1;
				_data_->_tmp25_ = folks_backend_get_name (_data_->_tmp24_);
				_data_->_tmp26_ = _data_->_tmp25_;
				gee_abstract_collection_remove ((GeeAbstractCollection*) _data_->_tmp23_, _data_->_tmp26_);
				_g_object_unref0 (_data_->backend1);
			}
			_g_object_unref0 (_data_->_backend1_it);
		}
		_data_->_tmp27_ = _data_->backends_expected;
		_data_->_tmp28_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp27_);
		_data_->_tmp29_ = _data_->_tmp28_;
		g_assert (_data_->_tmp29_ == 0);
	}
	goto __finally3;
	__catch3_g_error:
	{
		_data_->e1 = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp30_ = _data_->e1;
		_data_->_tmp31_ = _data_->_tmp30_->message;
		g_error ("backend-loading.vala:202: Failed to load backends: %s", _data_->_tmp31_);
		_g_error_free0 (_data_->e1);
	}
	__finally3:
	if (_data_->_inner_error_ != NULL) {
		_g_object_unref0 (_data_->backends_expected);
		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;
	}
	_data_->_tmp32_ = g_str_hash;
	_data_->_tmp33_ = g_str_equal;
	_data_->_tmp34_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _data_->_tmp32_, _data_->_tmp33_);
	_g_object_unref0 (_data_->backends_expected);
	_data_->backends_expected = _data_->_tmp34_;
	_data_->_tmp35_ = _data_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp35_, "telepathy");
	_data_->_tmp36_ = _data_->store;
	_data_->_state_ = 2;
	folks_backend_store_disable_backend (_data_->_tmp36_, "key-file", backend_loading_tests_test_reloading_async_ready, _data_);
	return FALSE;
	_state_2:
	folks_backend_store_disable_backend_finish (_data_->_tmp36_, _data_->_res_);
	{
		_data_->_tmp37_ = _data_->store;
		_data_->_state_ = 3;
		folks_backend_store_load_backends (_data_->_tmp37_, backend_loading_tests_test_reloading_async_ready, _data_);
		return FALSE;
		_state_3:
		folks_backend_store_load_backends_finish (_data_->_tmp37_, _data_->_res_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch4_g_error;
		}
		{
			_data_->_tmp38_ = _data_->store;
			_data_->_tmp39_ = folks_backend_store_get_enabled_backends (_data_->_tmp38_);
			_data_->_tmp40_ = _data_->_tmp39_;
			_data_->_tmp41_ = gee_map_get_values (_data_->_tmp40_);
			_data_->_tmp42_ = _data_->_tmp41_;
			_data_->_tmp43_ = _data_->_tmp42_;
			_data_->_tmp44_ = NULL;
			_data_->_tmp44_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp43_);
			_data_->_tmp45_ = _data_->_tmp44_;
			_g_object_unref0 (_data_->_tmp43_);
			_data_->_backend2_it = _data_->_tmp45_;
			while (TRUE) {
				_data_->_tmp46_ = _data_->_backend2_it;
				_data_->_tmp47_ = FALSE;
				_data_->_tmp47_ = gee_iterator_next (_data_->_tmp46_);
				if (!_data_->_tmp47_) {
					break;
				}
				_data_->_tmp48_ = _data_->_backend2_it;
				_data_->_tmp49_ = NULL;
				_data_->_tmp49_ = gee_iterator_get (_data_->_tmp48_);
				_data_->backend2 = (FolksBackend*) _data_->_tmp49_;
				_data_->_tmp50_ = _data_->backends_expected;
				_data_->_tmp51_ = _data_->backend2;
				_data_->_tmp52_ = folks_backend_get_name (_data_->_tmp51_);
				_data_->_tmp53_ = _data_->_tmp52_;
				_data_->_tmp54_ = FALSE;
				_data_->_tmp54_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _data_->_tmp50_, _data_->_tmp53_);
				g_assert (_data_->_tmp54_);
				_data_->_tmp55_ = _data_->backends_expected;
				_data_->_tmp56_ = _data_->backend2;
				_data_->_tmp57_ = folks_backend_get_name (_data_->_tmp56_);
				_data_->_tmp58_ = _data_->_tmp57_;
				gee_abstract_collection_remove ((GeeAbstractCollection*) _data_->_tmp55_, _data_->_tmp58_);
				_g_object_unref0 (_data_->backend2);
			}
			_g_object_unref0 (_data_->_backend2_it);
		}
		_data_->_tmp59_ = _data_->backends_expected;
		_data_->_tmp60_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp59_);
		_data_->_tmp61_ = _data_->_tmp60_;
		g_assert (_data_->_tmp61_ == 0);
	}
	goto __finally4;
	__catch4_g_error:
	{
		_data_->e2 = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp62_ = _data_->e2;
		_data_->_tmp63_ = _data_->_tmp62_->message;
		g_error ("backend-loading.vala:229: Failed to load backends: %s", _data_->_tmp63_);
		_g_error_free0 (_data_->e2);
	}
	__finally4:
	if (_data_->_inner_error_ != NULL) {
		_g_object_unref0 (_data_->backends_expected);
		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;
	}
	_data_->_tmp64_ = g_str_hash;
	_data_->_tmp65_ = g_str_equal;
	_data_->_tmp66_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _data_->_tmp64_, _data_->_tmp65_);
	_g_object_unref0 (_data_->backends_expected);
	_data_->backends_expected = _data_->_tmp66_;
	_data_->_tmp67_ = _data_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp67_, "key-file");
	_data_->_tmp68_ = _data_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp68_, "telepathy");
	_data_->_tmp69_ = _data_->store;
	_data_->_state_ = 4;
	folks_backend_store_enable_backend (_data_->_tmp69_, "key-file", backend_loading_tests_test_reloading_async_ready, _data_);
	return FALSE;
	_state_4:
	folks_backend_store_enable_backend_finish (_data_->_tmp69_, _data_->_res_);
	{
		_data_->_tmp70_ = _data_->store;
		_data_->_state_ = 5;
		folks_backend_store_load_backends (_data_->_tmp70_, backend_loading_tests_test_reloading_async_ready, _data_);
		return FALSE;
		_state_5:
		folks_backend_store_load_backends_finish (_data_->_tmp70_, _data_->_res_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch5_g_error;
		}
		{
			_data_->_tmp71_ = _data_->store;
			_data_->_tmp72_ = folks_backend_store_get_enabled_backends (_data_->_tmp71_);
			_data_->_tmp73_ = _data_->_tmp72_;
			_data_->_tmp74_ = gee_map_get_values (_data_->_tmp73_);
			_data_->_tmp75_ = _data_->_tmp74_;
			_data_->_tmp76_ = _data_->_tmp75_;
			_data_->_tmp77_ = NULL;
			_data_->_tmp77_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp76_);
			_data_->_tmp78_ = _data_->_tmp77_;
			_g_object_unref0 (_data_->_tmp76_);
			_data_->_backend3_it = _data_->_tmp78_;
			while (TRUE) {
				_data_->_tmp79_ = _data_->_backend3_it;
				_data_->_tmp80_ = FALSE;
				_data_->_tmp80_ = gee_iterator_next (_data_->_tmp79_);
				if (!_data_->_tmp80_) {
					break;
				}
				_data_->_tmp81_ = _data_->_backend3_it;
				_data_->_tmp82_ = NULL;
				_data_->_tmp82_ = gee_iterator_get (_data_->_tmp81_);
				_data_->backend3 = (FolksBackend*) _data_->_tmp82_;
				_data_->_tmp83_ = _data_->backends_expected;
				_data_->_tmp84_ = _data_->backend3;
				_data_->_tmp85_ = folks_backend_get_name (_data_->_tmp84_);
				_data_->_tmp86_ = _data_->_tmp85_;
				_data_->_tmp87_ = FALSE;
				_data_->_tmp87_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _data_->_tmp83_, _data_->_tmp86_);
				g_assert (_data_->_tmp87_);
				_data_->_tmp88_ = _data_->backends_expected;
				_data_->_tmp89_ = _data_->backend3;
				_data_->_tmp90_ = folks_backend_get_name (_data_->_tmp89_);
				_data_->_tmp91_ = _data_->_tmp90_;
				gee_abstract_collection_remove ((GeeAbstractCollection*) _data_->_tmp88_, _data_->_tmp91_);
				_g_object_unref0 (_data_->backend3);
			}
			_g_object_unref0 (_data_->_backend3_it);
		}
		_data_->_tmp92_ = _data_->backends_expected;
		_data_->_tmp93_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp92_);
		_data_->_tmp94_ = _data_->_tmp93_;
		g_assert (_data_->_tmp94_ == 0);
	}
	goto __finally5;
	__catch5_g_error:
	{
		_data_->e3 = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp95_ = _data_->e3;
		_data_->_tmp96_ = _data_->_tmp95_->message;
		g_error ("backend-loading.vala:257: Failed to load backends: %s", _data_->_tmp96_);
		_g_error_free0 (_data_->e3);
	}
	__finally5:
	if (_data_->_inner_error_ != NULL) {
		_g_object_unref0 (_data_->backends_expected);
		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;
	}
	_data_->_tmp97_ = g_str_hash;
	_data_->_tmp98_ = g_str_equal;
	_data_->_tmp99_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _data_->_tmp97_, _data_->_tmp98_);
	_g_object_unref0 (_data_->backends_expected);
	_data_->backends_expected = _data_->_tmp99_;
	_data_->_tmp100_ = _data_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp100_, "key-file");
	_data_->_tmp101_ = _data_->backends_expected;
	gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp101_, "telepathy");
	{
		_data_->_tmp102_ = _data_->store;
		_data_->_state_ = 6;
		folks_backend_store_load_backends (_data_->_tmp102_, backend_loading_tests_test_reloading_async_ready, _data_);
		return FALSE;
		_state_6:
		folks_backend_store_load_backends_finish (_data_->_tmp102_, _data_->_res_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch6_g_error;
		}
		{
			_data_->_tmp103_ = _data_->store;
			_data_->_tmp104_ = folks_backend_store_get_enabled_backends (_data_->_tmp103_);
			_data_->_tmp105_ = _data_->_tmp104_;
			_data_->_tmp106_ = gee_map_get_values (_data_->_tmp105_);
			_data_->_tmp107_ = _data_->_tmp106_;
			_data_->_tmp108_ = _data_->_tmp107_;
			_data_->_tmp109_ = NULL;
			_data_->_tmp109_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp108_);
			_data_->_tmp110_ = _data_->_tmp109_;
			_g_object_unref0 (_data_->_tmp108_);
			_data_->_backend_it = _data_->_tmp110_;
			while (TRUE) {
				_data_->_tmp111_ = _data_->_backend_it;
				_data_->_tmp112_ = FALSE;
				_data_->_tmp112_ = gee_iterator_next (_data_->_tmp111_);
				if (!_data_->_tmp112_) {
					break;
				}
				_data_->_tmp113_ = _data_->_backend_it;
				_data_->_tmp114_ = NULL;
				_data_->_tmp114_ = gee_iterator_get (_data_->_tmp113_);
				_data_->backend = (FolksBackend*) _data_->_tmp114_;
				_data_->_tmp115_ = _data_->backends_expected;
				_data_->_tmp116_ = _data_->backend;
				_data_->_tmp117_ = folks_backend_get_name (_data_->_tmp116_);
				_data_->_tmp118_ = _data_->_tmp117_;
				_data_->_tmp119_ = FALSE;
				_data_->_tmp119_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _data_->_tmp115_, _data_->_tmp118_);
				g_assert (_data_->_tmp119_);
				_data_->_tmp120_ = _data_->backends_expected;
				_data_->_tmp121_ = _data_->backend;
				_data_->_tmp122_ = folks_backend_get_name (_data_->_tmp121_);
				_data_->_tmp123_ = _data_->_tmp122_;
				gee_abstract_collection_remove ((GeeAbstractCollection*) _data_->_tmp120_, _data_->_tmp123_);
				_g_object_unref0 (_data_->backend);
			}
			_g_object_unref0 (_data_->_backend_it);
		}
		_data_->_tmp124_ = _data_->backends_expected;
		_data_->_tmp125_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp124_);
		_data_->_tmp126_ = _data_->_tmp125_;
		g_assert (_data_->_tmp126_ == 0);
	}
	goto __finally6;
	__catch6_g_error:
	{
		_data_->e4 = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp127_ = _data_->e4;
		_data_->_tmp128_ = _data_->_tmp127_->message;
		g_error ("backend-loading.vala:283: Failed to load backends: %s", _data_->_tmp128_);
		_g_error_free0 (_data_->e4);
	}
	__finally6:
	if (_data_->_inner_error_ != NULL) {
		_g_object_unref0 (_data_->backends_expected);
		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;
	}
	_data_->_tmp129_ = _data_->self->priv->main_loop;
	g_main_loop_quit (_data_->_tmp129_);
	_g_object_unref0 (_data_->backends_expected);
	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 backend_loading_tests_class_init (BackendLoadingTestsClass * klass) {
	backend_loading_tests_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (BackendLoadingTestsPrivate));
	FOLKS_TEST_CASE_CLASS (klass)->set_up = backend_loading_tests_real_set_up;
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = backend_loading_tests_real_tear_down;
	G_OBJECT_CLASS (klass)->finalize = backend_loading_tests_finalize;
}


static void backend_loading_tests_instance_init (BackendLoadingTests * self) {
	self->priv = BACKEND_LOADING_TESTS_GET_PRIVATE (self);
}


static void backend_loading_tests_finalize (GObject* obj) {
	BackendLoadingTests * self;
	self = BACKEND_LOADING_TESTS (obj);
	_g_object_unref0 (self->priv->_tp_backend);
	_g_main_loop_unref0 (self->priv->main_loop);
	G_OBJECT_CLASS (backend_loading_tests_parent_class)->finalize (obj);
}


GType backend_loading_tests_get_type (void) {
	static volatile gsize backend_loading_tests_type_id__volatile = 0;
	if (g_once_init_enter (&backend_loading_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BackendLoadingTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) backend_loading_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BackendLoadingTests), 0, (GInstanceInitFunc) backend_loading_tests_instance_init, NULL };
		GType backend_loading_tests_type_id;
		backend_loading_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "BackendLoadingTests", &g_define_type_info, 0);
		g_once_init_leave (&backend_loading_tests_type_id__volatile, backend_loading_tests_type_id);
	}
	return backend_loading_tests_type_id__volatile;
}


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



