/* RecursiveDelete.c generated by valac 0.30.2, the Vala compiler
 * generated from RecursiveDelete.vala, do not modify */

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
    This file is part of Déjà Dup.
    For copyright information, see AUTHORS.

    Déjà Dup 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 3 of the License, or
    (at your option) any later version.

    Déjà Dup 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 Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.
*/

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


#define DEJA_DUP_TYPE_RECURSIVE_OP (deja_dup_recursive_op_get_type ())
#define DEJA_DUP_RECURSIVE_OP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_RECURSIVE_OP, DejaDupRecursiveOp))
#define DEJA_DUP_RECURSIVE_OP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_RECURSIVE_OP, DejaDupRecursiveOpClass))
#define DEJA_DUP_IS_RECURSIVE_OP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_RECURSIVE_OP))
#define DEJA_DUP_IS_RECURSIVE_OP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_RECURSIVE_OP))
#define DEJA_DUP_RECURSIVE_OP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_RECURSIVE_OP, DejaDupRecursiveOpClass))

typedef struct _DejaDupRecursiveOp DejaDupRecursiveOp;
typedef struct _DejaDupRecursiveOpClass DejaDupRecursiveOpClass;
typedef struct _DejaDupRecursiveOpPrivate DejaDupRecursiveOpPrivate;

#define DEJA_DUP_TYPE_RECURSIVE_DELETE (deja_dup_recursive_delete_get_type ())
#define DEJA_DUP_RECURSIVE_DELETE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_RECURSIVE_DELETE, DejaDupRecursiveDelete))
#define DEJA_DUP_RECURSIVE_DELETE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_RECURSIVE_DELETE, DejaDupRecursiveDeleteClass))
#define DEJA_DUP_IS_RECURSIVE_DELETE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_RECURSIVE_DELETE))
#define DEJA_DUP_IS_RECURSIVE_DELETE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_RECURSIVE_DELETE))
#define DEJA_DUP_RECURSIVE_DELETE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_RECURSIVE_DELETE, DejaDupRecursiveDeleteClass))

typedef struct _DejaDupRecursiveDelete DejaDupRecursiveDelete;
typedef struct _DejaDupRecursiveDeleteClass DejaDupRecursiveDeleteClass;
typedef struct _DejaDupRecursiveDeletePrivate DejaDupRecursiveDeletePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _DejaDupRecursiveOp {
	GObject parent_instance;
	DejaDupRecursiveOpPrivate * priv;
	GFileType src_type;
	GFileType dst_type;
};

struct _DejaDupRecursiveOpClass {
	GObjectClass parent_class;
	void (*handle_file) (DejaDupRecursiveOp* self);
	void (*handle_dir) (DejaDupRecursiveOp* self);
	void (*finish_dir) (DejaDupRecursiveOp* self);
	DejaDupRecursiveOp* (*clone_for_info) (DejaDupRecursiveOp* self, GFileInfo* info);
};

struct _DejaDupRecursiveDelete {
	DejaDupRecursiveOp parent_instance;
	DejaDupRecursiveDeletePrivate * priv;
};

struct _DejaDupRecursiveDeleteClass {
	DejaDupRecursiveOpClass parent_class;
};

struct _DejaDupRecursiveDeletePrivate {
	gchar* _skip;
};


static gpointer deja_dup_recursive_delete_parent_class = NULL;

