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

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <libsoup/soup.h>
#include <json-glib/json-glib.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <handy.h>

#define TOOTLE_TYPE_ACCOUNTS (tootle_accounts_get_type ())
#define TOOTLE_ACCOUNTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_ACCOUNTS, TootleAccounts))
#define TOOTLE_ACCOUNTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_ACCOUNTS, TootleAccountsClass))
#define TOOTLE_IS_ACCOUNTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_ACCOUNTS))
#define TOOTLE_IS_ACCOUNTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_ACCOUNTS))
#define TOOTLE_ACCOUNTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_ACCOUNTS, TootleAccountsClass))

typedef struct _TootleAccounts TootleAccounts;
typedef struct _TootleAccountsClass TootleAccountsClass;
typedef struct _TootleAccountsPrivate TootleAccountsPrivate;

#define TOOTLE_TYPE_ENTITY (tootle_entity_get_type ())
#define TOOTLE_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_ENTITY, TootleEntity))
#define TOOTLE_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_ENTITY, TootleEntityClass))
#define TOOTLE_IS_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_ENTITY))
#define TOOTLE_IS_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_ENTITY))
#define TOOTLE_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_ENTITY, TootleEntityClass))

typedef struct _TootleEntity TootleEntity;
typedef struct _TootleEntityClass TootleEntityClass;

#define TOOTLE_API_TYPE_ACCOUNT (tootle_api_account_get_type ())
#define TOOTLE_API_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccount))
#define TOOTLE_API_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccountClass))
#define TOOTLE_API_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_API_TYPE_ACCOUNT))
#define TOOTLE_API_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_API_TYPE_ACCOUNT))
#define TOOTLE_API_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_API_TYPE_ACCOUNT, TootleAPIAccountClass))

typedef struct _TootleAPIAccount TootleAPIAccount;
typedef struct _TootleAPIAccountClass TootleAPIAccountClass;

#define TOOTLE_TYPE_INSTANCE_ACCOUNT (tootle_instance_account_get_type ())
#define TOOTLE_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccount))
#define TOOTLE_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccountClass))
#define TOOTLE_IS_INSTANCE_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT))
#define TOOTLE_IS_INSTANCE_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_INSTANCE_ACCOUNT))
#define TOOTLE_INSTANCE_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_INSTANCE_ACCOUNT, TootleInstanceAccountClass))

typedef struct _TootleInstanceAccount TootleInstanceAccount;
typedef struct _TootleInstanceAccountClass TootleInstanceAccountClass;
enum  {
	TOOTLE_ACCOUNTS_0_PROPERTY,
	TOOTLE_ACCOUNTS_SAVED_PROPERTY,
	TOOTLE_ACCOUNTS_ACTIVE_PROPERTY,
	TOOTLE_ACCOUNTS_NUM_PROPERTIES
};
static GParamSpec* tootle_accounts_properties[TOOTLE_ACCOUNTS_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block10Data Block10Data;

#define TOOTLE_TYPE_REQUEST (tootle_request_get_type ())
#define TOOTLE_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_REQUEST, TootleRequest))
#define TOOTLE_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_REQUEST, TootleRequestClass))
#define TOOTLE_IS_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_REQUEST))
#define TOOTLE_IS_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_REQUEST))
#define TOOTLE_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_REQUEST, TootleRequestClass))

typedef struct _TootleRequest TootleRequest;
typedef struct _TootleRequestClass TootleRequestClass;
typedef void (*TootleNetworkSuccessCallback) (SoupSession* session, SoupMessage* msg, gpointer user_data, GError** error);

#define TOOTLE_TYPE_NETWORK (tootle_network_get_type ())
#define TOOTLE_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_NETWORK, TootleNetwork))
#define TOOTLE_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_NETWORK, TootleNetworkClass))
#define TOOTLE_IS_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_NETWORK))
#define TOOTLE_IS_NETWORK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_NETWORK))
#define TOOTLE_NETWORK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_NETWORK, TootleNetworkClass))

typedef struct _TootleNetwork TootleNetwork;
typedef struct _TootleNetworkClass TootleNetworkClass;
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))

#define TOOTLE_TYPE_SETTINGS (tootle_settings_get_type ())
#define TOOTLE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_SETTINGS, TootleSettings))
#define TOOTLE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_SETTINGS, TootleSettingsClass))
#define TOOTLE_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_SETTINGS))
#define TOOTLE_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_SETTINGS))
#define TOOTLE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_SETTINGS, TootleSettingsClass))

typedef struct _TootleSettings TootleSettings;
typedef struct _TootleSettingsClass TootleSettingsClass;
typedef void (*TootleNetworkErrorCallback) (gint32 code, const gchar* reason, gpointer user_data);

