/* contacts-link-operation.c generated by valac 0.56.0, the Vala compiler
 * generated from contacts-link-operation.vala, do not modify */

/*
 * Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "contacts.h"
#include <gee.h>
#include <glib-object.h>
#include <folks/folks.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>

enum  {
	CONTACTS_LINK_OPERATION_0_PROPERTY,
	CONTACTS_LINK_OPERATION_REVERSABLE_PROPERTY,
	CONTACTS_LINK_OPERATION_DESCRIPTION_PROPERTY,
	CONTACTS_LINK_OPERATION_NUM_PROPERTIES
};
static GParamSpec* contacts_link_operation_properties[CONTACTS_LINK_OPERATION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _ContactsLinkOperationExecuteData ContactsLinkOperationExecuteData;
typedef struct _ContactsLinkOperationUndoData ContactsLinkOperationUndoData;

struct _ContactsLinkOperationPrivate {
	ContactsStore* store;
	GeeLinkedList* individuals;
	GeeHashSet* personas_to_link;
	gboolean _finished;
	gboolean _reversable;
	gchar* _description;
};

struct _ContactsLinkOperationExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ContactsLinkOperation* self;
	GeeHashSet* personas_to_link;
	GeeHashSet* _tmp0_;
	GeeLinkedList* _i_list;
	GeeLinkedList* _tmp1_;
	gint _i_size;
	GeeLinkedList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint _i_index;
	gint _tmp5_;
	gint _tmp6_;
	FolksIndividual* i;
	GeeLinkedList* _tmp7_;
	gpointer _tmp8_;
	GeeHashSet* saved_personas;
	GeeHashSet* _tmp9_;
	GeeIterator* _persona_it;
	FolksIndividual* _tmp10_;
	GeeSet* _tmp11_;
	GeeSet* _tmp12_;
	GeeIterator* _tmp13_;
	GeeIterator* _tmp14_;
	FolksPersona* persona;
	GeeIterator* _tmp15_;
	gpointer _tmp16_;
	GeeHashSet* _tmp17_;
	FolksPersona* _tmp18_;
	GeeHashSet* _tmp19_;
	FolksPersona* _tmp20_;
	GeeHashSet* _tmp21_;
	GeeHashSet* _tmp22_;
	ContactsStore* _tmp23_;
	FolksIndividualAggregator* _tmp24_;
	FolksIndividualAggregator* _tmp25_;
	GeeHashSet* _tmp26_;
	GError* _inner_error0_;
};

struct _ContactsLinkOperationUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ContactsLinkOperation* self;
	FolksIndividual* individual;
	GeeHashSet* _tmp0_;
	gpointer _tmp1_;
	GeeHashSet* _tmp2_;
	gpointer _tmp3_;
	FolksPersona* _tmp4_;
	FolksIndividual* _tmp5_;
	FolksIndividual* _tmp6_;
	FolksIndividual* _tmp7_;
	FolksIndividual* _tmp8_;
	ContactsStore* _tmp9_;
	FolksIndividualAggregator* _tmp10_;
	FolksIndividualAggregator* _tmp11_;
	FolksIndividual* _tmp12_;
	GeeIterator* _personas_it;
	GeeHashSet* _tmp13_;
	GeeIterator* _tmp14_;
	GeeIterator* _tmp15_;
	GeeHashSet* personas;
	GeeIterator* _tmp16_;
	gpointer _tmp17_;
	ContactsStore* _tmp18_;
	FolksIndividualAggregator* _tmp19_;
	FolksIndividualAggregator* _tmp20_;
	GeeHashSet* _tmp21_;
	GError* _inner_error0_;
};

static gint ContactsLinkOperation_private_offset;
static gpointer contacts_link_operation_parent_class = NULL;
static ContactsOperationIface * contacts_link_operation_contacts_operation_parent_iface = NULL;

static void contacts_link_operation_real_execute_data_free (gpointer _data);
static void contacts_link_operation_real_execute (ContactsOperation* base,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
static gboolean contacts_link_operation_real_execute_co (ContactsLinkOperationExecuteData* _data_);
static void contacts_link_operation_execute_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_);
static void contacts_link_operation_real__undo_data_free (gpointer _data);
static void contacts_link_operation_real__undo (ContactsOperation* base,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
static gboolean contacts_link_operation_real__undo_co (ContactsLinkOperationUndoData* _data_);
static gboolean __lambda17_ (ContactsLinkOperation* self);
static gboolean ___lambda17__gee_predicate (gconstpointer g,
                                     gpointer self);
static gboolean __lambda18_ (ContactsLinkOperation* self);
static gboolean ___lambda18__gee_predicate (gconstpointer g,
                                     gpointer self);
static void _contacts_link_operation_undo_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static gboolean contacts_link_operation_get_finished (ContactsLinkOperation* self);
static void contacts_link_operation_set_finished (ContactsLinkOperation* self,
                                           gboolean value);
static void contacts_link_operation_finalize (GObject * obj);
static GType contacts_link_operation_get_type_once (void);
static void _vala_contacts_link_operation_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_contacts_link_operation_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);

static inline gpointer
contacts_link_operation_get_instance_private (ContactsLinkOperation* self)
{
	return G_STRUCT_MEMBER_P (self, ContactsLinkOperation_private_offset);
}

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

ContactsLinkOperation*
contacts_link_operation_construct (GType object_type,
                                   ContactsStore* store,
                                   GeeLinkedList* individuals)
{
	ContactsLinkOperation * self = NULL;
	GeeLinkedList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gchar* _tmp5_;
	g_return_val_if_fail (store != NULL, NULL);
	g_return_val_if_fail (individuals != NULL, NULL);
	self = (ContactsLinkOperation*) g_object_new (object_type, NULL);
	self->priv->store = store;
	_tmp0_ = _g_object_ref0 (individuals);
	_g_object_unref0 (self->priv->individuals);
	self->priv->individuals = _tmp0_;
	_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) individuals);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) individuals);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strdup_printf (ngettext ("Linked %d contact", "Linked %d contacts", (gulong) _tmp2_), _tmp4_);
	_g_free0 (self->priv->_description);
	self->priv->_description = _tmp5_;
	return self;
}

ContactsLinkOperation*
contacts_link_operation_new (ContactsStore* store,
                             GeeLinkedList* individuals)
{
	return contacts_link_operation_construct (CONTACTS_TYPE_LINK_OPERATION, store, individuals);
}

static void
contacts_link_operation_real_execute_data_free (gpointer _data)
{
	ContactsLinkOperationExecuteData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (ContactsLinkOperationExecuteData, _data_);
}

static void
contacts_link_operation_real_execute (ContactsOperation* base,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	ContactsLinkOperation * self;
	ContactsLinkOperationExecuteData* _data_;
	ContactsLinkOperation* _tmp0_;
	self = (ContactsLinkOperation*) base;
	_data_ = g_slice_new0 (ContactsLinkOperationExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, contacts_link_operation_real_execute_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	contacts_link_operation_real_execute_co (_data_);
}

static void
contacts_link_operation_execute_finish (ContactsOperation* base,
                                        GAsyncResult* _res_,
                                        GError** error)
{
	ContactsLinkOperationExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/**
   * Link individuals
   */
