/* release-source-support.c generated by valac 0.56.19, the Vala compiler
 * generated from release-source-support.vala, do not modify */

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <json-glib/json-glib.h>
#include "protonplus_core.h"
#include <gee.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 PROTON_PLUS_PROVIDERS_SOURCES_TYPE_RELEASE_SOURCE_SUPPORT (proton_plus_providers_sources_release_source_support_get_type ())
#define PROTON_PLUS_PROVIDERS_SOURCES_RELEASE_SOURCE_SUPPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_PROVIDERS_SOURCES_TYPE_RELEASE_SOURCE_SUPPORT, ProtonPlusProvidersSourcesReleaseSourceSupport))
#define PROTON_PLUS_PROVIDERS_SOURCES_RELEASE_SOURCE_SUPPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_PROVIDERS_SOURCES_TYPE_RELEASE_SOURCE_SUPPORT, ProtonPlusProvidersSourcesReleaseSourceSupportClass))
#define PROTON_PLUS_PROVIDERS_SOURCES_IS_RELEASE_SOURCE_SUPPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_PROVIDERS_SOURCES_TYPE_RELEASE_SOURCE_SUPPORT))
#define PROTON_PLUS_PROVIDERS_SOURCES_IS_RELEASE_SOURCE_SUPPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_PROVIDERS_SOURCES_TYPE_RELEASE_SOURCE_SUPPORT))
#define PROTON_PLUS_PROVIDERS_SOURCES_RELEASE_SOURCE_SUPPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_PROVIDERS_SOURCES_TYPE_RELEASE_SOURCE_SUPPORT, ProtonPlusProvidersSourcesReleaseSourceSupportClass))

typedef struct _ProtonPlusProvidersSourcesReleaseSourceSupport ProtonPlusProvidersSourcesReleaseSourceSupport;
typedef struct _ProtonPlusProvidersSourcesReleaseSourceSupportClass ProtonPlusProvidersSourcesReleaseSourceSupportClass;
typedef struct _ProtonPlusProvidersSourcesReleaseSourceSupportPrivate ProtonPlusProvidersSourcesReleaseSourceSupportPrivate;
enum  {
	PROTON_PLUS_PROVIDERS_SOURCES_RELEASE_SOURCE_SUPPORT_0_PROPERTY,
	PROTON_PLUS_PROVIDERS_SOURCES_RELEASE_SOURCE_SUPPORT_NUM_PROPERTIES
};
static GParamSpec* proton_plus_providers_sources_release_source_support_properties[PROTON_PLUS_PROVIDERS_SOURCES_RELEASE_SOURCE_SUPPORT_NUM_PROPERTIES];
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ProtonPlusProvidersSourcesReleaseSourceSupport {
	GObject parent_instance;
	ProtonPlusProvidersSourcesReleaseSourceSupportPrivate * priv;
};

struct _ProtonPlusProvidersSourcesReleaseSourceSupportClass {
	GObjectClass parent_class;
};

static gpointer proton_plus_providers_sources_release_source_support_parent_class = NULL;

VALA_EXTERN GType proton_plus_providers_sources_release_source_support_get_type (void) G_GNUC_CONST ;
VALA_EXTERN JsonArray* proton_plus_providers_sources_release_source_support_parse_array (const gchar* response_body);
static void _vala_JsonNode_free (JsonNode* self);
VALA_EXTERN gchar* proton_plus_providers_sources_release_source_support_get_iso8601_date (JsonObject* object,
                                                                              const gchar* member);
VALA_EXTERN void proton_plus_providers_sources_release_source_support_add_variants (ProtonPlusModelsRelease* release,
                                                                        GeeIterable* variants);
VALA_EXTERN ProtonPlusProvidersSourcesReleaseSourceSupport* proton_plus_providers_sources_release_source_support_new (void);
VALA_EXTERN ProtonPlusProvidersSourcesReleaseSourceSupport* proton_plus_providers_sources_release_source_support_construct (GType object_type);
static GType proton_plus_providers_sources_release_source_support_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

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

static gpointer
_json_array_ref0 (gpointer self)
{
	return self ? json_array_ref (self) : NULL;
}

JsonArray*
proton_plus_providers_sources_release_source_support_parse_array (const gchar* response_body)
{
	JsonNode* root_node = NULL;
	gboolean _tmp3_ = FALSE;
	JsonNode* _tmp4_;
	JsonNode* _tmp6_;
	JsonArray* _tmp7_;
	JsonArray* _tmp8_;
	GError* _inner_error0_ = NULL;
	JsonArray* result;
	g_return_val_if_fail (response_body != NULL, NULL);
	{
		JsonNode* _tmp0_ = NULL;
		JsonNode* _tmp1_;
		JsonNode* _tmp2_;
		_tmp1_ = json_from_string (response_body, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		__vala_JsonNode_free0 (root_node);
		root_node = _tmp2_;
		__vala_JsonNode_free0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		__vala_JsonNode_free0 (root_node);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		__vala_JsonNode_free0 (root_node);
		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_);
		return NULL;
	}
	_tmp4_ = root_node;
	if (_tmp4_ == NULL) {
		_tmp3_ = TRUE;
	} else {
		JsonNode* _tmp5_;
		_tmp5_ = root_node;
		_tmp3_ = json_node_get_node_type (_tmp5_) != JSON_NODE_ARRAY;
	}
	if (_tmp3_) {
		result = NULL;
		__vala_JsonNode_free0 (root_node);
		return result;
	}
	_tmp6_ = root_node;
	_tmp7_ = json_node_get_array (_tmp6_);
	_tmp8_ = _json_array_ref0 (_tmp7_);
	result = _tmp8_;
	__vala_JsonNode_free0 (root_node);
	return result;
}