#define TOOTLE_TYPE_APPLICATION (tootle_application_get_type ())
#define TOOTLE_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_APPLICATION, TootleApplication))
#define TOOTLE_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_APPLICATION, TootleApplicationClass))
#define TOOTLE_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_APPLICATION))
#define TOOTLE_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_APPLICATION))
#define TOOTLE_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_APPLICATION, TootleApplicationClass))

typedef struct _TootleApplication TootleApplication;
typedef struct _TootleApplicationClass TootleApplicationClass;

#define TOOTLE_DIALOGS_TYPE_NEW_ACCOUNT (tootle_dialogs_new_account_get_type ())
#define TOOTLE_DIALOGS_NEW_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_DIALOGS_TYPE_NEW_ACCOUNT, TootleDialogsNewAccount))
#define TOOTLE_DIALOGS_NEW_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_DIALOGS_TYPE_NEW_ACCOUNT, TootleDialogsNewAccountClass))
#define TOOTLE_DIALOGS_IS_NEW_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_DIALOGS_TYPE_NEW_ACCOUNT))
#define TOOTLE_DIALOGS_IS_NEW_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_DIALOGS_TYPE_NEW_ACCOUNT))
#define TOOTLE_DIALOGS_NEW_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_DIALOGS_TYPE_NEW_ACCOUNT, TootleDialogsNewAccountClass))

typedef struct _TootleDialogsNewAccount TootleDialogsNewAccount;
typedef struct _TootleDialogsNewAccountClass TootleDialogsNewAccountClass;
typedef struct _Block11Data Block11Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _json_array_unref0(var) ((var == NULL) ? NULL : (var = (json_array_unref (var), NULL)))

struct _TootleAccounts {
	GObject parent_instance;
	TootleAccountsPrivate * priv;
};

struct _TootleAccountsClass {
	GObjectClass parent_class;
};

struct _TootleAccountsPrivate {
	gchar* dir_path;
	gchar* file_path;
	GeeArrayList* _saved;
	TootleInstanceAccount* _active;
};

struct _Block10Data {
	int _ref_count_;
	TootleAccounts* self;
	TootleInstanceAccount* acc;
	gint id;
};

struct _Block11Data {
	int _ref_count_;
	TootleAccounts* self;
	JsonBuilder* builder;
};

static gint TootleAccounts_private_offset;
static gpointer tootle_accounts_parent_class = NULL;
extern TootleNetwork* tootle_network;
extern TootleSettings* tootle_settings;
extern TootleApplication* tootle_app;

GType tootle_accounts_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAccounts, g_object_unref)
GType tootle_entity_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleEntity, g_object_unref)
GType tootle_api_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleAPIAccount, g_object_unref)
GType tootle_instance_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleInstanceAccount, g_object_unref)
void tootle_accounts_switch_account (TootleAccounts* self,
                                     gint id);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
GeeArrayList* tootle_accounts_get_saved (TootleAccounts* self);
gchar* tootle_instance_account_get_handle (TootleInstanceAccount* self);
TootleRequest* tootle_request_new_GET (const gchar* url);
TootleRequest* tootle_request_construct_GET (GType object_type,
                                             const gchar* url);
GType tootle_request_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleRequest, g_object_unref)
TootleRequest* tootle_request_with_account (TootleRequest* self,
                                            TootleInstanceAccount* account);
TootleRequest* tootle_request_then (TootleRequest* self,
                                    TootleNetworkSuccessCallback cb,
                                    gpointer cb_target,
                                    GDestroyNotify cb_target_destroy_notify);
static void __lambda101_ (Block10Data* _data10_,
                   SoupSession* sess,
                   SoupMessage* mess,
                   GError** error);
GType tootle_network_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleNetwork, g_object_unref)
JsonNode* tootle_network_parse_node (TootleNetwork* self,
                                     SoupMessage* msg,
                                     GError** error);
TootleAPIAccount* tootle_api_account_from (JsonNode* node,
                                           GError** error);
static void _vala_JsonNode_free (JsonNode* self);
void tootle_entity_patch (TootleEntity* self,
                          GObject* with);
void tootle_accounts_set_active (TootleAccounts* self,
                                 TootleInstanceAccount* value);
GType tootle_settings_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleSettings, g_object_unref)
void tootle_settings_set_current_account (TootleSettings* self,
                                          gint value);
static void ___lambda101__tootle_network_success_callback (SoupSession* session,
                                                    SoupMessage* msg,
                                                    gpointer self,
                                                    GError** error);
TootleRequest* tootle_request_on_error (TootleRequest* self,
                                        TootleNetworkErrorCallback cb,
                                        gpointer cb_target,
                                        GDestroyNotify cb_target_destroy_notify);
