/* OperationFiles.c generated by valac 0.30.0, the Vala compiler
 * generated from OperationFiles.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 <time.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_FILES (deja_dup_operation_files_get_type ())
#define DEJA_DUP_OPERATION_FILES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_OPERATION_FILES, DejaDupOperationFiles))
#define DEJA_DUP_OPERATION_FILES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_OPERATION_FILES, DejaDupOperationFilesClass))
#define DEJA_DUP_IS_OPERATION_FILES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_OPERATION_FILES))
#define DEJA_DUP_IS_OPERATION_FILES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_OPERATION_FILES))
#define DEJA_DUP_OPERATION_FILES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_OPERATION_FILES, DejaDupOperationFilesClass))

typedef struct _DejaDupOperationFiles DejaDupOperationFiles;
typedef struct _DejaDupOperationFilesClass DejaDupOperationFilesClass;
typedef struct _DejaDupOperationFilesPrivate DejaDupOperationFilesPrivate;
#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))

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 _DejaDupOperationFiles {
	DejaDupOperation parent_instance;
	DejaDupOperationFilesPrivate * priv;
};

struct _DejaDupOperationFilesClass {
	DejaDupOperationClass parent_class;
};

struct _DejaDupOperationFilesPrivate {
	struct tm _time;
	GFile* _source;
};

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;


static gpointer deja_dup_operation_files_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_files_get_type (void) G_GNUC_CONST;
#define DEJA_DUP_OPERATION_FILES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEJA_DUP_TYPE_OPERATION_FILES, DejaDupOperationFilesPrivate))
enum  {
	DEJA_DUP_OPERATION_FILES_DUMMY_PROPERTY,
	DEJA_DUP_OPERATION_FILES_SOURCE
};
DejaDupOperationFiles* deja_dup_operation_files_new (struct tm* time_in, GFile* source);
DejaDupOperationFiles* deja_dup_operation_files_construct (GType object_type, struct tm* time_in, GFile* source);
GType deja_dup_tool_job_mode_get_type (void) G_GNUC_CONST;
void deja_dup_operation_files_set_time (DejaDupOperationFiles* self, struct tm* value);
static void deja_dup_operation_files_real_connect_to_job (DejaDupOperation* base);
static void __lambda27_ (DejaDupOperationFiles* self, DejaDupToolJob* d, const gchar* date, const gchar* file);
static void ___lambda27__deja_dup_tool_job_listed_current_files (DejaDupToolJob* _sender, const gchar* date, const gchar* file, gpointer self);
void deja_dup_operation_connect_to_job (DejaDupOperation* self);
static GList* deja_dup_operation_files_real_make_argv (DejaDupOperation* base);
void deja_dup_operation_files_get_time (DejaDupOperationFiles* self, struct tm* result);
void deja_dup_tool_job_set_time (DejaDupToolJob* self, const gchar* value);
GFile* deja_dup_operation_files_get_source (DejaDupOperationFiles* self);
void deja_dup_tool_job_set_local (DejaDupToolJob* self, GFile* value);
static void deja_dup_operation_files_set_source (DejaDupOperationFiles* self, GFile* value);
static void g_cclosure_user_marshal_VOID__STRING_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static void deja_dup_operation_files_finalize (GObject* obj);
static void _vala_deja_dup_operation_files_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_deja_dup_operation_files_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


DejaDupOperationFiles* deja_dup_operation_files_construct (GType object_type, struct tm* time_in, GFile* source) {
	DejaDupOperationFiles * self = NULL;
	GFile* _tmp0_ = NULL;
	struct tm* _tmp1_ = NULL;
	g_return_val_if_fail (source != NULL, NULL);
	_tmp0_ = source;
	self = (DejaDupOperationFiles*) g_object_new (object_type, "mode", DEJA_DUP_TOOL_JOB_MODE_LIST, "source", _tmp0_, NULL);
	_tmp1_ = time_in;
	if (_tmp1_ != NULL) {
		struct tm* _tmp2_ = NULL;
		_tmp2_ = time_in;
		deja_dup_operation_files_set_time (self, _tmp2_);
	}
	return self;
}


DejaDupOperationFiles* deja_dup_operation_files_new (struct tm* time_in, GFile* source) {
	return deja_dup_operation_files_construct (DEJA_DUP_TYPE_OPERATION_FILES, time_in, source);
}


static void __lambda27_ (DejaDupOperationFiles* self, DejaDupToolJob* d, const gchar* date, const gchar* file) {
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (d != NULL);
	g_return_if_fail (date != NULL);
	g_return_if_fail (file != NULL);
	_tmp0_ = date;
	_tmp1_ = file;
	g_signal_emit_by_name (self, "listed-current-files", _tmp0_, _tmp1_);
}


static void ___lambda27__deja_dup_tool_job_listed_current_files (DejaDupToolJob* _sender, const gchar* date, const gchar* file, gpointer self) {
	__lambda27_ ((DejaDupOperationFiles*) self, _sender, date, file);
}


static void deja_dup_operation_files_real_connect_to_job (DejaDupOperation* base) {
	DejaDupOperationFiles * self;
	DejaDupToolJob* _tmp0_ = NULL;
	self = (DejaDupOperationFiles*) base;
	_tmp0_ = ((DejaDupOperation*) self)->job;
	g_signal_connect_object (_tmp0_, "listed-current-files", (GCallback) ___lambda27__deja_dup_tool_job_listed_current_files, self, 0);
	DEJA_DUP_OPERATION_CLASS (deja_dup_operation_files_parent_class)->connect_to_job (G_TYPE_CHECK_INSTANCE_CAST (self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation));
}


static gchar* g_time_format (struct tm *self, const gchar* format) {
	gchar* result = NULL;
	gchar* buffer = NULL;
	gchar* _tmp0_ = NULL;
	gint buffer_length1 = 0;
	gint _buffer_size_ = 0;
	gchar* _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	gchar* _tmp4_ = NULL;
	g_return_val_if_fail (format != NULL, NULL);
	_tmp0_ = g_new0 (gchar, 64);
	buffer = _tmp0_;
	buffer_length1 = 64;
	_buffer_size_ = buffer_length1;
	_tmp1_ = buffer;
	_tmp1__length1 = buffer_length1;
	_tmp2_ = format;
	strftime (_tmp1_, _tmp1__length1, _tmp2_, &(*self));
	_tmp3_ = buffer;
	_tmp3__length1 = buffer_length1;
	_tmp4_ = g_strdup ((const gchar*) _tmp3_);
	result = _tmp4_;
	buffer = (g_free (buffer), NULL);
	return result;
}


static GList* deja_dup_operation_files_real_make_argv (DejaDupOperation* base) {
	DejaDupOperationFiles * self;
	GList* result = NULL;
	struct tm _tmp0_ = {0};
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gboolean _tmp3_ = FALSE;
	DejaDupToolJob* _tmp9_ = NULL;
	GFile* _tmp10_ = NULL;
	self = (DejaDupOperationFiles*) base;
	_tmp0_ = self->priv->_time;
	_tmp1_ = g_time_format (&_tmp0_, "%s");
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strcmp0 (_tmp2_, "-1") != 0;
	_g_free0 (_tmp2_);
	if (_tmp3_) {
		DejaDupToolJob* _tmp4_ = NULL;
		struct tm _tmp5_ = {0};
		gchar* _tmp6_ = NULL;
		gchar* _tmp7_ = NULL;
		_tmp4_ = ((DejaDupOperation*) self)->job;
		_tmp5_ = self->priv->_time;
		_tmp6_ = g_time_format (&_tmp5_, "%s");
		_tmp7_ = _tmp6_;
		deja_dup_tool_job_set_time (_tmp4_, _tmp7_);
		_g_free0 (_tmp7_);
	} else {
		DejaDupToolJob* _tmp8_ = NULL;
		_tmp8_ = ((DejaDupOperation*) self)->job;
		deja_dup_tool_job_set_time (_tmp8_, NULL);
	}
	_tmp9_ = ((DejaDupOperation*) self)->job;
	_tmp10_ = self->priv->_source;
	deja_dup_tool_job_set_local (_tmp9_, _tmp10_);
	result = NULL;
	return result;
}


void deja_dup_operation_files_get_time (DejaDupOperationFiles* self, struct tm* result) {
	struct tm _tmp0_ = {0};
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_time;
	*result = _tmp0_;
	return;
}


void deja_dup_operation_files_set_time (DejaDupOperationFiles* self, struct tm* value) {
	struct tm _tmp0_ = {0};
	g_return_if_fail (self != NULL);
	_tmp0_ = *value;
	self->priv->_time = _tmp0_;
}


GFile* deja_dup_operation_files_get_source (DejaDupOperationFiles* self) {
	GFile* result;
	GFile* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_source;
	result = _tmp0_;
	return result;
}


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


static void deja_dup_operation_files_set_source (DejaDupOperationFiles* self, GFile* value) {
	GFile* _tmp0_ = NULL;
	GFile* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_source);
	self->priv->_source = _tmp1_;
	g_object_notify ((GObject *) self, "source");
}


static void g_cclosure_user_marshal_VOID__STRING_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1, const char* arg_1, const char* arg_2, gpointer data2);
	register GMarshalFunc_VOID__STRING_STRING 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__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_string (param_values + 1), g_value_get_string (param_values + 2), data2);
}


static void deja_dup_operation_files_class_init (DejaDupOperationFilesClass * klass) {
	deja_dup_operation_files_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (DejaDupOperationFilesPrivate));
	((DejaDupOperationClass *) klass)->connect_to_job = deja_dup_operation_files_real_connect_to_job;
	((DejaDupOperationClass *) klass)->make_argv = deja_dup_operation_files_real_make_argv;
	G_OBJECT_CLASS (klass)->get_property = _vala_deja_dup_operation_files_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_deja_dup_operation_files_set_property;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_operation_files_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_OPERATION_FILES_SOURCE, g_param_spec_object ("source", "source", "source", G_TYPE_FILE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_signal_new ("listed_current_files", DEJA_DUP_TYPE_OPERATION_FILES, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
}


static void deja_dup_operation_files_instance_init (DejaDupOperationFiles * self) {
	self->priv = DEJA_DUP_OPERATION_FILES_GET_PRIVATE (self);
}


static void deja_dup_operation_files_finalize (GObject* obj) {
	DejaDupOperationFiles * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_OPERATION_FILES, DejaDupOperationFiles);
	_g_object_unref0 (self->priv->_source);
	G_OBJECT_CLASS (deja_dup_operation_files_parent_class)->finalize (obj);
}


GType deja_dup_operation_files_get_type (void) {
	static volatile gsize deja_dup_operation_files_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_operation_files_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupOperationFilesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_operation_files_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupOperationFiles), 0, (GInstanceInitFunc) deja_dup_operation_files_instance_init, NULL };
		GType deja_dup_operation_files_type_id;
		deja_dup_operation_files_type_id = g_type_register_static (DEJA_DUP_TYPE_OPERATION, "DejaDupOperationFiles", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_operation_files_type_id__volatile, deja_dup_operation_files_type_id);
	}
	return deja_dup_operation_files_type_id__volatile;
}


static void _vala_deja_dup_operation_files_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	DejaDupOperationFiles * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_OPERATION_FILES, DejaDupOperationFiles);
	switch (property_id) {
		case DEJA_DUP_OPERATION_FILES_SOURCE:
		g_value_set_object (value, deja_dup_operation_files_get_source (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_deja_dup_operation_files_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	DejaDupOperationFiles * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_OPERATION_FILES, DejaDupOperationFiles);
	switch (property_id) {
		case DEJA_DUP_OPERATION_FILES_SOURCE:
		deja_dup_operation_files_set_source (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



