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

#include "protonplus_core.h"
#include <gee.h>
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	PROTON_PLUS_SERVICES_MIGRATIONS_MANAGER_0_PROPERTY,
	PROTON_PLUS_SERVICES_MIGRATIONS_MANAGER_NUM_PROPERTIES
};
static GParamSpec* proton_plus_services_migrations_manager_properties[PROTON_PLUS_SERVICES_MIGRATIONS_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 _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _ProtonPlusServicesMigrationsManagerCheckAndMigrateData ProtonPlusServicesMigrationsManagerCheckAndMigrateData;
typedef struct _Block47Data Block47Data;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))

struct _ProtonPlusServicesMigrationsManagerPrivate {
	GeeArrayList* migrations;
	GeeArrayList* completed_migrations;
};

struct _ProtonPlusServicesMigrationsManagerCheckAndMigrateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ProtonPlusServicesMigrationsManager* self;
	gchar* current_version;
	GeeArrayList* _tmp0_;
	GSettings* settings;
	GSettings* _tmp1_;
	GSettings* _tmp2_;
	GSettings* _tmp3_;
	gchar* last_version;
	GSettings* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	GSettings* _tmp7_;
	gchar* _tmp8_;
	GSettings* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	GeeArrayList* _step_list;
	GeeArrayList* _tmp12_;
	gint _step_size;
	GeeArrayList* _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	gint _step_index;
	gint _tmp16_;
	gint _tmp17_;
	ProtonPlusServicesMigrationsIMigration* step;
	GeeArrayList* _tmp18_;
	gpointer _tmp19_;
	gboolean _tmp20_;
	ProtonPlusServicesMigrationsIMigration* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	ProtonPlusServicesMigrationsIMigration* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	ProtonPlusServicesMigrationsIMigration* _tmp28_;
	GeeArrayList* _tmp29_;
	ProtonPlusServicesMigrationsIMigration* _tmp30_;
	GSettings* _tmp31_;
	ProtonPlusServicesMigrationsIMigration* _tmp32_;
	const gchar* _tmp33_;
	const gchar* _tmp34_;
	GError* e;
	ProtonPlusServicesMigrationsIMigration* _tmp35_;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	GError* _tmp38_;
	const gchar* _tmp39_;
	GSettings* _tmp40_;
	GError* _inner_error0_;
};

struct _Block47Data {
	int _ref_count_;
	ProtonPlusServicesMigrationsManager* self;
	GMainLoop* loop;
};

static gint ProtonPlusServicesMigrationsManager_private_offset;
static gpointer proton_plus_services_migrations_manager_parent_class = NULL;

static void proton_plus_services_migrations_manager_register_migrations (ProtonPlusServicesMigrationsManager* self);
static void proton_plus_services_migrations_manager_check_and_migrate_data_free (gpointer _data);
static gboolean proton_plus_services_migrations_manager_check_and_migrate_co (ProtonPlusServicesMigrationsManagerCheckAndMigrateData* _data_);
static gint proton_plus_services_migrations_manager_compare_versions (ProtonPlusServicesMigrationsManager* self,
                                                               const gchar* v1,
                                                               const gchar* v2);
static void proton_plus_services_migrations_manager_check_and_migrate_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_);
static Block47Data* block47_data_ref (Block47Data* _data47_);
static void block47_data_unref (void * _userdata_);
static void __lambda355_ (Block47Data* _data47_,
                   GObject* obj,
                   GAsyncResult* res);
static void ___lambda355__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void proton_plus_services_migrations_manager_finalize (GObject * obj);
static GType proton_plus_services_migrations_manager_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
proton_plus_services_migrations_manager_get_instance_private (ProtonPlusServicesMigrationsManager* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusServicesMigrationsManager_private_offset);
}

ProtonPlusServicesMigrationsManager*
proton_plus_services_migrations_manager_construct (GType object_type)
{
	ProtonPlusServicesMigrationsManager * self = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	self = (ProtonPlusServicesMigrationsManager*) g_object_new (object_type, NULL);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_SERVICES_MIGRATIONS_TYPE_IMIGRATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->migrations);
	self->priv->migrations = _tmp0_;
	_tmp1_ = gee_array_list_new (PROTON_PLUS_SERVICES_MIGRATIONS_TYPE_IMIGRATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->completed_migrations);
	self->priv->completed_migrations = _tmp1_;
	proton_plus_services_migrations_manager_register_migrations (self);
	return self;
}

