/* OperationBackup.c generated by valac 0.30.2, the Vala compiler
 * generated from OperationBackup.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>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>


#define DEJA_DUP_TYPE_OPERATION (deja_dup_operation_get_type ())
#define DEJA_DUP_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_OPERATION, DejaDupOperation))
#define DEJA_DUP_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_OPERATION, DejaDupOperationClass))
#define DEJA_DUP_IS_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_OPERATION))
#define DEJA_DUP_IS_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_OPERATION))
#define DEJA_DUP_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_OPERATION, DejaDupOperationClass))

typedef struct _DejaDupOperation DejaDupOperation;
typedef struct _DejaDupOperationClass DejaDupOperationClass;
typedef struct _DejaDupOperationPrivate DejaDupOperationPrivate;

#define DEJA_DUP_TYPE_TOOL_JOB (deja_dup_tool_job_get_type ())
#define DEJA_DUP_TOOL_JOB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_TOOL_JOB, DejaDupToolJob))
#define DEJA_DUP_TOOL_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_TOOL_JOB, DejaDupToolJobClass))
#define DEJA_DUP_IS_TOOL_JOB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_TOOL_JOB))
#define DEJA_DUP_IS_TOOL_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_TOOL_JOB))
#define DEJA_DUP_TOOL_JOB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_TOOL_JOB, DejaDupToolJobClass))

typedef struct _DejaDupToolJob DejaDupToolJob;
typedef struct _DejaDupToolJobClass DejaDupToolJobClass;

#define DEJA_DUP_TYPE_OPERATION_BACKUP (deja_dup_operation_backup_get_type ())
#define DEJA_DUP_OPERATION_BACKUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_OPERATION_BACKUP, DejaDupOperationBackup))
#define DEJA_DUP_OPERATION_BACKUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_OPERATION_BACKUP, DejaDupOperationBackupClass))
#define DEJA_DUP_IS_OPERATION_BACKUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_OPERATION_BACKUP))
#define DEJA_DUP_IS_OPERATION_BACKUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_OPERATION_BACKUP))
#define DEJA_DUP_OPERATION_BACKUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_OPERATION_BACKUP, DejaDupOperationBackupClass))

typedef struct _DejaDupOperationBackup DejaDupOperationBackup;
typedef struct _DejaDupOperationBackupClass DejaDupOperationBackupClass;
typedef struct _DejaDupOperationBackupPrivate DejaDupOperationBackupPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define DEJA_DUP_TOOL_JOB_TYPE_MODE (deja_dup_tool_job_mode_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))

#define DEJA_DUP_TYPE_TIMESTAMP_TYPE (deja_dup_timestamp_type_get_type ())

#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;

#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;

#define DEJA_DUP_TYPE_OPERATION_VERIFY (deja_dup_operation_verify_get_type ())
#define DEJA_DUP_OPERATION_VERIFY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_OPERATION_VERIFY, DejaDupOperationVerify))
#define DEJA_DUP_OPERATION_VERIFY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_OPERATION_VERIFY, DejaDupOperationVerifyClass))
#define DEJA_DUP_IS_OPERATION_VERIFY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_OPERATION_VERIFY))
#define DEJA_DUP_IS_OPERATION_VERIFY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_OPERATION_VERIFY))
#define DEJA_DUP_OPERATION_VERIFY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_OPERATION_VERIFY, DejaDupOperationVerifyClass))

typedef struct _DejaDupOperationVerify DejaDupOperationVerify;
typedef struct _DejaDupOperationVerifyClass DejaDupOperationVerifyClass;
typedef struct _DejaDupOperationBackupOperationFinishedData DejaDupOperationBackupOperationFinishedData;

#define DEJA_DUP_TYPE_FILTERED_SETTINGS (deja_dup_filtered_settings_get_type ())
#define DEJA_DUP_FILTERED_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_FILTERED_SETTINGS, DejaDupFilteredSettings))
#define DEJA_DUP_FILTERED_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_FILTERED_SETTINGS, DejaDupFilteredSettingsClass))
#define DEJA_DUP_IS_FILTERED_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_FILTERED_SETTINGS))
#define DEJA_DUP_IS_FILTERED_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_FILTERED_SETTINGS))
#define DEJA_DUP_FILTERED_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_FILTERED_SETTINGS, DejaDupFilteredSettingsClass))

typedef struct _DejaDupFilteredSettings DejaDupFilteredSettings;
typedef struct _DejaDupFilteredSettingsClass DejaDupFilteredSettingsClass;
typedef struct _DejaDupToolJobPrivate DejaDupToolJobPrivate;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __g_list_free__g_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_free0_ (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

struct _DejaDupOperation {
	GObject parent_instance;
	DejaDupOperationPrivate * priv;
	DejaDupToolJob* job;
	gchar* passphrase;
};

struct _DejaDupOperationClass {
	GObjectClass parent_class;
	void (*start) (DejaDupOperation* self, gboolean try_claim_bus, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*start_finish) (DejaDupOperation* self, GAsyncResult* _res_);
	void (*connect_to_job) (DejaDupOperation* self);
	void (*send_action_file_changed) (DejaDupOperation* self, GFile* file, gboolean actual);
	void (*operation_finished) (DejaDupOperation* self, DejaDupToolJob* job, gboolean success, gboolean cancelled, const gchar* detail, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*operation_finished_finish) (DejaDupOperation* self, GAsyncResult* _res_);
	GList* (*make_argv) (DejaDupOperation* self);
};

struct _DejaDupOperationBackup {
	DejaDupOperation parent_instance;
	DejaDupOperationBackupPrivate * priv;
};

struct _DejaDupOperationBackupClass {
	DejaDupOperationClass parent_class;
};

struct _DejaDupOperationBackupPrivate {
	GFile* metadir;
};

typedef enum  {
	DEJA_DUP_TOOL_JOB_MODE_INVALID,
	DEJA_DUP_TOOL_JOB_MODE_BACKUP,
	DEJA_DUP_TOOL_JOB_MODE_RESTORE,
	DEJA_DUP_TOOL_JOB_MODE_STATUS,
	DEJA_DUP_TOOL_JOB_MODE_LIST,
	DEJA_DUP_TOOL_JOB_MODE_HISTORY
} DejaDupToolJobMode;

typedef enum  {
	DEJA_DUP_TIMESTAMP_TYPE_NONE,
	DEJA_DUP_TIMESTAMP_TYPE_BACKUP,
	DEJA_DUP_TIMESTAMP_TYPE_RESTORE
} DejaDupTimestampType;

struct _DejaDupOperationBackupOperationFinishedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	DejaDupOperationBackup* self;
	DejaDupToolJob* job;
	gboolean success;
	gboolean cancelled;
	gchar* detail;
	gboolean _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	DejaDupRecursiveDelete* _tmp3_;
	DejaDupRecursiveDelete* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	DejaDupOperationVerify* _tmp8_;
	DejaDupOperationVerify* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	DejaDupToolJob* _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_;
	const gchar* _tmp15_;
};

struct _DejaDupToolJob {
	GObject parent_instance;
	DejaDupToolJobPrivate * priv;
	GList* includes;
	GList* excludes;
	GList* _restore_files;
};

struct _DejaDupToolJobClass {
	GObjectClass parent_class;
	void (*start) (DejaDupToolJob* self);
	void (*cancel) (DejaDupToolJob* self);
	void (*stop) (DejaDupToolJob* self);
	void (*pause) (DejaDupToolJob* self, const gchar* reason);
	void (*resume) (DejaDupToolJob* self);
};


static gpointer deja_dup_operation_backup_parent_class = NULL;

GType deja_dup_operation_get_type (void) G_GNUC_CONST;
GType deja_dup_tool_job_get_type (void) G_GNUC_CONST;
GType deja_dup_operation_backup_get_type (void) G_GNUC_CONST;
#define DEJA_DUP_OPERATION_BACKUP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEJA_DUP_TYPE_OPERATION_BACKUP, DejaDupOperationBackupPrivate))
enum  {
	DEJA_DUP_OPERATION_BACKUP_DUMMY_PROPERTY
};
DejaDupOperationBackup* deja_dup_operation_backup_new (void);
DejaDupOperationBackup* deja_dup_operation_backup_construct (GType object_type);
GType deja_dup_tool_job_mode_get_type (void) G_GNUC_CONST;
static void deja_dup_operation_backup_real_operation_finished_data_free (gpointer _data);
static void deja_dup_operation_backup_real_operation_finished (DejaDupOperation* base, DejaDupToolJob* job, gboolean success, gboolean cancelled, const gchar* detail, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean deja_dup_operation_backup_real_operation_finished_co (DejaDupOperationBackupOperationFinishedData* _data_);
GType deja_dup_timestamp_type_get_type (void) G_GNUC_CONST;
void deja_dup_update_last_run_timestamp (DejaDupTimestampType type);
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);
GType deja_dup_recursive_op_get_type (void) G_GNUC_CONST;
GType deja_dup_recursive_delete_get_type (void) G_GNUC_CONST;
void deja_dup_recursive_op_start (DejaDupRecursiveOp* self);
void deja_dup_operation_chain_op (DejaDupOperation* self, DejaDupOperation* subop, const gchar* desc, const gchar* detail, GAsyncReadyCallback _callback_, gpointer _user_data_);
void deja_dup_operation_chain_op_finish (DejaDupOperation* self, GAsyncResult* _res_);
DejaDupOperationVerify* deja_dup_operation_verify_new (void);
DejaDupOperationVerify* deja_dup_operation_verify_construct (GType object_type);
GType deja_dup_operation_verify_get_type (void) G_GNUC_CONST;
static void deja_dup_operation_backup_operation_finished_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void deja_dup_operation_operation_finished (DejaDupOperation* self, DejaDupToolJob* job, gboolean success, gboolean cancelled, const gchar* detail, GAsyncReadyCallback _callback_, gpointer _user_data_);
void deja_dup_operation_operation_finished_finish (DejaDupOperation* self, GAsyncResult* _res_);
static void deja_dup_operation_backup_real_send_action_file_changed (DejaDupOperation* base, GFile* file, gboolean actual);
void deja_dup_operation_send_action_file_changed (DejaDupOperation* self, GFile* file, gboolean actual);
static GList* deja_dup_operation_backup_real_make_argv (DejaDupOperation* base);
GType deja_dup_filtered_settings_get_type (void) G_GNUC_CONST;
DejaDupFilteredSettings* deja_dup_get_settings (const gchar* subdir);
GFile** deja_dup_filtered_settings_get_file_list (DejaDupFilteredSettings* self, const gchar* k, int* result_length1);
#define DEJA_DUP_INCLUDE_LIST_KEY "include-list"
#define DEJA_DUP_EXCLUDE_LIST_KEY "exclude-list"
static GList* deja_dup_operation_backup_get_always_excluded_dirs (DejaDupOperationBackup* self);
static void deja_dup_operation_backup_fill_metadir (DejaDupOperationBackup* self, GError** error);
static void _g_free0_ (gpointer var);
static void _g_list_free__g_free0_ (GList* self);
void deja_dup_tool_job_set_local (DejaDupToolJob* self, GFile* value);
gchar** deja_dup_get_tempdirs (int* result_length1);
static void deja_dup_operation_backup_finalize (GObject* obj);
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);


DejaDupOperationBackup* deja_dup_operation_backup_construct (GType object_type) {
	DejaDupOperationBackup * self = NULL;
	self = (DejaDupOperationBackup*) g_object_new (object_type, "mode", DEJA_DUP_TOOL_JOB_MODE_BACKUP, NULL);
	return self;
}


DejaDupOperationBackup* deja_dup_operation_backup_new (void) {
	return deja_dup_operation_backup_construct (DEJA_DUP_TYPE_OPERATION_BACKUP);
}


static void deja_dup_operation_backup_real_operation_finished_data_free (gpointer _data) {
	DejaDupOperationBackupOperationFinishedData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->job);
	_g_free0 (_data_->detail);
	_g_object_unref0 (_data_->self);
	g_slice_free (DejaDupOperationBackupOperationFinishedData, _data_);
}


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


static void deja_dup_operation_backup_real_operation_finished (DejaDupOperation* base, DejaDupToolJob* job, gboolean success, gboolean cancelled, const gchar* detail, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	DejaDupOperationBackup * self;
	DejaDupOperationBackupOperationFinishedData* _data_;
	DejaDupOperationBackup* _tmp0_ = NULL;
	DejaDupToolJob* _tmp1_ = NULL;
	DejaDupToolJob* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	self = (DejaDupOperationBackup*) base;
	_data_ = g_slice_new0 (DejaDupOperationBackupOperationFinishedData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, deja_dup_operation_backup_real_operation_finished);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, deja_dup_operation_backup_real_operation_finished_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = job;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (_data_->job);
	_data_->job = _tmp2_;
	_tmp3_ = success;
	_data_->success = _tmp3_;
	_tmp4_ = cancelled;
	_data_->cancelled = _tmp4_;
	_tmp5_ = detail;
	_tmp6_ = g_strdup (_tmp5_);
	_g_free0 (_data_->detail);
	_data_->detail = _tmp6_;
	deja_dup_operation_backup_real_operation_finished_co (_data_);
}


static void deja_dup_operation_backup_real_operation_finished_finish (DejaDupOperation* base, GAsyncResult* _res_) {
	DejaDupOperationBackupOperationFinishedData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void deja_dup_operation_backup_operation_finished_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	DejaDupOperationBackupOperationFinishedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	deja_dup_operation_backup_real_operation_finished_co (_data_);
}


static gboolean deja_dup_operation_backup_real_operation_finished_co (DejaDupOperationBackupOperationFinishedData* _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_ = FALSE;
	_data_->_tmp0_ = _data_->success;
	if (_data_->_tmp0_) {
		deja_dup_update_last_run_timestamp (DEJA_DUP_TIMESTAMP_TYPE_BACKUP);
	}
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = _data_->self->priv->metadir;
	if (_data_->_tmp1_ != NULL) {
		_data_->_tmp2_ = NULL;
		_data_->_tmp2_ = _data_->self->priv->metadir;
		_data_->_tmp3_ = NULL;
		_data_->_tmp3_ = deja_dup_recursive_delete_new (_data_->_tmp2_, NULL);
		_data_->_tmp4_ = NULL;
		_data_->_tmp4_ = _data_->_tmp3_;
		deja_dup_recursive_op_start ((DejaDupRecursiveOp*) _data_->_tmp4_);
		_g_object_unref0 (_data_->_tmp4_);
	}
	_data_->_tmp6_ = FALSE;
	_data_->_tmp6_ = _data_->success;
	if (_data_->_tmp6_) {
		_data_->_tmp7_ = FALSE;
		_data_->_tmp7_ = _data_->cancelled;
		_data_->_tmp5_ = !_data_->_tmp7_;
	} else {
		_data_->_tmp5_ = FALSE;
	}
	if (_data_->_tmp5_) {
		_data_->_tmp8_ = NULL;
		_data_->_tmp8_ = deja_dup_operation_verify_new ();
		_data_->_tmp9_ = NULL;
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = NULL;
		_data_->_tmp10_ = _ ("Verifying backup…");
		_data_->_tmp11_ = NULL;
		_data_->_tmp11_ = _data_->detail;
		_data_->_state_ = 1;
		deja_dup_operation_chain_op ((DejaDupOperation*) _data_->self, (DejaDupOperation*) _data_->_tmp9_, _data_->_tmp10_, _data_->_tmp11_, deja_dup_operation_backup_operation_finished_ready, _data_);
		return FALSE;
		_state_1:
		deja_dup_operation_chain_op_finish ((DejaDupOperation*) _data_->self, _data_->_res_);
		_g_object_unref0 (_data_->_tmp9_);
	} else {
		_data_->_tmp12_ = NULL;
		_data_->_tmp12_ = _data_->job;
		_data_->_tmp13_ = FALSE;
		_data_->_tmp13_ = _data_->success;
		_data_->_tmp14_ = FALSE;
		_data_->_tmp14_ = _data_->cancelled;
		_data_->_tmp15_ = NULL;
		_data_->_tmp15_ = _data_->detail;
		_data_->_state_ = 2;
		DEJA_DUP_OPERATION_CLASS (deja_dup_operation_backup_parent_class)->operation_finished (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation), _data_->_tmp12_, _data_->_tmp13_, _data_->_tmp14_, _data_->_tmp15_, deja_dup_operation_backup_operation_finished_ready, _data_);
		return FALSE;
		_state_2:
		DEJA_DUP_OPERATION_CLASS (deja_dup_operation_backup_parent_class)->operation_finished_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation), _data_->_res_);
	}
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void deja_dup_operation_backup_real_send_action_file_changed (DejaDupOperation* base, GFile* file, gboolean actual) {
	DejaDupOperationBackup * self;
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	self = (DejaDupOperationBackup*) base;
	g_return_if_fail (file != NULL);
	_tmp0_ = file;
	_tmp1_ = self->priv->metadir;
	_tmp2_ = g_file_has_prefix (_tmp0_, _tmp1_);
	if (!_tmp2_) {
		GFile* _tmp3_ = NULL;
		gboolean _tmp4_ = FALSE;
		_tmp3_ = file;
		_tmp4_ = actual;
		DEJA_DUP_OPERATION_CLASS (deja_dup_operation_backup_parent_class)->send_action_file_changed (G_TYPE_CHECK_INSTANCE_CAST (self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation), _tmp3_, _tmp4_);
	}
}


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


static void _g_list_free__g_free0_ (GList* self) {
	g_list_foreach (self, (GFunc) _g_free0_, NULL);
	g_list_free (self);
}


static GList* deja_dup_operation_backup_real_make_argv (DejaDupOperation* base) {
	DejaDupOperationBackup * self;
	GList* result = NULL;
	DejaDupFilteredSettings* settings = NULL;
	DejaDupFilteredSettings* _tmp0_ = NULL;
	GFile** include_list = NULL;
	DejaDupFilteredSettings* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	GFile** _tmp3_ = NULL;
	gint include_list_length1 = 0;
	gint _include_list_size_ = 0;
	GFile** exclude_list = NULL;
	DejaDupFilteredSettings* _tmp4_ = NULL;
	gint _tmp5_ = 0;
	GFile** _tmp6_ = NULL;
	gint exclude_list_length1 = 0;
	gint _exclude_list_size_ = 0;
	GList* always_excluded = NULL;
	GList* _tmp7_ = NULL;
	GList* _tmp8_ = NULL;
	GFile** _tmp13_ = NULL;
	gint _tmp13__length1 = 0;
	GFile** _tmp18_ = NULL;
	gint _tmp18__length1 = 0;
	gchar* cachedir = NULL;
	const gchar* _tmp23_ = NULL;
	gchar* _tmp24_ = NULL;
	DejaDupToolJob* _tmp33_ = NULL;
	GFile* _tmp34_ = NULL;
	GFile* _tmp35_ = NULL;
	GError * _inner_error_ = NULL;
	self = (DejaDupOperationBackup*) base;
	_tmp0_ = deja_dup_get_settings (NULL);
	settings = _tmp0_;
	_tmp1_ = settings;
	_tmp3_ = deja_dup_filtered_settings_get_file_list (_tmp1_, DEJA_DUP_INCLUDE_LIST_KEY, &_tmp2_);
	include_list = _tmp3_;
	include_list_length1 = _tmp2_;
	_include_list_size_ = include_list_length1;
	_tmp4_ = settings;
	_tmp6_ = deja_dup_filtered_settings_get_file_list (_tmp4_, DEJA_DUP_EXCLUDE_LIST_KEY, &_tmp5_);
	exclude_list = _tmp6_;
	exclude_list_length1 = _tmp5_;
	_exclude_list_size_ = exclude_list_length1;
	_tmp7_ = deja_dup_operation_backup_get_always_excluded_dirs (self);
	always_excluded = _tmp7_;
	_tmp8_ = always_excluded;
	{
		GList* dir_collection = NULL;
		GList* dir_it = NULL;
		dir_collection = _tmp8_;
		for (dir_it = dir_collection; dir_it != NULL; dir_it = dir_it->next) {
			gchar* _tmp9_ = NULL;
			gchar* dir = NULL;
			_tmp9_ = g_strdup ((const gchar*) dir_it->data);
			dir = _tmp9_;
			{
				DejaDupToolJob* _tmp10_ = NULL;
				const gchar* _tmp11_ = NULL;
				GFile* _tmp12_ = NULL;
				_tmp10_ = ((DejaDupOperation*) self)->job;
				_tmp11_ = dir;
				_tmp12_ = g_file_new_for_path (_tmp11_);
				_tmp10_->excludes = g_list_prepend (_tmp10_->excludes, _tmp12_);
				_g_free0 (dir);
			}
		}
	}
	_tmp13_ = exclude_list;
	_tmp13__length1 = exclude_list_length1;
	{
		GFile** s_collection = NULL;
		gint s_collection_length1 = 0;
		gint _s_collection_size_ = 0;
		gint s_it = 0;
		s_collection = _tmp13_;
		s_collection_length1 = _tmp13__length1;
		for (s_it = 0; s_it < _tmp13__length1; s_it = s_it + 1) {
			GFile* _tmp14_ = NULL;
			GFile* s = NULL;
			_tmp14_ = _g_object_ref0 (s_collection[s_it]);
			s = _tmp14_;
			{
				DejaDupToolJob* _tmp15_ = NULL;
				GFile* _tmp16_ = NULL;
				GFile* _tmp17_ = NULL;
				_tmp15_ = ((DejaDupOperation*) self)->job;
				_tmp16_ = s;
				_tmp17_ = _g_object_ref0 (_tmp16_);
				_tmp15_->excludes = g_list_prepend (_tmp15_->excludes, _tmp17_);
				_g_object_unref0 (s);
			}
		}
	}
	_tmp18_ = include_list;
	_tmp18__length1 = include_list_length1;
	{
		GFile** s_collection = NULL;
		gint s_collection_length1 = 0;
		gint _s_collection_size_ = 0;
		gint s_it = 0;
		s_collection = _tmp18_;
		s_collection_length1 = _tmp18__length1;
		for (s_it = 0; s_it < _tmp18__length1; s_it = s_it + 1) {
			GFile* _tmp19_ = NULL;
			GFile* s = NULL;
			_tmp19_ = _g_object_ref0 (s_collection[s_it]);
			s = _tmp19_;
			{
				DejaDupToolJob* _tmp20_ = NULL;
				GFile* _tmp21_ = NULL;
				GFile* _tmp22_ = NULL;
				_tmp20_ = ((DejaDupOperation*) self)->job;
				_tmp21_ = s;
				_tmp22_ = _g_object_ref0 (_tmp21_);
				_tmp20_->includes = g_list_prepend (_tmp20_->includes, _tmp22_);
				_g_object_unref0 (s);
			}
		}
	}
	_tmp23_ = g_get_user_cache_dir ();
	_tmp24_ = g_strdup (_tmp23_);
	cachedir = _tmp24_;
	{
		gchar* _tmp25_ = NULL;
		gchar* _tmp26_ = NULL;
		GFile* _tmp27_ = NULL;
		DejaDupToolJob* _tmp28_ = NULL;
		GFile* _tmp29_ = NULL;
		GFile* _tmp30_ = NULL;
		_tmp25_ = g_build_filename (cachedir, PACKAGE, "metadata", NULL);
		_tmp26_ = _tmp25_;
		_tmp27_ = g_file_new_for_path (_tmp26_);
		_g_object_unref0 (self->priv->metadir);
		self->priv->metadir = _tmp27_;
		_g_free0 (_tmp26_);
		deja_dup_operation_backup_fill_metadir (self, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch37_g_error;
		}
		_tmp28_ = ((DejaDupOperation*) self)->job;
		_tmp29_ = self->priv->metadir;
		_tmp30_ = _g_object_ref0 (_tmp29_);
		_tmp28_->includes = g_list_prepend (_tmp28_->includes, _tmp30_);
	}
	goto __finally37;
	__catch37_g_error:
	{
		GError* e = NULL;
		GError* _tmp31_ = NULL;
		const gchar* _tmp32_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp31_ = e;
		_tmp32_ = _tmp31_->message;
		g_warning ("OperationBackup.vala:79: %s\n", _tmp32_);
		_g_error_free0 (e);
	}
	__finally37:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_free0 (cachedir);
		__g_list_free__g_free0_0 (always_excluded);
		exclude_list = (_vala_array_free (exclude_list, exclude_list_length1, (GDestroyNotify) g_object_unref), NULL);
		include_list = (_vala_array_free (include_list, include_list_length1, (GDestroyNotify) g_object_unref), NULL);
		_g_object_unref0 (settings);
		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;
	}
	_tmp33_ = ((DejaDupOperation*) self)->job;
	_tmp34_ = g_file_new_for_path ("/");
	_tmp35_ = _tmp34_;
	deja_dup_tool_job_set_local (_tmp33_, _tmp35_);
	_g_object_unref0 (_tmp35_);
	result = NULL;
	_g_free0 (cachedir);
	__g_list_free__g_free0_0 (always_excluded);
	exclude_list = (_vala_array_free (exclude_list, exclude_list_length1, (GDestroyNotify) g_object_unref), NULL);
	include_list = (_vala_array_free (include_list, include_list_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (settings);
	return result;
}


static GList* deja_dup_operation_backup_get_always_excluded_dirs (DejaDupOperationBackup* self) {
	GList* result = NULL;
	GList* rv = NULL;
	gchar* dir = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	gint _tmp26_ = 0;
	gchar** _tmp27_ = NULL;
	gchar* _tmp31_ = NULL;
	gchar* _tmp32_ = NULL;
	gchar* _tmp33_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	rv = NULL;
	_tmp0_ = g_get_user_cache_dir ();
	_tmp1_ = g_strdup (_tmp0_);
	dir = _tmp1_;
	_tmp2_ = dir;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		const gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		_tmp3_ = dir;
		_tmp4_ = g_strdup (_tmp3_);
		rv = g_list_append (rv, _tmp4_);
		_tmp5_ = dir;
		_tmp6_ = g_build_filename (_tmp5_, PACKAGE, NULL);
		rv = g_list_append (rv, _tmp6_);
	}
	_tmp7_ = g_get_home_dir ();
	_tmp8_ = g_strdup (_tmp7_);
	_g_free0 (dir);
	dir = _tmp8_;
	_tmp9_ = dir;
	if (_tmp9_ != NULL) {
		const gchar* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		const gchar* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		gchar* _tmp15_ = NULL;
		const gchar* _tmp16_ = NULL;
		gchar* _tmp17_ = NULL;
		const gchar* _tmp18_ = NULL;
		gchar* _tmp19_ = NULL;
		const gchar* _tmp20_ = NULL;
		gchar* _tmp21_ = NULL;
		const gchar* _tmp22_ = NULL;
		gchar* _tmp23_ = NULL;
		const gchar* _tmp24_ = NULL;
		gchar* _tmp25_ = NULL;
		_tmp10_ = dir;
		_tmp11_ = g_build_filename (_tmp10_, ".adobe/Flash_Player/AssetCache", NULL);
		rv = g_list_append (rv, _tmp11_);
		_tmp12_ = dir;
		_tmp13_ = g_build_filename (_tmp12_, ".gvfs", NULL);
		rv = g_list_append (rv, _tmp13_);
		_tmp14_ = dir;
		_tmp15_ = g_build_filename (_tmp14_, ".Private", NULL);
		rv = g_list_append (rv, _tmp15_);
		_tmp16_ = dir;
		_tmp17_ = g_build_filename (_tmp16_, ".recent-applications.xbel", NULL);
		rv = g_list_append (rv, _tmp17_);
		_tmp18_ = dir;
		_tmp19_ = g_build_filename (_tmp18_, ".recently-used.xbel", NULL);
		rv = g_list_append (rv, _tmp19_);
		_tmp20_ = dir;
		_tmp21_ = g_build_filename (_tmp20_, ".steam/root", NULL);
		rv = g_list_append (rv, _tmp21_);
		_tmp22_ = dir;
		_tmp23_ = g_build_filename (_tmp22_, ".thumbnails", NULL);
		rv = g_list_append (rv, _tmp23_);
		_tmp24_ = dir;
		_tmp25_ = g_build_filename (_tmp24_, ".xsession-errors", NULL);
		rv = g_list_append (rv, _tmp25_);
	}
	_tmp27_ = deja_dup_get_tempdirs (&_tmp26_);
	{
		gchar** tempdir_collection = NULL;
		gint tempdir_collection_length1 = 0;
		gint _tempdir_collection_size_ = 0;
		gint tempdir_it = 0;
		tempdir_collection = _tmp27_;
		tempdir_collection_length1 = _tmp26_;
		for (tempdir_it = 0; tempdir_it < _tmp26_; tempdir_it = tempdir_it + 1) {
			gchar* _tmp28_ = NULL;
			gchar* tempdir = NULL;
			_tmp28_ = g_strdup (tempdir_collection[tempdir_it]);
			tempdir = _tmp28_;
			{
				const gchar* _tmp29_ = NULL;
				gchar* _tmp30_ = NULL;
				_tmp29_ = tempdir;
				_tmp30_ = g_strdup (_tmp29_);
				rv = g_list_append (rv, _tmp30_);
				_g_free0 (tempdir);
			}
		}
		tempdir_collection = (_vala_array_free (tempdir_collection, tempdir_collection_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp31_ = g_strdup ("/proc");
	rv = g_list_append (rv, _tmp31_);
	_tmp32_ = g_strdup ("/run");
	rv = g_list_append (rv, _tmp32_);
	_tmp33_ = g_strdup ("/sys");
	rv = g_list_append (rv, _tmp33_);
	result = rv;
	_g_free0 (dir);
	return result;
}


static void deja_dup_operation_backup_fill_metadir (DejaDupOperationBackup* self, GError** error) {
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	DejaDupRecursiveDelete* _tmp2_ = NULL;
	DejaDupRecursiveDelete* _tmp3_ = NULL;
	GFile* _tmp4_ = NULL;
	GDateTime* now = NULL;
	GDateTime* _tmp5_ = NULL;
	gchar* msg = NULL;
	GDateTime* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	gchar* _tmp10_ = NULL;
	GFile* _tmp11_ = NULL;
	gchar* _tmp12_ = NULL;
	gchar* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	gchar* _tmp15_ = NULL;
	const gchar* _tmp16_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->metadir;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->metadir;
	_tmp2_ = deja_dup_recursive_delete_new (_tmp1_, NULL);
	_tmp3_ = _tmp2_;
	deja_dup_recursive_op_start ((DejaDupRecursiveOp*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = self->priv->metadir;
	g_file_make_directory_with_parents (_tmp4_, NULL, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		return;
	}
	_tmp5_ = g_date_time_new_now_utc ();
	now = _tmp5_;
	_tmp6_ = now;
	_tmp7_ = g_date_time_format (_tmp6_, "%s");
	_tmp8_ = _tmp7_;
	_tmp9_ = g_strdup_printf ("This folder can be safely deleted.\n%s", _tmp8_);
	_tmp10_ = _tmp9_;
	_g_free0 (_tmp8_);
	msg = _tmp10_;
	_tmp11_ = self->priv->metadir;
	_tmp12_ = g_file_get_path (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_build_filename (_tmp13_, "README", NULL);
	_tmp15_ = _tmp14_;
	_tmp16_ = msg;
	g_file_set_contents (_tmp15_, _tmp16_, (gssize) -1, &_inner_error_);
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (msg);
		_g_date_time_unref0 (now);
		return;
	}
	_g_free0 (msg);
	_g_date_time_unref0 (now);
}


static void deja_dup_operation_backup_class_init (DejaDupOperationBackupClass * klass) {
	deja_dup_operation_backup_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DejaDupOperationBackupPrivate));
	((DejaDupOperationClass *) klass)->operation_finished = deja_dup_operation_backup_real_operation_finished;
	((DejaDupOperationClass *) klass)->operation_finished_finish = deja_dup_operation_backup_real_operation_finished_finish;
	((DejaDupOperationClass *) klass)->send_action_file_changed = deja_dup_operation_backup_real_send_action_file_changed;
	((DejaDupOperationClass *) klass)->make_argv = deja_dup_operation_backup_real_make_argv;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_operation_backup_finalize;
}


static void deja_dup_operation_backup_instance_init (DejaDupOperationBackup * self) {
	self->priv = DEJA_DUP_OPERATION_BACKUP_GET_PRIVATE (self);
}


static void deja_dup_operation_backup_finalize (GObject* obj) {
	DejaDupOperationBackup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_OPERATION_BACKUP, DejaDupOperationBackup);
	_g_object_unref0 (self->priv->metadir);
	G_OBJECT_CLASS (deja_dup_operation_backup_parent_class)->finalize (obj);
}


GType deja_dup_operation_backup_get_type (void) {
	static volatile gsize deja_dup_operation_backup_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_operation_backup_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupOperationBackupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_operation_backup_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupOperationBackup), 0, (GInstanceInitFunc) deja_dup_operation_backup_instance_init, NULL };
		GType deja_dup_operation_backup_type_id;
		deja_dup_operation_backup_type_id = g_type_register_static (DEJA_DUP_TYPE_OPERATION, "DejaDupOperationBackup", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_operation_backup_type_id__volatile, deja_dup_operation_backup_type_id);
	}
	return deja_dup_operation_backup_type_id__volatile;
}


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



