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

#include "libdino.h"
#include <gee.h>
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.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

#define DINO_CONNECTION_MANAGER_TYPE_CONNECTION (dino_connection_manager_connection_get_type ())
#define DINO_CONNECTION_MANAGER_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_CONNECTION_MANAGER_TYPE_CONNECTION, DinoConnectionManagerConnection))
#define DINO_CONNECTION_MANAGER_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_CONNECTION_MANAGER_TYPE_CONNECTION, DinoConnectionManagerConnectionClass))
#define DINO_CONNECTION_MANAGER_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_CONNECTION_MANAGER_TYPE_CONNECTION))
#define DINO_CONNECTION_MANAGER_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_CONNECTION_MANAGER_TYPE_CONNECTION))
#define DINO_CONNECTION_MANAGER_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_CONNECTION_MANAGER_TYPE_CONNECTION, DinoConnectionManagerConnectionClass))

typedef struct _DinoConnectionManagerConnection DinoConnectionManagerConnection;
typedef struct _DinoConnectionManagerConnectionClass DinoConnectionManagerConnectionClass;
enum  {
	DINO_CONNECTION_MANAGER_0_PROPERTY,
	DINO_CONNECTION_MANAGER_NUM_PROPERTIES
};
static GParamSpec* dino_connection_manager_properties[DINO_CONNECTION_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _dino_module_manager_unref0(var) ((var == NULL) ? NULL : (var = (dino_module_manager_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _dino_connection_manager_connection_unref0(var) ((var == NULL) ? NULL : (var = (dino_connection_manager_connection_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
typedef struct _DinoConnectionManagerDisconnectAccountData DinoConnectionManagerDisconnectAccountData;
typedef struct _Block9Data Block9Data;
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _xmpp_xmpp_stream_result_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xmpp_stream_result_unref (var), NULL)))
#define _dino_connection_manager_connection_error_unref0(var) ((var == NULL) ? NULL : (var = (dino_connection_manager_connection_error_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DinoConnectionManagerConnectStreamData DinoConnectionManagerConnectStreamData;
typedef struct _Block10Data Block10Data;
typedef struct _DinoConnectionManagerOnPrepareForSleepData DinoConnectionManagerOnPrepareForSleepData;
typedef struct _DinoConnectionManagerParamSpecConnectionError DinoConnectionManagerParamSpecConnectionError;
typedef struct _DinoConnectionManagerConnectionPrivate DinoConnectionManagerConnectionPrivate;
typedef struct _DinoConnectionManagerConnectionDisconnectAccountData DinoConnectionManagerConnectionDisconnectAccountData;
typedef struct _DinoConnectionManagerParamSpecConnection DinoConnectionManagerParamSpecConnection;
enum  {
	DINO_CONNECTION_MANAGER_STREAM_OPENED_SIGNAL,
	DINO_CONNECTION_MANAGER_STREAM_ATTACHED_MODULES_SIGNAL,
	DINO_CONNECTION_MANAGER_CONNECTION_STATE_CHANGED_SIGNAL,
	DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SIGNAL,
	DINO_CONNECTION_MANAGER_NUM_SIGNALS
};
static guint dino_connection_manager_signals[DINO_CONNECTION_MANAGER_NUM_SIGNALS] = {0};

struct _DinoConnectionManagerPrivate {
	GeeHashMap* connections;
	GeeHashMap* connection_errors;
	GeeHashMap* connection_ongoing;
	GeeHashMap* connection_directly_retry;
	GNetworkMonitor* network_monitor;
	DinoLogin1Manager* login1;
	DinoModuleManager* module_manager;
};

struct _DinoConnectionManagerDisconnectAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoConnectionManager* self;
	DinoEntitiesAccount* account;
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	gpointer _tmp2_;
	DinoConnectionManagerConnection* _tmp3_;
	GeeHashMap* _tmp4_;
};

struct _Block9Data {
	int _ref_count_;
	DinoConnectionManager* self;
	gchar* connection_uuid;
	DinoEntitiesAccount* account;
	gpointer _async_data_;
};

struct _DinoConnectionManagerConnectStreamData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoConnectionManager* self;
	DinoEntitiesAccount* account;
	Block9Data* _data9_;
	GeeHashMap* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	XmppJid* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GeeHashMap* _tmp6_;
	XmppXmppStreamResult* stream_result;
	GeeHashMap* _tmp7_;
	gpointer _tmp8_;
	XmppJid* _tmp9_;
	XmppJid* _tmp10_;
	XmppJid* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GeeHashMap* _tmp14_;
	GeeHashMap* _tmp15_;
	gpointer _tmp16_;
	DinoConnectionManagerConnection* _tmp17_;
	XmppXmppStream* _tmp18_;
	XmppXmppStream* _tmp19_;
	gboolean _tmp20_;
	XmppJid* _tmp21_;
	XmppJid* _tmp22_;
	XmppJid* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	GeeHashMap* _tmp26_;
	GeeHashMap* _tmp27_;
	XmppJid* _tmp28_;
	XmppJid* _tmp29_;
	XmppJid* _tmp30_;
	DinoModuleManager* _tmp31_;
	GeeArrayList* _tmp32_;
	GeeArrayList* _tmp33_;
	const gchar* _tmp34_;
	XmppXmppStreamResult* _tmp35_;
	GeeHashMap* _tmp36_;
	gpointer _tmp37_;
	DinoConnectionManagerConnection* _tmp38_;
	XmppXmppStreamResult* _tmp39_;
	XmppTlsXmppStream* _tmp40_;
	XmppTlsXmppStream* _tmp41_;
	GeeHashMap* _tmp42_;
	XmppXmppStreamResult* _tmp43_;
	XmppTlsXmppStream* _tmp44_;
	XmppTlsXmppStream* _tmp45_;
	XmppXmppStreamResult* _tmp46_;
	GTlsCertificateFlags* _tmp47_;
	GTlsCertificateFlags* _tmp48_;
	DinoConnectionManagerConnectionError* _tmp49_;
	DinoConnectionManagerConnectionError* _tmp50_;
	XmppJid* _tmp51_;
	XmppJid* _tmp52_;
	XmppJid* _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	GeeHashMap* _tmp56_;
	gpointer _tmp57_;
	XmppXmppStream* stream;
	XmppXmppStreamResult* _tmp58_;
	XmppTlsXmppStream* _tmp59_;
	XmppTlsXmppStream* _tmp60_;
	XmppXmppStream* _tmp61_;
	XmppJid* _tmp62_;
	XmppJid* _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	XmppXmppStream* _tmp66_;
	GeeHashMap* _tmp67_;
	gpointer _tmp68_;
	DinoConnectionManagerConnection* _tmp69_;
	GDateTime* _tmp70_;
	GDateTime* _tmp71_;
	XmppXmppStream* _tmp72_;
	XmppXmppStream* _tmp73_;
	XmppModuleIdentity* _tmp74_;
	gpointer _tmp75_;
	XmppSaslModule* _tmp76_;
	GeeHashMap* _tmp77_;
	gpointer _tmp78_;
	DinoConnectionManagerConnection* _tmp79_;
	const gchar* _tmp80_;
	const gchar* _tmp81_;
	gchar* _tmp82_;
	gchar* _tmp83_;
	XmppXmppStream* _tmp84_;
	XmppXmppStream* _tmp85_;
	XmppXmppStream* _tmp86_;
	GError* e;
	XmppJid* _tmp87_;
	XmppJid* _tmp88_;
	XmppJid* _tmp89_;
	gchar* _tmp90_;
	gchar* _tmp91_;
	XmppXmppStream* _tmp92_;
	GError* _tmp93_;
	const gchar* _tmp94_;
	GeeHashMap* _tmp95_;
	GeeHashMap* _tmp96_;
	gpointer _tmp97_;
	DinoConnectionManagerConnection* _tmp98_;
	XmppStreamErrorFlag* flag;
	XmppXmppStream* _tmp99_;
	XmppFlagIdentity* _tmp100_;
	gpointer _tmp101_;
	XmppStreamErrorFlag* _tmp102_;
	XmppJid* _tmp103_;
	XmppJid* _tmp104_;
	XmppJid* _tmp105_;
	gchar* _tmp106_;
	gchar* _tmp107_;
	XmppXmppStream* _tmp108_;
	XmppStreamErrorFlag* _tmp109_;
	const gchar* _tmp110_;
	XmppStreamErrorFlag* _tmp111_;
	const gchar* _tmp112_;
	DinoConnectionManagerConnectionError* _tmp113_;
	DinoConnectionManagerConnectionError* _tmp114_;
	XmppStreamErrorFlag* _tmp115_;
	DinoConnectionManagerConnectionError* _error_;
	GeeHashMap* _tmp116_;
	gpointer _tmp117_;
	gboolean _tmp118_;
	DinoConnectionManagerConnectionError* _tmp119_;
	DinoConnectionManagerConnectionError* _tmp120_;
	GError* _inner_error0_;
};

struct _Block10Data {
	int _ref_count_;
	DinoConnectionManager* self;
	gboolean acked;
	GDateTime* last_activity_was;
	XmppXmppStream* stream;
	DinoEntitiesAccount* account;
};

struct _DinoConnectionManagerOnPrepareForSleepData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoConnectionManager* self;
	gboolean suspend;
	GeeIterator* _account_it;
	GeeHashMap* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* _tmp3_;
	GeeIterator* _tmp4_;
	GeeIterator* _tmp5_;
	GeeIterator* _tmp6_;
	DinoEntitiesAccount* account;
	GeeIterator* _tmp7_;
	gpointer _tmp8_;
	DinoEntitiesAccount* _tmp9_;
	GeeIterator* _vala1__account_it;
	GeeHashMap* _tmp10_;
	GeeSet* _tmp11_;
	GeeSet* _tmp12_;
	GeeSet* _tmp13_;
	GeeIterator* _tmp14_;
	GeeIterator* _tmp15_;
	GeeIterator* _tmp16_;
	DinoEntitiesAccount* _vala1_account;
	GeeIterator* _tmp17_;
	gpointer _tmp18_;
	DinoEntitiesAccount* _tmp19_;
	GeeHashMap* _tmp20_;
	DinoEntitiesAccount* _tmp21_;
	gpointer _tmp22_;
	DinoConnectionManagerConnection* _tmp23_;
	XmppXmppStream* _tmp24_;
	XmppXmppStream* _tmp25_;
	gboolean _tmp26_;
	GeeHashMap* _tmp27_;
	DinoEntitiesAccount* _tmp28_;
	gpointer _tmp29_;
	DinoConnectionManagerConnection* _tmp30_;
	XmppXmppStream* _tmp31_;
	XmppXmppStream* _tmp32_;
	GError* e;
	GeeHashMap* _tmp33_;
	DinoEntitiesAccount* _tmp34_;
	gpointer _tmp35_;
	DinoConnectionManagerConnection* _tmp36_;
	XmppXmppStream* _tmp37_;
	XmppXmppStream* _tmp38_;
	GError* _tmp39_;
	const gchar* _tmp40_;
	GError* _inner_error0_;
};

struct _DinoConnectionManagerConnectionErrorPrivate {
	DinoConnectionManagerConnectionErrorReconnect _reconnect_recomendation;
};

struct _DinoConnectionManagerParamSpecConnectionError {
	GParamSpec parent_instance;
};

struct _DinoConnectionManagerConnection {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DinoConnectionManagerConnectionPrivate * priv;
};

struct _DinoConnectionManagerConnectionClass {
	GTypeClass parent_class;
	void (*finalize) (DinoConnectionManagerConnection *self);
};

struct _DinoConnectionManagerConnectionPrivate {
	gchar* _uuid;
	XmppXmppStream* _stream;
	DinoConnectionManagerConnectionState _connection_state;
	GDateTime* _established;
	GDateTime* _last_activity;
};

struct _DinoConnectionManagerConnectionDisconnectAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoConnectionManagerConnection* self;
	XmppXmppStream* _tmp0_;
	XmppXmppStream* _tmp1_;
	GError* e;
	GError* _tmp2_;
	const gchar* _tmp3_;
	GError* _inner_error0_;
};

struct _DinoConnectionManagerParamSpecConnection {
	GParamSpec parent_instance;
};

static gint DinoConnectionManager_private_offset;
static gpointer dino_connection_manager_parent_class = NULL;
static gint DinoConnectionManagerConnectionError_private_offset;
static gpointer dino_connection_manager_connection_error_parent_class = NULL;
static gint DinoConnectionManagerConnection_private_offset;
static gpointer dino_connection_manager_connection_parent_class = NULL;

static gpointer dino_connection_manager_connection_ref (gpointer instance);
static void dino_connection_manager_connection_unref (gpointer instance);
static GParamSpec* dino_connection_manager_param_spec_connection (const gchar* name,
                                                           const gchar* nick,
                                                           const gchar* blurb,
                                                           GType object_type,
                                                           GParamFlags flags) G_GNUC_UNUSED ;
static void dino_connection_manager_value_set_connection (GValue* value,
                                                   gpointer v_object) G_GNUC_UNUSED ;
static void dino_connection_manager_value_take_connection (GValue* value,
                                                    gpointer v_object) G_GNUC_UNUSED ;
