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

#include <glib-object.h>
#include <gee.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <glib/gstdio.h>
#include <json-glib/json-glib.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 PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER (proton_plus_models_download_manager_get_type ())
#define PROTON_PLUS_MODELS_DOWNLOAD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManager))
#define PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManagerClass))
#define PROTON_PLUS_MODELS_IS_DOWNLOAD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER))
#define PROTON_PLUS_MODELS_IS_DOWNLOAD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER))
#define PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManagerClass))

typedef struct _ProtonPlusModelsDownloadManager ProtonPlusModelsDownloadManager;
typedef struct _ProtonPlusModelsDownloadManagerClass ProtonPlusModelsDownloadManagerClass;
typedef struct _ProtonPlusModelsDownloadManagerPrivate ProtonPlusModelsDownloadManagerPrivate;

#define PROTON_PLUS_MODELS_TYPE_BASE_RELEASE (proton_plus_models_base_release_get_type ())
#define PROTON_PLUS_MODELS_BASE_RELEASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, ProtonPlusModelsBaseRelease))
#define PROTON_PLUS_MODELS_BASE_RELEASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, ProtonPlusModelsBaseReleaseClass))
#define PROTON_PLUS_MODELS_IS_BASE_RELEASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE))
#define PROTON_PLUS_MODELS_IS_BASE_RELEASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE))
#define PROTON_PLUS_MODELS_BASE_RELEASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, ProtonPlusModelsBaseReleaseClass))

typedef struct _ProtonPlusModelsBaseRelease ProtonPlusModelsBaseRelease;
typedef struct _ProtonPlusModelsBaseReleaseClass ProtonPlusModelsBaseReleaseClass;
enum  {
	PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_0_PROPERTY,
	PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_ACTIVE_DOWNLOADS_PROPERTY,
	PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_HISTORY_PROPERTY,
	PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_NUM_PROPERTIES
};
static GParamSpec* proton_plus_models_download_manager_properties[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_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))

#define PROTON_PLUS_MODELS_TYPE_RUNNER (proton_plus_models_runner_get_type ())
#define PROTON_PLUS_MODELS_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_RUNNER, ProtonPlusModelsRunner))
#define PROTON_PLUS_MODELS_RUNNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_RUNNER, ProtonPlusModelsRunnerClass))
#define PROTON_PLUS_MODELS_IS_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_RUNNER))
#define PROTON_PLUS_MODELS_IS_RUNNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_RUNNER))
#define PROTON_PLUS_MODELS_RUNNER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_RUNNER, ProtonPlusModelsRunnerClass))

typedef struct _ProtonPlusModelsRunner ProtonPlusModelsRunner;
typedef struct _ProtonPlusModelsRunnerClass ProtonPlusModelsRunnerClass;

#define PROTON_PLUS_MODELS_TYPE_GROUP (proton_plus_models_group_get_type ())
#define PROTON_PLUS_MODELS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_GROUP, ProtonPlusModelsGroup))
#define PROTON_PLUS_MODELS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_GROUP, ProtonPlusModelsGroupClass))
#define PROTON_PLUS_MODELS_IS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_GROUP))
#define PROTON_PLUS_MODELS_IS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_GROUP))
#define PROTON_PLUS_MODELS_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_GROUP, ProtonPlusModelsGroupClass))

typedef struct _ProtonPlusModelsGroup ProtonPlusModelsGroup;
typedef struct _ProtonPlusModelsGroupClass ProtonPlusModelsGroupClass;

#define PROTON_PLUS_MODELS_TYPE_LAUNCHER (proton_plus_models_launcher_get_type ())
#define PROTON_PLUS_MODELS_LAUNCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_LAUNCHER, ProtonPlusModelsLauncher))
#define PROTON_PLUS_MODELS_LAUNCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_LAUNCHER, ProtonPlusModelsLauncherClass))
#define PROTON_PLUS_MODELS_IS_LAUNCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_LAUNCHER))
#define PROTON_PLUS_MODELS_IS_LAUNCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_LAUNCHER))
#define PROTON_PLUS_MODELS_LAUNCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_LAUNCHER, ProtonPlusModelsLauncherClass))

typedef struct _ProtonPlusModelsLauncher ProtonPlusModelsLauncher;
typedef struct _ProtonPlusModelsLauncherClass ProtonPlusModelsLauncherClass;
typedef struct _ProtonPlusModelsLauncherPrivate ProtonPlusModelsLauncherPrivate;

#define PROTON_PLUS_MODELS_TYPE_GAME (proton_plus_models_game_get_type ())
#define PROTON_PLUS_MODELS_GAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_GAME, ProtonPlusModelsGame))
#define PROTON_PLUS_MODELS_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_GAME, ProtonPlusModelsGameClass))
#define PROTON_PLUS_MODELS_IS_GAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_GAME))
#define PROTON_PLUS_MODELS_IS_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_GAME))
#define PROTON_PLUS_MODELS_GAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_GAME, ProtonPlusModelsGameClass))

typedef struct _ProtonPlusModelsGame ProtonPlusModelsGame;
typedef struct _ProtonPlusModelsGameClass ProtonPlusModelsGameClass;

#define PROTON_PLUS_MODELS_TYPE_SIMPLE_RUNNER (proton_plus_models_simple_runner_get_type ())
#define PROTON_PLUS_MODELS_SIMPLE_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_SIMPLE_RUNNER, ProtonPlusModelsSimpleRunner))
#define PROTON_PLUS_MODELS_SIMPLE_RUNNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_SIMPLE_RUNNER, ProtonPlusModelsSimpleRunnerClass))
#define PROTON_PLUS_MODELS_IS_SIMPLE_RUNNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_SIMPLE_RUNNER))
#define PROTON_PLUS_MODELS_IS_SIMPLE_RUNNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_SIMPLE_RUNNER))
#define PROTON_PLUS_MODELS_SIMPLE_RUNNER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_SIMPLE_RUNNER, ProtonPlusModelsSimpleRunnerClass))