static void
contacts_link_operation_execute_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_)
{
	ContactsLinkOperationExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	contacts_link_operation_real_execute_co (_data_);
}

static gboolean
contacts_link_operation_real_execute_co (ContactsLinkOperationExecuteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gee_hash_set_new (FOLKS_TYPE_PERSONA, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->personas_to_link = _data_->_tmp0_;
	{
		_data_->_tmp1_ = _data_->self->priv->individuals;
		_data_->_i_list = _data_->_tmp1_;
		_data_->_tmp2_ = _data_->_i_list;
		_data_->_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp2_);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_i_size = _data_->_tmp4_;
		_data_->_i_index = -1;
		while (TRUE) {
			_data_->_i_index = _data_->_i_index + 1;
			_data_->_tmp5_ = _data_->_i_index;
			_data_->_tmp6_ = _data_->_i_size;
			if (!(_data_->_tmp5_ < _data_->_tmp6_)) {
				break;
			}
			_data_->_tmp7_ = _data_->_i_list;
			_data_->_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp7_, _data_->_i_index);
			_data_->i = (FolksIndividual*) _data_->_tmp8_;
			_data_->_tmp9_ = gee_hash_set_new (FOLKS_TYPE_PERSONA, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
			_data_->saved_personas = _data_->_tmp9_;
			{
				_data_->_tmp10_ = _data_->i;
				_data_->_tmp11_ = folks_individual_get_personas (_data_->_tmp10_);
				_data_->_tmp12_ = _data_->_tmp11_;
				_data_->_tmp13_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp12_);
				_data_->_persona_it = _data_->_tmp13_;
				while (TRUE) {
					_data_->_tmp14_ = _data_->_persona_it;
					if (!gee_iterator_next (_data_->_tmp14_)) {
						break;
					}
					_data_->_tmp15_ = _data_->_persona_it;
					_data_->_tmp16_ = gee_iterator_get (_data_->_tmp15_);
					_data_->persona = (FolksPersona*) _data_->_tmp16_;
					_data_->_tmp17_ = _data_->personas_to_link;
					_data_->_tmp18_ = _data_->persona;
					gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp17_, _data_->_tmp18_);
					_data_->_tmp19_ = _data_->saved_personas;
					_data_->_tmp20_ = _data_->persona;
					gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp19_, _data_->_tmp20_);
					_g_object_unref0 (_data_->persona);
				}
				_g_object_unref0 (_data_->_persona_it);
			}
			_data_->_tmp21_ = _data_->self->priv->personas_to_link;
			_data_->_tmp22_ = _data_->saved_personas;
			gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp21_, _data_->_tmp22_);
			_g_object_unref0 (_data_->saved_personas);
			_g_object_unref0 (_data_->i);
		}
	}
	_data_->_tmp23_ = _data_->self->priv->store;
	_data_->_tmp24_ = contacts_store_get_aggregator (_data_->_tmp23_);
	_data_->_tmp25_ = _data_->_tmp24_;
	_data_->_tmp26_ = _data_->personas_to_link;
	_data_->_state_ = 1;
	folks_individual_aggregator_link_personas (_data_->_tmp25_, (GeeSet*) _data_->_tmp26_, contacts_link_operation_execute_ready, _data_);
	return FALSE;
	_state_1:
	folks_individual_aggregator_link_personas_finish (_data_->_tmp25_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->personas_to_link);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->_reversable = TRUE;
	g_object_notify ((GObject*) _data_->self, "reversable");
	_g_object_unref0 (_data_->personas_to_link);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