static gpointer dino_connection_manager_value_get_connection (const GValue* value) G_GNUC_UNUSED ;
static GType dino_connection_manager_connection_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static guint _dino_entities_account_hash_func_gee_hash_data_func (gconstpointer v,
                                                           gpointer self);
static gboolean _dino_entities_account_equals_func_gee_equal_data_func (gconstpointer a,
                                                                 gconstpointer b,
                                                                 gpointer self);
static void dino_connection_manager_on_network_changed (DinoConnectionManager* self);
static void _dino_connection_manager_on_network_changed_g_network_monitor_network_changed (GNetworkMonitor* _sender,
                                                                                    gboolean network_available,
                                                                                    gpointer self);
static void _dino_connection_manager_on_network_changed_g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self);
static void __lambda12_ (DinoConnectionManager* self,
                  GObject* _,
                  GAsyncResult* res);
static void dino_connection_manager_on_prepare_for_sleep (DinoConnectionManager* self,
                                                   gboolean suspend,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static void dino_connection_manager_on_prepare_for_sleep_finish (DinoConnectionManager* self,
                                                          GAsyncResult* _res_);
static void _dino_connection_manager_on_prepare_for_sleep_dino_login1_manager_prepare_for_sleep (DinoLogin1Manager* _sender,
                                                                                          gboolean suspend,
                                                                                          gpointer self);
static void ___lambda12__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static gboolean __lambda13_ (DinoConnectionManager* self);
static GDateTime* dino_connection_manager_connection_get_last_activity (DinoConnectionManagerConnection* self);
static void dino_connection_manager_check_reconnect (DinoConnectionManager* self,
                                              DinoEntitiesAccount* account,
                                              gboolean directly_reconnect);
static gboolean ___lambda13__gsource_func (gpointer self);
static XmppXmppStream* dino_connection_manager_connection_get_stream (DinoConnectionManagerConnection* self);
static DinoConnectionManagerConnectionState dino_connection_manager_connection_get_connection_state (DinoConnectionManagerConnection* self);
static DinoConnectionManagerConnection* dino_connection_manager_connection_new (void);
static DinoConnectionManagerConnection* dino_connection_manager_connection_construct (GType object_type);
static void dino_connection_manager_connect_stream (DinoConnectionManager* self,
                                             DinoEntitiesAccount* account,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
static void dino_connection_manager_connect_stream_finish (DinoConnectionManager* self,
                                                    GAsyncResult* _res_);
static void dino_connection_manager_make_offline (DinoConnectionManager* self,
                                           DinoEntitiesAccount* account);
static void dino_connection_manager_connection_make_offline (DinoConnectionManagerConnection* self);
static void dino_connection_manager_change_connection_state (DinoConnectionManager* self,
                                                      DinoEntitiesAccount* account,
                                                      DinoConnectionManagerConnectionState state);
static void dino_connection_manager_disconnect_account_data_free (gpointer _data);
static gboolean dino_connection_manager_disconnect_account_co (DinoConnectionManagerDisconnectAccountData* _data_);
static void dino_connection_manager_connection_disconnect_account (DinoConnectionManagerConnection* self,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
static void dino_connection_manager_connection_disconnect_account_finish (DinoConnectionManagerConnection* self,
                                                                   GAsyncResult* _res_);
static void dino_connection_manager_connect_stream_data_free (gpointer _data);
static gboolean dino_connection_manager_connect_stream_co (DinoConnectionManagerConnectStreamData* _data_);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static gboolean ____lambda6_ (Block9Data* _data9_,
                       GTlsCertificate* peer_cert,
                       GTlsCertificateFlags errors);
static gboolean _____lambda6__xmpp_tls_xmpp_stream_on_invalid_cert (GTlsCertificate* peer_cert,
                                                             GTlsCertificateFlags errors,
                                                             gpointer self);
static void dino_connection_manager_connect_stream_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void dino_connection_manager_connection_set_stream (DinoConnectionManagerConnection* self,
                                                    XmppXmppStream* value);
static void dino_connection_manager_set_connection_error (DinoConnectionManager* self,
                                                   DinoEntitiesAccount* account,
                                                   DinoConnectionManagerConnectionError* _error_);
static void dino_connection_manager_connection_set_established (DinoConnectionManagerConnection* self,
                                                         GDateTime* value);
static void __lambda7_ (Block9Data* _data9_,
                 XmppXmppStream* stream);
static void ___lambda7__xmpp_xmpp_stream_attached_modules (XmppXmppStream* _sender,
                                                    XmppXmppStream* stream,
                                                    gpointer self);
static void __lambda8_ (Block9Data* _data9_,
                 XmppXmppStream* stream,
                 XmppStanzaNode* node);
static void ___lambda8__xmpp_sasl_module_received_auth_failure (XmppSaslModule* _sender,
                                                         XmppXmppStream* stream,
                                                         XmppStanzaNode* node,
                                                         gpointer self);
static const gchar* dino_connection_manager_connection_get_uuid (DinoConnectionManagerConnection* self);
static void __lambda9_ (Block9Data* _data9_);
static void dino_connection_manager_connection_set_last_activity (DinoConnectionManagerConnection* self,
                                                           GDateTime* value);
static void ___lambda9__xmpp_xmpp_stream_received_node (XmppXmppStream* _sender,
                                                 XmppXmppStream* stream,
                                                 XmppStanzaNode* node,
                                                 gpointer self);
static void dino_connection_manager_connection_reset (DinoConnectionManagerConnection* self);
static void dino_connection_manager_check_reconnects (DinoConnectionManager* self);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
static gboolean ___lambda5_ (Block10Data* _data10_);
static gboolean ____lambda5__gsource_func (gpointer self);
static void __lambda10_ (Block10Data* _data10_);
static void ___lambda10__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static gboolean __lambda11_ (Block10Data* _data10_);
static gboolean ___lambda11__gsource_func (gpointer self);
static gboolean dino_connection_manager_network_is_online (DinoConnectionManager* self);
static void dino_connection_manager_on_prepare_for_sleep_data_free (gpointer _data);
static gboolean dino_connection_manager_on_prepare_for_sleep_co (DinoConnectionManagerOnPrepareForSleepData* _data_);
static void dino_connection_manager_on_prepare_for_sleep_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void dino_connection_manager_connection_set_connection_state (DinoConnectionManagerConnection* self,
                                                              DinoConnectionManagerConnectionState value);
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure * closure,
                                                  GValue * return_value,
                                                  guint n_param_values,
                                                  const GValue * param_values,
                                                  gpointer invocation_hint,
                                                  gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_ENUM (GClosure * closure,
                                                GValue * return_value,
                                                guint n_param_values,
                                                const GValue * param_values,
                                                gpointer invocation_hint,
                                                gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__OBJECT_DINO_CONNECTION_MANAGER_CONNECTION_ERROR (GClosure * closure,
                                                                                    GValue * return_value,
                                                                                    guint n_param_values,
                                                                                    const GValue * param_values,
                                                                                    gpointer invocation_hint,
                                                                                    gpointer marshal_data);
static void dino_connection_manager_connection_error_finalize (DinoConnectionManagerConnectionError * obj);
static GType dino_connection_manager_connection_error_get_type_once (void);
static void dino_connection_manager_connection_set_uuid (DinoConnectionManagerConnection* self,
                                                  const gchar* value);
static void dino_connection_manager_connection_disconnect_account_data_free (gpointer _data);
static gboolean dino_connection_manager_connection_disconnect_account_co (DinoConnectionManagerConnectionDisconnectAccountData* _data_);
static void dino_connection_manager_connection_disconnect_account_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static GDateTime* dino_connection_manager_connection_get_established (DinoConnectionManagerConnection* self);
static void dino_connection_manager_connection_finalize (DinoConnectionManagerConnection * obj);
static GType dino_connection_manager_connection_get_type_once (void);
static void dino_connection_manager_finalize (GObject * obj);
static GType dino_connection_manager_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_connection_manager_get_instance_private (DinoConnectionManager* self)
{
	return G_STRUCT_MEMBER_P (self, DinoConnectionManager_private_offset);
}

static GType
dino_connection_manager_connection_state_get_type_once (void)
{
	static const GEnumValue values[] = {{DINO_CONNECTION_MANAGER_CONNECTION_STATE_CONNECTED, "DINO_CONNECTION_MANAGER_CONNECTION_STATE_CONNECTED", "connected"}, {DINO_CONNECTION_MANAGER_CONNECTION_STATE_CONNECTING, "DINO_CONNECTION_MANAGER_CONNECTION_STATE_CONNECTING", "connecting"}, {DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED, "DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED", "disconnected"}, {0, NULL, NULL}};
	GType dino_connection_manager_connection_state_type_id;
	dino_connection_manager_connection_state_type_id = g_enum_register_static ("DinoConnectionManagerConnectionState", values);
	return dino_connection_manager_connection_state_type_id;
}

GType
dino_connection_manager_connection_state_get_type (void)
{
	static volatile gsize dino_connection_manager_connection_state_type_id__once = 0;
	if (g_once_init_enter (&dino_connection_manager_connection_state_type_id__once)) {
		GType dino_connection_manager_connection_state_type_id;
		dino_connection_manager_connection_state_type_id = dino_connection_manager_connection_state_get_type_once ();
		g_once_init_leave (&dino_connection_manager_connection_state_type_id__once, dino_connection_manager_connection_state_type_id);
	}
	return dino_connection_manager_connection_state_type_id__once;
}

static guint
_dino_entities_account_hash_func_gee_hash_data_func (gconstpointer v,
                                                     gpointer self)
{
	guint result;
	result = dino_entities_account_hash_func ((DinoEntitiesAccount*) v);
	return result;
}

static gboolean
_dino_entities_account_equals_func_gee_equal_data_func (gconstpointer a,
                                                        gconstpointer b,
                                                        gpointer self)
{
	gboolean result;
	result = dino_entities_account_equals_func ((DinoEntitiesAccount*) a, (DinoEntitiesAccount*) b);
	return result;
}

static gpointer
_dino_module_manager_ref0 (gpointer self)
{
	return self ? dino_module_manager_ref (self) : NULL;
}

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

static void
_dino_connection_manager_on_network_changed_g_network_monitor_network_changed (GNetworkMonitor* _sender,
                                                                               gboolean network_available,
                                                                               gpointer self)
{
	dino_connection_manager_on_network_changed ((DinoConnectionManager*) self);
}

static void
_dino_connection_manager_on_network_changed_g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self)
{
	dino_connection_manager_on_network_changed ((DinoConnectionManager*) self);
}

static void
_dino_connection_manager_on_prepare_for_sleep_dino_login1_manager_prepare_for_sleep (DinoLogin1Manager* _sender,
                                                                                     gboolean suspend,
                                                                                     gpointer self)
{
	dino_connection_manager_on_prepare_for_sleep ((DinoConnectionManager*) self, suspend, NULL, NULL);
}

static void
__lambda12_ (DinoConnectionManager* self,
             GObject* _,
             GAsyncResult* res)
{
	DinoLogin1Manager* _tmp0_;
	DinoLogin1Manager* _tmp1_;
	g_return_if_fail (res != NULL);
	_tmp0_ = dino_get_login1_finish (res);
	_g_object_unref0 (self->priv->login1);
	self->priv->login1 = _tmp0_;
	_tmp1_ = self->priv->login1;
	if (_tmp1_ != NULL) {
		DinoLogin1Manager* _tmp2_;
		_tmp2_ = self->priv->login1;
		g_signal_connect_object (_tmp2_, "prepare-for-sleep", (GCallback) _dino_connection_manager_on_prepare_for_sleep_dino_login1_manager_prepare_for_sleep, self, 0);
	}
}

static void
___lambda12__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda12_ ((DinoConnectionManager*) self, source_object, res);
	g_object_unref (self);
}

static gboolean
__lambda13_ (DinoConnectionManager* self)
{
	gboolean result;
	{
		GeeIterator* _account_it = NULL;
		GeeHashMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->connections;
		_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_account_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			DinoEntitiesAccount* account = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			gboolean _tmp9_ = FALSE;
			GeeHashMap* _tmp10_;
			DinoEntitiesAccount* _tmp11_;
			gpointer _tmp12_;
			DinoConnectionManagerConnection* _tmp13_;
			GDateTime* _tmp14_;
			GDateTime* _tmp15_;
			gboolean _tmp16_;
			_tmp6_ = _account_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _account_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			account = (DinoEntitiesAccount*) _tmp8_;
			_tmp10_ = self->priv->connections;
			_tmp11_ = account;
			_tmp12_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp10_, _tmp11_);
			_tmp13_ = (DinoConnectionManagerConnection*) _tmp12_;
			_tmp14_ = dino_connection_manager_connection_get_last_activity (_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp16_ = _tmp15_ == NULL;
			_dino_connection_manager_connection_unref0 (_tmp13_);
			if (_tmp16_) {
				_tmp9_ = TRUE;
			} else {
				GeeHashMap* _tmp17_;
				DinoEntitiesAccount* _tmp18_;
				gpointer _tmp19_;
				DinoConnectionManagerConnection* _tmp20_;
				GDateTime* _tmp21_;
				GDateTime* _tmp22_;
				GDateTime* _tmp23_;
				GDateTime* _tmp24_;
				GDateTime* _tmp25_;
				GDateTime* _tmp26_;
				_tmp17_ = self->priv->connections;
				_tmp18_ = account;
				_tmp19_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp17_, _tmp18_);
				_tmp20_ = (DinoConnectionManagerConnection*) _tmp19_;
				_tmp21_ = dino_connection_manager_connection_get_last_activity (_tmp20_);
				_tmp22_ = _tmp21_;
				_tmp23_ = g_date_time_new_now_utc ();
				_tmp24_ = _tmp23_;
				_tmp25_ = g_date_time_add_minutes (_tmp24_, -1);
				_tmp26_ = _tmp25_;
				_tmp9_ = g_date_time_compare (_tmp22_, _tmp26_) < 0;
				_g_date_time_unref0 (_tmp26_);
				_g_date_time_unref0 (_tmp24_);
				_dino_connection_manager_connection_unref0 (_tmp20_);
			}
			if (_tmp9_) {
				DinoEntitiesAccount* _tmp27_;
				_tmp27_ = account;
				dino_connection_manager_check_reconnect (self, _tmp27_, FALSE);
			}
			_g_object_unref0 (account);
		}
		_g_object_unref0 (_account_it);
	}
	result = TRUE;
	return result;
}