typedef struct _ProtonPlusModelsSimpleRunner ProtonPlusModelsSimpleRunner;
typedef struct _ProtonPlusModelsSimpleRunnerClass ProtonPlusModelsSimpleRunnerClass;
typedef enum  {
	PROTON_PLUS_MODELS_LAUNCHER_INSTALLATION_TYPES_SYSTEM,
	PROTON_PLUS_MODELS_LAUNCHER_INSTALLATION_TYPES_FLATPAK,
	PROTON_PLUS_MODELS_LAUNCHER_INSTALLATION_TYPES_SNAP
} ProtonPlusModelsLauncherInstallationTypes;

#define PROTON_PLUS_MODELS_LAUNCHER_TYPE_INSTALLATION_TYPES (proton_plus_models_launcher_installation_types_get_type ())
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#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 PROTON_PLUS_MODELS_RELEASES_TYPE_HISTORY (proton_plus_models_releases_history_get_type ())
#define PROTON_PLUS_MODELS_RELEASES_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_RELEASES_TYPE_HISTORY, ProtonPlusModelsReleasesHistory))
#define PROTON_PLUS_MODELS_RELEASES_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_RELEASES_TYPE_HISTORY, ProtonPlusModelsReleasesHistoryClass))
#define PROTON_PLUS_MODELS_RELEASES_IS_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_RELEASES_TYPE_HISTORY))
#define PROTON_PLUS_MODELS_RELEASES_IS_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_RELEASES_TYPE_HISTORY))
#define PROTON_PLUS_MODELS_RELEASES_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_RELEASES_TYPE_HISTORY, ProtonPlusModelsReleasesHistoryClass))

typedef struct _ProtonPlusModelsReleasesHistory ProtonPlusModelsReleasesHistory;
typedef struct _ProtonPlusModelsReleasesHistoryClass ProtonPlusModelsReleasesHistoryClass;
enum  {
	PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_ADDED_SIGNAL,
	PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_REMOVED_SIGNAL,
	PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_FINISHED_SIGNAL,
	PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_NUM_SIGNALS
};
static guint proton_plus_models_download_manager_signals[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_NUM_SIGNALS] = {0};

struct _ProtonPlusModelsDownloadManager {
	GObject parent_instance;
	ProtonPlusModelsDownloadManagerPrivate * priv;
};

struct _ProtonPlusModelsDownloadManagerClass {
	GObjectClass parent_class;
};

struct _ProtonPlusModelsDownloadManagerPrivate {
	GeeArrayList* _active_downloads;
	GeeArrayList* _history;
};

struct _ProtonPlusModelsLauncher {
	GObject parent_instance;
	ProtonPlusModelsLauncherPrivate * priv;
	gchar* title;
	gchar* icon_path;
	gchar* directory;
	gboolean installed;
	gboolean has_library_support;
	GList* games;
	GeeArrayList* compatibility_tools;
	ProtonPlusModelsGroup** groups;
	gint groups_length1;
	ProtonPlusModelsLauncherInstallationTypes installation_type;
};

struct _ProtonPlusModelsLauncherClass {
	GObjectClass parent_class;
	void (*load_game_library) (ProtonPlusModelsLauncher* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	gboolean (*load_game_library_finish) (ProtonPlusModelsLauncher* self, GAsyncResult* _res_);
	gint (*get_compatibility_tool_usage_count) (ProtonPlusModelsLauncher* self, const gchar* compatibility_tool_name);
};

static gint ProtonPlusModelsDownloadManager_private_offset;
static gpointer proton_plus_models_download_manager_parent_class = NULL;
static ProtonPlusModelsDownloadManager* proton_plus_models_download_manager__instance;
static ProtonPlusModelsDownloadManager* proton_plus_models_download_manager__instance = NULL;
VALA_EXTERN GSettings* proton_plus_globals_SETTINGS;
VALA_EXTERN gchar* proton_plus_globals_CONFIG_PATH;

VALA_EXTERN GType proton_plus_models_download_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsDownloadManager, g_object_unref)
VALA_EXTERN GType proton_plus_models_base_release_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsBaseRelease, g_object_unref)
VALA_EXTERN gboolean proton_plus_models_download_manager_is_downloading (ProtonPlusModelsDownloadManager* self,
                                                             ProtonPlusModelsBaseRelease* release);
VALA_EXTERN ProtonPlusModelsBaseRelease* proton_plus_models_download_manager_get_active_download (ProtonPlusModelsDownloadManager* self,
                                                                                      ProtonPlusModelsBaseRelease* release);
VALA_EXTERN GeeArrayList* proton_plus_models_download_manager_get_active_downloads (ProtonPlusModelsDownloadManager* self);
VALA_EXTERN const gchar* proton_plus_models_base_release_get_download_url (ProtonPlusModelsBaseRelease* self);
VALA_EXTERN const gchar* proton_plus_models_base_release_get_title (ProtonPlusModelsBaseRelease* self);
static ProtonPlusModelsDownloadManager* proton_plus_models_download_manager_new (void);
static ProtonPlusModelsDownloadManager* proton_plus_models_download_manager_construct (GType object_type);
static void proton_plus_models_download_manager_set_active_downloads (ProtonPlusModelsDownloadManager* self,
                                                               GeeArrayList* value);
static void proton_plus_models_download_manager_set_history (ProtonPlusModelsDownloadManager* self,
                                                      GeeArrayList* value);
static void proton_plus_models_download_manager_load_history (ProtonPlusModelsDownloadManager* self);
static void ___lambda9_ (ProtonPlusModelsDownloadManager* self);
VALA_EXTERN void proton_plus_models_download_manager_clear_history (ProtonPlusModelsDownloadManager* self);
static void ____lambda9__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
VALA_EXTERN void proton_plus_models_download_manager_add_download (ProtonPlusModelsDownloadManager* self,
                                                       ProtonPlusModelsBaseRelease* release);
VALA_EXTERN GeeArrayList* proton_plus_models_download_manager_get_history (ProtonPlusModelsDownloadManager* self);
static void proton_plus_models_download_manager_save_history (ProtonPlusModelsDownloadManager* self);
VALA_EXTERN void proton_plus_models_download_manager_remove_download (ProtonPlusModelsDownloadManager* self,
                                                          ProtonPlusModelsBaseRelease* release);