ProtonPlusServicesMigrationsManager*
proton_plus_services_migrations_manager_new (void)
{
	return proton_plus_services_migrations_manager_construct (PROTON_PLUS_SERVICES_MIGRATIONS_TYPE_MANAGER);
}

static void
proton_plus_services_migrations_manager_register_migrations (ProtonPlusServicesMigrationsManager* self)
{
	GeeArrayList* _tmp0_;
	ProtonPlusServicesMigrationsVersionsv0_5_21* _tmp1_;
	ProtonPlusServicesMigrationsVersionsv0_5_21* _tmp2_;
	GeeArrayList* _tmp3_;
	ProtonPlusServicesMigrationsVersionsv0_6_0* _tmp4_;
	ProtonPlusServicesMigrationsVersionsv0_6_0* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->migrations;
	_tmp1_ = proton_plus_services_migrations_versions_v0_5_21_new ();
	_tmp2_ = _tmp1_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, (ProtonPlusServicesMigrationsIMigration*) _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = self->priv->migrations;
	_tmp4_ = proton_plus_services_migrations_versions_v0_6_0_new ();
	_tmp5_ = _tmp4_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp3_, (ProtonPlusServicesMigrationsIMigration*) _tmp5_);
	_g_object_unref0 (_tmp5_);
}

static void
proton_plus_services_migrations_manager_check_and_migrate_data_free (gpointer _data)
{
	ProtonPlusServicesMigrationsManagerCheckAndMigrateData* _data_;
	_data_ = _data;
	_g_free0 (_data_->current_version);
	_g_object_unref0 (_data_->self);
	g_slice_free (ProtonPlusServicesMigrationsManagerCheckAndMigrateData, _data_);
}

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

