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

/*
 * Copyright (C) 2018 Niels De Graef <nielsdegraef@gmail.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 <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <folks/folks.h>
#include <gee.h>
#include <config.h>

typedef enum  {
	CONTACTS_TYPEDESCRIPTOR_SOURCE_VCARD,
	CONTACTS_TYPEDESCRIPTOR_SOURCE_OTHER,
	CONTACTS_TYPEDESCRIPTOR_SOURCE_CUSTOM
} ContactsTypeDescriptorSource;

#define CONTACTS_TYPEDESCRIPTOR_TYPE_SOURCE (contacts_typedescriptor_source_get_type ())
enum  {
	CONTACTS_TYPEDESCRIPTOR_0_PROPERTY,
	CONTACTS_TYPEDESCRIPTOR_DISPLAY_NAME_PROPERTY,
	CONTACTS_TYPEDESCRIPTOR_NUM_PROPERTIES
};
static GParamSpec* contacts_typedescriptor_properties[CONTACTS_TYPEDESCRIPTOR_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

struct _ContactsTypeDescriptorPrivate {
	ContactsTypeDescriptorSource source;
};

static gint ContactsTypeDescriptor_private_offset;
static gpointer contacts_typedescriptor_parent_class = NULL;

static GType contacts_typedescriptor_source_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static const gchar* contacts_typedescriptor_source_to_string (ContactsTypeDescriptorSource self);
static gchar** _vala_array_dup3 (gchar** self,
                          gssize length);
static void contacts_typedescriptor_finalize (GObject * obj);
static GType contacts_typedescriptor_get_type_once (void);
static void _vala_contacts_typedescriptor_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
contacts_typedescriptor_get_instance_private (ContactsTypeDescriptor* self)
{
	return G_STRUCT_MEMBER_P (self, ContactsTypeDescriptor_private_offset);
}

static const gchar*
contacts_typedescriptor_source_to_string (ContactsTypeDescriptorSource self)
{
	const gchar* result;
	switch (self) {
		case CONTACTS_TYPEDESCRIPTOR_SOURCE_VCARD:
		{
			result = "vcard";
			return result;
		}
		case CONTACTS_TYPEDESCRIPTOR_SOURCE_OTHER:
		{
			result = "other";
			return result;
		}
		case CONTACTS_TYPEDESCRIPTOR_SOURCE_CUSTOM:
		{
			result = "custom";
			return result;
		}
		default:
		break;
	}
	result = "INVALID";
	return result;
}

 G_GNUC_NO_INLINE static GType
contacts_typedescriptor_source_get_type_once (void)
{
	static const GEnumValue values[] = {{CONTACTS_TYPEDESCRIPTOR_SOURCE_VCARD, "CONTACTS_TYPEDESCRIPTOR_SOURCE_VCARD", "vcard"}, {CONTACTS_TYPEDESCRIPTOR_SOURCE_OTHER, "CONTACTS_TYPEDESCRIPTOR_SOURCE_OTHER", "other"}, {CONTACTS_TYPEDESCRIPTOR_SOURCE_CUSTOM, "CONTACTS_TYPEDESCRIPTOR_SOURCE_CUSTOM", "custom"}, {0, NULL, NULL}};
	GType contacts_typedescriptor_source_type_id;
	contacts_typedescriptor_source_type_id = g_enum_register_static ("ContactsTypeDescriptorSource", values);
	return contacts_typedescriptor_source_type_id;
}

static GType
contacts_typedescriptor_source_get_type (void)
{
	static volatile gsize contacts_typedescriptor_source_type_id__once = 0;
	if (g_once_init_enter (&contacts_typedescriptor_source_type_id__once)) {
		GType contacts_typedescriptor_source_type_id;
		contacts_typedescriptor_source_type_id = contacts_typedescriptor_source_get_type_once ();
		g_once_init_leave (&contacts_typedescriptor_source_type_id__once, contacts_typedescriptor_source_type_id);
	}
	return contacts_typedescriptor_source_type_id__once;
}

/**
   * Creates a TypeDescriptor which is mappable to the given VCard Type strings.
   */
static gchar**
_vala_array_dup3 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize 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;
	}
	return NULL;
}

