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

#include "protonplus_core.h"
#include <gee.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <json-glib/json-glib.h>
#include <glib/gstdio.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  {
	PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_0_PROPERTY,
	PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_RELEASES_PROPERTY,
	PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_PAGE_PROPERTY,
	PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_HAS_MORE_PROPERTY,
	PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_LAST_UPDATED_PROPERTY,
	PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_NUM_PROPERTIES
};
static GParamSpec* proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_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))
enum  {
	PROTON_PLUS_MODELS_RELEASE_CATALOG_CACHE_0_PROPERTY,
	PROTON_PLUS_MODELS_RELEASE_CATALOG_CACHE_NUM_PROPERTIES
};
static GParamSpec* proton_plus_models_release_catalog_cache_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_CACHE_NUM_PROPERTIES];
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
typedef struct _ProtonPlusModelsReleaseCatalogCacheSaveData ProtonPlusModelsReleaseCatalogCacheSaveData;
typedef struct _ProtonPlusModelsReleaseCatalogCacheLoadData ProtonPlusModelsReleaseCatalogCacheLoadData;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

struct _ProtonPlusModelsReleaseCatalogSnapshotPrivate {
	GeeLinkedList* _releases;
	gint _page;
	gboolean _has_more;
	gchar* _last_updated;
};

struct _ProtonPlusModelsReleaseCatalogCachePrivate {
	gchar* tool_id;
	gchar* tool_title;
};

struct _ProtonPlusModelsReleaseCatalogCacheSaveData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ProtonPlusModelsReleaseCatalogCache* self;
	ProtonPlusModelsReleaseCatalogSnapshot* snapshot;
	JsonObject* root_obj;
	JsonObject* _tmp0_;
	JsonObject* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	JsonObject* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	JsonObject* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	JsonArray* releases_array;
	JsonArray* _tmp10_;
	GeeLinkedList* _release_list;
	GeeLinkedList* _tmp11_;
	GeeLinkedList* _tmp12_;
	gint _release_size;
	GeeLinkedList* _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	gint _release_index;
	gint _tmp16_;
	gint _tmp17_;
	ProtonPlusModelsRelease* release;
	GeeLinkedList* _tmp18_;
	gpointer _tmp19_;
	JsonArray* _tmp20_;
	ProtonPlusModelsRelease* _tmp21_;
	JsonObject* _tmp22_;
	JsonObject* _tmp23_;
	JsonArray* _tmp24_;
	JsonArray* _tmp25_;
	JsonGenerator* generator;
	JsonGenerator* _tmp26_;
	JsonNode* root_node;
	JsonNode* _tmp27_;
	JsonNode* _tmp28_;
	JsonObject* _tmp29_;
	JsonGenerator* _tmp30_;
	JsonNode* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	JsonGenerator* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gboolean _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
};

struct _ProtonPlusModelsReleaseCatalogCacheLoadData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ProtonPlusModelsReleaseCatalogCache* self;
	ProtonPlusModelsReleaseCatalogSnapshot* result;
	gchar* cache_file;
	gchar* _tmp0_;
	gchar* legacy_cache_file;
	gchar* _tmp1_;
	gboolean loading_legacy_cache;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* json;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	JsonNode* root_node;
	const gchar* _tmp9_;
	JsonNode* _tmp10_;
	gboolean _tmp11_;
	JsonNode* _tmp12_;
	JsonNode* _tmp13_;
	JsonObject* root_obj;
	JsonNode* _tmp14_;
	JsonObject* _tmp15_;
	JsonObject* _tmp16_;
	JsonObject* _tmp17_;
	JsonNode* releases_node;
	JsonObject* _tmp18_;
	JsonNode* _tmp19_;
	JsonNode* _tmp20_;
	gboolean _tmp21_;
	JsonNode* _tmp22_;
	JsonNode* _tmp23_;
	GeeLinkedList* releases;
	GeeLinkedList* _tmp24_;
	JsonArray* releases_array;
	JsonNode* _tmp25_;
	JsonArray* _tmp26_;
	JsonArray* _tmp27_;
	gint i;
	gboolean _tmp28_;
	gint _tmp29_;
	JsonArray* _tmp30_;
	JsonObject* release_obj;
	JsonArray* _tmp31_;
	JsonObject* _tmp32_;
	JsonObject* _tmp33_;
	JsonObject* _tmp34_;
	ProtonPlusModelsRelease* release;
	JsonObject* _tmp35_;
	ProtonPlusModelsRelease* _tmp36_;
	ProtonPlusModelsRelease* _tmp37_;
	GeeLinkedList* _tmp38_;
	ProtonPlusModelsRelease* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	const gchar* _tmp42_;
	gboolean _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	const gchar* _tmp46_;
	GeeLinkedList* _tmp47_;
	JsonObject* _tmp48_;
	JsonObject* _tmp49_;
	JsonObject* _tmp50_;
	const gchar* _tmp51_;
	ProtonPlusModelsReleaseCatalogSnapshot* _tmp52_;
};