void
proton_plus_services_migrations_manager_check_and_migrate (ProtonPlusServicesMigrationsManager* self,
                                                           const gchar* current_version,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	ProtonPlusServicesMigrationsManagerCheckAndMigrateData* _data_;
	ProtonPlusServicesMigrationsManager* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (current_version != NULL);
	_data_ = g_slice_new0 (ProtonPlusServicesMigrationsManagerCheckAndMigrateData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_services_migrations_manager_check_and_migrate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (current_version);
	_g_free0 (_data_->current_version);
	_data_->current_version = _tmp1_;
	proton_plus_services_migrations_manager_check_and_migrate_co (_data_);
}

void
proton_plus_services_migrations_manager_check_and_migrate_finish (ProtonPlusServicesMigrationsManager* self,
                                                                  GAsyncResult* _res_)
{
	ProtonPlusServicesMigrationsManagerCheckAndMigrateData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
proton_plus_services_migrations_manager_check_and_migrate_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_)
{
	ProtonPlusServicesMigrationsManagerCheckAndMigrateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	proton_plus_services_migrations_manager_check_and_migrate_co (_data_);
}

static gboolean
proton_plus_services_migrations_manager_check_and_migrate_co (ProtonPlusServicesMigrationsManagerCheckAndMigrateData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->completed_migrations;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _data_->_tmp0_);
	_data_->_tmp1_ = proton_plus_globals_SETTINGS;
	_data_->_tmp2_ = _g_object_ref0 (_data_->_tmp1_);
	_data_->settings = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->settings;
	if (_data_->_tmp3_ == NULL) {
		g_print ("GSettings is not initialized. Skipping migration check.\n");
		_g_object_unref0 (_data_->settings);
		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_->settings;
	_data_->_tmp5_ = g_settings_get_string (_data_->_tmp4_, "last-version");
	_data_->last_version = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->last_version;
	if (g_strcmp0 (_data_->_tmp6_, "") == 0) {
		_data_->_tmp7_ = _data_->settings;
		if (g_settings_get_boolean (_data_->_tmp7_, "first-run") == FALSE) {
			_data_->_tmp8_ = g_strdup ("0.5.0");
			_g_free0 (_data_->last_version);
			_data_->last_version = _data_->_tmp8_;
		} else {
			_data_->_tmp9_ = _data_->settings;
			g_settings_set_string (_data_->_tmp9_, "last-version", _data_->current_version);
			_g_free0 (_data_->last_version);
			_g_object_unref0 (_data_->settings);
			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_->_tmp10_ = _data_->last_version;
	if (g_strcmp0 (_data_->_tmp10_, _data_->current_version) == 0) {
		_g_free0 (_data_->last_version);
		_g_object_unref0 (_data_->settings);
		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_->_tmp11_ = _data_->last_version;
	g_print ("Detected version change from %s to %s. Running migration stack…\n", _data_->_tmp11_, _data_->current_version);
	{
		_data_->_tmp12_ = _data_->self->priv->migrations;
		_data_->_step_list = _data_->_tmp12_;
		_data_->_tmp13_ = _data_->_step_list;
		_data_->_tmp14_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp13_);
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_step_size = _data_->_tmp15_;
		_data_->_step_index = -1;
		while (TRUE) {
			_data_->_step_index = _data_->_step_index + 1;
			_data_->_tmp16_ = _data_->_step_index;
			_data_->_tmp17_ = _data_->_step_size;
			if (!(_data_->_tmp16_ < _data_->_tmp17_)) {
				break;
			}
			_data_->_tmp18_ = _data_->_step_list;
			_data_->_tmp19_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp18_, _data_->_step_index);
			_data_->step = (ProtonPlusServicesMigrationsIMigration*) _data_->_tmp19_;
			_data_->_tmp21_ = _data_->step;
			_data_->_tmp22_ = proton_plus_services_migrations_imigration_get_version (_data_->_tmp21_);
			_data_->_tmp23_ = _data_->_tmp22_;
			_data_->_tmp24_ = _data_->last_version;
			if (proton_plus_services_migrations_manager_compare_versions (_data_->self, _data_->_tmp23_, _data_->_tmp24_) > 0) {
				_data_->_tmp25_ = _data_->step;
				_data_->_tmp26_ = proton_plus_services_migrations_imigration_get_version (_data_->_tmp25_);
				_data_->_tmp27_ = _data_->_tmp26_;
				_data_->_tmp20_ = proton_plus_services_migrations_manager_compare_versions (_data_->self, _data_->_tmp27_, _data_->current_version) <= 0;
			} else {
				_data_->_tmp20_ = FALSE;
			}
			if (_data_->_tmp20_) {
				{
					_data_->_tmp28_ = _data_->step;
					_data_->_state_ = 1;
					proton_plus_services_migrations_imigration_migrate (_data_->_tmp28_, proton_plus_services_migrations_manager_check_and_migrate_ready, _data_);
					return FALSE;
					_state_1:
					proton_plus_services_migrations_imigration_migrate_finish (_data_->_tmp28_, _data_->_res_, &_data_->_inner_error0_);
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_data_->_tmp29_ = _data_->self->priv->completed_migrations;
					_data_->_tmp30_ = _data_->step;
					gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp29_, _data_->_tmp30_);
					_data_->_tmp31_ = _data_->settings;
					_data_->_tmp32_ = _data_->step;
					_data_->_tmp33_ = proton_plus_services_migrations_imigration_get_version (_data_->_tmp32_);
					_data_->_tmp34_ = _data_->_tmp33_;
					g_settings_set_string (_data_->_tmp31_, "last-version", _data_->_tmp34_);
				}
				goto __finally0;
				__catch0_g_error:
				{
					_data_->e = _data_->_inner_error0_;
					_data_->_inner_error0_ = NULL;
					_data_->_tmp35_ = _data_->step;
					_data_->_tmp36_ = proton_plus_services_migrations_imigration_get_version (_data_->_tmp35_);
					_data_->_tmp37_ = _data_->_tmp36_;
					_data_->_tmp38_ = _data_->e;
					_data_->_tmp39_ = _data_->_tmp38_->message;
					g_critical ("manager.vala:58: Migration failed during migration to version %s: %s", _data_->_tmp37_, _data_->_tmp39_);
					_g_error_free0 (_data_->e);
					_g_object_unref0 (_data_->step);
					_g_free0 (_data_->last_version);
					_g_object_unref0 (_data_->settings);
					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;
				}
				__finally0:
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->step);
					_g_free0 (_data_->last_version);
					_g_object_unref0 (_data_->settings);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
					g_clear_error (&_data_->_inner_error0_);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
			}
			_g_object_unref0 (_data_->step);
		}
	}
	_data_->_tmp40_ = _data_->settings;
	g_settings_set_string (_data_->_tmp40_, "last-version", _data_->current_version);
	_g_free0 (_data_->last_version);
	_g_object_unref0 (_data_->settings);
	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 Block47Data*
block47_data_ref (Block47Data* _data47_)
{
	g_atomic_int_inc (&_data47_->_ref_count_);
	return _data47_;
}

static void
block47_data_unref (void * _userdata_)
{
	Block47Data* _data47_;
	_data47_ = (Block47Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data47_->_ref_count_)) {
		ProtonPlusServicesMigrationsManager* self;
		self = _data47_->self;
		_g_main_loop_unref0 (_data47_->loop);
		_g_object_unref0 (self);
		g_slice_free (Block47Data, _data47_);
	}
}