ContactsTypeDescriptor*
contacts_typedescriptor_construct_vcard (GType object_type,
                                         const gchar* untranslated_name,
                                         gchar** types,
                                         gint types_length1)
{
	ContactsTypeDescriptor * self = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (untranslated_name != NULL, NULL);
	self = (ContactsTypeDescriptor*) g_object_new (object_type, NULL);
	self->priv->source = CONTACTS_TYPEDESCRIPTOR_SOURCE_VCARD;
	_tmp0_ = g_strdup (untranslated_name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	_tmp1_ = (types != NULL) ? _vala_array_dup3 (types, types_length1) : types;
	_tmp1__length1 = types_length1;
	self->vcard_types = (_vala_array_free (self->vcard_types, self->vcard_types_length1, (GDestroyNotify) g_free), NULL);
	self->vcard_types = _tmp1_;
	self->vcard_types_length1 = _tmp1__length1;
	return self;
}

ContactsTypeDescriptor*
contacts_typedescriptor_new_vcard (const gchar* untranslated_name,
                                   gchar** types,
                                   gint types_length1)
{
	return contacts_typedescriptor_construct_vcard (CONTACTS_TYPE_TYPEDESCRIPTOR, untranslated_name, types, types_length1);
}

/**
   * Creates a TypeDescriptor with a custom label
   */
ContactsTypeDescriptor*
contacts_typedescriptor_construct_custom (GType object_type,
                                          const gchar* name)
{
	ContactsTypeDescriptor * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (name != NULL, NULL);
	self = (ContactsTypeDescriptor*) g_object_new (object_type, NULL);
	self->priv->source = CONTACTS_TYPEDESCRIPTOR_SOURCE_CUSTOM;
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	return self;
}

ContactsTypeDescriptor*
contacts_typedescriptor_new_custom (const gchar* name)
{
	return contacts_typedescriptor_construct_custom (CONTACTS_TYPE_TYPEDESCRIPTOR, name);
}

/**
   * Creates a TypeDescriptor which represents all non-representable types.
   */
ContactsTypeDescriptor*
contacts_typedescriptor_construct_other (GType object_type)
{
	ContactsTypeDescriptor * self = NULL;
	gchar* _tmp0_;
	self = (ContactsTypeDescriptor*) g_object_new (object_type, NULL);
	self->priv->source = CONTACTS_TYPEDESCRIPTOR_SOURCE_OTHER;
	_tmp0_ = g_strdup (N_ ("Other"));
	_g_free0 (self->name);
	self->name = _tmp0_;
	return self;
}

ContactsTypeDescriptor*
contacts_typedescriptor_new_other (void)
{
	return contacts_typedescriptor_construct_other (CONTACTS_TYPE_TYPEDESCRIPTOR);
}

gboolean
contacts_typedescriptor_is_custom (ContactsTypeDescriptor* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->source == CONTACTS_TYPEDESCRIPTOR_SOURCE_CUSTOM;
	return result;
}

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

void
contacts_typedescriptor_save_to_field_details (ContactsTypeDescriptor* self,
                                               FolksAbstractFieldDetails* details)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	GeeMultiMap* old_parameters = NULL;
	GeeMultiMap* _tmp2_;
	GeeMultiMap* _tmp3_;
	GeeMultiMap* _tmp4_;
	GeeHashMultiMap* new_parameters = NULL;
	GeeHashMultiMap* _tmp5_;
	gboolean has_pref = FALSE;
	GeeHashMultiMap* _tmp48_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (details != NULL);
	_tmp0_ = contacts_typedescriptor_to_string (self);
	_tmp1_ = _tmp0_;
	g_debug ("contacts-type-descriptor.vala:91: Saving type %s", _tmp1_);
	_g_free0 (_tmp1_);
	_tmp2_ = folks_abstract_field_details_get_parameters (details);
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	old_parameters = _tmp4_;
	_tmp5_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	new_parameters = _tmp5_;
	has_pref = FALSE;
	{
		GeeIterator* _val_it = NULL;
		GeeMultiMap* _tmp6_;
		GeeCollection* _tmp7_;
		GeeCollection* _tmp8_;
		GeeIterator* _tmp9_;
		GeeIterator* _tmp10_;
		_tmp6_ = old_parameters;
		_tmp7_ = gee_multi_map_get (_tmp6_, "type");
		_tmp8_ = _tmp7_;
		_tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_);
		_tmp10_ = _tmp9_;
		_g_object_unref0 (_tmp8_);
		_val_it = _tmp10_;
		while (TRUE) {
			GeeIterator* _tmp11_;
			gchar* val = NULL;
			GeeIterator* _tmp12_;
			gpointer _tmp13_;
			const gchar* _tmp14_;
			_tmp11_ = _val_it;
			if (!gee_iterator_next (_tmp11_)) {
				break;
			}
			_tmp12_ = _val_it;
			_tmp13_ = gee_iterator_get (_tmp12_);
			val = (gchar*) _tmp13_;
			_tmp14_ = val;
			if (g_ascii_strcasecmp (_tmp14_, "PREF") == 0) {
				has_pref = TRUE;
				_g_free0 (val);
				break;
			}
			_g_free0 (val);
		}
		_g_object_unref0 (_val_it);
	}
	{
		GeeIterator* _param_it = NULL;
		GeeMultiMap* _tmp15_;
		GeeSet* _tmp16_;
		GeeSet* _tmp17_;
		GeeIterator* _tmp18_;
		GeeIterator* _tmp19_;
		_tmp15_ = old_parameters;
		_tmp16_ = gee_multi_map_get_keys (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = gee_iterable_iterator ((GeeIterable*) _tmp17_);
		_tmp19_ = _tmp18_;
		_g_object_unref0 (_tmp17_);
		_param_it = _tmp19_;
		while (TRUE) {
			GeeIterator* _tmp20_;
			gchar* param = NULL;
			GeeIterator* _tmp21_;
			gpointer _tmp22_;
			gboolean _tmp23_ = FALSE;
			const gchar* _tmp24_;
			_tmp20_ = _param_it;
			if (!gee_iterator_next (_tmp20_)) {
				break;
			}
			_tmp21_ = _param_it;
			_tmp22_ = gee_iterator_get (_tmp21_);
			param = (gchar*) _tmp22_;
			_tmp24_ = param;
			if (g_strcmp0 (_tmp24_, "type") != 0) {
				const gchar* _tmp25_;
				_tmp25_ = param;
				_tmp23_ = g_strcmp0 (_tmp25_, CONTACTS_TYPEDESCRIPTOR_X_GOOGLE_LABEL) != 0;
			} else {
				_tmp23_ = FALSE;
			}
			if (_tmp23_) {
				{
					GeeIterator* _val_it = NULL;
					GeeMultiMap* _tmp26_;
					const gchar* _tmp27_;
					GeeCollection* _tmp28_;
					GeeCollection* _tmp29_;
					GeeIterator* _tmp30_;
					GeeIterator* _tmp31_;
					_tmp26_ = old_parameters;
					_tmp27_ = param;
					_tmp28_ = gee_multi_map_get (_tmp26_, _tmp27_);
					_tmp29_ = _tmp28_;
					_tmp30_ = gee_iterable_iterator ((GeeIterable*) _tmp29_);
					_tmp31_ = _tmp30_;
					_g_object_unref0 (_tmp29_);
					_val_it = _tmp31_;
					while (TRUE) {
						GeeIterator* _tmp32_;
						gchar* val = NULL;
						GeeIterator* _tmp33_;
						gpointer _tmp34_;
						GeeHashMultiMap* _tmp35_;
						const gchar* _tmp36_;
						const gchar* _tmp37_;
						_tmp32_ = _val_it;
						if (!gee_iterator_next (_tmp32_)) {
							break;
						}
						_tmp33_ = _val_it;
						_tmp34_ = gee_iterator_get (_tmp33_);
						val = (gchar*) _tmp34_;
						_tmp35_ = new_parameters;
						_tmp36_ = param;
						_tmp37_ = val;
						gee_multi_map_set ((GeeMultiMap*) _tmp35_, _tmp36_, _tmp37_);
						_g_free0 (val);
					}
					_g_object_unref0 (_val_it);
				}
			}
			_g_free0 (param);
		}
		_g_object_unref0 (_param_it);
	}
	switch (self->priv->source) {
		case CONTACTS_TYPEDESCRIPTOR_SOURCE_VCARD:
		{
			gchar** _tmp38_;
			gint _tmp38__length1;
			_tmp38_ = self->vcard_types;
			_tmp38__length1 = self->vcard_types_length1;
			{
				gchar** type_collection = NULL;
				gint type_collection_length1 = 0;
				gint _type_collection_size_ = 0;
				gint type_it = 0;
				type_collection = _tmp38_;
				type_collection_length1 = _tmp38__length1;
				for (type_it = 0; type_it < type_collection_length1; type_it = type_it + 1) {
					gchar* _tmp39_;
					gchar* type = NULL;
					_tmp39_ = g_strdup (type_collection[type_it]);
					type = _tmp39_;
					{
						const gchar* _tmp40_;
						_tmp40_ = type;
						if (_tmp40_ != NULL) {
							GeeHashMultiMap* _tmp41_;
							const gchar* _tmp42_;
							_tmp41_ = new_parameters;
							_tmp42_ = type;
							gee_multi_map_set ((GeeMultiMap*) _tmp41_, "type", _tmp42_);
						}
						_g_free0 (type);
					}
				}
			}
			break;
		}
		case CONTACTS_TYPEDESCRIPTOR_SOURCE_OTHER:
		{
			GeeHashMultiMap* _tmp43_;
			_tmp43_ = new_parameters;
			gee_multi_map_set ((GeeMultiMap*) _tmp43_, "type", "OTHER");
			break;
		}
		case CONTACTS_TYPEDESCRIPTOR_SOURCE_CUSTOM:
		{
			GeeHashMultiMap* _tmp44_;
			GeeHashMultiMap* _tmp45_;
			const gchar* _tmp46_;
			_tmp44_ = new_parameters;
			gee_multi_map_set ((GeeMultiMap*) _tmp44_, "type", "OTHER");
			_tmp45_ = new_parameters;
			_tmp46_ = self->name;
			gee_multi_map_set ((GeeMultiMap*) _tmp45_, CONTACTS_TYPEDESCRIPTOR_X_GOOGLE_LABEL, _tmp46_);
			break;
		}
		default:
		break;
	}
	if (has_pref) {
		GeeHashMultiMap* _tmp47_;
		_tmp47_ = new_parameters;
		gee_multi_map_set ((GeeMultiMap*) _tmp47_, "type", "PREF");
	}
	_tmp48_ = new_parameters;
	folks_abstract_field_details_set_parameters (details, (GeeMultiMap*) _tmp48_);
	_g_object_unref0 (new_parameters);
	_g_object_unref0 (old_parameters);
}

