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

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright (c) 2017 elementary LLC. (https://elementary.io)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Corentin Noël <corentin@elementary.io>
 */

#include <glib-object.h>
#include <gio/gio.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <camel/camel.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 MAIL_TYPE_ACCOUNT_SAVED_STATE (mail_account_saved_state_get_type ())
#define MAIL_ACCOUNT_SAVED_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_ACCOUNT_SAVED_STATE, MailAccountSavedState))
#define MAIL_ACCOUNT_SAVED_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_ACCOUNT_SAVED_STATE, MailAccountSavedStateClass))
#define MAIL_IS_ACCOUNT_SAVED_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_ACCOUNT_SAVED_STATE))
#define MAIL_IS_ACCOUNT_SAVED_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_ACCOUNT_SAVED_STATE))
#define MAIL_ACCOUNT_SAVED_STATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_ACCOUNT_SAVED_STATE, MailAccountSavedStateClass))

typedef struct _MailAccountSavedState MailAccountSavedState;
typedef struct _MailAccountSavedStateClass MailAccountSavedStateClass;
typedef struct _MailAccountSavedStatePrivate MailAccountSavedStatePrivate;

#define MAIL_BACKEND_TYPE_ACCOUNT (mail_backend_account_get_type ())
#define MAIL_BACKEND_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccount))
#define MAIL_BACKEND_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccountClass))
#define MAIL_BACKEND_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_BACKEND_TYPE_ACCOUNT))
#define MAIL_BACKEND_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_BACKEND_TYPE_ACCOUNT))
#define MAIL_BACKEND_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_BACKEND_TYPE_ACCOUNT, MailBackendAccountClass))

typedef struct _MailBackendAccount MailBackendAccount;
typedef struct _MailBackendAccountClass MailBackendAccountClass;

#define MAIL_SOURCE_LIST_TYPE_ITEM (mail_source_list_item_get_type ())
#define MAIL_SOURCE_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_SOURCE_LIST_TYPE_ITEM, MailSourceListItem))
#define MAIL_SOURCE_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_SOURCE_LIST_TYPE_ITEM, MailSourceListItemClass))
#define MAIL_SOURCE_LIST_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_SOURCE_LIST_TYPE_ITEM))
#define MAIL_SOURCE_LIST_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_SOURCE_LIST_TYPE_ITEM))
#define MAIL_SOURCE_LIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_SOURCE_LIST_TYPE_ITEM, MailSourceListItemClass))

typedef struct _MailSourceListItem MailSourceListItem;
typedef struct _MailSourceListItemClass MailSourceListItemClass;

#define MAIL_SOURCE_LIST_TYPE_EXPANDABLE_ITEM (mail_source_list_expandable_item_get_type ())
#define MAIL_SOURCE_LIST_EXPANDABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, MailSourceListExpandableItem))
#define MAIL_SOURCE_LIST_EXPANDABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, MailSourceListExpandableItemClass))
#define MAIL_SOURCE_LIST_IS_EXPANDABLE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_SOURCE_LIST_TYPE_EXPANDABLE_ITEM))
#define MAIL_SOURCE_LIST_IS_EXPANDABLE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_SOURCE_LIST_TYPE_EXPANDABLE_ITEM))
#define MAIL_SOURCE_LIST_EXPANDABLE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_SOURCE_LIST_TYPE_EXPANDABLE_ITEM, MailSourceListExpandableItemClass))

typedef struct _MailSourceListExpandableItem MailSourceListExpandableItem;
typedef struct _MailSourceListExpandableItemClass MailSourceListExpandableItemClass;

#define MAIL_TYPE_FOLDER_SOURCE_ITEM (mail_folder_source_item_get_type ())
#define MAIL_FOLDER_SOURCE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_FOLDER_SOURCE_ITEM, MailFolderSourceItem))
#define MAIL_FOLDER_SOURCE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_FOLDER_SOURCE_ITEM, MailFolderSourceItemClass))
#define MAIL_IS_FOLDER_SOURCE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_FOLDER_SOURCE_ITEM))
#define MAIL_IS_FOLDER_SOURCE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_FOLDER_SOURCE_ITEM))
#define MAIL_FOLDER_SOURCE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_FOLDER_SOURCE_ITEM, MailFolderSourceItemClass))

typedef struct _MailFolderSourceItem MailFolderSourceItem;
typedef struct _MailFolderSourceItemClass MailFolderSourceItemClass;
enum  {
	MAIL_ACCOUNT_SAVED_STATE_0_PROPERTY,
	MAIL_ACCOUNT_SAVED_STATE_ACCOUNT_PROPERTY,
	MAIL_ACCOUNT_SAVED_STATE_NUM_PROPERTIES
};
static GParamSpec* mail_account_saved_state_properties[MAIL_ACCOUNT_SAVED_STATE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block40Data Block40Data;

#define MAIL_TYPE_ACCOUNT_SOURCE_ITEM (mail_account_source_item_get_type ())
#define MAIL_ACCOUNT_SOURCE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_ACCOUNT_SOURCE_ITEM, MailAccountSourceItem))
#define MAIL_ACCOUNT_SOURCE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_ACCOUNT_SOURCE_ITEM, MailAccountSourceItemClass))
#define MAIL_IS_ACCOUNT_SOURCE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_ACCOUNT_SOURCE_ITEM))
#define MAIL_IS_ACCOUNT_SOURCE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_ACCOUNT_SOURCE_ITEM))
#define MAIL_ACCOUNT_SOURCE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_ACCOUNT_SOURCE_ITEM, MailAccountSourceItemClass))

typedef struct _MailAccountSourceItem MailAccountSourceItem;
typedef struct _MailAccountSourceItemClass MailAccountSourceItemClass;
typedef struct _Block41Data Block41Data;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _MailAccountSavedState {
	GObject parent_instance;
	MailAccountSavedStatePrivate * priv;
};

struct _MailAccountSavedStateClass {
	GObjectClass parent_class;
};

struct _MailAccountSavedStatePrivate {
	MailBackendAccount* _account;
	GSettings* settings;
	GeeHashMap* items;
};

struct _Block40Data {
	int _ref_count_;
	MailAccountSavedState* self;
	MailSourceListExpandableItem* item;
};

struct _Block41Data {
	int _ref_count_;
	Block40Data * _data40_;
	MailFolderSourceItem* folder_item;
};

static gint MailAccountSavedState_private_offset;
static gpointer mail_account_saved_state_parent_class = NULL;

VALA_EXTERN GType mail_account_saved_state_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailAccountSavedState, g_object_unref)
VALA_EXTERN GType mail_backend_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailBackendAccount, g_object_unref)
VALA_EXTERN GType mail_source_list_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailSourceListItem, g_object_unref)
VALA_EXTERN GType mail_source_list_expandable_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailSourceListExpandableItem, g_object_unref)
VALA_EXTERN GType mail_folder_source_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailFolderSourceItem, g_object_unref)
VALA_EXTERN MailAccountSavedState* mail_account_saved_state_new (MailBackendAccount* account);
VALA_EXTERN MailAccountSavedState* mail_account_saved_state_construct (GType object_type,
                                                           MailBackendAccount* account);