VALA_EXTERN void proton_plus_models_download_manager_add_to_history (ProtonPlusModelsDownloadManager* self,
                                                         ProtonPlusModelsBaseRelease* release,
                                                         gboolean success);
VALA_EXTERN const gchar* proton_plus_models_base_release_get_displayed_title (ProtonPlusModelsBaseRelease* self);
VALA_EXTERN GType proton_plus_models_runner_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsRunner, g_object_unref)
VALA_EXTERN ProtonPlusModelsRunner* proton_plus_models_base_release_get_runner (ProtonPlusModelsBaseRelease* self);
VALA_EXTERN GType proton_plus_models_group_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsGroup, g_object_unref)
VALA_EXTERN ProtonPlusModelsGroup* proton_plus_models_runner_get_group (ProtonPlusModelsRunner* self);
VALA_EXTERN GType proton_plus_models_launcher_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsLauncher, g_object_unref)
VALA_EXTERN ProtonPlusModelsLauncher* proton_plus_models_group_get_launcher (ProtonPlusModelsGroup* self);
VALA_EXTERN GType proton_plus_models_game_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsGame, g_object_unref)
VALA_EXTERN GType proton_plus_models_simple_runner_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsSimpleRunner, g_object_unref)
VALA_EXTERN GType proton_plus_models_launcher_installation_types_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gboolean proton_plus_models_base_release_get_is_finished (ProtonPlusModelsBaseRelease* self);
VALA_EXTERN gboolean proton_plus_models_base_release_get_install_success (ProtonPlusModelsBaseRelease* self);
VALA_EXTERN gboolean proton_plus_models_base_release_get_canceled (ProtonPlusModelsBaseRelease* self);
VALA_EXTERN const gchar* proton_plus_models_base_release_get_error_message (ProtonPlusModelsBaseRelease* self);
static void _vala_JsonNode_free (JsonNode* self);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
VALA_EXTERN GType proton_plus_models_releases_history_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsReleasesHistory, g_object_unref)
VALA_EXTERN ProtonPlusModelsReleasesHistory* proton_plus_models_releases_history_new (const gchar* title,
                                                                          const gchar* displayed_title,
                                                                          const gchar* icon_path,
                                                                          gboolean is_finished,
                                                                          gboolean install_success,
                                                                          gboolean canceled,
                                                                          const gchar* error_message);
VALA_EXTERN ProtonPlusModelsReleasesHistory* proton_plus_models_releases_history_construct (GType object_type,
                                                                                const gchar* title,
                                                                                const gchar* displayed_title,
                                                                                const gchar* icon_path,
                                                                                gboolean is_finished,
                                                                                gboolean install_success,
                                                                                gboolean canceled,
                                                                                const gchar* error_message);
VALA_EXTERN ProtonPlusModelsDownloadManager* proton_plus_models_download_manager_get_instance (void);
static void g_cclosure_user_marshal_VOID__OBJECT_BOOLEAN (GClosure * closure,
                                                   GValue * return_value,
                                                   guint n_param_values,
                                                   const GValue * param_values,
                                                   gpointer invocation_hint,
                                                   gpointer marshal_data);
static void proton_plus_models_download_manager_finalize (GObject * obj);
static GType proton_plus_models_download_manager_get_type_once (void);
static void _vala_proton_plus_models_download_manager_get_property (GObject * object,
                                                             guint property_id,
                                                             GValue * value,
                                                             GParamSpec * pspec);
static void _vala_proton_plus_models_download_manager_set_property (GObject * object,
                                                             guint property_id,
                                                             const GValue * value,
                                                             GParamSpec * pspec);

static inline gpointer
proton_plus_models_download_manager_get_instance_private (ProtonPlusModelsDownloadManager* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusModelsDownloadManager_private_offset);
}

gboolean
proton_plus_models_download_manager_is_downloading (ProtonPlusModelsDownloadManager* self,
                                                    ProtonPlusModelsBaseRelease* release)
{
	ProtonPlusModelsBaseRelease* _tmp0_;
	ProtonPlusModelsBaseRelease* _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (release != NULL, FALSE);
	_tmp0_ = proton_plus_models_download_manager_get_active_download (self, release);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_ != NULL;
	_g_object_unref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

ProtonPlusModelsBaseRelease*
proton_plus_models_download_manager_get_active_download (ProtonPlusModelsDownloadManager* self,
                                                         ProtonPlusModelsBaseRelease* release)
{
	ProtonPlusModelsBaseRelease* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (release != NULL, NULL);
	{
		GeeArrayList* _active_download_list = NULL;
		GeeArrayList* _tmp0_;
		gint _active_download_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _active_download_index = 0;
		_tmp0_ = self->priv->_active_downloads;
		_active_download_list = _tmp0_;
		_tmp1_ = _active_download_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_active_download_size = _tmp3_;
		_active_download_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ProtonPlusModelsBaseRelease* active_download = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			gboolean _tmp8_ = FALSE;
			ProtonPlusModelsBaseRelease* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			const gchar* _tmp12_;
			const gchar* _tmp13_;
			_active_download_index = _active_download_index + 1;
			_tmp4_ = _active_download_index;
			_tmp5_ = _active_download_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _active_download_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _active_download_index);
			active_download = (ProtonPlusModelsBaseRelease*) _tmp7_;
			_tmp9_ = active_download;
			_tmp10_ = proton_plus_models_base_release_get_download_url (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = proton_plus_models_base_release_get_download_url (release);
			_tmp13_ = _tmp12_;
			if (g_strcmp0 (_tmp11_, _tmp13_) == 0) {
				ProtonPlusModelsBaseRelease* _tmp14_;
				const gchar* _tmp15_;
				const gchar* _tmp16_;
				const gchar* _tmp17_;
				const gchar* _tmp18_;
				_tmp14_ = active_download;
				_tmp15_ = proton_plus_models_base_release_get_title (_tmp14_);
				_tmp16_ = _tmp15_;
				_tmp17_ = proton_plus_models_base_release_get_title (release);
				_tmp18_ = _tmp17_;
				_tmp8_ = g_strcmp0 (_tmp16_, _tmp18_) == 0;
			} else {
				_tmp8_ = FALSE;
			}
			if (_tmp8_) {
				result = active_download;
				return result;
			}
			_g_object_unref0 (active_download);
		}
	}
	result = NULL;
	return result;
}