/**
   * Converts the TypeDescriptor to a string. Should only be used for debugging.
   */
static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

gchar*
contacts_typedescriptor_to_string (ContactsTypeDescriptor* self)
{
	GString* str = NULL;
	GString* _tmp0_;
	GString* _tmp1_;
	const gchar* _tmp2_;
	GString* _tmp3_;
	const gchar* _tmp4_;
	GString* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	GString* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_string_new ("{ ");
	str = _tmp0_;
	_tmp1_ = str;
	_tmp2_ = contacts_typedescriptor_source_to_string (self->priv->source);
	g_string_append_printf (_tmp1_, ".source = %s, ", _tmp2_);
	_tmp3_ = str;
	_tmp4_ = self->name;
	g_string_append_printf (_tmp3_, ".name = \"%s\", ", _tmp4_);
	_tmp5_ = str;
	_tmp6_ = contacts_typedescriptor_get_display_name (self);
	_tmp7_ = _tmp6_;
	g_string_append_printf (_tmp5_, ".display_name = \"%s\", ", _tmp7_);
	_tmp8_ = self->vcard_types;
	_tmp8__length1 = self->vcard_types_length1;
	if (_tmp8_ == NULL) {
		GString* _tmp9_;
		_tmp9_ = str;
		g_string_append_printf (_tmp9_, ".vcard_types = NULL }");
	} else {
		GString* _tmp10_;
		gchar** _tmp11_;
		gint _tmp11__length1;
		gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp10_ = str;
		_tmp11_ = self->vcard_types;
		_tmp11__length1 = self->vcard_types_length1;
		_tmp12_ = _vala_g_strjoinv (", ", _tmp11_, (gint) _tmp11__length1);
		_tmp13_ = _tmp12_;
		g_string_append_printf (_tmp10_, ".vcard_types = [ %s }", _tmp13_);
		_g_free0 (_tmp13_);
	}
	_tmp14_ = str;
	_tmp15_ = _tmp14_->str;
	_tmp16_ = g_strdup (_tmp15_);
	result = _tmp16_;
	_g_string_free0 (str);
	return result;
}

