/* OperationFiles.c generated by valac 0.12.1, 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_DUPLICITY (deja_dup_duplicity_get_type ())
#define DEJA_DUP_DUPLICITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_DUPLICITY, DejaDupDuplicity))
#define DEJA_DUP_DUPLICITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_DUPLICITY, DejaDupDuplicityClass))
#define DEJA_DUP_IS_DUPLICITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_DUPLICITY))
#define DEJA_DUP_IS_DUPLICITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_DUPLICITY))
#define DEJA_DUP_DUPLICITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_DUPLICITY, DejaDupDuplicityClass))

typedef struct _DejaDupDuplicity DejaDupDuplicity;
typedef struct _DejaDupDuplicityClass DejaDupDuplicityClass;

#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_OPERATION_TYPE_MODE (deja_dup_operation_mode_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))
#define __g_list_free__g_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_free0_ (var), NULL)))

struct _DejaDupOperation {
	GObject parent_instance;
	DejaDupOperationPrivate * priv;
	DejaDupDuplicity* dup;
	gchar* passphrase;
};

struct _DejaDupOperationClass {
	GObjectClass parent_class;
	void (*start) (DejaDupOperation* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*start_finish) (DejaDupOperation* self, GAsyncResult* _res_);
	void (*connect_to_dup) (DejaDupOperation* self);
	void (*operation_finished) (DejaDupOperation* self, DejaDupDuplicity* dup, gboolean success, gboolean cancelled, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*operation_finished_finish) (DejaDupOperation* self, GAsyncResult* _res_);
	GList* (*make_argv) (DejaDupOperation* self, GError** error);
};

struct _DejaDupOperationFiles {
	DejaDupOperation parent_instance;
	DejaDupOperationFilesPrivate * priv;
};

struct _DejaDupOperationFilesClass {
	DejaDupOperationClass parent_class;
};

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

typedef enum  {
	DEJA_DUP_OPERATION_MODE_INVALID,
	DEJA_DUP_OPERATION_MODE_BACKUP,
	DEJA_DUP_OPERATION_MODE_RESTORE,
	DEJA_DUP_OPERATION_MODE_STATUS,
	DEJA_DUP_OPERATION_MODE_LIST,
	DEJA_DUP_OPERATION_MODE_FILEHISTORY
} DejaDupOperationMode;


static gpointer deja_dup_operation_files_parent_class = NULL;

GType deja_dup_operation_get_type (void) G_GNUC_CONST;
GType deja_dup_duplicity_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 (guint xid, struct tm* time_in, GFile* source);
DejaDupOperationFiles* deja_dup_operation_files_construct (GType object_type, guint xid, struct tm* time_in, GFile* source);
GType deja_dup_operation_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_dup (DejaDupOperation* base);
static void _lambda27_ (DejaDupDuplicity* d, const gchar* date, const gchar* file, DejaDupOperationFiles* self);
static void __lambda27__deja_dup_duplicity_listed_current_files (DejaDupDuplicity* _sender, const gchar* date, const gchar* file, gpointer self);
void deja_dup_operation_connect_to_dup (DejaDupOperation* self);
static GList* deja_dup_operation_files_real_make_argv (DejaDupOperation* base, GError** error);
void deja_dup_operation_files_get_time (DejaDupOperationFiles* self, struct tm* result);
GFile* deja_dup_operation_files_get_source (DejaDupOperationFiles* self);
void deja_dup_duplicity_set_local (DejaDupDuplicity* self, GFile* value);
static void _g_free0_ (gpointer var);
static void _g_list_free__g_free0_ (GList* self);
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, guint xid, struct tm* time_in, GFile* source) {
	DejaDupOperationFiles * self = NULL;
	g_return_val_if_fail (source != NULL, NULL);
	self = (DejaDupOperationFiles*) g_object_new (object_type, "xid", xid, "mode", DEJA_DUP_OPERATION_MODE_LIST, "source", source, NULL);
	if (time_in != NULL) {
		deja_dup_operation_files_set_time (self, time_in);
	}
	return self;
}


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


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


static void __lambda27__deja_dup_duplicity_listed_current_files (DejaDupDuplicity* _sender, const gchar* date, const gchar* file, gpointer self) {
	_lambda27_ (_sender, date, file, self);
}


static void deja_dup_operation_files_real_connect_to_dup (DejaDupOperation* base) {
	DejaDupOperationFiles * self;
	self = (DejaDupOperationFiles*) base;
	g_signal_connect_object (((DejaDupOperation*) self)->dup, "listed-current-files", (GCallback) __lambda27__deja_dup_duplicity_listed_current_files, self, 0);
	DEJA_DUP_OPERATION_CLASS (deja_dup_operation_files_parent_class)->connect_to_dup (DEJA_DUP_OPERATION (self));
}


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


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_files_real_make_argv (DejaDupOperation* base, GError** error) {
	DejaDupOperationFiles * self;
	GList* result = NULL;
	GList* argv;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gboolean _tmp2_;
	self = (DejaDupOperationFiles*) base;
	argv = NULL;
	_tmp0_ = g_time_format (&self->priv->_time, "%s");
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strcmp0 (_tmp1_, "-1") != 0;
	_g_free0 (_tmp1_);
	if (_tmp2_) {
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_;
		gchar* _tmp5_ = NULL;
		_tmp3_ = g_time_format (&self->priv->_time, "%s");
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strdup_printf ("--time=%s", _tmp4_);
		argv = g_list_append (argv, _tmp5_);
		_g_free0 (_tmp4_);
	}
	deja_dup_duplicity_set_local (((DejaDupOperation*) self)->dup, self->priv->_source);
	result = argv;
	return result;
}


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


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


GFile* deja_dup_operation_files_get_source (DejaDupOperationFiles* self) {
	GFile* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_source;
	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_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_source);
	self->priv->_source = _tmp0_;
	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, 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));
	DEJA_DUP_OPERATION_CLASS (klass)->connect_to_dup = deja_dup_operation_files_real_connect_to_dup;
	DEJA_DUP_OPERATION_CLASS (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 = DEJA_DUP_OPERATION_FILES (obj);
	_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 = DEJA_DUP_OPERATION_FILES (object);
	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 = DEJA_DUP_OPERATION_FILES (object);
	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;
	}
}