static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

gchar*
proton_plus_providers_sources_release_source_support_get_iso8601_date (JsonObject* object,
                                                                       const gchar* member)
{
	gchar* raw = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	GDateTime* parsed = NULL;
	const gchar* _tmp2_;
	GDateTime* _tmp3_;
	GDateTime* _tmp4_ = NULL;
	GDateTime* _tmp5_;
	GDateTime* _tmp6_;
	gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (object != NULL, NULL);
	g_return_val_if_fail (member != NULL, NULL);
	_tmp0_ = json_object_get_string_member_with_default (object, member, "");
	_tmp1_ = g_strdup (_tmp0_);
	raw = _tmp1_;
	_tmp2_ = raw;
	_tmp3_ = g_date_time_new_from_iso8601 (_tmp2_, NULL);
	parsed = _tmp3_;
	_tmp5_ = parsed;
	_tmp6_ = _g_date_time_ref0 (_tmp5_);
	_tmp4_ = _tmp6_;
	if (_tmp4_ == NULL) {
		GDateTime* _tmp7_;
		_tmp7_ = g_date_time_new_now_utc ();
		_g_date_time_unref0 (_tmp4_);
		_tmp4_ = _tmp7_;
	}
	_tmp8_ = g_date_time_format_iso8601 (_tmp4_);
	result = _tmp8_;
	_g_date_time_unref0 (_tmp4_);
	_g_date_time_unref0 (parsed);
	_g_free0 (raw);
	return result;
}

void
proton_plus_providers_sources_release_source_support_add_variants (ProtonPlusModelsRelease* release,
                                                                   GeeIterable* variants)
{
	g_return_if_fail (release != NULL);
	g_return_if_fail (variants != NULL);
	{
		GeeIterator* _variant_it = NULL;
		GeeIterator* _tmp0_;
		_tmp0_ = gee_iterable_iterator (variants);
		_variant_it = _tmp0_;
		while (TRUE) {
			GeeIterator* _tmp1_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeIterator* _tmp2_;
			gpointer _tmp3_;
			GeeLinkedList* _tmp4_;
			GeeLinkedList* _tmp5_;
			ProtonPlusModelsVariant* _tmp6_;
			_tmp1_ = _variant_it;
			if (!gee_iterator_next (_tmp1_)) {
				break;
			}
			_tmp2_ = _variant_it;
			_tmp3_ = gee_iterator_get (_tmp2_);
			variant = (ProtonPlusModelsVariant*) _tmp3_;
			_tmp4_ = proton_plus_models_release_get_variants (release);
			_tmp5_ = _tmp4_;
			_tmp6_ = variant;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp5_, _tmp6_);
			_g_object_unref0 (variant);
		}
		_g_object_unref0 (_variant_it);
	}
}

ProtonPlusProvidersSourcesReleaseSourceSupport*
proton_plus_providers_sources_release_source_support_construct (GType object_type)
{
	ProtonPlusProvidersSourcesReleaseSourceSupport * self = NULL;
	self = (ProtonPlusProvidersSourcesReleaseSourceSupport*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusProvidersSourcesReleaseSourceSupport*
proton_plus_providers_sources_release_source_support_new (void)
{
	return proton_plus_providers_sources_release_source_support_construct (PROTON_PLUS_PROVIDERS_SOURCES_TYPE_RELEASE_SOURCE_SUPPORT);
}

static void
proton_plus_providers_sources_release_source_support_class_init (ProtonPlusProvidersSourcesReleaseSourceSupportClass * klass,
                                                                 gpointer klass_data)
{
	proton_plus_providers_sources_release_source_support_parent_class = g_type_class_peek_parent (klass);
}

static void
proton_plus_providers_sources_release_source_support_instance_init (ProtonPlusProvidersSourcesReleaseSourceSupport * self,
                                                                    gpointer klass)
{
}

static GType
proton_plus_providers_sources_release_source_support_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusProvidersSourcesReleaseSourceSupportClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_providers_sources_release_source_support_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusProvidersSourcesReleaseSourceSupport), 0, (GInstanceInitFunc) proton_plus_providers_sources_release_source_support_instance_init, NULL };
	GType proton_plus_providers_sources_release_source_support_type_id;
	proton_plus_providers_sources_release_source_support_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusProvidersSourcesReleaseSourceSupport", &g_define_type_info, 0);
	return proton_plus_providers_sources_release_source_support_type_id;
}

GType
proton_plus_providers_sources_release_source_support_get_type (void)
{
	static volatile gsize proton_plus_providers_sources_release_source_support_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_providers_sources_release_source_support_type_id__once)) {
		GType proton_plus_providers_sources_release_source_support_type_id;
		proton_plus_providers_sources_release_source_support_type_id = proton_plus_providers_sources_release_source_support_get_type_once ();
		g_once_init_leave (&proton_plus_providers_sources_release_source_support_type_id__once, proton_plus_providers_sources_release_source_support_type_id);
	}
	return proton_plus_providers_sources_release_source_support_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