GType deja_dup_recursive_op_get_type (void) G_GNUC_CONST;
GType deja_dup_recursive_delete_get_type (void) G_GNUC_CONST;
#define DEJA_DUP_RECURSIVE_DELETE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEJA_DUP_TYPE_RECURSIVE_DELETE, DejaDupRecursiveDeletePrivate))
enum  {
	DEJA_DUP_RECURSIVE_DELETE_DUMMY_PROPERTY,
	DEJA_DUP_RECURSIVE_DELETE_SKIP
};
DejaDupRecursiveDelete* deja_dup_recursive_delete_new (GFile* source, const gchar* skip);
DejaDupRecursiveDelete* deja_dup_recursive_delete_construct (GType object_type, GFile* source, const gchar* skip);
static void deja_dup_recursive_delete_real_handle_file (DejaDupRecursiveOp* base);
GFile* deja_dup_recursive_op_get_src (DejaDupRecursiveOp* self);
GFile* deja_dup_recursive_op_get_dst (DejaDupRecursiveOp* self);
static void deja_dup_recursive_delete_real_finish_dir (DejaDupRecursiveOp* base);
static DejaDupRecursiveOp* deja_dup_recursive_delete_real_clone_for_info (DejaDupRecursiveOp* base, GFileInfo* info);
const gchar* deja_dup_recursive_delete_get_skip (DejaDupRecursiveDelete* self);
static void deja_dup_recursive_delete_set_skip (DejaDupRecursiveDelete* self, const gchar* value);
static void deja_dup_recursive_delete_finalize (GObject* obj);
static void _vala_deja_dup_recursive_delete_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_deja_dup_recursive_delete_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


DejaDupRecursiveDelete* deja_dup_recursive_delete_construct (GType object_type, GFile* source, const gchar* skip) {
	DejaDupRecursiveDelete * self = NULL;
	GFile* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_val_if_fail (source != NULL, NULL);
	_tmp0_ = source;
	_tmp1_ = skip;
	self = (DejaDupRecursiveDelete*) g_object_new (object_type, "src", _tmp0_, "skip", _tmp1_, NULL);
	return self;
}


DejaDupRecursiveDelete* deja_dup_recursive_delete_new (GFile* source, const gchar* skip) {
	return deja_dup_recursive_delete_construct (DEJA_DUP_TYPE_RECURSIVE_DELETE, source, skip);
}


static void deja_dup_recursive_delete_real_handle_file (DejaDupRecursiveOp* base) {
	DejaDupRecursiveDelete * self;
	GError * _inner_error_ = NULL;
	self = (DejaDupRecursiveDelete*) base;
	{
		GFile* _tmp0_ = NULL;
		GFile* _tmp1_ = NULL;
		_tmp0_ = deja_dup_recursive_op_get_src ((DejaDupRecursiveOp*) self);
		_tmp1_ = _tmp0_;
		g_file_delete (_tmp1_, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch39_g_error;
		}
	}
	goto __finally39;
	__catch39_g_error:
	{
		GError* e = NULL;
		GFile* _tmp2_ = NULL;
		GFile* _tmp3_ = NULL;
		GFile* _tmp4_ = NULL;
		GFile* _tmp5_ = NULL;
		GError* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp2_ = deja_dup_recursive_op_get_src ((DejaDupRecursiveOp*) self);
		_tmp3_ = _tmp2_;
		_tmp4_ = deja_dup_recursive_op_get_dst ((DejaDupRecursiveOp*) self);
		_tmp5_ = _tmp4_;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_signal_emit_by_name ((DejaDupRecursiveOp*) self, "raise-error", _tmp3_, _tmp5_, _tmp7_);
		_g_error_free0 (e);
	}
	__finally39:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		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;
	}
}


static void deja_dup_recursive_delete_real_finish_dir (DejaDupRecursiveOp* base) {
	DejaDupRecursiveDelete * self;
	GError * _inner_error_ = NULL;
	self = (DejaDupRecursiveDelete*) base;
	{
		GFile* _tmp0_ = NULL;
		GFile* _tmp1_ = NULL;
		_tmp0_ = deja_dup_recursive_op_get_src ((DejaDupRecursiveOp*) self);
		_tmp1_ = _tmp0_;
		g_file_delete (_tmp1_, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch40_g_error;
		}
	}
	goto __finally40;
	__catch40_g_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_g_error_free0 (e);
	}
	__finally40:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		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;
	}
}


