/* command-set.c generated by valac 0.34.0.3-63fa6, the Vala compiler
 * generated from command-set.vala, do not modify */

/*
 * Copyright (C) 2012 Jeremy Whiting <jeremy.whiting@collabora.com>
 *
 * 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:
 *       Jeremy Whiting <jeremy.whiting@collabora.com>
 */

#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <folks/folks.h>
#include <gee.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_SET (folks_inspect_commands_set_get_type ())
#define FOLKS_INSPECT_COMMANDS_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_COMMANDS_TYPE_SET, FolksInspectCommandsSet))
#define FOLKS_INSPECT_COMMANDS_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_COMMANDS_TYPE_SET, FolksInspectCommandsSetClass))
#define FOLKS_INSPECT_COMMANDS_IS_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_COMMANDS_TYPE_SET))
#define FOLKS_INSPECT_COMMANDS_IS_SET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_COMMANDS_TYPE_SET))
#define FOLKS_INSPECT_COMMANDS_SET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_COMMANDS_TYPE_SET, FolksInspectCommandsSetClass))

typedef struct _FolksInspectCommandsSet FolksInspectCommandsSet;
typedef struct _FolksInspectCommandsSetClass FolksInspectCommandsSetClass;
typedef struct _FolksInspectCommandsSetPrivate FolksInspectCommandsSetPrivate;
#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 _FolksInspectCommandsSetRunData FolksInspectCommandsSetRunData;

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_);
	gint (*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 _FolksInspectCommandsSet {
	FolksInspectCommand parent_instance;
	FolksInspectCommandsSetPrivate * priv;
};

struct _FolksInspectCommandsSetClass {
	FolksInspectCommandClass parent_class;
};

struct _FolksInspectCommandsSetRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	FolksInspectCommandsSet* self;
	gchar* command_string;
	gint result;
	gchar** parts;
	gchar** _tmp0_;
	gint parts_length1;
	gint _parts_size_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	const gchar* _tmp9_;
	gboolean _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	const gchar* _tmp12_;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gboolean _tmp14_;
	gchar** _tmp15_;
	gint _tmp15__length1;
	const gchar* _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	const gchar* _tmp22_;
	gchar* id;
	gchar** _tmp23_;
	gint _tmp23__length1;
	const gchar* _tmp24_;
	gchar* _tmp25_;
	FolksIndividual* individual;
	FolksInspectClient* _tmp26_;
	FolksIndividualAggregator* _tmp27_;
	FolksIndividualAggregator* _tmp28_;
	GeeMap* _tmp29_;
	GeeMap* _tmp30_;
	const gchar* _tmp31_;
	gpointer _tmp32_;
	FolksIndividual* _tmp33_;
	const gchar* _tmp34_;
	FolksPersona* persona;
	FolksInspectClient* _tmp35_;
	FolksIndividualAggregator* _tmp36_;
	FolksIndividualAggregator* _tmp37_;
	FolksIndividual* _tmp38_;
	FolksPersona* _tmp39_;
	FolksPersona* _tmp40_;
	FolksIndividual* _tmp41_;
	FolksIndividual* _tmp42_;
	gchar** _tmp43_;
	gint _tmp43__length1;
	const gchar* _tmp44_;
	gchar** _tmp45_;
	gint _tmp45__length1;
	const gchar* _tmp46_;
	GError* e;
	gchar** _tmp47_;
	gint _tmp47__length1;
	const gchar* _tmp48_;
	GError * _inner_error_;
};