static void
__lambda355_ (Block47Data* _data47_,
              GObject* obj,
              GAsyncResult* res)
{
	ProtonPlusServicesMigrationsManager* self;
	self = _data47_->self;
	g_return_if_fail (res != NULL);
	proton_plus_services_migrations_manager_check_and_migrate_finish (self, res);
	g_main_loop_quit (_data47_->loop);
}

static void
___lambda355__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda355_ (self, source_object, res);
	block47_data_unref (self);
}

void
proton_plus_services_migrations_manager_check_and_migrate_sync (ProtonPlusServicesMigrationsManager* self,
                                                                const gchar* current_version)
{
	Block47Data* _data47_;
	GMainLoop* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (current_version != NULL);
	_data47_ = g_slice_new0 (Block47Data);
	_data47_->_ref_count_ = 1;
	_data47_->self = g_object_ref (self);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_data47_->loop = _tmp0_;
	proton_plus_services_migrations_manager_check_and_migrate (self, current_version, ___lambda355__gasync_ready_callback, block47_data_ref (_data47_));
	g_main_loop_run (_data47_->loop);
	block47_data_unref (_data47_);
	_data47_ = NULL;
}

void
proton_plus_services_migrations_manager_post_migrate (ProtonPlusServicesMigrationsManager* self,
                                                      ProtonPlusServicesMigrationsMigrationContext* context)
{
	g_return_if_fail (self != NULL);
	{
		GeeArrayList* _step_list = NULL;
		GeeArrayList* _tmp0_;
		gint _step_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _step_index = 0;
		_tmp0_ = self->priv->completed_migrations;
		_step_list = _tmp0_;
		_tmp1_ = _step_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_step_size = _tmp3_;
		_step_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ProtonPlusServicesMigrationsIMigration* step = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			ProtonPlusServicesMigrationsIMigration* _tmp8_;
			_step_index = _step_index + 1;
			_tmp4_ = _step_index;
			_tmp5_ = _step_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _step_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _step_index);
			step = (ProtonPlusServicesMigrationsIMigration*) _tmp7_;
			_tmp8_ = step;
			proton_plus_services_migrations_imigration_post_migrate (_tmp8_, context);
			_g_object_unref0 (step);
		}
	}
}

/**
         * Helper method for comparing semantic versions (X.Y.Z)
         * Returns: > 0 if v1 > v2, < 0 if v1 < v2, 0 if v1 == v2
         */
