/* GcrAgent.c generated by valac 0.56.19, the Vala compiler
 * generated from GcrAgent.vala, do not modify */

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2026 elementary, Inc. (https://elementary.io)
 */

#include <gcr/gcr.h>
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define AG_TYPE_GCR_AGENT (ag_gcr_agent_get_type ())
#define AG_GCR_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AG_TYPE_GCR_AGENT, AgGcrAgent))
#define AG_GCR_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AG_TYPE_GCR_AGENT, AgGcrAgentClass))
#define AG_IS_GCR_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AG_TYPE_GCR_AGENT))
#define AG_IS_GCR_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AG_TYPE_GCR_AGENT))
#define AG_GCR_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AG_TYPE_GCR_AGENT, AgGcrAgentClass))

typedef struct _AgGcrAgent AgGcrAgent;
typedef struct _AgGcrAgentClass AgGcrAgentClass;
typedef struct _AgGcrAgentPrivate AgGcrAgentPrivate;
enum  {
	AG_GCR_AGENT_0_PROPERTY,
	AG_GCR_AGENT_NUM_PROPERTIES
};
static GParamSpec* ag_gcr_agent_properties[AG_GCR_AGENT_NUM_PROPERTIES];

#define AG_TYPE_GCR_PROMPT (ag_gcr_prompt_get_type ())
#define AG_GCR_PROMPT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AG_TYPE_GCR_PROMPT, AgGcrPrompt))
#define AG_GCR_PROMPT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AG_TYPE_GCR_PROMPT, AgGcrPromptClass))
#define AG_IS_GCR_PROMPT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AG_TYPE_GCR_PROMPT))
#define AG_IS_GCR_PROMPT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AG_TYPE_GCR_PROMPT))
#define AG_GCR_PROMPT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AG_TYPE_GCR_PROMPT, AgGcrPromptClass))

typedef struct _AgGcrPrompt AgGcrPrompt;
typedef struct _AgGcrPromptClass AgGcrPromptClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _AgGcrAgent {
	GcrSystemPrompter parent_instance;
	AgGcrAgentPrivate * priv;
};

struct _AgGcrAgentClass {
	GcrSystemPrompterClass parent_class;
};

static gpointer ag_gcr_agent_parent_class = NULL;

VALA_EXTERN GType ag_gcr_agent_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AgGcrAgent, g_object_unref)
static GcrPrompt* ag_gcr_agent_on_new_prompt (AgGcrAgent* self);
VALA_EXTERN AgGcrPrompt* ag_gcr_prompt_new (void);
VALA_EXTERN AgGcrPrompt* ag_gcr_prompt_construct (GType object_type);
VALA_EXTERN GType ag_gcr_prompt_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AgGcrPrompt, g_object_unref)
VALA_EXTERN AgGcrAgent* ag_gcr_agent_new (void);
VALA_EXTERN AgGcrAgent* ag_gcr_agent_construct (GType object_type);
static GObject * ag_gcr_agent_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties);
static GcrPrompt* _ag_gcr_agent_on_new_prompt_gcr_system_prompter_new_prompt (GcrSystemPrompter* _sender,
                                                                       gpointer self);
static GType ag_gcr_agent_get_type_once (void);

static GcrPrompt*
ag_gcr_agent_on_new_prompt (AgGcrAgent* self)
{
	AgGcrPrompt* _tmp0_;
	GcrPrompt* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ag_gcr_prompt_new ();
	result = (GcrPrompt*) _tmp0_;
	return result;
}

AgGcrAgent*
ag_gcr_agent_construct (GType object_type)
{
	AgGcrAgent * self = NULL;
	self = (AgGcrAgent*) g_object_new (object_type, NULL);
	return self;
}

AgGcrAgent*
ag_gcr_agent_new (void)
{
	return ag_gcr_agent_construct (AG_TYPE_GCR_AGENT);
}

static GcrPrompt*
_ag_gcr_agent_on_new_prompt_gcr_system_prompter_new_prompt (GcrSystemPrompter* _sender,
                                                            gpointer self)
{
	GcrPrompt* result;
	result = ag_gcr_agent_on_new_prompt ((AgGcrAgent*) self);
	return result;
}

static GObject *
ag_gcr_agent_constructor (GType type,
                          guint n_construct_properties,
                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	AgGcrAgent * self;
	GError* _inner_error0_ = NULL;
	parent_class = G_OBJECT_CLASS (ag_gcr_agent_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, AG_TYPE_GCR_AGENT, AgGcrAgent);
	{
		GDBusConnection* connection = NULL;
		GDBusConnection* _tmp0_;
		GDBusConnection* _tmp1_;
		GDBusConnection* _tmp2_;
		_tmp0_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error0_);
		connection = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp1_ = connection;
		gcr_system_prompter_register ((GcrSystemPrompter*) self, _tmp1_);
		_tmp2_ = connection;
		g_bus_own_name_on_connection_with_closures (_tmp2_, "org.gnome.keyring.SystemPrompter", G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
		_g_object_unref0 (connection);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_critical ("GcrAgent.vala:14: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
	}
	g_signal_connect_object ((GcrSystemPrompter*) self, "new-prompt", (GCallback) _ag_gcr_agent_on_new_prompt_gcr_system_prompter_new_prompt, self, 0);
	return obj;
}

static void
ag_gcr_agent_class_init (AgGcrAgentClass * klass,
                         gpointer klass_data)
{
	ag_gcr_agent_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = ag_gcr_agent_constructor;
}

static void
ag_gcr_agent_instance_init (AgGcrAgent * self,
                            gpointer klass)
{
}

static GType
ag_gcr_agent_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AgGcrAgentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ag_gcr_agent_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AgGcrAgent), 0, (GInstanceInitFunc) ag_gcr_agent_instance_init, NULL };
	GType ag_gcr_agent_type_id;
	ag_gcr_agent_type_id = g_type_register_static (gcr_system_prompter_get_type (), "AgGcrAgent", &g_define_type_info, 0);
	return ag_gcr_agent_type_id;
}

GType
ag_gcr_agent_get_type (void)
{
	static volatile gsize ag_gcr_agent_type_id__once = 0;
	if (g_once_init_enter (&ag_gcr_agent_type_id__once)) {
		GType ag_gcr_agent_type_id;
		ag_gcr_agent_type_id = ag_gcr_agent_get_type_once ();
		g_once_init_leave (&ag_gcr_agent_type_id__once, ag_gcr_agent_type_id);
	}
	return ag_gcr_agent_type_id__once;
}