static gboolean
___lambda13__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda13_ ((DinoConnectionManager*) self);
	return result;
}

DinoConnectionManager*
dino_connection_manager_construct (GType object_type,
                                   DinoModuleManager* module_manager)
{
	DinoConnectionManager * self = NULL;
	DinoModuleManager* _tmp0_;
	GNetworkMonitor* _tmp1_;
	GNetworkMonitor* _tmp2_;
	GNetworkMonitor* _tmp3_;
	g_return_val_if_fail (module_manager != NULL, NULL);
	self = (DinoConnectionManager*) g_object_new (object_type, NULL);
	_tmp0_ = _dino_module_manager_ref0 (module_manager);
	_dino_module_manager_unref0 (self->priv->module_manager);
	self->priv->module_manager = _tmp0_;
	_tmp1_ = g_network_monitor_get_default ();
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (self->priv->network_monitor);
	self->priv->network_monitor = _tmp2_;
	_tmp3_ = self->priv->network_monitor;
	if (_tmp3_ != NULL) {
		GNetworkMonitor* _tmp4_;
		GNetworkMonitor* _tmp5_;
		_tmp4_ = self->priv->network_monitor;
		g_signal_connect_object (_tmp4_, "network-changed", (GCallback) _dino_connection_manager_on_network_changed_g_network_monitor_network_changed, self, 0);
		_tmp5_ = self->priv->network_monitor;
		g_signal_connect_object ((GObject*) _tmp5_, "notify::connectivity", (GCallback) _dino_connection_manager_on_network_changed_g_object_notify, self, 0);
	}
	dino_get_login1 (___lambda12__gasync_ready_callback, g_object_ref (self));
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 60, ___lambda13__gsource_func, g_object_ref (self), g_object_unref);
	return self;
}

DinoConnectionManager*
dino_connection_manager_new (DinoModuleManager* module_manager)
{
	return dino_connection_manager_construct (DINO_TYPE_CONNECTION_MANAGER, module_manager);
}

XmppXmppStream*
dino_connection_manager_get_stream (DinoConnectionManager* self,
                                    DinoEntitiesAccount* account)
{
	XmppXmppStream* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	if (dino_connection_manager_get_state (self, account) == DINO_CONNECTION_MANAGER_CONNECTION_STATE_CONNECTED) {
		GeeHashMap* _tmp0_;
		gpointer _tmp1_;
		DinoConnectionManagerConnection* _tmp2_;
		XmppXmppStream* _tmp3_;
		XmppXmppStream* _tmp4_;
		XmppXmppStream* _tmp5_;
		XmppXmppStream* _tmp6_;
		_tmp0_ = self->priv->connections;
		_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, account);
		_tmp2_ = (DinoConnectionManagerConnection*) _tmp1_;
		_tmp3_ = dino_connection_manager_connection_get_stream (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = _g_object_ref0 (_tmp4_);
		_tmp6_ = _tmp5_;
		_dino_connection_manager_connection_unref0 (_tmp2_);
		result = _tmp6_;
		return result;
	}
	result = NULL;
	return result;
}

DinoConnectionManagerConnectionState
dino_connection_manager_get_state (DinoConnectionManager* self,
                                   DinoEntitiesAccount* account)
{
	GeeHashMap* _tmp0_;
	DinoConnectionManagerConnectionState result;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (account != NULL, 0);
	_tmp0_ = self->priv->connections;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, account)) {
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		DinoConnectionManagerConnection* _tmp3_;
		DinoConnectionManagerConnectionState _tmp4_;
		DinoConnectionManagerConnectionState _tmp5_;
		DinoConnectionManagerConnectionState _tmp6_;
		_tmp1_ = self->priv->connections;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, account);
		_tmp3_ = (DinoConnectionManagerConnection*) _tmp2_;
		_tmp4_ = dino_connection_manager_connection_get_connection_state (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = _tmp5_;
		_dino_connection_manager_connection_unref0 (_tmp3_);
		result = _tmp6_;
		return result;
	}
	result = DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED;
	return result;
}

DinoConnectionManagerConnectionError*
dino_connection_manager_get_error (DinoConnectionManager* self,
                                   DinoEntitiesAccount* account)
{
	GeeHashMap* _tmp0_;
	DinoConnectionManagerConnectionError* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	_tmp0_ = self->priv->connection_errors;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, account)) {
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		_tmp1_ = self->priv->connection_errors;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, account);
		result = (DinoConnectionManagerConnectionError*) _tmp2_;
		return result;
	}
	result = NULL;
	return result;
}

GeeCollection*
dino_connection_manager_get_managed_accounts (DinoConnectionManager* self)
{
	GeeHashMap* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeCollection* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->connections;
	_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = (GeeCollection*) _tmp2_;
	return result;
}

void
dino_connection_manager_connect_account (DinoConnectionManager* self,
                                         DinoEntitiesAccount* account)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_tmp0_ = self->priv->connections;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, account)) {
		GeeHashMap* _tmp1_;
		DinoConnectionManagerConnection* _tmp2_;
		DinoConnectionManagerConnection* _tmp3_;
		GeeHashMap* _tmp4_;
		GeeHashMap* _tmp5_;
		_tmp1_ = self->priv->connections;
		_tmp2_ = dino_connection_manager_connection_new ();
		_tmp3_ = _tmp2_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, account, _tmp3_);
		_dino_connection_manager_connection_unref0 (_tmp3_);
		_tmp4_ = self->priv->connection_ongoing;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp4_, account, (gpointer) ((gintptr) FALSE));
		_tmp5_ = self->priv->connection_directly_retry;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp5_, account, (gpointer) ((gintptr) FALSE));
		dino_connection_manager_connect_stream (self, account, NULL, NULL);
	} else {
		dino_connection_manager_check_reconnect (self, account, FALSE);
	}
}

void
dino_connection_manager_make_offline_all (DinoConnectionManager* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeIterator* _account_it = NULL;
		GeeHashMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->connections;
		_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_account_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			DinoEntitiesAccount* account = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			DinoEntitiesAccount* _tmp9_;
			_tmp6_ = _account_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _account_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			account = (DinoEntitiesAccount*) _tmp8_;
			_tmp9_ = account;
			dino_connection_manager_make_offline (self, _tmp9_);
			_g_object_unref0 (account);
		}
		_g_object_unref0 (_account_it);
	}
}

static void
dino_connection_manager_make_offline (DinoConnectionManager* self,
                                      DinoEntitiesAccount* account)
{
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	DinoConnectionManagerConnection* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_tmp0_ = self->priv->connections;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, account);
	_tmp2_ = (DinoConnectionManagerConnection*) _tmp1_;
	dino_connection_manager_connection_make_offline (_tmp2_);
	_dino_connection_manager_connection_unref0 (_tmp2_);
	dino_connection_manager_change_connection_state (self, account, DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED);
}

static void
dino_connection_manager_disconnect_account_data_free (gpointer _data)
{
	DinoConnectionManagerDisconnectAccountData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoConnectionManagerDisconnectAccountData, _data_);
}

void
dino_connection_manager_disconnect_account (DinoConnectionManager* self,
                                            DinoEntitiesAccount* account,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	DinoConnectionManagerDisconnectAccountData* _data_;
	DinoConnectionManager* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_data_ = g_slice_new0 (DinoConnectionManagerDisconnectAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_connection_manager_disconnect_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	dino_connection_manager_disconnect_account_co (_data_);
}

void
dino_connection_manager_disconnect_account_finish (DinoConnectionManager* self,
                                                   GAsyncResult* _res_)
{
	DinoConnectionManagerDisconnectAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
dino_connection_manager_disconnect_account_co (DinoConnectionManagerDisconnectAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->connections;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _data_->_tmp0_, _data_->account)) {
		dino_connection_manager_make_offline (_data_->self, _data_->account);
		_data_->_tmp1_ = _data_->self->priv->connections;
		_data_->_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp1_, _data_->account);
		_data_->_tmp3_ = (DinoConnectionManagerConnection*) _data_->_tmp2_;
		dino_connection_manager_connection_disconnect_account (_data_->_tmp3_, NULL, NULL);
		_dino_connection_manager_connection_unref0 (_data_->_tmp3_);
		_data_->_tmp4_ = _data_->self->priv->connections;
		gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp4_, _data_->account, NULL);
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dino_connection_manager_connect_stream_data_free (gpointer _data)
{
	DinoConnectionManagerConnectStreamData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoConnectionManagerConnectStreamData, _data_);
}

static void
dino_connection_manager_connect_stream (DinoConnectionManager* self,
                                        DinoEntitiesAccount* account,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	DinoConnectionManagerConnectStreamData* _data_;
	DinoConnectionManager* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_data_ = g_slice_new0 (DinoConnectionManagerConnectStreamData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_connection_manager_connect_stream_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	dino_connection_manager_connect_stream_co (_data_);
}

static void
dino_connection_manager_connect_stream_finish (DinoConnectionManager* self,
                                               GAsyncResult* _res_)
{
	DinoConnectionManagerConnectStreamData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		DinoConnectionManager* self;
		self = _data9_->self;
		_g_free0 (_data9_->connection_uuid);
		_g_object_unref0 (_data9_->account);
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}

static gboolean
____lambda6_ (Block9Data* _data9_,
              GTlsCertificate* peer_cert,
              GTlsCertificateFlags errors)
{
	DinoConnectionManager* self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gboolean result;
	self = _data9_->self;
	g_return_val_if_fail (peer_cert != NULL, FALSE);
	_tmp0_ = dino_entities_account_get_domainpart (_data9_->account);
	_tmp1_ = _tmp0_;
	result = dino_connection_manager_on_invalid_certificate (_tmp1_, peer_cert, errors);
	return result;
}

static gboolean
_____lambda6__xmpp_tls_xmpp_stream_on_invalid_cert (GTlsCertificate* peer_cert,
                                                    GTlsCertificateFlags errors,
                                                    gpointer self)
{
	gboolean result;
	result = ____lambda6_ (self, peer_cert, errors);
	return result;
}

static void
dino_connection_manager_connect_stream_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	DinoConnectionManagerConnectStreamData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_connection_manager_connect_stream_co (_data_);
}

static void
__lambda7_ (Block9Data* _data9_,
            XmppXmppStream* stream)
{
	DinoConnectionManager* self;
	self = _data9_->self;
	g_return_if_fail (stream != NULL);
	g_signal_emit (self, dino_connection_manager_signals[DINO_CONNECTION_MANAGER_STREAM_ATTACHED_MODULES_SIGNAL], 0, _data9_->account, stream);
	dino_connection_manager_change_connection_state (self, _data9_->account, DINO_CONNECTION_MANAGER_CONNECTION_STATE_CONNECTED);
}

static void
___lambda7__xmpp_xmpp_stream_attached_modules (XmppXmppStream* _sender,
                                               XmppXmppStream* stream,
                                               gpointer self)
{
	__lambda7_ (self, stream);
}

static void
__lambda8_ (Block9Data* _data9_,
            XmppXmppStream* stream,
            XmppStanzaNode* node)
{
	DinoConnectionManager* self;
	DinoConnectionManagerConnectionError* _tmp0_;
	DinoConnectionManagerConnectionError* _tmp1_;
	self = _data9_->self;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = dino_connection_manager_connection_error_new (DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_SASL, NULL);
	_tmp1_ = _tmp0_;
	dino_connection_manager_set_connection_error (self, _data9_->account, _tmp1_);
	_dino_connection_manager_connection_error_unref0 (_tmp1_);
}

static void
___lambda8__xmpp_sasl_module_received_auth_failure (XmppSaslModule* _sender,
                                                    XmppXmppStream* stream,
                                                    XmppStanzaNode* node,
                                                    gpointer self)
{
	__lambda8_ (self, stream, node);
}

