/* collection-source.c generated by valac 0.17.7, the Vala compiler
 * generated from collection-source.vala, do not modify */

/* This file is part of GNOME Boxes. License: LGPLv2+*/

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>


#define BOXES_TYPE_ICONFIG (boxes_iconfig_get_type ())
#define BOXES_ICONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_ICONFIG, BoxesIConfig))
#define BOXES_IS_ICONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_ICONFIG))
#define BOXES_ICONFIG_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), BOXES_TYPE_ICONFIG, BoxesIConfigIface))

typedef struct _BoxesIConfig BoxesIConfig;
typedef struct _BoxesIConfigIface BoxesIConfigIface;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define BOXES_TYPE_COLLECTION_SOURCE (boxes_collection_source_get_type ())
#define BOXES_COLLECTION_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_COLLECTION_SOURCE, BoxesCollectionSource))
#define BOXES_COLLECTION_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_COLLECTION_SOURCE, BoxesCollectionSourceClass))
#define BOXES_IS_COLLECTION_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_COLLECTION_SOURCE))
#define BOXES_IS_COLLECTION_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_COLLECTION_SOURCE))
#define BOXES_COLLECTION_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_COLLECTION_SOURCE, BoxesCollectionSourceClass))

typedef struct _BoxesCollectionSource BoxesCollectionSource;
typedef struct _BoxesCollectionSourceClass BoxesCollectionSourceClass;
typedef struct _BoxesCollectionSourcePrivate BoxesCollectionSourcePrivate;
#define _g_key_file_free0(var) ((var == NULL) ? NULL : (var = (g_key_file_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _BoxesIConfigIface {
	GTypeInterface parent_iface;
	GKeyFile* (*get_keyfile) (BoxesIConfig* self);
	const gchar* (*get_filename) (BoxesIConfig* self);
	void (*set_filename) (BoxesIConfig* self, const gchar* value);
	gboolean (*get_has_file) (BoxesIConfig* self);
	void (*set_has_file) (BoxesIConfig* self, gboolean value);
};

typedef enum  {
	BOXES_ERROR_INVALID,
	BOXES_ERROR_COMMAND_FAILED
} BoxesError;
#define BOXES_ERROR boxes_error_quark ()
struct _BoxesCollectionSource {
	GObject parent_instance;
	BoxesCollectionSourcePrivate * priv;
};

struct _BoxesCollectionSourceClass {
	GObjectClass parent_class;
};

struct _BoxesCollectionSourcePrivate {
	GKeyFile* _keyfile;
	gboolean _has_file;
	gchar* _filename;
};


static gpointer boxes_collection_source_parent_class = NULL;
static BoxesIConfigIface* boxes_collection_source_boxes_iconfig_parent_iface = NULL;