ContactsTypeDescriptor*
contacts_typedescriptor_construct (GType object_type)
{
	ContactsTypeDescriptor * self = NULL;
	self = (ContactsTypeDescriptor*) g_object_new (object_type, NULL);
	return self;
}

ContactsTypeDescriptor*
contacts_typedescriptor_new (void)
{
	return contacts_typedescriptor_construct (CONTACTS_TYPE_TYPEDESCRIPTOR);
}

const gchar*
contacts_typedescriptor_get_display_name (ContactsTypeDescriptor* self)
{
	const gchar* result;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	if (contacts_typedescriptor_is_custom (self)) {
		const gchar* _tmp0_;
		_tmp0_ = self->name;
		result = _tmp0_;
		return result;
	}
	_tmp1_ = self->name;
	result = g_dgettext (GETTEXT_PACKAGE, _tmp1_);
	return result;
}

static void
contacts_typedescriptor_class_init (ContactsTypeDescriptorClass * klass,
                                    gpointer klass_data)
{
	contacts_typedescriptor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ContactsTypeDescriptor_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_contacts_typedescriptor_get_property;
	G_OBJECT_CLASS (klass)->finalize = contacts_typedescriptor_finalize;
	/**
	   * Returns the translated name for this property.
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_TYPEDESCRIPTOR_DISPLAY_NAME_PROPERTY, contacts_typedescriptor_properties[CONTACTS_TYPEDESCRIPTOR_DISPLAY_NAME_PROPERTY] = g_param_spec_string ("display-name", "display-name", "display-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
contacts_typedescriptor_instance_init (ContactsTypeDescriptor * self,
                                       gpointer klass)
{
	self->priv = contacts_typedescriptor_get_instance_private (self);
	self->name = NULL;
	self->vcard_types = NULL;
	self->vcard_types_length1 = 0;
}

static void
contacts_typedescriptor_finalize (GObject * obj)
{
	ContactsTypeDescriptor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_TYPEDESCRIPTOR, ContactsTypeDescriptor);
	_g_free0 (self->name);
	self->vcard_types = (_vala_array_free (self->vcard_types, self->vcard_types_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (contacts_typedescriptor_parent_class)->finalize (obj);
}

/**
 * The TypeDescriptor is the internal representation of a property's type.
 */
 G_GNUC_NO_INLINE static GType
contacts_typedescriptor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsTypeDescriptorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_typedescriptor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsTypeDescriptor), 0, (GInstanceInitFunc) contacts_typedescriptor_instance_init, NULL };
	GType contacts_typedescriptor_type_id;
	contacts_typedescriptor_type_id = g_type_register_static (G_TYPE_OBJECT, "ContactsTypeDescriptor", &g_define_type_info, 0);
	ContactsTypeDescriptor_private_offset = g_type_add_instance_private (contacts_typedescriptor_type_id, sizeof (ContactsTypeDescriptorPrivate));
	return contacts_typedescriptor_type_id;
}

GType
contacts_typedescriptor_get_type (void)
{
	static volatile gsize contacts_typedescriptor_type_id__once = 0;
	if (g_once_init_enter (&contacts_typedescriptor_type_id__once)) {
		GType contacts_typedescriptor_type_id;
		contacts_typedescriptor_type_id = contacts_typedescriptor_get_type_once ();
		g_once_init_leave (&contacts_typedescriptor_type_id__once, contacts_typedescriptor_type_id);
	}
	return contacts_typedescriptor_type_id__once;
}

static void
_vala_contacts_typedescriptor_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	ContactsTypeDescriptor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_TYPEDESCRIPTOR, ContactsTypeDescriptor);
	switch (property_id) {
		case CONTACTS_TYPEDESCRIPTOR_DISPLAY_NAME_PROPERTY:
		g_value_set_string (value, contacts_typedescriptor_get_display_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