static void __lambda102_ (TootleAccounts* self,
                   gint32 code,
                   const gchar* reason);
GType tootle_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleApplication, g_object_unref)
static void ___lambda102__tootle_network_error_callback (gint32 code,
                                                  const gchar* reason,
                                                  gpointer self);
TootleRequest* tootle_request_exec (TootleRequest* self);
void tootle_accounts_add (TootleAccounts* self,
                          TootleInstanceAccount* account);
void tootle_accounts_save (TootleAccounts* self,
                           gboolean overwrite);
void tootle_instance_account_subscribe (TootleInstanceAccount* self);
void tootle_accounts_remove (TootleAccounts* self,
                             TootleInstanceAccount* account);
void tootle_instance_account_unsubscribe (TootleInstanceAccount* self);
gint tootle_settings_get_current_account (TootleSettings* self);
gboolean tootle_accounts_is_empty (TootleAccounts* self);
TootleDialogsNewAccount* tootle_dialogs_new_account_new (void);
TootleDialogsNewAccount* tootle_dialogs_new_account_construct (GType object_type);
GType tootle_dialogs_new_account_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleDialogsNewAccount, g_object_unref)
void tootle_accounts_init (TootleAccounts* self);
static void tootle_accounts_load (TootleAccounts* self);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static gboolean ___lambda51_ (Block11Data* _data11_,
                       TootleInstanceAccount* acc);
JsonNode* tootle_entity_to_json (TootleEntity* self);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static gboolean ____lambda51__gee_forall_func (gpointer g,
                                        gpointer self);
static void ___lambda104_ (TootleAccounts* self,
                    JsonArray* _arr,
                    guint _i,
                    JsonNode* node);
TootleInstanceAccount* tootle_instance_account_from (JsonNode* node,
                                                     GError** error);
static void ____lambda104__json_array_foreach (JsonArray* array,
                                        guint index_,
                                        JsonNode* element_node,
                                        gpointer self);
TootleAccounts* tootle_accounts_new (void);
TootleAccounts* tootle_accounts_construct (GType object_type);
void tootle_accounts_set_saved (TootleAccounts* self,
                                GeeArrayList* value);
TootleInstanceAccount* tootle_accounts_get_active (TootleAccounts* self);
static GObject * tootle_accounts_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties);
static void tootle_accounts_finalize (GObject * obj);
static GType tootle_accounts_get_type_once (void);
static void _vala_tootle_accounts_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_tootle_accounts_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
tootle_accounts_get_instance_private (TootleAccounts* self)
{
	return G_STRUCT_MEMBER_P (self, TootleAccounts_private_offset);
}

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		TootleAccounts* self;
		self = _data10_->self;
		_g_object_unref0 (_data10_->acc);
		_g_object_unref0 (self);
		g_slice_free (Block10Data, _data10_);
	}
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

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

static void
__lambda101_ (Block10Data* _data10_,
              SoupSession* sess,
              SoupMessage* mess,
              GError** error)
{
	TootleAccounts* self;
	JsonNode* node = NULL;
	TootleNetwork* _tmp0_;
	JsonNode* _tmp1_;
	TootleAPIAccount* updated = NULL;
	JsonNode* _tmp2_;
	TootleAPIAccount* _tmp3_;
	TootleAPIAccount* _tmp4_;
	TootleSettings* _tmp5_;
	GError* _inner_error0_ = NULL;
	self = _data10_->self;
	g_return_if_fail (sess != NULL);
	g_return_if_fail (mess != NULL);
	_tmp0_ = tootle_network;
	_tmp1_ = tootle_network_parse_node (_tmp0_, mess, &_inner_error0_);
	node = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp2_ = node;
	_tmp3_ = tootle_api_account_from (_tmp2_, &_inner_error0_);
	updated = _tmp3_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		__vala_JsonNode_free0 (node);
		return;
	}
	_tmp4_ = updated;
	tootle_entity_patch ((TootleEntity*) _data10_->acc, (GObject*) _tmp4_);
	g_message ("Accounts.vala:25: OK: Token is valid");
	tootle_accounts_set_active (self, _data10_->acc);
	_tmp5_ = tootle_settings;
	tootle_settings_set_current_account (_tmp5_, _data10_->id);
	_g_object_unref0 (updated);
	__vala_JsonNode_free0 (node);
}

static void
___lambda101__tootle_network_success_callback (SoupSession* session,
                                               SoupMessage* msg,
                                               gpointer self,
                                               GError** error)
{
	__lambda101_ (self, session, msg, error);
}