static void
__lambda9_ (Block9Data* _data9_)
{
	DinoConnectionManager* self;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	DinoConnectionManagerConnection* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gboolean _tmp6_;
	self = _data9_->self;
	_tmp0_ = self->priv->connections;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _data9_->account);
	_tmp2_ = (DinoConnectionManagerConnection*) _tmp1_;
	_tmp3_ = dino_connection_manager_connection_get_uuid (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _data9_->connection_uuid;
	_tmp6_ = g_strcmp0 (_tmp4_, _tmp5_) == 0;
	_dino_connection_manager_connection_unref0 (_tmp2_);
	if (_tmp6_) {
		GeeHashMap* _tmp7_;
		gpointer _tmp8_;
		DinoConnectionManagerConnection* _tmp9_;
		GDateTime* _tmp10_;
		GDateTime* _tmp11_;
		_tmp7_ = self->priv->connections;
		_tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp7_, _data9_->account);
		_tmp9_ = (DinoConnectionManagerConnection*) _tmp8_;
		_tmp10_ = g_date_time_new_now_utc ();
		_tmp11_ = _tmp10_;
		dino_connection_manager_connection_set_last_activity (_tmp9_, _tmp11_);
		_g_date_time_unref0 (_tmp11_);
		_dino_connection_manager_connection_unref0 (_tmp9_);
	} else {
		g_warning ("connection_manager.vala:246: Got node for outdated connection");
	}
}

static void
___lambda9__xmpp_xmpp_stream_received_node (XmppXmppStream* _sender,
                                            XmppXmppStream* stream,
                                            XmppStanzaNode* node,
                                            gpointer self)
{
	__lambda9_ (self);
}

static gboolean
dino_connection_manager_connect_stream_co (DinoConnectionManagerConnectStreamData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data9_ = g_slice_new0 (Block9Data);
	_data_->_data9_->_ref_count_ = 1;
	_data_->_data9_->self = g_object_ref (_data_->self);
	_g_object_unref0 (_data_->_data9_->account);
	_data_->_data9_->account = _data_->account;
	_data_->_data9_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->connections;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _data_->_tmp0_, _data_->_data9_->account)) {
		block9_data_unref (_data_->_data9_);
		_data_->_data9_ = NULL;
		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_->_tmp1_ = dino_entities_account_get_bare_jid (_data_->_data9_->account);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = xmpp_jid_to_string (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	g_debug ("connection_manager.vala:185: [%s] (Maybe) Establishing a new connectio" \
"n", _data_->_tmp5_);
	_g_free0 (_data_->_tmp5_);
	_xmpp_jid_unref0 (_data_->_tmp3_);
	_data_->_tmp6_ = _data_->self->priv->connection_errors;
	gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp6_, _data_->_data9_->account, NULL);
	_data_->_tmp7_ = _data_->self->priv->connection_ongoing;
	_data_->_tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp7_, _data_->_data9_->account);
	if ((gboolean) ((gintptr) _data_->_tmp8_)) {
		_data_->_tmp9_ = dino_entities_account_get_bare_jid (_data_->_data9_->account);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = xmpp_jid_to_string (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		g_debug ("connection_manager.vala:192: [%s] Connection attempt already in progre" \
"ss. Directly retry if it fails.", _data_->_tmp13_);
		_g_free0 (_data_->_tmp13_);
		_xmpp_jid_unref0 (_data_->_tmp11_);
		_data_->_tmp14_ = _data_->self->priv->connection_directly_retry;
		gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp14_, _data_->_data9_->account, (gpointer) ((gintptr) TRUE));
		_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
		block9_data_unref (_data_->_data9_);
		_data_->_data9_ = NULL;
		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;
	} else {
		_data_->_tmp15_ = _data_->self->priv->connections;
		_data_->_tmp16_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp15_, _data_->_data9_->account);
		_data_->_tmp17_ = (DinoConnectionManagerConnection*) _data_->_tmp16_;
		_data_->_tmp18_ = dino_connection_manager_connection_get_stream (_data_->_tmp17_);
		_data_->_tmp19_ = _data_->_tmp18_;
		_data_->_tmp20_ = _data_->_tmp19_ != NULL;
		_dino_connection_manager_connection_unref0 (_data_->_tmp17_);
		if (_data_->_tmp20_) {
			_data_->_tmp21_ = dino_entities_account_get_bare_jid (_data_->_data9_->account);
			_data_->_tmp22_ = _data_->_tmp21_;
			_data_->_tmp23_ = _data_->_tmp22_;
			_data_->_tmp24_ = xmpp_jid_to_string (_data_->_tmp23_);
			_data_->_tmp25_ = _data_->_tmp24_;
			g_debug ("connection_manager.vala:196: [%s] Cancelling connecting because there " \
"is already a stream", _data_->_tmp25_);
			_g_free0 (_data_->_tmp25_);
			_xmpp_jid_unref0 (_data_->_tmp23_);
			_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
			block9_data_unref (_data_->_data9_);
			_data_->_data9_ = NULL;
			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;
		} else {
			_data_->_tmp26_ = _data_->self->priv->connection_ongoing;
			gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp26_, _data_->_data9_->account, (gpointer) ((gintptr) TRUE));
			_data_->_tmp27_ = _data_->self->priv->connection_directly_retry;
			gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp27_, _data_->_data9_->account, (gpointer) ((gintptr) FALSE));
			dino_connection_manager_change_connection_state (_data_->self, _data_->_data9_->account, DINO_CONNECTION_MANAGER_CONNECTION_STATE_CONNECTING);
			_data_->_tmp28_ = dino_entities_account_get_bare_jid (_data_->_data9_->account);
			_data_->_tmp29_ = _data_->_tmp28_;
			_data_->_tmp30_ = _data_->_tmp29_;
			_data_->_tmp31_ = _data_->self->priv->module_manager;
			_data_->_tmp32_ = dino_module_manager_get_modules (_data_->_tmp31_, _data_->_data9_->account);
			_data_->_tmp33_ = _data_->_tmp32_;
			_data_->_tmp34_ = _data_->self->log_options;
			_data_->_state_ = 1;
			xmpp_establish_stream (_data_->_tmp30_, (GeeList*) _data_->_tmp33_, _data_->_tmp34_, _____lambda6__xmpp_tls_xmpp_stream_on_invalid_cert, block9_data_ref (_data_->_data9_), block9_data_unref, dino_connection_manager_connect_stream_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp35_ = xmpp_establish_stream_finish (_data_->_res_);
			_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
			_data_->stream_result = _data_->_tmp35_;
			_g_object_unref0 (_data_->_tmp33_);
			_xmpp_jid_unref0 (_data_->_tmp30_);
			_data_->_tmp36_ = _data_->self->priv->connections;
			_data_->_tmp37_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp36_, _data_->_data9_->account);
			_data_->_tmp38_ = (DinoConnectionManagerConnection*) _data_->_tmp37_;
			_data_->_tmp39_ = _data_->stream_result;
			_data_->_tmp40_ = xmpp_xmpp_stream_result_get_stream (_data_->_tmp39_);
			_data_->_tmp41_ = _data_->_tmp40_;
			dino_connection_manager_connection_set_stream (_data_->_tmp38_, (XmppXmppStream*) _data_->_tmp41_);
			_dino_connection_manager_connection_unref0 (_data_->_tmp38_);
			_data_->_tmp42_ = _data_->self->priv->connection_ongoing;
			gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp42_, _data_->_data9_->account, (gpointer) ((gintptr) FALSE));
		}
	}
	_data_->_tmp43_ = _data_->stream_result;
	_data_->_tmp44_ = xmpp_xmpp_stream_result_get_stream (_data_->_tmp43_);
	_data_->_tmp45_ = _data_->_tmp44_;
	if (_data_->_tmp45_ == NULL) {
		_data_->_tmp46_ = _data_->stream_result;
		_data_->_tmp47_ = xmpp_xmpp_stream_result_get_tls_errors (_data_->_tmp46_);
		_data_->_tmp48_ = _data_->_tmp47_;
		if (_data_->_tmp48_ != NULL) {
			_data_->_tmp49_ = NULL;
			_data_->_tmp49_ = dino_connection_manager_connection_error_new (DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_TLS, NULL);
			dino_connection_manager_connection_error_set_reconnect_recomendation (_data_->_tmp49_, DINO_CONNECTION_MANAGER_CONNECTION_ERROR_RECONNECT_NEVER);
			_data_->_tmp50_ = _data_->_tmp49_;
			dino_connection_manager_set_connection_error (_data_->self, _data_->_data9_->account, _data_->_tmp50_);
			_dino_connection_manager_connection_error_unref0 (_data_->_tmp50_);
			_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
			block9_data_unref (_data_->_data9_);
			_data_->_data9_ = NULL;
			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_->_tmp51_ = dino_entities_account_get_bare_jid (_data_->_data9_->account);
		_data_->_tmp52_ = _data_->_tmp51_;
		_data_->_tmp53_ = _data_->_tmp52_;
		_data_->_tmp54_ = xmpp_jid_to_string (_data_->_tmp53_);
		_data_->_tmp55_ = _data_->_tmp54_;
		g_debug ("connection_manager.vala:217: [%s] Could not connect", _data_->_tmp55_);
		_g_free0 (_data_->_tmp55_);
		_xmpp_jid_unref0 (_data_->_tmp53_);
		dino_connection_manager_change_connection_state (_data_->self, _data_->_data9_->account, DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED);
		_data_->_tmp56_ = _data_->self->priv->connection_directly_retry;
		_data_->_tmp57_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp56_, _data_->_data9_->account);
		dino_connection_manager_check_reconnect (_data_->self, _data_->_data9_->account, (gboolean) ((gintptr) _data_->_tmp57_));
		_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
		block9_data_unref (_data_->_data9_);
		_data_->_data9_ = NULL;
		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_->_tmp58_ = _data_->stream_result;
	_data_->_tmp59_ = xmpp_xmpp_stream_result_get_stream (_data_->_tmp58_);
	_data_->_tmp60_ = _data_->_tmp59_;
	_data_->_tmp61_ = _g_object_ref0 ((XmppXmppStream*) _data_->_tmp60_);
	_data_->stream = _data_->_tmp61_;
	_data_->_tmp62_ = dino_entities_account_get_full_jid (_data_->_data9_->account);
	_data_->_tmp63_ = _data_->_tmp62_;
	_data_->_tmp64_ = xmpp_jid_to_string (_data_->_tmp63_);
	_data_->_tmp65_ = _data_->_tmp64_;
	_data_->_tmp66_ = _data_->stream;
	g_debug ("connection_manager.vala:228: [%s] New connection: %p", _data_->_tmp65_, _data_->_tmp66_);
	_g_free0 (_data_->_tmp65_);
	_data_->_tmp67_ = _data_->self->priv->connections;
	_data_->_tmp68_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp67_, _data_->_data9_->account);
	_data_->_tmp69_ = (DinoConnectionManagerConnection*) _data_->_tmp68_;
	_data_->_tmp70_ = g_date_time_new_now_utc ();
	_data_->_tmp71_ = _data_->_tmp70_;
	dino_connection_manager_connection_set_established (_data_->_tmp69_, _data_->_tmp71_);
	_g_date_time_unref0 (_data_->_tmp71_);
	_dino_connection_manager_connection_unref0 (_data_->_tmp69_);
	_data_->_tmp72_ = _data_->stream;
	g_signal_connect_data (_data_->_tmp72_, "attached-modules", (GCallback) ___lambda7__xmpp_xmpp_stream_attached_modules, block9_data_ref (_data_->_data9_), (GClosureNotify) block9_data_unref, 0);
	_data_->_tmp73_ = _data_->stream;
	_data_->_tmp74_ = xmpp_sasl_module_IDENTITY;
	_data_->_tmp75_ = xmpp_xmpp_stream_get_module (_data_->_tmp73_, XMPP_SASL_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp74_);
	_data_->_tmp76_ = (XmppSaslModule*) _data_->_tmp75_;
	g_signal_connect_data (_data_->_tmp76_, "received-auth-failure", (GCallback) ___lambda8__xmpp_sasl_module_received_auth_failure, block9_data_ref (_data_->_data9_), (GClosureNotify) block9_data_unref, 0);
	_g_object_unref0 (_data_->_tmp76_);
	_data_->_tmp77_ = _data_->self->priv->connections;
	_data_->_tmp78_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp77_, _data_->_data9_->account);
	_data_->_tmp79_ = (DinoConnectionManagerConnection*) _data_->_tmp78_;
	_data_->_tmp80_ = dino_connection_manager_connection_get_uuid (_data_->_tmp79_);
	_data_->_tmp81_ = _data_->_tmp80_;
	_data_->_tmp82_ = g_strdup (_data_->_tmp81_);
	_data_->_tmp83_ = _data_->_tmp82_;
	_dino_connection_manager_connection_unref0 (_data_->_tmp79_);
	_data_->_data9_->connection_uuid = _data_->_tmp83_;
	_data_->_tmp84_ = _data_->stream;
	g_signal_connect_data (_data_->_tmp84_, "received-node", (GCallback) ___lambda9__xmpp_xmpp_stream_received_node, block9_data_ref (_data_->_data9_), (GClosureNotify) block9_data_unref, 0);
	_data_->_tmp85_ = _data_->stream;
	g_signal_emit (_data_->self, dino_connection_manager_signals[DINO_CONNECTION_MANAGER_STREAM_OPENED_SIGNAL], 0, _data_->_data9_->account, _data_->_tmp85_);
	{
		_data_->_tmp86_ = _data_->stream;
		_data_->_state_ = 2;
		xmpp_xmpp_stream_loop (_data_->_tmp86_, dino_connection_manager_connect_stream_ready, _data_);
		return FALSE;
		_state_2:
		xmpp_xmpp_stream_loop_finish (_data_->_tmp86_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp87_ = dino_entities_account_get_bare_jid (_data_->_data9_->account);
		_data_->_tmp88_ = _data_->_tmp87_;
		_data_->_tmp89_ = _data_->_tmp88_;
		_data_->_tmp90_ = xmpp_jid_to_string (_data_->_tmp89_);
		_data_->_tmp91_ = _data_->_tmp90_;
		_data_->_tmp92_ = _data_->stream;
		_data_->_tmp93_ = _data_->e;
		_data_->_tmp94_ = _data_->_tmp93_->message;
		g_debug ("connection_manager.vala:254: [%s %p] Connection error: %s", _data_->_tmp91_, _data_->_tmp92_, _data_->_tmp94_);
		_g_free0 (_data_->_tmp91_);
		_xmpp_jid_unref0 (_data_->_tmp89_);
		dino_connection_manager_change_connection_state (_data_->self, _data_->_data9_->account, DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED);
		_data_->_tmp95_ = _data_->self->priv->connections;
		if (!gee_abstract_map_has_key ((GeeAbstractMap*) _data_->_tmp95_, _data_->_data9_->account)) {
			_g_error_free0 (_data_->e);
			_g_object_unref0 (_data_->stream);
			_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
			block9_data_unref (_data_->_data9_);
			_data_->_data9_ = NULL;
			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_->_tmp96_ = _data_->self->priv->connections;
		_data_->_tmp97_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp96_, _data_->_data9_->account);
		_data_->_tmp98_ = (DinoConnectionManagerConnection*) _data_->_tmp97_;
		dino_connection_manager_connection_reset (_data_->_tmp98_);
		_dino_connection_manager_connection_unref0 (_data_->_tmp98_);
		_data_->_tmp99_ = _data_->stream;
		_data_->_tmp100_ = xmpp_stream_error_flag_IDENTITY;
		_data_->_tmp101_ = xmpp_xmpp_stream_get_flag (_data_->_tmp99_, XMPP_STREAM_ERROR_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp100_);
		_data_->flag = (XmppStreamErrorFlag*) _data_->_tmp101_;
		_data_->_tmp102_ = _data_->flag;
		if (_data_->_tmp102_ != NULL) {
			_data_->_tmp103_ = dino_entities_account_get_bare_jid (_data_->_data9_->account);
			_data_->_tmp104_ = _data_->_tmp103_;
			_data_->_tmp105_ = _data_->_tmp104_;
			_data_->_tmp106_ = xmpp_jid_to_string (_data_->_tmp105_);
			_data_->_tmp107_ = _data_->_tmp106_;
			_data_->_tmp108_ = _data_->stream;
			_data_->_tmp109_ = _data_->flag;
			_data_->_tmp110_ = _data_->_tmp109_->error_type;
			g_warning ("connection_manager.vala:262: [%s %p] Stream Error: %s", _data_->_tmp107_, _data_->_tmp108_, _data_->_tmp110_);
			_g_free0 (_data_->_tmp107_);
			_xmpp_jid_unref0 (_data_->_tmp105_);
			_data_->_tmp111_ = _data_->flag;
			_data_->_tmp112_ = _data_->_tmp111_->error_type;
			_data_->_tmp113_ = dino_connection_manager_connection_error_new (DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_STREAM_ERROR, _data_->_tmp112_);
			_data_->_tmp114_ = _data_->_tmp113_;
			dino_connection_manager_set_connection_error (_data_->self, _data_->_data9_->account, _data_->_tmp114_);
			_dino_connection_manager_connection_error_unref0 (_data_->_tmp114_);
			_data_->_tmp115_ = _data_->flag;
			if (_data_->_tmp115_->resource_rejected) {
				dino_entities_account_set_random_resource (_data_->_data9_->account);
				dino_connection_manager_connect_stream (_data_->self, _data_->_data9_->account, NULL, NULL);
				_g_object_unref0 (_data_->flag);
				_g_error_free0 (_data_->e);
				_g_object_unref0 (_data_->stream);
				_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
				block9_data_unref (_data_->_data9_);
				_data_->_data9_ = NULL;
				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_->_tmp116_ = _data_->self->priv->connection_errors;
		_data_->_tmp117_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp116_, _data_->_data9_->account);
		_data_->_error_ = (DinoConnectionManagerConnectionError*) _data_->_tmp117_;
		_data_->_tmp119_ = _data_->_error_;
		if (_data_->_tmp119_ != NULL) {
			_data_->_tmp120_ = _data_->_error_;
			_data_->_tmp118_ = _data_->_tmp120_->source == DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_SASL;
		} else {
			_data_->_tmp118_ = FALSE;
		}
		if (_data_->_tmp118_) {
			_dino_connection_manager_connection_error_unref0 (_data_->_error_);
			_g_object_unref0 (_data_->flag);
			_g_error_free0 (_data_->e);
			_g_object_unref0 (_data_->stream);
			_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
			block9_data_unref (_data_->_data9_);
			_data_->_data9_ = NULL;
			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;
		}
		dino_connection_manager_check_reconnect (_data_->self, _data_->_data9_->account, FALSE);
		_dino_connection_manager_connection_error_unref0 (_data_->_error_);
		_g_object_unref0 (_data_->flag);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->stream);
		_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
		block9_data_unref (_data_->_data9_);
		_data_->_data9_ = NULL;
		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_->stream);
	_xmpp_xmpp_stream_result_unref0 (_data_->stream_result);
	block9_data_unref (_data_->_data9_);
	_data_->_data9_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dino_connection_manager_check_reconnects (DinoConnectionManager* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeIterator* _account_it = NULL;
		GeeHashMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->connections;
		_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_account_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			DinoEntitiesAccount* account = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			DinoEntitiesAccount* _tmp9_;
			_tmp6_ = _account_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _account_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			account = (DinoEntitiesAccount*) _tmp8_;
			_tmp9_ = account;
			dino_connection_manager_check_reconnect (self, _tmp9_, FALSE);
			_g_object_unref0 (account);
		}
		_g_object_unref0 (_account_it);
	}
}

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_)) {
		DinoConnectionManager* self;
		self = _data10_->self;
		_g_object_unref0 (_data10_->stream);
		_g_date_time_unref0 (_data10_->last_activity_was);
		_g_object_unref0 (_data10_->account);
		_g_object_unref0 (self);
		g_slice_free (Block10Data, _data10_);
	}
}