contacts_link_operation_real__undo_data_free (gpointer _data)
{
	ContactsLinkOperationUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (ContactsLinkOperationUndoData, _data_);
}

static void
contacts_link_operation_real__undo (ContactsOperation* base,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	ContactsLinkOperation * self;
	ContactsLinkOperationUndoData* _data_;
	ContactsLinkOperation* _tmp0_;
	self = (ContactsLinkOperation*) base;
	_data_ = g_slice_new0 (ContactsLinkOperationUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, contacts_link_operation_real__undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	contacts_link_operation_real__undo_co (_data_);
}

static void
_contacts_link_operation_undo_finish (ContactsOperation* base,
                                      GAsyncResult* _res_,
                                      GError** error)
{
	ContactsLinkOperationUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/**
   * Undoing means unlinking
   */
static gboolean
__lambda17_ (ContactsLinkOperation* self)
{
	gboolean result;
	result = TRUE;
	return result;
}

static gboolean
___lambda17__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = __lambda17_ ((ContactsLinkOperation*) self);
	return result;
}

static gboolean
__lambda18_ (ContactsLinkOperation* self)
{
	gboolean result;
	result = TRUE;
	return result;
}

static gboolean
___lambda18__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = __lambda18_ ((ContactsLinkOperation*) self);
	return result;
}

static void
_contacts_link_operation_undo_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	ContactsLinkOperationUndoData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	contacts_link_operation_real__undo_co (_data_);
}