static void
__lambda102_ (TootleAccounts* self,
              gint32 code,
              const gchar* reason)
{
	TootleApplication* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (reason != NULL);
	g_warning ("Accounts.vala:30: Token invalid!");
	_tmp0_ = tootle_app;
	_tmp1_ = g_strdup_printf (_ ("The instance has invalidated this session. Please sign in again.\n" \
"\n" \
"%s"), reason);
	_tmp2_ = _tmp1_;
	g_signal_emit_by_name (_tmp0_, "error", _ ("Network Error"), _tmp2_);
	_g_free0 (_tmp2_);
}

static void
___lambda102__tootle_network_error_callback (gint32 code,
                                             const gchar* reason,
                                             gpointer self)
{
	__lambda102_ ((TootleAccounts*) self, code, reason);
}

void
tootle_accounts_switch_account (TootleAccounts* self,
                                gint id)
{
	Block10Data* _data10_;
	GeeArrayList* _tmp0_;
	gpointer _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	TootleRequest* _tmp8_;
	TootleRequest* _tmp9_;
	TootleRequest* _tmp10_;
	TootleRequest* _tmp11_;
	TootleRequest* _tmp12_;
	TootleRequest* _tmp13_;
	TootleRequest* _tmp14_;
	TootleRequest* _tmp15_;
	TootleRequest* _tmp16_;
	TootleRequest* _tmp17_;
	g_return_if_fail (self != NULL);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_data10_->self = g_object_ref (self);
	_data10_->id = id;
	_tmp0_ = self->priv->_saved;
	_tmp1_ = gee_abstract_list_get ((GeeAbstractList*) _tmp0_, _data10_->id);
	_data10_->acc = (TootleInstanceAccount*) _tmp1_;
	_tmp2_ = tootle_instance_account_get_handle (_data10_->acc);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = string_to_string (_tmp4_);
	_tmp6_ = g_strconcat ("Switching to ", _tmp5_, "...", NULL);
	_tmp7_ = _tmp6_;
	g_message ("Accounts.vala:18: %s", _tmp7_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp4_);
	_tmp8_ = tootle_request_new_GET ("/api/v1/accounts/verify_credentials");
	_tmp9_ = _tmp8_;
	_tmp10_ = tootle_request_with_account (_tmp9_, _data10_->acc);
	_tmp11_ = _tmp10_;
	_tmp12_ = tootle_request_then (_tmp11_, ___lambda101__tootle_network_success_callback, block10_data_ref (_data10_), block10_data_unref);
	_tmp13_ = _tmp12_;
	_tmp14_ = tootle_request_on_error (_tmp13_, ___lambda102__tootle_network_error_callback, g_object_ref (self), g_object_unref);
	_tmp15_ = _tmp14_;
	_tmp16_ = tootle_request_exec (_tmp15_);
	_tmp17_ = _tmp16_;
	_g_object_unref0 (_tmp17_);
	_g_object_unref0 (_tmp15_);
	_g_object_unref0 (_tmp13_);
	_g_object_unref0 (_tmp11_);
	_g_object_unref0 (_tmp9_);
	block10_data_unref (_data10_);
	_data10_ = NULL;
}

void
tootle_accounts_add (TootleAccounts* self,
                     TootleInstanceAccount* account)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_tmp0_ = tootle_instance_account_get_handle (account);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = string_to_string (_tmp2_);
	_tmp4_ = g_strconcat ("Adding new account: ", _tmp3_, NULL);
	_tmp5_ = _tmp4_;
	g_message ("Accounts.vala:40: %s", _tmp5_);
	_g_free0 (_tmp5_);
	_g_free0 (_tmp2_);
	_tmp6_ = self->priv->_saved;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp6_, account);
	tootle_accounts_save (self, TRUE);
	_tmp7_ = self->priv->_saved;
	_tmp8_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp7_);
	_tmp9_ = _tmp8_;
	tootle_accounts_switch_account (self, _tmp9_ - 1);
	tootle_instance_account_subscribe (account);
}

