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

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

#include "deja.h"
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.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

enum  {
	DEJA_DUP_BACKEND_AUTO_0_PROPERTY,
	DEJA_DUP_BACKEND_AUTO_NUM_PROPERTIES
};
static GParamSpec* deja_dup_backend_auto_properties[DEJA_DUP_BACKEND_AUTO_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _DejaDupBackendAutoIsReadyData DejaDupBackendAutoIsReadyData;

struct _DejaDupBackendAutoIsReadyData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DejaDupBackendAuto* self;
	gchar* reason;
	gchar* message;
	gboolean result;
	gchar* _tmp0_;
	gchar* _tmp1_;
};

static gpointer deja_dup_backend_auto_parent_class = NULL;

static gboolean deja_dup_backend_auto_real_is_native (DejaDupBackend* base);
static GIcon* deja_dup_backend_auto_real_get_icon (DejaDupBackend* base);
static void deja_dup_backend_auto_real_is_ready_data_free (gpointer _data);
static void deja_dup_backend_auto_real_is_ready (DejaDupBackend* base,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static gboolean deja_dup_backend_auto_real_is_ready_co (DejaDupBackendAutoIsReadyData* _data_);
static void deja_dup_backend_auto_is_ready_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static gchar* deja_dup_backend_auto_real_get_location_pretty (DejaDupBackend* base);
static gchar* deja_dup_backend_auto_real_get_unique_location (DejaDupBackend* base);
static GObject * deja_dup_backend_auto_constructor (GType type,
                                             guint n_construct_properties,
                                             GObjectConstructParam * construct_properties);
static GType deja_dup_backend_auto_get_type_once (void);

static gboolean
deja_dup_backend_auto_real_is_native (DejaDupBackend* base)
{
	DejaDupBackendAuto * self;
	gboolean result;
	self = (DejaDupBackendAuto*) base;
	result = FALSE;
	return result;
}

static GIcon*
deja_dup_backend_auto_real_get_icon (DejaDupBackend* base)
{
	DejaDupBackendAuto * self;
	GIcon* result;
	self = (DejaDupBackendAuto*) base;
	result = NULL;
	return result;
}

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

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

static void
deja_dup_backend_auto_real_is_ready (DejaDupBackend* base,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	DejaDupBackendAuto * self;
	DejaDupBackendAutoIsReadyData* _data_;
	DejaDupBackendAuto* _tmp0_;
	self = (DejaDupBackendAuto*) base;
	_data_ = g_slice_new0 (DejaDupBackendAutoIsReadyData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, deja_dup_backend_auto_real_is_ready_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	deja_dup_backend_auto_real_is_ready_co (_data_);
}

static gboolean
deja_dup_backend_auto_is_ready_finish (DejaDupBackend* base,
                                       GAsyncResult* _res_,
                                       gchar** reason,
                                       gchar** message)
{
	gboolean result;
	DejaDupBackendAutoIsReadyData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	if (reason) {
		*reason = _data_->reason;
	} else {
		_g_free0 (_data_->reason);
	}
	_data_->reason = NULL;
	if (message) {
		*message = _data_->message;
	} else {
		_g_free0 (_data_->message);
	}
	_data_->message = NULL;
	result = _data_->result;
	return result;
}

static void
deja_dup_backend_auto_is_ready_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	DejaDupBackendAutoIsReadyData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	deja_dup_backend_auto_real_is_ready_co (_data_);
}

static gboolean
deja_dup_backend_auto_real_is_ready_co (DejaDupBackendAutoIsReadyData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp1_ = NULL;
	_data_->_state_ = 1;
	DEJA_DUP_BACKEND_CLASS (deja_dup_backend_auto_parent_class)->is_ready (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, DEJA_DUP_TYPE_BACKEND, DejaDupBackend), deja_dup_backend_auto_is_ready_ready, _data_);
	return FALSE;
	_state_1:
	DEJA_DUP_BACKEND_CLASS (deja_dup_backend_auto_parent_class)->is_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, DEJA_DUP_TYPE_BACKEND, DejaDupBackend), _data_->_res_, &_data_->_tmp0_, &_data_->_tmp1_);
	_g_free0 (_data_->reason);
	_data_->reason = _data_->_tmp0_;
	_g_free0 (_data_->message);
	_data_->message = _data_->_tmp1_;
	_data_->result = 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 gchar*