static DejaDupRecursiveOp* deja_dup_recursive_delete_real_clone_for_info (DejaDupRecursiveOp* base, GFileInfo* info) {
	DejaDupRecursiveDelete * self;
	DejaDupRecursiveOp* result = NULL;
	gchar* child_name = NULL;
	GFileInfo* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	GFile* src_child = NULL;
	GFile* _tmp5_ = NULL;
	GFile* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	GFile* _tmp8_ = NULL;
	GFile* _tmp9_ = NULL;
	DejaDupRecursiveDelete* _tmp10_ = NULL;
	self = (DejaDupRecursiveDelete*) base;
	g_return_val_if_fail (info != NULL, NULL);
	_tmp0_ = info;
	_tmp1_ = g_file_info_get_name (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	child_name = _tmp2_;
	_tmp3_ = child_name;
	_tmp4_ = self->priv->_skip;
	if (g_strcmp0 (_tmp3_, _tmp4_) == 0) {
		result = NULL;
		_g_free0 (child_name);
		return result;
	}
	_tmp5_ = deja_dup_recursive_op_get_src ((DejaDupRecursiveOp*) self);
	_tmp6_ = _tmp5_;
	_tmp7_ = child_name;
	_tmp8_ = g_file_get_child (_tmp6_, _tmp7_);
	src_child = _tmp8_;
	_tmp9_ = src_child;
	_tmp10_ = deja_dup_recursive_delete_new (_tmp9_, NULL);
	result = (DejaDupRecursiveOp*) _tmp10_;
	_g_object_unref0 (src_child);
	_g_free0 (child_name);
	return result;
}


const gchar* deja_dup_recursive_delete_get_skip (DejaDupRecursiveDelete* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_skip;
	result = _tmp0_;
	return result;
}


static void deja_dup_recursive_delete_set_skip (DejaDupRecursiveDelete* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_skip);
	self->priv->_skip = _tmp1_;
	g_object_notify ((GObject *) self, "skip");
}


static void deja_dup_recursive_delete_class_init (DejaDupRecursiveDeleteClass * klass) {
	deja_dup_recursive_delete_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DejaDupRecursiveDeletePrivate));
	((DejaDupRecursiveOpClass *) klass)->handle_file = deja_dup_recursive_delete_real_handle_file;
	((DejaDupRecursiveOpClass *) klass)->finish_dir = deja_dup_recursive_delete_real_finish_dir;
	((DejaDupRecursiveOpClass *) klass)->clone_for_info = deja_dup_recursive_delete_real_clone_for_info;
	G_OBJECT_CLASS (klass)->get_property = _vala_deja_dup_recursive_delete_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_deja_dup_recursive_delete_set_property;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_recursive_delete_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_RECURSIVE_DELETE_SKIP, g_param_spec_string ("skip", "skip", "skip", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void deja_dup_recursive_delete_instance_init (DejaDupRecursiveDelete * self) {
	self->priv = DEJA_DUP_RECURSIVE_DELETE_GET_PRIVATE (self);
}


static void deja_dup_recursive_delete_finalize (GObject* obj) {
	DejaDupRecursiveDelete * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_RECURSIVE_DELETE, DejaDupRecursiveDelete);
	_g_free0 (self->priv->_skip);
	G_OBJECT_CLASS (deja_dup_recursive_delete_parent_class)->finalize (obj);
}


GType deja_dup_recursive_delete_get_type (void) {
	static volatile gsize deja_dup_recursive_delete_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_recursive_delete_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupRecursiveDeleteClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_recursive_delete_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupRecursiveDelete), 0, (GInstanceInitFunc) deja_dup_recursive_delete_instance_init, NULL };
		GType deja_dup_recursive_delete_type_id;
		deja_dup_recursive_delete_type_id = g_type_register_static (DEJA_DUP_TYPE_RECURSIVE_OP, "DejaDupRecursiveDelete", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_recursive_delete_type_id__volatile, deja_dup_recursive_delete_type_id);
	}
	return deja_dup_recursive_delete_type_id__volatile;
}


static void _vala_deja_dup_recursive_delete_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	DejaDupRecursiveDelete * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_RECURSIVE_DELETE, DejaDupRecursiveDelete);
	switch (property_id) {
		case DEJA_DUP_RECURSIVE_DELETE_SKIP:
		g_value_set_string (value, deja_dup_recursive_delete_get_skip (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_deja_dup_recursive_delete_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DejaDupRecursiveDelete * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_RECURSIVE_DELETE, DejaDupRecursiveDelete);
	switch (property_id) {
		case DEJA_DUP_RECURSIVE_DELETE_SKIP:
		deja_dup_recursive_delete_set_skip (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