static gint ProtonPlusModelsReleaseCatalogSnapshot_private_offset;
static gpointer proton_plus_models_release_catalog_snapshot_parent_class = NULL;
static gint ProtonPlusModelsReleaseCatalogCache_private_offset;
static gpointer proton_plus_models_release_catalog_cache_parent_class = NULL;

static void proton_plus_models_release_catalog_snapshot_finalize (GObject * obj);
static GType proton_plus_models_release_catalog_snapshot_get_type_once (void);
static void _vala_proton_plus_models_release_catalog_snapshot_get_property (GObject * object,
                                                                     guint property_id,
                                                                     GValue * value,
                                                                     GParamSpec * pspec);
static void _vala_proton_plus_models_release_catalog_snapshot_set_property (GObject * object,
                                                                     guint property_id,
                                                                     const GValue * value,
                                                                     GParamSpec * pspec);
static void proton_plus_models_release_catalog_cache_save_data_free (gpointer _data);
static gboolean proton_plus_models_release_catalog_cache_save_co (ProtonPlusModelsReleaseCatalogCacheSaveData* _data_);
static gchar* proton_plus_models_release_catalog_cache_get_cache_file (ProtonPlusModelsReleaseCatalogCache* self);
static gchar* proton_plus_models_release_catalog_cache_get_legacy_cache_file (ProtonPlusModelsReleaseCatalogCache* self);
static void _vala_JsonNode_free (JsonNode* self);
static void proton_plus_models_release_catalog_cache_load_data_free (gpointer _data);
static gboolean proton_plus_models_release_catalog_cache_load_co (ProtonPlusModelsReleaseCatalogCacheLoadData* _data_);
static JsonNode* proton_plus_models_release_catalog_cache_parse_cache_json (ProtonPlusModelsReleaseCatalogCache* self,
                                                                     const gchar* json);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void proton_plus_models_release_catalog_cache_finalize (GObject * obj);
static GType proton_plus_models_release_catalog_cache_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
proton_plus_models_release_catalog_snapshot_get_instance_private (ProtonPlusModelsReleaseCatalogSnapshot* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusModelsReleaseCatalogSnapshot_private_offset);
}

ProtonPlusModelsReleaseCatalogSnapshot*
proton_plus_models_release_catalog_snapshot_construct (GType object_type,
                                                       GeeLinkedList* releases,
                                                       gint page,
                                                       gboolean has_more,
                                                       const gchar* last_updated)
{
	ProtonPlusModelsReleaseCatalogSnapshot * self = NULL;
	g_return_val_if_fail (releases != NULL, NULL);
	g_return_val_if_fail (last_updated != NULL, NULL);
	self = (ProtonPlusModelsReleaseCatalogSnapshot*) g_object_new (object_type, "releases", releases, "page", page, "has-more", has_more, "last-updated", last_updated, NULL);
	return self;
}

ProtonPlusModelsReleaseCatalogSnapshot*
proton_plus_models_release_catalog_snapshot_new (GeeLinkedList* releases,
                                                 gint page,
                                                 gboolean has_more,
                                                 const gchar* last_updated)
{
	return proton_plus_models_release_catalog_snapshot_construct (PROTON_PLUS_MODELS_TYPE_RELEASE_CATALOG_SNAPSHOT, releases, page, has_more, last_updated);
}

GeeLinkedList*
proton_plus_models_release_catalog_snapshot_get_releases (ProtonPlusModelsReleaseCatalogSnapshot* self)
{
	GeeLinkedList* result;
	GeeLinkedList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_releases;
	result = _tmp0_;
	return result;
}

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

static void
proton_plus_models_release_catalog_snapshot_set_releases (ProtonPlusModelsReleaseCatalogSnapshot* self,
                                                          GeeLinkedList* value)
{
	GeeLinkedList* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_release_catalog_snapshot_get_releases (self);
	if (old_value != value) {
		GeeLinkedList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_releases);
		self->priv->_releases = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_RELEASES_PROPERTY]);
	}
}

gint
proton_plus_models_release_catalog_snapshot_get_page (ProtonPlusModelsReleaseCatalogSnapshot* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_page;
	return result;
}

static void
proton_plus_models_release_catalog_snapshot_set_page (ProtonPlusModelsReleaseCatalogSnapshot* self,
                                                      gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_release_catalog_snapshot_get_page (self);
	if (old_value != value) {
		self->priv->_page = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_PAGE_PROPERTY]);
	}
}