static gpointer folks_inspect_commands_set_parent_class = NULL;
static gchar** folks_inspect_commands_set_subcommand_completions;
static gchar** folks_inspect_commands_set_subcommand_completions = NULL;
static guint folks_inspect_commands_set_completion_count;
static guint folks_inspect_commands_set_completion_count = 0U;
static gchar* folks_inspect_commands_set_prefix;
static gchar* folks_inspect_commands_set_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_set_get_type (void) G_GNUC_CONST;
enum  {
	FOLKS_INSPECT_COMMANDS_SET_DUMMY_PROPERTY
};
FolksInspectCommandsSet* folks_inspect_commands_set_new (FolksInspectClient* client);
FolksInspectCommandsSet* folks_inspect_commands_set_construct (GType object_type, FolksInspectClient* client);
FolksInspectCommand* folks_inspect_command_construct (GType object_type, FolksInspectClient* client);
static void folks_inspect_commands_set_real_run_data_free (gpointer _data);
static void folks_inspect_commands_set_real_run (FolksInspectCommand* base, const gchar* command_string, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean folks_inspect_commands_set_real_run_co (FolksInspectCommandsSetRunData* _data_);
gboolean folks_inspect_utils_validate_subcommand (const gchar* command, const gchar* command_string, const gchar* subcommand, gchar** valid_subcommands, int valid_subcommands_length1);
const gchar* folks_inspect_command_get_name (FolksInspectCommand* self);
void folks_inspect_utils_print_line (const gchar* format, ...);
FolksIndividualAggregator* folks_inspect_client_get_aggregator (FolksInspectClient* self);
static void folks_inspect_commands_set_run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
gchar* folks_inspect_commands_set_subcommand_name_completion_cb (const gchar* word, gint state);
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_dup11 (gchar** self, int length);
static gchar** _vala_array_dup12 (gchar** self, int length);
static gchar** folks_inspect_commands_set_real_complete_subcommand (FolksInspectCommand* base, const gchar* subcommand, int* result_length1);
static gchar* _folks_inspect_commands_set_subcommand_name_completion_cb_rl_compentry_func_t (const gchar* str, gint a);
static gchar** _vala_array_dup13 (gchar** self, int length);
static void folks_inspect_commands_set_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);

static const gchar* FOLKS_INSPECT_COMMANDS_SET__valid_subcommands[1] = {"alias"};

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


FolksInspectCommandsSet* folks_inspect_commands_set_new (FolksInspectClient* client) {
	return folks_inspect_commands_set_construct (FOLKS_INSPECT_COMMANDS_TYPE_SET, client);
}


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


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


static void folks_inspect_commands_set_real_run (FolksInspectCommand* base, const gchar* command_string, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FolksInspectCommandsSet * self;
	FolksInspectCommandsSetRunData* _data_;
	FolksInspectCommandsSet* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	self = (FolksInspectCommandsSet*) base;
	_data_ = g_slice_new0 (FolksInspectCommandsSetRunData);
	_data_->_async_result = g_simple_async_result_new (NULL, _callback_, _user_data_, folks_inspect_commands_set_real_run);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, folks_inspect_commands_set_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_set_real_run_co (_data_);
}


static gint folks_inspect_commands_set_real_run_finish (FolksInspectCommand* base, GAsyncResult* _res_) {
	gint result;
	FolksInspectCommandsSetRunData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
	result = _data_->result;
	return result;
}


static gchar* string_strip (const gchar* self) {
	gchar* result = NULL;
	gchar* _result_ = NULL;
	gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	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_set_run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	FolksInspectCommandsSetRunData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	folks_inspect_commands_set_real_run_co (_data_);
}