VALA_EXTERN void mail_account_saved_state_bind_with_expandable_item (MailAccountSavedState* self,
                                                         MailSourceListExpandableItem* item);
static Block40Data* block40_data_ref (Block40Data* _data40_);
static void block40_data_unref (void * _userdata_);
VALA_EXTERN GType mail_account_source_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailAccountSourceItem, g_object_unref)
static Block41Data* block41_data_ref (Block41Data* _data41_);
static void block41_data_unref (void * _userdata_);
VALA_EXTERN const gchar* mail_folder_source_item_get_full_name (MailFolderSourceItem* self);
static gboolean _vala_string_array_contains (gchar* * stack,
                                      gssize stack_length,
                                      const gchar* needle);
VALA_EXTERN void mail_source_list_expandable_item_set_expanded (MailSourceListExpandableItem* self,
                                                    gboolean value);
static void ____lambda15_ (Block41Data* _data41_);
VALA_EXTERN gboolean mail_source_list_expandable_item_get_expanded (MailSourceListExpandableItem* self);
static void _vala_array_add7 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static void _vala_array_add8 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static gchar** _vala_array_dup1 (gchar** self,
                          gssize length);
static void _____lambda15__g_object_notify (GObject* _sender,
                                     GParamSpec* pspec,
                                     gpointer self);
VALA_EXTERN MailBackendAccount* mail_account_saved_state_get_account (MailAccountSavedState* self);
static void mail_account_saved_state_set_account (MailAccountSavedState* self,
                                           MailBackendAccount* value);
static GObject * mail_account_saved_state_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
VALA_EXTERN CamelService* mail_backend_account_get_service (MailBackendAccount* self);
static void mail_account_saved_state_finalize (GObject * obj);
static GType mail_account_saved_state_get_type_once (void);
static void _vala_mail_account_saved_state_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_mail_account_saved_state_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);
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
mail_account_saved_state_get_instance_private (MailAccountSavedState* self)
{
	return G_STRUCT_MEMBER_P (self, MailAccountSavedState_private_offset);
}

