/* BorgInstance.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from BorgInstance.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 <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <json-glib/json-glib.h>
#include "deja.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

#define TYPE_TOOL_INSTANCE (tool_instance_get_type ())
#define TOOL_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TOOL_INSTANCE, ToolInstance))
#define TOOL_INSTANCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TOOL_INSTANCE, ToolInstanceClass))
#define IS_TOOL_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TOOL_INSTANCE))
#define IS_TOOL_INSTANCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TOOL_INSTANCE))
#define TOOL_INSTANCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TOOL_INSTANCE, ToolInstanceClass))

typedef struct _ToolInstance ToolInstance;
typedef struct _ToolInstanceClass ToolInstanceClass;
typedef struct _ToolInstancePrivate ToolInstancePrivate;

#define TYPE_BORG_INSTANCE (borg_instance_get_type ())
#define BORG_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BORG_INSTANCE, BorgInstance))
#define BORG_INSTANCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BORG_INSTANCE, BorgInstanceClass))
#define IS_BORG_INSTANCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BORG_INSTANCE))
#define IS_BORG_INSTANCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BORG_INSTANCE))
#define BORG_INSTANCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BORG_INSTANCE, BorgInstanceClass))

typedef struct _BorgInstance BorgInstance;
typedef struct _BorgInstanceClass BorgInstanceClass;
typedef struct _BorgInstancePrivate BorgInstancePrivate;
enum  {
	BORG_INSTANCE_0_PROPERTY,
	BORG_INSTANCE_NUM_PROPERTIES
};
static GParamSpec* borg_instance_properties[BORG_INSTANCE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
enum  {
	BORG_INSTANCE_MESSAGE_SIGNAL,
	BORG_INSTANCE_NUM_SIGNALS
};
static guint borg_instance_signals[BORG_INSTANCE_NUM_SIGNALS] = {0};

struct _ToolInstance {
	GObject parent_instance;
	ToolInstancePrivate * priv;
};

struct _ToolInstanceClass {
	GObjectClass parent_class;
	gchar* (*_name) (ToolInstance* self);
	void (*_send_error) (ToolInstance* self, GError* e);
	gboolean (*_process_line) (ToolInstance* self, const gchar* stanza, const gchar* line, gboolean* loggable, GError** error);
	void (*_edit_envp) (ToolInstance* self, GList* envp);
};

struct _BorgInstance {
	ToolInstance parent_instance;
	BorgInstancePrivate * priv;
};

struct _BorgInstanceClass {
	ToolInstanceClass parent_class;
};

static gpointer borg_instance_parent_class = NULL;

VALA_EXTERN GType tool_instance_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType borg_instance_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* _tool_instance_name (ToolInstance* self);
VALA_EXTERN void _tool_instance_send_error (ToolInstance* self,
                                GError* e);
VALA_EXTERN gboolean _tool_instance_process_line (ToolInstance* self,
                                      const gchar* stanza,
                                      const gchar* line,
                                      gboolean* loggable,
                                      GError** error);
static gchar* borg_instance_real__name (ToolInstance* base);
static void borg_instance_real__send_error (ToolInstance* base,
                                     GError* e);
static gboolean borg_instance_real__process_line (ToolInstance* base,
                                           const gchar* stanza,
                                           const gchar* line,
                                           gboolean* loggable,
                                           GError** error);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void _vala_JsonNode_free (JsonNode* self);
VALA_EXTERN BorgInstance* borg_instance_new (void);
VALA_EXTERN BorgInstance* borg_instance_construct (GType object_type);
VALA_EXTERN ToolInstance* tool_instance_construct (GType object_type);
static GType borg_instance_get_type_once (void);

static gchar*
borg_instance_real__name (ToolInstance* base)
{
	BorgInstance * self;
	gchar* _tmp0_;
	gchar* result;
	self = (BorgInstance*) base;
	_tmp0_ = g_strdup ("borg");
	result = _tmp0_;
	return result;
}

static void
borg_instance_real__send_error (ToolInstance* base,
                                GError* e)
{
	BorgInstance * self;
	self = (BorgInstance*) base;
	g_return_if_fail (e != NULL);
}

static JsonNode*
_vala_JsonNode_copy (JsonNode* self)
{
	return g_boxed_copy (json_node_get_type (), self);
}

static gpointer
__vala_JsonNode_copy0 (gpointer self)
{
	return self ? _vala_JsonNode_copy (self) : NULL;
}

static void
_vala_JsonNode_free (JsonNode* self)
{
	g_boxed_free (json_node_get_type (), self);
}

static gboolean
borg_instance_real__process_line (ToolInstance* base,
                                  const gchar* stanza,
                                  const gchar* line,
                                  gboolean* loggable,
                                  GError** error)
{
	BorgInstance * self;
	gboolean _vala_loggable = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean stanza_done = FALSE;
	JsonParser* parser = NULL;
	JsonParser* _tmp4_;
	JsonParser* _tmp5_;
	JsonNode* root = NULL;
	JsonParser* _tmp7_;
	JsonNode* _tmp8_;
	JsonNode* _tmp9_;
	JsonNode* _tmp10_;
	JsonReader* _tmp11_;
	JsonReader* _tmp12_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (BorgInstance*) base;
	g_return_val_if_fail (stanza != NULL, FALSE);
	g_return_val_if_fail (line != NULL, FALSE);
	_vala_loggable = TRUE;
	if (g_strcmp0 (line, "}") == 0) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp1_ = FALSE;
		if (g_str_has_prefix (line, "{")) {
			gint _tmp2_;
			gint _tmp3_;
			_tmp2_ = strlen (line);
			_tmp3_ = _tmp2_;
			_tmp1_ = _tmp3_ > 1;
		} else {
			_tmp1_ = FALSE;
		}
		_tmp0_ = _tmp1_;
	}
	stanza_done = _tmp0_;
	if (!stanza_done) {
		result = FALSE;
		if (loggable) {
			*loggable = _vala_loggable;
		}
		return result;
	}
	_tmp4_ = json_parser_new_immutable ();
	parser = _tmp4_;
	_tmp5_ = parser;
	json_parser_load_from_data (_tmp5_, stanza, (gssize) -1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp6_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (parser);
		return _tmp6_;
	}
	_tmp7_ = parser;
	_tmp8_ = json_parser_get_root (_tmp7_);
	_tmp9_ = __vala_JsonNode_copy0 (_tmp8_);
	root = _tmp9_;
	_tmp10_ = root;
	_tmp11_ = json_reader_new (_tmp10_);
	_tmp12_ = _tmp11_;
	g_signal_emit (self, borg_instance_signals[BORG_INSTANCE_MESSAGE_SIGNAL], 0, _tmp12_);
	_g_object_unref0 (_tmp12_);
	result = TRUE;
	__vala_JsonNode_free0 (root);
	_g_object_unref0 (parser);
	if (loggable) {
		*loggable = _vala_loggable;
	}
	return result;
}

BorgInstance*
borg_instance_construct (GType object_type)
{
	BorgInstance * self = NULL;
	self = (BorgInstance*) tool_instance_construct (object_type);
	return self;
}

BorgInstance*
borg_instance_new (void)
{
	return borg_instance_construct (TYPE_BORG_INSTANCE);
}

static void
borg_instance_class_init (BorgInstanceClass * klass,
                          gpointer klass_data)
{
	borg_instance_parent_class = g_type_class_peek_parent (klass);
	((ToolInstanceClass *) klass)->_name = (gchar* (*) (ToolInstance*)) borg_instance_real__name;
	((ToolInstanceClass *) klass)->_send_error = (void (*) (ToolInstance*, GError*)) borg_instance_real__send_error;
	((ToolInstanceClass *) klass)->_process_line = (gboolean (*) (ToolInstance*, const gchar*, const gchar*, gboolean*, GError**)) borg_instance_real__process_line;
	borg_instance_signals[BORG_INSTANCE_MESSAGE_SIGNAL] = g_signal_new ("message", TYPE_BORG_INSTANCE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, json_reader_get_type ());
}

static void
borg_instance_instance_init (BorgInstance * self,
                             gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
borg_instance_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BorgInstanceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) borg_instance_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BorgInstance), 0, (GInstanceInitFunc) borg_instance_instance_init, NULL };
	GType borg_instance_type_id;
	borg_instance_type_id = g_type_register_static (TYPE_TOOL_INSTANCE, "BorgInstance", &g_define_type_info, 0);
	return borg_instance_type_id;
}

GType
borg_instance_get_type (void)
{
	static gsize borg_instance_type_id__once = 0;
	if (g_once_init_enter (&borg_instance_type_id__once)) {
		GType borg_instance_type_id;
		borg_instance_type_id = borg_instance_get_type_once ();
		g_once_init_leave (&borg_instance_type_id__once, borg_instance_type_id);
	}
	return borg_instance_type_id__once;
}