static void
___lambda9_ (ProtonPlusModelsDownloadManager* self)
{
	GSettings* _tmp0_;
	_tmp0_ = proton_plus_globals_SETTINGS;
	if (!g_settings_get_boolean (_tmp0_, "save-history")) {
		proton_plus_models_download_manager_clear_history (self);
	}
}

static void
____lambda9__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	___lambda9_ ((ProtonPlusModelsDownloadManager*) self);
}

static ProtonPlusModelsDownloadManager*
proton_plus_models_download_manager_construct (GType object_type)
{
	ProtonPlusModelsDownloadManager * self = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeArrayList* _tmp3_;
	GSettings* _tmp4_;
	self = (ProtonPlusModelsDownloadManager*) g_object_new (object_type, NULL);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_tmp1_ = _tmp0_;
	proton_plus_models_download_manager_set_active_downloads (self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_tmp3_ = _tmp2_;
	proton_plus_models_download_manager_set_history (self, _tmp3_);
	_g_object_unref0 (_tmp3_);
	proton_plus_models_download_manager_load_history (self);
	_tmp4_ = proton_plus_globals_SETTINGS;
	if (_tmp4_ != NULL) {
		GSettings* _tmp5_;
		_tmp5_ = proton_plus_globals_SETTINGS;
		g_signal_connect_object (_tmp5_, "changed::save-history", (GCallback) ____lambda9__g_settings_changed, self, 0);
	}
	return self;
}

static ProtonPlusModelsDownloadManager*
proton_plus_models_download_manager_new (void)
{
	return proton_plus_models_download_manager_construct (PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER);
}

void
proton_plus_models_download_manager_add_download (ProtonPlusModelsDownloadManager* self,
                                                  ProtonPlusModelsBaseRelease* release)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (release != NULL);
	if (!proton_plus_models_download_manager_is_downloading (self, release)) {
		GeeArrayList* _tmp15_;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp0_ = FALSE;
				_tmp0_ = TRUE;
				while (TRUE) {
					GeeArrayList* _tmp2_;
					gint _tmp3_;
					gint _tmp4_;
					ProtonPlusModelsBaseRelease* history_release = NULL;
					GeeArrayList* _tmp5_;
					gpointer _tmp6_;
					ProtonPlusModelsBaseRelease* _tmp7_;
					const gchar* _tmp8_;
					const gchar* _tmp9_;
					const gchar* _tmp10_;
					const gchar* _tmp11_;
					if (!_tmp0_) {
						gint _tmp1_;
						_tmp1_ = i;
						i = _tmp1_ + 1;
					}
					_tmp0_ = FALSE;
					_tmp2_ = self->priv->_history;
					_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
					_tmp4_ = _tmp3_;
					if (!(i < _tmp4_)) {
						break;
					}
					_tmp5_ = self->priv->_history;
					_tmp6_ = gee_abstract_list_get ((GeeAbstractList*) _tmp5_, i);
					history_release = (ProtonPlusModelsBaseRelease*) _tmp6_;
					_tmp7_ = history_release;
					_tmp8_ = proton_plus_models_base_release_get_title (_tmp7_);
					_tmp9_ = _tmp8_;
					_tmp10_ = proton_plus_models_base_release_get_title (release);
					_tmp11_ = _tmp10_;
					if (g_strcmp0 (_tmp9_, _tmp11_) == 0) {
						GeeArrayList* _tmp12_;
						gpointer _tmp13_;
						ProtonPlusModelsBaseRelease* _tmp14_;
						_tmp12_ = self->priv->_history;
						_tmp13_ = gee_abstract_list_remove_at ((GeeAbstractList*) _tmp12_, i);
						_tmp14_ = (ProtonPlusModelsBaseRelease*) _tmp13_;
						_g_object_unref0 (_tmp14_);
						proton_plus_models_download_manager_save_history (self);
						_g_object_unref0 (history_release);
						break;
					}
					_g_object_unref0 (history_release);
				}
			}
		}
		_tmp15_ = self->priv->_active_downloads;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp15_, release);
		g_signal_emit (self, proton_plus_models_download_manager_signals[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_ADDED_SIGNAL], 0, release);
	}
}

void
proton_plus_models_download_manager_remove_download (ProtonPlusModelsDownloadManager* self,
                                                     ProtonPlusModelsBaseRelease* release)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (release != NULL);
	_tmp0_ = self->priv->_active_downloads;
	if (gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp0_, release)) {
		GeeArrayList* _tmp1_;
		_tmp1_ = self->priv->_active_downloads;
		gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp1_, release);
		g_signal_emit (self, proton_plus_models_download_manager_signals[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_REMOVED_SIGNAL], 0, release);
	}
}

void
proton_plus_models_download_manager_add_to_history (ProtonPlusModelsDownloadManager* self,
                                                    ProtonPlusModelsBaseRelease* release,
                                                    gboolean success)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (release != NULL);
	_tmp0_ = self->priv->_history;
	if (!gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp0_, release)) {
		GeeArrayList* _tmp1_;
		_tmp1_ = self->priv->_history;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, release);
		g_signal_emit (self, proton_plus_models_download_manager_signals[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_FINISHED_SIGNAL], 0, release, success);
		proton_plus_models_download_manager_save_history (self);
	}
}

void
proton_plus_models_download_manager_clear_history (ProtonPlusModelsDownloadManager* self)
{
	GeeArrayList* _tmp0_;
	gchar* history_file = NULL;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_history;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp0_);
	_tmp1_ = g_get_user_config_dir ();
	_tmp2_ = g_build_filename (_tmp1_, "ProtonPlus", "history.json", NULL);
	history_file = _tmp2_;
	_tmp3_ = history_file;
	if (g_file_test (_tmp3_, G_FILE_TEST_EXISTS)) {
		const gchar* _tmp4_;
		_tmp4_ = history_file;
		g_remove (_tmp4_);
	}
	proton_plus_models_download_manager_save_history (self);
	_g_free0 (history_file);
}