MailAccountSavedState*
mail_account_saved_state_construct (GType object_type,
                                    MailBackendAccount* account)
{
	MailAccountSavedState * self = NULL;
	g_return_val_if_fail (account != NULL, NULL);
	self = (MailAccountSavedState*) g_object_new (object_type, "account", account, NULL);
	return self;
}

MailAccountSavedState*
mail_account_saved_state_new (MailBackendAccount* account)
{
	return mail_account_saved_state_construct (MAIL_TYPE_ACCOUNT_SAVED_STATE, account);
}

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

static Block40Data*
block40_data_ref (Block40Data* _data40_)
{
	g_atomic_int_inc (&_data40_->_ref_count_);
	return _data40_;
}

static void
block40_data_unref (void * _userdata_)
{
	Block40Data* _data40_;
	_data40_ = (Block40Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data40_->_ref_count_)) {
		MailAccountSavedState* self;
		self = _data40_->self;
		_g_object_unref0 (_data40_->item);
		_g_object_unref0 (self);
		g_slice_free (Block40Data, _data40_);
	}
}

static Block41Data*
block41_data_ref (Block41Data* _data41_)
{
	g_atomic_int_inc (&_data41_->_ref_count_);
	return _data41_;
}

static void
block41_data_unref (void * _userdata_)
{
	Block41Data* _data41_;
	_data41_ = (Block41Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data41_->_ref_count_)) {
		MailAccountSavedState* self;
		self = _data41_->_data40_->self;
		_g_object_unref0 (_data41_->folder_item);
		block40_data_unref (_data41_->_data40_);
		_data41_->_data40_ = NULL;
		g_slice_free (Block41Data, _data41_);
	}
}

static gboolean
_vala_string_array_contains (gchar* * stack,
                             gssize stack_length,
                             const gchar* needle)
{
	gssize i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}