static gint
proton_plus_services_migrations_manager_compare_versions (ProtonPlusServicesMigrationsManager* self,
                                                          const gchar* v1,
                                                          const gchar* v2)
{
	gchar** parts1 = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint parts1_length1;
	gint _parts1_size_;
	gchar** parts2 = NULL;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint parts2_length1;
	gint _parts2_size_;
	gint max_length = 0;
	gchar** _tmp4_;
	gint _tmp4__length1;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (v1 != NULL, -1);
	g_return_val_if_fail (v2 != NULL, -1);
	_tmp1_ = _tmp0_ = g_strsplit (v1, ".", 0);
	parts1 = _tmp1_;
	parts1_length1 = _vala_array_length (_tmp0_);
	_parts1_size_ = parts1_length1;
	_tmp3_ = _tmp2_ = g_strsplit (v2, ".", 0);
	parts2 = _tmp3_;
	parts2_length1 = _vala_array_length (_tmp2_);
	_parts2_size_ = parts2_length1;
	_tmp4_ = parts1;
	_tmp4__length1 = parts1_length1;
	_tmp5_ = parts2;
	_tmp5__length1 = parts2_length1;
	max_length = MAX (_tmp4__length1, _tmp5__length1);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp6_ = FALSE;
			_tmp6_ = TRUE;
			while (TRUE) {
				gint _tmp8_ = 0;
				gchar** _tmp9_;
				gint _tmp9__length1;
				gint p1 = 0;
				gint _tmp12_ = 0;
				gchar** _tmp13_;
				gint _tmp13__length1;
				gint p2 = 0;
				if (!_tmp6_) {
					gint _tmp7_;
					_tmp7_ = i;
					i = _tmp7_ + 1;
				}
				_tmp6_ = FALSE;
				if (!(i < max_length)) {
					break;
				}
				_tmp9_ = parts1;
				_tmp9__length1 = parts1_length1;
				if (i < _tmp9__length1) {
					gchar** _tmp10_;
					gint _tmp10__length1;
					const gchar* _tmp11_;
					_tmp10_ = parts1;
					_tmp10__length1 = parts1_length1;
					_tmp11_ = _tmp10_[i];
					_tmp8_ = atoi (_tmp11_);
				} else {
					_tmp8_ = 0;
				}
				p1 = _tmp8_;
				_tmp13_ = parts2;
				_tmp13__length1 = parts2_length1;
				if (i < _tmp13__length1) {
					gchar** _tmp14_;
					gint _tmp14__length1;
					const gchar* _tmp15_;
					_tmp14_ = parts2;
					_tmp14__length1 = parts2_length1;
					_tmp15_ = _tmp14_[i];
					_tmp12_ = atoi (_tmp15_);
				} else {
					_tmp12_ = 0;
				}
				p2 = _tmp12_;
				if (p1 != p2) {
					result = p1 - p2;
					parts2 = (_vala_array_free (parts2, parts2_length1, (GDestroyNotify) g_free), NULL);
					parts1 = (_vala_array_free (parts1, parts1_length1, (GDestroyNotify) g_free), NULL);
					return result;
				}
			}
		}
	}
	result = 0;
	parts2 = (_vala_array_free (parts2, parts2_length1, (GDestroyNotify) g_free), NULL);
	parts1 = (_vala_array_free (parts1, parts1_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

static void
proton_plus_services_migrations_manager_class_init (ProtonPlusServicesMigrationsManagerClass * klass,
                                                    gpointer klass_data)
{
	proton_plus_services_migrations_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusServicesMigrationsManager_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_services_migrations_manager_finalize;
}

static void
proton_plus_services_migrations_manager_instance_init (ProtonPlusServicesMigrationsManager * self,
                                                       gpointer klass)
{
	self->priv = proton_plus_services_migrations_manager_get_instance_private (self);
}

static void
proton_plus_services_migrations_manager_finalize (GObject * obj)
{
	ProtonPlusServicesMigrationsManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_SERVICES_MIGRATIONS_TYPE_MANAGER, ProtonPlusServicesMigrationsManager);
	_g_object_unref0 (self->priv->migrations);
	_g_object_unref0 (self->priv->completed_migrations);
	G_OBJECT_CLASS (proton_plus_services_migrations_manager_parent_class)->finalize (obj);
}

static GType
proton_plus_services_migrations_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusServicesMigrationsManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_services_migrations_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusServicesMigrationsManager), 0, (GInstanceInitFunc) proton_plus_services_migrations_manager_instance_init, NULL };
	GType proton_plus_services_migrations_manager_type_id;
	proton_plus_services_migrations_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusServicesMigrationsManager", &g_define_type_info, 0);
	ProtonPlusServicesMigrationsManager_private_offset = g_type_add_instance_private (proton_plus_services_migrations_manager_type_id, sizeof (ProtonPlusServicesMigrationsManagerPrivate));
	return proton_plus_services_migrations_manager_type_id;
}

GType
proton_plus_services_migrations_manager_get_type (void)
{
	static volatile gsize proton_plus_services_migrations_manager_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_services_migrations_manager_type_id__once)) {
		GType proton_plus_services_migrations_manager_type_id;
		proton_plus_services_migrations_manager_type_id = proton_plus_services_migrations_manager_get_type_once ();
		g_once_init_leave (&proton_plus_services_migrations_manager_type_id__once, proton_plus_services_migrations_manager_type_id);
	}
	return proton_plus_services_migrations_manager_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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;
}