static gpointer
_json_object_ref0 (gpointer self)
{
	return self ? json_object_ref (self) : NULL;
}

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

static void
proton_plus_models_download_manager_save_history (ProtonPlusModelsDownloadManager* self)
{
	gboolean _tmp0_ = FALSE;
	GSettings* _tmp1_;
	JsonArray* root_array = NULL;
	JsonArray* _tmp3_;
	JsonNode* root_node = NULL;
	JsonNode* _tmp66_;
	JsonNode* _tmp67_;
	JsonArray* _tmp68_;
	JsonGenerator* generator = NULL;
	JsonGenerator* _tmp69_;
	JsonGenerator* _tmp70_;
	JsonNode* _tmp71_;
	JsonGenerator* _tmp72_;
	gchar* history_file = NULL;
	const gchar* _tmp73_;
	gchar* _tmp74_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp1_ = proton_plus_globals_SETTINGS;
	if (_tmp1_ != NULL) {
		GSettings* _tmp2_;
		_tmp2_ = proton_plus_globals_SETTINGS;
		_tmp0_ = !g_settings_get_boolean (_tmp2_, "save-history");
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	_tmp3_ = json_array_new ();
	root_array = _tmp3_;
	{
		GeeArrayList* _release_list = NULL;
		GeeArrayList* _tmp4_;
		gint _release_size = 0;
		GeeArrayList* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		gint _release_index = 0;
		_tmp4_ = self->priv->_history;
		_release_list = _tmp4_;
		_tmp5_ = _release_list;
		_tmp6_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp5_);
		_tmp7_ = _tmp6_;
		_release_size = _tmp7_;
		_release_index = -1;
		while (TRUE) {
			gint _tmp8_;
			gint _tmp9_;
			ProtonPlusModelsBaseRelease* release = NULL;
			GeeArrayList* _tmp10_;
			gpointer _tmp11_;
			JsonObject* release_object = NULL;
			JsonObject* _tmp12_;
			JsonObject* _tmp13_;
			ProtonPlusModelsBaseRelease* _tmp14_;
			const gchar* _tmp15_;
			const gchar* _tmp16_;
			const gchar* _tmp17_ = NULL;
			ProtonPlusModelsBaseRelease* _tmp18_;
			const gchar* _tmp19_;
			const gchar* _tmp20_;
			JsonObject* _tmp24_;
			const gchar* _tmp25_ = NULL;
			ProtonPlusModelsBaseRelease* _tmp26_;
			ProtonPlusModelsRunner* _tmp27_;
			ProtonPlusModelsRunner* _tmp28_;
			ProtonPlusModelsGroup* _tmp29_;
			ProtonPlusModelsGroup* _tmp30_;
			ProtonPlusModelsLauncher* _tmp31_;
			ProtonPlusModelsLauncher* _tmp32_;
			const gchar* _tmp33_;
			JsonObject* _tmp42_;
			JsonObject* _tmp43_;
			ProtonPlusModelsBaseRelease* _tmp44_;
			gboolean _tmp45_;
			gboolean _tmp46_;
			JsonObject* _tmp47_;
			ProtonPlusModelsBaseRelease* _tmp48_;
			gboolean _tmp49_;
			gboolean _tmp50_;
			JsonObject* _tmp51_;
			ProtonPlusModelsBaseRelease* _tmp52_;
			gboolean _tmp53_;
			gboolean _tmp54_;
			const gchar* _tmp55_ = NULL;
			ProtonPlusModelsBaseRelease* _tmp56_;
			const gchar* _tmp57_;
			const gchar* _tmp58_;
			JsonObject* _tmp62_;
			JsonArray* _tmp63_;
			JsonObject* _tmp64_;
			JsonObject* _tmp65_;
			_release_index = _release_index + 1;
			_tmp8_ = _release_index;
			_tmp9_ = _release_size;
			if (!(_tmp8_ < _tmp9_)) {
				break;
			}
			_tmp10_ = _release_list;
			_tmp11_ = gee_abstract_list_get ((GeeAbstractList*) _tmp10_, _release_index);
			release = (ProtonPlusModelsBaseRelease*) _tmp11_;
			_tmp12_ = json_object_new ();
			release_object = _tmp12_;
			_tmp13_ = release_object;
			_tmp14_ = release;
			_tmp15_ = proton_plus_models_base_release_get_title (_tmp14_);
			_tmp16_ = _tmp15_;
			json_object_set_string_member (_tmp13_, "title", _tmp16_);
			_tmp18_ = release;
			_tmp19_ = proton_plus_models_base_release_get_displayed_title (_tmp18_);
			_tmp20_ = _tmp19_;
			if (_tmp20_ != NULL) {
				ProtonPlusModelsBaseRelease* _tmp21_;
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				_tmp21_ = release;
				_tmp22_ = proton_plus_models_base_release_get_displayed_title (_tmp21_);
				_tmp23_ = _tmp22_;
				_tmp17_ = _tmp23_;
			} else {
				_tmp17_ = "";
			}
			_tmp24_ = release_object;
			json_object_set_string_member (_tmp24_, "displayed_title", _tmp17_);
			_tmp26_ = release;
			_tmp27_ = proton_plus_models_base_release_get_runner (_tmp26_);
			_tmp28_ = _tmp27_;
			_tmp29_ = proton_plus_models_runner_get_group (_tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = proton_plus_models_group_get_launcher (_tmp30_);
			_tmp32_ = _tmp31_;
			_tmp33_ = _tmp32_->icon_path;
			if (_tmp33_ != NULL) {
				ProtonPlusModelsBaseRelease* _tmp34_;
				ProtonPlusModelsRunner* _tmp35_;
				ProtonPlusModelsRunner* _tmp36_;
				ProtonPlusModelsGroup* _tmp37_;
				ProtonPlusModelsGroup* _tmp38_;
				ProtonPlusModelsLauncher* _tmp39_;
				ProtonPlusModelsLauncher* _tmp40_;
				const gchar* _tmp41_;
				_tmp34_ = release;
				_tmp35_ = proton_plus_models_base_release_get_runner (_tmp34_);
				_tmp36_ = _tmp35_;
				_tmp37_ = proton_plus_models_runner_get_group (_tmp36_);
				_tmp38_ = _tmp37_;
				_tmp39_ = proton_plus_models_group_get_launcher (_tmp38_);
				_tmp40_ = _tmp39_;
				_tmp41_ = _tmp40_->icon_path;
				_tmp25_ = _tmp41_;
			} else {
				_tmp25_ = "";
			}
			_tmp42_ = release_object;
			json_object_set_string_member (_tmp42_, "icon_path", _tmp25_);
			_tmp43_ = release_object;
			_tmp44_ = release;
			_tmp45_ = proton_plus_models_base_release_get_is_finished (_tmp44_);
			_tmp46_ = _tmp45_;
			json_object_set_boolean_member (_tmp43_, "is_finished", _tmp46_);
			_tmp47_ = release_object;
			_tmp48_ = release;
			_tmp49_ = proton_plus_models_base_release_get_install_success (_tmp48_);
			_tmp50_ = _tmp49_;
			json_object_set_boolean_member (_tmp47_, "install_success", _tmp50_);
			_tmp51_ = release_object;
			_tmp52_ = release;
			_tmp53_ = proton_plus_models_base_release_get_canceled (_tmp52_);
			_tmp54_ = _tmp53_;
			json_object_set_boolean_member (_tmp51_, "canceled", _tmp54_);
			_tmp56_ = release;
			_tmp57_ = proton_plus_models_base_release_get_error_message (_tmp56_);
			_tmp58_ = _tmp57_;
			if (_tmp58_ != NULL) {
				ProtonPlusModelsBaseRelease* _tmp59_;
				const gchar* _tmp60_;
				const gchar* _tmp61_;
				_tmp59_ = release;
				_tmp60_ = proton_plus_models_base_release_get_error_message (_tmp59_);
				_tmp61_ = _tmp60_;
				_tmp55_ = _tmp61_;
			} else {
				_tmp55_ = "";
			}
			_tmp62_ = release_object;
			json_object_set_string_member (_tmp62_, "error_message", _tmp55_);
			_tmp63_ = root_array;
			_tmp64_ = release_object;
			_tmp65_ = _json_object_ref0 (_tmp64_);
			json_array_add_object_element (_tmp63_, _tmp65_);
			_json_object_unref0 (release_object);
			_g_object_unref0 (release);
		}
	}
	_tmp66_ = json_node_new (JSON_NODE_ARRAY);
	root_node = _tmp66_;
	_tmp67_ = root_node;
	_tmp68_ = root_array;
	json_node_set_array (_tmp67_, _tmp68_);
	_tmp69_ = json_generator_new ();
	generator = _tmp69_;
	_tmp70_ = generator;
	_tmp71_ = root_node;
	json_generator_set_root (_tmp70_, _tmp71_);
	_tmp72_ = generator;
	json_generator_set_pretty (_tmp72_, TRUE);
	_tmp73_ = proton_plus_globals_CONFIG_PATH;
	_tmp74_ = g_build_filename (_tmp73_, "history.json", NULL);
	history_file = _tmp74_;
	{
		JsonGenerator* _tmp75_;
		const gchar* _tmp76_;
		_tmp75_ = generator;
		_tmp76_ = history_file;
		json_generator_to_file (_tmp75_, _tmp76_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp77_;
		const gchar* _tmp78_;
		gchar* _tmp79_;
		gchar* _tmp80_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp77_ = e;
		_tmp78_ = _tmp77_->message;
		_tmp79_ = g_strdup_printf ("Failed to save download history: %s", _tmp78_);
		_tmp80_ = _tmp79_;
		g_warning ("download-manager.vala:117: %s", _tmp80_);
		_g_free0 (_tmp80_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (history_file);
		_g_object_unref0 (generator);
		__vala_JsonNode_free0 (root_node);
		_json_array_unref0 (root_array);
		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;
	}
	_g_free0 (history_file);
	_g_object_unref0 (generator);
	__vala_JsonNode_free0 (root_node);
	_json_array_unref0 (root_array);
}

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 gpointer
_json_array_ref0 (gpointer self)
{
	return self ? json_array_ref (self) : NULL;
}

static void
proton_plus_models_download_manager_load_history (ProtonPlusModelsDownloadManager* self)
{
	gboolean _tmp0_ = FALSE;
	GSettings* _tmp1_;
	gchar* history_file = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	JsonParser* parser = NULL;
	JsonParser* _tmp6_;
	JsonNode* root_node = NULL;
	JsonParser* _tmp13_;
	JsonNode* _tmp14_;
	JsonNode* _tmp15_;
	gboolean _tmp16_ = FALSE;
	JsonNode* _tmp17_;
	JsonArray* root_array = NULL;
	JsonNode* _tmp19_;
	JsonArray* _tmp20_;
	JsonArray* _tmp21_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp1_ = proton_plus_globals_SETTINGS;
	if (_tmp1_ != NULL) {
		GSettings* _tmp2_;
		_tmp2_ = proton_plus_globals_SETTINGS;
		_tmp0_ = !g_settings_get_boolean (_tmp2_, "save-history");
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	_tmp3_ = g_get_user_config_dir ();
	_tmp4_ = g_build_filename (_tmp3_, "ProtonPlus", "history.json", NULL);
	history_file = _tmp4_;
	_tmp5_ = history_file;
	if (!g_file_test (_tmp5_, G_FILE_TEST_EXISTS)) {
		_g_free0 (history_file);
		return;
	}
	_tmp6_ = json_parser_new ();
	parser = _tmp6_;
	{
		JsonParser* _tmp7_;
		const gchar* _tmp8_;
		_tmp7_ = parser;
		_tmp8_ = history_file;
		json_parser_load_from_file (_tmp7_, _tmp8_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		_tmp11_ = g_strdup_printf ("Failed to load download history: %s", _tmp10_);
		_tmp12_ = _tmp11_;
		g_warning ("download-manager.vala:133: %s", _tmp12_);
		_g_free0 (_tmp12_);
		_g_error_free0 (e);
		_g_object_unref0 (parser);
		_g_free0 (history_file);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (parser);
		_g_free0 (history_file);
		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;
	}
	_tmp13_ = parser;
	_tmp14_ = json_parser_get_root (_tmp13_);
	_tmp15_ = __vala_JsonNode_copy0 (_tmp14_);
	root_node = _tmp15_;
	_tmp17_ = root_node;
	if (_tmp17_ == NULL) {
		_tmp16_ = TRUE;
	} else {
		JsonNode* _tmp18_;
		_tmp18_ = root_node;
		_tmp16_ = json_node_get_node_type (_tmp18_) != JSON_NODE_ARRAY;
	}
	if (_tmp16_) {
		__vala_JsonNode_free0 (root_node);
		_g_object_unref0 (parser);
		_g_free0 (history_file);
		return;
	}
	_tmp19_ = root_node;
	_tmp20_ = json_node_get_array (_tmp19_);
	_tmp21_ = _json_array_ref0 (_tmp20_);
	root_array = _tmp21_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp22_ = FALSE;
			_tmp22_ = TRUE;
			while (TRUE) {
				JsonArray* _tmp24_;
				JsonObject* release_object = NULL;
				JsonArray* _tmp25_;
				JsonObject* _tmp26_;
				JsonObject* _tmp27_;
				gchar* title = NULL;
				JsonObject* _tmp28_;
				const gchar* _tmp29_;
				gchar* _tmp30_;
				gchar* displayed_title = NULL;
				JsonObject* _tmp31_;
				const gchar* _tmp32_;
				gchar* _tmp33_;
				gchar* icon_path = NULL;
				JsonObject* _tmp34_;
				const gchar* _tmp35_;
				gchar* _tmp36_;
				gboolean is_finished = FALSE;
				JsonObject* _tmp37_;
				gboolean install_success = FALSE;
				JsonObject* _tmp38_;
				gboolean canceled = FALSE;
				JsonObject* _tmp39_;
				const gchar* _tmp40_ = NULL;
				JsonObject* _tmp41_;
				gchar* error_message = NULL;
				gchar* _tmp44_;
				const gchar* _tmp45_ = NULL;
				const gchar* _tmp46_;
				const gchar* _tmp48_ = NULL;
				const gchar* _tmp49_;
				ProtonPlusModelsReleasesHistory* release = NULL;
				const gchar* _tmp51_;
				const gchar* _tmp52_;
				ProtonPlusModelsReleasesHistory* _tmp53_;
				GeeArrayList* _tmp54_;
				ProtonPlusModelsReleasesHistory* _tmp55_;
				if (!_tmp22_) {
					gint _tmp23_;
					_tmp23_ = i;
					i = _tmp23_ + 1;
				}
				_tmp22_ = FALSE;
				_tmp24_ = root_array;
				if (!(((guint) i) < json_array_get_length (_tmp24_))) {
					break;
				}
				_tmp25_ = root_array;
				_tmp26_ = json_array_get_object_element (_tmp25_, (guint) i);
				_tmp27_ = _json_object_ref0 (_tmp26_);
				release_object = _tmp27_;
				_tmp28_ = release_object;
				_tmp29_ = json_object_get_string_member (_tmp28_, "title");
				_tmp30_ = g_strdup (_tmp29_);
				title = _tmp30_;
				_tmp31_ = release_object;
				_tmp32_ = json_object_get_string_member (_tmp31_, "displayed_title");
				_tmp33_ = g_strdup (_tmp32_);
				displayed_title = _tmp33_;
				_tmp34_ = release_object;
				_tmp35_ = json_object_get_string_member (_tmp34_, "icon_path");
				_tmp36_ = g_strdup (_tmp35_);
				icon_path = _tmp36_;
				_tmp37_ = release_object;
				is_finished = json_object_get_boolean_member (_tmp37_, "is_finished");
				_tmp38_ = release_object;
				install_success = json_object_get_boolean_member (_tmp38_, "install_success");
				_tmp39_ = release_object;
				canceled = json_object_get_boolean_member (_tmp39_, "canceled");
				_tmp41_ = release_object;
				if (json_object_has_member (_tmp41_, "error_message")) {
					JsonObject* _tmp42_;
					const gchar* _tmp43_;
					_tmp42_ = release_object;
					_tmp43_ = json_object_get_string_member (_tmp42_, "error_message");
					_tmp40_ = _tmp43_;
				} else {
					_tmp40_ = "";
				}
				_tmp44_ = g_strdup (_tmp40_);
				error_message = _tmp44_;
				_tmp46_ = displayed_title;
				if (g_strcmp0 (_tmp46_, "") != 0) {
					const gchar* _tmp47_;
					_tmp47_ = displayed_title;
					_tmp45_ = _tmp47_;
				} else {
					_tmp45_ = NULL;
				}
				_tmp49_ = error_message;
				if (g_strcmp0 (_tmp49_, "") != 0) {
					const gchar* _tmp50_;
					_tmp50_ = error_message;
					_tmp48_ = _tmp50_;
				} else {
					_tmp48_ = NULL;
				}
				_tmp51_ = title;
				_tmp52_ = icon_path;
				_tmp53_ = proton_plus_models_releases_history_new (_tmp51_, _tmp45_, _tmp52_, is_finished, install_success, canceled, _tmp48_);
				release = _tmp53_;
				_tmp54_ = self->priv->_history;
				_tmp55_ = release;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp54_, (ProtonPlusModelsBaseRelease*) _tmp55_);
				_g_object_unref0 (release);
				_g_free0 (error_message);
				_g_free0 (icon_path);
				_g_free0 (displayed_title);
				_g_free0 (title);
				_json_object_unref0 (release_object);
			}
		}
	}
	_json_array_unref0 (root_array);
	__vala_JsonNode_free0 (root_node);
	_g_object_unref0 (parser);
	_g_free0 (history_file);
}

ProtonPlusModelsDownloadManager*
proton_plus_models_download_manager_get_instance (void)
{
	ProtonPlusModelsDownloadManager* result;
	ProtonPlusModelsDownloadManager* _tmp0_;
	ProtonPlusModelsDownloadManager* _tmp2_;
	_tmp0_ = proton_plus_models_download_manager__instance;
	if (_tmp0_ == NULL) {
		ProtonPlusModelsDownloadManager* _tmp1_;
		_tmp1_ = proton_plus_models_download_manager_new ();
		_g_object_unref0 (proton_plus_models_download_manager__instance);
		proton_plus_models_download_manager__instance = _tmp1_;
	}
	_tmp2_ = proton_plus_models_download_manager__instance;
	result = _tmp2_;
	return result;
}

GeeArrayList*
proton_plus_models_download_manager_get_active_downloads (ProtonPlusModelsDownloadManager* self)
{
	GeeArrayList* result;
	GeeArrayList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_active_downloads;
	result = _tmp0_;
	return result;
}

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

static void
proton_plus_models_download_manager_set_active_downloads (ProtonPlusModelsDownloadManager* self,
                                                          GeeArrayList* value)
{
	GeeArrayList* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_download_manager_get_active_downloads (self);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_active_downloads);
		self->priv->_active_downloads = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_download_manager_properties[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_ACTIVE_DOWNLOADS_PROPERTY]);
	}
}

