/* BackendU1.c generated by valac 0.30.0, the Vala compiler
 * generated from BackendU1.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>


#define DEJA_DUP_TYPE_BACKEND (deja_dup_backend_get_type ())
#define DEJA_DUP_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_BACKEND, DejaDupBackend))
#define DEJA_DUP_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_BACKEND, DejaDupBackendClass))
#define DEJA_DUP_IS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_BACKEND))
#define DEJA_DUP_IS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_BACKEND))
#define DEJA_DUP_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_BACKEND, DejaDupBackendClass))

typedef struct _DejaDupBackend DejaDupBackend;
typedef struct _DejaDupBackendClass DejaDupBackendClass;
typedef struct _DejaDupBackendPrivate DejaDupBackendPrivate;

#define DEJA_DUP_TOOL_JOB_TYPE_MODE (deja_dup_tool_job_mode_get_type ())

#define DEJA_DUP_TYPE_BACKEND_U1 (deja_dup_backend_u1_get_type ())
#define DEJA_DUP_BACKEND_U1(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_BACKEND_U1, DejaDupBackendU1))
#define DEJA_DUP_BACKEND_U1_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_BACKEND_U1, DejaDupBackendU1Class))
#define DEJA_DUP_IS_BACKEND_U1(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_BACKEND_U1))
#define DEJA_DUP_IS_BACKEND_U1_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_BACKEND_U1))
#define DEJA_DUP_BACKEND_U1_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_BACKEND_U1, DejaDupBackendU1Class))

typedef struct _DejaDupBackendU1 DejaDupBackendU1;
typedef struct _DejaDupBackendU1Class DejaDupBackendU1Class;
typedef struct _DejaDupBackendU1Private DejaDupBackendU1Private;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _DejaDupBackendU1GetEnvpData DejaDupBackendU1GetEnvpData;

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;

struct _DejaDupBackend {
	GObject parent_instance;
	DejaDupBackendPrivate * priv;
};

struct _DejaDupBackendClass {
	GObjectClass parent_class;
	gboolean (*is_native) (DejaDupBackend* self);
	GIcon* (*get_icon) (DejaDupBackend* self);
	gchar* (*get_location) (DejaDupBackend* self, gboolean* as_root);
	gchar* (*get_location_pretty) (DejaDupBackend* self);
	void (*is_ready) (DejaDupBackend* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	gboolean (*is_ready_finish) (DejaDupBackend* self, GAsyncResult* _res_, gchar** when);
	void (*get_envp) (DejaDupBackend* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*get_envp_finish) (DejaDupBackend* self, GAsyncResult* _res_, GError** error);
	void (*get_space) (DejaDupBackend* self, gboolean free, GAsyncReadyCallback _callback_, gpointer _user_data_);
	guint64 (*get_space_finish) (DejaDupBackend* self, GAsyncResult* _res_);
	gboolean (*space_can_be_infinite) (DejaDupBackend* self);
	void (*add_argv) (DejaDupBackend* self, DejaDupToolJobMode mode, GList** argv);
	DejaDupBackend* (*clone) (DejaDupBackend* self);
};

struct _DejaDupBackendU1 {
	DejaDupBackend parent_instance;
	DejaDupBackendU1Private * priv;
};

struct _DejaDupBackendU1Class {
	DejaDupBackendClass parent_class;
};

typedef enum  {
	DEJA_DUP_BACKUP_ERROR_BAD_CONFIG,
	DEJA_DUP_BACKUP_ERROR_ALREADY_RUNNING
} DejaDupBackupError;
#define DEJA_DUP_BACKUP_ERROR deja_dup_backup_error_quark ()
struct _DejaDupBackendU1GetEnvpData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	DejaDupBackendU1* self;
	const gchar* _tmp0_;
	GError* _tmp1_;
	GError * _inner_error_;
};


static gpointer deja_dup_backend_u1_parent_class = NULL;

GType deja_dup_backend_get_type (void) G_GNUC_CONST;
GType deja_dup_tool_job_mode_get_type (void) G_GNUC_CONST;
GType deja_dup_backend_u1_get_type (void) G_GNUC_CONST;
enum  {
	DEJA_DUP_BACKEND_U1_DUMMY_PROPERTY
};
static DejaDupBackend* deja_dup_backend_u1_real_clone (DejaDupBackend* base);
DejaDupBackendU1* deja_dup_backend_u1_new (void);
DejaDupBackendU1* deja_dup_backend_u1_construct (GType object_type);
static gboolean deja_dup_backend_u1_real_is_native (DejaDupBackend* base);
static GIcon* deja_dup_backend_u1_real_get_icon (DejaDupBackend* base);
static gchar* deja_dup_backend_u1_real_get_location (DejaDupBackend* base, gboolean* as_root);
static gchar* deja_dup_backend_u1_real_get_location_pretty (DejaDupBackend* base);
static void deja_dup_backend_u1_real_get_envp_data_free (gpointer _data);
static void deja_dup_backend_u1_real_get_envp (DejaDupBackend* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean deja_dup_backend_u1_real_get_envp_co (DejaDupBackendU1GetEnvpData* _data_);
GQuark deja_dup_backup_error_quark (void);
DejaDupBackend* deja_dup_backend_construct (GType object_type);
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);


static DejaDupBackend* deja_dup_backend_u1_real_clone (DejaDupBackend* base) {
	DejaDupBackendU1 * self;
	DejaDupBackend* result = NULL;
	DejaDupBackendU1* _tmp0_ = NULL;
	self = (DejaDupBackendU1*) base;
	_tmp0_ = deja_dup_backend_u1_new ();
	result = (DejaDupBackend*) _tmp0_;
	return result;
}


static gboolean deja_dup_backend_u1_real_is_native (DejaDupBackend* base) {
	DejaDupBackendU1 * self;
	gboolean result = FALSE;
	self = (DejaDupBackendU1*) base;
	result = FALSE;
	return result;
}


static GIcon* deja_dup_backend_u1_real_get_icon (DejaDupBackend* base) {
	DejaDupBackendU1 * self;
	GIcon* result = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	gchar** _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	gint _tmp4__length1 = 0;
	GThemedIcon* _tmp5_ = NULL;
	GIcon* _tmp6_ = NULL;
	self = (DejaDupBackendU1*) base;
	_tmp0_ = g_strdup ("ubuntuone");
	_tmp1_ = g_strdup ("ubuntuone-installer");
	_tmp2_ = g_strdup ("deja-dup-cloud");
	_tmp3_ = g_new0 (gchar*, 3 + 1);
	_tmp3_[0] = _tmp0_;
	_tmp3_[1] = _tmp1_;
	_tmp3_[2] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 3;
	_tmp5_ = (GThemedIcon*) g_themed_icon_new_from_names (_tmp4_, 3);
	_tmp6_ = (GIcon*) _tmp5_;
	_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	result = _tmp6_;
	return result;
}


static gchar* deja_dup_backend_u1_real_get_location (DejaDupBackend* base, gboolean* as_root) {
	DejaDupBackendU1 * self;
	gchar* result = NULL;
	gchar* _tmp0_ = NULL;
	self = (DejaDupBackendU1*) base;
	_tmp0_ = g_strdup ("");
	result = _tmp0_;
	return result;
}


static gchar* deja_dup_backend_u1_real_get_location_pretty (DejaDupBackend* base) {
	DejaDupBackendU1 * self;
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	self = (DejaDupBackendU1*) base;
	_tmp0_ = _ ("Ubuntu One");
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}


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


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


static void deja_dup_backend_u1_real_get_envp (DejaDupBackend* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	DejaDupBackendU1 * self;
	DejaDupBackendU1GetEnvpData* _data_;
	DejaDupBackendU1* _tmp0_ = NULL;
	self = (DejaDupBackendU1*) base;
	_data_ = g_slice_new0 (DejaDupBackendU1GetEnvpData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, deja_dup_backend_u1_real_get_envp);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, deja_dup_backend_u1_real_get_envp_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	deja_dup_backend_u1_real_get_envp_co (_data_);
}


static void deja_dup_backend_u1_real_get_envp_finish (DejaDupBackend* base, GAsyncResult* _res_, GError** error) {
	DejaDupBackendU1GetEnvpData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static gboolean deja_dup_backend_u1_real_get_envp_co (DejaDupBackendU1GetEnvpData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = _ ("Ubuntu One has shut down.  Please choose another storage location.");
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = g_error_new_literal (DEJA_DUP_BACKUP_ERROR, DEJA_DUP_BACKUP_ERROR_BAD_CONFIG, _data_->_tmp0_);
	_data_->_inner_error_ = _data_->_tmp1_;
	g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
	g_error_free (_data_->_inner_error_);
	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;
	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;
}


DejaDupBackendU1* deja_dup_backend_u1_construct (GType object_type) {
	DejaDupBackendU1 * self = NULL;
	self = (DejaDupBackendU1*) deja_dup_backend_construct (object_type);
	return self;
}


DejaDupBackendU1* deja_dup_backend_u1_new (void) {
	return deja_dup_backend_u1_construct (DEJA_DUP_TYPE_BACKEND_U1);
}


static void deja_dup_backend_u1_class_init (DejaDupBackendU1Class * klass) {
	deja_dup_backend_u1_parent_class = g_type_class_peek_parent (klass);
	((DejaDupBackendClass *) klass)->clone = deja_dup_backend_u1_real_clone;
	((DejaDupBackendClass *) klass)->is_native = deja_dup_backend_u1_real_is_native;
	((DejaDupBackendClass *) klass)->get_icon = deja_dup_backend_u1_real_get_icon;
	((DejaDupBackendClass *) klass)->get_location = deja_dup_backend_u1_real_get_location;
	((DejaDupBackendClass *) klass)->get_location_pretty = deja_dup_backend_u1_real_get_location_pretty;
	((DejaDupBackendClass *) klass)->get_envp = deja_dup_backend_u1_real_get_envp;
	((DejaDupBackendClass *) klass)->get_envp_finish = deja_dup_backend_u1_real_get_envp_finish;
}


static void deja_dup_backend_u1_instance_init (DejaDupBackendU1 * self) {
}


GType deja_dup_backend_u1_get_type (void) {
	static volatile gsize deja_dup_backend_u1_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_backend_u1_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupBackendU1Class), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_backend_u1_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupBackendU1), 0, (GInstanceInitFunc) deja_dup_backend_u1_instance_init, NULL };
		GType deja_dup_backend_u1_type_id;
		deja_dup_backend_u1_type_id = g_type_register_static (DEJA_DUP_TYPE_BACKEND, "DejaDupBackendU1", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_backend_u1_type_id__volatile, deja_dup_backend_u1_type_id);
	}
	return deja_dup_backend_u1_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);
}