static void
_vala_array_add7 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add8 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gchar**
_vala_array_dup1 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
____lambda15_ (Block41Data* _data41_)
{
	Block40Data* _data40_;
	MailAccountSavedState* self;
	gchar** folders = NULL;
	GSettings* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint folders_length1;
	gint _folders_size_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GSettings* _tmp20_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	_data40_ = _data41_->_data40_;
	self = _data40_->self;
	_tmp0_ = self->priv->settings;
	_tmp2_ = _tmp1_ = g_settings_get_strv (_tmp0_, "expanded-folders");
	folders = _tmp2_;
	folders_length1 = _vala_array_length (_tmp1_);
	_folders_size_ = folders_length1;
	_tmp3_ = mail_source_list_expandable_item_get_expanded (_data40_->item);
	_tmp4_ = _tmp3_;
	if (_tmp4_) {
		MailFolderSourceItem* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp5_ = _data41_->folder_item;
		_tmp6_ = mail_folder_source_item_get_full_name (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_strdup (_tmp7_);
		_vala_array_add7 (&folders, &folders_length1, &_folders_size_, _tmp8_);
	} else {
		gchar** new_folders = NULL;
		gchar** _tmp9_;
		gint new_folders_length1;
		gint _new_folders_size_;
		gchar** _tmp10_;
		gint _tmp10__length1;
		gchar** _tmp18_;
		gint _tmp18__length1;
		gchar** _tmp19_;
		gint _tmp19__length1;
		_tmp9_ = g_new0 (gchar*, 0 + 1);
		new_folders = _tmp9_;
		new_folders_length1 = 0;
		_new_folders_size_ = new_folders_length1;
		_tmp10_ = folders;
		_tmp10__length1 = folders_length1;
		{
			gchar** folder_collection = NULL;
			gint folder_collection_length1 = 0;
			gint _folder_collection_size_ = 0;
			gint folder_it = 0;
			folder_collection = _tmp10_;
			folder_collection_length1 = _tmp10__length1;
			for (folder_it = 0; folder_it < folder_collection_length1; folder_it = folder_it + 1) {
				gchar* _tmp11_;
				gchar* folder = NULL;
				_tmp11_ = g_strdup (folder_collection[folder_it]);
				folder = _tmp11_;
				{
					const gchar* _tmp12_;
					MailFolderSourceItem* _tmp13_;
					const gchar* _tmp14_;
					const gchar* _tmp15_;
					_tmp12_ = folder;
					_tmp13_ = _data41_->folder_item;
					_tmp14_ = mail_folder_source_item_get_full_name (_tmp13_);
					_tmp15_ = _tmp14_;
					if (g_strcmp0 (_tmp12_, _tmp15_) != 0) {
						const gchar* _tmp16_;
						gchar* _tmp17_;
						_tmp16_ = folder;
						_tmp17_ = g_strdup (_tmp16_);
						_vala_array_add8 (&new_folders, &new_folders_length1, &_new_folders_size_, _tmp17_);
					}
					_g_free0 (folder);
				}
			}
		}
		_tmp18_ = new_folders;
		_tmp18__length1 = new_folders_length1;
		_tmp19_ = (_tmp18_ != NULL) ? _vala_array_dup1 (_tmp18_, _tmp18__length1) : _tmp18_;
		_tmp19__length1 = _tmp18__length1;
		folders = (_vala_array_free (folders, folders_length1, (GDestroyNotify) g_free), NULL);
		folders = _tmp19_;
		folders_length1 = _tmp19__length1;
		_folders_size_ = folders_length1;
		new_folders = (_vala_array_free (new_folders, new_folders_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp20_ = self->priv->settings;
	_tmp21_ = folders;
	_tmp21__length1 = folders_length1;
	g_settings_set_strv (_tmp20_, "expanded-folders", _tmp21_);
	folders = (_vala_array_free (folders, folders_length1, (GDestroyNotify) g_free), NULL);
}

static void
_____lambda15__g_object_notify (GObject* _sender,
                                GParamSpec* pspec,
                                gpointer self)
{
	____lambda15_ (self);
}

void
mail_account_saved_state_bind_with_expandable_item (MailAccountSavedState* self,
                                                    MailSourceListExpandableItem* item)
{
	Block40Data* _data40_;
	MailSourceListExpandableItem* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_data40_ = g_slice_new0 (Block40Data);
	_data40_->_ref_count_ = 1;
	_data40_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (item);
	_g_object_unref0 (_data40_->item);
	_data40_->item = _tmp0_;
	if (MAIL_IS_ACCOUNT_SOURCE_ITEM (_data40_->item)) {
		GSettings* _tmp1_;
		_tmp1_ = self->priv->settings;
		g_settings_bind (_tmp1_, "expanded", (GObject*) _data40_->item, "expanded", G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_GET_NO_CHANGES);
	} else {
		if (MAIL_IS_FOLDER_SOURCE_ITEM (_data40_->item)) {
			Block41Data* _data41_;
			MailFolderSourceItem* _tmp2_;
			GeeHashMap* _tmp3_;
			MailFolderSourceItem* _tmp4_;
			const gchar* _tmp5_;
			const gchar* _tmp6_;
			MailFolderSourceItem* _tmp7_;
			MailFolderSourceItem* _tmp8_;
			const gchar* _tmp9_;
			const gchar* _tmp10_;
			GSettings* _tmp11_;
			gchar** _tmp12_;
			gchar** _tmp13_;
			gchar** _tmp14_;
			gint _tmp14__length1;
			gboolean _tmp15_;
			_data41_ = g_slice_new0 (Block41Data);
			_data41_->_ref_count_ = 1;
			_data41_->_data40_ = block40_data_ref (_data40_);
			_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data40_->item, MAIL_TYPE_FOLDER_SOURCE_ITEM, MailFolderSourceItem));
			_data41_->folder_item = _tmp2_;
			_tmp3_ = self->priv->items;
			_tmp4_ = _data41_->folder_item;
			_tmp5_ = mail_folder_source_item_get_full_name (_tmp4_);
			_tmp6_ = _tmp5_;
			_tmp7_ = _data41_->folder_item;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp3_, _tmp6_, _tmp7_);
			_tmp8_ = _data41_->folder_item;
			_tmp9_ = mail_folder_source_item_get_full_name (_tmp8_);
			_tmp10_ = _tmp9_;
			_tmp11_ = self->priv->settings;
			_tmp13_ = _tmp12_ = g_settings_get_strv (_tmp11_, "expanded-folders");
			_tmp14_ = _tmp13_;
			_tmp14__length1 = _vala_array_length (_tmp12_);
			_tmp15_ = _vala_string_array_contains (_tmp14_, _vala_array_length (_tmp12_), _tmp10_);
			_tmp14_ = (_vala_array_free (_tmp14_, _tmp14__length1, (GDestroyNotify) g_free), NULL);
			if (_tmp15_) {
				mail_source_list_expandable_item_set_expanded (_data40_->item, TRUE);
			}
			g_signal_connect_data ((GObject*) _data40_->item, "notify::expanded", (GCallback) _____lambda15__g_object_notify, block41_data_ref (_data41_), (GClosureNotify) block41_data_unref, 0);
			block41_data_unref (_data41_);
			_data41_ = NULL;
		}
	}
	block40_data_unref (_data40_);
	_data40_ = NULL;
}

MailBackendAccount*
mail_account_saved_state_get_account (MailAccountSavedState* self)
{
	MailBackendAccount* result;
	MailBackendAccount* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_account;
	result = _tmp0_;
	return result;
}

static void
mail_account_saved_state_set_account (MailAccountSavedState* self,
                                      MailBackendAccount* value)
{
	MailBackendAccount* old_value;
	g_return_if_fail (self != NULL);
	old_value = mail_account_saved_state_get_account (self);
	if (old_value != value) {
		self->priv->_account = value;
		g_object_notify_by_pspec ((GObject *) self, mail_account_saved_state_properties[MAIL_ACCOUNT_SAVED_STATE_ACCOUNT_PROPERTY]);
	}
}

static GObject *
mail_account_saved_state_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MailAccountSavedState * self;
	MailBackendAccount* _tmp0_;
	CamelService* _tmp1_;
	CamelService* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GSettings* _tmp7_;
	GeeHashMap* _tmp8_;
	parent_class = G_OBJECT_CLASS (mail_account_saved_state_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_TYPE_ACCOUNT_SAVED_STATE, MailAccountSavedState);
	_tmp0_ = self->priv->_account;
	_tmp1_ = mail_backend_account_get_service (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = camel_service_get_uid (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strdup_printf ("/io/elementary/mail/accounts/%s/", _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_settings_new_with_path ("io.elementary.mail.accounts", _tmp6_);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp7_;
	_g_free0 (_tmp6_);
	_tmp8_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, MAIL_TYPE_FOLDER_SOURCE_ITEM, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->items);
	self->priv->items = _tmp8_;
	return obj;
}

static void
mail_account_saved_state_class_init (MailAccountSavedStateClass * klass,
                                     gpointer klass_data)
{
	mail_account_saved_state_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &MailAccountSavedState_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_mail_account_saved_state_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_mail_account_saved_state_set_property;
	G_OBJECT_CLASS (klass)->constructor = mail_account_saved_state_constructor;
	G_OBJECT_CLASS (klass)->finalize = mail_account_saved_state_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), MAIL_ACCOUNT_SAVED_STATE_ACCOUNT_PROPERTY, mail_account_saved_state_properties[MAIL_ACCOUNT_SAVED_STATE_ACCOUNT_PROPERTY] = g_param_spec_object ("account", "account", "account", MAIL_BACKEND_TYPE_ACCOUNT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
mail_account_saved_state_instance_init (MailAccountSavedState * self,
                                        gpointer klass)
{
	self->priv = mail_account_saved_state_get_instance_private (self);
}

static void
mail_account_saved_state_finalize (GObject * obj)
{
	MailAccountSavedState * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_TYPE_ACCOUNT_SAVED_STATE, MailAccountSavedState);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->items);
	G_OBJECT_CLASS (mail_account_saved_state_parent_class)->finalize (obj);
}

static GType
mail_account_saved_state_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MailAccountSavedStateClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mail_account_saved_state_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MailAccountSavedState), 0, (GInstanceInitFunc) mail_account_saved_state_instance_init, NULL };
	GType mail_account_saved_state_type_id;
	mail_account_saved_state_type_id = g_type_register_static (G_TYPE_OBJECT, "MailAccountSavedState", &g_define_type_info, 0);
	MailAccountSavedState_private_offset = g_type_add_instance_private (mail_account_saved_state_type_id, sizeof (MailAccountSavedStatePrivate));
	return mail_account_saved_state_type_id;
}

GType
mail_account_saved_state_get_type (void)
{
	static volatile gsize mail_account_saved_state_type_id__once = 0;
	if (g_once_init_enter (&mail_account_saved_state_type_id__once)) {
		GType mail_account_saved_state_type_id;
		mail_account_saved_state_type_id = mail_account_saved_state_get_type_once ();
		g_once_init_leave (&mail_account_saved_state_type_id__once, mail_account_saved_state_type_id);
	}
	return mail_account_saved_state_type_id__once;
}

static void
_vala_mail_account_saved_state_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	MailAccountSavedState * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, MAIL_TYPE_ACCOUNT_SAVED_STATE, MailAccountSavedState);
	switch (property_id) {
		case MAIL_ACCOUNT_SAVED_STATE_ACCOUNT_PROPERTY:
		g_value_set_object (value, mail_account_saved_state_get_account (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_mail_account_saved_state_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	MailAccountSavedState * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, MAIL_TYPE_ACCOUNT_SAVED_STATE, MailAccountSavedState);
	switch (property_id) {
		case MAIL_ACCOUNT_SAVED_STATE_ACCOUNT_PROPERTY:
		mail_account_saved_state_set_account (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