static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

static gboolean
___lambda5_ (Block10Data* _data10_)
{
	DinoConnectionManager* self;
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	gpointer _tmp2_;
	DinoConnectionManagerConnection* _tmp3_;
	XmppXmppStream* _tmp4_;
	XmppXmppStream* _tmp5_;
	gboolean _tmp6_;
	GeeHashMap* _tmp7_;
	gpointer _tmp8_;
	DinoConnectionManagerConnection* _tmp9_;
	GDateTime* _tmp10_;
	GDateTime* _tmp11_;
	GDateTime* _tmp12_;
	gboolean _tmp13_;
	gboolean result;
	self = _data10_->self;
	_tmp0_ = self->priv->connections;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _data10_->account)) {
		result = FALSE;
		return result;
	}
	_tmp1_ = self->priv->connections;
	_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, _data10_->account);
	_tmp3_ = (DinoConnectionManagerConnection*) _tmp2_;
	_tmp4_ = dino_connection_manager_connection_get_stream (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_ != NULL;
	_dino_connection_manager_connection_unref0 (_tmp3_);
	if (_tmp6_) {
		result = FALSE;
		return result;
	}
	_tmp7_ = self->priv->connections;
	_tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp7_, _data10_->account);
	_tmp9_ = (DinoConnectionManagerConnection*) _tmp8_;
	_tmp10_ = dino_connection_manager_connection_get_last_activity (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = _data10_->last_activity_was;
	_tmp13_ = _tmp11_ != _tmp12_;
	_dino_connection_manager_connection_unref0 (_tmp9_);
	if (_tmp13_) {
		result = FALSE;
		return result;
	}
	dino_connection_manager_connect_stream (self, _data10_->account, NULL, NULL);
	result = FALSE;
	return result;
}

static gboolean
____lambda5__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda5_ (self);
	return result;
}

static void
__lambda10_ (Block10Data* _data10_)
{
	DinoConnectionManager* self;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	DinoConnectionManagerConnection* _tmp2_;
	XmppXmppStream* _tmp3_;
	XmppXmppStream* _tmp4_;
	XmppXmppStream* _tmp5_;
	gboolean _tmp6_;
	self = _data10_->self;
	_data10_->acked = TRUE;
	_tmp0_ = self->priv->connections;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, _data10_->account);
	_tmp2_ = (DinoConnectionManagerConnection*) _tmp1_;
	_tmp3_ = dino_connection_manager_connection_get_stream (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _data10_->stream;
	_tmp6_ = _tmp4_ != _tmp5_;
	_dino_connection_manager_connection_unref0 (_tmp2_);
	if (_tmp6_) {
		return;
	}
	dino_connection_manager_change_connection_state (self, _data10_->account, DINO_CONNECTION_MANAGER_CONNECTION_STATE_CONNECTED);
}

static void
___lambda10__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda10_ (self);
	block10_data_unref (self);
}

static gboolean
__lambda11_ (Block10Data* _data10_)
{
	DinoConnectionManager* self;
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	gpointer _tmp2_;
	DinoConnectionManagerConnection* _tmp3_;
	XmppXmppStream* _tmp4_;
	XmppXmppStream* _tmp5_;
	XmppXmppStream* _tmp6_;
	gboolean _tmp7_;
	GeeHashMap* _tmp8_;
	gpointer _tmp9_;
	DinoConnectionManagerConnection* _tmp10_;
	GDateTime* _tmp11_;
	GDateTime* _tmp12_;
	GDateTime* _tmp13_;
	gboolean _tmp14_;
	XmppJid* _tmp15_;
	XmppJid* _tmp16_;
	XmppJid* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	XmppXmppStream* _tmp20_;
	GeeHashMap* _tmp21_;
	gpointer _tmp22_;
	DinoConnectionManagerConnection* _tmp23_;
	gboolean result;
	self = _data10_->self;
	_tmp0_ = self->priv->connections;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _data10_->account)) {
		result = FALSE;
		return result;
	}
	_tmp1_ = self->priv->connections;
	_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, _data10_->account);
	_tmp3_ = (DinoConnectionManagerConnection*) _tmp2_;
	_tmp4_ = dino_connection_manager_connection_get_stream (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _data10_->stream;
	_tmp7_ = _tmp5_ != _tmp6_;
	_dino_connection_manager_connection_unref0 (_tmp3_);
	if (_tmp7_) {
		result = FALSE;
		return result;
	}
	if (_data10_->acked) {
		result = FALSE;
		return result;
	}
	_tmp8_ = self->priv->connections;
	_tmp9_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp8_, _data10_->account);
	_tmp10_ = (DinoConnectionManagerConnection*) _tmp9_;
	_tmp11_ = dino_connection_manager_connection_get_last_activity (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = _data10_->last_activity_was;
	_tmp14_ = _tmp12_ != _tmp13_;
	_dino_connection_manager_connection_unref0 (_tmp10_);
	if (_tmp14_) {
		result = FALSE;
		return result;
	}
	_tmp15_ = dino_entities_account_get_bare_jid (_data10_->account);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp18_ = xmpp_jid_to_string (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = _data10_->stream;
	g_debug ("connection_manager.vala:320: [%s %p] Ping timeouted. Reconnecting", _tmp19_, _tmp20_);
	_g_free0 (_tmp19_);
	_xmpp_jid_unref0 (_tmp17_);
	dino_connection_manager_change_connection_state (self, _data10_->account, DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED);
	_tmp21_ = self->priv->connections;
	_tmp22_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp21_, _data10_->account);
	_tmp23_ = (DinoConnectionManagerConnection*) _tmp22_;
	dino_connection_manager_connection_reset (_tmp23_);
	_dino_connection_manager_connection_unref0 (_tmp23_);
	dino_connection_manager_connect_stream (self, _data10_->account, NULL, NULL);
	result = FALSE;
	return result;
}

static gboolean
___lambda11__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda11_ (self);
	return result;
}

