/* DuplicityInstance.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from DuplicityInstance.vala, do not modify */

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: Canonical Ltd
 * SPDX-FileCopyrightText: Michael Terry
 */

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "deja.h"
#include <gio/gio.h>
#include <unistd.h>
#include <glob.h>
#include <glib/gstdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define TYPE_DUPLICITY_INSTANCE (duplicity_instance_get_type ())
#define DUPLICITY_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DUPLICITY_INSTANCE, DuplicityInstance))
#define DUPLICITY_INSTANCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DUPLICITY_INSTANCE, DuplicityInstanceClass))
#define IS_DUPLICITY_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DUPLICITY_INSTANCE))
#define IS_DUPLICITY_INSTANCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DUPLICITY_INSTANCE))
#define DUPLICITY_INSTANCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DUPLICITY_INSTANCE, DuplicityInstanceClass))

typedef struct _DuplicityInstance DuplicityInstance;
typedef struct _DuplicityInstanceClass DuplicityInstanceClass;
typedef struct _DuplicityInstancePrivate DuplicityInstancePrivate;
enum  {
	DUPLICITY_INSTANCE_0_PROPERTY,
	DUPLICITY_INSTANCE_FORCED_CACHE_DIR_PROPERTY,
	DUPLICITY_INSTANCE_NUM_PROPERTIES
};
static GParamSpec* duplicity_instance_properties[DUPLICITY_INSTANCE_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_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DuplicityInstanceStartData DuplicityInstanceStartData;
typedef struct _DuplicityInstanceStartInternalData DuplicityInstanceStartInternalData;
typedef struct _DuplicityInstanceReadLogData DuplicityInstanceReadLogData;
enum  {
	DUPLICITY_INSTANCE_DONE_SIGNAL,
	DUPLICITY_INSTANCE_EXITED_SIGNAL,
	DUPLICITY_INSTANCE_MESSAGE_SIGNAL,
	DUPLICITY_INSTANCE_NUM_SIGNALS
};
static guint duplicity_instance_signals[DUPLICITY_INSTANCE_NUM_SIGNALS] = {0};

struct _DuplicityInstance {
	GObject parent_instance;
	DuplicityInstancePrivate * priv;
};

struct _DuplicityInstanceClass {
	GObjectClass parent_class;
};

struct _DuplicityInstancePrivate {
	gchar* _forced_cache_dir;
	guint watch_id;
	GPid child_pid;
	gint* pipes;
	gint pipes_length1;
	gint _pipes_size_;
	DejaDupDuplicityLogger* logger;
	gboolean reading_done;
	gboolean process_done;
	gint status;
};

struct _DuplicityInstanceStartData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DuplicityInstance* self;
	GList* argv_in;
	GList* envp_in;
	GList* argv;
	GList* arg_collection;
	GList* arg_it;
	gchar* _tmp0_;
	gchar* arg;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	GList* envp;
	GList* env_collection;
	GList* env_it;
	gchar* _tmp3_;
	gchar* env;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gboolean _tmp6_;
	GList* _tmp7_;
	GList* _tmp8_;
	GError* e;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar** _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	GError* _tmp13_;
	const gchar* _tmp14_;
	GError* _inner_error0_;
};

struct _DuplicityInstanceStartInternalData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DuplicityInstance* self;
	GList* argv_in;
	GList* envp_in;
	gboolean result;
	gchar** real_envp;
	gint _tmp0_;
	gchar** _tmp1_;
	gint real_envp_length1;
	gint _real_envp_size_;
	GList* argv;
	GList* arg_collection;
	GList* arg_it;
	gchar* _tmp2_;
	gchar* arg;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* cache_dir;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gboolean _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* tempdir;
	gchar* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* fast_fail_str;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gboolean _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* user_cmd;
	GList* _tmp28_;
	GList* a_collection;
	GList* a_it;
	gchar* _tmp29_;
	gchar* a;
	const gchar* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gint* _tmp39_;
	gint _tmp39__length1;
	gint* _tmp40_;
	gint _tmp40__length1;
	gint _tmp41_;
	gchar* _tmp42_;
	gchar** real_argv;
	GList* _tmp43_;
	gchar** _tmp44_;
	gint real_argv_length1;
	gint _real_argv_size_;
	gint i;
	GList* _tmp45_;
	GList* _vala1_a_collection;
	GList* _vala1_a_it;
	gchar* _tmp46_;
	gchar* _vala1_a;
	gchar** _tmp47_;
	gint _tmp47__length1;
	gint _tmp48_;
	const gchar* _tmp49_;
	gchar* _tmp50_;
	gchar** _tmp51_;
	gint _tmp51__length1;
	gint _tmp52_;
	gchar** _tmp53_;
	gchar* lockfile_pattern;
	const gchar* _tmp54_;
	gchar* _tmp55_;
	glob_t lockfiles;
	const gchar* _tmp56_;
	gboolean _tmp57_;
	gint _tmp58_;
	glob_t _tmp59_;
	glob_t _tmp60_;
	gchar** _tmp61_;
	gint _tmp61__length1;
	const gchar* _tmp62_;
	glob_t _tmp63_;
	gchar** _tmp64_;
	gint _tmp64__length1;
	const gchar* _tmp65_;
	gchar** _tmp66_;
	gint _tmp66__length1;
	gchar** _tmp67_;
	gint _tmp67__length1;
	GPid _tmp68_;
	const gchar* _tmp69_;
	gint* _tmp70_;
	gint _tmp70__length1;
	gint _tmp71_;
	gint* _tmp72_;
	gint _tmp72__length1;
	gint _tmp73_;
	GError* _inner_error0_;
};