GeeArrayList*
proton_plus_models_download_manager_get_history (ProtonPlusModelsDownloadManager* self)
{
	GeeArrayList* result;
	GeeArrayList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_history;
	result = _tmp0_;
	return result;
}

static void
proton_plus_models_download_manager_set_history (ProtonPlusModelsDownloadManager* self,
                                                 GeeArrayList* value)
{
	GeeArrayList* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_download_manager_get_history (self);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_history);
		self->priv->_history = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_download_manager_properties[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_HISTORY_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__OBJECT_BOOLEAN (GClosure * closure,
                                              GValue * return_value,
                                              guint n_param_values,
                                              const GValue * param_values,
                                              gpointer invocation_hint,
                                              gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_BOOLEAN) (gpointer data1, gpointer arg_1, gboolean arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_BOOLEAN callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_BOOLEAN) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), g_value_get_boolean (param_values + 2), data2);
}

static void
proton_plus_models_download_manager_class_init (ProtonPlusModelsDownloadManagerClass * klass,
                                                gpointer klass_data)
{
	proton_plus_models_download_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusModelsDownloadManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_models_download_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_models_download_manager_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_models_download_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_ACTIVE_DOWNLOADS_PROPERTY, proton_plus_models_download_manager_properties[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_ACTIVE_DOWNLOADS_PROPERTY] = g_param_spec_object ("active-downloads", "active-downloads", "active-downloads", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_HISTORY_PROPERTY, proton_plus_models_download_manager_properties[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_HISTORY_PROPERTY] = g_param_spec_object ("history", "history", "history", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	proton_plus_models_download_manager_signals[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_ADDED_SIGNAL] = g_signal_new ("download-added", PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, PROTON_PLUS_MODELS_TYPE_BASE_RELEASE);
	proton_plus_models_download_manager_signals[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_REMOVED_SIGNAL] = g_signal_new ("download-removed", PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, PROTON_PLUS_MODELS_TYPE_BASE_RELEASE);
	proton_plus_models_download_manager_signals[PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_DOWNLOAD_FINISHED_SIGNAL] = g_signal_new ("download-finished", PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2, PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, G_TYPE_BOOLEAN);
}

static void
proton_plus_models_download_manager_instance_init (ProtonPlusModelsDownloadManager * self,
                                                   gpointer klass)
{
	self->priv = proton_plus_models_download_manager_get_instance_private (self);
}

static void
proton_plus_models_download_manager_finalize (GObject * obj)
{
	ProtonPlusModelsDownloadManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManager);
	_g_object_unref0 (self->priv->_active_downloads);
	_g_object_unref0 (self->priv->_history);
	G_OBJECT_CLASS (proton_plus_models_download_manager_parent_class)->finalize (obj);
}

static GType
proton_plus_models_download_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusModelsDownloadManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_models_download_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusModelsDownloadManager), 0, (GInstanceInitFunc) proton_plus_models_download_manager_instance_init, NULL };
	GType proton_plus_models_download_manager_type_id;
	proton_plus_models_download_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusModelsDownloadManager", &g_define_type_info, 0);
	ProtonPlusModelsDownloadManager_private_offset = g_type_add_instance_private (proton_plus_models_download_manager_type_id, sizeof (ProtonPlusModelsDownloadManagerPrivate));
	return proton_plus_models_download_manager_type_id;
}