void
tootle_accounts_remove (TootleAccounts* self,
                        TootleInstanceAccount* account)
{
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	tootle_instance_account_unsubscribe (account);
	_tmp0_ = self->priv->_saved;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp0_, account);
	_tmp1_ = self->priv->_saved;
	g_object_notify ((GObject*) _tmp1_, "size");
	_tmp2_ = self->priv->_saved;
	_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_ < 1) {
		tootle_accounts_set_active (self, NULL);
	} else {
		gint id = 0;
		TootleSettings* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		GeeArrayList* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp5_ = tootle_settings;
		_tmp6_ = tootle_settings_get_current_account (_tmp5_);
		_tmp7_ = _tmp6_;
		id = _tmp7_ - 1;
		_tmp8_ = self->priv->_saved;
		_tmp9_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp8_);
		_tmp10_ = _tmp9_;
		if (id > (_tmp10_ - 1)) {
			GeeArrayList* _tmp11_;
			gint _tmp12_;
			gint _tmp13_;
			_tmp11_ = self->priv->_saved;
			_tmp12_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp11_);
			_tmp13_ = _tmp12_;
			id = _tmp13_ - 1;
		} else {
			GeeArrayList* _tmp14_;
			gint _tmp15_;
			gint _tmp16_;
			_tmp14_ = self->priv->_saved;
			_tmp15_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp14_);
			_tmp16_ = _tmp15_;
			if (id < (_tmp16_ - 1)) {
				id = 0;
			}
		}
		tootle_accounts_switch_account (self, id);
	}
	tootle_accounts_save (self, TRUE);
	if (tootle_accounts_is_empty (self)) {
		TootleDialogsNewAccount* _tmp17_;
		TootleDialogsNewAccount* _tmp18_;
		_tmp17_ = tootle_dialogs_new_account_new ();
		g_object_ref_sink (_tmp17_);
		_tmp18_ = _tmp17_;
		_g_object_unref0 (_tmp18_);
	}
}

gboolean
tootle_accounts_is_empty (TootleAccounts* self)
{
	GeeArrayList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_saved;
	_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_ == 0;
	return result;
}

void
tootle_accounts_init (TootleAccounts* self)
{
	g_return_if_fail (self != NULL);
	tootle_accounts_save (self, FALSE);
	tootle_accounts_load (self);
	if (!tootle_accounts_is_empty (self)) {
		TootleSettings* _tmp0_;
		gint _tmp1_;
		gint _tmp2_;
		_tmp0_ = tootle_settings;
		_tmp1_ = tootle_settings_get_current_account (_tmp0_);
		_tmp2_ = _tmp1_;
		tootle_accounts_switch_account (self, _tmp2_);
	}
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		TootleAccounts* self;
		self = _data11_->self;
		_g_object_unref0 (_data11_->builder);
		_g_object_unref0 (self);
		g_slice_free (Block11Data, _data11_);
	}
}

static JsonNode*
_vala_JsonNode_copy (JsonNode* self)
{
	return g_boxed_copy (json_node_get_type (), self);
}

static gpointer
__vala_JsonNode_copy0 (gpointer self)
{
	return self ? _vala_JsonNode_copy (self) : NULL;
}

static gboolean
___lambda51_ (Block11Data* _data11_,
              TootleInstanceAccount* acc)
{
	TootleAccounts* self;
	JsonNode* node = NULL;
	JsonNode* _tmp0_;
	JsonBuilder* _tmp1_;
	JsonNode* _tmp2_;
	gboolean result = FALSE;
	self = _data11_->self;
	g_return_val_if_fail (acc != NULL, FALSE);
	_tmp0_ = tootle_entity_to_json ((TootleEntity*) acc);
	node = _tmp0_;
	_tmp1_ = _data11_->builder;
	_tmp2_ = __vala_JsonNode_copy0 (node);
	json_builder_add_value (_tmp1_, _tmp2_);
	result = TRUE;
	__vala_JsonNode_free0 (node);
	_g_object_unref0 (acc);
	return result;
}