GType boxes_iconfig_get_type (void) G_GNUC_CONST;
void boxes_iconfig_save (BoxesIConfig* self);
gboolean boxes_keyfile_save (GKeyFile* key_file, const gchar* file_name, gboolean overwrite);
GKeyFile* boxes_iconfig_get_keyfile (BoxesIConfig* self);
gchar* boxes_get_user_pkgconfig_source (const gchar* file_name);
const gchar* boxes_iconfig_get_filename (BoxesIConfig* self);
gboolean boxes_iconfig_get_has_file (BoxesIConfig* self);
void boxes_iconfig_set_has_file (BoxesIConfig* self, gboolean value);
gboolean boxes_iconfig_get_boolean (BoxesIConfig* self, const gchar* group, const gchar* key, gboolean default_value);
void boxes_iconfig_set_boolean (BoxesIConfig* self, const gchar* group, const gchar* key, gboolean value);
void boxes_iconfig_load (BoxesIConfig* self, GError** error);
GQuark boxes_error_quark (void);
gchar* boxes_iconfig_get_string (BoxesIConfig* self, const gchar* group, const gchar* key);
gchar** boxes_iconfig_get_string_list (BoxesIConfig* self, const gchar* group, const gchar* key, int* result_length1);
gchar** boxes_iconfig_get_groups (BoxesIConfig* self, const gchar* with_prefix, int* result_length1);
static void _vala_array_add1 (gchar*** array, int* length, int* size, gchar* value);
void boxes_iconfig_set_filename (BoxesIConfig* self, const gchar* value);
GType boxes_collection_source_get_type (void) G_GNUC_CONST;
#define BOXES_COLLECTION_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BOXES_TYPE_COLLECTION_SOURCE, BoxesCollectionSourcePrivate))
enum  {
	BOXES_COLLECTION_SOURCE_DUMMY_PROPERTY,
	BOXES_COLLECTION_SOURCE_NAME,
	BOXES_COLLECTION_SOURCE_SOURCE_TYPE,
	BOXES_COLLECTION_SOURCE_URI,
	BOXES_COLLECTION_SOURCE_ENABLED
};
BoxesCollectionSource* boxes_collection_source_new (const gchar* name, const gchar* source_type, const gchar* uri);
BoxesCollectionSource* boxes_collection_source_construct (GType object_type, const gchar* name, const gchar* source_type, const gchar* uri);
void boxes_collection_source_set_name (BoxesCollectionSource* self, const gchar* value);
void boxes_collection_source_set_source_type (BoxesCollectionSource* self, const gchar* value);
void boxes_collection_source_set_uri (BoxesCollectionSource* self, const gchar* value);
BoxesCollectionSource* boxes_collection_source_new_with_file (const gchar* filename, GError** error);
BoxesCollectionSource* boxes_collection_source_construct_with_file (GType object_type, const gchar* filename, GError** error);
void boxes_collection_source_delete (BoxesCollectionSource* self);
gchar* boxes_make_filename (const gchar* name);
gchar* boxes_collection_source_get_name (BoxesCollectionSource* self);
gchar* boxes_collection_source_get_source_type (BoxesCollectionSource* self);
gchar* boxes_collection_source_get_uri (BoxesCollectionSource* self);
gboolean boxes_collection_source_get_enabled (BoxesCollectionSource* self);
void boxes_collection_source_set_enabled (BoxesCollectionSource* self, gboolean value);
static GObject * boxes_collection_source_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void boxes_collection_source_finalize (GObject* obj);
static void _vala_boxes_collection_source_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_boxes_collection_source_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
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);