gboolean
proton_plus_models_release_catalog_snapshot_get_has_more (ProtonPlusModelsReleaseCatalogSnapshot* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_has_more;
	return result;
}

static void
proton_plus_models_release_catalog_snapshot_set_has_more (ProtonPlusModelsReleaseCatalogSnapshot* self,
                                                          gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_release_catalog_snapshot_get_has_more (self);
	if (old_value != value) {
		self->priv->_has_more = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_HAS_MORE_PROPERTY]);
	}
}

const gchar*
proton_plus_models_release_catalog_snapshot_get_last_updated (ProtonPlusModelsReleaseCatalogSnapshot* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_last_updated;
	result = _tmp0_;
	return result;
}

static void
proton_plus_models_release_catalog_snapshot_set_last_updated (ProtonPlusModelsReleaseCatalogSnapshot* self,
                                                              const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_release_catalog_snapshot_get_last_updated (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_last_updated);
		self->priv->_last_updated = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_LAST_UPDATED_PROPERTY]);
	}
}

static void
proton_plus_models_release_catalog_snapshot_class_init (ProtonPlusModelsReleaseCatalogSnapshotClass * klass,
                                                        gpointer klass_data)
{
	proton_plus_models_release_catalog_snapshot_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusModelsReleaseCatalogSnapshot_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_models_release_catalog_snapshot_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_models_release_catalog_snapshot_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_models_release_catalog_snapshot_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_RELEASES_PROPERTY, proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_RELEASES_PROPERTY] = g_param_spec_object ("releases", "releases", "releases", GEE_TYPE_LINKED_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_PAGE_PROPERTY, proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_PAGE_PROPERTY] = g_param_spec_int ("page", "page", "page", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_HAS_MORE_PROPERTY, proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_HAS_MORE_PROPERTY] = g_param_spec_boolean ("has-more", "has-more", "has-more", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_LAST_UPDATED_PROPERTY, proton_plus_models_release_catalog_snapshot_properties[PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_LAST_UPDATED_PROPERTY] = g_param_spec_string ("last-updated", "last-updated", "last-updated", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
proton_plus_models_release_catalog_snapshot_instance_init (ProtonPlusModelsReleaseCatalogSnapshot * self,
                                                           gpointer klass)
{
	self->priv = proton_plus_models_release_catalog_snapshot_get_instance_private (self);
}

static void
proton_plus_models_release_catalog_snapshot_finalize (GObject * obj)
{
	ProtonPlusModelsReleaseCatalogSnapshot * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_MODELS_TYPE_RELEASE_CATALOG_SNAPSHOT, ProtonPlusModelsReleaseCatalogSnapshot);
	_g_object_unref0 (self->priv->_releases);
	_g_free0 (self->priv->_last_updated);
	G_OBJECT_CLASS (proton_plus_models_release_catalog_snapshot_parent_class)->finalize (obj);
}

static GType
proton_plus_models_release_catalog_snapshot_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusModelsReleaseCatalogSnapshotClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_models_release_catalog_snapshot_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusModelsReleaseCatalogSnapshot), 0, (GInstanceInitFunc) proton_plus_models_release_catalog_snapshot_instance_init, NULL };
	GType proton_plus_models_release_catalog_snapshot_type_id;
	proton_plus_models_release_catalog_snapshot_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusModelsReleaseCatalogSnapshot", &g_define_type_info, 0);
	ProtonPlusModelsReleaseCatalogSnapshot_private_offset = g_type_add_instance_private (proton_plus_models_release_catalog_snapshot_type_id, sizeof (ProtonPlusModelsReleaseCatalogSnapshotPrivate));
	return proton_plus_models_release_catalog_snapshot_type_id;
}

GType
proton_plus_models_release_catalog_snapshot_get_type (void)
{
	static volatile gsize proton_plus_models_release_catalog_snapshot_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_models_release_catalog_snapshot_type_id__once)) {
		GType proton_plus_models_release_catalog_snapshot_type_id;
		proton_plus_models_release_catalog_snapshot_type_id = proton_plus_models_release_catalog_snapshot_get_type_once ();
		g_once_init_leave (&proton_plus_models_release_catalog_snapshot_type_id__once, proton_plus_models_release_catalog_snapshot_type_id);
	}
	return proton_plus_models_release_catalog_snapshot_type_id__once;
}