struct _DuplicityInstanceReadLogData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DuplicityInstance* self;
	gint* _tmp0_;
	gint _tmp0__length1;
	gint _tmp1_;
	DejaDupDuplicityLogger* _tmp2_;
	DejaDupDuplicityLogger* _tmp3_;
	gchar* verbose_str;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gboolean _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	DejaDupDuplicityLogger* _tmp9_;
	DejaDupDuplicityLogger* _tmp10_;
	DejaDupDuplicityLogger* _tmp11_;
};

static gint DuplicityInstance_private_offset;
static gpointer duplicity_instance_parent_class = NULL;

VALA_EXTERN GType duplicity_instance_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gboolean duplicity_instance_is_started (DuplicityInstance* self);
static void duplicity_instance_kill_child (DuplicityInstance* self);
static void duplicity_instance_start_data_free (gpointer _data);
VALA_EXTERN void duplicity_instance_start (DuplicityInstance* self,
                               GList* argv_in,
                               GList* envp_in,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_);
VALA_EXTERN void duplicity_instance_start_finish (DuplicityInstance* self,
                                      GAsyncResult* _res_);
static gboolean duplicity_instance_start_co (DuplicityInstanceStartData* _data_);
static void duplicity_instance_start_internal (DuplicityInstance* self,
                                        GList* argv_in,
                                        GList* envp_in,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
static gboolean duplicity_instance_start_internal_finish (DuplicityInstance* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
static void duplicity_instance_start_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_);
static void _g_free0_ (gpointer var);
static inline void _g_list_free__g_free0_ (GList* self);
static void duplicity_instance_start_internal_data_free (gpointer _data);
static gboolean duplicity_instance_start_internal_co (DuplicityInstanceStartInternalData* _data_);
VALA_EXTERN const gchar* duplicity_instance_get_forced_cache_dir (DuplicityInstance* self);
static void duplicity_instance_start_internal_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_);
VALA_EXTERN gint tool_instance_prefix_wrapper_args (GList** args,
                                        GError** error);
static void __lambda29_ (DuplicityInstance* self);
static void ___lambda29__gspawn_child_setup_func (gpointer self);
static void duplicity_instance_spawn_finished (DuplicityInstance* self,
                                        GPid pid,
                                        gint status);
static void _duplicity_instance_spawn_finished_gchild_watch_func (GPid pid,
                                                           gint wait_status,
                                                           gpointer self);
static void duplicity_instance_read_log (DuplicityInstance* self,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
static void duplicity_instance_read_log_finish (DuplicityInstance* self,
                                         GAsyncResult* _res_);
static void duplicity_instance_send_done_for_status (DuplicityInstance* self);
VALA_EXTERN void duplicity_instance_cancel (DuplicityInstance* self);
VALA_EXTERN void duplicity_instance_pause (DuplicityInstance* self);
static void duplicity_instance_stop_child (DuplicityInstance* self);
VALA_EXTERN void duplicity_instance_resume (DuplicityInstance* self);
static void duplicity_instance_cont_child (DuplicityInstance* self);
static void duplicity_instance_read_log_data_free (gpointer _data);
static gboolean duplicity_instance_read_log_co (DuplicityInstanceReadLogData* _data_);
static void __lambda30_ (DuplicityInstance* self,
                  DejaDupDuplicityLogger* l,
                  gchar** c,
                  gint c_length1,
                  GList* d,
                  const gchar* t);
static void ___lambda30__deja_dup_duplicity_logger_message (DejaDupDuplicityLogger* _sender,
                                                     gchar** control_line,
                                                     gint control_line_length1,
                                                     GList* data_lines,
                                                     const gchar* user_text,
                                                     gpointer self);
static void duplicity_instance_read_log_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_);
VALA_EXTERN DuplicityInstance* duplicity_instance_new (void);
VALA_EXTERN DuplicityInstance* duplicity_instance_construct (GType object_type);
VALA_EXTERN void duplicity_instance_set_forced_cache_dir (DuplicityInstance* self,
                                              const gchar* value);
