/* OperationVerify.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from OperationVerify.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 <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.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_OPERATION_VERIFY_0_PROPERTY,
	DEJA_DUP_OPERATION_VERIFY_TAG_PROPERTY,
	DEJA_DUP_OPERATION_VERIFY_NUM_PROPERTIES
};
static GParamSpec* deja_dup_operation_verify_properties[DEJA_DUP_OPERATION_VERIFY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _deja_dup_operation_state_unref0(var) ((var == NULL) ? NULL : (var = (deja_dup_operation_state_unref (var), NULL)))
typedef struct _DejaDupOperationVerifyStartData DejaDupOperationVerifyStartData;
typedef struct _DejaDupOperationVerifyOperationFinishedData DejaDupOperationVerifyOperationFinishedData;

struct _DejaDupOperationVerifyPrivate {
	gchar* _tag;
};

struct _DejaDupOperationVerifyStartData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DejaDupOperationVerify* self;
	DejaDupToolJobMode _tmp0_;
	DejaDupToolJobMode _tmp1_;
	DejaDupOperationState* tmp_state;
	DejaDupOperationState* _tmp2_;
	DejaDupOperationState* _tmp3_;
	DejaDupOperationState* _tmp4_;
};

struct _DejaDupOperationVerifyOperationFinishedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DejaDupOperationVerify* self;
	gboolean success;
	gboolean cancelled;
	gboolean _tmp0_;
	gboolean _tmp1_;
	DejaDupToolJobMode _tmp2_;
	DejaDupToolJobMode _tmp3_;
};

static gint DejaDupOperationVerify_private_offset;
static gpointer deja_dup_operation_verify_parent_class = NULL;

VALA_EXTERN void deja_dup_operation_operation_finished (DejaDupOperation* self,
                                            gboolean success,
                                            gboolean cancelled,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
VALA_EXTERN void deja_dup_operation_operation_finished_finish (DejaDupOperation* self,
                                                   GAsyncResult* _res_);
static void deja_dup_operation_verify_real_start_data_free (gpointer _data);
static void deja_dup_operation_verify_real_start (DejaDupOperation* base,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
static gboolean deja_dup_operation_verify_real_start_co (DejaDupOperationVerifyStartData* _data_);
static void deja_dup_operation_verify_start_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_);
static void deja_dup_operation_verify_real_connect_to_job (DejaDupOperation* base,
                                                    gboolean actions);
static void deja_dup_operation_verify_real_operation_finished_data_free (gpointer _data);
static void deja_dup_operation_verify_real_operation_finished (DejaDupOperation* base,
                                                        gboolean success,
                                                        gboolean cancelled,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
static gboolean deja_dup_operation_verify_real_operation_finished_co (DejaDupOperationVerifyOperationFinishedData* _data_);
static void deja_dup_operation_verify_operation_finished_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void deja_dup_operation_verify_finalize (GObject * obj);
static GType deja_dup_operation_verify_get_type_once (void);
static void _vala_deja_dup_operation_verify_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_deja_dup_operation_verify_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);

static inline gpointer
deja_dup_operation_verify_get_instance_private (DejaDupOperationVerify* self)
{
	return G_STRUCT_MEMBER_P (self, DejaDupOperationVerify_private_offset);
}

DejaDupOperationVerify*
deja_dup_operation_verify_construct (GType object_type,
                                     DejaDupBackend* backend,
                                     const gchar* tag)
{
	DejaDupOperationVerify * self = NULL;
	DejaDupToolJobMode _tmp0_ = 0;
	DejaDupToolJobMode mode = 0;
	g_return_val_if_fail (backend != NULL, NULL);
	g_return_val_if_fail (tag != NULL, NULL);
	if (deja_dup_is_nag_time ()) {
		_tmp0_ = DEJA_DUP_TOOL_JOB_MODE_VERIFY_CLEAN;
	} else {
		_tmp0_ = DEJA_DUP_TOOL_JOB_MODE_VERIFY_BASIC;
	}
	mode = _tmp0_;
	self = (DejaDupOperationVerify*) g_object_new (object_type, "mode", mode, "backend", backend, "tag", tag, NULL);
	if (mode == DEJA_DUP_TOOL_JOB_MODE_VERIFY_CLEAN) {
		deja_dup_operation_set_use_cached_password ((DejaDupOperation*) self, FALSE);
	}
	return self;
}

DejaDupOperationVerify*
deja_dup_operation_verify_new (DejaDupBackend* backend,
                               const gchar* tag)
{
	return deja_dup_operation_verify_construct (DEJA_DUP_TYPE_OPERATION_VERIFY, backend, tag);
}

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

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

static void
deja_dup_operation_verify_real_start (DejaDupOperation* base,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	DejaDupOperationVerify * self;
	DejaDupOperationVerifyStartData* _data_;
	DejaDupOperationVerify* _tmp0_;
	self = (DejaDupOperationVerify*) base;
	_data_ = g_slice_new0 (DejaDupOperationVerifyStartData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, deja_dup_operation_verify_real_start_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	deja_dup_operation_verify_real_start_co (_data_);
}

static void
deja_dup_operation_verify_start_finish (DejaDupOperation* base,
                                        GAsyncResult* _res_)
{
	DejaDupOperationVerifyStartData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
deja_dup_operation_verify_start_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_)
{
	DejaDupOperationVerifyStartData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	deja_dup_operation_verify_real_start_co (_data_);
}

static gboolean
deja_dup_operation_verify_real_start_co (DejaDupOperationVerifyStartData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = deja_dup_operation_get_mode ((DejaDupOperation*) _data_->self);
	_data_->_tmp1_ = _data_->_tmp0_;
	if (_data_->_tmp1_ == DEJA_DUP_TOOL_JOB_MODE_VERIFY_CLEAN) {
		_data_->_tmp2_ = deja_dup_operation_get_state ((DejaDupOperation*) _data_->self);
		_data_->tmp_state = _data_->_tmp2_;
		_data_->_tmp3_ = _data_->tmp_state;
		_g_free0 (_data_->_tmp3_->passphrase);
		_data_->_tmp3_->passphrase = NULL;
		_data_->_tmp4_ = _data_->tmp_state;
		deja_dup_operation_set_state ((DejaDupOperation*) _data_->self, _data_->_tmp4_);
		_deja_dup_operation_state_unref0 (_data_->tmp_state);
	}
	_data_->_state_ = 1;
	DEJA_DUP_OPERATION_CLASS (deja_dup_operation_verify_parent_class)->start (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation), deja_dup_operation_verify_start_ready, _data_);
	return FALSE;
	_state_1:
	DEJA_DUP_OPERATION_CLASS (deja_dup_operation_verify_parent_class)->start_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation), _data_->_res_);
	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 void
deja_dup_operation_verify_real_connect_to_job (DejaDupOperation* base,
                                               gboolean actions)
{
	DejaDupOperationVerify * self;
	DejaDupToolJob* _tmp0_;
	const gchar* _tmp1_;
	self = (DejaDupOperationVerify*) base;
	_tmp0_ = ((DejaDupOperation*) self)->job;
	_tmp1_ = self->priv->_tag;
	deja_dup_tool_job_set_tag (_tmp0_, _tmp1_);
	DEJA_DUP_OPERATION_CLASS (deja_dup_operation_verify_parent_class)->connect_to_job (G_TYPE_CHECK_INSTANCE_CAST (self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation), FALSE);
}

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

static void
deja_dup_operation_verify_real_operation_finished (DejaDupOperation* base,
                                                   gboolean success,
                                                   gboolean cancelled,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	DejaDupOperationVerify * self;
	DejaDupOperationVerifyOperationFinishedData* _data_;
	DejaDupOperationVerify* _tmp0_;
	self = (DejaDupOperationVerify*) base;
	_data_ = g_slice_new0 (DejaDupOperationVerifyOperationFinishedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, deja_dup_operation_verify_real_operation_finished_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->success = success;
	_data_->cancelled = cancelled;
	deja_dup_operation_verify_real_operation_finished_co (_data_);
}

static void
deja_dup_operation_verify_operation_finished_finish (DejaDupOperation* base,
                                                     GAsyncResult* _res_)
{
	DejaDupOperationVerifyOperationFinishedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
deja_dup_operation_verify_operation_finished_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	DejaDupOperationVerifyOperationFinishedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	deja_dup_operation_verify_real_operation_finished_co (_data_);
}

static gboolean
deja_dup_operation_verify_real_operation_finished_co (DejaDupOperationVerifyOperationFinishedData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->success) {
		_data_->_tmp1_ = !_data_->cancelled;
	} else {
		_data_->_tmp1_ = FALSE;
	}
	if (_data_->_tmp1_) {
		_data_->_tmp2_ = deja_dup_operation_get_mode ((DejaDupOperation*) _data_->self);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp0_ = _data_->_tmp3_ == DEJA_DUP_TOOL_JOB_MODE_VERIFY_CLEAN;
	} else {
		_data_->_tmp0_ = FALSE;
	}
	if (_data_->_tmp0_) {
		deja_dup_update_nag_time (FALSE);
	}
	_data_->_state_ = 1;
	DEJA_DUP_OPERATION_CLASS (deja_dup_operation_verify_parent_class)->operation_finished (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation), _data_->success, _data_->cancelled, deja_dup_operation_verify_operation_finished_ready, _data_);
	return FALSE;
	_state_1:
	DEJA_DUP_OPERATION_CLASS (deja_dup_operation_verify_parent_class)->operation_finished_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, DEJA_DUP_TYPE_OPERATION, DejaDupOperation), _data_->_res_);
	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;
}

const gchar*
deja_dup_operation_verify_get_tag (DejaDupOperationVerify* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_tag;
	result = _tmp0_;
	return result;
}

static void
deja_dup_operation_verify_set_tag (DejaDupOperationVerify* self,
                                   const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = deja_dup_operation_verify_get_tag (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_tag);
		self->priv->_tag = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, deja_dup_operation_verify_properties[DEJA_DUP_OPERATION_VERIFY_TAG_PROPERTY]);
	}
}

static void
deja_dup_operation_verify_class_init (DejaDupOperationVerifyClass * klass,
                                      gpointer klass_data)
{
	deja_dup_operation_verify_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DejaDupOperationVerify_private_offset);
	((DejaDupOperationClass *) klass)->start = (void (*) (DejaDupOperation*, GAsyncReadyCallback, gpointer)) deja_dup_operation_verify_real_start;
	((DejaDupOperationClass *) klass)->start_finish = (void (*) (DejaDupOperation*, GAsyncResult*)) deja_dup_operation_verify_start_finish;
	((DejaDupOperationClass *) klass)->connect_to_job = (void (*) (DejaDupOperation*, gboolean)) deja_dup_operation_verify_real_connect_to_job;
	((DejaDupOperationClass *) klass)->operation_finished = (void (*) (DejaDupOperation*, gboolean, gboolean, GAsyncReadyCallback, gpointer)) deja_dup_operation_verify_real_operation_finished;
	((DejaDupOperationClass *) klass)->operation_finished_finish = (void (*) (DejaDupOperation*, GAsyncResult*)) deja_dup_operation_verify_operation_finished_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_deja_dup_operation_verify_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_deja_dup_operation_verify_set_property;
	G_OBJECT_CLASS (klass)->finalize = deja_dup_operation_verify_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DEJA_DUP_OPERATION_VERIFY_TAG_PROPERTY, deja_dup_operation_verify_properties[DEJA_DUP_OPERATION_VERIFY_TAG_PROPERTY] = g_param_spec_string ("tag", "tag", "tag", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
deja_dup_operation_verify_instance_init (DejaDupOperationVerify * self,
                                         gpointer klass)
{
	self->priv = deja_dup_operation_verify_get_instance_private (self);
}

static void
deja_dup_operation_verify_finalize (GObject * obj)
{
	DejaDupOperationVerify * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DEJA_DUP_TYPE_OPERATION_VERIFY, DejaDupOperationVerify);
	_g_free0 (self->priv->_tag);
	G_OBJECT_CLASS (deja_dup_operation_verify_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
deja_dup_operation_verify_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DejaDupOperationVerifyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_operation_verify_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupOperationVerify), 0, (GInstanceInitFunc) deja_dup_operation_verify_instance_init, NULL };
	GType deja_dup_operation_verify_type_id;
	deja_dup_operation_verify_type_id = g_type_register_static (DEJA_DUP_TYPE_OPERATION, "DejaDupOperationVerify", &g_define_type_info, 0);
	DejaDupOperationVerify_private_offset = g_type_add_instance_private (deja_dup_operation_verify_type_id, sizeof (DejaDupOperationVerifyPrivate));
	return deja_dup_operation_verify_type_id;
}

GType
deja_dup_operation_verify_get_type (void)
{
	static gsize deja_dup_operation_verify_type_id__once = 0;
	if (g_once_init_enter (&deja_dup_operation_verify_type_id__once)) {
		GType deja_dup_operation_verify_type_id;
		deja_dup_operation_verify_type_id = deja_dup_operation_verify_get_type_once ();
		g_once_init_leave (&deja_dup_operation_verify_type_id__once, deja_dup_operation_verify_type_id);
	}
	return deja_dup_operation_verify_type_id__once;
}

static void
_vala_deja_dup_operation_verify_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	DejaDupOperationVerify * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_OPERATION_VERIFY, DejaDupOperationVerify);
	switch (property_id) {
		case DEJA_DUP_OPERATION_VERIFY_TAG_PROPERTY:
		g_value_set_string (value, deja_dup_operation_verify_get_tag (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_deja_dup_operation_verify_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	DejaDupOperationVerify * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DEJA_DUP_TYPE_OPERATION_VERIFY, DejaDupOperationVerify);
	switch (property_id) {
		case DEJA_DUP_OPERATION_VERIFY_TAG_PROPERTY:
		deja_dup_operation_verify_set_tag (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