static void
_vala_proton_plus_models_release_catalog_snapshot_get_property (GObject * object,
                                                                guint property_id,
                                                                GValue * value,
                                                                GParamSpec * pspec)
{
	ProtonPlusModelsReleaseCatalogSnapshot * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_MODELS_TYPE_RELEASE_CATALOG_SNAPSHOT, ProtonPlusModelsReleaseCatalogSnapshot);
	switch (property_id) {
		case PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_RELEASES_PROPERTY:
		g_value_set_object (value, proton_plus_models_release_catalog_snapshot_get_releases (self));
		break;
		case PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_PAGE_PROPERTY:
		g_value_set_int (value, proton_plus_models_release_catalog_snapshot_get_page (self));
		break;
		case PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_HAS_MORE_PROPERTY:
		g_value_set_boolean (value, proton_plus_models_release_catalog_snapshot_get_has_more (self));
		break;
		case PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_LAST_UPDATED_PROPERTY:
		g_value_set_string (value, proton_plus_models_release_catalog_snapshot_get_last_updated (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_models_release_catalog_snapshot_set_property (GObject * object,
                                                                guint property_id,
                                                                const GValue * value,
                                                                GParamSpec * pspec)
{
	ProtonPlusModelsReleaseCatalogSnapshot * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_MODELS_TYPE_RELEASE_CATALOG_SNAPSHOT, ProtonPlusModelsReleaseCatalogSnapshot);
	switch (property_id) {
		case PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_RELEASES_PROPERTY:
		proton_plus_models_release_catalog_snapshot_set_releases (self, g_value_get_object (value));
		break;
		case PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_PAGE_PROPERTY:
		proton_plus_models_release_catalog_snapshot_set_page (self, g_value_get_int (value));
		break;
		case PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_HAS_MORE_PROPERTY:
		proton_plus_models_release_catalog_snapshot_set_has_more (self, g_value_get_boolean (value));
		break;
		case PROTON_PLUS_MODELS_RELEASE_CATALOG_SNAPSHOT_LAST_UPDATED_PROPERTY:
		proton_plus_models_release_catalog_snapshot_set_last_updated (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
proton_plus_models_release_catalog_cache_get_instance_private (ProtonPlusModelsReleaseCatalogCache* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusModelsReleaseCatalogCache_private_offset);
}

ProtonPlusModelsReleaseCatalogCache*
proton_plus_models_release_catalog_cache_construct (GType object_type,
                                                    const gchar* tool_id,
                                                    const gchar* tool_title)
{
	ProtonPlusModelsReleaseCatalogCache * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (tool_id != NULL, NULL);
	g_return_val_if_fail (tool_title != NULL, NULL);
	self = (ProtonPlusModelsReleaseCatalogCache*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (tool_id);
	_g_free0 (self->priv->tool_id);
	self->priv->tool_id = _tmp0_;
	_tmp1_ = g_strdup (tool_title);
	_g_free0 (self->priv->tool_title);
	self->priv->tool_title = _tmp1_;
	return self;
}

ProtonPlusModelsReleaseCatalogCache*
proton_plus_models_release_catalog_cache_new (const gchar* tool_id,
                                              const gchar* tool_title)
{
	return proton_plus_models_release_catalog_cache_construct (PROTON_PLUS_MODELS_TYPE_RELEASE_CATALOG_CACHE, tool_id, tool_title);
}

static void
proton_plus_models_release_catalog_cache_save_data_free (gpointer _data)
{
	ProtonPlusModelsReleaseCatalogCacheSaveData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->snapshot);
	_g_object_unref0 (_data_->self);
	g_slice_free (ProtonPlusModelsReleaseCatalogCacheSaveData, _data_);
}

void
proton_plus_models_release_catalog_cache_save (ProtonPlusModelsReleaseCatalogCache* self,
                                               ProtonPlusModelsReleaseCatalogSnapshot* snapshot,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	ProtonPlusModelsReleaseCatalogCacheSaveData* _data_;
	ProtonPlusModelsReleaseCatalogCache* _tmp0_;
	ProtonPlusModelsReleaseCatalogSnapshot* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (snapshot != NULL);
	_data_ = g_slice_new0 (ProtonPlusModelsReleaseCatalogCacheSaveData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_models_release_catalog_cache_save_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (snapshot);
	_g_object_unref0 (_data_->snapshot);
	_data_->snapshot = _tmp1_;
	proton_plus_models_release_catalog_cache_save_co (_data_);
}

void
proton_plus_models_release_catalog_cache_save_finish (ProtonPlusModelsReleaseCatalogCache* self,
                                                      GAsyncResult* _res_)
{
	ProtonPlusModelsReleaseCatalogCacheSaveData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

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

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

static gboolean
proton_plus_models_release_catalog_cache_save_co (ProtonPlusModelsReleaseCatalogCacheSaveData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = json_object_new ();
	_data_->root_obj = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->root_obj;
	_data_->_tmp2_ = proton_plus_models_release_catalog_snapshot_get_last_updated (_data_->snapshot);
	_data_->_tmp3_ = _data_->_tmp2_;
	json_object_set_string_member (_data_->_tmp1_, "last_updated", _data_->_tmp3_);
	_data_->_tmp4_ = _data_->root_obj;
	_data_->_tmp5_ = proton_plus_models_release_catalog_snapshot_get_page (_data_->snapshot);
	_data_->_tmp6_ = _data_->_tmp5_;
	json_object_set_int_member (_data_->_tmp4_, "page", (gint64) _data_->_tmp6_);
	_data_->_tmp7_ = _data_->root_obj;
	_data_->_tmp8_ = proton_plus_models_release_catalog_snapshot_get_has_more (_data_->snapshot);
	_data_->_tmp9_ = _data_->_tmp8_;
	json_object_set_boolean_member (_data_->_tmp7_, "has_more", _data_->_tmp9_);
	_data_->_tmp10_ = json_array_new ();
	_data_->releases_array = _data_->_tmp10_;
	{
		_data_->_tmp11_ = proton_plus_models_release_catalog_snapshot_get_releases (_data_->snapshot);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_release_list = _data_->_tmp12_;
		_data_->_tmp13_ = _data_->_release_list;
		_data_->_tmp14_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp13_);
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_release_size = _data_->_tmp15_;
		_data_->_release_index = -1;
		while (TRUE) {
			_data_->_release_index = _data_->_release_index + 1;
			_data_->_tmp16_ = _data_->_release_index;
			_data_->_tmp17_ = _data_->_release_size;
			if (!(_data_->_tmp16_ < _data_->_tmp17_)) {
				break;
			}
			_data_->_tmp18_ = _data_->_release_list;
			_data_->_tmp19_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp18_, _data_->_release_index);
			_data_->release = (ProtonPlusModelsRelease*) _data_->_tmp19_;
			_data_->_tmp20_ = _data_->releases_array;
			_data_->_tmp21_ = _data_->release;
			_data_->_tmp22_ = proton_plus_models_release_to_json (_data_->_tmp21_);
			json_array_add_object_element (_data_->_tmp20_, _data_->_tmp22_);
			_g_object_unref0 (_data_->release);
		}
	}
	_data_->_tmp23_ = _data_->root_obj;
	_data_->_tmp24_ = _data_->releases_array;
	_data_->_tmp25_ = _json_array_ref0 (_data_->_tmp24_);
	json_object_set_array_member (_data_->_tmp23_, "releases", _data_->_tmp25_);
	_data_->_tmp26_ = json_generator_new ();
	_data_->generator = _data_->_tmp26_;
	_data_->_tmp27_ = json_node_new (JSON_NODE_OBJECT);
	_data_->root_node = _data_->_tmp27_;
	_data_->_tmp28_ = _data_->root_node;
	_data_->_tmp29_ = _data_->root_obj;
	json_node_set_object (_data_->_tmp28_, _data_->_tmp29_);
	_data_->_tmp30_ = _data_->generator;
	_data_->_tmp31_ = _data_->root_node;
	json_generator_set_root (_data_->_tmp30_, _data_->_tmp31_);
	_data_->_tmp32_ = proton_plus_models_release_catalog_cache_get_cache_file (_data_->self);
	_data_->_tmp33_ = _data_->_tmp32_;
	_data_->_tmp34_ = _data_->generator;
	_data_->_tmp35_ = json_generator_to_data (_data_->_tmp34_, NULL);
	_data_->_tmp36_ = _data_->_tmp35_;
	_data_->_tmp37_ = proton_plus_utils_filesystem_modify_file (_data_->_tmp33_, _data_->_tmp36_);
	_g_free0 (_data_->_tmp36_);
	_g_free0 (_data_->_tmp33_);
	if (_data_->_tmp37_) {
		_data_->_tmp38_ = proton_plus_models_release_catalog_cache_get_legacy_cache_file (_data_->self);
		_data_->_tmp39_ = _data_->_tmp38_;
		proton_plus_utils_filesystem_delete_file (_data_->_tmp39_);
		_g_free0 (_data_->_tmp39_);
	}
	__vala_JsonNode_free0 (_data_->root_node);
	_g_object_unref0 (_data_->generator);
	_json_array_unref0 (_data_->releases_array);
	_json_object_unref0 (_data_->root_obj);
	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
proton_plus_models_release_catalog_cache_load_data_free (gpointer _data)
{
	ProtonPlusModelsReleaseCatalogCacheLoadData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ProtonPlusModelsReleaseCatalogCacheLoadData, _data_);
}

void
proton_plus_models_release_catalog_cache_load (ProtonPlusModelsReleaseCatalogCache* self,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	ProtonPlusModelsReleaseCatalogCacheLoadData* _data_;
	ProtonPlusModelsReleaseCatalogCache* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (ProtonPlusModelsReleaseCatalogCacheLoadData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_models_release_catalog_cache_load_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	proton_plus_models_release_catalog_cache_load_co (_data_);
}

ProtonPlusModelsReleaseCatalogSnapshot*
proton_plus_models_release_catalog_cache_load_finish (ProtonPlusModelsReleaseCatalogCache* self,
                                                      GAsyncResult* _res_)
{
	ProtonPlusModelsReleaseCatalogSnapshot* result;
	ProtonPlusModelsReleaseCatalogCacheLoadData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static gpointer
_json_object_ref0 (gpointer self)
{
	return self ? json_object_ref (self) : 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 gboolean
proton_plus_models_release_catalog_cache_load_co (ProtonPlusModelsReleaseCatalogCacheLoadData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = proton_plus_models_release_catalog_cache_get_cache_file (_data_->self);
	_data_->cache_file = _data_->_tmp0_;
	_data_->_tmp1_ = proton_plus_models_release_catalog_cache_get_legacy_cache_file (_data_->self);
	_data_->legacy_cache_file = _data_->_tmp1_;
	_data_->loading_legacy_cache = FALSE;
	_data_->_tmp2_ = _data_->cache_file;
	if (!g_file_test (_data_->_tmp2_, G_FILE_TEST_EXISTS)) {
		_data_->_tmp3_ = _data_->legacy_cache_file;
		if (!g_file_test (_data_->_tmp3_, G_FILE_TEST_EXISTS)) {
			_data_->result = NULL;
			_g_free0 (_data_->legacy_cache_file);
			_g_free0 (_data_->cache_file);
			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;
		}
		_data_->_tmp4_ = _data_->legacy_cache_file;
		_data_->_tmp5_ = g_strdup (_data_->_tmp4_);
		_g_free0 (_data_->cache_file);
		_data_->cache_file = _data_->_tmp5_;
		_data_->loading_legacy_cache = TRUE;
	}
	_data_->_tmp6_ = _data_->cache_file;
	_data_->_tmp7_ = proton_plus_utils_filesystem_get_file_content (_data_->_tmp6_, FALSE);
	_data_->json = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->json;
	if (g_strcmp0 (_data_->_tmp8_, "") == 0) {
		_data_->result = NULL;
		_g_free0 (_data_->json);
		_g_free0 (_data_->legacy_cache_file);
		_g_free0 (_data_->cache_file);
		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;
	}
	_data_->_tmp9_ = _data_->json;
	_data_->_tmp10_ = proton_plus_models_release_catalog_cache_parse_cache_json (_data_->self, _data_->_tmp9_);
	_data_->root_node = _data_->_tmp10_;
	_data_->_tmp12_ = _data_->root_node;
	if (_data_->_tmp12_ == NULL) {
		_data_->_tmp11_ = TRUE;
	} else {
		_data_->_tmp13_ = _data_->root_node;
		_data_->_tmp11_ = json_node_get_node_type (_data_->_tmp13_) != JSON_NODE_OBJECT;
	}
	if (_data_->_tmp11_) {
		_data_->result = NULL;
		__vala_JsonNode_free0 (_data_->root_node);
		_g_free0 (_data_->json);
		_g_free0 (_data_->legacy_cache_file);
		_g_free0 (_data_->cache_file);
		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;
	}
	_data_->_tmp14_ = _data_->root_node;
	_data_->_tmp15_ = json_node_get_object (_data_->_tmp14_);
	_data_->_tmp16_ = _json_object_ref0 (_data_->_tmp15_);
	_data_->root_obj = _data_->_tmp16_;
	_data_->_tmp17_ = _data_->root_obj;
	if (!json_object_has_member (_data_->_tmp17_, "releases")) {
		_data_->result = NULL;
		_json_object_unref0 (_data_->root_obj);
		__vala_JsonNode_free0 (_data_->root_node);
		_g_free0 (_data_->json);
		_g_free0 (_data_->legacy_cache_file);
		_g_free0 (_data_->cache_file);
		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;
	}
	_data_->_tmp18_ = _data_->root_obj;
	_data_->_tmp19_ = json_object_get_member (_data_->_tmp18_, "releases");
	_data_->_tmp20_ = __vala_JsonNode_copy0 (_data_->_tmp19_);
	_data_->releases_node = _data_->_tmp20_;
	_data_->_tmp22_ = _data_->releases_node;
	if (_data_->_tmp22_ == NULL) {
		_data_->_tmp21_ = TRUE;
	} else {
		_data_->_tmp23_ = _data_->releases_node;
		_data_->_tmp21_ = json_node_get_node_type (_data_->_tmp23_) != JSON_NODE_ARRAY;
	}
	if (_data_->_tmp21_) {
		_data_->result = NULL;
		__vala_JsonNode_free0 (_data_->releases_node);
		_json_object_unref0 (_data_->root_obj);
		__vala_JsonNode_free0 (_data_->root_node);
		_g_free0 (_data_->json);
		_g_free0 (_data_->legacy_cache_file);
		_g_free0 (_data_->cache_file);
		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;
	}
	_data_->_tmp24_ = gee_linked_list_new (PROTON_PLUS_MODELS_TYPE_RELEASE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data_->releases = _data_->_tmp24_;
	_data_->_tmp25_ = _data_->releases_node;
	_data_->_tmp26_ = json_node_get_array (_data_->_tmp25_);
	_data_->_tmp27_ = _json_array_ref0 (_data_->_tmp26_);
	_data_->releases_array = _data_->_tmp27_;
	{
		_data_->i = 0;
		{
			_data_->_tmp28_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp28_) {
					_data_->_tmp29_ = _data_->i;
					_data_->i = _data_->_tmp29_ + 1;
				}
				_data_->_tmp28_ = FALSE;
				_data_->_tmp30_ = _data_->releases_array;
				if (!(((guint) _data_->i) < json_array_get_length (_data_->_tmp30_))) {
					break;
				}
				_data_->_tmp31_ = _data_->releases_array;
				_data_->_tmp32_ = json_array_get_object_element (_data_->_tmp31_, (guint) _data_->i);
				_data_->_tmp33_ = _json_object_ref0 (_data_->_tmp32_);
				_data_->release_obj = _data_->_tmp33_;
				_data_->_tmp34_ = _data_->release_obj;
				if (_data_->_tmp34_ == NULL) {
					_json_object_unref0 (_data_->release_obj);
					continue;
				}
				_data_->_tmp35_ = _data_->release_obj;
				_data_->_tmp36_ = proton_plus_models_release_from_json (_data_->_tmp35_);
				_data_->release = _data_->_tmp36_;
				_data_->_tmp37_ = _data_->release;
				if (_data_->_tmp37_ != NULL) {
					_data_->_tmp38_ = _data_->releases;
					_data_->_tmp39_ = _data_->release;
					gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp38_, _data_->_tmp39_);
				}
				_g_object_unref0 (_data_->release);
				_json_object_unref0 (_data_->release_obj);
			}
		}
	}
	if (_data_->loading_legacy_cache) {
		_data_->_tmp40_ = proton_plus_models_release_catalog_cache_get_cache_file (_data_->self);
		_data_->_tmp41_ = _data_->_tmp40_;
		_data_->_tmp42_ = _data_->json;
		_data_->_tmp43_ = proton_plus_utils_filesystem_modify_file (_data_->_tmp41_, _data_->_tmp42_);
		_g_free0 (_data_->_tmp41_);
		if (_data_->_tmp43_) {
			_data_->_tmp44_ = _data_->legacy_cache_file;
			proton_plus_utils_filesystem_delete_file (_data_->_tmp44_);
		}
	} else {
		_data_->_tmp45_ = _data_->legacy_cache_file;
		if (g_file_test (_data_->_tmp45_, G_FILE_TEST_EXISTS)) {
			_data_->_tmp46_ = _data_->legacy_cache_file;
			proton_plus_utils_filesystem_delete_file (_data_->_tmp46_);
		}
	}
	_data_->_tmp47_ = _data_->releases;
	_data_->_tmp48_ = _data_->root_obj;
	_data_->_tmp49_ = _data_->root_obj;
	_data_->_tmp50_ = _data_->root_obj;
	_data_->_tmp51_ = json_object_get_string_member_with_default (_data_->_tmp50_, "last_updated", "");
	_data_->_tmp52_ = proton_plus_models_release_catalog_snapshot_new (_data_->_tmp47_, (gint) json_object_get_int_member_with_default (_data_->_tmp48_, "page", (gint64) 1), json_object_get_boolean_member_with_default (_data_->_tmp49_, "has_more", FALSE), _data_->_tmp51_);
	_data_->result = _data_->_tmp52_;
	_json_array_unref0 (_data_->releases_array);
	_g_object_unref0 (_data_->releases);
	__vala_JsonNode_free0 (_data_->releases_node);
	_json_object_unref0 (_data_->root_obj);
	__vala_JsonNode_free0 (_data_->root_node);
	_g_free0 (_data_->json);
	_g_free0 (_data_->legacy_cache_file);
	_g_free0 (_data_->cache_file);
	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*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	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;
}

static gchar*
proton_plus_models_release_catalog_cache_get_cache_file (ProtonPlusModelsReleaseCatalogCache* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = proton_plus_globals_CACHE_PATH;
	_tmp1_ = self->priv->tool_id;
	_tmp2_ = string_replace (_tmp1_, "/", "_");
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat (_tmp3_, ".json", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_build_filename (_tmp0_, _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	result = _tmp7_;
	return result;
}

static gchar*
proton_plus_models_release_catalog_cache_get_legacy_cache_file (ProtonPlusModelsReleaseCatalogCache* self)
{
	gchar* safe_title = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->tool_title;
	_tmp1_ = string_replace (_tmp0_, ":", "_");
	_tmp2_ = _tmp1_;
	_tmp3_ = string_replace (_tmp2_, "/", "_");
	_tmp4_ = _tmp3_;
	_tmp5_ = string_replace (_tmp4_, ".", "_");
	_tmp6_ = _tmp5_;
	_tmp7_ = string_replace (_tmp6_, " ", "_");
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	safe_title = _tmp8_;
	_tmp9_ = proton_plus_globals_CACHE_PATH;
	_tmp10_ = g_strconcat (safe_title, ".json", NULL);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_build_filename (_tmp9_, _tmp11_, NULL);
	_tmp13_ = _tmp12_;
	_g_free0 (_tmp11_);
	result = _tmp13_;
	_g_free0 (safe_title);
	return result;
}

static JsonNode*
proton_plus_models_release_catalog_cache_parse_cache_json (ProtonPlusModelsReleaseCatalogCache* self,
                                                           const gchar* json)
{
	GError* _inner_error0_ = NULL;
	JsonNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (json != NULL, NULL);
	{
		JsonParser* parser = NULL;
		JsonParser* _tmp0_;
		JsonNode* _tmp1_;
		JsonNode* _tmp2_;
		_tmp0_ = json_parser_new ();
		parser = _tmp0_;
		json_parser_load_from_data (parser, json, (gssize) -1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (parser);
			goto __catch0_g_error;
		}
		_tmp1_ = json_parser_get_root (parser);
		_tmp2_ = __vala_JsonNode_copy0 (_tmp1_);
		result = _tmp2_;
		_g_object_unref0 (parser);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		return result;
	}
	__finally0:
	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;
}

static void
proton_plus_models_release_catalog_cache_class_init (ProtonPlusModelsReleaseCatalogCacheClass * klass,
                                                     gpointer klass_data)
{
	proton_plus_models_release_catalog_cache_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusModelsReleaseCatalogCache_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_models_release_catalog_cache_finalize;
}

static void
proton_plus_models_release_catalog_cache_instance_init (ProtonPlusModelsReleaseCatalogCache * self,
                                                        gpointer klass)
{
	self->priv = proton_plus_models_release_catalog_cache_get_instance_private (self);
}

static void
proton_plus_models_release_catalog_cache_finalize (GObject * obj)
{
	ProtonPlusModelsReleaseCatalogCache * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_MODELS_TYPE_RELEASE_CATALOG_CACHE, ProtonPlusModelsReleaseCatalogCache);
	_g_free0 (self->priv->tool_id);
	_g_free0 (self->priv->tool_title);
	G_OBJECT_CLASS (proton_plus_models_release_catalog_cache_parent_class)->finalize (obj);
}

static GType
proton_plus_models_release_catalog_cache_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusModelsReleaseCatalogCacheClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_models_release_catalog_cache_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusModelsReleaseCatalogCache), 0, (GInstanceInitFunc) proton_plus_models_release_catalog_cache_instance_init, NULL };
	GType proton_plus_models_release_catalog_cache_type_id;
	proton_plus_models_release_catalog_cache_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusModelsReleaseCatalogCache", &g_define_type_info, 0);
	ProtonPlusModelsReleaseCatalogCache_private_offset = g_type_add_instance_private (proton_plus_models_release_catalog_cache_type_id, sizeof (ProtonPlusModelsReleaseCatalogCachePrivate));
	return proton_plus_models_release_catalog_cache_type_id;
}

GType
proton_plus_models_release_catalog_cache_get_type (void)
{
	static volatile gsize proton_plus_models_release_catalog_cache_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_models_release_catalog_cache_type_id__once)) {
		GType proton_plus_models_release_catalog_cache_type_id;
		proton_plus_models_release_catalog_cache_type_id = proton_plus_models_release_catalog_cache_get_type_once ();
		g_once_init_leave (&proton_plus_models_release_catalog_cache_type_id__once, proton_plus_models_release_catalog_cache_type_id);
	}
	return proton_plus_models_release_catalog_cache_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;
}