void boxes_iconfig_save (BoxesIConfig* self) {
	GKeyFile* _tmp0_;
	GKeyFile* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	_tmp0_ = boxes_iconfig_get_keyfile (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = boxes_iconfig_get_filename (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = boxes_get_user_pkgconfig_source (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = boxes_iconfig_get_has_file (self);
	_tmp7_ = _tmp6_;
	boxes_keyfile_save (_tmp1_, _tmp5_, _tmp7_);
	_g_free0 (_tmp5_);
	boxes_iconfig_set_has_file (self, TRUE);
}


gboolean boxes_iconfig_get_boolean (BoxesIConfig* self, const gchar* group, const gchar* key, gboolean default_value) {
	gboolean result = FALSE;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (group != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	{
		GKeyFile* _tmp0_;
		GKeyFile* _tmp1_;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		gboolean _tmp4_ = FALSE;
		gboolean _tmp5_;
		_tmp0_ = boxes_iconfig_get_keyfile (self);
		_tmp1_ = _tmp0_;
		_tmp2_ = group;
		_tmp3_ = key;
		_tmp4_ = g_key_file_get_boolean (_tmp1_, _tmp2_, _tmp3_, &_inner_error_);
		_tmp5_ = _tmp4_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_KEY_FILE_ERROR) {
				goto __catch0_g_key_file_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
		result = _tmp5_;
		return result;
	}
	goto __finally0;
	__catch0_g_key_file_error:
	{
		GError* _error_ = NULL;
		gboolean _tmp6_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = default_value;
		result = _tmp6_;
		_g_error_free0 (_error_);
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
	g_clear_error (&_inner_error_);
	return FALSE;
}


void boxes_iconfig_set_boolean (BoxesIConfig* self, const gchar* group, const gchar* key, gboolean value) {
	GKeyFile* _tmp0_;
	GKeyFile* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gboolean _tmp4_;
	g_return_if_fail (group != NULL);
	g_return_if_fail (key != NULL);
	_tmp0_ = boxes_iconfig_get_keyfile (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = group;
	_tmp3_ = key;
	_tmp4_ = value;
	g_key_file_set_boolean (_tmp1_, _tmp2_, _tmp3_, _tmp4_);
}


void boxes_iconfig_load (BoxesIConfig* self, GError** error) {
	gboolean _tmp0_;
	gboolean _tmp1_;
	GKeyFile* _tmp3_;
	GKeyFile* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_;
	GError * _inner_error_ = NULL;
	_tmp0_ = boxes_iconfig_get_has_file (self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		GError* _tmp2_;
		_tmp2_ = g_error_new_literal (BOXES_ERROR, BOXES_ERROR_INVALID, "has_file is false");
		_inner_error_ = _tmp2_;
		g_propagate_error (error, _inner_error_);
		return;
	}
	_tmp3_ = boxes_iconfig_get_keyfile (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = boxes_iconfig_get_filename (self);
	_tmp6_ = _tmp5_;
	_tmp7_ = boxes_get_user_pkgconfig_source (_tmp6_);
	_tmp8_ = _tmp7_;
	g_key_file_load_from_file (_tmp4_, _tmp8_, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &_inner_error_);
	_g_free0 (_tmp8_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return;
	}
}


gchar* boxes_iconfig_get_string (BoxesIConfig* self, const gchar* group, const gchar* key) {
	gchar* result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (group != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	{
		GKeyFile* _tmp0_;
		GKeyFile* _tmp1_;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_ = NULL;
		gchar* _tmp5_;
		_tmp0_ = boxes_iconfig_get_keyfile (self);
		_tmp1_ = _tmp0_;
		_tmp2_ = group;
		_tmp3_ = key;
		_tmp4_ = g_key_file_get_string (_tmp1_, _tmp2_, _tmp3_, &_inner_error_);
		_tmp5_ = _tmp4_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_KEY_FILE_ERROR) {
				goto __catch1_g_key_file_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		result = _tmp5_;
		return result;
	}
	goto __finally1;
	__catch1_g_key_file_error:
	{
		GError* _error_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		result = NULL;
		_g_error_free0 (_error_);
		return result;
	}
	__finally1:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
	g_clear_error (&_inner_error_);
	return NULL;
}


gchar** boxes_iconfig_get_string_list (BoxesIConfig* self, const gchar* group, const gchar* key, int* result_length1) {
	gchar** result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (group != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	{
		GKeyFile* _tmp0_;
		GKeyFile* _tmp1_;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		gsize _tmp4_;
		gchar** _tmp5_ = NULL;
		gchar** _tmp6_;
		gint _tmp6__length1;
		gint __tmp6__size_;
		gchar** _tmp7_;
		gint _tmp7__length1;
		_tmp0_ = boxes_iconfig_get_keyfile (self);
		_tmp1_ = _tmp0_;
		_tmp2_ = group;
		_tmp3_ = key;
		_tmp5_ = g_key_file_get_string_list (_tmp1_, _tmp2_, _tmp3_, &_tmp4_, &_inner_error_);
		_tmp6_ = _tmp5_;
		_tmp6__length1 = _tmp4_;
		__tmp6__size_ = _tmp6__length1;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_KEY_FILE_ERROR) {
				goto __catch2_g_key_file_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp7_ = _tmp6_;
		_tmp7__length1 = _tmp6__length1;
		if (result_length1) {
			*result_length1 = _tmp7__length1;
		}
		result = _tmp7_;
		return result;
	}
	goto __finally2;
	__catch2_g_key_file_error:
	{
		GError* _error_ = NULL;
		gchar** _tmp8_;
		gint _tmp8__length1;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp8_ = NULL;
		_tmp8__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp8__length1;
		}
		result = _tmp8_;
		_g_error_free0 (_error_);
		return result;
	}
	__finally2:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
	g_clear_error (&_inner_error_);
	return NULL;
}


static void _vala_array_add1 (gchar*** array, int* length, int* size, gchar* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


gchar** boxes_iconfig_get_groups (BoxesIConfig* self, const gchar* with_prefix, int* result_length1) {
	gchar** result = NULL;
	gchar** _tmp0_ = NULL;
	gchar** groups;
	gint groups_length1;
	gint _groups_size_;
	GKeyFile* _tmp1_;
	GKeyFile* _tmp2_;
	gsize _tmp3_;
	gchar** _tmp4_ = NULL;
	gchar** _tmp12_;
	gint _tmp12__length1;
	g_return_val_if_fail (with_prefix != NULL, NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	groups = _tmp0_;
	groups_length1 = 0;
	_groups_size_ = groups_length1;
	_tmp1_ = boxes_iconfig_get_keyfile (self);
	_tmp2_ = _tmp1_;
	_tmp4_ = g_key_file_get_groups (_tmp2_, &_tmp3_);
	{
		gchar** group_collection = NULL;
		gint group_collection_length1 = 0;
		gint _group_collection_size_ = 0;
		gint group_it = 0;
		group_collection = _tmp4_;
		group_collection_length1 = _tmp3_;
		for (group_it = 0; group_it < _tmp3_; group_it = group_it + 1) {
			gchar* _tmp5_;
			gchar* group = NULL;
			_tmp5_ = g_strdup (group_collection[group_it]);
			group = _tmp5_;
			{
				const gchar* _tmp6_;
				const gchar* _tmp7_;
				gboolean _tmp8_ = FALSE;
				gchar** _tmp9_;
				gint _tmp9__length1;
				const gchar* _tmp10_;
				gchar* _tmp11_;
				_tmp6_ = group;
				_tmp7_ = with_prefix;
				_tmp8_ = g_str_has_prefix (_tmp6_, _tmp7_);
				if (!_tmp8_) {
					_g_free0 (group);
					continue;
				}
				_tmp9_ = groups;
				_tmp9__length1 = groups_length1;
				_tmp10_ = group;
				_tmp11_ = g_strdup (_tmp10_);
				_vala_array_add1 (&groups, &groups_length1, &_groups_size_, _tmp11_);
				_g_free0 (group);
			}
		}
		group_collection = (_vala_array_free (group_collection, group_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp12_ = groups;
	_tmp12__length1 = groups_length1;
	if (result_length1) {
		*result_length1 = _tmp12__length1;
	}
	result = _tmp12_;
	return result;
}


GKeyFile* boxes_iconfig_get_keyfile (BoxesIConfig* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return BOXES_ICONFIG_GET_INTERFACE (self)->get_keyfile (self);
}


const gchar* boxes_iconfig_get_filename (BoxesIConfig* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return BOXES_ICONFIG_GET_INTERFACE (self)->get_filename (self);
}


void boxes_iconfig_set_filename (BoxesIConfig* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	BOXES_ICONFIG_GET_INTERFACE (self)->set_filename (self, value);
}


gboolean boxes_iconfig_get_has_file (BoxesIConfig* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return BOXES_ICONFIG_GET_INTERFACE (self)->get_has_file (self);
}


void boxes_iconfig_set_has_file (BoxesIConfig* self, gboolean value) {
	g_return_if_fail (self != NULL);
	BOXES_ICONFIG_GET_INTERFACE (self)->set_has_file (self, value);
}


static void boxes_iconfig_base_init (BoxesIConfigIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
	}
}


GType boxes_iconfig_get_type (void) {
	static volatile gsize boxes_iconfig_type_id__volatile = 0;
	if (g_once_init_enter (&boxes_iconfig_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BoxesIConfigIface), (GBaseInitFunc) boxes_iconfig_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType boxes_iconfig_type_id;
		boxes_iconfig_type_id = g_type_register_static (G_TYPE_INTERFACE, "BoxesIConfig", &g_define_type_info, 0);
		g_once_init_leave (&boxes_iconfig_type_id__volatile, boxes_iconfig_type_id);
	}
	return boxes_iconfig_type_id__volatile;
}


BoxesCollectionSource* boxes_collection_source_construct (GType object_type, const gchar* name, const gchar* source_type, const gchar* uri) {
	BoxesCollectionSource * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (source_type != NULL, NULL);
	g_return_val_if_fail (uri != NULL, NULL);
	self = (BoxesCollectionSource*) g_object_new (object_type, NULL);
	_tmp0_ = name;
	boxes_collection_source_set_name (self, _tmp0_);
	_tmp1_ = source_type;
	boxes_collection_source_set_source_type (self, _tmp1_);
	_tmp2_ = uri;
	boxes_collection_source_set_uri (self, _tmp2_);
	return self;
}


BoxesCollectionSource* boxes_collection_source_new (const gchar* name, const gchar* source_type, const gchar* uri) {
	return boxes_collection_source_construct (BOXES_TYPE_COLLECTION_SOURCE, name, source_type, uri);
}


BoxesCollectionSource* boxes_collection_source_construct_with_file (GType object_type, const gchar* filename, GError** error) {
	BoxesCollectionSource * self = NULL;
	const gchar* _tmp0_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (filename != NULL, NULL);
	self = (BoxesCollectionSource*) g_object_new (object_type, NULL);
	_tmp0_ = filename;
	boxes_iconfig_set_filename ((BoxesIConfig*) self, _tmp0_);
	boxes_iconfig_set_has_file ((BoxesIConfig*) self, TRUE);
	boxes_iconfig_load ((BoxesIConfig*) self, &_inner_error_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (self);
		return NULL;
	}
	return self;
}


BoxesCollectionSource* boxes_collection_source_new_with_file (const gchar* filename, GError** error) {
	return boxes_collection_source_construct_with_file (BOXES_TYPE_COLLECTION_SOURCE, filename, error);
}


void boxes_collection_source_delete (BoxesCollectionSource* self) {
	gboolean _tmp0_;
	gboolean _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = boxes_iconfig_get_has_file ((BoxesIConfig*) self);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		return;
	}
	_tmp2_ = boxes_iconfig_get_filename ((BoxesIConfig*) self);
	_tmp3_ = _tmp2_;
	_tmp4_ = boxes_get_user_pkgconfig_source (_tmp3_);
	_tmp5_ = _tmp4_;
	g_unlink (_tmp5_);
	_g_free0 (_tmp5_);
	boxes_iconfig_set_has_file ((BoxesIConfig*) self, FALSE);
}


static GKeyFile* boxes_collection_source_real_get_keyfile (BoxesIConfig* base) {
	GKeyFile* result;
	BoxesCollectionSource* self;
	GKeyFile* _tmp0_;
	self = (BoxesCollectionSource*) base;
	_tmp0_ = self->priv->_keyfile;
	result = _tmp0_;
	return result;
}


static gboolean boxes_collection_source_real_get_has_file (BoxesIConfig* base) {
	gboolean result;
	BoxesCollectionSource* self;
	gboolean _tmp0_;
	self = (BoxesCollectionSource*) base;
	_tmp0_ = self->priv->_has_file;
	result = _tmp0_;
	return result;
}


static void boxes_collection_source_real_set_has_file (BoxesIConfig* base, gboolean value) {
	BoxesCollectionSource* self;
	gboolean _tmp0_;
	self = (BoxesCollectionSource*) base;
	_tmp0_ = value;
	self->priv->_has_file = _tmp0_;
}


static const gchar* boxes_collection_source_real_get_filename (BoxesIConfig* base) {
	const gchar* result;
	BoxesCollectionSource* self;
	const gchar* _tmp0_;
	const gchar* _tmp5_;
	self = (BoxesCollectionSource*) base;
	_tmp0_ = self->priv->_filename;
	if (_tmp0_ == NULL) {
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_ = NULL;
		_tmp1_ = boxes_collection_source_get_name (self);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = boxes_make_filename (_tmp3_);
		_g_free0 (self->priv->_filename);
		self->priv->_filename = _tmp4_;
		_g_free0 (_tmp3_);
	}
	_tmp5_ = self->priv->_filename;
	result = _tmp5_;
	return result;
}


static void boxes_collection_source_real_set_filename (BoxesIConfig* base, const gchar* value) {
	BoxesCollectionSource* self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	self = (BoxesCollectionSource*) base;
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_filename);
	self->priv->_filename = _tmp1_;
}


gchar* boxes_collection_source_get_name (BoxesCollectionSource* self) {
	gchar* result;
	gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = boxes_iconfig_get_string ((BoxesIConfig*) self, "source", "name");
	result = _tmp0_;
	return result;
}


void boxes_collection_source_set_name (BoxesCollectionSource* self, const gchar* value) {
	GKeyFile* _tmp0_;
	GKeyFile* _tmp1_;
	const gchar* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	gboolean had_file;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = boxes_iconfig_get_keyfile ((BoxesIConfig*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = value;
	g_key_file_set_string (_tmp1_, "source", "name", _tmp2_);
	_tmp3_ = boxes_iconfig_get_has_file ((BoxesIConfig*) self);
	_tmp4_ = _tmp3_;
	had_file = _tmp4_;
	boxes_collection_source_delete (self);
	_g_free0 (self->priv->_filename);
	self->priv->_filename = NULL;
	_tmp5_ = had_file;
	if (_tmp5_) {
		boxes_iconfig_save ((BoxesIConfig*) self);
	}
	g_object_notify ((GObject *) self, "name");
}


gchar* boxes_collection_source_get_source_type (BoxesCollectionSource* self) {
	gchar* result;
	gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = boxes_iconfig_get_string ((BoxesIConfig*) self, "source", "type");
	result = _tmp0_;
	return result;
}


void boxes_collection_source_set_source_type (BoxesCollectionSource* self, const gchar* value) {
	GKeyFile* _tmp0_;
	GKeyFile* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = boxes_iconfig_get_keyfile ((BoxesIConfig*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = value;
	g_key_file_set_string (_tmp1_, "source", "type", _tmp2_);
	g_object_notify ((GObject *) self, "source-type");
}


gchar* boxes_collection_source_get_uri (BoxesCollectionSource* self) {
	gchar* result;
	gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = boxes_iconfig_get_string ((BoxesIConfig*) self, "source", "uri");
	result = _tmp0_;
	return result;
}


void boxes_collection_source_set_uri (BoxesCollectionSource* self, const gchar* value) {
	GKeyFile* _tmp0_;
	GKeyFile* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = boxes_iconfig_get_keyfile ((BoxesIConfig*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = value;
	g_key_file_set_string (_tmp1_, "source", "uri", _tmp2_);
	g_object_notify ((GObject *) self, "uri");
}


gboolean boxes_collection_source_get_enabled (BoxesCollectionSource* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = boxes_iconfig_get_boolean ((BoxesIConfig*) self, "source", "enabled", TRUE);
	result = _tmp0_;
	return result;
}


void boxes_collection_source_set_enabled (BoxesCollectionSource* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	boxes_iconfig_set_boolean ((BoxesIConfig*) self, "source", "enabled", _tmp0_);
	g_object_notify ((GObject *) self, "enabled");
}


static GObject * boxes_collection_source_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	BoxesCollectionSource * self;
	GKeyFile* _tmp0_;
	parent_class = G_OBJECT_CLASS (boxes_collection_source_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_COLLECTION_SOURCE, BoxesCollectionSource);
	_tmp0_ = g_key_file_new ();
	_g_key_file_free0 (self->priv->_keyfile);
	self->priv->_keyfile = _tmp0_;
	return obj;
}


static void boxes_collection_source_class_init (BoxesCollectionSourceClass * klass) {
	boxes_collection_source_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (BoxesCollectionSourcePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_collection_source_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_boxes_collection_source_set_property;
	G_OBJECT_CLASS (klass)->constructor = boxes_collection_source_constructor;
	G_OBJECT_CLASS (klass)->finalize = boxes_collection_source_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_COLLECTION_SOURCE_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_COLLECTION_SOURCE_SOURCE_TYPE, g_param_spec_string ("source-type", "source-type", "source-type", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_COLLECTION_SOURCE_URI, g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_COLLECTION_SOURCE_ENABLED, g_param_spec_boolean ("enabled", "enabled", "enabled", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void boxes_collection_source_boxes_iconfig_interface_init (BoxesIConfigIface * iface) {
	boxes_collection_source_boxes_iconfig_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_keyfile = boxes_collection_source_real_get_keyfile;
	iface->get_has_file = boxes_collection_source_real_get_has_file;
	iface->set_has_file = boxes_collection_source_real_set_has_file;
	iface->get_filename = boxes_collection_source_real_get_filename;
	iface->set_filename = boxes_collection_source_real_set_filename;
}


static void boxes_collection_source_instance_init (BoxesCollectionSource * self) {
	self->priv = BOXES_COLLECTION_SOURCE_GET_PRIVATE (self);
}


static void boxes_collection_source_finalize (GObject* obj) {
	BoxesCollectionSource * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_COLLECTION_SOURCE, BoxesCollectionSource);
	_g_key_file_free0 (self->priv->_keyfile);
	_g_free0 (self->priv->_filename);
	G_OBJECT_CLASS (boxes_collection_source_parent_class)->finalize (obj);
}


GType boxes_collection_source_get_type (void) {
	static volatile gsize boxes_collection_source_type_id__volatile = 0;
	if (g_once_init_enter (&boxes_collection_source_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BoxesCollectionSourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_collection_source_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesCollectionSource), 0, (GInstanceInitFunc) boxes_collection_source_instance_init, NULL };
		static const GInterfaceInfo boxes_iconfig_info = { (GInterfaceInitFunc) boxes_collection_source_boxes_iconfig_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType boxes_collection_source_type_id;
		boxes_collection_source_type_id = g_type_register_static (G_TYPE_OBJECT, "BoxesCollectionSource", &g_define_type_info, 0);
		g_type_add_interface_static (boxes_collection_source_type_id, BOXES_TYPE_ICONFIG, &boxes_iconfig_info);
		g_once_init_leave (&boxes_collection_source_type_id__volatile, boxes_collection_source_type_id);
	}
	return boxes_collection_source_type_id__volatile;
}


static void _vala_boxes_collection_source_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	BoxesCollectionSource * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_COLLECTION_SOURCE, BoxesCollectionSource);
	switch (property_id) {
		case BOXES_COLLECTION_SOURCE_NAME:
		g_value_take_string (value, boxes_collection_source_get_name (self));
		break;
		case BOXES_COLLECTION_SOURCE_SOURCE_TYPE:
		g_value_take_string (value, boxes_collection_source_get_source_type (self));
		break;
		case BOXES_COLLECTION_SOURCE_URI:
		g_value_take_string (value, boxes_collection_source_get_uri (self));
		break;
		case BOXES_COLLECTION_SOURCE_ENABLED:
		g_value_set_boolean (value, boxes_collection_source_get_enabled (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_boxes_collection_source_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	BoxesCollectionSource * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_COLLECTION_SOURCE, BoxesCollectionSource);
	switch (property_id) {
		case BOXES_COLLECTION_SOURCE_NAME:
		boxes_collection_source_set_name (self, g_value_get_string (value));
		break;
		case BOXES_COLLECTION_SOURCE_SOURCE_TYPE:
		boxes_collection_source_set_source_type (self, g_value_get_string (value));
		break;
		case BOXES_COLLECTION_SOURCE_URI:
		boxes_collection_source_set_uri (self, g_value_get_string (value));
		break;
		case BOXES_COLLECTION_SOURCE_ENABLED:
		boxes_collection_source_set_enabled (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


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);
}