deja_dup_backend_auto_real_get_location_pretty (DejaDupBackend* base)
{
	DejaDupBackendAuto * self;
	gchar* _tmp0_;
	gchar* result;
	self = (DejaDupBackendAuto*) base;
	_tmp0_ = g_strdup ("");
	result = _tmp0_;
	return result;
}

static gchar*
deja_dup_backend_auto_real_get_unique_location (DejaDupBackend* base)
{
	DejaDupBackendAuto * self;
	gchar* _tmp0_;
	gchar* result;
	self = (DejaDupBackendAuto*) base;
	_tmp0_ = g_strdup ("auto:");
	result = _tmp0_;
	return result;
}

DejaDupBackendAuto*
deja_dup_backend_auto_construct (GType object_type)
{
	DejaDupBackendAuto * self = NULL;
	self = (DejaDupBackendAuto*) deja_dup_backend_construct (object_type);
	return self;
}

DejaDupBackendAuto*
deja_dup_backend_auto_new (void)
{
	return deja_dup_backend_auto_construct (DEJA_DUP_TYPE_BACKEND_AUTO);
}

static GObject *
deja_dup_backend_auto_constructor (GType type,
                                   guint n_construct_properties,
                                   GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DejaDupBackendAuto * self;
	DejaDupFilteredSettings* settings = NULL;
	DejaDupFilteredSettings* _tmp0_;
	DejaDupFilteredSettings* _tmp1_;
	parent_class = G_OBJECT_CLASS (deja_dup_backend_auto_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_BACKEND_AUTO, DejaDupBackendAuto);
	_tmp0_ = deja_dup_get_settings (NULL);
	settings = _tmp0_;
	_tmp1_ = settings;
	deja_dup_filtered_settings_set_string (_tmp1_, DEJA_DUP_BACKEND_KEY, "google");
	_g_object_unref0 (settings);
	return obj;
}

static void
deja_dup_backend_auto_class_init (DejaDupBackendAutoClass * klass,
                                  gpointer klass_data)
{
	deja_dup_backend_auto_parent_class = g_type_class_peek_parent (klass);
	((DejaDupBackendClass *) klass)->is_native = (gboolean (*) (DejaDupBackend*)) deja_dup_backend_auto_real_is_native;
	((DejaDupBackendClass *) klass)->get_icon = (GIcon* (*) (DejaDupBackend*)) deja_dup_backend_auto_real_get_icon;
	((DejaDupBackendClass *) klass)->is_ready = (void (*) (DejaDupBackend*, GAsyncReadyCallback, gpointer)) deja_dup_backend_auto_real_is_ready;
	((DejaDupBackendClass *) klass)->is_ready_finish = (gboolean (*) (DejaDupBackend*, GAsyncResult*, gchar**, gchar**)) deja_dup_backend_auto_is_ready_finish;
	((DejaDupBackendClass *) klass)->get_location_pretty = (gchar* (*) (DejaDupBackend*)) deja_dup_backend_auto_real_get_location_pretty;
	((DejaDupBackendClass *) klass)->get_unique_location = (gchar* (*) (DejaDupBackend*)) deja_dup_backend_auto_real_get_unique_location;
	G_OBJECT_CLASS (klass)->constructor = deja_dup_backend_auto_constructor;
}

static void
deja_dup_backend_auto_instance_init (DejaDupBackendAuto * self,
                                     gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
deja_dup_backend_auto_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DejaDupBackendAutoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_backend_auto_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupBackendAuto), 0, (GInstanceInitFunc) deja_dup_backend_auto_instance_init, NULL };
	GType deja_dup_backend_auto_type_id;
	deja_dup_backend_auto_type_id = g_type_register_static (DEJA_DUP_TYPE_BACKEND, "DejaDupBackendAuto", &g_define_type_info, 0);
	return deja_dup_backend_auto_type_id;
}

GType
deja_dup_backend_auto_get_type (void)
{
	static gsize deja_dup_backend_auto_type_id__once = 0;
	if (g_once_init_enter (&deja_dup_backend_auto_type_id__once)) {
		GType deja_dup_backend_auto_type_id;
		deja_dup_backend_auto_type_id = deja_dup_backend_auto_get_type_once ();
		g_once_init_leave (&deja_dup_backend_auto_type_id__once, deja_dup_backend_auto_type_id);
	}
	return deja_dup_backend_auto_type_id__once;
}