static gboolean folks_inspect_commands_set_real_run_co (FolksInspectCommandsSetRunData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = g_new0 (gchar*, 0 + 1);
	_data_->parts_length1 = 0;
	_data_->_parts_size_ = 0;
	_data_->parts = _data_->_tmp0_;
	_data_->parts_length1 = 0;
	_data_->_parts_size_ = _data_->parts_length1;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = _data_->command_string;
	if (_data_->_tmp1_ != NULL) {
		_data_->_tmp2_ = NULL;
		_data_->_tmp2_ = _data_->command_string;
		_data_->_tmp3_ = NULL;
		_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_->_tmp5_ = NULL;
	_data_->_tmp5_ = folks_inspect_command_get_name ((FolksInspectCommand*) _data_->self);
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = NULL;
	_data_->_tmp7_ = _data_->command_string;
	_data_->_tmp8_ = NULL;
	_data_->_tmp8__length1 = 0;
	_data_->_tmp8_ = _data_->parts;
	_data_->_tmp8__length1 = _data_->parts_length1;
	_data_->_tmp9_ = NULL;
	_data_->_tmp9_ = _data_->_tmp8_[0];
	_data_->_tmp10_ = FALSE;
	_data_->_tmp10_ = folks_inspect_utils_validate_subcommand (_data_->_tmp6_, _data_->_tmp7_, _data_->_tmp9_, FOLKS_INSPECT_COMMANDS_SET__valid_subcommands, G_N_ELEMENTS (FOLKS_INSPECT_COMMANDS_SET__valid_subcommands));
	if (!_data_->_tmp10_) {
		_data_->result = 1;
		_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_->_tmp11_ = NULL;
	_data_->_tmp11__length1 = 0;
	_data_->_tmp11_ = _data_->parts;
	_data_->_tmp11__length1 = _data_->parts_length1;
	_data_->_tmp12_ = NULL;
	_data_->_tmp12_ = _data_->_tmp11_[0];
	if (g_strcmp0 (_data_->_tmp12_, "alias") == 0) {
		_data_->_tmp13_ = NULL;
		_data_->_tmp13__length1 = 0;
		_data_->_tmp13_ = _data_->parts;
		_data_->_tmp13__length1 = _data_->parts_length1;
		if (_data_->_tmp13__length1 < 3) {
			folks_inspect_utils_print_line ("%s", "Must pass at least one individual ID and a new alias to an " "'alias' subcommand.");
			_data_->result = 1;
			_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_->_tmp15_ = NULL;
		_data_->_tmp15__length1 = 0;
		_data_->_tmp15_ = _data_->parts;
		_data_->_tmp15__length1 = _data_->parts_length1;
		_data_->_tmp16_ = NULL;
		_data_->_tmp16_ = _data_->_tmp15_[1];
		if (_data_->_tmp16_ == NULL) {
			_data_->_tmp14_ = TRUE;
		} else {
			_data_->_tmp17_ = NULL;
			_data_->_tmp17__length1 = 0;
			_data_->_tmp17_ = _data_->parts;
			_data_->_tmp17__length1 = _data_->parts_length1;
			_data_->_tmp18_ = NULL;
			_data_->_tmp18_ = _data_->_tmp17_[1];
			_data_->_tmp19_ = NULL;
			_data_->_tmp19_ = string_strip (_data_->_tmp18_);
			_data_->_tmp20_ = NULL;
			_data_->_tmp20_ = _data_->_tmp19_;
			_data_->_tmp14_ = g_strcmp0 (_data_->_tmp20_, "") == 0;
			_g_free0 (_data_->_tmp20_);
		}
		if (_data_->_tmp14_) {
			_data_->_tmp21_ = NULL;
			_data_->_tmp21__length1 = 0;
			_data_->_tmp21_ = _data_->parts;
			_data_->_tmp21__length1 = _data_->parts_length1;
			_data_->_tmp22_ = NULL;
			_data_->_tmp22_ = _data_->_tmp21_[1];
			folks_inspect_utils_print_line ("Unrecognised individual ID '%s'.", _data_->_tmp22_);
			_data_->result = 1;
			_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_->_tmp23_ = NULL;
		_data_->_tmp23__length1 = 0;
		_data_->_tmp23_ = _data_->parts;
		_data_->_tmp23__length1 = _data_->parts_length1;
		_data_->_tmp24_ = NULL;
		_data_->_tmp24_ = _data_->_tmp23_[1];
		_data_->_tmp25_ = NULL;
		_data_->_tmp25_ = string_strip (_data_->_tmp24_);
		_data_->id = _data_->_tmp25_;
		_data_->_tmp26_ = NULL;
		_data_->_tmp26_ = ((FolksInspectCommand*) _data_->self)->client;
		_data_->_tmp27_ = NULL;
		_data_->_tmp27_ = folks_inspect_client_get_aggregator (_data_->_tmp26_);
		_data_->_tmp28_ = NULL;
		_data_->_tmp28_ = _data_->_tmp27_;
		_data_->_tmp29_ = NULL;
		_data_->_tmp29_ = folks_individual_aggregator_get_individuals (_data_->_tmp28_);
		_data_->_tmp30_ = NULL;
		_data_->_tmp30_ = _data_->_tmp29_;
		_data_->_tmp31_ = NULL;
		_data_->_tmp31_ = _data_->id;
		_data_->_tmp32_ = NULL;
		_data_->_tmp32_ = gee_map_get (_data_->_tmp30_, _data_->_tmp31_);
		_data_->individual = (FolksIndividual*) _data_->_tmp32_;
		_data_->_tmp33_ = NULL;
		_data_->_tmp33_ = _data_->individual;
		if (_data_->_tmp33_ == NULL) {
			_data_->_tmp34_ = NULL;
			_data_->_tmp34_ = _data_->id;
			folks_inspect_utils_print_line ("Unrecognized individual ID '%s'.", _data_->_tmp34_);
			_data_->result = 1;
			_g_object_unref0 (_data_->individual);
			_g_free0 (_data_->id);
			_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_->_tmp35_ = NULL;
			_data_->_tmp35_ = ((FolksInspectCommand*) _data_->self)->client;
			_data_->_tmp36_ = NULL;
			_data_->_tmp36_ = folks_inspect_client_get_aggregator (_data_->_tmp35_);
			_data_->_tmp37_ = NULL;
			_data_->_tmp37_ = _data_->_tmp36_;
			_data_->_tmp38_ = NULL;
			_data_->_tmp38_ = _data_->individual;
			_data_->_state_ = 1;
			folks_individual_aggregator_ensure_individual_property_writeable (_data_->_tmp37_, _data_->_tmp38_, "alias", folks_inspect_commands_set_run_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp39_ = NULL;
			_data_->_tmp39_ = folks_individual_aggregator_ensure_individual_property_writeable_finish (_data_->_tmp37_, _data_->_res_, &_data_->_inner_error_);
			_data_->persona = _data_->_tmp39_;
			if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
				if (_data_->_inner_error_->domain == FOLKS_INDIVIDUAL_AGGREGATOR_ERROR) {
					goto __catch3_folks_individual_aggregator_error;
				}
				_g_object_unref0 (_data_->individual);
				_g_free0 (_data_->id);
				_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;
			}
			_data_->_tmp40_ = NULL;
			_data_->_tmp40_ = _data_->persona;
			_data_->_tmp41_ = NULL;
			_data_->_tmp41_ = folks_persona_get_individual (_data_->_tmp40_);
			_data_->_tmp42_ = NULL;
			_data_->_tmp42_ = _data_->_tmp41_;
			_data_->_tmp43_ = NULL;
			_data_->_tmp43__length1 = 0;
			_data_->_tmp43_ = _data_->parts;
			_data_->_tmp43__length1 = _data_->parts_length1;
			_data_->_tmp44_ = NULL;
			_data_->_tmp44_ = _data_->_tmp43_[2];
			folks_alias_details_set_alias ((FolksAliasDetails*) _data_->_tmp42_, _data_->_tmp44_);
			_data_->_tmp45_ = NULL;
			_data_->_tmp45__length1 = 0;
			_data_->_tmp45_ = _data_->parts;
			_data_->_tmp45__length1 = _data_->parts_length1;
			_data_->_tmp46_ = NULL;
			_data_->_tmp46_ = _data_->_tmp45_[2];
			folks_inspect_utils_print_line ("Setting of individual's alias to '%s' was successful.", _data_->_tmp46_);
			_g_object_unref0 (_data_->persona);
		}
		goto __finally3;
		__catch3_folks_individual_aggregator_error:
		{
			_data_->e = _data_->_inner_error_;
			_data_->_inner_error_ = NULL;
			_data_->_tmp47_ = NULL;
			_data_->_tmp47__length1 = 0;
			_data_->_tmp47_ = _data_->parts;
			_data_->_tmp47__length1 = _data_->parts_length1;
			_data_->_tmp48_ = NULL;
			_data_->_tmp48_ = _data_->_tmp47_[2];
			folks_inspect_utils_print_line ("Setting of individual's alias to '%s' failed.", _data_->_tmp48_);
			_data_->result = 1;
			_g_error_free0 (_data_->e);
			_g_object_unref0 (_data_->individual);
			_g_free0 (_data_->id);
			_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;
		}
		__finally3:
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			_g_object_unref0 (_data_->individual);
			_g_free0 (_data_->id);
			_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;
		}
		_g_object_unref0 (_data_->individual);
		_g_free0 (_data_->id);
	} else {
		g_assert_not_reached ();
	}
	_data_->result = 0;
	_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_->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_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_dup11 (gchar** self, int length) {
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_ = NULL;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


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


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


gchar* folks_inspect_commands_set_subcommand_name_completion_cb (const gchar* word, gint state) {
	gchar* result = NULL;
	gint _tmp0_ = 0;
	gchar* _tmp45_ = NULL;
	g_return_val_if_fail (word != NULL, NULL);
	_tmp0_ = state;
	if (_tmp0_ == 0) {
		gchar** parts = NULL;
		const gchar* _tmp1_ = NULL;
		gchar** _tmp2_ = NULL;
		gchar** _tmp3_ = NULL;
		gint parts_length1 = 0;
		gint _parts_size_ = 0;
		gboolean _tmp4_ = FALSE;
		gchar** _tmp5_ = NULL;
		gint _tmp5__length1 = 0;
		_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) {
			gchar** _tmp6_ = NULL;
			gint _tmp6__length1 = 0;
			const gchar* _tmp7_ = NULL;
			_tmp6_ = parts;
			_tmp6__length1 = parts_length1;
			_tmp7_ = _tmp6_[0];
			_tmp4_ = g_strcmp0 (_tmp7_, "alias") == 0;
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			gchar* last_part = NULL;
			gchar** _tmp8_ = NULL;
			gint _tmp8__length1 = 0;
			gchar** _tmp9_ = NULL;
			gint _tmp9__length1 = 0;
			const gchar* _tmp10_ = NULL;
			gchar* _tmp11_ = NULL;
			gchar** _tmp12_ = NULL;
			gint _tmp12__length1 = 0;
			const gchar* _tmp13_ = NULL;
			const gchar* _tmp18_ = NULL;
			_tmp8_ = parts;
			_tmp8__length1 = parts_length1;
			_tmp9_ = parts;
			_tmp9__length1 = parts_length1;
			_tmp10_ = _tmp8_[_tmp9__length1 - 1];
			_tmp11_ = g_strdup (_tmp10_);
			last_part = _tmp11_;
			_tmp12_ = parts;
			_tmp12__length1 = parts_length1;
			_tmp13_ = _tmp12_[0];
			if (g_strcmp0 (_tmp13_, "alias") == 0) {
				const gchar* _tmp14_ = NULL;
				gchar** _tmp15_ = NULL;
				gchar** _tmp16_ = NULL;
				gchar** _tmp17_ = NULL;
				gint _tmp17__length1 = 0;
				_tmp14_ = last_part;
				_tmp16_ = _tmp15_ = rl_completion_matches (_tmp14_, _folks_inspect_utils_individual_id_completion_cb_rl_compentry_func_t);
				_tmp17_ = (_tmp16_ != NULL) ? _vala_array_dup11 (_tmp16_, _vala_array_length (_tmp15_)) : ((gpointer) _tmp16_);
				_tmp17__length1 = _vala_array_length (_tmp15_);
				folks_inspect_commands_set_subcommand_completions = (_vala_array_free (folks_inspect_commands_set_subcommand_completions, _vala_array_length (folks_inspect_commands_set_subcommand_completions), (GDestroyNotify) g_free), NULL);
				folks_inspect_commands_set_subcommand_completions = _tmp17_;
			}
			_tmp18_ = last_part;
			if (g_strcmp0 (_tmp18_, "") == 0) {
				const gchar* _tmp19_ = NULL;
				gchar* _tmp20_ = NULL;
				_tmp19_ = word;
				_tmp20_ = g_strdup (_tmp19_);
				_g_free0 (folks_inspect_commands_set_prefix);
				folks_inspect_commands_set_prefix = _tmp20_;
			} else {
				const gchar* _tmp21_ = NULL;
				const gchar* _tmp22_ = NULL;
				gint _tmp23_ = 0;
				gint _tmp24_ = 0;
				gchar* _tmp25_ = NULL;
				_tmp21_ = word;
				_tmp22_ = last_part;
				_tmp23_ = strlen (_tmp22_);
				_tmp24_ = _tmp23_;
				_tmp25_ = string_slice (_tmp21_, (glong) 0, (glong) (-_tmp24_));
				_g_free0 (folks_inspect_commands_set_prefix);
				folks_inspect_commands_set_prefix = _tmp25_;
			}
			_g_free0 (last_part);
		} else {
			gchar** _tmp26_ = NULL;
			gint _tmp26__length1 = 0;
			gchar* _tmp27_ = NULL;
			_tmp26_ = (FOLKS_INSPECT_COMMANDS_SET__valid_subcommands != NULL) ? _vala_array_dup12 (FOLKS_INSPECT_COMMANDS_SET__valid_subcommands, G_N_ELEMENTS (FOLKS_INSPECT_COMMANDS_SET__valid_subcommands)) : ((gpointer) FOLKS_INSPECT_COMMANDS_SET__valid_subcommands);
			_tmp26__length1 = G_N_ELEMENTS (FOLKS_INSPECT_COMMANDS_SET__valid_subcommands);
			folks_inspect_commands_set_subcommand_completions = (_vala_array_free (folks_inspect_commands_set_subcommand_completions, _vala_array_length (folks_inspect_commands_set_subcommand_completions), (GDestroyNotify) g_free), NULL);
			folks_inspect_commands_set_subcommand_completions = _tmp26_;
			_tmp27_ = g_strdup ("");
			_g_free0 (folks_inspect_commands_set_prefix);
			folks_inspect_commands_set_prefix = _tmp27_;
		}
		folks_inspect_commands_set_completion_count = (guint) 0;
		parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL);
	}
	while (TRUE) {
		guint _tmp28_ = 0U;
		gchar** _tmp29_ = NULL;
		gint _tmp29__length1 = 0;
		gchar* completion = NULL;
		gchar** _tmp30_ = NULL;
		gint _tmp30__length1 = 0;
		guint _tmp31_ = 0U;
		const gchar* _tmp32_ = NULL;
		gchar* _tmp33_ = NULL;
		gchar* candidate = NULL;
		const gchar* _tmp34_ = NULL;
		const gchar* _tmp35_ = NULL;
		gchar* _tmp36_ = NULL;
		guint _tmp37_ = 0U;
		gboolean _tmp38_ = FALSE;
		gboolean _tmp39_ = FALSE;
		const gchar* _tmp40_ = NULL;
		_tmp28_ = folks_inspect_commands_set_completion_count;
		_tmp29_ = folks_inspect_commands_set_subcommand_completions;
		_tmp29__length1 = _vala_array_length (folks_inspect_commands_set_subcommand_completions);
		if (!(_tmp28_ < ((guint) _tmp29__length1))) {
			break;
		}
		_tmp30_ = folks_inspect_commands_set_subcommand_completions;
		_tmp30__length1 = _vala_array_length (folks_inspect_commands_set_subcommand_completions);
		_tmp31_ = folks_inspect_commands_set_completion_count;
		_tmp32_ = _tmp30_[_tmp31_];
		_tmp33_ = g_strdup (_tmp32_);
		completion = _tmp33_;
		_tmp34_ = folks_inspect_commands_set_prefix;
		_tmp35_ = completion;
		_tmp36_ = g_strconcat (_tmp34_, _tmp35_, NULL);
		candidate = _tmp36_;
		_tmp37_ = folks_inspect_commands_set_completion_count;
		folks_inspect_commands_set_completion_count = _tmp37_ + 1;
		_tmp40_ = completion;
		if (_tmp40_ != NULL) {
			const gchar* _tmp41_ = NULL;
			_tmp41_ = completion;
			_tmp39_ = g_strcmp0 (_tmp41_, "") != 0;
		} else {
			_tmp39_ = FALSE;
		}
		if (_tmp39_) {
			const gchar* _tmp42_ = NULL;
			const gchar* _tmp43_ = NULL;
			gboolean _tmp44_ = FALSE;
			_tmp42_ = candidate;
			_tmp43_ = word;
			_tmp44_ = g_str_has_prefix (_tmp42_, _tmp43_);
			_tmp38_ = _tmp44_;
		} else {
			_tmp38_ = FALSE;
		}
		if (_tmp38_) {
			result = completion;
			_g_free0 (candidate);
			return result;
		}
		_g_free0 (candidate);
		_g_free0 (completion);
	}
	folks_inspect_commands_set_subcommand_completions = (_vala_array_free (folks_inspect_commands_set_subcommand_completions, _vala_array_length (folks_inspect_commands_set_subcommand_completions), (GDestroyNotify) g_free), NULL);
	folks_inspect_commands_set_subcommand_completions = NULL;
	folks_inspect_commands_set_completion_count = (guint) 0;
	_tmp45_ = g_strdup ("");
	_g_free0 (folks_inspect_commands_set_prefix);
	folks_inspect_commands_set_prefix = _tmp45_;
	result = NULL;
	return result;
}


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


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


static gchar** folks_inspect_commands_set_real_complete_subcommand (FolksInspectCommand* base, const gchar* subcommand, int* result_length1) {
	FolksInspectCommandsSet * self;
	gchar** result = NULL;
	const gchar* _tmp0_ = NULL;
	gchar** _tmp1_ = NULL;
	gchar** _tmp2_ = NULL;
	gchar** _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	gchar** _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	self = (FolksInspectCommandsSet*) base;
	g_return_val_if_fail (subcommand != NULL, NULL);
	_tmp0_ = subcommand;
	_tmp2_ = _tmp1_ = rl_completion_matches (_tmp0_, _folks_inspect_commands_set_subcommand_name_completion_cb_rl_compentry_func_t);
	_tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup13 (_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_set_real_get_name (FolksInspectCommand* base) {
	const gchar* result;
	FolksInspectCommandsSet* self;
	self = (FolksInspectCommandsSet*) base;
	result = "set";
	return result;
}


static const gchar* folks_inspect_commands_set_real_get_description (FolksInspectCommand* base) {
	const gchar* result;
	FolksInspectCommandsSet* self;
	self = (FolksInspectCommandsSet*) base;
	result = "Set an individual's properties";
	return result;
}


static const gchar* folks_inspect_commands_set_real_get_help (FolksInspectCommand* base) {
	const gchar* result;
	FolksInspectCommandsSet* self;
	self = (FolksInspectCommandsSet*) base;
	result = "set alias [individual UID] [new alias]" "   Set the alias of the given individual.";
	return result;
}


static void folks_inspect_commands_set_class_init (FolksInspectCommandsSetClass * klass) {
	folks_inspect_commands_set_parent_class = g_type_class_peek_parent (klass);
	((FolksInspectCommandClass *) klass)->finalize = folks_inspect_commands_set_finalize;
	((FolksInspectCommandClass *) klass)->run = folks_inspect_commands_set_real_run;
	((FolksInspectCommandClass *) klass)->run_finish = folks_inspect_commands_set_real_run_finish;
	((FolksInspectCommandClass *) klass)->complete_subcommand = folks_inspect_commands_set_real_complete_subcommand;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_name = folks_inspect_commands_set_real_get_name;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_description = folks_inspect_commands_set_real_get_description;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_help = folks_inspect_commands_set_real_get_help;
}


static void folks_inspect_commands_set_instance_init (FolksInspectCommandsSet * self) {
}


static void folks_inspect_commands_set_finalize (FolksInspectCommand* obj) {
	FolksInspectCommandsSet * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FOLKS_INSPECT_COMMANDS_TYPE_SET, FolksInspectCommandsSet);
	FOLKS_INSPECT_COMMAND_CLASS (folks_inspect_commands_set_parent_class)->finalize (obj);
}


GType folks_inspect_commands_set_get_type (void) {
	static volatile gsize folks_inspect_commands_set_type_id__volatile = 0;
	if (g_once_init_enter (&folks_inspect_commands_set_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FolksInspectCommandsSetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) folks_inspect_commands_set_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FolksInspectCommandsSet), 0, (GInstanceInitFunc) folks_inspect_commands_set_instance_init, NULL };
		GType folks_inspect_commands_set_type_id;
		folks_inspect_commands_set_type_id = g_type_register_static (FOLKS_INSPECT_TYPE_COMMAND, "FolksInspectCommandsSet", &g_define_type_info, 0);
		g_once_init_leave (&folks_inspect_commands_set_type_id__volatile, folks_inspect_commands_set_type_id);
	}
	return folks_inspect_commands_set_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;
}