static void
dino_connection_manager_check_reconnect (DinoConnectionManager* self,
                                         DinoEntitiesAccount* account,
                                         gboolean directly_reconnect)
{
	Block10Data* _data10_;
	DinoEntitiesAccount* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	gpointer _tmp3_;
	DinoConnectionManagerConnection* _tmp4_;
	GDateTime* _tmp5_;
	GDateTime* _tmp6_;
	GDateTime* _tmp7_;
	GDateTime* _tmp8_;
	GeeHashMap* _tmp9_;
	gpointer _tmp10_;
	DinoConnectionManagerConnection* _tmp11_;
	XmppXmppStream* _tmp12_;
	XmppXmppStream* _tmp13_;
	gboolean _tmp14_;
	GeeHashMap* _tmp15_;
	gpointer _tmp16_;
	DinoConnectionManagerConnection* _tmp17_;
	XmppXmppStream* _tmp18_;
	XmppXmppStream* _tmp19_;
	XmppXmppStream* _tmp20_;
	XmppXmppStream* _tmp21_;
	XmppXmppStream* _tmp22_;
	XmppModuleIdentity* _tmp23_;
	gpointer _tmp24_;
	XmppXepPingModule* _tmp25_;
	XmppXmppStream* _tmp26_;
	XmppJid* _tmp27_;
	XmppJid* _tmp28_;
	XmppJid* _tmp29_;
	XmppJid* _tmp30_;
	XmppJid* _tmp31_;
	XmppJid* _tmp32_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_data10_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (_data10_->account);
	_data10_->account = _tmp0_;
	_tmp1_ = self->priv->connections;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp1_, _data10_->account)) {
		block10_data_unref (_data10_);
		_data10_ = NULL;
		return;
	}
	_data10_->acked = FALSE;
	_tmp2_ = self->priv->connections;
	_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp2_, _data10_->account);
	_tmp4_ = (DinoConnectionManagerConnection*) _tmp3_;
	_tmp5_ = dino_connection_manager_connection_get_last_activity (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _g_date_time_ref0 (_tmp6_);
	_tmp8_ = _tmp7_;
	_dino_connection_manager_connection_unref0 (_tmp4_);
	_data10_->last_activity_was = _tmp8_;
	_tmp9_ = self->priv->connections;
	_tmp10_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp9_, _data10_->account);
	_tmp11_ = (DinoConnectionManagerConnection*) _tmp10_;
	_tmp12_ = dino_connection_manager_connection_get_stream (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_ == NULL;
	_dino_connection_manager_connection_unref0 (_tmp11_);
	if (_tmp14_) {
		g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 10, ____lambda5__gsource_func, block10_data_ref (_data10_), block10_data_unref);
		block10_data_unref (_data10_);
		_data10_ = NULL;
		return;
	}
	_tmp15_ = self->priv->connections;
	_tmp16_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp15_, _data10_->account);
	_tmp17_ = (DinoConnectionManagerConnection*) _tmp16_;
	_tmp18_ = dino_connection_manager_connection_get_stream (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = _g_object_ref0 (_tmp19_);
	_tmp21_ = _tmp20_;
	_dino_connection_manager_connection_unref0 (_tmp17_);
	_data10_->stream = _tmp21_;
	_tmp22_ = _data10_->stream;
	_tmp23_ = xmpp_xep_ping_module_IDENTITY;
	_tmp24_ = xmpp_xmpp_stream_get_module (_tmp22_, XMPP_XEP_PING_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp23_);
	_tmp25_ = (XmppXepPingModule*) _tmp24_;
	_tmp26_ = _data10_->stream;
	_tmp27_ = dino_entities_account_get_bare_jid (_data10_->account);
	_tmp28_ = _tmp27_;
	_tmp29_ = _tmp28_;
	_tmp30_ = xmpp_jid_get_domain_jid (_tmp29_);
	_tmp31_ = _tmp30_;
	_tmp32_ = _tmp31_;
	xmpp_xep_ping_module_send_ping (_tmp25_, _tmp26_, _tmp32_, ___lambda10__gasync_ready_callback, block10_data_ref (_data10_));
	_xmpp_jid_unref0 (_tmp32_);
	_xmpp_jid_unref0 (_tmp29_);
	_g_object_unref0 (_tmp25_);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 10, ___lambda11__gsource_func, block10_data_ref (_data10_), block10_data_unref);
	block10_data_unref (_data10_);
	_data10_ = NULL;
}

static gboolean
dino_connection_manager_network_is_online (DinoConnectionManager* self)
{
	gboolean _tmp0_ = FALSE;
	GNetworkMonitor* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->network_monitor;
	if (_tmp1_ != NULL) {
		GNetworkMonitor* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->priv->network_monitor;
		_tmp3_ = g_network_monitor_get_network_available (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
dino_connection_manager_on_network_changed (DinoConnectionManager* self)
{
	g_return_if_fail (self != NULL);
	if (dino_connection_manager_network_is_online (self)) {
		g_debug ("connection_manager.vala:341: NetworkMonitor: Network reported online");
		dino_connection_manager_check_reconnects (self);
	} else {
		g_debug ("connection_manager.vala:344: NetworkMonitor: Network reported offline");
		{
			GeeIterator* _account_it = NULL;
			GeeHashMap* _tmp0_;
			GeeSet* _tmp1_;
			GeeSet* _tmp2_;
			GeeSet* _tmp3_;
			GeeIterator* _tmp4_;
			GeeIterator* _tmp5_;
			_tmp0_ = self->priv->connections;
			_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _tmp0_);
			_tmp2_ = _tmp1_;
			_tmp3_ = _tmp2_;
			_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
			_tmp5_ = _tmp4_;
			_g_object_unref0 (_tmp3_);
			_account_it = _tmp5_;
			while (TRUE) {
				GeeIterator* _tmp6_;
				DinoEntitiesAccount* account = NULL;
				GeeIterator* _tmp7_;
				gpointer _tmp8_;
				DinoEntitiesAccount* _tmp9_;
				_tmp6_ = _account_it;
				if (!gee_iterator_next (_tmp6_)) {
					break;
				}
				_tmp7_ = _account_it;
				_tmp8_ = gee_iterator_get (_tmp7_);
				account = (DinoEntitiesAccount*) _tmp8_;
				_tmp9_ = account;
				dino_connection_manager_change_connection_state (self, _tmp9_, DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED);
				_g_object_unref0 (account);
			}
			_g_object_unref0 (_account_it);
		}
	}
}

static void
dino_connection_manager_on_prepare_for_sleep_data_free (gpointer _data)
{
	DinoConnectionManagerOnPrepareForSleepData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoConnectionManagerOnPrepareForSleepData, _data_);
}

static void
dino_connection_manager_on_prepare_for_sleep (DinoConnectionManager* self,
                                              gboolean suspend,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	DinoConnectionManagerOnPrepareForSleepData* _data_;
	DinoConnectionManager* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DinoConnectionManagerOnPrepareForSleepData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_connection_manager_on_prepare_for_sleep_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->suspend = suspend;
	dino_connection_manager_on_prepare_for_sleep_co (_data_);
}

static void
dino_connection_manager_on_prepare_for_sleep_finish (DinoConnectionManager* self,
                                                     GAsyncResult* _res_)
{
	DinoConnectionManagerOnPrepareForSleepData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dino_connection_manager_on_prepare_for_sleep_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	DinoConnectionManagerOnPrepareForSleepData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_connection_manager_on_prepare_for_sleep_co (_data_);
}

static gboolean
dino_connection_manager_on_prepare_for_sleep_co (DinoConnectionManagerOnPrepareForSleepData* _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->connections;
		_data_->_tmp1_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _data_->_tmp0_);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		_g_object_unref0 (_data_->_tmp3_);
		_data_->_account_it = _data_->_tmp5_;
		while (TRUE) {
			_data_->_tmp6_ = _data_->_account_it;
			if (!gee_iterator_next (_data_->_tmp6_)) {
				break;
			}
			_data_->_tmp7_ = _data_->_account_it;
			_data_->_tmp8_ = gee_iterator_get (_data_->_tmp7_);
			_data_->account = (DinoEntitiesAccount*) _data_->_tmp8_;
			_data_->_tmp9_ = _data_->account;
			dino_connection_manager_change_connection_state (_data_->self, _data_->_tmp9_, DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED);
			_g_object_unref0 (_data_->account);
		}
		_g_object_unref0 (_data_->_account_it);
	}
	if (_data_->suspend) {
		g_debug ("connection_manager.vala:356: Login1: Device suspended");
		{
			_data_->_tmp10_ = _data_->self->priv->connections;
			_data_->_tmp11_ = gee_abstract_map_get_keys ((GeeAbstractMap*) _data_->_tmp10_);
			_data_->_tmp12_ = _data_->_tmp11_;
			_data_->_tmp13_ = _data_->_tmp12_;
			_data_->_tmp14_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp13_);
			_data_->_tmp15_ = _data_->_tmp14_;
			_g_object_unref0 (_data_->_tmp13_);
			_data_->_vala1__account_it = _data_->_tmp15_;
			while (TRUE) {
				_data_->_tmp16_ = _data_->_vala1__account_it;
				if (!gee_iterator_next (_data_->_tmp16_)) {
					break;
				}
				_data_->_tmp17_ = _data_->_vala1__account_it;
				_data_->_tmp18_ = gee_iterator_get (_data_->_tmp17_);
				_data_->_vala1_account = (DinoEntitiesAccount*) _data_->_tmp18_;
				{
					_data_->_tmp19_ = _data_->_vala1_account;
					dino_connection_manager_make_offline (_data_->self, _data_->_tmp19_);
					_data_->_tmp20_ = _data_->self->priv->connections;
					_data_->_tmp21_ = _data_->_vala1_account;
					_data_->_tmp22_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp20_, _data_->_tmp21_);
					_data_->_tmp23_ = (DinoConnectionManagerConnection*) _data_->_tmp22_;
					_data_->_tmp24_ = dino_connection_manager_connection_get_stream (_data_->_tmp23_);
					_data_->_tmp25_ = _data_->_tmp24_;
					_data_->_tmp26_ = _data_->_tmp25_ != NULL;
					_dino_connection_manager_connection_unref0 (_data_->_tmp23_);
					if (_data_->_tmp26_) {
						_data_->_tmp27_ = _data_->self->priv->connections;
						_data_->_tmp28_ = _data_->_vala1_account;
						_data_->_tmp29_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp27_, _data_->_tmp28_);
						_data_->_tmp30_ = (DinoConnectionManagerConnection*) _data_->_tmp29_;
						_data_->_tmp31_ = dino_connection_manager_connection_get_stream (_data_->_tmp30_);
						_data_->_tmp32_ = _data_->_tmp31_;
						_data_->_state_ = 1;
						xmpp_xmpp_stream_disconnect (_data_->_tmp32_, dino_connection_manager_on_prepare_for_sleep_ready, _data_);
						return FALSE;
						_state_1:
						xmpp_xmpp_stream_disconnect_finish (_data_->_tmp32_, _data_->_res_, &_data_->_inner_error0_);
						_dino_connection_manager_connection_unref0 (_data_->_tmp30_);
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							goto __catch0_g_error;
						}
					}
				}
				goto __finally0;
				__catch0_g_error:
				{
					_data_->e = _data_->_inner_error0_;
					_data_->_inner_error0_ = NULL;
					_data_->_tmp33_ = _data_->self->priv->connections;
					_data_->_tmp34_ = _data_->_vala1_account;
					_data_->_tmp35_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp33_, _data_->_tmp34_);
					_data_->_tmp36_ = (DinoConnectionManagerConnection*) _data_->_tmp35_;
					_data_->_tmp37_ = dino_connection_manager_connection_get_stream (_data_->_tmp36_);
					_data_->_tmp38_ = _data_->_tmp37_;
					_data_->_tmp39_ = _data_->e;
					_data_->_tmp40_ = _data_->_tmp39_->message;
					g_debug ("connection_manager.vala:364: Error disconnecting stream %p: %s", _data_->_tmp38_, _data_->_tmp40_);
					_dino_connection_manager_connection_unref0 (_data_->_tmp36_);
					_g_error_free0 (_data_->e);
				}
				__finally0:
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->_vala1_account);
					_g_object_unref0 (_data_->_vala1__account_it);
					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_->_vala1_account);
			}
			_g_object_unref0 (_data_->_vala1__account_it);
		}
	} else {
		g_debug ("connection_manager.vala:368: Login1: Device un-suspend");
		dino_connection_manager_check_reconnects (_data_->self);
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dino_connection_manager_change_connection_state (DinoConnectionManager* self,
                                                 DinoEntitiesAccount* account,
                                                 DinoConnectionManagerConnectionState state)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_tmp0_ = self->priv->connections;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, account)) {
		GeeHashMap* _tmp1_;
		gpointer _tmp2_;
		DinoConnectionManagerConnection* _tmp3_;
		_tmp1_ = self->priv->connections;
		_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp1_, account);
		_tmp3_ = (DinoConnectionManagerConnection*) _tmp2_;
		dino_connection_manager_connection_set_connection_state (_tmp3_, state);
		_dino_connection_manager_connection_unref0 (_tmp3_);
		g_signal_emit (self, dino_connection_manager_signals[DINO_CONNECTION_MANAGER_CONNECTION_STATE_CHANGED_SIGNAL], 0, account, state);
	}
}

static void
dino_connection_manager_set_connection_error (DinoConnectionManager* self,
                                              DinoEntitiesAccount* account,
                                              DinoConnectionManagerConnectionError* _error_)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (_error_ != NULL);
	_tmp0_ = self->priv->connection_errors;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp0_, account, _error_);
	g_signal_emit (self, dino_connection_manager_signals[DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SIGNAL], 0, account, _error_);
}