static gboolean
____lambda51__gee_forall_func (gpointer g,
                               gpointer self)
{
	gboolean result;
	result = ___lambda51_ (self, (TootleInstanceAccount*) g);
	return result;
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

void
tootle_accounts_save (TootleAccounts* self,
                      gboolean overwrite)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		Block11Data* _data11_;
		GFile* dir = NULL;
		const gchar* _tmp0_;
		GFile* _tmp1_;
		GFile* _tmp2_;
		GFile* file = NULL;
		const gchar* _tmp4_;
		GFile* _tmp5_;
		gboolean _tmp6_ = FALSE;
		GFile* _tmp7_;
		JsonBuilder* _tmp8_;
		JsonBuilder* _tmp9_;
		GeeArrayList* _tmp10_;
		JsonBuilder* _tmp11_;
		JsonGenerator* generator = NULL;
		JsonGenerator* _tmp12_;
		JsonGenerator* _tmp13_;
		JsonBuilder* _tmp14_;
		JsonNode* _tmp15_;
		JsonNode* _tmp16_;
		gchar* data = NULL;
		JsonGenerator* _tmp17_;
		gchar* _tmp18_;
		GFile* _tmp19_;
		GFileOutputStream* stream = NULL;
		GFile* _tmp21_;
		GFileOutputStream* _tmp22_;
		GFileOutputStream* _tmp23_;
		const gchar* _tmp24_;
		guint8* _tmp25_;
		gint _tmp25__length1;
		gint _tmp26_ = 0;
		guint8* _tmp27_;
		gint _tmp27__length1;
		_data11_ = g_slice_new0 (Block11Data);
		_data11_->_ref_count_ = 1;
		_data11_->self = g_object_ref (self);
		_tmp0_ = self->priv->dir_path;
		_tmp1_ = g_file_new_for_path (_tmp0_);
		dir = _tmp1_;
		_tmp2_ = dir;
		if (!g_file_query_exists (_tmp2_, NULL)) {
			GFile* _tmp3_;
			_tmp3_ = dir;
			g_file_make_directory (_tmp3_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (dir);
				block11_data_unref (_data11_);
				_data11_ = NULL;
				goto __catch0_g_error;
			}
		}
		_tmp4_ = self->priv->file_path;
		_tmp5_ = g_file_new_for_path (_tmp4_);
		file = _tmp5_;
		_tmp7_ = file;
		if (g_file_query_exists (_tmp7_, NULL)) {
			_tmp6_ = !overwrite;
		} else {
			_tmp6_ = FALSE;
		}
		if (_tmp6_) {
			_g_object_unref0 (file);
			_g_object_unref0 (dir);
			block11_data_unref (_data11_);
			_data11_ = NULL;
			return;
		}
		_tmp8_ = json_builder_new ();
		_data11_->builder = _tmp8_;
		_tmp9_ = _data11_->builder;
		json_builder_begin_array (_tmp9_);
		_tmp10_ = self->priv->_saved;
		gee_abstract_collection_foreach ((GeeAbstractCollection*) _tmp10_, ____lambda51__gee_forall_func, _data11_);
		_tmp11_ = _data11_->builder;
		json_builder_end_array (_tmp11_);
		_tmp12_ = json_generator_new ();
		generator = _tmp12_;
		_tmp13_ = generator;
		_tmp14_ = _data11_->builder;
		_tmp15_ = json_builder_get_root (_tmp14_);
		_tmp16_ = _tmp15_;
		json_generator_set_root (_tmp13_, _tmp16_);
		__vala_JsonNode_free0 (_tmp16_);
		_tmp17_ = generator;
		_tmp18_ = json_generator_to_data (_tmp17_, NULL);
		data = _tmp18_;
		_tmp19_ = file;
		if (g_file_query_exists (_tmp19_, NULL)) {
			GFile* _tmp20_;
			_tmp20_ = file;
			g_file_delete (_tmp20_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_free0 (data);
				_g_object_unref0 (generator);
				_g_object_unref0 (file);
				_g_object_unref0 (dir);
				block11_data_unref (_data11_);
				_data11_ = NULL;
				goto __catch0_g_error;
			}
		}
		_tmp21_ = file;
		_tmp22_ = g_file_create (_tmp21_, G_FILE_CREATE_PRIVATE, NULL, &_inner_error0_);
		stream = _tmp22_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (data);
			_g_object_unref0 (generator);
			_g_object_unref0 (file);
			_g_object_unref0 (dir);
			block11_data_unref (_data11_);
			_data11_ = NULL;
			goto __catch0_g_error;
		}
		_tmp23_ = stream;
		_tmp24_ = data;
		_tmp25_ = string_get_data (_tmp24_, &_tmp26_);
		_tmp25__length1 = _tmp26_;
		_tmp27_ = _tmp25_;
		_tmp27__length1 = _tmp25__length1;
		g_output_stream_write ((GOutputStream*) _tmp23_, _tmp27_, (gsize) _tmp27__length1, NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (stream);
			_g_free0 (data);
			_g_object_unref0 (generator);
			_g_object_unref0 (file);
			_g_object_unref0 (dir);
			block11_data_unref (_data11_);
			_data11_ = NULL;
			goto __catch0_g_error;
		}
		g_message ("Accounts.vala:108: Saved accounts");
		_g_object_unref0 (stream);
		_g_free0 (data);
		_g_object_unref0 (generator);
		_g_object_unref0 (file);
		_g_object_unref0 (dir);
		block11_data_unref (_data11_);
		_data11_ = NULL;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp28_;
		const gchar* _tmp29_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp28_ = e;
		_tmp29_ = _tmp28_->message;
		g_warning ("Accounts.vala:111: %s", _tmp29_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

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

static void
___lambda104_ (TootleAccounts* self,
               JsonArray* _arr,
               guint _i,
               JsonNode* node)
{
	TootleInstanceAccount* account = NULL;
	TootleInstanceAccount* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (_arr != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = tootle_instance_account_from (node, &_inner_error0_);
	account = _tmp0_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
	if (account != NULL) {
		GeeArrayList* _tmp1_;
		_tmp1_ = self->priv->_saved;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, account);
		tootle_instance_account_subscribe (account);
	}
	_g_object_unref0 (account);
}

static void
____lambda104__json_array_foreach (JsonArray* array,
                                   guint index_,
                                   JsonNode* element_node,
                                   gpointer self)
{
	___lambda104_ ((TootleAccounts*) self, array, index_, element_node);
}

static void
tootle_accounts_load (TootleAccounts* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		guint8* data = NULL;
		gint data_length1 = 0;
		gint _data_size_ = 0;
		gchar* etag = NULL;
		GFile* file = NULL;
		const gchar* _tmp0_;
		GFile* _tmp1_;
		GFile* _tmp2_;
		guint8* _tmp3_ = NULL;
		gsize _tmp4_ = 0;
		gchar* _tmp5_ = NULL;
		gchar* contents = NULL;
		guint8* _tmp6_;
		gint _tmp6__length1;
		gchar* _tmp7_;
		JsonParser* parser = NULL;
		JsonParser* _tmp8_;
		JsonParser* _tmp9_;
		const gchar* _tmp10_;
		JsonArray* array = NULL;
		JsonParser* _tmp11_;
		JsonNode* _tmp12_;
		JsonArray* _tmp13_;
		JsonArray* _tmp14_;
		JsonArray* _tmp15_;
		GeeArrayList* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		_tmp0_ = self->priv->file_path;
		_tmp1_ = g_file_new_for_path (_tmp0_);
		file = _tmp1_;
		_tmp2_ = file;
		g_file_load_contents (_tmp2_, NULL, &_tmp3_, &_tmp4_, &_tmp5_, &_inner_error0_);
		data = (g_free (data), NULL);
		data = _tmp3_;
		data_length1 = _tmp4_;
		_data_size_ = data_length1;
		_g_free0 (etag);
		etag = _tmp5_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (file);
			_g_free0 (etag);
			data = (g_free (data), NULL);
			goto __catch0_g_error;
		}
		_tmp6_ = data;
		_tmp6__length1 = data_length1;
		_tmp7_ = g_strdup ((const gchar*) _tmp6_);
		contents = _tmp7_;
		_tmp8_ = json_parser_new ();
		parser = _tmp8_;
		_tmp9_ = parser;
		_tmp10_ = contents;
		json_parser_load_from_data (_tmp9_, _tmp10_, (gssize) -1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (parser);
			_g_free0 (contents);
			_g_object_unref0 (file);
			_g_free0 (etag);
			data = (g_free (data), NULL);
			goto __catch0_g_error;
		}
		_tmp11_ = parser;
		_tmp12_ = json_parser_get_root (_tmp11_);
		_tmp13_ = json_node_get_array (_tmp12_);
		_tmp14_ = _json_array_ref0 (_tmp13_);
		array = _tmp14_;
		_tmp15_ = array;
		json_array_foreach_element (_tmp15_, ____lambda104__json_array_foreach, self);
		_tmp16_ = self->priv->_saved;
		_tmp17_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = g_strdup_printf ("%i", _tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = g_strconcat ("Loaded ", _tmp20_, " accounts", NULL);
		_tmp22_ = _tmp21_;
		g_message ("Accounts.vala:134: %s", _tmp22_);
		_g_free0 (_tmp22_);
		_g_free0 (_tmp20_);
		_json_array_unref0 (array);
		_g_object_unref0 (parser);
		_g_free0 (contents);
		_g_object_unref0 (file);
		_g_free0 (etag);
		data = (g_free (data), NULL);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp23_;
		const gchar* _tmp24_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp23_ = e;
		_tmp24_ = _tmp23_->message;
		g_warning ("Accounts.vala:137: %s", _tmp24_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
	}
}

TootleAccounts*
tootle_accounts_construct (GType object_type)
{
	TootleAccounts * self = NULL;
	self = (TootleAccounts*) g_object_new (object_type, NULL);
	return self;
}

TootleAccounts*
tootle_accounts_new (void)
{
	return tootle_accounts_construct (TOOTLE_TYPE_ACCOUNTS);
}

GeeArrayList*
tootle_accounts_get_saved (TootleAccounts* self)
{
	GeeArrayList* result;
	GeeArrayList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_saved;
	result = _tmp0_;
	return result;
}

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

void
tootle_accounts_set_saved (TootleAccounts* self,
                           GeeArrayList* value)
{
	GeeArrayList* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_accounts_get_saved (self);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_saved);
		self->priv->_saved = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_accounts_properties[TOOTLE_ACCOUNTS_SAVED_PROPERTY]);
	}
}