GType
proton_plus_models_download_manager_get_type (void)
{
	static volatile gsize proton_plus_models_download_manager_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_models_download_manager_type_id__once)) {
		GType proton_plus_models_download_manager_type_id;
		proton_plus_models_download_manager_type_id = proton_plus_models_download_manager_get_type_once ();
		g_once_init_leave (&proton_plus_models_download_manager_type_id__once, proton_plus_models_download_manager_type_id);
	}
	return proton_plus_models_download_manager_type_id__once;
}

static void
_vala_proton_plus_models_download_manager_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec)
{
	ProtonPlusModelsDownloadManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManager);
	switch (property_id) {
		case PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_ACTIVE_DOWNLOADS_PROPERTY:
		g_value_set_object (value, proton_plus_models_download_manager_get_active_downloads (self));
		break;
		case PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_HISTORY_PROPERTY:
		g_value_set_object (value, proton_plus_models_download_manager_get_history (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_models_download_manager_set_property (GObject * object,
                                                        guint property_id,
                                                        const GValue * value,
                                                        GParamSpec * pspec)
{
	ProtonPlusModelsDownloadManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManager);
	switch (property_id) {
		case PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_ACTIVE_DOWNLOADS_PROPERTY:
		proton_plus_models_download_manager_set_active_downloads (self, g_value_get_object (value));
		break;
		case PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_HISTORY_PROPERTY:
		proton_plus_models_download_manager_set_history (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