static void g_cclosure_user_marshal_VOID__BOOLEAN_BOOLEAN (GClosure * closure,
                                                    GValue * return_value,
                                                    guint n_param_values,
                                                    const GValue * param_values,
                                                    gpointer invocation_hint,
                                                    gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__BOXED_INT_POINTER_STRING (GClosure * closure,
                                                             GValue * return_value,
                                                             guint n_param_values,
                                                             const GValue * param_values,
                                                             gpointer invocation_hint,
                                                             gpointer marshal_data);
static GObject * duplicity_instance_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void duplicity_instance_finalize (GObject * obj);
static GType duplicity_instance_get_type_once (void);
static void _vala_duplicity_instance_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_duplicity_instance_set_property (GObject * object,
                                            guint property_id,
                                            const 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 gssize _vala_array_length (gpointer array);

static inline gpointer
duplicity_instance_get_instance_private (DuplicityInstance* self)
{
	return G_STRUCT_MEMBER_P (self, DuplicityInstance_private_offset);
}

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

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

void
duplicity_instance_start (DuplicityInstance* self,
                          GList* argv_in,
                          GList* envp_in,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	DuplicityInstanceStartData* _data_;
	DuplicityInstance* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DuplicityInstanceStartData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, duplicity_instance_start_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->argv_in = argv_in;
	_data_->envp_in = envp_in;
	duplicity_instance_start_co (_data_);
}

void
duplicity_instance_start_finish (DuplicityInstance* self,
                                 GAsyncResult* _res_)
{
	DuplicityInstanceStartData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
duplicity_instance_start_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_)
{
	DuplicityInstanceStartData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	duplicity_instance_start_co (_data_);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static inline void
_g_list_free__g_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_free0_);
}

static gboolean
duplicity_instance_start_co (DuplicityInstanceStartData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->argv = NULL;
		{
			_data_->arg_collection = _data_->argv_in;
			for (_data_->arg_it = _data_->arg_collection; _data_->arg_it != NULL; _data_->arg_it = _data_->arg_it->next) {
				_data_->_tmp0_ = g_strdup ((const gchar*) _data_->arg_it->data);
				_data_->arg = _data_->_tmp0_;
				{
					_data_->_tmp1_ = _data_->arg;
					_data_->_tmp2_ = g_strdup (_data_->_tmp1_);
					_data_->argv = g_list_append (_data_->argv, _data_->_tmp2_);
					_g_free0 (_data_->arg);
				}
			}
		}
		_data_->envp = NULL;
		{
			_data_->env_collection = _data_->envp_in;
			for (_data_->env_it = _data_->env_collection; _data_->env_it != NULL; _data_->env_it = _data_->env_it->next) {
				_data_->_tmp3_ = g_strdup ((const gchar*) _data_->env_it->data);
				_data_->env = _data_->_tmp3_;
				{
					_data_->_tmp4_ = _data_->env;
					_data_->_tmp5_ = g_strdup (_data_->_tmp4_);
					_data_->envp = g_list_append (_data_->envp, _data_->_tmp5_);
					_g_free0 (_data_->env);
				}
			}
		}
		_data_->_tmp7_ = _data_->argv;
		_data_->_tmp8_ = _data_->envp;
		_data_->_state_ = 1;
		duplicity_instance_start_internal (_data_->self, _data_->_tmp7_, _data_->_tmp8_, duplicity_instance_start_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp6_ = duplicity_instance_start_internal_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			(_data_->envp == NULL) ? NULL : (_data_->envp = (_g_list_free__g_free0_ (_data_->envp), NULL));
			(_data_->argv == NULL) ? NULL : (_data_->argv = (_g_list_free__g_free0_ (_data_->argv), NULL));
			goto __catch0_g_error;
		}
		if (!_data_->_tmp6_) {
			g_signal_emit (_data_->self, duplicity_instance_signals[DUPLICITY_INSTANCE_DONE_SIGNAL], 0, FALSE, FALSE);
		}
		(_data_->envp == NULL) ? NULL : (_data_->envp = (_g_list_free__g_free0_ (_data_->envp), NULL));
		(_data_->argv == NULL) ? NULL : (_data_->argv = (_g_list_free__g_free0_ (_data_->argv), NULL));
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp9_ = g_strdup ("ERROR");
		_data_->_tmp10_ = g_strdup ("1");
		_data_->_tmp11_ = g_new0 (gchar*, 2 + 1);
		_data_->_tmp11_[0] = _data_->_tmp9_;
		_data_->_tmp11_[1] = _data_->_tmp10_;
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp12__length1 = 2;
		_data_->_tmp13_ = _data_->e;
		_data_->_tmp14_ = _data_->_tmp13_->message;
		g_signal_emit (_data_->self, duplicity_instance_signals[DUPLICITY_INSTANCE_MESSAGE_SIGNAL], 0, _data_->_tmp12_, (gint) 2, NULL, _data_->_tmp14_);
		_data_->_tmp12_ = (_vala_array_free (_data_->_tmp12_, _data_->_tmp12__length1, (GDestroyNotify) g_free), NULL);
		g_signal_emit (_data_->self, duplicity_instance_signals[DUPLICITY_INSTANCE_DONE_SIGNAL], 0, FALSE, FALSE);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	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
duplicity_instance_start_internal_data_free (gpointer _data)
{
	DuplicityInstanceStartInternalData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DuplicityInstanceStartInternalData, _data_);
}

static void
duplicity_instance_start_internal (DuplicityInstance* self,
                                   GList* argv_in,
                                   GList* envp_in,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_)
{
	DuplicityInstanceStartInternalData* _data_;
	DuplicityInstance* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DuplicityInstanceStartInternalData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, duplicity_instance_start_internal_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->argv_in = argv_in;
	_data_->envp_in = envp_in;
	duplicity_instance_start_internal_co (_data_);
}

static gboolean
duplicity_instance_start_internal_finish (DuplicityInstance* self,
                                          GAsyncResult* _res_,
                                          GError** error)
{
	gboolean result;
	DuplicityInstanceStartInternalData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
duplicity_instance_start_internal_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_)
{
	DuplicityInstanceStartInternalData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	duplicity_instance_start_internal_co (_data_);
}

static void
__lambda29_ (DuplicityInstance* self)
{
	setsid ();
}

static void
___lambda29__gspawn_child_setup_func (gpointer self)
{
	__lambda29_ ((DuplicityInstance*) self);
}

static void
_duplicity_instance_spawn_finished_gchild_watch_func (GPid pid,
                                                      gint wait_status,
                                                      gpointer self)
{
	duplicity_instance_spawn_finished ((DuplicityInstance*) self, pid, wait_status);
}

static gboolean
duplicity_instance_start_internal_co (DuplicityInstanceStartInternalData* _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_ = 0;
	_data_->_tmp1_ = deja_dup_copy_env (_data_->envp_in, &_data_->_tmp0_);
	_data_->real_envp = _data_->_tmp1_;
	_data_->real_envp_length1 = _data_->_tmp0_;
	_data_->_real_envp_size_ = _data_->real_envp_length1;
	_data_->argv = NULL;
	{
		_data_->arg_collection = _data_->argv_in;
		for (_data_->arg_it = _data_->arg_collection; _data_->arg_it != NULL; _data_->arg_it = _data_->arg_it->next) {
			_data_->_tmp2_ = g_strdup ((const gchar*) _data_->arg_it->data);
			_data_->arg = _data_->_tmp2_;
			{
				_data_->_tmp3_ = _data_->arg;
				_data_->_tmp4_ = g_strdup (_data_->_tmp3_);
				_data_->argv = g_list_append (_data_->argv, _data_->_tmp4_);
				_g_free0 (_data_->arg);
			}
		}
	}
	_data_->_tmp5_ = g_strdup ("--verbosity=9");
	_data_->argv = g_list_append (_data_->argv, _data_->_tmp5_);
	_data_->_tmp6_ = g_strdup ("--timeout=120");
	_data_->argv = g_list_append (_data_->argv, _data_->_tmp6_);
	_data_->_tmp7_ = _data_->self->priv->_forced_cache_dir;
	_data_->_tmp8_ = g_strdup (_data_->_tmp7_);
	_data_->cache_dir = _data_->_tmp8_;
	_data_->_tmp9_ = _data_->cache_dir;
	if (_data_->_tmp9_ == NULL) {
		_data_->_tmp10_ = g_get_user_cache_dir ();
		_data_->_tmp11_ = g_build_filename (_data_->_tmp10_, PACKAGE, NULL);
		_g_free0 (_data_->cache_dir);
		_data_->cache_dir = _data_->_tmp11_;
	}
	_data_->_tmp13_ = _data_->cache_dir;
	if (_data_->_tmp13_ != NULL) {
		_data_->_tmp14_ = _data_->cache_dir;
		_data_->_tmp12_ = deja_dup_ensure_directory_exists (_data_->_tmp14_);
	} else {
		_data_->_tmp12_ = FALSE;
	}
	if (_data_->_tmp12_) {
		_data_->_tmp15_ = _data_->cache_dir;
		_data_->_tmp16_ = g_strconcat ("--archive-dir=", _data_->_tmp15_, NULL);
		_data_->argv = g_list_append (_data_->argv, _data_->_tmp16_);
	}
	_data_->_state_ = 1;
	deja_dup_get_tempdir (duplicity_instance_start_internal_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp17_ = deja_dup_get_tempdir_finish (_data_->_res_);
	_data_->tempdir = _data_->_tmp17_;
	_data_->_tmp18_ = _data_->tempdir;
	if (deja_dup_ensure_directory_exists (_data_->_tmp18_)) {
		_data_->_tmp19_ = _data_->tempdir;
		_data_->_tmp20_ = g_strdup_printf ("--tempdir=%s", _data_->_tmp19_);
		_data_->argv = g_list_append (_data_->argv, _data_->_tmp20_);
	}
	_data_->_tmp21_ = g_getenv ("DEJA_DUP_TEST_FAST_FAIL");
	_data_->_tmp22_ = g_strdup (_data_->_tmp21_);
	_data_->fast_fail_str = _data_->_tmp22_;
	_data_->_tmp24_ = _data_->fast_fail_str;
	if (_data_->_tmp24_ != NULL) {
		_data_->_tmp25_ = _data_->fast_fail_str;
		_data_->_tmp23_ = atoi (_data_->_tmp25_) > 0;
	} else {
		_data_->_tmp23_ = FALSE;
	}
	if (_data_->_tmp23_) {
		_data_->_tmp26_ = g_strdup ("--num-retries=1");
		_data_->argv = g_list_append (_data_->argv, _data_->_tmp26_);
	}
	_data_->_tmp27_ = duplicity_plugin_duplicity_command ();
	_data_->argv = g_list_prepend (_data_->argv, _data_->_tmp27_);
	tool_instance_prefix_wrapper_args (&_data_->argv, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_free0 (_data_->fast_fail_str);
		_g_free0 (_data_->tempdir);
		_g_free0 (_data_->cache_dir);
		(_data_->argv == NULL) ? NULL : (_data_->argv = (_g_list_free__g_free0_ (_data_->argv), NULL));
		_data_->real_envp = (_vala_array_free (_data_->real_envp, _data_->real_envp_length1, (GDestroyNotify) g_free), NULL);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->user_cmd = NULL;
	_data_->_tmp28_ = _data_->argv;
	{
		_data_->a_collection = _data_->_tmp28_;
		for (_data_->a_it = _data_->a_collection; _data_->a_it != NULL; _data_->a_it = _data_->a_it->next) {
			_data_->_tmp29_ = g_strdup ((const gchar*) _data_->a_it->data);
			_data_->a = _data_->_tmp29_;
			{
				_data_->_tmp30_ = _data_->a;
				if (_data_->_tmp30_ == NULL) {
					_g_free0 (_data_->a);
					break;
				}
				_data_->_tmp31_ = _data_->user_cmd;
				if (_data_->_tmp31_ == NULL) {
					_data_->_tmp32_ = _data_->a;
					_data_->_tmp33_ = g_strdup (_data_->_tmp32_);
					_g_free0 (_data_->user_cmd);
					_data_->user_cmd = _data_->_tmp33_;
				} else {
					_data_->_tmp34_ = _data_->user_cmd;
					_data_->_tmp35_ = _data_->a;
					_data_->_tmp36_ = g_shell_quote (_data_->_tmp35_);
					_data_->_tmp37_ = _data_->_tmp36_;
					_data_->_tmp38_ = g_strdup_printf ("%s %s", _data_->_tmp34_, _data_->_tmp37_);
					_g_free0 (_data_->user_cmd);
					_data_->user_cmd = _data_->_tmp38_;
					_g_free0 (_data_->_tmp37_);
				}
				_g_free0 (_data_->a);
			}
		}
	}
	_data_->_tmp39_ = _data_->self->priv->pipes;
	_data_->_tmp39__length1 = _data_->self->priv->pipes_length1;
	if (pipe (_data_->_tmp39_) != 0) {
		_data_->result = FALSE;
		_g_free0 (_data_->user_cmd);
		_g_free0 (_data_->fast_fail_str);
		_g_free0 (_data_->tempdir);
		_g_free0 (_data_->cache_dir);
		(_data_->argv == NULL) ? NULL : (_data_->argv = (_g_list_free__g_free0_ (_data_->argv), NULL));
		_data_->real_envp = (_vala_array_free (_data_->real_envp, _data_->real_envp_length1, (GDestroyNotify) g_free), NULL);
		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;
	}
	_data_->_tmp40_ = _data_->self->priv->pipes;
	_data_->_tmp40__length1 = _data_->self->priv->pipes_length1;
	_data_->_tmp41_ = _data_->_tmp40_[1];
	_data_->_tmp42_ = g_strdup_printf ("--log-fd=%d", _data_->_tmp41_);
	_data_->argv = g_list_append (_data_->argv, _data_->_tmp42_);
	_data_->_tmp43_ = _data_->argv;
	_data_->_tmp44_ = g_new0 (gchar*, g_list_length (_data_->_tmp43_) + 1);
	_data_->real_argv = _data_->_tmp44_;
	_data_->real_argv_length1 = g_list_length (_data_->_tmp43_);
	_data_->_real_argv_size_ = _data_->real_argv_length1;
	_data_->i = 0;
	_data_->_tmp45_ = _data_->argv;
	{
		_data_->_vala1_a_collection = _data_->_tmp45_;
		for (_data_->_vala1_a_it = _data_->_vala1_a_collection; _data_->_vala1_a_it != NULL; _data_->_vala1_a_it = _data_->_vala1_a_it->next) {
			_data_->_tmp46_ = g_strdup ((const gchar*) _data_->_vala1_a_it->data);
			_data_->_vala1_a = _data_->_tmp46_;
			{
				_data_->_tmp47_ = _data_->real_argv;
				_data_->_tmp47__length1 = _data_->real_argv_length1;
				_data_->_tmp48_ = _data_->i;
				_data_->i = _data_->_tmp48_ + 1;
				_data_->_tmp49_ = _data_->_vala1_a;
				_data_->_tmp50_ = g_strdup (_data_->_tmp49_);
				_g_free0 (_data_->_tmp47_[_data_->_tmp48_]);
				_data_->_tmp47_[_data_->_tmp48_] = _data_->_tmp50_;
				_g_free0 (_data_->_vala1_a);
			}
		}
	}
	_data_->_tmp51_ = _data_->real_argv;
	_data_->_tmp51__length1 = _data_->real_argv_length1;
	_data_->_tmp52_ = 0;
	_data_->_tmp53_ = deja_dup_nice_prefix (_data_->_tmp51_, (gint) _data_->_tmp51__length1, &_data_->_tmp52_);
	_data_->real_argv = (_vala_array_free (_data_->real_argv, _data_->real_argv_length1, (GDestroyNotify) g_free), NULL);
	_data_->real_argv = _data_->_tmp53_;
	_data_->real_argv_length1 = _data_->_tmp52_;
	_data_->_real_argv_size_ = _data_->real_argv_length1;
	_data_->_tmp54_ = _data_->cache_dir;
	_data_->_tmp55_ = g_strconcat (_data_->_tmp54_, "/*/lockfile\\.lock", NULL);
	_data_->lockfile_pattern = _data_->_tmp55_;
	memset (&_data_->lockfiles, 0, sizeof (glob_t));
	_data_->_tmp56_ = _data_->lockfile_pattern;
	if (glob (_data_->_tmp56_, GLOB_NOSORT, NULL, &_data_->lockfiles) == 0) {
		{
			_data_->i = 0;
			_data_->_tmp57_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp57_) {
					_data_->_tmp58_ = _data_->i;
					_data_->i = _data_->_tmp58_ + 1;
				}
				_data_->_tmp57_ = FALSE;
				_data_->_tmp59_ = _data_->lockfiles;
				if (!(((gsize) _data_->i) < _data_->_tmp59_.gl_pathc)) {
					break;
				}
				_data_->_tmp60_ = _data_->lockfiles;
				_data_->_tmp61_ = _data_->_tmp60_.gl_pathv;
				_data_->_tmp61__length1 = _vala_array_length (_data_->_tmp60_.gl_pathv);
				_data_->_tmp62_ = _data_->_tmp61_[_data_->i];
				if (g_remove (_data_->_tmp62_) != 0) {
					_data_->_tmp63_ = _data_->lockfiles;
					_data_->_tmp64_ = _data_->_tmp63_.gl_pathv;
					_data_->_tmp64__length1 = _vala_array_length (_data_->_tmp63_.gl_pathv);
					_data_->_tmp65_ = _data_->_tmp64_[_data_->i];
					g_warning ("DuplicityInstance.vala:111: Could not delete '%s'", _data_->_tmp65_);
				}
			}
		}
	}
	_data_->_tmp66_ = _data_->real_argv;
	_data_->_tmp66__length1 = _data_->real_argv_length1;
	_data_->_tmp67_ = _data_->real_envp;
	_data_->_tmp67__length1 = _data_->real_envp_length1;
	_data_->_tmp68_ = 0;
	g_spawn_async_with_pipes (NULL, _data_->_tmp66_, _data_->_tmp67_, (((G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD) | G_SPAWN_LEAVE_DESCRIPTORS_OPEN) | G_SPAWN_STDOUT_TO_DEV_NULL) | G_SPAWN_STDERR_TO_DEV_NULL, ___lambda29__gspawn_child_setup_func, _data_->self, &_data_->_tmp68_, NULL, NULL, NULL, &_data_->_inner_error0_);
	_data_->self->priv->child_pid = _data_->_tmp68_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		globfree (&_data_->lockfiles);
		_g_free0 (_data_->lockfile_pattern);
		_data_->real_argv = (_vala_array_free (_data_->real_argv, _data_->real_argv_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_data_->user_cmd);
		_g_free0 (_data_->fast_fail_str);
		_g_free0 (_data_->tempdir);
		_g_free0 (_data_->cache_dir);
		(_data_->argv == NULL) ? NULL : (_data_->argv = (_g_list_free__g_free0_ (_data_->argv), NULL));
		_data_->real_envp = (_vala_array_free (_data_->real_envp, _data_->real_envp_length1, (GDestroyNotify) g_free), NULL);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp69_ = _data_->user_cmd;
	g_debug ("DuplicityInstance.vala:127: Running the following duplicity (%i) comma" \
"nd: %s\n", (gint) _data_->self->priv->child_pid, _data_->_tmp69_);
	_data_->self->priv->watch_id = g_child_watch_add_full (G_PRIORITY_DEFAULT_IDLE, _data_->self->priv->child_pid, _duplicity_instance_spawn_finished_gchild_watch_func, g_object_ref (_data_->self), g_object_unref);
	_data_->_tmp70_ = _data_->self->priv->pipes;
	_data_->_tmp70__length1 = _data_->self->priv->pipes_length1;
	_data_->_tmp71_ = _data_->_tmp70_[1];
	if (_data_->_tmp71_ != -1) {
		_data_->_tmp72_ = _data_->self->priv->pipes;
		_data_->_tmp72__length1 = _data_->self->priv->pipes_length1;
		_data_->_tmp73_ = _data_->_tmp72_[1];
		close (_data_->_tmp73_);
	}
	_data_->_state_ = 2;
	duplicity_instance_read_log (_data_->self, duplicity_instance_start_internal_ready, _data_);
	return FALSE;
	_state_2:
	duplicity_instance_read_log_finish (_data_->self, _data_->_res_);
	_data_->self->priv->reading_done = TRUE;
	if (_data_->self->priv->process_done) {
		duplicity_instance_send_done_for_status (_data_->self);
	}
	_data_->result = TRUE;
	globfree (&_data_->lockfiles);
	_g_free0 (_data_->lockfile_pattern);
	_data_->real_argv = (_vala_array_free (_data_->real_argv, _data_->real_argv_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (_data_->user_cmd);
	_g_free0 (_data_->fast_fail_str);
	_g_free0 (_data_->tempdir);
	_g_free0 (_data_->cache_dir);
	(_data_->argv == NULL) ? NULL : (_data_->argv = (_g_list_free__g_free0_ (_data_->argv), NULL));
	_data_->real_envp = (_vala_array_free (_data_->real_envp, _data_->real_envp_length1, (GDestroyNotify) g_free), NULL);
	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;
}

gboolean
duplicity_instance_is_started (DuplicityInstance* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = ((gint) self->priv->child_pid) > 0;
	return result;
}

void
duplicity_instance_cancel (DuplicityInstance* self)
{
	g_return_if_fail (self != NULL);
	if (duplicity_instance_is_started (self)) {
		duplicity_instance_kill_child (self);
	} else {
		g_signal_emit (self, duplicity_instance_signals[DUPLICITY_INSTANCE_DONE_SIGNAL], 0, FALSE, TRUE);
	}
}

void
duplicity_instance_pause (DuplicityInstance* self)
{
	g_return_if_fail (self != NULL);
	if (duplicity_instance_is_started (self)) {
		duplicity_instance_stop_child (self);
	}
}

void
duplicity_instance_resume (DuplicityInstance* self)
{
	g_return_if_fail (self != NULL);
	if (duplicity_instance_is_started (self)) {
		duplicity_instance_cont_child (self);
	}
}

static void
duplicity_instance_kill_child (DuplicityInstance* self)
{
	g_return_if_fail (self != NULL);
	kill ((pid_t) self->priv->child_pid, (gint) SIGKILL);
}

static void
duplicity_instance_stop_child (DuplicityInstance* self)
{
	g_return_if_fail (self != NULL);
	kill ((pid_t) self->priv->child_pid, (gint) SIGSTOP);
}

static void
duplicity_instance_cont_child (DuplicityInstance* self)
{
	g_return_if_fail (self != NULL);
	kill ((pid_t) self->priv->child_pid, (gint) SIGCONT);
}

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

static void
duplicity_instance_read_log (DuplicityInstance* self,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_)
{
	DuplicityInstanceReadLogData* _data_;
	DuplicityInstance* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DuplicityInstanceReadLogData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, duplicity_instance_read_log_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	duplicity_instance_read_log_co (_data_);
}

static void
duplicity_instance_read_log_finish (DuplicityInstance* self,
                                    GAsyncResult* _res_)
{
	DuplicityInstanceReadLogData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
__lambda30_ (DuplicityInstance* self,
             DejaDupDuplicityLogger* l,
             gchar** c,
             gint c_length1,
             GList* d,
             const gchar* t)
{
	g_return_if_fail (l != NULL);
	g_return_if_fail (t != NULL);
	g_signal_emit (self, duplicity_instance_signals[DUPLICITY_INSTANCE_MESSAGE_SIGNAL], 0, c, (gint) c_length1, d, t);
}

static void
___lambda30__deja_dup_duplicity_logger_message (DejaDupDuplicityLogger* _sender,
                                                gchar** control_line,
                                                gint control_line_length1,
                                                GList* data_lines,
                                                const gchar* user_text,
                                                gpointer self)
{
	__lambda30_ ((DuplicityInstance*) self, _sender, control_line, control_line_length1, data_lines, user_text);
}

static void
duplicity_instance_read_log_ready (GObject* source_object,
                                   GAsyncResult* _res_,
                                   gpointer _user_data_)
{
	DuplicityInstanceReadLogData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	duplicity_instance_read_log_co (_data_);
}

static gboolean
duplicity_instance_read_log_co (DuplicityInstanceReadLogData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->pipes;
	_data_->_tmp0__length1 = _data_->self->priv->pipes_length1;
	_data_->_tmp1_ = _data_->_tmp0_[0];
	_data_->_tmp2_ = deja_dup_duplicity_logger_new_for_fd (_data_->_tmp1_);
	_g_object_unref0 (_data_->self->priv->logger);
	_data_->self->priv->logger = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->self->priv->logger;
	g_signal_connect_object (_data_->_tmp3_, "message", (GCallback) ___lambda30__deja_dup_duplicity_logger_message, _data_->self, 0);
	_data_->_tmp4_ = g_getenv ("DEJA_DUP_DEBUG");
	_data_->_tmp5_ = g_strdup (_data_->_tmp4_);
	_data_->verbose_str = _data_->_tmp5_;
	_data_->_tmp7_ = _data_->verbose_str;
	if (_data_->_tmp7_ != NULL) {
		_data_->_tmp8_ = _data_->verbose_str;
		_data_->_tmp6_ = atoi (_data_->_tmp8_) > 0;
	} else {
		_data_->_tmp6_ = FALSE;
	}
	if (_data_->_tmp6_) {
		_data_->_tmp9_ = _data_->self->priv->logger;
		deja_dup_duplicity_logger_set_print_to_console (_data_->_tmp9_, TRUE);
	}
	g_object_ref ((GObject*) _data_->self);
	_data_->_tmp10_ = _data_->self->priv->logger;
	_data_->_state_ = 1;
	deja_dup_duplicity_logger_read (_data_->_tmp10_, NULL, duplicity_instance_read_log_ready, _data_);
	return FALSE;
	_state_1:
	deja_dup_duplicity_logger_read_finish (_data_->_tmp10_, _data_->_res_);
	_data_->_tmp11_ = _data_->self->priv->logger;
	deja_dup_duplicity_logger_write_tail_to_cache (_data_->_tmp11_);
	g_object_unref ((GObject*) _data_->self);
	_g_free0 (_data_->verbose_str);
	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
duplicity_instance_spawn_finished (DuplicityInstance* self,
                                   GPid pid,
                                   gint status)
{
	g_return_if_fail (self != NULL);
	self->priv->status = status;
	if (WIFEXITED (status)) {
		gint exitval = 0;
		exitval = WEXITSTATUS (status);
		g_debug ("DuplicityInstance.vala:226: duplicity (%i) exited with value %i\n", (gint) pid, exitval);
	} else {
		g_debug ("DuplicityInstance.vala:229: duplicity (%i) process killed\n", (gint) pid);
	}
	self->priv->watch_id = (guint) 0;
	g_spawn_close_pid (pid);
	self->priv->process_done = TRUE;
	if (self->priv->reading_done) {
		duplicity_instance_send_done_for_status (self);
	}
}

static void
duplicity_instance_send_done_for_status (DuplicityInstance* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean success = FALSE;
	gboolean cancelled = FALSE;
	g_return_if_fail (self != NULL);
	if (WIFEXITED (self->priv->status)) {
		_tmp0_ = WEXITSTATUS (self->priv->status) == 0;
	} else {
		_tmp0_ = FALSE;
	}
	success = _tmp0_;
	cancelled = !WIFEXITED (self->priv->status);
	if (WIFEXITED (self->priv->status)) {
		g_signal_emit (self, duplicity_instance_signals[DUPLICITY_INSTANCE_EXITED_SIGNAL], 0, WEXITSTATUS (self->priv->status));
	}
	self->priv->child_pid = (GPid) 0;
	g_signal_emit (self, duplicity_instance_signals[DUPLICITY_INSTANCE_DONE_SIGNAL], 0, success, cancelled);
}

DuplicityInstance*
duplicity_instance_construct (GType object_type)
{
	DuplicityInstance * self = NULL;
	self = (DuplicityInstance*) g_object_new (object_type, NULL);
	return self;
}

DuplicityInstance*
duplicity_instance_new (void)
{
	return duplicity_instance_construct (TYPE_DUPLICITY_INSTANCE);
}

const gchar*
duplicity_instance_get_forced_cache_dir (DuplicityInstance* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_forced_cache_dir;
	result = _tmp0_;
	return result;
}

void
duplicity_instance_set_forced_cache_dir (DuplicityInstance* self,
                                         const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = duplicity_instance_get_forced_cache_dir (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_forced_cache_dir);
		self->priv->_forced_cache_dir = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, duplicity_instance_properties[DUPLICITY_INSTANCE_FORCED_CACHE_DIR_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__BOOLEAN_BOOLEAN (GClosure * closure,
                                               GValue * return_value,
                                               guint n_param_values,
                                               const GValue * param_values,
                                               gpointer invocation_hint,
                                               gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__BOOLEAN_BOOLEAN) (gpointer data1, gboolean arg_1, gboolean arg_2, gpointer data2);
	register GMarshalFunc_VOID__BOOLEAN_BOOLEAN callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__BOOLEAN_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_boolean (param_values + 1), g_value_get_boolean (param_values + 2), data2);
}

static void
g_cclosure_user_marshal_VOID__BOXED_INT_POINTER_STRING (GClosure * closure,
                                                        GValue * return_value,
                                                        guint n_param_values,
                                                        const GValue * param_values,
                                                        gpointer invocation_hint,
                                                        gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__BOXED_INT_POINTER_STRING) (gpointer data1, gpointer arg_1, gint arg_2, gpointer arg_3, const char* arg_4, gpointer data2);
	register GMarshalFunc_VOID__BOXED_INT_POINTER_STRING callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 5);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__BOXED_INT_POINTER_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_boxed (param_values + 1), g_value_get_int (param_values + 2), g_value_get_pointer (param_values + 3), g_value_get_string (param_values + 4), data2);
}

static GObject *
duplicity_instance_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DuplicityInstance * self;
	gint* _tmp0_;
	gint* _tmp1_;
	gint _tmp1__length1;
	gint* _tmp2_;
	gint _tmp2__length1;
	parent_class = G_OBJECT_CLASS (duplicity_instance_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DUPLICITY_INSTANCE, DuplicityInstance);
	_tmp0_ = g_new0 (gint, 2);
	self->priv->pipes = (g_free (self->priv->pipes), NULL);
	self->priv->pipes = _tmp0_;
	self->priv->pipes_length1 = 2;
	self->priv->_pipes_size_ = self->priv->pipes_length1;
	_tmp1_ = self->priv->pipes;
	_tmp1__length1 = self->priv->pipes_length1;
	_tmp2_ = self->priv->pipes;
	_tmp2__length1 = self->priv->pipes_length1;
	_tmp2_[1] = -1;
	_tmp1_[0] = _tmp2_[1];
	return obj;
}

static void
duplicity_instance_class_init (DuplicityInstanceClass * klass,
                               gpointer klass_data)
{
	duplicity_instance_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DuplicityInstance_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_duplicity_instance_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_duplicity_instance_set_property;
	G_OBJECT_CLASS (klass)->constructor = duplicity_instance_constructor;
	G_OBJECT_CLASS (klass)->finalize = duplicity_instance_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DUPLICITY_INSTANCE_FORCED_CACHE_DIR_PROPERTY, duplicity_instance_properties[DUPLICITY_INSTANCE_FORCED_CACHE_DIR_PROPERTY] = g_param_spec_string ("forced-cache-dir", "forced-cache-dir", "forced-cache-dir", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	duplicity_instance_signals[DUPLICITY_INSTANCE_DONE_SIGNAL] = g_signal_new ("done", TYPE_DUPLICITY_INSTANCE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOOLEAN_BOOLEAN, G_TYPE_NONE, 2, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
	duplicity_instance_signals[DUPLICITY_INSTANCE_EXITED_SIGNAL] = g_signal_new ("exited", TYPE_DUPLICITY_INSTANCE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	duplicity_instance_signals[DUPLICITY_INSTANCE_MESSAGE_SIGNAL] = g_signal_new ("message", TYPE_DUPLICITY_INSTANCE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__BOXED_INT_POINTER_STRING, G_TYPE_NONE, 4, G_TYPE_STRV, G_TYPE_INT, G_TYPE_POINTER, G_TYPE_STRING);
}

static void
duplicity_instance_instance_init (DuplicityInstance * self,
                                  gpointer klass)
{
	self->priv = duplicity_instance_get_instance_private (self);
	self->priv->_forced_cache_dir = NULL;
}

static void
duplicity_instance_finalize (GObject * obj)
{
	DuplicityInstance * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_DUPLICITY_INSTANCE, DuplicityInstance);
	if (self->priv->watch_id != ((guint) 0)) {
		g_source_remove (self->priv->watch_id);
	}
	if (duplicity_instance_is_started (self)) {
		g_debug ("DuplicityInstance.vala:186: duplicity (%i) process killed\n", (gint) self->priv->child_pid);
		duplicity_instance_kill_child (self);
	}
	_g_free0 (self->priv->_forced_cache_dir);
	self->priv->pipes = (g_free (self->priv->pipes), NULL);
	_g_object_unref0 (self->priv->logger);
	G_OBJECT_CLASS (duplicity_instance_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
duplicity_instance_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DuplicityInstanceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) duplicity_instance_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DuplicityInstance), 0, (GInstanceInitFunc) duplicity_instance_instance_init, NULL };
	GType duplicity_instance_type_id;
	duplicity_instance_type_id = g_type_register_static (G_TYPE_OBJECT, "DuplicityInstance", &g_define_type_info, 0);
	DuplicityInstance_private_offset = g_type_add_instance_private (duplicity_instance_type_id, sizeof (DuplicityInstancePrivate));
	return duplicity_instance_type_id;
}

GType
duplicity_instance_get_type (void)
{
	static gsize duplicity_instance_type_id__once = 0;
	if (g_once_init_enter (&duplicity_instance_type_id__once)) {
		GType duplicity_instance_type_id;
		duplicity_instance_type_id = duplicity_instance_get_type_once ();
		g_once_init_leave (&duplicity_instance_type_id__once, duplicity_instance_type_id);
	}
	return duplicity_instance_type_id__once;
}

static void
_vala_duplicity_instance_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	DuplicityInstance * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DUPLICITY_INSTANCE, DuplicityInstance);
	switch (property_id) {
		case DUPLICITY_INSTANCE_FORCED_CACHE_DIR_PROPERTY:
		g_value_set_string (value, duplicity_instance_get_forced_cache_dir (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_duplicity_instance_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	DuplicityInstance * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_DUPLICITY_INSTANCE, DuplicityInstance);
	switch (property_id) {
		case DUPLICITY_INSTANCE_FORCED_CACHE_DIR_PROPERTY:
		duplicity_instance_set_forced_cache_dir (self, g_value_get_string (value));
		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);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

