/* data-source-stuff.c generated by valac 0.48.11, the Vala compiler
 * generated from data-source-stuff.vala, do not modify */

#include <glib.h>
#include <gio/gio.h>
#include "zeitgeist.h"
#include "zeitgeist-datamodel.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#define _g_ptr_array_unref0(var) ((var == NULL) ? NULL : (var = (g_ptr_array_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _DoStuffData DoStuffData;
#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 _OnSourceEnabledData OnSourceEnabledData;
typedef struct _PrintDataSourcesData PrintDataSourcesData;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))

struct _DoStuffData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ZeitgeistDataSourceRegistry* registry;
	ZeitgeistDataSourceRegistry* _tmp0_;
	ZeitgeistDataSourceRegistry* _tmp1_;
	ZeitgeistDataSourceRegistry* _tmp2_;
	ZeitgeistDataSource* my_data_source;
	GPtrArray* _tmp3_;
	GPtrArray* _tmp4_;
	ZeitgeistDataSource* _tmp5_;
	ZeitgeistDataSource* _tmp6_;
	FILE* _tmp7_;
	gboolean enabled;
	ZeitgeistDataSourceRegistry* _tmp8_;
	ZeitgeistDataSource* _tmp9_;
	const gchar* _tmp10_;
	FILE* _tmp11_;
	FILE* _tmp12_;
	ZeitgeistDataSourceRegistry* _tmp13_;
	ZeitgeistDataSource* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	ZeitgeistDataSourceRegistry* _tmp17_;
	FILE* _tmp18_;
	ZeitgeistDataSourceRegistry* _tmp19_;
	ZeitgeistDataSource* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	ZeitgeistDataSourceRegistry* _tmp23_;
	GMainLoop* _tmp24_;
	GError* _inner_error0_;
};

struct _OnSourceEnabledData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gchar* unique_id;
	gboolean enabled;
	ZeitgeistDataSourceRegistry* registry;
	ZeitgeistDataSourceRegistry* _tmp0_;
	ZeitgeistDataSource* source;
	ZeitgeistDataSource* _tmp1_;
	ZeitgeistDataSource* _tmp2_;
	ZeitgeistDataSource* _tmp3_;
	const gchar* _tmp4_;
	FILE* _tmp5_;
	ZeitgeistDataSource* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	GError* e;
	GError* _tmp9_;
	const gchar* _tmp10_;
	GError* _inner_error0_;
};

struct _PrintDataSourcesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ZeitgeistDataSourceRegistry* registry;
	GPtrArray* datasources;
	GPtrArray* _tmp0_;
	GPtrArray* _tmp1_;
	GPtrArray* _tmp2_;
	FILE* _tmp3_;
	gint i;
	gboolean _tmp4_;
	gint _tmp5_;
	GPtrArray* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	ZeitgeistDataSource* datasource;
	GPtrArray* _tmp9_;
	gconstpointer _tmp10_;
	ZeitgeistDataSource* _tmp11_;
	const gchar* _tmp12_;
	ZeitgeistDataSource* _tmp13_;
	gboolean _tmp14_;
	gboolean _tmp15_;
	FILE* _tmp16_;
	ZeitgeistDataSource* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	GError* _inner_error0_;
};

extern GMainLoop* loop;
GMainLoop* loop = NULL;

static void do_stuff_data_free (gpointer _data);
void do_stuff (GAsyncReadyCallback _callback_,
               gpointer _user_data_);
void do_stuff_finish (GAsyncResult* _res_,
                      GError** error);
static gboolean do_stuff_co (DoStuffData* _data_);
void on_source_registered (ZeitgeistDataSource* source);
static void _on_source_registered_zeitgeist_data_source_registry_source_registered (ZeitgeistDataSourceRegistry* _sender,
                                                                             ZeitgeistDataSource* data_source,
                                                                             gpointer self);
void on_source_enabled (const gchar* unique_id,
                        gboolean enabled,
                        GAsyncReadyCallback _callback_,
                        gpointer _user_data_);
void on_source_enabled_finish (GAsyncResult* _res_);
static void _on_source_enabled_zeitgeist_data_source_registry_source_enabled (ZeitgeistDataSourceRegistry* _sender,
                                                                       const gchar* unique_id,
                                                                       gboolean enabled,
                                                                       gpointer self);
static void _g_object_unref0_ (gpointer var);
static void do_stuff_ready (GObject* source_object,
                     GAsyncResult* _res_,
                     gpointer _user_data_);