TootleInstanceAccount*
tootle_accounts_get_active (TootleAccounts* self)
{
	TootleInstanceAccount* result;
	TootleInstanceAccount* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_active;
	result = _tmp0_;
	return result;
}

void
tootle_accounts_set_active (TootleAccounts* self,
                            TootleInstanceAccount* value)
{
	TootleInstanceAccount* old_value;
	g_return_if_fail (self != NULL);
	old_value = tootle_accounts_get_active (self);
	if (old_value != value) {
		TootleInstanceAccount* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_active);
		self->priv->_active = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, tootle_accounts_properties[TOOTLE_ACCOUNTS_ACTIVE_PROPERTY]);
	}
}

static GObject *
tootle_accounts_constructor (GType type,
                             guint n_construct_properties,
                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	TootleAccounts * self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	TootleApplication* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	parent_class = G_OBJECT_CLASS (tootle_accounts_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_TYPE_ACCOUNTS, TootleAccounts);
	_tmp0_ = g_get_user_config_dir ();
	_tmp1_ = string_to_string (_tmp0_);
	_tmp2_ = tootle_app;
	_tmp3_ = g_application_get_application_id ((GApplication*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = string_to_string (_tmp4_);
	_tmp6_ = g_strconcat (_tmp1_, "/", _tmp5_, NULL);
	_g_free0 (self->priv->dir_path);
	self->priv->dir_path = _tmp6_;
	_tmp7_ = self->priv->dir_path;
	_tmp8_ = string_to_string (_tmp7_);
	_tmp9_ = g_strconcat (_tmp8_, "/accounts.json", NULL);
	_g_free0 (self->priv->file_path);
	self->priv->file_path = _tmp9_;
	return obj;
}

static void
tootle_accounts_class_init (TootleAccountsClass * klass,
                            gpointer klass_data)
{
	tootle_accounts_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &TootleAccounts_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_tootle_accounts_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_tootle_accounts_set_property;
	G_OBJECT_CLASS (klass)->constructor = tootle_accounts_constructor;
	G_OBJECT_CLASS (klass)->finalize = tootle_accounts_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_ACCOUNTS_SAVED_PROPERTY, tootle_accounts_properties[TOOTLE_ACCOUNTS_SAVED_PROPERTY] = g_param_spec_object ("saved", "saved", "saved", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), TOOTLE_ACCOUNTS_ACTIVE_PROPERTY, tootle_accounts_properties[TOOTLE_ACCOUNTS_ACTIVE_PROPERTY] = g_param_spec_object ("active", "active", "active", TOOTLE_TYPE_INSTANCE_ACCOUNT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
tootle_accounts_instance_init (TootleAccounts * self,
                               gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = tootle_accounts_get_instance_private (self);
	_tmp0_ = gee_array_list_new (TOOTLE_TYPE_INSTANCE_ACCOUNT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->_saved = _tmp0_;
}

static void
tootle_accounts_finalize (GObject * obj)
{
	TootleAccounts * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TOOTLE_TYPE_ACCOUNTS, TootleAccounts);
	_g_free0 (self->priv->dir_path);
	_g_free0 (self->priv->file_path);
	_g_object_unref0 (self->priv->_saved);
	_g_object_unref0 (self->priv->_active);
	G_OBJECT_CLASS (tootle_accounts_parent_class)->finalize (obj);
}

static GType
tootle_accounts_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleAccountsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_accounts_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TootleAccounts), 0, (GInstanceInitFunc) tootle_accounts_instance_init, NULL };
	GType tootle_accounts_type_id;
	tootle_accounts_type_id = g_type_register_static (G_TYPE_OBJECT, "TootleAccounts", &g_define_type_info, 0);
	TootleAccounts_private_offset = g_type_add_instance_private (tootle_accounts_type_id, sizeof (TootleAccountsPrivate));
	return tootle_accounts_type_id;
}

GType
tootle_accounts_get_type (void)
{
	static volatile gsize tootle_accounts_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_accounts_type_id__volatile)) {
		GType tootle_accounts_type_id;
		tootle_accounts_type_id = tootle_accounts_get_type_once ();
		g_once_init_leave (&tootle_accounts_type_id__volatile, tootle_accounts_type_id);
	}
	return tootle_accounts_type_id__volatile;
}

static void
_vala_tootle_accounts_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	TootleAccounts * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_TYPE_ACCOUNTS, TootleAccounts);
	switch (property_id) {
		case TOOTLE_ACCOUNTS_SAVED_PROPERTY:
		g_value_set_object (value, tootle_accounts_get_saved (self));
		break;
		case TOOTLE_ACCOUNTS_ACTIVE_PROPERTY:
		g_value_set_object (value, tootle_accounts_get_active (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_tootle_accounts_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	TootleAccounts * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TOOTLE_TYPE_ACCOUNTS, TootleAccounts);
	switch (property_id) {
		case TOOTLE_ACCOUNTS_SAVED_PROPERTY:
		tootle_accounts_set_saved (self, g_value_get_object (value));
		break;
		case TOOTLE_ACCOUNTS_ACTIVE_PROPERTY:
		tootle_accounts_set_active (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