gboolean
dino_connection_manager_on_invalid_certificate (const gchar* domain,
                                                GTlsCertificate* peer_cert,
                                                GTlsCertificateFlags errors)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (domain != NULL, FALSE);
	g_return_val_if_fail (peer_cert != NULL, FALSE);
	if (g_str_has_suffix (domain, ".onion")) {
		_tmp0_ = errors == G_TLS_CERTIFICATE_UNKNOWN_CA;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		g_warning ("connection_manager.vala:389: Accepting TLS certificate from unknown CA" \
" from .onion address %s", domain);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

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

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

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

static inline gpointer
dino_connection_manager_connection_error_get_instance_private (DinoConnectionManagerConnectionError* self)
{
	return G_STRUCT_MEMBER_P (self, DinoConnectionManagerConnectionError_private_offset);
}

static GType
dino_connection_manager_connection_error_source_get_type_once (void)
{
	static const GEnumValue values[] = {{DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_CONNECTION, "DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_CONNECTION", "connection"}, {DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_SASL, "DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_SASL", "sasl"}, {DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_TLS, "DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_TLS", "tls"}, {DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_STREAM_ERROR, "DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SOURCE_STREAM_ERROR", "stream-error"}, {0, NULL, NULL}};
	GType dino_connection_manager_connection_error_source_type_id;
	dino_connection_manager_connection_error_source_type_id = g_enum_register_static ("DinoConnectionManagerConnectionErrorSource", values);
	return dino_connection_manager_connection_error_source_type_id;
}

GType
dino_connection_manager_connection_error_source_get_type (void)
{
	static volatile gsize dino_connection_manager_connection_error_source_type_id__once = 0;
	if (g_once_init_enter (&dino_connection_manager_connection_error_source_type_id__once)) {
		GType dino_connection_manager_connection_error_source_type_id;
		dino_connection_manager_connection_error_source_type_id = dino_connection_manager_connection_error_source_get_type_once ();
		g_once_init_leave (&dino_connection_manager_connection_error_source_type_id__once, dino_connection_manager_connection_error_source_type_id);
	}
	return dino_connection_manager_connection_error_source_type_id__once;
}

static GType
dino_connection_manager_connection_error_reconnect_get_type_once (void)
{
	static const GEnumValue values[] = {{DINO_CONNECTION_MANAGER_CONNECTION_ERROR_RECONNECT_NOW, "DINO_CONNECTION_MANAGER_CONNECTION_ERROR_RECONNECT_NOW", "now"}, {DINO_CONNECTION_MANAGER_CONNECTION_ERROR_RECONNECT_LATER, "DINO_CONNECTION_MANAGER_CONNECTION_ERROR_RECONNECT_LATER", "later"}, {DINO_CONNECTION_MANAGER_CONNECTION_ERROR_RECONNECT_NEVER, "DINO_CONNECTION_MANAGER_CONNECTION_ERROR_RECONNECT_NEVER", "never"}, {0, NULL, NULL}};
	GType dino_connection_manager_connection_error_reconnect_type_id;
	dino_connection_manager_connection_error_reconnect_type_id = g_enum_register_static ("DinoConnectionManagerConnectionErrorReconnect", values);
	return dino_connection_manager_connection_error_reconnect_type_id;
}

GType
dino_connection_manager_connection_error_reconnect_get_type (void)
{
	static volatile gsize dino_connection_manager_connection_error_reconnect_type_id__once = 0;
	if (g_once_init_enter (&dino_connection_manager_connection_error_reconnect_type_id__once)) {
		GType dino_connection_manager_connection_error_reconnect_type_id;
		dino_connection_manager_connection_error_reconnect_type_id = dino_connection_manager_connection_error_reconnect_get_type_once ();
		g_once_init_leave (&dino_connection_manager_connection_error_reconnect_type_id__once, dino_connection_manager_connection_error_reconnect_type_id);
	}
	return dino_connection_manager_connection_error_reconnect_type_id__once;
}

DinoConnectionManagerConnectionError*
dino_connection_manager_connection_error_construct (GType object_type,
                                                    DinoConnectionManagerConnectionErrorSource source,
                                                    const gchar* identifier)
{
	DinoConnectionManagerConnectionError* self = NULL;
	gchar* _tmp0_;
	self = (DinoConnectionManagerConnectionError*) g_type_create_instance (object_type);
	self->source = source;
	_tmp0_ = g_strdup (identifier);
	_g_free0 (self->identifier);
	self->identifier = _tmp0_;
	return self;
}

DinoConnectionManagerConnectionError*
dino_connection_manager_connection_error_new (DinoConnectionManagerConnectionErrorSource source,
                                              const gchar* identifier)
{
	return dino_connection_manager_connection_error_construct (DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR, source, identifier);
}

DinoConnectionManagerConnectionErrorReconnect
dino_connection_manager_connection_error_get_reconnect_recomendation (DinoConnectionManagerConnectionError* self)
{
	DinoConnectionManagerConnectionErrorReconnect result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_reconnect_recomendation;
	return result;
}

void
dino_connection_manager_connection_error_set_reconnect_recomendation (DinoConnectionManagerConnectionError* self,
                                                                      DinoConnectionManagerConnectionErrorReconnect value)
{
	g_return_if_fail (self != NULL);
	self->priv->_reconnect_recomendation = value;
}

static void
dino_connection_manager_value_connection_error_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dino_connection_manager_value_connection_error_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dino_connection_manager_connection_error_unref (value->data[0].v_pointer);
	}
}

static void
dino_connection_manager_value_connection_error_copy_value (const GValue* src_value,
                                                           GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dino_connection_manager_connection_error_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dino_connection_manager_value_connection_error_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dino_connection_manager_value_connection_error_collect_value (GValue* value,
                                                              guint n_collect_values,
                                                              GTypeCValue* collect_values,
                                                              guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DinoConnectionManagerConnectionError * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dino_connection_manager_connection_error_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dino_connection_manager_value_connection_error_lcopy_value (const GValue* value,
                                                            guint n_collect_values,
                                                            GTypeCValue* collect_values,
                                                            guint collect_flags)
{
	DinoConnectionManagerConnectionError ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dino_connection_manager_connection_error_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
dino_connection_manager_param_spec_connection_error (const gchar* name,
                                                     const gchar* nick,
                                                     const gchar* blurb,
                                                     GType object_type,
                                                     GParamFlags flags)
{
	DinoConnectionManagerParamSpecConnectionError* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
dino_connection_manager_value_get_connection_error (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR), NULL);
	return value->data[0].v_pointer;
}

void
dino_connection_manager_value_set_connection_error (GValue* value,
                                                    gpointer v_object)
{
	DinoConnectionManagerConnectionError * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dino_connection_manager_connection_error_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_connection_manager_connection_error_unref (old);
	}
}

void
dino_connection_manager_value_take_connection_error (GValue* value,
                                                     gpointer v_object)
{
	DinoConnectionManagerConnectionError * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_connection_manager_connection_error_unref (old);
	}
}

static void
dino_connection_manager_connection_error_class_init (DinoConnectionManagerConnectionErrorClass * klass,
                                                     gpointer klass_data)
{
	dino_connection_manager_connection_error_parent_class = g_type_class_peek_parent (klass);
	((DinoConnectionManagerConnectionErrorClass *) klass)->finalize = dino_connection_manager_connection_error_finalize;
	g_type_class_adjust_private_offset (klass, &DinoConnectionManagerConnectionError_private_offset);
}

static void
dino_connection_manager_connection_error_instance_init (DinoConnectionManagerConnectionError * self,
                                                        gpointer klass)
{
	self->priv = dino_connection_manager_connection_error_get_instance_private (self);
	self->priv->_reconnect_recomendation = DINO_CONNECTION_MANAGER_CONNECTION_ERROR_RECONNECT_NOW;
	self->ref_count = 1;
}

static void
dino_connection_manager_connection_error_finalize (DinoConnectionManagerConnectionError * obj)
{
	DinoConnectionManagerConnectionError * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR, DinoConnectionManagerConnectionError);
	g_signal_handlers_destroy (self);
	_g_free0 (self->identifier);
}

static GType
dino_connection_manager_connection_error_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dino_connection_manager_value_connection_error_init, dino_connection_manager_value_connection_error_free_value, dino_connection_manager_value_connection_error_copy_value, dino_connection_manager_value_connection_error_peek_pointer, "p", dino_connection_manager_value_connection_error_collect_value, "p", dino_connection_manager_value_connection_error_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DinoConnectionManagerConnectionErrorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_connection_manager_connection_error_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoConnectionManagerConnectionError), 0, (GInstanceInitFunc) dino_connection_manager_connection_error_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dino_connection_manager_connection_error_type_id;
	dino_connection_manager_connection_error_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DinoConnectionManagerConnectionError", &g_define_type_info, &g_define_type_fundamental_info, 0);
	DinoConnectionManagerConnectionError_private_offset = g_type_add_instance_private (dino_connection_manager_connection_error_type_id, sizeof (DinoConnectionManagerConnectionErrorPrivate));
	return dino_connection_manager_connection_error_type_id;
}

GType
dino_connection_manager_connection_error_get_type (void)
{
	static volatile gsize dino_connection_manager_connection_error_type_id__once = 0;
	if (g_once_init_enter (&dino_connection_manager_connection_error_type_id__once)) {
		GType dino_connection_manager_connection_error_type_id;
		dino_connection_manager_connection_error_type_id = dino_connection_manager_connection_error_get_type_once ();
		g_once_init_leave (&dino_connection_manager_connection_error_type_id__once, dino_connection_manager_connection_error_type_id);
	}
	return dino_connection_manager_connection_error_type_id__once;
}