void print_data_sources (ZeitgeistDataSourceRegistry* registry,
                         GAsyncReadyCallback _callback_,
                         gpointer _user_data_);
void print_data_sources_finish (GAsyncResult* _res_,
                                GError** error);
static void on_source_enabled_data_free (gpointer _data);
static gboolean on_source_enabled_co (OnSourceEnabledData* _data_);
static void on_source_enabled_ready (GObject* source_object,
                              GAsyncResult* _res_,
                              gpointer _user_data_);
static void print_data_sources_data_free (gpointer _data);
static gboolean print_data_sources_co (PrintDataSourcesData* _data_);
static void print_data_sources_ready (GObject* source_object,
                               GAsyncResult* _res_,
                               gpointer _user_data_);
gint _vala_main (void);

static void
do_stuff_data_free (gpointer _data)
{
	DoStuffData* _data_;
	_data_ = _data;
	g_slice_free (DoStuffData, _data_);
}

void
do_stuff (GAsyncReadyCallback _callback_,
          gpointer _user_data_)
{
	DoStuffData* _data_;
	_data_ = g_slice_new0 (DoStuffData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, do_stuff_data_free);
	do_stuff_co (_data_);
}

void
do_stuff_finish (GAsyncResult* _res_,
                 GError** error)
{
	DoStuffData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
_on_source_registered_zeitgeist_data_source_registry_source_registered (ZeitgeistDataSourceRegistry* _sender,
                                                                        ZeitgeistDataSource* data_source,
                                                                        gpointer self)
{
	on_source_registered (data_source);
}

static void
_on_source_enabled_zeitgeist_data_source_registry_source_enabled (ZeitgeistDataSourceRegistry* _sender,
                                                                  const gchar* unique_id,
                                                                  gboolean enabled,
                                                                  gpointer self)
{
	on_source_enabled (unique_id, enabled, NULL, NULL);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static void
do_stuff_ready (GObject* source_object,
                GAsyncResult* _res_,
                gpointer _user_data_)
{
	DoStuffData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	do_stuff_co (_data_);
}

static gboolean
do_stuff_co (DoStuffData* _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;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = zeitgeist_data_source_registry_new ();
	_data_->registry = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->registry;
	g_signal_connect (_data_->_tmp1_, "source-registered", (GCallback) _on_source_registered_zeitgeist_data_source_registry_source_registered, NULL);
	_data_->_tmp2_ = _data_->registry;
	g_signal_connect (_data_->_tmp2_, "source-enabled", (GCallback) _on_source_enabled_zeitgeist_data_source_registry_source_enabled, NULL);
	_data_->_tmp3_ = g_ptr_array_new_full ((guint) 0, _g_object_unref0_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = zeitgeist_data_source_new_full ("com.example.test/my-ds", "Example Data-Source", "An example data-source for testing libzeitgeist2", _data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	_g_ptr_array_unref0 (_data_->_tmp4_);
	_data_->my_data_source = _data_->_tmp6_;
	_data_->_tmp7_ = stdout;
	fprintf (_data_->_tmp7_, "Registering with data-source registry...\n");
	_data_->_tmp8_ = _data_->registry;
	_data_->_tmp9_ = _data_->my_data_source;
	_data_->_state_ = 1;
	zeitgeist_data_source_registry_register_data_source (_data_->_tmp8_, _data_->_tmp9_, NULL, do_stuff_ready, _data_);
	return FALSE;
	_state_1:
	_data_->enabled = zeitgeist_data_source_registry_register_data_source_finish (_data_->_tmp8_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->my_data_source);
		_g_object_unref0 (_data_->registry);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	if (_data_->enabled) {
		_data_->_tmp10_ = "enabled";
	} else {
		_data_->_tmp10_ = "disabled";
	}
	_data_->_tmp11_ = stdout;
	fprintf (_data_->_tmp11_, "Done. The data-source is %s.\n\n", _data_->_tmp10_);
	_data_->_tmp12_ = stdout;
	fprintf (_data_->_tmp12_, "Disabling the data-source...\n");
	_data_->_tmp13_ = _data_->registry;
	_data_->_tmp14_ = _data_->my_data_source;
	_data_->_tmp15_ = zeitgeist_data_source_get_unique_id (_data_->_tmp14_);
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_state_ = 2;
	zeitgeist_data_source_registry_set_data_source_enabled (_data_->_tmp13_, _data_->_tmp16_, FALSE, NULL, do_stuff_ready, _data_);
	return FALSE;
	_state_2:
	zeitgeist_data_source_registry_set_data_source_enabled_finish (_data_->_tmp13_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->my_data_source);
		_g_object_unref0 (_data_->registry);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp17_ = _data_->registry;
	_data_->_state_ = 3;
	print_data_sources (_data_->_tmp17_, do_stuff_ready, _data_);
	return FALSE;
	_state_3:
	print_data_sources_finish (_data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->my_data_source);
		_g_object_unref0 (_data_->registry);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp18_ = stdout;
	fprintf (_data_->_tmp18_, "\nEnabling it again...\n");
	_data_->_tmp19_ = _data_->registry;
	_data_->_tmp20_ = _data_->my_data_source;
	_data_->_tmp21_ = zeitgeist_data_source_get_unique_id (_data_->_tmp20_);
	_data_->_tmp22_ = _data_->_tmp21_;
	_data_->_state_ = 4;
	zeitgeist_data_source_registry_set_data_source_enabled (_data_->_tmp19_, _data_->_tmp22_, TRUE, NULL, do_stuff_ready, _data_);
	return FALSE;
	_state_4:
	zeitgeist_data_source_registry_set_data_source_enabled_finish (_data_->_tmp19_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->my_data_source);
		_g_object_unref0 (_data_->registry);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp23_ = _data_->registry;
	_data_->_state_ = 5;
	print_data_sources (_data_->_tmp23_, do_stuff_ready, _data_);
	return FALSE;
	_state_5:
	print_data_sources_finish (_data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->my_data_source);
		_g_object_unref0 (_data_->registry);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp24_ = loop;
	g_main_loop_quit (_data_->_tmp24_);
	_g_object_unref0 (_data_->my_data_source);
	_g_object_unref0 (_data_->registry);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
on_source_registered (ZeitgeistDataSource* source)
{
	FILE* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (source != NULL);
	_tmp0_ = stdout;
	_tmp1_ = zeitgeist_data_source_get_name (source);
	_tmp2_ = _tmp1_;
	fprintf (_tmp0_, "%s registered!\n", _tmp2_);
}

static void
on_source_enabled_data_free (gpointer _data)
{
	OnSourceEnabledData* _data_;
	_data_ = _data;
	_g_free0 (_data_->unique_id);
	g_slice_free (OnSourceEnabledData, _data_);
}

void
on_source_enabled (const gchar* unique_id,
                   gboolean enabled,
                   GAsyncReadyCallback _callback_,
                   gpointer _user_data_)
{
	OnSourceEnabledData* _data_;
	gchar* _tmp0_;
	_data_ = g_slice_new0 (OnSourceEnabledData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, on_source_enabled_data_free);
	_tmp0_ = g_strdup (unique_id);
	_g_free0 (_data_->unique_id);
	_data_->unique_id = _tmp0_;
	_data_->enabled = enabled;
	on_source_enabled_co (_data_);
}

void
on_source_enabled_finish (GAsyncResult* _res_)
{
	OnSourceEnabledData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
on_source_enabled_ready (GObject* source_object,
                         GAsyncResult* _res_,
                         gpointer _user_data_)
{
	OnSourceEnabledData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	on_source_enabled_co (_data_);
}

static gboolean
on_source_enabled_co (OnSourceEnabledData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = zeitgeist_data_source_registry_new ();
	_data_->registry = _data_->_tmp0_;
	{
		_data_->_state_ = 1;
		zeitgeist_data_source_registry_get_data_source_from_id (_data_->registry, _data_->unique_id, NULL, on_source_enabled_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp2_ = zeitgeist_data_source_registry_get_data_source_from_id_finish (_data_->registry, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp2_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp3_ = _data_->_tmp1_;
		_data_->_tmp1_ = NULL;
		_g_object_unref0 (_data_->source);
		_data_->source = _data_->_tmp3_;
		if (_data_->enabled) {
			_data_->_tmp4_ = "enabled";
		} else {
			_data_->_tmp4_ = "disabled";
		}
		_data_->_tmp5_ = stdout;
		_data_->_tmp6_ = _data_->source;
		_data_->_tmp7_ = zeitgeist_data_source_get_name (_data_->_tmp6_);
		_data_->_tmp8_ = _data_->_tmp7_;
		fprintf (_data_->_tmp5_, "%s has been %s!\n", _data_->_tmp8_, _data_->_tmp4_);
		_g_object_unref0 (_data_->_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp9_ = _data_->e;
		_data_->_tmp10_ = _data_->_tmp9_->message;
		g_critical ("data-source-stuff.vala:52: Error retrieving data-source information: %" \
"s", _data_->_tmp10_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->source);
		_g_object_unref0 (_data_->registry);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->source);
	_g_object_unref0 (_data_->registry);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
print_data_sources_data_free (gpointer _data)
{
	PrintDataSourcesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->registry);
	g_slice_free (PrintDataSourcesData, _data_);
}

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

void
print_data_sources (ZeitgeistDataSourceRegistry* registry,
                    GAsyncReadyCallback _callback_,
                    gpointer _user_data_)
{
	PrintDataSourcesData* _data_;
	ZeitgeistDataSourceRegistry* _tmp0_;
	_data_ = g_slice_new0 (PrintDataSourcesData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, print_data_sources_data_free);
	_tmp0_ = _g_object_ref0 (registry);
	_g_object_unref0 (_data_->registry);
	_data_->registry = _tmp0_;
	print_data_sources_co (_data_);
}

void
print_data_sources_finish (GAsyncResult* _res_,
                           GError** error)
{
	PrintDataSourcesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
print_data_sources_ready (GObject* source_object,
                          GAsyncResult* _res_,
                          gpointer _user_data_)
{
	PrintDataSourcesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	print_data_sources_co (_data_);
}

static gint
g_ptr_array_get_length (GPtrArray* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	result = (gint) self->len;
	return result;
}

static void
g_ptr_array_set_length (GPtrArray* self,
                        gint value)
{
	g_return_if_fail (self != NULL);
	g_ptr_array_set_size (self, value);
}

static gboolean
print_data_sources_co (PrintDataSourcesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->datasources = NULL;
	_data_->_state_ = 1;
	zeitgeist_data_source_registry_get_data_sources (_data_->registry, NULL, print_data_sources_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = zeitgeist_data_source_registry_get_data_sources_finish (_data_->registry, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp0_ = _data_->_tmp1_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_ptr_array_unref0 (_data_->datasources);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp2_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_g_ptr_array_unref0 (_data_->datasources);
	_data_->datasources = _data_->_tmp2_;
	_data_->_tmp3_ = stdout;
	fprintf (_data_->_tmp3_, "\nThe following data-sources are registered:\n");
	{
		_data_->i = 0;
		{
			_data_->_tmp4_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp4_) {
					_data_->i = _data_->i + 1;
					_data_->_tmp5_ = _data_->i;
				}
				_data_->_tmp4_ = FALSE;
				_data_->_tmp6_ = _data_->datasources;
				_data_->_tmp7_ = g_ptr_array_get_length (_data_->_tmp6_);
				_data_->_tmp8_ = _data_->_tmp7_;
				if (!(_data_->i < _data_->_tmp8_)) {
					break;
				}
				_data_->_tmp9_ = _data_->datasources;
				_data_->_tmp10_ = g_ptr_array_index (_data_->_tmp9_, (guint) _data_->i);
				_data_->_tmp11_ = _g_object_ref0 ((ZeitgeistDataSource*) _data_->_tmp10_);
				_data_->datasource = _data_->_tmp11_;
				_data_->_tmp13_ = _data_->datasource;
				_data_->_tmp14_ = zeitgeist_data_source_get_enabled (_data_->_tmp13_);
				_data_->_tmp15_ = _data_->_tmp14_;
				if (_data_->_tmp15_) {
					_data_->_tmp12_ = "enabled";
				} else {
					_data_->_tmp12_ = "disabled";
				}
				_data_->_tmp16_ = stdout;
				_data_->_tmp17_ = _data_->datasource;
				_data_->_tmp18_ = zeitgeist_data_source_get_name (_data_->_tmp17_);
				_data_->_tmp19_ = _data_->_tmp18_;
				fprintf (_data_->_tmp16_, " - %s [%s]\n", _data_->_tmp19_, _data_->_tmp12_);
				_g_object_unref0 (_data_->datasource);
			}
		}
	}
	_g_ptr_array_unref0 (_data_->_tmp0_);
	_g_ptr_array_unref0 (_data_->datasources);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

gint
_vala_main (void)
{
	GMainLoop* _tmp0_;
	GMainLoop* _tmp1_;
	gint result = 0;
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (loop);
	loop = _tmp0_;
	do_stuff (NULL, NULL);
	_tmp1_ = loop;
	g_main_loop_run (_tmp1_);
	result = 0;
	return result;
}

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

