/* command-linking.c generated by valac 0.17.6.5-65f99, the Vala compiler
 * generated from command-linking.vala, do not modify */

/*
 * Copyright (C) 2011 Philip Withnall
 *
 * 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:
 *       Philip Withnall <philip@tecnocode.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <folks/folks.h>
#include <stdio.h>
#include <readline/readline.h>


#define FOLKS_INSPECT_TYPE_COMMAND (folks_inspect_command_get_type ())
#define FOLKS_INSPECT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommand))
#define FOLKS_INSPECT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommandClass))
#define FOLKS_INSPECT_IS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_TYPE_COMMAND))
#define FOLKS_INSPECT_IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_TYPE_COMMAND))
#define FOLKS_INSPECT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommandClass))

typedef struct _FolksInspectCommand FolksInspectCommand;
typedef struct _FolksInspectCommandClass FolksInspectCommandClass;
typedef struct _FolksInspectCommandPrivate FolksInspectCommandPrivate;

#define FOLKS_INSPECT_TYPE_CLIENT (folks_inspect_client_get_type ())
#define FOLKS_INSPECT_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClient))
#define FOLKS_INSPECT_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClientClass))
#define FOLKS_INSPECT_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_TYPE_CLIENT))
#define FOLKS_INSPECT_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_TYPE_CLIENT))
#define FOLKS_INSPECT_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClientClass))

typedef struct _FolksInspectClient FolksInspectClient;
typedef struct _FolksInspectClientClass FolksInspectClientClass;

#define FOLKS_INSPECT_COMMANDS_TYPE_LINKING (folks_inspect_commands_linking_get_type ())
#define FOLKS_INSPECT_COMMANDS_LINKING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_COMMANDS_TYPE_LINKING, FolksInspectCommandsLinking))
#define FOLKS_INSPECT_COMMANDS_LINKING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_COMMANDS_TYPE_LINKING, FolksInspectCommandsLinkingClass))
#define FOLKS_INSPECT_COMMANDS_IS_LINKING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_COMMANDS_TYPE_LINKING))
#define FOLKS_INSPECT_COMMANDS_IS_LINKING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_COMMANDS_TYPE_LINKING))
#define FOLKS_INSPECT_COMMANDS_LINKING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_COMMANDS_TYPE_LINKING, FolksInspectCommandsLinkingClass))

typedef struct _FolksInspectCommandsLinking FolksInspectCommandsLinking;
typedef struct _FolksInspectCommandsLinkingClass FolksInspectCommandsLinkingClass;
typedef struct _FolksInspectCommandsLinkingPrivate FolksInspectCommandsLinkingPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _folks_inspect_command_unref0(var) ((var == NULL) ? NULL : (var = (folks_inspect_command_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _FolksInspectCommandsLinkingRunData FolksInspectCommandsLinkingRunData;

struct _FolksInspectCommand {
	GTypeInstance parent_instance;
	volatile int ref_count;
	FolksInspectCommandPrivate * priv;
	FolksInspectClient* client;
};

struct _FolksInspectCommandClass {
	GTypeClass parent_class;
	void (*finalize) (FolksInspectCommand *self);
	void (*run) (FolksInspectCommand* self, const gchar* command_string, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*run_finish) (FolksInspectCommand* self, GAsyncResult* _res_);
	gchar** (*complete_subcommand) (FolksInspectCommand* self, const gchar* subcommand, int* result_length1);
	const gchar* (*get_name) (FolksInspectCommand* self);
	const gchar* (*get_description) (FolksInspectCommand* self);
	const gchar* (*get_help) (FolksInspectCommand* self);
};

struct _FolksInspectCommandsLinking {
	FolksInspectCommand parent_instance;
	FolksInspectCommandsLinkingPrivate * priv;
};

struct _FolksInspectCommandsLinkingClass {
	FolksInspectCommandClass parent_class;
};

struct _FolksInspectCommandsLinkingRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FolksInspectCommandsLinking* self;
	gchar* command_string;
	gchar** _tmp0_;
	gchar** parts;
	gint parts_length1;
	gint _parts_size_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gboolean _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	const gchar* _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	const gchar* _tmp12_;
	gboolean _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	const gchar* _tmp15_;
	gboolean _tmp16_;
	gboolean _tmp17_;
	const gchar* _tmp18_;
	gboolean _tmp19_;
	gchar** _tmp20_;
	gint _tmp20__length1;
	const gchar* _tmp21_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	const gchar* _tmp23_;
	gboolean _tmp24_;
	GeeHashSet* _tmp25_;
	GeeHashSet* personas;
	gchar** _tmp26_;
	gint _tmp26__length1;
	gchar** _tmp27_;
	gint _tmp27__length1;
	const gchar* _tmp28_;
	guint i;
	gboolean _tmp29_;
	gboolean _tmp30_;
	guint _tmp31_;
	guint _tmp32_;
	gchar** _tmp33_;
	gint _tmp33__length1;
	gboolean _tmp34_;
	gchar** _tmp35_;
	gint _tmp35__length1;
	guint _tmp36_;
	const gchar* _tmp37_;
	gchar** _tmp38_;
	gint _tmp38__length1;
	guint _tmp39_;
	const gchar* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	gboolean _tmp43_;
	gchar** _tmp44_;
	gint _tmp44__length1;
	const gchar* _tmp45_;
	gchar** _tmp46_;
	gint _tmp46__length1;
	guint _tmp47_;
	const gchar* _tmp48_;
	gchar** _tmp49_;
	gint _tmp49__length1;
	guint _tmp50_;
	const gchar* _tmp51_;
	gboolean found;
	gchar** _tmp52_;
	gint _tmp52__length1;
	const gchar* _tmp53_;
	gchar** _tmp54_;
	gint _tmp54__length1;
	guint _tmp55_;
	const gchar* _tmp56_;
	gchar* _tmp57_;
	gchar* uid;
	FolksInspectClient* _tmp58_;
	FolksIndividualAggregator* _tmp59_;
	FolksIndividualAggregator* _tmp60_;
	GeeMap* _tmp61_;
	GeeMap* _tmp62_;
	GeeCollection* _tmp63_;
	GeeCollection* _tmp64_;
	GeeCollection* _tmp65_;
	GeeIterator* _tmp66_;
	GeeIterator* _tmp67_;
	GeeIterator* _individual_it;
	GeeIterator* _tmp68_;
	gboolean _tmp69_;
	GeeIterator* _tmp70_;
	gpointer _tmp71_;
	FolksIndividual* individual;
	FolksIndividual* _tmp72_;
	GeeSet* _tmp73_;
	GeeSet* _tmp74_;
	GeeIterator* _tmp75_;
	GeeIterator* _persona_it;
	GeeIterator* _tmp76_;
	gboolean _tmp77_;
	GeeIterator* _tmp78_;
	gpointer _tmp79_;
	FolksPersona* persona;
	FolksPersona* _tmp80_;
	const gchar* _tmp81_;
	const gchar* _tmp82_;
	const gchar* _tmp83_;
	GeeHashSet* _tmp84_;
	FolksPersona* _tmp85_;
	gboolean _tmp86_;
	gboolean _tmp87_;
	gchar** _tmp88_;
	gint _tmp88__length1;
	guint _tmp89_;
	const gchar* _tmp90_;
	gchar** _tmp91_;
	gint _tmp91__length1;
	guint _tmp92_;
	const gchar* _tmp93_;
	gchar* _tmp94_;
	gchar* id;
	FolksInspectClient* _tmp95_;
	FolksIndividualAggregator* _tmp96_;
	FolksIndividualAggregator* _tmp97_;
	GeeMap* _tmp98_;
	GeeMap* _tmp99_;
	GeeCollection* _tmp100_;
	GeeCollection* _tmp101_;
	GeeCollection* _tmp102_;
	GeeIterator* _tmp103_;
	GeeIterator* _tmp104_;
	GeeIterator* _vala1__individual_it;
	GeeIterator* _tmp105_;
	gboolean _tmp106_;
	GeeIterator* _tmp107_;
	gpointer _tmp108_;
	FolksIndividual* _vala1_individual;
	FolksIndividual* _tmp109_;
	const gchar* _tmp110_;
	const gchar* _tmp111_;
	const gchar* _tmp112_;
	FolksIndividual* _tmp113_;
	GeeSet* _tmp114_;
	GeeSet* _tmp115_;
	GeeIterator* _tmp116_;
	GeeIterator* _vala1__persona_it;
	GeeIterator* _tmp117_;
	gboolean _tmp118_;
	GeeIterator* _tmp119_;
	gpointer _tmp120_;
	FolksPersona* _vala1_persona;
	GeeHashSet* _tmp121_;
	FolksPersona* _tmp122_;
	gboolean _tmp123_;
	gchar** _tmp124_;
	gint _tmp124__length1;
	guint _tmp125_;
	const gchar* _tmp126_;
	FolksInspectClient* _tmp127_;
	FolksIndividualAggregator* _tmp128_;
	FolksIndividualAggregator* _tmp129_;
	GeeHashSet* _tmp130_;
	GError* e;
	GError* _tmp131_;
	GQuark _tmp132_;
	GError* _tmp133_;
	gint _tmp134_;
	GeeHashSet* _tmp135_;
	gint _tmp136_;
	gint _tmp137_;
	GError* _tmp138_;
	const gchar* _tmp139_;
	GeeHashSet* _tmp140_;
	gint _tmp141_;
	gint _tmp142_;
	gchar** _tmp143_;
	gint _tmp143__length1;
	const gchar* _tmp144_;
	gchar** _tmp145_;
	gint _tmp145__length1;
	FolksInspectClient* _tmp146_;
	FolksIndividualAggregator* _tmp147_;
	FolksIndividualAggregator* _tmp148_;
	GeeMap* _tmp149_;
	GeeMap* _tmp150_;
	gchar** _tmp151_;
	gint _tmp151__length1;
	const gchar* _tmp152_;
	gpointer _tmp153_;
	FolksIndividual* ind;
	FolksIndividual* _tmp154_;
	gchar** _tmp155_;
	gint _tmp155__length1;
	const gchar* _tmp156_;
	FolksInspectClient* _tmp157_;
	FolksIndividualAggregator* _tmp158_;
	FolksIndividualAggregator* _tmp159_;
	FolksIndividual* _tmp160_;
	GError* _vala1_e;
	GError* _tmp161_;
	GQuark _tmp162_;
	GError* _tmp163_;
	gint _tmp164_;
	FolksIndividual* _tmp165_;
	const gchar* _tmp166_;
	const gchar* _tmp167_;
	GError* _tmp168_;
	const gchar* _tmp169_;
	FolksIndividual* _tmp170_;
	const gchar* _tmp171_;
	const gchar* _tmp172_;
	GError * _inner_error_;
};


static gpointer folks_inspect_commands_linking_parent_class = NULL;
static gchar** folks_inspect_commands_linking_subcommand_completions;
static gchar** folks_inspect_commands_linking_subcommand_completions = NULL;
static guint folks_inspect_commands_linking_completion_count;
static guint folks_inspect_commands_linking_completion_count = 0U;
static gchar* folks_inspect_commands_linking_prefix;
static gchar* folks_inspect_commands_linking_prefix = NULL;

gpointer folks_inspect_command_ref (gpointer instance);
void folks_inspect_command_unref (gpointer instance);
GParamSpec* folks_inspect_param_spec_command (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void folks_inspect_value_set_command (GValue* value, gpointer v_object);
void folks_inspect_value_take_command (GValue* value, gpointer v_object);
gpointer folks_inspect_value_get_command (const GValue* value);
GType folks_inspect_command_get_type (void) G_GNUC_CONST;
GType folks_inspect_client_get_type (void) G_GNUC_CONST;
GType folks_inspect_commands_linking_get_type (void) G_GNUC_CONST;
enum  {
	FOLKS_INSPECT_COMMANDS_LINKING_DUMMY_PROPERTY
};
FolksInspectCommandsLinking* folks_inspect_commands_linking_new (FolksInspectClient* client);
FolksInspectCommandsLinking* folks_inspect_commands_linking_construct (GType object_type, FolksInspectClient* client);
FolksInspectCommand* folks_inspect_command_construct (GType object_type, FolksInspectClient* client);
static void folks_inspect_commands_linking_real_run_data_free (gpointer _data);
static void folks_inspect_commands_linking_real_run (FolksInspectCommand* base, const gchar* command_string, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean folks_inspect_commands_linking_real_run_co (FolksInspectCommandsLinkingRunData* _data_);
void folks_inspect_utils_print_line (const gchar* format, ...);
FolksIndividualAggregator* folks_inspect_client_get_aggregator (FolksInspectClient* self);
static void folks_inspect_commands_linking_run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
gchar* folks_inspect_commands_linking_subcommand_name_completion_cb (const gchar* word, gint state);
gchar* folks_inspect_utils_persona_uid_completion_cb (const gchar* word, gint state);
static gchar* _folks_inspect_utils_persona_uid_completion_cb_rl_compentry_func_t (const gchar* str, gint a);
static gchar** _vala_array_dup4 (gchar** self, int length);
gchar* folks_inspect_utils_individual_id_completion_cb (const gchar* word, gint state);
static gchar* _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t (const gchar* str, gint a);
static gchar** _vala_array_dup5 (gchar** self, int length);
static gchar** _vala_array_dup6 (gchar** self, int length);
static gchar** folks_inspect_commands_linking_real_complete_subcommand (FolksInspectCommand* base, const gchar* subcommand, int* result_length1);
static gchar* _folks_inspect_commands_linking_subcommand_name_completion_cb_rl_compentry_func_t (const gchar* str, gint a);
static gchar** _vala_array_dup7 (gchar** self, int length);
static void folks_inspect_commands_linking_finalize (FolksInspectCommand* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


FolksInspectCommandsLinking* folks_inspect_commands_linking_construct (GType object_type, FolksInspectClient* client) {
	FolksInspectCommandsLinking* self = NULL;
	FolksInspectClient* _tmp0_;
	g_return_val_if_fail (client != NULL, NULL);
	_tmp0_ = client;
	self = (FolksInspectCommandsLinking*) folks_inspect_command_construct (object_type, _tmp0_);
	return self;
}


FolksInspectCommandsLinking* folks_inspect_commands_linking_new (FolksInspectClient* client) {
	return folks_inspect_commands_linking_construct (FOLKS_INSPECT_COMMANDS_TYPE_LINKING, client);
}


static void folks_inspect_commands_linking_real_run_data_free (gpointer _data) {
	FolksInspectCommandsLinkingRunData* _data_;
	_data_ = _data;
	_g_free0 (_data_->command_string);
	_folks_inspect_command_unref0 (_data_->self);
	g_slice_free (FolksInspectCommandsLinkingRunData, _data_);
}


static gpointer _folks_inspect_command_ref0 (gpointer self) {
	return self ? folks_inspect_command_ref (self) : NULL;
}


static void folks_inspect_commands_linking_real_run (FolksInspectCommand* base, const gchar* command_string, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FolksInspectCommandsLinking * self;
	FolksInspectCommandsLinkingRunData* _data_;
	FolksInspectCommandsLinking* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	self = (FolksInspectCommandsLinking*) base;
	_data_ = g_slice_new0 (FolksInspectCommandsLinkingRunData);
	_data_->_async_result = g_simple_async_result_new (g_object_newv (G_TYPE_OBJECT, 0, NULL), _callback_, _user_data_, folks_inspect_commands_linking_real_run);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, folks_inspect_commands_linking_real_run_data_free);
	_tmp0_ = _folks_inspect_command_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = command_string;
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (_data_->command_string);
	_data_->command_string = _tmp2_;
	folks_inspect_commands_linking_real_run_co (_data_);
}


static void folks_inspect_commands_linking_real_run_finish (FolksInspectCommand* base, GAsyncResult* _res_) {
	FolksInspectCommandsLinkingRunData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gchar* string_strip (const gchar* self) {
	gchar* result = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _result_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	g_strstrip (_tmp1_);
	result = _result_;
	return result;
}


static void folks_inspect_commands_linking_run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	FolksInspectCommandsLinkingRunData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	folks_inspect_commands_linking_real_run_co (_data_);
}


static gboolean folks_inspect_commands_linking_real_run_co (FolksInspectCommandsLinkingRunData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = g_new0 (gchar*, 0 + 1);
	_data_->parts = _data_->_tmp0_;
	_data_->parts_length1 = 0;
	_data_->_parts_size_ = _data_->parts_length1;
	_data_->_tmp1_ = _data_->command_string;
	if (_data_->_tmp1_ != NULL) {
		_data_->_tmp2_ = _data_->command_string;
		_data_->_tmp4_ = NULL;
		_data_->_tmp4_ = _data_->_tmp3_ = g_strsplit (_data_->_tmp2_, " ", 0);
		_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), NULL);
		_data_->parts = _data_->_tmp4_;
		_data_->parts_length1 = _vala_array_length (_data_->_tmp3_);
		_data_->_parts_size_ = _data_->parts_length1;
	}
	_data_->_tmp6_ = _data_->parts;
	_data_->_tmp6__length1 = _data_->parts_length1;
	if (_data_->_tmp6__length1 < 1) {
		_data_->_tmp5_ = TRUE;
	} else {
		_data_->_tmp9_ = _data_->parts;
		_data_->_tmp9__length1 = _data_->parts_length1;
		_data_->_tmp10_ = _data_->_tmp9_[0];
		if (g_strcmp0 (_data_->_tmp10_, "link-personas") != 0) {
			_data_->_tmp11_ = _data_->parts;
			_data_->_tmp11__length1 = _data_->parts_length1;
			_data_->_tmp12_ = _data_->_tmp11_[0];
			_data_->_tmp8_ = g_strcmp0 (_data_->_tmp12_, "link-individuals") != 0;
		} else {
			_data_->_tmp8_ = FALSE;
		}
		_data_->_tmp13_ = _data_->_tmp8_;
		if (_data_->_tmp13_) {
			_data_->_tmp14_ = _data_->parts;
			_data_->_tmp14__length1 = _data_->parts_length1;
			_data_->_tmp15_ = _data_->_tmp14_[0];
			_data_->_tmp7_ = g_strcmp0 (_data_->_tmp15_, "unlink-individual") != 0;
		} else {
			_data_->_tmp7_ = FALSE;
		}
		_data_->_tmp16_ = _data_->_tmp7_;
		_data_->_tmp5_ = _data_->_tmp16_;
	}
	_data_->_tmp17_ = _data_->_tmp5_;
	if (_data_->_tmp17_) {
		_data_->_tmp18_ = _data_->command_string;
		folks_inspect_utils_print_line ("Unrecognised 'linking' command '%s'.", _data_->_tmp18_);
		_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
	}
	_data_->_tmp20_ = _data_->parts;
	_data_->_tmp20__length1 = _data_->parts_length1;
	_data_->_tmp21_ = _data_->_tmp20_[0];
	if (g_strcmp0 (_data_->_tmp21_, "link-personas") == 0) {
		_data_->_tmp19_ = TRUE;
	} else {
		_data_->_tmp22_ = _data_->parts;
		_data_->_tmp22__length1 = _data_->parts_length1;
		_data_->_tmp23_ = _data_->_tmp22_[0];
		_data_->_tmp19_ = g_strcmp0 (_data_->_tmp23_, "link-individuals") == 0;
	}
	_data_->_tmp24_ = _data_->_tmp19_;
	if (_data_->_tmp24_) {
		_data_->_tmp25_ = gee_hash_set_new (FOLKS_TYPE_PERSONA, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL);
		_data_->personas = _data_->_tmp25_;
		_data_->_tmp26_ = _data_->parts;
		_data_->_tmp26__length1 = _data_->parts_length1;
		if (_data_->_tmp26__length1 < 2) {
			_data_->_tmp27_ = _data_->parts;
			_data_->_tmp27__length1 = _data_->parts_length1;
			_data_->_tmp28_ = _data_->_tmp27_[0];
			if (g_strcmp0 (_data_->_tmp28_, "link-personas") == 0) {
				folks_inspect_utils_print_line ("%s", "Must pass at least one persona to a " "'link-personas' subcommand.");
			} else {
				folks_inspect_utils_print_line ("%s", "Must pass at least one individual to a " "'link-individuals' subcommand.");
			}
			_g_object_unref0 (_data_->personas);
			_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
		}
		{
			_data_->i = (guint) 1;
			{
				_data_->_tmp29_ = TRUE;
				while (TRUE) {
					_data_->_tmp30_ = _data_->_tmp29_;
					if (!_data_->_tmp30_) {
						_data_->_tmp31_ = _data_->i;
						_data_->i = _data_->_tmp31_ + 1;
					}
					_data_->_tmp29_ = FALSE;
					_data_->_tmp32_ = _data_->i;
					_data_->_tmp33_ = _data_->parts;
					_data_->_tmp33__length1 = _data_->parts_length1;
					if (!(_data_->_tmp32_ < ((guint) _data_->_tmp33__length1))) {
						break;
					}
					_data_->_tmp35_ = _data_->parts;
					_data_->_tmp35__length1 = _data_->parts_length1;
					_data_->_tmp36_ = _data_->i;
					_data_->_tmp37_ = _data_->_tmp35_[_data_->_tmp36_];
					if (_data_->_tmp37_ == NULL) {
						_data_->_tmp34_ = TRUE;
					} else {
						_data_->_tmp38_ = _data_->parts;
						_data_->_tmp38__length1 = _data_->parts_length1;
						_data_->_tmp39_ = _data_->i;
						_data_->_tmp40_ = _data_->_tmp38_[_data_->_tmp39_];
						_data_->_tmp41_ = NULL;
						_data_->_tmp41_ = string_strip (_data_->_tmp40_);
						_data_->_tmp42_ = _data_->_tmp41_;
						_data_->_tmp34_ = g_strcmp0 (_data_->_tmp42_, "") == 0;
						_g_free0 (_data_->_tmp42_);
					}
					_data_->_tmp43_ = _data_->_tmp34_;
					if (_data_->_tmp43_) {
						_data_->_tmp44_ = _data_->parts;
						_data_->_tmp44__length1 = _data_->parts_length1;
						_data_->_tmp45_ = _data_->_tmp44_[0];
						if (g_strcmp0 (_data_->_tmp45_, "link-personas") == 0) {
							_data_->_tmp46_ = _data_->parts;
							_data_->_tmp46__length1 = _data_->parts_length1;
							_data_->_tmp47_ = _data_->i;
							_data_->_tmp48_ = _data_->_tmp46_[_data_->_tmp47_];
							folks_inspect_utils_print_line ("Unrecognised persona UID '%s'.", _data_->_tmp48_);
						} else {
							_data_->_tmp49_ = _data_->parts;
							_data_->_tmp49__length1 = _data_->parts_length1;
							_data_->_tmp50_ = _data_->i;
							_data_->_tmp51_ = _data_->_tmp49_[_data_->_tmp50_];
							folks_inspect_utils_print_line ("Unrecognised individual ID '%s'.", _data_->_tmp51_);
						}
						_g_object_unref0 (_data_->personas);
						_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
					}
					_data_->found = FALSE;
					_data_->_tmp52_ = _data_->parts;
					_data_->_tmp52__length1 = _data_->parts_length1;
					_data_->_tmp53_ = _data_->_tmp52_[0];
					if (g_strcmp0 (_data_->_tmp53_, "link-personas") == 0) {
						_data_->_tmp54_ = _data_->parts;
						_data_->_tmp54__length1 = _data_->parts_length1;
						_data_->_tmp55_ = _data_->i;
						_data_->_tmp56_ = _data_->_tmp54_[_data_->_tmp55_];
						_data_->_tmp57_ = NULL;
						_data_->_tmp57_ = string_strip (_data_->_tmp56_);
						_data_->uid = _data_->_tmp57_;
						{
							_data_->_tmp58_ = ((FolksInspectCommand*) _data_->self)->client;
							_data_->_tmp59_ = folks_inspect_client_get_aggregator (_data_->_tmp58_);
							_data_->_tmp60_ = _data_->_tmp59_;
							_data_->_tmp61_ = folks_individual_aggregator_get_individuals (_data_->_tmp60_);
							_data_->_tmp62_ = _data_->_tmp61_;
							_data_->_tmp63_ = gee_map_get_values (_data_->_tmp62_);
							_data_->_tmp64_ = _data_->_tmp63_;
							_data_->_tmp65_ = _data_->_tmp64_;
							_data_->_tmp66_ = NULL;
							_data_->_tmp66_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp65_);
							_data_->_tmp67_ = _data_->_tmp66_;
							_g_object_unref0 (_data_->_tmp65_);
							_data_->_individual_it = _data_->_tmp67_;
							while (TRUE) {
								_data_->_tmp68_ = _data_->_individual_it;
								_data_->_tmp69_ = FALSE;
								_data_->_tmp69_ = gee_iterator_next (_data_->_tmp68_);
								if (!_data_->_tmp69_) {
									break;
								}
								_data_->_tmp70_ = _data_->_individual_it;
								_data_->_tmp71_ = NULL;
								_data_->_tmp71_ = gee_iterator_get (_data_->_tmp70_);
								_data_->individual = (FolksIndividual*) _data_->_tmp71_;
								{
									_data_->_tmp72_ = _data_->individual;
									_data_->_tmp73_ = folks_individual_get_personas (_data_->_tmp72_);
									_data_->_tmp74_ = _data_->_tmp73_;
									_data_->_tmp75_ = NULL;
									_data_->_tmp75_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp74_);
									_data_->_persona_it = _data_->_tmp75_;
									while (TRUE) {
										_data_->_tmp76_ = _data_->_persona_it;
										_data_->_tmp77_ = FALSE;
										_data_->_tmp77_ = gee_iterator_next (_data_->_tmp76_);
										if (!_data_->_tmp77_) {
											break;
										}
										_data_->_tmp78_ = _data_->_persona_it;
										_data_->_tmp79_ = NULL;
										_data_->_tmp79_ = gee_iterator_get (_data_->_tmp78_);
										_data_->persona = (FolksPersona*) _data_->_tmp79_;
										_data_->_tmp80_ = _data_->persona;
										_data_->_tmp81_ = folks_persona_get_uid (_data_->_tmp80_);
										_data_->_tmp82_ = _data_->_tmp81_;
										_data_->_tmp83_ = _data_->uid;
										if (g_strcmp0 (_data_->_tmp82_, _data_->_tmp83_) == 0) {
											_data_->_tmp84_ = _data_->personas;
											_data_->_tmp85_ = _data_->persona;
											gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp84_, _data_->_tmp85_);
											_data_->found = TRUE;
											_g_object_unref0 (_data_->persona);
											break;
										}
										_g_object_unref0 (_data_->persona);
									}
									_g_object_unref0 (_data_->_persona_it);
								}
								_data_->_tmp86_ = _data_->found;
								if (_data_->_tmp86_ == TRUE) {
									_g_object_unref0 (_data_->individual);
									break;
								}
								_g_object_unref0 (_data_->individual);
							}
							_g_object_unref0 (_data_->_individual_it);
						}
						_data_->_tmp87_ = _data_->found;
						if (_data_->_tmp87_ == FALSE) {
							_data_->_tmp88_ = _data_->parts;
							_data_->_tmp88__length1 = _data_->parts_length1;
							_data_->_tmp89_ = _data_->i;
							_data_->_tmp90_ = _data_->_tmp88_[_data_->_tmp89_];
							folks_inspect_utils_print_line ("Unrecognised persona UID '%s'.", _data_->_tmp90_);
							_g_free0 (_data_->uid);
							_g_object_unref0 (_data_->personas);
							_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
						}
						_g_free0 (_data_->uid);
					} else {
						_data_->_tmp91_ = _data_->parts;
						_data_->_tmp91__length1 = _data_->parts_length1;
						_data_->_tmp92_ = _data_->i;
						_data_->_tmp93_ = _data_->_tmp91_[_data_->_tmp92_];
						_data_->_tmp94_ = NULL;
						_data_->_tmp94_ = string_strip (_data_->_tmp93_);
						_data_->id = _data_->_tmp94_;
						{
							_data_->_tmp95_ = ((FolksInspectCommand*) _data_->self)->client;
							_data_->_tmp96_ = folks_inspect_client_get_aggregator (_data_->_tmp95_);
							_data_->_tmp97_ = _data_->_tmp96_;
							_data_->_tmp98_ = folks_individual_aggregator_get_individuals (_data_->_tmp97_);
							_data_->_tmp99_ = _data_->_tmp98_;
							_data_->_tmp100_ = gee_map_get_values (_data_->_tmp99_);
							_data_->_tmp101_ = _data_->_tmp100_;
							_data_->_tmp102_ = _data_->_tmp101_;
							_data_->_tmp103_ = NULL;
							_data_->_tmp103_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp102_);
							_data_->_tmp104_ = _data_->_tmp103_;
							_g_object_unref0 (_data_->_tmp102_);
							_data_->_vala1__individual_it = _data_->_tmp104_;
							while (TRUE) {
								_data_->_tmp105_ = _data_->_vala1__individual_it;
								_data_->_tmp106_ = FALSE;
								_data_->_tmp106_ = gee_iterator_next (_data_->_tmp105_);
								if (!_data_->_tmp106_) {
									break;
								}
								_data_->_tmp107_ = _data_->_vala1__individual_it;
								_data_->_tmp108_ = NULL;
								_data_->_tmp108_ = gee_iterator_get (_data_->_tmp107_);
								_data_->_vala1_individual = (FolksIndividual*) _data_->_tmp108_;
								_data_->_tmp109_ = _data_->_vala1_individual;
								_data_->_tmp110_ = folks_individual_get_id (_data_->_tmp109_);
								_data_->_tmp111_ = _data_->_tmp110_;
								_data_->_tmp112_ = _data_->id;
								if (g_strcmp0 (_data_->_tmp111_, _data_->_tmp112_) == 0) {
									{
										_data_->_tmp113_ = _data_->_vala1_individual;
										_data_->_tmp114_ = folks_individual_get_personas (_data_->_tmp113_);
										_data_->_tmp115_ = _data_->_tmp114_;
										_data_->_tmp116_ = NULL;
										_data_->_tmp116_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp115_);
										_data_->_vala1__persona_it = _data_->_tmp116_;
										while (TRUE) {
											_data_->_tmp117_ = _data_->_vala1__persona_it;
											_data_->_tmp118_ = FALSE;
											_data_->_tmp118_ = gee_iterator_next (_data_->_tmp117_);
											if (!_data_->_tmp118_) {
												break;
											}
											_data_->_tmp119_ = _data_->_vala1__persona_it;
											_data_->_tmp120_ = NULL;
											_data_->_tmp120_ = gee_iterator_get (_data_->_tmp119_);
											_data_->_vala1_persona = (FolksPersona*) _data_->_tmp120_;
											_data_->_tmp121_ = _data_->personas;
											_data_->_tmp122_ = _data_->_vala1_persona;
											gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp121_, _data_->_tmp122_);
											_g_object_unref0 (_data_->_vala1_persona);
										}
										_g_object_unref0 (_data_->_vala1__persona_it);
									}
									_data_->found = TRUE;
									_g_object_unref0 (_data_->_vala1_individual);
									break;
								}
								_g_object_unref0 (_data_->_vala1_individual);
							}
							_g_object_unref0 (_data_->_vala1__individual_it);
						}
						_data_->_tmp123_ = _data_->found;
						if (_data_->_tmp123_ == FALSE) {
							_data_->_tmp124_ = _data_->parts;
							_data_->_tmp124__length1 = _data_->parts_length1;
							_data_->_tmp125_ = _data_->i;
							_data_->_tmp126_ = _data_->_tmp124_[_data_->_tmp125_];
							folks_inspect_utils_print_line ("Unrecognised individual ID '%s'.", _data_->_tmp126_);
							_g_free0 (_data_->id);
							_g_object_unref0 (_data_->personas);
							_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
						}
						_g_free0 (_data_->id);
					}
				}
			}
		}
		{
			_data_->_tmp127_ = ((FolksInspectCommand*) _data_->self)->client;
			_data_->_tmp128_ = folks_inspect_client_get_aggregator (_data_->_tmp127_);
			_data_->_tmp129_ = _data_->_tmp128_;
			_data_->_tmp130_ = _data_->personas;
			_data_->_state_ = 1;
			folks_individual_aggregator_link_personas (_data_->_tmp129_, (GeeSet*) _data_->_tmp130_, folks_inspect_commands_linking_run_ready, _data_);
			return FALSE;
			_state_1:
			folks_individual_aggregator_link_personas_finish (_data_->_tmp129_, _data_->_res_, &_data_->_inner_error_);
			if (_data_->_inner_error_ != NULL) {
				if (_data_->_inner_error_->domain == FOLKS_INDIVIDUAL_AGGREGATOR_ERROR) {
					goto __catch0_folks_individual_aggregator_error;
				}
				_g_object_unref0 (_data_->personas);
				_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), NULL);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
				g_clear_error (&_data_->_inner_error_);
				return FALSE;
			}
		}
		goto __finally0;
		__catch0_folks_individual_aggregator_error:
		{
			_data_->e = _data_->_inner_error_;
			_data_->_inner_error_ = NULL;
			_data_->_tmp131_ = _data_->e;
			_data_->_tmp132_ = _data_->_tmp131_->domain;
			_data_->_tmp133_ = _data_->e;
			_data_->_tmp134_ = _data_->_tmp133_->code;
			_data_->_tmp135_ = _data_->personas;
			_data_->_tmp136_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp135_);
			_data_->_tmp137_ = _data_->_tmp136_;
			_data_->_tmp138_ = _data_->e;
			_data_->_tmp139_ = _data_->_tmp138_->message;
			folks_inspect_utils_print_line ("Error (domain: %u, code: %u) linking %u " "personas: %s", _data_->_tmp132_, _data_->_tmp134_, _data_->_tmp137_, _data_->_tmp139_);
			_g_error_free0 (_data_->e);
		}
		__finally0:
		if (_data_->_inner_error_ != NULL) {
			_g_object_unref0 (_data_->personas);
			_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
		}
		_data_->_tmp140_ = _data_->personas;
		_data_->_tmp141_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp140_);
		_data_->_tmp142_ = _data_->_tmp141_;
		folks_inspect_utils_print_line ("Linking of %u personas was successful.", (guint) _data_->_tmp142_);
		_g_object_unref0 (_data_->personas);
	} else {
		_data_->_tmp143_ = _data_->parts;
		_data_->_tmp143__length1 = _data_->parts_length1;
		_data_->_tmp144_ = _data_->_tmp143_[0];
		if (g_strcmp0 (_data_->_tmp144_, "unlink-individual") == 0) {
			_data_->_tmp145_ = _data_->parts;
			_data_->_tmp145__length1 = _data_->parts_length1;
			if (_data_->_tmp145__length1 != 2) {
				folks_inspect_utils_print_line ("%s", "Must pass exactly one individual ID to an " "'unlink-individual' subcommand.");
				_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
			}
			_data_->_tmp146_ = ((FolksInspectCommand*) _data_->self)->client;
			_data_->_tmp147_ = folks_inspect_client_get_aggregator (_data_->_tmp146_);
			_data_->_tmp148_ = _data_->_tmp147_;
			_data_->_tmp149_ = folks_individual_aggregator_get_individuals (_data_->_tmp148_);
			_data_->_tmp150_ = _data_->_tmp149_;
			_data_->_tmp151_ = _data_->parts;
			_data_->_tmp151__length1 = _data_->parts_length1;
			_data_->_tmp152_ = _data_->_tmp151_[1];
			_data_->_tmp153_ = NULL;
			_data_->_tmp153_ = gee_map_get (_data_->_tmp150_, _data_->_tmp152_);
			_data_->ind = (FolksIndividual*) _data_->_tmp153_;
			_data_->_tmp154_ = _data_->ind;
			if (_data_->_tmp154_ == NULL) {
				_data_->_tmp155_ = _data_->parts;
				_data_->_tmp155__length1 = _data_->parts_length1;
				_data_->_tmp156_ = _data_->_tmp155_[1];
				folks_inspect_utils_print_line ("Unrecognised individual ID '%s'.", _data_->_tmp156_);
				_g_object_unref0 (_data_->ind);
				_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
			}
			{
				_data_->_tmp157_ = ((FolksInspectCommand*) _data_->self)->client;
				_data_->_tmp158_ = folks_inspect_client_get_aggregator (_data_->_tmp157_);
				_data_->_tmp159_ = _data_->_tmp158_;
				_data_->_tmp160_ = _data_->ind;
				_data_->_state_ = 2;
				folks_individual_aggregator_unlink_individual (_data_->_tmp159_, _data_->_tmp160_, folks_inspect_commands_linking_run_ready, _data_);
				return FALSE;
				_state_2:
				folks_individual_aggregator_unlink_individual_finish (_data_->_tmp159_, _data_->_res_, &_data_->_inner_error_);
				if (_data_->_inner_error_ != NULL) {
					goto __catch1_g_error;
				}
			}
			goto __finally1;
			__catch1_g_error:
			{
				_data_->_vala1_e = _data_->_inner_error_;
				_data_->_inner_error_ = NULL;
				_data_->_tmp161_ = _data_->_vala1_e;
				_data_->_tmp162_ = _data_->_tmp161_->domain;
				_data_->_tmp163_ = _data_->_vala1_e;
				_data_->_tmp164_ = _data_->_tmp163_->code;
				_data_->_tmp165_ = _data_->ind;
				_data_->_tmp166_ = folks_individual_get_id (_data_->_tmp165_);
				_data_->_tmp167_ = _data_->_tmp166_;
				_data_->_tmp168_ = _data_->_vala1_e;
				_data_->_tmp169_ = _data_->_tmp168_->message;
				folks_inspect_utils_print_line ("Error (domain: %u, code: %u) unlinking " "individual '%s': %s", _data_->_tmp162_, _data_->_tmp164_, _data_->_tmp167_, _data_->_tmp169_);
				_g_error_free0 (_data_->_vala1_e);
			}
			__finally1:
			if (_data_->_inner_error_ != NULL) {
				_g_object_unref0 (_data_->ind);
				_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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;
			}
			_data_->_tmp170_ = _data_->ind;
			_data_->_tmp171_ = folks_individual_get_id (_data_->_tmp170_);
			_data_->_tmp172_ = _data_->_tmp171_;
			folks_inspect_utils_print_line ("Unlinking of individual '%s' was successful.", _data_->_tmp172_);
			_g_object_unref0 (_data_->ind);
		} else {
			g_assert_not_reached ();
		}
	}
	_data_->parts = (_vala_array_free (_data_->parts, _data_->parts_length1, (GDestroyNotify) g_free), 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 gchar* _folks_inspect_utils_persona_uid_completion_cb_rl_compentry_func_t (const gchar* str, gint a) {
	gchar* result;
	result = folks_inspect_utils_persona_uid_completion_cb (str, a);
	return result;
}


static gchar** _vala_array_dup4 (gchar** self, int length) {
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


static gchar* _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t (const gchar* str, gint a) {
	gchar* result;
	result = folks_inspect_utils_individual_id_completion_cb (str, a);
	return result;
}


static gchar** _vala_array_dup5 (gchar** self, int length) {
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


static gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	gint _tmp0_;
	gint _tmp1_;
	glong string_length;
	glong _tmp2_;
	glong _tmp5_;
	gboolean _tmp8_ = FALSE;
	glong _tmp9_;
	gboolean _tmp12_;
	gboolean _tmp13_ = FALSE;
	glong _tmp14_;
	gboolean _tmp17_;
	glong _tmp18_;
	glong _tmp19_;
	glong _tmp20_;
	glong _tmp21_;
	glong _tmp22_;
	gchar* _tmp23_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	_tmp2_ = start;
	if (_tmp2_ < ((glong) 0)) {
		glong _tmp3_;
		glong _tmp4_;
		_tmp3_ = string_length;
		_tmp4_ = start;
		start = _tmp3_ + _tmp4_;
	}
	_tmp5_ = end;
	if (_tmp5_ < ((glong) 0)) {
		glong _tmp6_;
		glong _tmp7_;
		_tmp6_ = string_length;
		_tmp7_ = end;
		end = _tmp6_ + _tmp7_;
	}
	_tmp9_ = start;
	if (_tmp9_ >= ((glong) 0)) {
		glong _tmp10_;
		glong _tmp11_;
		_tmp10_ = start;
		_tmp11_ = string_length;
		_tmp8_ = _tmp10_ <= _tmp11_;
	} else {
		_tmp8_ = FALSE;
	}
	_tmp12_ = _tmp8_;
	g_return_val_if_fail (_tmp12_, NULL);
	_tmp14_ = end;
	if (_tmp14_ >= ((glong) 0)) {
		glong _tmp15_;
		glong _tmp16_;
		_tmp15_ = end;
		_tmp16_ = string_length;
		_tmp13_ = _tmp15_ <= _tmp16_;
	} else {
		_tmp13_ = FALSE;
	}
	_tmp17_ = _tmp13_;
	g_return_val_if_fail (_tmp17_, NULL);
	_tmp18_ = start;
	_tmp19_ = end;
	g_return_val_if_fail (_tmp18_ <= _tmp19_, NULL);
	_tmp20_ = start;
	_tmp21_ = end;
	_tmp22_ = start;
	_tmp23_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) (_tmp21_ - _tmp22_));
	result = _tmp23_;
	return result;
}


static gchar** _vala_array_dup6 (gchar** self, int length) {
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


gchar* folks_inspect_commands_linking_subcommand_name_completion_cb (const gchar* word, gint state) {
	gchar* result = NULL;
	gint _tmp0_;
	gchar* _tmp72_;
	g_return_val_if_fail (word != NULL, NULL);
	_tmp0_ = state;
	if (_tmp0_ == 0) {
		const gchar* _tmp1_;
		gchar** _tmp2_;
		gchar** _tmp3_ = NULL;
		gchar** parts;
		gint parts_length1;
		gint _parts_size_;
		gboolean _tmp4_ = FALSE;
		gchar** _tmp5_;
		gint _tmp5__length1;
		gboolean _tmp12_;
		_tmp1_ = word;
		_tmp3_ = _tmp2_ = g_strsplit (_tmp1_, " ", 0);
		parts = _tmp3_;
		parts_length1 = _vala_array_length (_tmp2_);
		_parts_size_ = parts_length1;
		_tmp5_ = parts;
		_tmp5__length1 = parts_length1;
		if (_tmp5__length1 > 0) {
			gboolean _tmp6_ = FALSE;
			gchar** _tmp7_;
			gint _tmp7__length1;
			const gchar* _tmp8_;
			gboolean _tmp11_;
			_tmp7_ = parts;
			_tmp7__length1 = parts_length1;
			_tmp8_ = _tmp7_[0];
			if (g_strcmp0 (_tmp8_, "link-personas") == 0) {
				_tmp6_ = TRUE;
			} else {
				gchar** _tmp9_;
				gint _tmp9__length1;
				const gchar* _tmp10_;
				_tmp9_ = parts;
				_tmp9__length1 = parts_length1;
				_tmp10_ = _tmp9_[0];
				_tmp6_ = g_strcmp0 (_tmp10_, "link-individuals") == 0;
			}
			_tmp11_ = _tmp6_;
			_tmp4_ = _tmp11_;
		} else {
			_tmp4_ = FALSE;
		}
		_tmp12_ = _tmp4_;
		if (_tmp12_) {
			gchar** _tmp13_;
			gint _tmp13__length1;
			gchar** _tmp14_;
			gint _tmp14__length1;
			const gchar* _tmp15_;
			gchar* _tmp16_;
			gchar* last_part;
			gchar** _tmp17_;
			gint _tmp17__length1;
			const gchar* _tmp18_;
			const gchar* _tmp27_;
			_tmp13_ = parts;
			_tmp13__length1 = parts_length1;
			_tmp14_ = parts;
			_tmp14__length1 = parts_length1;
			_tmp15_ = _tmp13_[_tmp14__length1 - 1];
			_tmp16_ = g_strdup (_tmp15_);
			last_part = _tmp16_;
			_tmp17_ = parts;
			_tmp17__length1 = parts_length1;
			_tmp18_ = _tmp17_[0];
			if (g_strcmp0 (_tmp18_, "link-personas") == 0) {
				const gchar* _tmp19_;
				gchar** _tmp20_;
				gchar** _tmp21_ = NULL;
				gchar** _tmp22_;
				gint _tmp22__length1;
				_tmp19_ = last_part;
				_tmp21_ = _tmp20_ = rl_completion_matches (_tmp19_, _folks_inspect_utils_persona_uid_completion_cb_rl_compentry_func_t);
				_tmp22_ = (_tmp21_ != NULL) ? _vala_array_dup4 (_tmp21_, _vala_array_length (_tmp20_)) : ((gpointer) _tmp21_);
				_tmp22__length1 = _vala_array_length (_tmp20_);
				folks_inspect_commands_linking_subcommand_completions = (_vala_array_free (folks_inspect_commands_linking_subcommand_completions, _vala_array_length (folks_inspect_commands_linking_subcommand_completions), (GDestroyNotify) g_free), NULL);
				folks_inspect_commands_linking_subcommand_completions = _tmp22_;
			} else {
				const gchar* _tmp23_;
				gchar** _tmp24_;
				gchar** _tmp25_ = NULL;
				gchar** _tmp26_;
				gint _tmp26__length1;
				_tmp23_ = last_part;
				_tmp25_ = _tmp24_ = rl_completion_matches (_tmp23_, _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t);
				_tmp26_ = (_tmp25_ != NULL) ? _vala_array_dup5 (_tmp25_, _vala_array_length (_tmp24_)) : ((gpointer) _tmp25_);
				_tmp26__length1 = _vala_array_length (_tmp24_);
				folks_inspect_commands_linking_subcommand_completions = (_vala_array_free (folks_inspect_commands_linking_subcommand_completions, _vala_array_length (folks_inspect_commands_linking_subcommand_completions), (GDestroyNotify) g_free), NULL);
				folks_inspect_commands_linking_subcommand_completions = _tmp26_;
			}
			_tmp27_ = last_part;
			if (g_strcmp0 (_tmp27_, "") == 0) {
				const gchar* _tmp28_;
				gchar* _tmp29_;
				_tmp28_ = word;
				_tmp29_ = g_strdup (_tmp28_);
				_g_free0 (folks_inspect_commands_linking_prefix);
				folks_inspect_commands_linking_prefix = _tmp29_;
			} else {
				const gchar* _tmp30_;
				const gchar* _tmp31_;
				gint _tmp32_;
				gint _tmp33_;
				gchar* _tmp34_ = NULL;
				_tmp30_ = word;
				_tmp31_ = last_part;
				_tmp32_ = strlen (_tmp31_);
				_tmp33_ = _tmp32_;
				_tmp34_ = string_slice (_tmp30_, (glong) 0, (glong) (-_tmp33_));
				_g_free0 (folks_inspect_commands_linking_prefix);
				folks_inspect_commands_linking_prefix = _tmp34_;
			}
			_g_free0 (last_part);
		} else {
			gboolean _tmp35_ = FALSE;
			gchar** _tmp36_;
			gint _tmp36__length1;
			gboolean _tmp39_;
			_tmp36_ = parts;
			_tmp36__length1 = parts_length1;
			if (_tmp36__length1 > 0) {
				gchar** _tmp37_;
				gint _tmp37__length1;
				const gchar* _tmp38_;
				_tmp37_ = parts;
				_tmp37__length1 = parts_length1;
				_tmp38_ = _tmp37_[0];
				_tmp35_ = g_strcmp0 (_tmp38_, "unlink-individual") == 0;
			} else {
				_tmp35_ = FALSE;
			}
			_tmp39_ = _tmp35_;
			if (_tmp39_) {
				gchar** _tmp40_;
				gint _tmp40__length1;
				gchar** _tmp42_;
				gint _tmp42__length1;
				const gchar* _tmp43_;
				gchar** _tmp44_;
				gchar** _tmp45_ = NULL;
				gchar** _tmp46_;
				gint _tmp46__length1;
				gchar* _tmp47_;
				_tmp40_ = parts;
				_tmp40__length1 = parts_length1;
				if (_tmp40__length1 != 2) {
					gchar* _tmp41_;
					folks_inspect_commands_linking_subcommand_completions = (_vala_array_free (folks_inspect_commands_linking_subcommand_completions, _vala_array_length (folks_inspect_commands_linking_subcommand_completions), (GDestroyNotify) g_free), NULL);
					folks_inspect_commands_linking_subcommand_completions = NULL;
					folks_inspect_commands_linking_completion_count = (guint) 0;
					_tmp41_ = g_strdup ("");
					_g_free0 (folks_inspect_commands_linking_prefix);
					folks_inspect_commands_linking_prefix = _tmp41_;
					result = NULL;
					parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
					return result;
				}
				_tmp42_ = parts;
				_tmp42__length1 = parts_length1;
				_tmp43_ = _tmp42_[1];
				_tmp45_ = _tmp44_ = rl_completion_matches (_tmp43_, _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t);
				_tmp46_ = (_tmp45_ != NULL) ? _vala_array_dup6 (_tmp45_, _vala_array_length (_tmp44_)) : ((gpointer) _tmp45_);
				_tmp46__length1 = _vala_array_length (_tmp44_);
				folks_inspect_commands_linking_subcommand_completions = (_vala_array_free (folks_inspect_commands_linking_subcommand_completions, _vala_array_length (folks_inspect_commands_linking_subcommand_completions), (GDestroyNotify) g_free), NULL);
				folks_inspect_commands_linking_subcommand_completions = _tmp46_;
				_tmp47_ = g_strdup ("unlink-individual ");
				_g_free0 (folks_inspect_commands_linking_prefix);
				folks_inspect_commands_linking_prefix = _tmp47_;
			} else {
				gchar* _tmp48_;
				gchar* _tmp49_;
				gchar* _tmp50_;
				gchar** _tmp51_ = NULL;
				gchar* _tmp52_;
				_tmp48_ = g_strdup ("link-personas");
				_tmp49_ = g_strdup ("link-individuals");
				_tmp50_ = g_strdup ("unlink-individual");
				_tmp51_ = g_new0 (gchar*, 4 + 1);
				_tmp51_[0] = _tmp48_;
				_tmp51_[1] = _tmp49_;
				_tmp51_[2] = _tmp50_;
				_tmp51_[3] = NULL;
				folks_inspect_commands_linking_subcommand_completions = (_vala_array_free (folks_inspect_commands_linking_subcommand_completions, _vala_array_length (folks_inspect_commands_linking_subcommand_completions), (GDestroyNotify) g_free), NULL);
				folks_inspect_commands_linking_subcommand_completions = _tmp51_;
				_tmp52_ = g_strdup ("");
				_g_free0 (folks_inspect_commands_linking_prefix);
				folks_inspect_commands_linking_prefix = _tmp52_;
			}
		}
		folks_inspect_commands_linking_completion_count = (guint) 0;
		parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
	}
	while (TRUE) {
		guint _tmp53_;
		gchar** _tmp54_;
		gint _tmp54__length1;
		gchar** _tmp55_;
		gint _tmp55__length1;
		guint _tmp56_;
		const gchar* _tmp57_;
		gchar* _tmp58_;
		gchar* completion;
		const gchar* _tmp59_;
		const gchar* _tmp60_;
		gchar* _tmp61_;
		gchar* candidate;
		guint _tmp62_;
		gboolean _tmp63_ = FALSE;
		gboolean _tmp64_ = FALSE;
		const gchar* _tmp65_;
		gboolean _tmp67_;
		gboolean _tmp71_;
		_tmp53_ = folks_inspect_commands_linking_completion_count;
		_tmp54_ = folks_inspect_commands_linking_subcommand_completions;
		_tmp54__length1 = _vala_array_length (folks_inspect_commands_linking_subcommand_completions);
		if (!(_tmp53_ < ((guint) _tmp54__length1))) {
			break;
		}
		_tmp55_ = folks_inspect_commands_linking_subcommand_completions;
		_tmp55__length1 = _vala_array_length (folks_inspect_commands_linking_subcommand_completions);
		_tmp56_ = folks_inspect_commands_linking_completion_count;
		_tmp57_ = _tmp55_[_tmp56_];
		_tmp58_ = g_strdup (_tmp57_);
		completion = _tmp58_;
		_tmp59_ = folks_inspect_commands_linking_prefix;
		_tmp60_ = completion;
		_tmp61_ = g_strconcat (_tmp59_, _tmp60_, NULL);
		candidate = _tmp61_;
		_tmp62_ = folks_inspect_commands_linking_completion_count;
		folks_inspect_commands_linking_completion_count = _tmp62_ + 1;
		_tmp65_ = completion;
		if (_tmp65_ != NULL) {
			const gchar* _tmp66_;
			_tmp66_ = completion;
			_tmp64_ = g_strcmp0 (_tmp66_, "") != 0;
		} else {
			_tmp64_ = FALSE;
		}
		_tmp67_ = _tmp64_;
		if (_tmp67_) {
			const gchar* _tmp68_;
			const gchar* _tmp69_;
			gboolean _tmp70_ = FALSE;
			_tmp68_ = candidate;
			_tmp69_ = word;
			_tmp70_ = g_str_has_prefix (_tmp68_, _tmp69_);
			_tmp63_ = _tmp70_;
		} else {
			_tmp63_ = FALSE;
		}
		_tmp71_ = _tmp63_;
		if (_tmp71_) {
			result = completion;
			_g_free0 (candidate);
			return result;
		}
		_g_free0 (candidate);
		_g_free0 (completion);
	}
	folks_inspect_commands_linking_subcommand_completions = (_vala_array_free (folks_inspect_commands_linking_subcommand_completions, _vala_array_length (folks_inspect_commands_linking_subcommand_completions), (GDestroyNotify) g_free), NULL);
	folks_inspect_commands_linking_subcommand_completions = NULL;
	folks_inspect_commands_linking_completion_count = (guint) 0;
	_tmp72_ = g_strdup ("");
	_g_free0 (folks_inspect_commands_linking_prefix);
	folks_inspect_commands_linking_prefix = _tmp72_;
	result = NULL;
	return result;
}


static gchar* _folks_inspect_commands_linking_subcommand_name_completion_cb_rl_compentry_func_t (const gchar* str, gint a) {
	gchar* result;
	result = folks_inspect_commands_linking_subcommand_name_completion_cb (str, a);
	return result;
}


static gchar** _vala_array_dup7 (gchar** self, int length) {
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


static gchar** folks_inspect_commands_linking_real_complete_subcommand (FolksInspectCommand* base, const gchar* subcommand, int* result_length1) {
	FolksInspectCommandsLinking * self;
	gchar** result = NULL;
	const gchar* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_ = NULL;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gchar** _tmp4_;
	gint _tmp4__length1;
	self = (FolksInspectCommandsLinking*) base;
	g_return_val_if_fail (subcommand != NULL, NULL);
	_tmp0_ = subcommand;
	_tmp2_ = _tmp1_ = rl_completion_matches (_tmp0_, _folks_inspect_commands_linking_subcommand_name_completion_cb_rl_compentry_func_t);
	_tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup7 (_tmp2_, _vala_array_length (_tmp1_)) : ((gpointer) _tmp2_);
	_tmp3__length1 = _vala_array_length (_tmp1_);
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp3__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}


static const gchar* folks_inspect_commands_linking_real_get_name (FolksInspectCommand* base) {
	const gchar* result;
	FolksInspectCommandsLinking* self;
	self = (FolksInspectCommandsLinking*) base;
	result = "linking";
	return result;
}


static const gchar* folks_inspect_commands_linking_real_get_description (FolksInspectCommand* base) {
	const gchar* result;
	FolksInspectCommandsLinking* self;
	self = (FolksInspectCommandsLinking*) base;
	result = "Link and unlink personas";
	return result;
}


static const gchar* folks_inspect_commands_linking_real_get_help (FolksInspectCommand* base) {
	const gchar* result;
	FolksInspectCommandsLinking* self;
	self = (FolksInspectCommandsLinking*) base;
	result = "linking link-personas [persona 1 UID] " "[persona 2 UID] …           " "Link the given personas.\n" "linking link-individuals [individual 1 ID] " "[individual 2 ID] …    " "Link the personas in the given individuals.\n" "linking unlink-individual " "[individual ID]                         " "Unlink the given individual.";
	return result;
}


static void folks_inspect_commands_linking_class_init (FolksInspectCommandsLinkingClass * klass) {
	folks_inspect_commands_linking_parent_class = g_type_class_peek_parent (klass);
	FOLKS_INSPECT_COMMAND_CLASS (klass)->finalize = folks_inspect_commands_linking_finalize;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->run = folks_inspect_commands_linking_real_run;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->run_finish = folks_inspect_commands_linking_real_run_finish;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->complete_subcommand = folks_inspect_commands_linking_real_complete_subcommand;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_name = folks_inspect_commands_linking_real_get_name;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_description = folks_inspect_commands_linking_real_get_description;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_help = folks_inspect_commands_linking_real_get_help;
}


static void folks_inspect_commands_linking_instance_init (FolksInspectCommandsLinking * self) {
}


static void folks_inspect_commands_linking_finalize (FolksInspectCommand* obj) {
	FolksInspectCommandsLinking * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FOLKS_INSPECT_COMMANDS_TYPE_LINKING, FolksInspectCommandsLinking);
	FOLKS_INSPECT_COMMAND_CLASS (folks_inspect_commands_linking_parent_class)->finalize (obj);
}


GType folks_inspect_commands_linking_get_type (void) {
	static volatile gsize folks_inspect_commands_linking_type_id__volatile = 0;
	if (g_once_init_enter (&folks_inspect_commands_linking_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FolksInspectCommandsLinkingClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) folks_inspect_commands_linking_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FolksInspectCommandsLinking), 0, (GInstanceInitFunc) folks_inspect_commands_linking_instance_init, NULL };
		GType folks_inspect_commands_linking_type_id;
		folks_inspect_commands_linking_type_id = g_type_register_static (FOLKS_INSPECT_TYPE_COMMAND, "FolksInspectCommandsLinking", &g_define_type_info, 0);
		g_once_init_leave (&folks_inspect_commands_linking_type_id__volatile, folks_inspect_commands_linking_type_id);
	}
	return folks_inspect_commands_linking_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