static gboolean
contacts_link_operation_real__undo_co (ContactsLinkOperationUndoData* _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_ = _data_->self->priv->personas_to_link;
	_data_->_tmp1_ = gee_traversable_first_match ((GeeTraversable*) _data_->_tmp0_, ___lambda17__gee_predicate, g_object_ref (_data_->self), g_object_unref);
	_data_->_tmp2_ = (GeeHashSet*) _data_->_tmp1_;
	_data_->_tmp3_ = gee_traversable_first_match ((GeeTraversable*) _data_->_tmp2_, ___lambda18__gee_predicate, g_object_ref (_data_->self), g_object_unref);
	_data_->_tmp4_ = (FolksPersona*) _data_->_tmp3_;
	_data_->_tmp5_ = folks_persona_get_individual (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = _g_object_ref0 (_data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	_g_object_unref0 (_data_->_tmp4_);
	_g_object_unref0 (_data_->_tmp2_);
	_data_->individual = _data_->_tmp8_;
	_data_->_tmp9_ = _data_->self->priv->store;
	_data_->_tmp10_ = contacts_store_get_aggregator (_data_->_tmp9_);
	_data_->_tmp11_ = _data_->_tmp10_;
	_data_->_tmp12_ = _data_->individual;
	_data_->_state_ = 1;
	folks_individual_aggregator_unlink_individual (_data_->_tmp11_, _data_->_tmp12_, _contacts_link_operation_undo_ready, _data_);
	return FALSE;
	_state_1:
	folks_individual_aggregator_unlink_individual_finish (_data_->_tmp11_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->individual);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->_tmp13_ = _data_->self->priv->personas_to_link;
		_data_->_tmp14_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _data_->_tmp13_);
		_data_->_personas_it = _data_->_tmp14_;
		while (TRUE) {
			_data_->_tmp15_ = _data_->_personas_it;
			if (!gee_iterator_next (_data_->_tmp15_)) {
				break;
			}
			_data_->_tmp16_ = _data_->_personas_it;
			_data_->_tmp17_ = gee_iterator_get (_data_->_tmp16_);
			_data_->personas = (GeeHashSet*) _data_->_tmp17_;
			_data_->_tmp18_ = _data_->self->priv->store;
			_data_->_tmp19_ = contacts_store_get_aggregator (_data_->_tmp18_);
			_data_->_tmp20_ = _data_->_tmp19_;
			_data_->_tmp21_ = _data_->personas;
			_data_->_state_ = 2;
			folks_individual_aggregator_link_personas (_data_->_tmp20_, (GeeSet*) _data_->_tmp21_, _contacts_link_operation_undo_ready, _data_);
			return FALSE;
			_state_2:
			folks_individual_aggregator_link_personas_finish (_data_->_tmp20_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->personas);
				_g_object_unref0 (_data_->_personas_it);
				_g_object_unref0 (_data_->individual);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_g_object_unref0 (_data_->personas);
		}
		_g_object_unref0 (_data_->_personas_it);
	}
	_data_->self->priv->_reversable = FALSE;
	g_object_notify ((GObject*) _data_->self, "reversable");
	_g_object_unref0 (_data_->individual);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gboolean
contacts_link_operation_get_finished (ContactsLinkOperation* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_finished;
	return result;
}

static void
contacts_link_operation_set_finished (ContactsLinkOperation* self,
                                      gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_finished = value;
}

static gboolean
contacts_link_operation_real_get_reversable (ContactsOperation* base)
{
	gboolean result;
	ContactsLinkOperation* self;
	self = (ContactsLinkOperation*) base;
	result = self->priv->_reversable;
	return result;
}

static gchar*
contacts_link_operation_real_get_description (ContactsOperation* base)
{
	gchar* result;
	ContactsLinkOperation* self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	self = (ContactsLinkOperation*) base;
	_tmp0_ = self->priv->_description;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
contacts_link_operation_class_init (ContactsLinkOperationClass * klass,
                                    gpointer klass_data)
{
	contacts_link_operation_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ContactsLinkOperation_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_contacts_link_operation_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_contacts_link_operation_set_property;
	G_OBJECT_CLASS (klass)->finalize = contacts_link_operation_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_LINK_OPERATION_REVERSABLE_PROPERTY, contacts_link_operation_properties[CONTACTS_LINK_OPERATION_REVERSABLE_PROPERTY] = g_param_spec_boolean ("reversable", "reversable", "reversable", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_LINK_OPERATION_DESCRIPTION_PROPERTY, contacts_link_operation_properties[CONTACTS_LINK_OPERATION_DESCRIPTION_PROPERTY] = g_param_spec_string ("description", "description", "description", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
contacts_link_operation_contacts_operation_interface_init (ContactsOperationIface * iface,
                                                           gpointer iface_data)
{
	contacts_link_operation_contacts_operation_parent_iface = g_type_interface_peek_parent (iface);
	iface->execute = (void (*) (ContactsOperation*, GAsyncReadyCallback, gpointer)) contacts_link_operation_real_execute;
	iface->execute_finish = (void (*) (ContactsOperation*, GAsyncResult*, GError**)) contacts_link_operation_execute_finish;
	iface->_undo = (void (*) (ContactsOperation*, GAsyncReadyCallback, gpointer)) contacts_link_operation_real__undo;
	iface->_undo_finish = (void (*) (ContactsOperation*, GAsyncResult*, GError**)) _contacts_link_operation_undo_finish;
	iface->get_reversable = contacts_link_operation_real_get_reversable;
	iface->get_description = contacts_link_operation_real_get_description;
}

static void
contacts_link_operation_instance_init (ContactsLinkOperation * self,
                                       gpointer klass)
{
	GeeHashSet* _tmp0_;
	self->priv = contacts_link_operation_get_instance_private (self);
	_tmp0_ = gee_hash_set_new (GEE_TYPE_HASH_SET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->personas_to_link = _tmp0_;
	self->priv->_finished = FALSE;
	self->priv->_reversable = FALSE;
}

static void
contacts_link_operation_finalize (GObject * obj)
{
	ContactsLinkOperation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_LINK_OPERATION, ContactsLinkOperation);
	_g_object_unref0 (self->priv->individuals);
	_g_object_unref0 (self->priv->personas_to_link);
	_g_free0 (self->priv->_description);
	G_OBJECT_CLASS (contacts_link_operation_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
contacts_link_operation_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsLinkOperationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_link_operation_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsLinkOperation), 0, (GInstanceInitFunc) contacts_link_operation_instance_init, NULL };
	static const GInterfaceInfo contacts_operation_info = { (GInterfaceInitFunc) contacts_link_operation_contacts_operation_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType contacts_link_operation_type_id;
	contacts_link_operation_type_id = g_type_register_static (G_TYPE_OBJECT, "ContactsLinkOperation", &g_define_type_info, 0);
	g_type_add_interface_static (contacts_link_operation_type_id, CONTACTS_TYPE_OPERATION, &contacts_operation_info);
	ContactsLinkOperation_private_offset = g_type_add_instance_private (contacts_link_operation_type_id, sizeof (ContactsLinkOperationPrivate));
	return contacts_link_operation_type_id;
}

GType
contacts_link_operation_get_type (void)
{
	static volatile gsize contacts_link_operation_type_id__once = 0;
	if (g_once_init_enter (&contacts_link_operation_type_id__once)) {
		GType contacts_link_operation_type_id;
		contacts_link_operation_type_id = contacts_link_operation_get_type_once ();
		g_once_init_leave (&contacts_link_operation_type_id__once, contacts_link_operation_type_id);
	}
	return contacts_link_operation_type_id__once;
}

static void
_vala_contacts_link_operation_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	ContactsLinkOperation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_LINK_OPERATION, ContactsLinkOperation);
	switch (property_id) {
		case CONTACTS_LINK_OPERATION_REVERSABLE_PROPERTY:
		g_value_set_boolean (value, contacts_operation_get_reversable ((ContactsOperation*) self));
		break;
		case CONTACTS_LINK_OPERATION_DESCRIPTION_PROPERTY:
		g_value_take_string (value, contacts_operation_get_description ((ContactsOperation*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_contacts_link_operation_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	ContactsLinkOperation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_LINK_OPERATION, ContactsLinkOperation);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