gpointer
dino_connection_manager_connection_error_ref (gpointer instance)
{
	DinoConnectionManagerConnectionError * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
dino_connection_manager_connection_error_unref (gpointer instance)
{
	DinoConnectionManagerConnectionError * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DINO_CONNECTION_MANAGER_CONNECTION_ERROR_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
dino_connection_manager_connection_get_instance_private (DinoConnectionManagerConnection* self)
{
	return G_STRUCT_MEMBER_P (self, DinoConnectionManagerConnection_private_offset);
}

static DinoConnectionManagerConnection*
dino_connection_manager_connection_construct (GType object_type)
{
	DinoConnectionManagerConnection* self = NULL;
	self = (DinoConnectionManagerConnection*) g_type_create_instance (object_type);
	dino_connection_manager_connection_reset (self);
	return self;
}

static DinoConnectionManagerConnection*
dino_connection_manager_connection_new (void)
{
	return dino_connection_manager_connection_construct (DINO_CONNECTION_MANAGER_TYPE_CONNECTION);
}

static void
dino_connection_manager_connection_reset (DinoConnectionManagerConnection* self)
{
	XmppXmppStream* _tmp0_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_stream;
	if (_tmp0_ != NULL) {
		XmppXmppStream* _tmp1_;
		XmppXmppStream* _tmp2_;
		_tmp1_ = self->priv->_stream;
		xmpp_xmpp_stream_detach_modules (_tmp1_);
		_tmp2_ = self->priv->_stream;
		xmpp_xmpp_stream_disconnect (_tmp2_, NULL, NULL);
	}
	dino_connection_manager_connection_set_stream (self, NULL);
	dino_connection_manager_connection_set_last_activity (self, NULL);
	dino_connection_manager_connection_set_established (self, NULL);
	_tmp3_ = xmpp_random_uuid ();
	_tmp4_ = _tmp3_;
	dino_connection_manager_connection_set_uuid (self, _tmp4_);
	_g_free0 (_tmp4_);
}

static void
dino_connection_manager_connection_make_offline (DinoConnectionManagerConnection* self)
{
	XmppPresenceStanza* presence = NULL;
	XmppPresenceStanza* _tmp0_;
	XmppPresenceStanza* _tmp1_;
	XmppXmppStream* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = xmpp_presence_stanza_new (NULL);
	presence = _tmp0_;
	_tmp1_ = presence;
	xmpp_stanza_set_type_ ((XmppStanza*) _tmp1_, XMPP_PRESENCE_STANZA_TYPE_UNAVAILABLE);
	_tmp2_ = self->priv->_stream;
	if (_tmp2_ != NULL) {
		XmppXmppStream* _tmp3_;
		XmppModuleIdentity* _tmp4_;
		gpointer _tmp5_;
		XmppPresenceModule* _tmp6_;
		XmppXmppStream* _tmp7_;
		XmppPresenceStanza* _tmp8_;
		_tmp3_ = self->priv->_stream;
		_tmp4_ = xmpp_presence_module_IDENTITY;
		_tmp5_ = xmpp_xmpp_stream_get_module (_tmp3_, XMPP_PRESENCE_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp4_);
		_tmp6_ = (XmppPresenceModule*) _tmp5_;
		_tmp7_ = self->priv->_stream;
		_tmp8_ = presence;
		xmpp_presence_module_send_presence (_tmp6_, _tmp7_, _tmp8_);
		_g_object_unref0 (_tmp6_);
	}
	_g_object_unref0 (presence);
}

static void
dino_connection_manager_connection_disconnect_account_data_free (gpointer _data)
{
	DinoConnectionManagerConnectionDisconnectAccountData* _data_;
	_data_ = _data;
	_dino_connection_manager_connection_unref0 (_data_->self);
	g_slice_free (DinoConnectionManagerConnectionDisconnectAccountData, _data_);
}

static gpointer
_dino_connection_manager_connection_ref0 (gpointer self)
{
	return self ? dino_connection_manager_connection_ref (self) : NULL;
}

static void
dino_connection_manager_connection_disconnect_account (DinoConnectionManagerConnection* self,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	DinoConnectionManagerConnectionDisconnectAccountData* _data_;
	DinoConnectionManagerConnection* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (DinoConnectionManagerConnectionDisconnectAccountData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_connection_manager_connection_disconnect_account_data_free);
	_tmp0_ = _dino_connection_manager_connection_ref0 (self);
	_data_->self = _tmp0_;
	dino_connection_manager_connection_disconnect_account_co (_data_);
}

static void
dino_connection_manager_connection_disconnect_account_finish (DinoConnectionManagerConnection* self,
                                                              GAsyncResult* _res_)
{
	DinoConnectionManagerConnectionDisconnectAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dino_connection_manager_connection_disconnect_account_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	DinoConnectionManagerConnectionDisconnectAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_connection_manager_connection_disconnect_account_co (_data_);
}

static gboolean
dino_connection_manager_connection_disconnect_account_co (DinoConnectionManagerConnectionDisconnectAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	dino_connection_manager_connection_make_offline (_data_->self);
	_data_->_tmp0_ = _data_->self->priv->_stream;
	if (_data_->_tmp0_ != NULL) {
		{
			_data_->_tmp1_ = _data_->self->priv->_stream;
			_data_->_state_ = 1;
			xmpp_xmpp_stream_disconnect (_data_->_tmp1_, dino_connection_manager_connection_disconnect_account_ready, _data_);
			return FALSE;
			_state_1:
			xmpp_xmpp_stream_disconnect_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			_data_->e = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp2_ = _data_->e;
			_data_->_tmp3_ = _data_->_tmp2_->message;
			g_debug ("connection_manager.vala:94: Error disconnecting stream: %s", _data_->_tmp3_);
			_g_error_free0 (_data_->e);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			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_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 const gchar*
dino_connection_manager_connection_get_uuid (DinoConnectionManagerConnection* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_uuid;
	result = _tmp0_;
	return result;
}

static void
dino_connection_manager_connection_set_uuid (DinoConnectionManagerConnection* self,
                                             const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_uuid);
	self->priv->_uuid = _tmp0_;
}

static XmppXmppStream*
dino_connection_manager_connection_get_stream (DinoConnectionManagerConnection* self)
{
	XmppXmppStream* result;
	XmppXmppStream* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_stream;
	result = _tmp0_;
	return result;
}

static void
dino_connection_manager_connection_set_stream (DinoConnectionManagerConnection* self,
                                               XmppXmppStream* value)
{
	XmppXmppStream* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_stream);
	self->priv->_stream = _tmp0_;
}

static DinoConnectionManagerConnectionState
dino_connection_manager_connection_get_connection_state (DinoConnectionManagerConnection* self)
{
	DinoConnectionManagerConnectionState result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_connection_state;
	return result;
}

static void
dino_connection_manager_connection_set_connection_state (DinoConnectionManagerConnection* self,
                                                         DinoConnectionManagerConnectionState value)
{
	g_return_if_fail (self != NULL);
	self->priv->_connection_state = value;
}

static GDateTime*
dino_connection_manager_connection_get_established (DinoConnectionManagerConnection* self)
{
	GDateTime* result;
	GDateTime* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_established;
	result = _tmp0_;
	return result;
}

static void
dino_connection_manager_connection_set_established (DinoConnectionManagerConnection* self,
                                                    GDateTime* value)
{
	GDateTime* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_date_time_ref0 (value);
	_g_date_time_unref0 (self->priv->_established);
	self->priv->_established = _tmp0_;
}

static GDateTime*
dino_connection_manager_connection_get_last_activity (DinoConnectionManagerConnection* self)
{
	GDateTime* result;
	GDateTime* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_last_activity;
	result = _tmp0_;
	return result;
}

static void
dino_connection_manager_connection_set_last_activity (DinoConnectionManagerConnection* self,
                                                      GDateTime* value)
{
	GDateTime* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_date_time_ref0 (value);
	_g_date_time_unref0 (self->priv->_last_activity);
	self->priv->_last_activity = _tmp0_;
}

static void
dino_connection_manager_value_connection_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dino_connection_manager_value_connection_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dino_connection_manager_connection_unref (value->data[0].v_pointer);
	}
}

static void
dino_connection_manager_value_connection_copy_value (const GValue* src_value,
                                                     GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dino_connection_manager_connection_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dino_connection_manager_value_connection_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dino_connection_manager_value_connection_collect_value (GValue* value,
                                                        guint n_collect_values,
                                                        GTypeCValue* collect_values,
                                                        guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DinoConnectionManagerConnection * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dino_connection_manager_connection_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dino_connection_manager_value_connection_lcopy_value (const GValue* value,
                                                      guint n_collect_values,
                                                      GTypeCValue* collect_values,
                                                      guint collect_flags)
{
	DinoConnectionManagerConnection ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dino_connection_manager_connection_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
dino_connection_manager_param_spec_connection (const gchar* name,
                                               const gchar* nick,
                                               const gchar* blurb,
                                               GType object_type,
                                               GParamFlags flags)
{
	DinoConnectionManagerParamSpecConnection* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DINO_CONNECTION_MANAGER_TYPE_CONNECTION), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
dino_connection_manager_value_get_connection (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_CONNECTION_MANAGER_TYPE_CONNECTION), NULL);
	return value->data[0].v_pointer;
}

static void
dino_connection_manager_value_set_connection (GValue* value,
                                              gpointer v_object)
{
	DinoConnectionManagerConnection * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_CONNECTION_MANAGER_TYPE_CONNECTION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_CONNECTION_MANAGER_TYPE_CONNECTION));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dino_connection_manager_connection_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_connection_manager_connection_unref (old);
	}
}

static void
dino_connection_manager_value_take_connection (GValue* value,
                                               gpointer v_object)
{
	DinoConnectionManagerConnection * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_CONNECTION_MANAGER_TYPE_CONNECTION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_CONNECTION_MANAGER_TYPE_CONNECTION));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_connection_manager_connection_unref (old);
	}
}

static void
dino_connection_manager_connection_class_init (DinoConnectionManagerConnectionClass * klass,
                                               gpointer klass_data)
{
	dino_connection_manager_connection_parent_class = g_type_class_peek_parent (klass);
	((DinoConnectionManagerConnectionClass *) klass)->finalize = dino_connection_manager_connection_finalize;
	g_type_class_adjust_private_offset (klass, &DinoConnectionManagerConnection_private_offset);
}

static void
dino_connection_manager_connection_instance_init (DinoConnectionManagerConnection * self,
                                                  gpointer klass)
{
	self->priv = dino_connection_manager_connection_get_instance_private (self);
	self->priv->_connection_state = DINO_CONNECTION_MANAGER_CONNECTION_STATE_DISCONNECTED;
	self->ref_count = 1;
}

static void
dino_connection_manager_connection_finalize (DinoConnectionManagerConnection * obj)
{
	DinoConnectionManagerConnection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_CONNECTION_MANAGER_TYPE_CONNECTION, DinoConnectionManagerConnection);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->_uuid);
	_g_object_unref0 (self->priv->_stream);
	_g_date_time_unref0 (self->priv->_established);
	_g_date_time_unref0 (self->priv->_last_activity);
}

static GType
dino_connection_manager_connection_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dino_connection_manager_value_connection_init, dino_connection_manager_value_connection_free_value, dino_connection_manager_value_connection_copy_value, dino_connection_manager_value_connection_peek_pointer, "p", dino_connection_manager_value_connection_collect_value, "p", dino_connection_manager_value_connection_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DinoConnectionManagerConnectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_connection_manager_connection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoConnectionManagerConnection), 0, (GInstanceInitFunc) dino_connection_manager_connection_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dino_connection_manager_connection_type_id;
	dino_connection_manager_connection_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DinoConnectionManagerConnection", &g_define_type_info, &g_define_type_fundamental_info, 0);
	DinoConnectionManagerConnection_private_offset = g_type_add_instance_private (dino_connection_manager_connection_type_id, sizeof (DinoConnectionManagerConnectionPrivate));
	return dino_connection_manager_connection_type_id;
}

static GType
dino_connection_manager_connection_get_type (void)
{
	static volatile gsize dino_connection_manager_connection_type_id__once = 0;
	if (g_once_init_enter (&dino_connection_manager_connection_type_id__once)) {
		GType dino_connection_manager_connection_type_id;
		dino_connection_manager_connection_type_id = dino_connection_manager_connection_get_type_once ();
		g_once_init_leave (&dino_connection_manager_connection_type_id__once, dino_connection_manager_connection_type_id);
	}
	return dino_connection_manager_connection_type_id__once;
}

static gpointer
dino_connection_manager_connection_ref (gpointer instance)
{
	DinoConnectionManagerConnection * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
dino_connection_manager_connection_unref (gpointer instance)
{
	DinoConnectionManagerConnection * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DINO_CONNECTION_MANAGER_CONNECTION_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
dino_connection_manager_class_init (DinoConnectionManagerClass * klass,
                                    gpointer klass_data)
{
	dino_connection_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoConnectionManager_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dino_connection_manager_finalize;
	dino_connection_manager_signals[DINO_CONNECTION_MANAGER_STREAM_OPENED_SIGNAL] = g_signal_new ("stream-opened", DINO_TYPE_CONNECTION_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, DINO_ENTITIES_TYPE_ACCOUNT, XMPP_TYPE_XMPP_STREAM);
	dino_connection_manager_signals[DINO_CONNECTION_MANAGER_STREAM_ATTACHED_MODULES_SIGNAL] = g_signal_new ("stream-attached-modules", DINO_TYPE_CONNECTION_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, DINO_ENTITIES_TYPE_ACCOUNT, XMPP_TYPE_XMPP_STREAM);
	dino_connection_manager_signals[DINO_CONNECTION_MANAGER_CONNECTION_STATE_CHANGED_SIGNAL] = g_signal_new ("connection-state-changed", DINO_TYPE_CONNECTION_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_ENUM, G_TYPE_NONE, 2, DINO_ENTITIES_TYPE_ACCOUNT, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_STATE);
	dino_connection_manager_signals[DINO_CONNECTION_MANAGER_CONNECTION_ERROR_SIGNAL] = g_signal_new ("connection-error", DINO_TYPE_CONNECTION_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_DINO_CONNECTION_MANAGER_CONNECTION_ERROR, G_TYPE_NONE, 2, DINO_ENTITIES_TYPE_ACCOUNT, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR);
}

static void
dino_connection_manager_instance_init (DinoConnectionManager * self,
                                       gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	GeeHashMap* _tmp3_;
	self->priv = dino_connection_manager_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (DINO_ENTITIES_TYPE_ACCOUNT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, DINO_CONNECTION_MANAGER_TYPE_CONNECTION, (GBoxedCopyFunc) dino_connection_manager_connection_ref, (GDestroyNotify) dino_connection_manager_connection_unref, _dino_entities_account_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_account_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->connections = _tmp0_;
	_tmp1_ = gee_hash_map_new (DINO_ENTITIES_TYPE_ACCOUNT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, DINO_CONNECTION_MANAGER_TYPE_CONNECTION_ERROR, (GBoxedCopyFunc) dino_connection_manager_connection_error_ref, (GDestroyNotify) dino_connection_manager_connection_error_unref, _dino_entities_account_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_account_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->connection_errors = _tmp1_;
	_tmp2_ = gee_hash_map_new (DINO_ENTITIES_TYPE_ACCOUNT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_BOOLEAN, NULL, NULL, _dino_entities_account_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_account_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->connection_ongoing = _tmp2_;
	_tmp3_ = gee_hash_map_new (DINO_ENTITIES_TYPE_ACCOUNT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_BOOLEAN, NULL, NULL, _dino_entities_account_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_account_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->connection_directly_retry = _tmp3_;
}

static void
dino_connection_manager_finalize (GObject * obj)
{
	DinoConnectionManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_CONNECTION_MANAGER, DinoConnectionManager);
	_g_object_unref0 (self->priv->connections);
	_g_object_unref0 (self->priv->connection_errors);
	_g_object_unref0 (self->priv->connection_ongoing);
	_g_object_unref0 (self->priv->connection_directly_retry);
	_g_object_unref0 (self->priv->network_monitor);
	_g_object_unref0 (self->priv->login1);
	_dino_module_manager_unref0 (self->priv->module_manager);
	_g_free0 (self->log_options);
	G_OBJECT_CLASS (dino_connection_manager_parent_class)->finalize (obj);
}

static GType
dino_connection_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoConnectionManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_connection_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoConnectionManager), 0, (GInstanceInitFunc) dino_connection_manager_instance_init, NULL };
	GType dino_connection_manager_type_id;
	dino_connection_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoConnectionManager", &g_define_type_info, 0);
	DinoConnectionManager_private_offset = g_type_add_instance_private (dino_connection_manager_type_id, sizeof (DinoConnectionManagerPrivate));
	return dino_connection_manager_type_id;
}

GType
dino_connection_manager_get_type (void)
{
	static volatile gsize dino_connection_manager_type_id__once = 0;
	if (g_once_init_enter (&dino_connection_manager_type_id__once)) {
		GType dino_connection_manager_type_id;
		dino_connection_manager_type_id = dino_connection_manager_get_type_once ();
		g_once_init_leave (&dino_connection_manager_type_id__once, dino_connection_manager_type_id);
	}
	return dino_connection_manager_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

