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

#include "libdino.h"
#include <gee.h>
#include <glib-object.h>
#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.h>
#include "qlite.h"

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

enum  {
	DINO_ENTITY_INFO_0_PROPERTY,
	DINO_ENTITY_INFO_ID_PROPERTY,
	DINO_ENTITY_INFO_NUM_PROPERTIES
};
static GParamSpec* dino_entity_info_properties[DINO_ENTITY_INFO_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _qlite_database_unref0(var) ((var == NULL) ? NULL : (var = (qlite_database_unref (var), NULL)))
typedef struct _Block13Data Block13Data;
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _xmpp_xep_service_discovery_info_result_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_service_discovery_info_result_unref (var), NULL)))
typedef struct _DinoEntityInfoGetIdentitiesData DinoEntityInfoGetIdentitiesData;
#define _xmpp_xep_service_discovery_identity_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_service_discovery_identity_unref (var), NULL)))
typedef struct _DinoEntityInfoGetIdentityData DinoEntityInfoGetIdentityData;
typedef struct _DinoEntityInfoHasFeatureData DinoEntityInfoHasFeatureData;
#define _qlite_statement_builder_unref0(var) ((var == NULL) ? NULL : (var = (qlite_statement_builder_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _qlite_row_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_unref (var), NULL)))
#define _qlite_row_iterator_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_iterator_unref (var), NULL)))
typedef struct _DinoEntityInfoGetInfoResultData DinoEntityInfoGetInfoResultData;
typedef struct _Block14Data Block14Data;
enum  {
	DINO_CAPS_CACHE_IMPL_0_PROPERTY,
	DINO_CAPS_CACHE_IMPL_NUM_PROPERTIES
};
static GParamSpec* dino_caps_cache_impl_properties[DINO_CAPS_CACHE_IMPL_NUM_PROPERTIES];
typedef struct _DinoCapsCacheImplHasEntityFeatureData DinoCapsCacheImplHasEntityFeatureData;
typedef struct _DinoCapsCacheImplGetEntityIdentitiesData DinoCapsCacheImplGetEntityIdentitiesData;

struct _DinoEntityInfoPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoDatabase* db;
	DinoEntityCapabilitiesStorage* entity_capabilities_storage;
	GeeHashMap* entity_caps_hashes;
	GeeHashMap* entity_features;
	GeeHashMap* jid_features;
	GeeHashMap* entity_identity;
	GeeHashMap* jid_identity;
};

struct _Block13Data {
	int _ref_count_;
	DinoEntityInfo* self;
	DinoEntitiesAccount* account;
	XmppXmppStream* stream;
};

struct _DinoEntityInfoGetIdentitiesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoEntityInfo* self;
	DinoEntitiesAccount* account;
	XmppJid* jid;
	GeeSet* result;
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	gpointer _tmp2_;
	gchar* hash;
	GeeHashMap* _tmp3_;
	gpointer _tmp4_;
	const gchar* _tmp5_;
	GeeSet* identities;
	const gchar* _tmp6_;
	GeeSet* _tmp7_;
	GeeSet* _tmp8_;
	XmppXepServiceDiscoveryInfoResult* info_result;
	const gchar* _tmp9_;
	XmppXepServiceDiscoveryInfoResult* _tmp10_;
	XmppXepServiceDiscoveryInfoResult* _tmp11_;
	XmppXepServiceDiscoveryInfoResult* _tmp12_;
	GeeSet* _tmp13_;
	GeeSet* _tmp14_;
};

struct _DinoEntityInfoGetIdentityData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoEntityInfo* self;
	DinoEntitiesAccount* account;
	XmppJid* jid;
	XmppXepServiceDiscoveryIdentity* result;
	GeeSet* identities;
	GeeSet* _tmp0_;
	GeeSet* _tmp1_;
	GeeIterator* _identity_it;
	GeeSet* _tmp2_;
	GeeIterator* _tmp3_;
	GeeIterator* _tmp4_;
	XmppXepServiceDiscoveryIdentity* identity;
	GeeIterator* _tmp5_;
	gpointer _tmp6_;
	XmppXepServiceDiscoveryIdentity* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
};

struct _DinoEntityInfoHasFeatureData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoEntityInfo* self;
	DinoEntitiesAccount* account;
	XmppJid* jid;
	gchar* feature;
	gboolean result;
	gint has_feature_cached;
	XmppXepServiceDiscoveryInfoResult* info_result;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	gchar* _tmp2_;
	XmppXepServiceDiscoveryInfoResult* _tmp3_;
	XmppXepServiceDiscoveryInfoResult* _tmp4_;
	XmppXepServiceDiscoveryInfoResult* _tmp5_;
	XmppXepServiceDiscoveryInfoResult* _tmp6_;
	GeeList* _tmp7_;
	GeeList* _tmp8_;
	GeeList* _tmp9_;
	gboolean _tmp10_;
};

struct _DinoEntityInfoGetInfoResultData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoEntityInfo* self;
	DinoEntitiesAccount* account;
	XmppJid* jid;
	gchar* hash;
	XmppXepServiceDiscoveryInfoResult* result;
	XmppXmppStream* stream;
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppXmppStream* _tmp2_;
	XmppXepServiceDiscoveryInfoResult* info_result;
	XmppXmppStream* _tmp3_;
	XmppModuleIdentity* _tmp4_;
	gpointer _tmp5_;
	XmppXepServiceDiscoveryModule* _tmp6_;
	XmppXmppStream* _tmp7_;
	XmppXepServiceDiscoveryInfoResult* _tmp8_;
	XmppXepServiceDiscoveryInfoResult* _tmp9_;
	XmppXepServiceDiscoveryInfoResult* _tmp10_;
	gchar* computed_hash;
	XmppXepServiceDiscoveryInfoResult* _tmp11_;
	gchar* _tmp12_;
	gboolean _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	DinoDatabase* _tmp17_;
	DinoDatabaseEntityTable* _tmp18_;
	DinoDatabaseEntityTable* _tmp19_;
	QliteUpsertBuilder* _tmp20_;
	QliteUpsertBuilder* _tmp21_;
	DinoDatabase* _tmp22_;
	DinoDatabaseEntityTable* _tmp23_;
	DinoDatabaseEntityTable* _tmp24_;
	QliteColumn* _tmp25_;
	gint _tmp26_;
	gint _tmp27_;
	QliteUpsertBuilder* _tmp28_;
	QliteUpsertBuilder* _tmp29_;
	DinoDatabase* _tmp30_;
	DinoDatabaseEntityTable* _tmp31_;
	DinoDatabaseEntityTable* _tmp32_;
	QliteColumn* _tmp33_;
	DinoDatabase* _tmp34_;
	QliteUpsertBuilder* _tmp35_;
	QliteUpsertBuilder* _tmp36_;
	DinoDatabase* _tmp37_;
	DinoDatabaseEntityTable* _tmp38_;
	DinoDatabaseEntityTable* _tmp39_;
	QliteColumn* _tmp40_;
	QliteUpsertBuilder* _tmp41_;
	QliteUpsertBuilder* _tmp42_;
	DinoDatabase* _tmp43_;
	DinoDatabaseEntityTable* _tmp44_;
	DinoDatabaseEntityTable* _tmp45_;
	QliteColumn* _tmp46_;
	GDateTime* _tmp47_;
	GDateTime* _tmp48_;
	QliteUpsertBuilder* _tmp49_;
	QliteUpsertBuilder* _tmp50_;
	DinoDatabase* _tmp51_;
	DinoDatabaseEntityTable* _tmp52_;
	DinoDatabaseEntityTable* _tmp53_;
	QliteColumn* _tmp54_;
	const gchar* _tmp55_;
	QliteUpsertBuilder* _tmp56_;
	QliteUpsertBuilder* _tmp57_;
	const gchar* _tmp58_;
	XmppXepServiceDiscoveryInfoResult* _tmp59_;
	GeeList* _tmp60_;
	GeeList* _tmp61_;
	GeeList* _tmp62_;
	const gchar* _tmp63_;
	XmppXepServiceDiscoveryInfoResult* _tmp64_;
	GeeSet* _tmp65_;
	GeeSet* _tmp66_;
	GeeSet* _tmp67_;
	gchar* _tmp68_;
	gchar* _tmp69_;
	GeeHashMap* _tmp70_;
	XmppXepServiceDiscoveryInfoResult* _tmp71_;
	GeeList* _tmp72_;
	GeeList* _tmp73_;
	GeeList* _tmp74_;
	GeeHashMap* _tmp75_;
	XmppXepServiceDiscoveryInfoResult* _tmp76_;
	GeeSet* _tmp77_;
	GeeSet* _tmp78_;
	GeeSet* _tmp79_;
};

struct _Block14Data {
	int _ref_count_;
	DinoEntityInfo* self;
	DinoEntitiesAccount* account;
};

struct _DinoCapsCacheImplPrivate {
	DinoEntitiesAccount* account;
	DinoEntityInfo* entity_info;
};

struct _DinoCapsCacheImplHasEntityFeatureData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoCapsCacheImpl* self;
	XmppJid* jid;
	gchar* feature;
	gboolean result;
	DinoEntityInfo* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
};

struct _DinoCapsCacheImplGetEntityIdentitiesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoCapsCacheImpl* self;
	XmppJid* jid;
	GeeSet* result;
	DinoEntityInfo* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	GeeSet* _tmp2_;
};

static gint DinoEntityInfo_private_offset;
static gpointer dino_entity_info_parent_class = NULL;
DinoModuleIdentity* dino_entity_info_IDENTITY = NULL;
static DinoStreamInteractionModuleIface * dino_entity_info_dino_stream_interaction_module_parent_iface = NULL;
static gint DinoCapsCacheImpl_private_offset;
static gpointer dino_caps_cache_impl_parent_class = NULL;
static XmppXepServiceDiscoveryCapsCacheIface * dino_caps_cache_impl_xmpp_xep_service_discovery_caps_cache_parent_iface = NULL;

static guint _xmpp_jid_hash_func_gee_hash_data_func (gconstpointer v,
                                              gpointer self);
static gboolean _xmpp_jid_equals_func_gee_equal_data_func (gconstpointer a,
                                                    gconstpointer b,
                                                    gpointer self);
static DinoEntityInfo* dino_entity_info_new (DinoStreamInteractor* stream_interactor,
                                      DinoDatabase* db);
static DinoEntityInfo* dino_entity_info_construct (GType object_type,
                                            DinoStreamInteractor* stream_interactor,
                                            DinoDatabase* db);
static void dino_entity_info_on_account_added (DinoEntityInfo* self,
                                        DinoEntitiesAccount* account);
static void _dino_entity_info_on_account_added_dino_stream_interactor_account_added (DinoStreamInteractor* _sender,
                                                                              DinoEntitiesAccount* account,
                                                                              gpointer self);
static void __lambda88_ (DinoEntityInfo* self,
                  DinoEntitiesAccount* account,
                  XmppXmppStream* stream);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
static void __lambda89_ (Block13Data* _data13_);
static void ___lambda89__xmpp_xmpp_stream_received_features_node (XmppXmppStream* _sender,
                                                           XmppXmppStream* stream,
                                                           gpointer self);
static void ___lambda88__dino_connection_manager_stream_opened (DinoConnectionManager* _sender,
                                                         DinoEntitiesAccount* account,
                                                         XmppXmppStream* stream,
                                                         gpointer self);
static void dino_entity_info_initialize_modules (DinoEntityInfo* self,
                                          DinoEntitiesAccount* account,
                                          GeeArrayList* modules);
static void _dino_entity_info_initialize_modules_dino_module_manager_initialize_account_modules (DinoModuleManager* _sender,
                                                                                          DinoEntitiesAccount* account,
                                                                                          GeeArrayList* modules,
                                                                                          gpointer self);
static void dino_entity_info_remove_old_entities (DinoEntityInfo* self);
static gboolean __lambda90_ (DinoEntityInfo* self);
static gboolean ___lambda90__gsource_func (gpointer self);
static void dino_entity_info_get_identities_data_free (gpointer _data);
static gboolean dino_entity_info_get_identities_co (DinoEntityInfoGetIdentitiesData* _data_);
static GeeSet* dino_entity_info_get_stored_identities (DinoEntityInfo* self,
                                                const gchar* entity);
static void dino_entity_info_get_info_result (DinoEntityInfo* self,
                                       DinoEntitiesAccount* account,
                                       XmppJid* jid,
                                       const gchar* hash,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
static XmppXepServiceDiscoveryInfoResult* dino_entity_info_get_info_result_finish (DinoEntityInfo* self,
                                                                            GAsyncResult* _res_);
static void dino_entity_info_get_identities_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_);
static void dino_entity_info_get_identity_data_free (gpointer _data);
static gboolean dino_entity_info_get_identity_co (DinoEntityInfoGetIdentityData* _data_);
static void dino_entity_info_get_identity_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void dino_entity_info_has_feature_data_free (gpointer _data);
static gboolean dino_entity_info_has_feature_co (DinoEntityInfoHasFeatureData* _data_);
static gint dino_entity_info_has_feature_cached_int (DinoEntityInfo* self,
                                              DinoEntitiesAccount* account,
                                              XmppJid* jid,
                                              const gchar* feature);
static void dino_entity_info_has_feature_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_);
static GeeList* dino_entity_info_get_stored_features (DinoEntityInfo* self,
                                               const gchar* entity);
static void dino_entity_info_on_received_available_presence (DinoEntityInfo* self,
                                                      DinoEntitiesAccount* account,
                                                      XmppPresenceStanza* presence);
static void dino_entity_info_store_features (DinoEntityInfo* self,
                                      const gchar* entity,
                                      GeeList* features);
static void dino_entity_info_store_identities (DinoEntityInfo* self,
                                        const gchar* entity,
                                        GeeSet* identities);
static guint _xmpp_xep_service_discovery_identity_hash_func_gee_hash_data_func (gconstpointer v,
                                                                         gpointer self);
static gboolean _xmpp_xep_service_discovery_identity_equals_func_gee_equal_data_func (gconstpointer a,
                                                                               gconstpointer b,
                                                                               gpointer self);
static void dino_entity_info_get_info_result_data_free (gpointer _data);
static gboolean dino_entity_info_get_info_result_co (DinoEntityInfoGetInfoResultData* _data_);
static void dino_entity_info_get_info_result_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_);
static Block14Data* block14_data_ref (Block14Data* _data14_);
static void block14_data_unref (void * _userdata_);
static void __lambda31_ (Block14Data* _data14_,
                  XmppXmppStream* stream,
                  XmppPresenceStanza* presence);
static void ___lambda31__xmpp_presence_module_received_available (XmppPresenceModule* _sender,
                                                           XmppXmppStream* stream,
                                                           XmppPresenceStanza* presence,
                                                           gpointer self);
static void dino_entity_info_finalize (GObject * obj);
static GType dino_entity_info_get_type_once (void);
static void _vala_dino_entity_info_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void dino_caps_cache_impl_real_has_entity_feature_data_free (gpointer _data);
static void dino_caps_cache_impl_real_has_entity_feature (XmppXepServiceDiscoveryCapsCache* base,
                                                   XmppJid* jid,
                                                   const gchar* feature,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static gboolean dino_caps_cache_impl_real_has_entity_feature_co (DinoCapsCacheImplHasEntityFeatureData* _data_);
static void dino_caps_cache_impl_has_entity_feature_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_);
static void dino_caps_cache_impl_real_get_entity_identities_data_free (gpointer _data);
static void dino_caps_cache_impl_real_get_entity_identities (XmppXepServiceDiscoveryCapsCache* base,
                                                      XmppJid* jid,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_);
static gboolean dino_caps_cache_impl_real_get_entity_identities_co (DinoCapsCacheImplGetEntityIdentitiesData* _data_);
static void dino_caps_cache_impl_get_entity_identities_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_);
static void dino_caps_cache_impl_finalize (GObject * obj);
static GType dino_caps_cache_impl_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_entity_info_get_instance_private (DinoEntityInfo* self)
{
	return G_STRUCT_MEMBER_P (self, DinoEntityInfo_private_offset);
}

static guint
_xmpp_jid_hash_func_gee_hash_data_func (gconstpointer v,
                                        gpointer self)
{
	guint result;
	result = xmpp_jid_hash_func ((XmppJid*) v);
	return result;
}

static gboolean
_xmpp_jid_equals_func_gee_equal_data_func (gconstpointer a,
                                           gconstpointer b,
                                           gpointer self)
{
	gboolean result;
	result = xmpp_jid_equals_func ((XmppJid*) a, (XmppJid*) b);
	return result;
}

void
dino_entity_info_start (DinoStreamInteractor* stream_interactor,
                        DinoDatabase* db)
{
	DinoEntityInfo* m = NULL;
	DinoEntityInfo* _tmp0_;
	g_return_if_fail (stream_interactor != NULL);
	g_return_if_fail (db != NULL);
	_tmp0_ = dino_entity_info_new (stream_interactor, db);
	m = _tmp0_;
	dino_stream_interactor_add_module (stream_interactor, (DinoStreamInteractionModule*) m);
	_g_object_unref0 (m);
}

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

static gpointer
_qlite_database_ref0 (gpointer self)
{
	return self ? qlite_database_ref (self) : NULL;
}

static void
_dino_entity_info_on_account_added_dino_stream_interactor_account_added (DinoStreamInteractor* _sender,
                                                                         DinoEntitiesAccount* account,
                                                                         gpointer self)
{
	dino_entity_info_on_account_added ((DinoEntityInfo*) self, account);
}

static Block13Data*
block13_data_ref (Block13Data* _data13_)
{
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}

static void
block13_data_unref (void * _userdata_)
{
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		DinoEntityInfo* self;
		self = _data13_->self;
		_g_object_unref0 (_data13_->account);
		_g_object_unref0 (_data13_->stream);
		_g_object_unref0 (self);
		g_slice_free (Block13Data, _data13_);
	}
}

static void
__lambda89_ (Block13Data* _data13_)
{
	DinoEntityInfo* self;
	gchar* hash = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	self = _data13_->self;
	_tmp0_ = xmpp_xep_entity_capabilities_get_server_caps_hash (_data13_->stream);
	hash = _tmp0_;
	_tmp1_ = hash;
	if (_tmp1_ != NULL) {
		GeeHashMap* _tmp2_;
		XmppJid* _tmp3_;
		XmppJid* _tmp4_;
		XmppJid* _tmp5_;
		XmppJid* _tmp6_;
		XmppJid* _tmp7_;
		XmppJid* _tmp8_;
		const gchar* _tmp9_;
		_tmp2_ = self->priv->entity_caps_hashes;
		_tmp3_ = dino_entities_account_get_bare_jid (_data13_->account);
		_tmp4_ = _tmp3_;
		_tmp5_ = _tmp4_;
		_tmp6_ = xmpp_jid_get_domain_jid (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = _tmp7_;
		_tmp9_ = hash;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp2_, _tmp8_, _tmp9_);
		_xmpp_jid_unref0 (_tmp8_);
		_xmpp_jid_unref0 (_tmp5_);
	}
	_g_free0 (hash);
}

static void
___lambda89__xmpp_xmpp_stream_received_features_node (XmppXmppStream* _sender,
                                                      XmppXmppStream* stream,
                                                      gpointer self)
{
	__lambda89_ (self);
}

static void
__lambda88_ (DinoEntityInfo* self,
             DinoEntitiesAccount* account,
             XmppXmppStream* stream)
{
	Block13Data* _data13_;
	DinoEntitiesAccount* _tmp0_;
	XmppXmppStream* _tmp1_;
	g_return_if_fail (account != NULL);
	g_return_if_fail (stream != NULL);
	_data13_ = g_slice_new0 (Block13Data);
	_data13_->_ref_count_ = 1;
	_data13_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (_data13_->account);
	_data13_->account = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data13_->stream);
	_data13_->stream = _tmp1_;
	g_signal_connect_data (_data13_->stream, "received-features-node", (GCallback) ___lambda89__xmpp_xmpp_stream_received_features_node, block13_data_ref (_data13_), (GClosureNotify) block13_data_unref, 0);
	block13_data_unref (_data13_);
	_data13_ = NULL;
}

static void
___lambda88__dino_connection_manager_stream_opened (DinoConnectionManager* _sender,
                                                    DinoEntitiesAccount* account,
                                                    XmppXmppStream* stream,
                                                    gpointer self)
{
	__lambda88_ ((DinoEntityInfo*) self, account, stream);
}

static void
_dino_entity_info_initialize_modules_dino_module_manager_initialize_account_modules (DinoModuleManager* _sender,
                                                                                     DinoEntitiesAccount* account,
                                                                                     GeeArrayList* modules,
                                                                                     gpointer self)
{
	dino_entity_info_initialize_modules ((DinoEntityInfo*) self, account, modules);
}

static gboolean
__lambda90_ (DinoEntityInfo* self)
{
	gboolean result;
	dino_entity_info_remove_old_entities (self);
	result = TRUE;
	return result;
}

static gboolean
___lambda90__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda90_ ((DinoEntityInfo*) self);
	return result;
}

static DinoEntityInfo*
dino_entity_info_construct (GType object_type,
                            DinoStreamInteractor* stream_interactor,
                            DinoDatabase* db)
{
	DinoEntityInfo * self = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoDatabase* _tmp1_;
	DinoEntityCapabilitiesStorage* _tmp2_;
	DinoConnectionManager* _tmp3_;
	DinoModuleManager* _tmp4_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoEntityInfo*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = _qlite_database_ref0 (db);
	_qlite_database_unref0 (self->priv->db);
	self->priv->db = _tmp1_;
	_tmp2_ = dino_entity_capabilities_storage_new (db);
	_g_object_unref0 (self->priv->entity_capabilities_storage);
	self->priv->entity_capabilities_storage = _tmp2_;
	g_signal_connect_object (stream_interactor, "account-added", (GCallback) _dino_entity_info_on_account_added_dino_stream_interactor_account_added, self, 0);
	_tmp3_ = stream_interactor->connection_manager;
	g_signal_connect_object (_tmp3_, "stream-opened", (GCallback) ___lambda88__dino_connection_manager_stream_opened, self, 0);
	_tmp4_ = stream_interactor->module_manager;
	g_signal_connect_object (_tmp4_, "initialize-account-modules", (GCallback) _dino_entity_info_initialize_modules_dino_module_manager_initialize_account_modules, self, 0);
	dino_entity_info_remove_old_entities (self);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) (60 * 60), ___lambda90__gsource_func, g_object_ref (self), g_object_unref);
	return self;
}

static DinoEntityInfo*
dino_entity_info_new (DinoStreamInteractor* stream_interactor,
                      DinoDatabase* db)
{
	return dino_entity_info_construct (DINO_TYPE_ENTITY_INFO, stream_interactor, db);
}

static void
dino_entity_info_get_identities_data_free (gpointer _data)
{
	DinoEntityInfoGetIdentitiesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_xmpp_jid_unref0 (_data_->jid);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoEntityInfoGetIdentitiesData, _data_);
}

static gpointer
_xmpp_jid_ref0 (gpointer self)
{
	return self ? xmpp_jid_ref (self) : NULL;
}

void
dino_entity_info_get_identities (DinoEntityInfo* self,
                                 DinoEntitiesAccount* account,
                                 XmppJid* jid,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	DinoEntityInfoGetIdentitiesData* _data_;
	DinoEntityInfo* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	XmppJid* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	_data_ = g_slice_new0 (DinoEntityInfoGetIdentitiesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_entity_info_get_identities_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	dino_entity_info_get_identities_co (_data_);
}

GeeSet*
dino_entity_info_get_identities_finish (DinoEntityInfo* self,
                                        GAsyncResult* _res_)
{
	GeeSet* result;
	DinoEntityInfoGetIdentitiesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dino_entity_info_get_identities_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_)
{
	DinoEntityInfoGetIdentitiesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_entity_info_get_identities_co (_data_);
}

static gboolean
dino_entity_info_get_identities_co (DinoEntityInfoGetIdentitiesData* _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->jid_identity;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _data_->_tmp0_, _data_->jid)) {
		_data_->_tmp1_ = _data_->self->priv->jid_identity;
		_data_->_tmp2_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp1_, _data_->jid);
		_data_->result = (GeeSet*) _data_->_tmp2_;
		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_->_tmp3_ = _data_->self->priv->entity_caps_hashes;
	_data_->_tmp4_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp3_, _data_->jid);
	_data_->hash = (gchar*) _data_->_tmp4_;
	_data_->_tmp5_ = _data_->hash;
	if (_data_->_tmp5_ != NULL) {
		_data_->_tmp6_ = _data_->hash;
		_data_->_tmp7_ = dino_entity_info_get_stored_identities (_data_->self, _data_->_tmp6_);
		_data_->identities = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->identities;
		if (_data_->_tmp8_ != NULL) {
			_data_->result = _data_->identities;
			_g_free0 (_data_->hash);
			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;
		}
		_g_object_unref0 (_data_->identities);
	}
	_data_->_tmp9_ = _data_->hash;
	_data_->_state_ = 1;
	dino_entity_info_get_info_result (_data_->self, _data_->account, _data_->jid, _data_->_tmp9_, dino_entity_info_get_identities_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp10_ = dino_entity_info_get_info_result_finish (_data_->self, _data_->_res_);
	_data_->info_result = _data_->_tmp10_;
	_data_->_tmp11_ = _data_->info_result;
	if (_data_->_tmp11_ != NULL) {
		_data_->_tmp12_ = _data_->info_result;
		_data_->_tmp13_ = xmpp_xep_service_discovery_info_result_get_identities (_data_->_tmp12_);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->result = _data_->_tmp14_;
		_xmpp_xep_service_discovery_info_result_unref0 (_data_->info_result);
		_g_free0 (_data_->hash);
		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_->result = NULL;
	_xmpp_xep_service_discovery_info_result_unref0 (_data_->info_result);
	_g_free0 (_data_->hash);
	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_entity_info_get_identity_data_free (gpointer _data)
{
	DinoEntityInfoGetIdentityData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_xmpp_jid_unref0 (_data_->jid);
	_xmpp_xep_service_discovery_identity_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoEntityInfoGetIdentityData, _data_);
}

void
dino_entity_info_get_identity (DinoEntityInfo* self,
                               DinoEntitiesAccount* account,
                               XmppJid* jid,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	DinoEntityInfoGetIdentityData* _data_;
	DinoEntityInfo* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	XmppJid* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	_data_ = g_slice_new0 (DinoEntityInfoGetIdentityData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_entity_info_get_identity_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	dino_entity_info_get_identity_co (_data_);
}

XmppXepServiceDiscoveryIdentity*
dino_entity_info_get_identity_finish (DinoEntityInfo* self,
                                      GAsyncResult* _res_)
{
	XmppXepServiceDiscoveryIdentity* result;
	DinoEntityInfoGetIdentityData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dino_entity_info_get_identity_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	DinoEntityInfoGetIdentityData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_entity_info_get_identity_co (_data_);
}

static gboolean
dino_entity_info_get_identity_co (DinoEntityInfoGetIdentityData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	dino_entity_info_get_identities (_data_->self, _data_->account, _data_->jid, dino_entity_info_get_identity_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = dino_entity_info_get_identities_finish (_data_->self, _data_->_res_);
	_data_->identities = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->identities;
	if (_data_->_tmp1_ == NULL) {
		_data_->result = NULL;
		_g_object_unref0 (_data_->identities);
		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_->_tmp2_ = _data_->identities;
		_data_->_tmp3_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp2_);
		_data_->_identity_it = _data_->_tmp3_;
		while (TRUE) {
			_data_->_tmp4_ = _data_->_identity_it;
			if (!gee_iterator_next (_data_->_tmp4_)) {
				break;
			}
			_data_->_tmp5_ = _data_->_identity_it;
			_data_->_tmp6_ = gee_iterator_get (_data_->_tmp5_);
			_data_->identity = (XmppXepServiceDiscoveryIdentity*) _data_->_tmp6_;
			_data_->_tmp7_ = _data_->identity;
			_data_->_tmp8_ = xmpp_xep_service_discovery_identity_get_category (_data_->_tmp7_);
			_data_->_tmp9_ = _data_->_tmp8_;
			if (g_strcmp0 (_data_->_tmp9_, XMPP_XEP_SERVICE_DISCOVERY_IDENTITY_CATEGORY_CLIENT) == 0) {
				_data_->result = _data_->identity;
				_g_object_unref0 (_data_->_identity_it);
				_g_object_unref0 (_data_->identities);
				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;
			}
			_xmpp_xep_service_discovery_identity_unref0 (_data_->identity);
		}
		_g_object_unref0 (_data_->_identity_it);
	}
	_data_->result = NULL;
	_g_object_unref0 (_data_->identities);
	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_entity_info_has_feature_data_free (gpointer _data)
{
	DinoEntityInfoHasFeatureData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_xmpp_jid_unref0 (_data_->jid);
	_g_free0 (_data_->feature);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoEntityInfoHasFeatureData, _data_);
}

void
dino_entity_info_has_feature (DinoEntityInfo* self,
                              DinoEntitiesAccount* account,
                              XmppJid* jid,
                              const gchar* feature,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	DinoEntityInfoHasFeatureData* _data_;
	DinoEntityInfo* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	XmppJid* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (feature != NULL);
	_data_ = g_slice_new0 (DinoEntityInfoHasFeatureData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_entity_info_has_feature_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	_tmp3_ = g_strdup (feature);
	_g_free0 (_data_->feature);
	_data_->feature = _tmp3_;
	dino_entity_info_has_feature_co (_data_);
}

gboolean
dino_entity_info_has_feature_finish (DinoEntityInfo* self,
                                     GAsyncResult* _res_)
{
	gboolean result;
	DinoEntityInfoHasFeatureData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
dino_entity_info_has_feature_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_)
{
	DinoEntityInfoHasFeatureData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_entity_info_has_feature_co (_data_);
}

static gboolean
dino_entity_info_has_feature_co (DinoEntityInfoHasFeatureData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->has_feature_cached = dino_entity_info_has_feature_cached_int (_data_->self, _data_->account, _data_->jid, _data_->feature);
	if (_data_->has_feature_cached != -1) {
		_data_->result = _data_->has_feature_cached == 1;
		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_->_tmp0_ = _data_->self->priv->entity_caps_hashes;
	_data_->_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp0_, _data_->jid);
	_data_->_tmp2_ = (gchar*) _data_->_tmp1_;
	_data_->_state_ = 1;
	dino_entity_info_get_info_result (_data_->self, _data_->account, _data_->jid, _data_->_tmp2_, dino_entity_info_has_feature_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp3_ = dino_entity_info_get_info_result_finish (_data_->self, _data_->_res_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_g_free0 (_data_->_tmp2_);
	_data_->info_result = _data_->_tmp4_;
	_data_->_tmp5_ = _data_->info_result;
	if (_data_->_tmp5_ == NULL) {
		_data_->result = FALSE;
		_xmpp_xep_service_discovery_info_result_unref0 (_data_->info_result);
		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_->_tmp6_ = _data_->info_result;
	_data_->_tmp7_ = xmpp_xep_service_discovery_info_result_get_features (_data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = _data_->_tmp8_;
	_data_->_tmp10_ = gee_collection_contains ((GeeCollection*) _data_->_tmp9_, _data_->feature);
	_g_object_unref0 (_data_->_tmp9_);
	_data_->result = _data_->_tmp10_;
	_xmpp_xep_service_discovery_info_result_unref0 (_data_->info_result);
	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;
}

gboolean
dino_entity_info_has_feature_offline (DinoEntityInfo* self,
                                      DinoEntitiesAccount* account,
                                      XmppJid* jid,
                                      const gchar* feature)
{
	gint ret = 0;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (account != NULL, FALSE);
	g_return_val_if_fail (jid != NULL, FALSE);
	g_return_val_if_fail (feature != NULL, FALSE);
	ret = dino_entity_info_has_feature_cached_int (self, account, jid, feature);
	if (ret == -1) {
		const gchar* _tmp0_ = NULL;
		const gchar* _tmp1_;
		DinoDatabase* _tmp2_;
		DinoDatabaseEntityTable* _tmp3_;
		DinoDatabaseEntityTable* _tmp4_;
		QliteQueryBuilder* _tmp5_;
		QliteQueryBuilder* _tmp6_;
		DinoDatabase* _tmp7_;
		DinoDatabaseEntityTable* _tmp8_;
		DinoDatabaseEntityTable* _tmp9_;
		QliteColumn* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		QliteQueryBuilder* _tmp13_;
		QliteQueryBuilder* _tmp14_;
		DinoDatabase* _tmp15_;
		DinoDatabaseEntityTable* _tmp16_;
		DinoDatabaseEntityTable* _tmp17_;
		QliteColumn* _tmp18_;
		DinoDatabase* _tmp19_;
		QliteQueryBuilder* _tmp20_;
		QliteQueryBuilder* _tmp21_;
		DinoDatabase* _tmp22_;
		DinoDatabaseEntityTable* _tmp23_;
		DinoDatabaseEntityTable* _tmp24_;
		QliteColumn* _tmp25_;
		QliteQueryBuilder* _tmp26_;
		QliteQueryBuilder* _tmp27_;
		DinoDatabase* _tmp28_;
		DinoDatabaseEntityFeatureTable* _tmp29_;
		DinoDatabaseEntityFeatureTable* _tmp30_;
		DinoDatabase* _tmp31_;
		DinoDatabaseEntityTable* _tmp32_;
		DinoDatabaseEntityTable* _tmp33_;
		QliteColumn* _tmp34_;
		DinoDatabase* _tmp35_;
		DinoDatabaseEntityFeatureTable* _tmp36_;
		DinoDatabaseEntityFeatureTable* _tmp37_;
		QliteColumn* _tmp38_;
		QliteQueryBuilder* _tmp39_;
		QliteQueryBuilder* _tmp40_;
		DinoDatabase* _tmp41_;
		DinoDatabaseEntityFeatureTable* _tmp42_;
		DinoDatabaseEntityFeatureTable* _tmp43_;
		QliteColumn* _tmp44_;
		QliteQueryBuilder* _tmp45_;
		QliteQueryBuilder* _tmp46_;
		gboolean _tmp47_;
		_tmp1_ = jid->resourcepart;
		_tmp0_ = _tmp1_;
		if (_tmp0_ == NULL) {
			_tmp0_ = "";
		}
		_tmp2_ = self->priv->db;
		_tmp3_ = dino_database_get_entity (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = qlite_table_select ((QliteTable*) _tmp4_, NULL, (gint) 0);
		_tmp6_ = _tmp5_;
		_tmp7_ = self->priv->db;
		_tmp8_ = dino_database_get_entity (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = _tmp9_->account_id;
		_tmp11_ = dino_entities_account_get_id (account);
		_tmp12_ = _tmp11_;
		_tmp13_ = qlite_query_builder_with (_tmp6_, G_TYPE_INT, NULL, NULL, _tmp10_, "=", (gpointer) ((gintptr) _tmp12_));
		_tmp14_ = _tmp13_;
		_tmp15_ = self->priv->db;
		_tmp16_ = dino_database_get_entity (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = _tmp17_->jid_id;
		_tmp19_ = self->priv->db;
		_tmp20_ = qlite_query_builder_with (_tmp14_, G_TYPE_INT, NULL, NULL, _tmp18_, "=", (gpointer) ((gintptr) dino_database_get_jid_id (_tmp19_, jid)));
		_tmp21_ = _tmp20_;
		_tmp22_ = self->priv->db;
		_tmp23_ = dino_database_get_entity (_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = _tmp24_->resource;
		_tmp26_ = qlite_query_builder_with (_tmp21_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp25_, "=", _tmp0_);
		_tmp27_ = _tmp26_;
		_tmp28_ = self->priv->db;
		_tmp29_ = dino_database_get_entity_feature (_tmp28_);
		_tmp30_ = _tmp29_;
		_tmp31_ = self->priv->db;
		_tmp32_ = dino_database_get_entity (_tmp31_);
		_tmp33_ = _tmp32_;
		_tmp34_ = _tmp33_->caps_hash;
		_tmp35_ = self->priv->db;
		_tmp36_ = dino_database_get_entity_feature (_tmp35_);
		_tmp37_ = _tmp36_;
		_tmp38_ = _tmp37_->entity;
		_tmp39_ = qlite_query_builder_join_with (_tmp27_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, (QliteTable*) _tmp30_, _tmp34_, _tmp38_, NULL);
		_tmp40_ = _tmp39_;
		_tmp41_ = self->priv->db;
		_tmp42_ = dino_database_get_entity_feature (_tmp41_);
		_tmp43_ = _tmp42_;
		_tmp44_ = _tmp43_->feature;
		_tmp45_ = qlite_query_builder_with (_tmp40_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp44_, "=", feature);
		_tmp46_ = _tmp45_;
		_tmp47_ = qlite_query_builder_count (_tmp46_) > ((gint64) 0);
		_qlite_statement_builder_unref0 (_tmp46_);
		_qlite_statement_builder_unref0 (_tmp40_);
		_qlite_statement_builder_unref0 (_tmp27_);
		_qlite_statement_builder_unref0 (_tmp21_);
		_qlite_statement_builder_unref0 (_tmp14_);
		_qlite_statement_builder_unref0 (_tmp6_);
		result = _tmp47_;
		return result;
	}
	result = ret == 1;
	return result;
}

gboolean
dino_entity_info_has_feature_cached (DinoEntityInfo* self,
                                     DinoEntitiesAccount* account,
                                     XmppJid* jid,
                                     const gchar* feature)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (account != NULL, FALSE);
	g_return_val_if_fail (jid != NULL, FALSE);
	g_return_val_if_fail (feature != NULL, FALSE);
	result = dino_entity_info_has_feature_cached_int (self, account, jid, feature) == 1;
	return result;
}

static gint
dino_entity_info_has_feature_cached_int (DinoEntityInfo* self,
                                         DinoEntitiesAccount* account,
                                         XmppJid* jid,
                                         const gchar* feature)
{
	GeeHashMap* _tmp0_;
	gchar* hash = NULL;
	GeeHashMap* _tmp6_;
	gpointer _tmp7_;
	const gchar* _tmp8_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (account != NULL, -1);
	g_return_val_if_fail (jid != NULL, -1);
	g_return_val_if_fail (feature != NULL, -1);
	_tmp0_ = self->priv->jid_features;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, jid)) {
		gint _tmp1_ = 0;
		GeeHashMap* _tmp2_;
		gpointer _tmp3_;
		GeeList* _tmp4_;
		gboolean _tmp5_;
		_tmp2_ = self->priv->jid_features;
		_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp2_, jid);
		_tmp4_ = (GeeList*) _tmp3_;
		_tmp5_ = gee_collection_contains ((GeeCollection*) _tmp4_, feature);
		_g_object_unref0 (_tmp4_);
		if (_tmp5_) {
			_tmp1_ = 1;
		} else {
			_tmp1_ = 0;
		}
		result = _tmp1_;
		return result;
	}
	_tmp6_ = self->priv->entity_caps_hashes;
	_tmp7_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp6_, jid);
	hash = (gchar*) _tmp7_;
	_tmp8_ = hash;
	if (_tmp8_ != NULL) {
		GeeList* features = NULL;
		const gchar* _tmp9_;
		GeeList* _tmp10_;
		GeeList* _tmp11_;
		_tmp9_ = hash;
		_tmp10_ = dino_entity_info_get_stored_features (self, _tmp9_);
		features = _tmp10_;
		_tmp11_ = features;
		if (_tmp11_ != NULL) {
			gint _tmp12_ = 0;
			GeeList* _tmp13_;
			_tmp13_ = features;
			if (gee_collection_contains ((GeeCollection*) _tmp13_, feature)) {
				_tmp12_ = 1;
			} else {
				_tmp12_ = 0;
			}
			result = _tmp12_;
			_g_object_unref0 (features);
			_g_free0 (hash);
			return result;
		}
		_g_object_unref0 (features);
	}
	result = -1;
	_g_free0 (hash);
	return result;
}

static void
dino_entity_info_on_received_available_presence (DinoEntityInfo* self,
                                                 DinoEntitiesAccount* account,
                                                 XmppPresenceStanza* presence)
{
	gboolean is_gc = FALSE;
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoMucManager* _tmp3_;
	XmppJid* _tmp4_;
	XmppJid* _tmp5_;
	XmppJid* _tmp6_;
	XmppJid* _tmp7_;
	XmppJid* _tmp8_;
	XmppJid* _tmp9_;
	gboolean _tmp10_;
	gchar* caps_hash = NULL;
	gchar* _tmp11_;
	const gchar* _tmp12_;
	DinoDatabase* _tmp13_;
	DinoDatabaseEntityTable* _tmp14_;
	DinoDatabaseEntityTable* _tmp15_;
	QliteUpsertBuilder* _tmp16_;
	QliteUpsertBuilder* _tmp17_;
	DinoDatabase* _tmp18_;
	DinoDatabaseEntityTable* _tmp19_;
	DinoDatabaseEntityTable* _tmp20_;
	QliteColumn* _tmp21_;
	gint _tmp22_;
	gint _tmp23_;
	QliteUpsertBuilder* _tmp24_;
	QliteUpsertBuilder* _tmp25_;
	DinoDatabase* _tmp26_;
	DinoDatabaseEntityTable* _tmp27_;
	DinoDatabaseEntityTable* _tmp28_;
	QliteColumn* _tmp29_;
	DinoDatabase* _tmp30_;
	XmppJid* _tmp31_;
	XmppJid* _tmp32_;
	XmppJid* _tmp33_;
	QliteUpsertBuilder* _tmp34_;
	QliteUpsertBuilder* _tmp35_;
	DinoDatabase* _tmp36_;
	DinoDatabaseEntityTable* _tmp37_;
	DinoDatabaseEntityTable* _tmp38_;
	QliteColumn* _tmp39_;
	XmppJid* _tmp40_;
	XmppJid* _tmp41_;
	XmppJid* _tmp42_;
	const gchar* _tmp43_;
	QliteUpsertBuilder* _tmp44_;
	QliteUpsertBuilder* _tmp45_;
	DinoDatabase* _tmp46_;
	DinoDatabaseEntityTable* _tmp47_;
	DinoDatabaseEntityTable* _tmp48_;
	QliteColumn* _tmp49_;
	GDateTime* _tmp50_;
	GDateTime* _tmp51_;
	QliteUpsertBuilder* _tmp52_;
	QliteUpsertBuilder* _tmp53_;
	DinoDatabase* _tmp54_;
	DinoDatabaseEntityTable* _tmp55_;
	DinoDatabaseEntityTable* _tmp56_;
	QliteColumn* _tmp57_;
	const gchar* _tmp58_;
	QliteUpsertBuilder* _tmp59_;
	QliteUpsertBuilder* _tmp60_;
	const gchar* _tmp61_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (presence != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_muc_manager_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (_tmp0_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoMucManager*) _tmp2_;
	_tmp4_ = xmpp_stanza_get_from ((XmppStanza*) presence);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp7_ = xmpp_jid_get_bare_jid (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp10_ = dino_muc_manager_might_be_groupchat (_tmp3_, _tmp9_, account);
	_xmpp_jid_unref0 (_tmp9_);
	_xmpp_jid_unref0 (_tmp6_);
	_g_object_unref0 (_tmp3_);
	is_gc = _tmp10_;
	if (is_gc) {
		return;
	}
	_tmp11_ = xmpp_xep_entity_capabilities_get_caps_hash (presence);
	caps_hash = _tmp11_;
	_tmp12_ = caps_hash;
	if (_tmp12_ == NULL) {
		_g_free0 (caps_hash);
		return;
	}
	_tmp13_ = self->priv->db;
	_tmp14_ = dino_database_get_entity (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = qlite_table_upsert ((QliteTable*) _tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = self->priv->db;
	_tmp19_ = dino_database_get_entity (_tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = _tmp20_->account_id;
	_tmp22_ = dino_entities_account_get_id (account);
	_tmp23_ = _tmp22_;
	_tmp24_ = qlite_upsert_builder_value (_tmp17_, G_TYPE_INT, NULL, NULL, _tmp21_, (gpointer) ((gintptr) _tmp23_), TRUE);
	_tmp25_ = _tmp24_;
	_tmp26_ = self->priv->db;
	_tmp27_ = dino_database_get_entity (_tmp26_);
	_tmp28_ = _tmp27_;
	_tmp29_ = _tmp28_->jid_id;
	_tmp30_ = self->priv->db;
	_tmp31_ = xmpp_stanza_get_from ((XmppStanza*) presence);
	_tmp32_ = _tmp31_;
	_tmp33_ = _tmp32_;
	_tmp34_ = qlite_upsert_builder_value (_tmp25_, G_TYPE_INT, NULL, NULL, _tmp29_, (gpointer) ((gintptr) dino_database_get_jid_id (_tmp30_, _tmp33_)), TRUE);
	_tmp35_ = _tmp34_;
	_tmp36_ = self->priv->db;
	_tmp37_ = dino_database_get_entity (_tmp36_);
	_tmp38_ = _tmp37_;
	_tmp39_ = _tmp38_->resource;
	_tmp40_ = xmpp_stanza_get_from ((XmppStanza*) presence);
	_tmp41_ = _tmp40_;
	_tmp42_ = _tmp41_;
	_tmp43_ = _tmp42_->resourcepart;
	_tmp44_ = qlite_upsert_builder_value (_tmp35_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp39_, _tmp43_, TRUE);
	_tmp45_ = _tmp44_;
	_tmp46_ = self->priv->db;
	_tmp47_ = dino_database_get_entity (_tmp46_);
	_tmp48_ = _tmp47_;
	_tmp49_ = _tmp48_->last_seen;
	_tmp50_ = g_date_time_new_now_local ();
	_tmp51_ = _tmp50_;
	_tmp52_ = qlite_upsert_builder_value (_tmp45_, G_TYPE_LONG, NULL, NULL, _tmp49_, (gpointer) ((gintptr) g_date_time_to_unix (_tmp51_)), FALSE);
	_tmp53_ = _tmp52_;
	_tmp54_ = self->priv->db;
	_tmp55_ = dino_database_get_entity (_tmp54_);
	_tmp56_ = _tmp55_;
	_tmp57_ = _tmp56_->caps_hash;
	_tmp58_ = caps_hash;
	_tmp59_ = qlite_upsert_builder_value (_tmp53_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp57_, _tmp58_, FALSE);
	_tmp60_ = _tmp59_;
	qlite_upsert_builder_perform (_tmp60_);
	_qlite_statement_builder_unref0 (_tmp60_);
	_qlite_statement_builder_unref0 (_tmp53_);
	_g_date_time_unref0 (_tmp51_);
	_qlite_statement_builder_unref0 (_tmp45_);
	_xmpp_jid_unref0 (_tmp42_);
	_qlite_statement_builder_unref0 (_tmp35_);
	_xmpp_jid_unref0 (_tmp33_);
	_qlite_statement_builder_unref0 (_tmp25_);
	_qlite_statement_builder_unref0 (_tmp17_);
	_tmp61_ = caps_hash;
	if (_tmp61_ != NULL) {
		GeeHashMap* _tmp62_;
		XmppJid* _tmp63_;
		XmppJid* _tmp64_;
		XmppJid* _tmp65_;
		const gchar* _tmp66_;
		_tmp62_ = self->priv->entity_caps_hashes;
		_tmp63_ = xmpp_stanza_get_from ((XmppStanza*) presence);
		_tmp64_ = _tmp63_;
		_tmp65_ = _tmp64_;
		_tmp66_ = caps_hash;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp62_, _tmp65_, _tmp66_);
		_xmpp_jid_unref0 (_tmp65_);
	}
	_g_free0 (caps_hash);
}

static void
dino_entity_info_remove_old_entities (DinoEntityInfo* self)
{
	glong timestamp = 0L;
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	glong _tmp4_;
	DinoDatabase* _tmp5_;
	DinoDatabaseEntityTable* _tmp6_;
	DinoDatabaseEntityTable* _tmp7_;
	QliteDeleteBuilder* _tmp8_;
	QliteDeleteBuilder* _tmp9_;
	DinoDatabase* _tmp10_;
	DinoDatabaseEntityTable* _tmp11_;
	DinoDatabaseEntityTable* _tmp12_;
	QliteColumn* _tmp13_;
	QliteDeleteBuilder* _tmp14_;
	QliteDeleteBuilder* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_date_time_new_now_local ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_date_time_add_days (_tmp1_, -14);
	_tmp3_ = _tmp2_;
	_tmp4_ = (glong) g_date_time_to_unix (_tmp3_);
	_g_date_time_unref0 (_tmp3_);
	_g_date_time_unref0 (_tmp1_);
	timestamp = _tmp4_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_database_get_entity (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = qlite_table_delete ((QliteTable*) _tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = self->priv->db;
	_tmp11_ = dino_database_get_entity (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = _tmp12_->last_seen;
	_tmp14_ = qlite_delete_builder_with (_tmp9_, G_TYPE_LONG, NULL, NULL, _tmp13_, "<", (gpointer) ((gintptr) timestamp));
	_tmp15_ = _tmp14_;
	qlite_delete_builder_perform (_tmp15_);
	_qlite_statement_builder_unref0 (_tmp15_);
	_qlite_statement_builder_unref0 (_tmp9_);
}

static void
dino_entity_info_store_features (DinoEntityInfo* self,
                                 const gchar* entity,
                                 GeeList* features)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp26_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (entity != NULL);
	g_return_if_fail (features != NULL);
	_tmp0_ = self->priv->entity_features;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, entity)) {
		return;
	}
	{
		GeeList* _feature_list = NULL;
		gint _feature_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _feature_index = 0;
		_feature_list = features;
		_tmp1_ = _feature_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_feature_size = _tmp3_;
		_feature_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			gchar* feature = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			DinoDatabase* _tmp8_;
			DinoDatabaseEntityFeatureTable* _tmp9_;
			DinoDatabaseEntityFeatureTable* _tmp10_;
			QliteInsertBuilder* _tmp11_;
			QliteInsertBuilder* _tmp12_;
			DinoDatabase* _tmp13_;
			DinoDatabaseEntityFeatureTable* _tmp14_;
			DinoDatabaseEntityFeatureTable* _tmp15_;
			QliteColumn* _tmp16_;
			QliteInsertBuilder* _tmp17_;
			QliteInsertBuilder* _tmp18_;
			DinoDatabase* _tmp19_;
			DinoDatabaseEntityFeatureTable* _tmp20_;
			DinoDatabaseEntityFeatureTable* _tmp21_;
			QliteColumn* _tmp22_;
			const gchar* _tmp23_;
			QliteInsertBuilder* _tmp24_;
			QliteInsertBuilder* _tmp25_;
			_feature_index = _feature_index + 1;
			_tmp4_ = _feature_index;
			_tmp5_ = _feature_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _feature_list;
			_tmp7_ = gee_list_get (_tmp6_, _feature_index);
			feature = (gchar*) _tmp7_;
			_tmp8_ = self->priv->db;
			_tmp9_ = dino_database_get_entity_feature (_tmp8_);
			_tmp10_ = _tmp9_;
			_tmp11_ = qlite_table_insert ((QliteTable*) _tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = self->priv->db;
			_tmp14_ = dino_database_get_entity_feature (_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp16_ = _tmp15_->entity;
			_tmp17_ = qlite_insert_builder_value (_tmp12_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp16_, entity);
			_tmp18_ = _tmp17_;
			_tmp19_ = self->priv->db;
			_tmp20_ = dino_database_get_entity_feature (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = _tmp21_->feature;
			_tmp23_ = feature;
			_tmp24_ = qlite_insert_builder_value (_tmp18_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp22_, _tmp23_);
			_tmp25_ = _tmp24_;
			qlite_insert_builder_perform (_tmp25_);
			_qlite_statement_builder_unref0 (_tmp25_);
			_qlite_statement_builder_unref0 (_tmp18_);
			_qlite_statement_builder_unref0 (_tmp12_);
			_g_free0 (feature);
		}
	}
	_tmp26_ = self->priv->entity_features;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp26_, entity, features);
}

static void
dino_entity_info_store_identities (DinoEntityInfo* self,
                                   const gchar* entity,
                                   GeeSet* identities)
{
	GeeHashMap* _tmp42_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (entity != NULL);
	g_return_if_fail (identities != NULL);
	{
		GeeIterator* _identity_it = NULL;
		GeeIterator* _tmp0_;
		_tmp0_ = gee_iterable_iterator ((GeeIterable*) identities);
		_identity_it = _tmp0_;
		while (TRUE) {
			GeeIterator* _tmp1_;
			XmppXepServiceDiscoveryIdentity* identity = NULL;
			GeeIterator* _tmp2_;
			gpointer _tmp3_;
			DinoDatabase* _tmp4_;
			DinoDatabaseEntityIdentityTable* _tmp5_;
			DinoDatabaseEntityIdentityTable* _tmp6_;
			QliteInsertBuilder* _tmp7_;
			QliteInsertBuilder* _tmp8_;
			DinoDatabase* _tmp9_;
			DinoDatabaseEntityIdentityTable* _tmp10_;
			DinoDatabaseEntityIdentityTable* _tmp11_;
			QliteColumn* _tmp12_;
			QliteInsertBuilder* _tmp13_;
			QliteInsertBuilder* _tmp14_;
			DinoDatabase* _tmp15_;
			DinoDatabaseEntityIdentityTable* _tmp16_;
			DinoDatabaseEntityIdentityTable* _tmp17_;
			QliteColumn* _tmp18_;
			XmppXepServiceDiscoveryIdentity* _tmp19_;
			const gchar* _tmp20_;
			const gchar* _tmp21_;
			QliteInsertBuilder* _tmp22_;
			QliteInsertBuilder* _tmp23_;
			DinoDatabase* _tmp24_;
			DinoDatabaseEntityIdentityTable* _tmp25_;
			DinoDatabaseEntityIdentityTable* _tmp26_;
			QliteColumn* _tmp27_;
			XmppXepServiceDiscoveryIdentity* _tmp28_;
			const gchar* _tmp29_;
			const gchar* _tmp30_;
			QliteInsertBuilder* _tmp31_;
			QliteInsertBuilder* _tmp32_;
			DinoDatabase* _tmp33_;
			DinoDatabaseEntityIdentityTable* _tmp34_;
			DinoDatabaseEntityIdentityTable* _tmp35_;
			QliteColumn* _tmp36_;
			XmppXepServiceDiscoveryIdentity* _tmp37_;
			const gchar* _tmp38_;
			const gchar* _tmp39_;
			QliteInsertBuilder* _tmp40_;
			QliteInsertBuilder* _tmp41_;
			_tmp1_ = _identity_it;
			if (!gee_iterator_next (_tmp1_)) {
				break;
			}
			_tmp2_ = _identity_it;
			_tmp3_ = gee_iterator_get (_tmp2_);
			identity = (XmppXepServiceDiscoveryIdentity*) _tmp3_;
			_tmp4_ = self->priv->db;
			_tmp5_ = dino_database_get_entity_identity (_tmp4_);
			_tmp6_ = _tmp5_;
			_tmp7_ = qlite_table_insert ((QliteTable*) _tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = self->priv->db;
			_tmp10_ = dino_database_get_entity_identity (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = _tmp11_->entity;
			_tmp13_ = qlite_insert_builder_value (_tmp8_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp12_, entity);
			_tmp14_ = _tmp13_;
			_tmp15_ = self->priv->db;
			_tmp16_ = dino_database_get_entity_identity (_tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = _tmp17_->category;
			_tmp19_ = identity;
			_tmp20_ = xmpp_xep_service_discovery_identity_get_category (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = qlite_insert_builder_value (_tmp14_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp18_, _tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = self->priv->db;
			_tmp25_ = dino_database_get_entity_identity (_tmp24_);
			_tmp26_ = _tmp25_;
			_tmp27_ = _tmp26_->type;
			_tmp28_ = identity;
			_tmp29_ = xmpp_xep_service_discovery_identity_get_type_ (_tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = qlite_insert_builder_value (_tmp23_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp27_, _tmp30_);
			_tmp32_ = _tmp31_;
			_tmp33_ = self->priv->db;
			_tmp34_ = dino_database_get_entity_identity (_tmp33_);
			_tmp35_ = _tmp34_;
			_tmp36_ = _tmp35_->entity_name;
			_tmp37_ = identity;
			_tmp38_ = xmpp_xep_service_discovery_identity_get_name (_tmp37_);
			_tmp39_ = _tmp38_;
			_tmp40_ = qlite_insert_builder_value (_tmp32_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp36_, _tmp39_);
			_tmp41_ = _tmp40_;
			qlite_insert_builder_perform (_tmp41_);
			_qlite_statement_builder_unref0 (_tmp41_);
			_qlite_statement_builder_unref0 (_tmp32_);
			_qlite_statement_builder_unref0 (_tmp23_);
			_qlite_statement_builder_unref0 (_tmp14_);
			_qlite_statement_builder_unref0 (_tmp8_);
			_xmpp_xep_service_discovery_identity_unref0 (identity);
		}
		_g_object_unref0 (_identity_it);
	}
	_tmp42_ = self->priv->entity_identity;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp42_, entity, identities);
}

static gpointer
_qlite_column_ref0 (gpointer self)
{
	return self ? qlite_column_ref (self) : NULL;
}

static GeeList*
dino_entity_info_get_stored_features (DinoEntityInfo* self,
                                      const gchar* entity)
{
	GeeList* features = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GeeList* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeList* _tmp35_;
	gint _tmp36_;
	gint _tmp37_;
	GeeHashMap* _tmp38_;
	GeeList* _tmp39_;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (entity != NULL, NULL);
	_tmp0_ = self->priv->entity_features;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, entity);
	features = (GeeList*) _tmp1_;
	_tmp2_ = features;
	if (_tmp2_ != NULL) {
		result = features;
		return result;
	}
	_tmp3_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_g_object_unref0 (features);
	features = (GeeList*) _tmp3_;
	{
		QliteRowIterator* _row_it = NULL;
		DinoDatabase* _tmp4_;
		DinoDatabaseEntityFeatureTable* _tmp5_;
		DinoDatabaseEntityFeatureTable* _tmp6_;
		DinoDatabase* _tmp7_;
		DinoDatabaseEntityFeatureTable* _tmp8_;
		DinoDatabaseEntityFeatureTable* _tmp9_;
		QliteColumn* _tmp10_;
		QliteColumn* _tmp11_;
		QliteColumn** _tmp12_;
		QliteColumn** _tmp13_;
		gint _tmp13__length1;
		QliteQueryBuilder* _tmp14_;
		QliteQueryBuilder* _tmp15_;
		DinoDatabase* _tmp16_;
		DinoDatabaseEntityFeatureTable* _tmp17_;
		DinoDatabaseEntityFeatureTable* _tmp18_;
		QliteColumn* _tmp19_;
		QliteQueryBuilder* _tmp20_;
		QliteQueryBuilder* _tmp21_;
		QliteRowIterator* _tmp22_;
		QliteRowIterator* _tmp23_;
		_tmp4_ = self->priv->db;
		_tmp5_ = dino_database_get_entity_feature (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = self->priv->db;
		_tmp8_ = dino_database_get_entity_feature (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = _tmp9_->feature;
		_tmp11_ = _qlite_column_ref0 (_tmp10_);
		_tmp12_ = g_new0 (QliteColumn*, 1 + 1);
		_tmp12_[0] = _tmp11_;
		_tmp13_ = _tmp12_;
		_tmp13__length1 = 1;
		_tmp14_ = qlite_table_select ((QliteTable*) _tmp6_, _tmp13_, (gint) 1);
		_tmp15_ = _tmp14_;
		_tmp16_ = self->priv->db;
		_tmp17_ = dino_database_get_entity_feature (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = _tmp18_->entity;
		_tmp20_ = qlite_query_builder_with (_tmp15_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp19_, "=", entity);
		_tmp21_ = _tmp20_;
		_tmp22_ = qlite_query_builder_iterator (_tmp21_);
		_tmp23_ = _tmp22_;
		_qlite_statement_builder_unref0 (_tmp21_);
		_qlite_statement_builder_unref0 (_tmp15_);
		_tmp13_ = (_vala_array_free (_tmp13_, _tmp13__length1, (GDestroyNotify) qlite_column_unref), NULL);
		_row_it = _tmp23_;
		while (TRUE) {
			QliteRowIterator* _tmp24_;
			QliteRow* row = NULL;
			QliteRowIterator* _tmp25_;
			QliteRow* _tmp26_;
			GeeList* _tmp27_;
			QliteRow* _tmp28_;
			DinoDatabase* _tmp29_;
			DinoDatabaseEntityFeatureTable* _tmp30_;
			DinoDatabaseEntityFeatureTable* _tmp31_;
			QliteColumn* _tmp32_;
			gpointer _tmp33_;
			gchar* _tmp34_;
			_tmp24_ = _row_it;
			if (!qlite_row_iterator_next (_tmp24_)) {
				break;
			}
			_tmp25_ = _row_it;
			_tmp26_ = qlite_row_iterator_get (_tmp25_);
			row = _tmp26_;
			_tmp27_ = features;
			_tmp28_ = row;
			_tmp29_ = self->priv->db;
			_tmp30_ = dino_database_get_entity_feature (_tmp29_);
			_tmp31_ = _tmp30_;
			_tmp32_ = _tmp31_->feature;
			_tmp33_ = qlite_row_get (_tmp28_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp32_);
			_tmp34_ = (gchar*) _tmp33_;
			gee_collection_add ((GeeCollection*) _tmp27_, _tmp34_);
			_g_free0 (_tmp34_);
			_qlite_row_unref0 (row);
		}
		_qlite_row_iterator_unref0 (_row_it);
	}
	_tmp35_ = features;
	_tmp36_ = gee_collection_get_size ((GeeCollection*) _tmp35_);
	_tmp37_ = _tmp36_;
	if (_tmp37_ == 0) {
		result = NULL;
		_g_object_unref0 (features);
		return result;
	}
	_tmp38_ = self->priv->entity_features;
	_tmp39_ = features;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp38_, entity, _tmp39_);
	result = features;
	return result;
}

static guint
_xmpp_xep_service_discovery_identity_hash_func_gee_hash_data_func (gconstpointer v,
                                                                   gpointer self)
{
	guint result;
	result = xmpp_xep_service_discovery_identity_hash_func ((XmppXepServiceDiscoveryIdentity*) v);
	return result;
}

static gboolean
_xmpp_xep_service_discovery_identity_equals_func_gee_equal_data_func (gconstpointer a,
                                                                      gconstpointer b,
                                                                      gpointer self)
{
	gboolean result;
	result = xmpp_xep_service_discovery_identity_equals_func ((XmppXepServiceDiscoveryIdentity*) a, (XmppXepServiceDiscoveryIdentity*) b);
	return result;
}

static GeeSet*
dino_entity_info_get_stored_identities (DinoEntityInfo* self,
                                        const gchar* entity)
{
	GeeSet* identities = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GeeSet* _tmp2_;
	GeeHashSet* _tmp3_;
	QliteQueryBuilder* qry = NULL;
	DinoDatabase* _tmp4_;
	DinoDatabaseEntityIdentityTable* _tmp5_;
	DinoDatabaseEntityIdentityTable* _tmp6_;
	QliteQueryBuilder* _tmp7_;
	QliteQueryBuilder* _tmp8_;
	DinoDatabase* _tmp9_;
	DinoDatabaseEntityIdentityTable* _tmp10_;
	DinoDatabaseEntityIdentityTable* _tmp11_;
	QliteColumn* _tmp12_;
	QliteQueryBuilder* _tmp13_;
	QliteQueryBuilder* _tmp14_;
	GeeSet* _tmp45_;
	gint _tmp46_;
	gint _tmp47_;
	GeeHashMap* _tmp48_;
	GeeSet* _tmp49_;
	GeeSet* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (entity != NULL, NULL);
	_tmp0_ = self->priv->entity_identity;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, entity);
	identities = (GeeSet*) _tmp1_;
	_tmp2_ = identities;
	if (_tmp2_ != NULL) {
		result = identities;
		return result;
	}
	_tmp3_ = gee_hash_set_new (XMPP_XEP_SERVICE_DISCOVERY_TYPE_IDENTITY, (GBoxedCopyFunc) xmpp_xep_service_discovery_identity_ref, (GDestroyNotify) xmpp_xep_service_discovery_identity_unref, _xmpp_xep_service_discovery_identity_hash_func_gee_hash_data_func, NULL, NULL, _xmpp_xep_service_discovery_identity_equals_func_gee_equal_data_func, NULL, NULL);
	_g_object_unref0 (identities);
	identities = (GeeSet*) _tmp3_;
	_tmp4_ = self->priv->db;
	_tmp5_ = dino_database_get_entity_identity (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = qlite_table_select ((QliteTable*) _tmp6_, NULL, (gint) 0);
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->db;
	_tmp10_ = dino_database_get_entity_identity (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = _tmp11_->entity;
	_tmp13_ = qlite_query_builder_with (_tmp8_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp12_, "=", entity);
	_tmp14_ = _tmp13_;
	_qlite_statement_builder_unref0 (_tmp8_);
	qry = _tmp14_;
	{
		QliteRowIterator* _row_it = NULL;
		QliteQueryBuilder* _tmp15_;
		QliteRowIterator* _tmp16_;
		_tmp15_ = qry;
		_tmp16_ = qlite_query_builder_iterator (_tmp15_);
		_row_it = _tmp16_;
		while (TRUE) {
			QliteRowIterator* _tmp17_;
			QliteRow* row = NULL;
			QliteRowIterator* _tmp18_;
			QliteRow* _tmp19_;
			XmppXepServiceDiscoveryIdentity* identity = NULL;
			QliteRow* _tmp20_;
			DinoDatabase* _tmp21_;
			DinoDatabaseEntityIdentityTable* _tmp22_;
			DinoDatabaseEntityIdentityTable* _tmp23_;
			QliteColumn* _tmp24_;
			gpointer _tmp25_;
			gchar* _tmp26_;
			QliteRow* _tmp27_;
			DinoDatabase* _tmp28_;
			DinoDatabaseEntityIdentityTable* _tmp29_;
			DinoDatabaseEntityIdentityTable* _tmp30_;
			QliteColumn* _tmp31_;
			gpointer _tmp32_;
			gchar* _tmp33_;
			QliteRow* _tmp34_;
			DinoDatabase* _tmp35_;
			DinoDatabaseEntityIdentityTable* _tmp36_;
			DinoDatabaseEntityIdentityTable* _tmp37_;
			QliteColumn* _tmp38_;
			gpointer _tmp39_;
			gchar* _tmp40_;
			XmppXepServiceDiscoveryIdentity* _tmp41_;
			XmppXepServiceDiscoveryIdentity* _tmp42_;
			GeeSet* _tmp43_;
			XmppXepServiceDiscoveryIdentity* _tmp44_;
			_tmp17_ = _row_it;
			if (!qlite_row_iterator_next (_tmp17_)) {
				break;
			}
			_tmp18_ = _row_it;
			_tmp19_ = qlite_row_iterator_get (_tmp18_);
			row = _tmp19_;
			_tmp20_ = row;
			_tmp21_ = self->priv->db;
			_tmp22_ = dino_database_get_entity_identity (_tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = _tmp23_->category;
			_tmp25_ = qlite_row_get (_tmp20_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp24_);
			_tmp26_ = (gchar*) _tmp25_;
			_tmp27_ = row;
			_tmp28_ = self->priv->db;
			_tmp29_ = dino_database_get_entity_identity (_tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = _tmp30_->type;
			_tmp32_ = qlite_row_get (_tmp27_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp31_);
			_tmp33_ = (gchar*) _tmp32_;
			_tmp34_ = row;
			_tmp35_ = self->priv->db;
			_tmp36_ = dino_database_get_entity_identity (_tmp35_);
			_tmp37_ = _tmp36_;
			_tmp38_ = _tmp37_->entity_name;
			_tmp39_ = qlite_row_get (_tmp34_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp38_);
			_tmp40_ = (gchar*) _tmp39_;
			_tmp41_ = xmpp_xep_service_discovery_identity_new (_tmp26_, _tmp33_, _tmp40_);
			_tmp42_ = _tmp41_;
			_g_free0 (_tmp40_);
			_g_free0 (_tmp33_);
			_g_free0 (_tmp26_);
			identity = _tmp42_;
			_tmp43_ = identities;
			_tmp44_ = identity;
			gee_collection_add ((GeeCollection*) _tmp43_, _tmp44_);
			_xmpp_xep_service_discovery_identity_unref0 (identity);
			_qlite_row_unref0 (row);
		}
		_qlite_row_iterator_unref0 (_row_it);
	}
	_tmp45_ = identities;
	_tmp46_ = gee_collection_get_size ((GeeCollection*) _tmp45_);
	_tmp47_ = _tmp46_;
	if (_tmp47_ == 0) {
		result = NULL;
		_qlite_statement_builder_unref0 (qry);
		_g_object_unref0 (identities);
		return result;
	}
	_tmp48_ = self->priv->entity_identity;
	_tmp49_ = identities;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp48_, entity, _tmp49_);
	result = identities;
	_qlite_statement_builder_unref0 (qry);
	return result;
}

static void
dino_entity_info_get_info_result_data_free (gpointer _data)
{
	DinoEntityInfoGetInfoResultData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_xmpp_jid_unref0 (_data_->jid);
	_g_free0 (_data_->hash);
	_xmpp_xep_service_discovery_info_result_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoEntityInfoGetInfoResultData, _data_);
}

static void
dino_entity_info_get_info_result (DinoEntityInfo* self,
                                  DinoEntitiesAccount* account,
                                  XmppJid* jid,
                                  const gchar* hash,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	DinoEntityInfoGetInfoResultData* _data_;
	DinoEntityInfo* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	XmppJid* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	_data_ = g_slice_new0 (DinoEntityInfoGetInfoResultData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_entity_info_get_info_result_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	_tmp3_ = g_strdup (hash);
	_g_free0 (_data_->hash);
	_data_->hash = _tmp3_;
	dino_entity_info_get_info_result_co (_data_);
}

static XmppXepServiceDiscoveryInfoResult*
dino_entity_info_get_info_result_finish (DinoEntityInfo* self,
                                         GAsyncResult* _res_)
{
	XmppXepServiceDiscoveryInfoResult* result;
	DinoEntityInfoGetInfoResultData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dino_entity_info_get_info_result_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_)
{
	DinoEntityInfoGetInfoResultData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_entity_info_get_info_result_co (_data_);
}

static gboolean
dino_entity_info_get_info_result_co (DinoEntityInfoGetInfoResultData* _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->stream_interactor;
	_data_->_tmp1_ = dino_stream_interactor_get_stream (_data_->_tmp0_, _data_->account);
	_data_->stream = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->stream;
	if (_data_->_tmp2_ == NULL) {
		_data_->result = NULL;
		_g_object_unref0 (_data_->stream);
		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_->_tmp3_ = _data_->stream;
	_data_->_tmp4_ = xmpp_xep_service_discovery_module_IDENTITY;
	_data_->_tmp5_ = xmpp_xmpp_stream_get_module (_data_->_tmp3_, XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp4_);
	_data_->_tmp6_ = (XmppXepServiceDiscoveryModule*) _data_->_tmp5_;
	_data_->_tmp7_ = _data_->stream;
	_data_->_state_ = 1;
	xmpp_xep_service_discovery_module_request_info (_data_->_tmp6_, _data_->_tmp7_, _data_->jid, dino_entity_info_get_info_result_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp8_ = xmpp_xep_service_discovery_module_request_info_finish (_data_->_tmp6_, _data_->_res_);
	_data_->_tmp9_ = _data_->_tmp8_;
	_g_object_unref0 (_data_->_tmp6_);
	_data_->info_result = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->info_result;
	if (_data_->_tmp10_ == NULL) {
		_data_->result = NULL;
		_xmpp_xep_service_discovery_info_result_unref0 (_data_->info_result);
		_g_object_unref0 (_data_->stream);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp11_ = _data_->info_result;
	_data_->_tmp12_ = xmpp_xep_entity_capabilities_module_compute_hash_for_info_result (_data_->_tmp11_);
	_data_->computed_hash = _data_->_tmp12_;
	if (_data_->hash == NULL) {
		_data_->_tmp13_ = TRUE;
	} else {
		_data_->_tmp14_ = _data_->computed_hash;
		_data_->_tmp13_ = g_strcmp0 (_data_->_tmp14_, _data_->hash) == 0;
	}
	if (_data_->_tmp13_) {
		_data_->_tmp16_ = _data_->jid->resourcepart;
		_data_->_tmp15_ = _data_->_tmp16_;
		if (_data_->_tmp15_ == NULL) {
			_data_->_tmp15_ = "";
		}
		_data_->_tmp17_ = _data_->self->priv->db;
		_data_->_tmp18_ = dino_database_get_entity (_data_->_tmp17_);
		_data_->_tmp19_ = _data_->_tmp18_;
		_data_->_tmp20_ = qlite_table_upsert ((QliteTable*) _data_->_tmp19_);
		_data_->_tmp21_ = _data_->_tmp20_;
		_data_->_tmp22_ = _data_->self->priv->db;
		_data_->_tmp23_ = dino_database_get_entity (_data_->_tmp22_);
		_data_->_tmp24_ = _data_->_tmp23_;
		_data_->_tmp25_ = _data_->_tmp24_->account_id;
		_data_->_tmp26_ = dino_entities_account_get_id (_data_->account);
		_data_->_tmp27_ = _data_->_tmp26_;
		_data_->_tmp28_ = qlite_upsert_builder_value (_data_->_tmp21_, G_TYPE_INT, NULL, NULL, _data_->_tmp25_, (gpointer) ((gintptr) _data_->_tmp27_), TRUE);
		_data_->_tmp29_ = _data_->_tmp28_;
		_data_->_tmp30_ = _data_->self->priv->db;
		_data_->_tmp31_ = dino_database_get_entity (_data_->_tmp30_);
		_data_->_tmp32_ = _data_->_tmp31_;
		_data_->_tmp33_ = _data_->_tmp32_->jid_id;
		_data_->_tmp34_ = _data_->self->priv->db;
		_data_->_tmp35_ = qlite_upsert_builder_value (_data_->_tmp29_, G_TYPE_INT, NULL, NULL, _data_->_tmp33_, (gpointer) ((gintptr) dino_database_get_jid_id (_data_->_tmp34_, _data_->jid)), TRUE);
		_data_->_tmp36_ = _data_->_tmp35_;
		_data_->_tmp37_ = _data_->self->priv->db;
		_data_->_tmp38_ = dino_database_get_entity (_data_->_tmp37_);
		_data_->_tmp39_ = _data_->_tmp38_;
		_data_->_tmp40_ = _data_->_tmp39_->resource;
		_data_->_tmp41_ = qlite_upsert_builder_value (_data_->_tmp36_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp40_, _data_->_tmp15_, TRUE);
		_data_->_tmp42_ = _data_->_tmp41_;
		_data_->_tmp43_ = _data_->self->priv->db;
		_data_->_tmp44_ = dino_database_get_entity (_data_->_tmp43_);
		_data_->_tmp45_ = _data_->_tmp44_;
		_data_->_tmp46_ = _data_->_tmp45_->last_seen;
		_data_->_tmp47_ = g_date_time_new_now_local ();
		_data_->_tmp48_ = _data_->_tmp47_;
		_data_->_tmp49_ = qlite_upsert_builder_value (_data_->_tmp42_, G_TYPE_LONG, NULL, NULL, _data_->_tmp46_, (gpointer) ((gintptr) g_date_time_to_unix (_data_->_tmp48_)), FALSE);
		_data_->_tmp50_ = _data_->_tmp49_;
		_data_->_tmp51_ = _data_->self->priv->db;
		_data_->_tmp52_ = dino_database_get_entity (_data_->_tmp51_);
		_data_->_tmp53_ = _data_->_tmp52_;
		_data_->_tmp54_ = _data_->_tmp53_->caps_hash;
		_data_->_tmp55_ = _data_->computed_hash;
		_data_->_tmp56_ = qlite_upsert_builder_value (_data_->_tmp50_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp54_, _data_->_tmp55_, FALSE);
		_data_->_tmp57_ = _data_->_tmp56_;
		qlite_upsert_builder_perform (_data_->_tmp57_);
		_qlite_statement_builder_unref0 (_data_->_tmp57_);
		_qlite_statement_builder_unref0 (_data_->_tmp50_);
		_g_date_time_unref0 (_data_->_tmp48_);
		_qlite_statement_builder_unref0 (_data_->_tmp42_);
		_qlite_statement_builder_unref0 (_data_->_tmp36_);
		_qlite_statement_builder_unref0 (_data_->_tmp29_);
		_qlite_statement_builder_unref0 (_data_->_tmp21_);
		_data_->_tmp58_ = _data_->computed_hash;
		_data_->_tmp59_ = _data_->info_result;
		_data_->_tmp60_ = xmpp_xep_service_discovery_info_result_get_features (_data_->_tmp59_);
		_data_->_tmp61_ = _data_->_tmp60_;
		_data_->_tmp62_ = _data_->_tmp61_;
		dino_entity_info_store_features (_data_->self, _data_->_tmp58_, _data_->_tmp62_);
		_g_object_unref0 (_data_->_tmp62_);
		_data_->_tmp63_ = _data_->computed_hash;
		_data_->_tmp64_ = _data_->info_result;
		_data_->_tmp65_ = xmpp_xep_service_discovery_info_result_get_identities (_data_->_tmp64_);
		_data_->_tmp66_ = _data_->_tmp65_;
		_data_->_tmp67_ = _data_->_tmp66_;
		dino_entity_info_store_identities (_data_->self, _data_->_tmp63_, _data_->_tmp67_);
		_g_object_unref0 (_data_->_tmp67_);
	} else {
		_data_->_tmp68_ = xmpp_jid_to_string (_data_->jid);
		_data_->_tmp69_ = _data_->_tmp68_;
		g_warning ("entity_info.vala:234: Claimed entity caps hash from %s doesn't match c" \
"omputed one", _data_->_tmp69_);
		_g_free0 (_data_->_tmp69_);
	}
	_data_->_tmp70_ = _data_->self->priv->jid_features;
	_data_->_tmp71_ = _data_->info_result;
	_data_->_tmp72_ = xmpp_xep_service_discovery_info_result_get_features (_data_->_tmp71_);
	_data_->_tmp73_ = _data_->_tmp72_;
	_data_->_tmp74_ = _data_->_tmp73_;
	gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp70_, _data_->jid, _data_->_tmp74_);
	_g_object_unref0 (_data_->_tmp74_);
	_data_->_tmp75_ = _data_->self->priv->jid_identity;
	_data_->_tmp76_ = _data_->info_result;
	_data_->_tmp77_ = xmpp_xep_service_discovery_info_result_get_identities (_data_->_tmp76_);
	_data_->_tmp78_ = _data_->_tmp77_;
	_data_->_tmp79_ = _data_->_tmp78_;
	gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp75_, _data_->jid, _data_->_tmp79_);
	_g_object_unref0 (_data_->_tmp79_);
	_data_->result = _data_->info_result;
	_g_free0 (_data_->computed_hash);
	_g_object_unref0 (_data_->stream);
	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 Block14Data*
block14_data_ref (Block14Data* _data14_)
{
	g_atomic_int_inc (&_data14_->_ref_count_);
	return _data14_;
}

static void
block14_data_unref (void * _userdata_)
{
	Block14Data* _data14_;
	_data14_ = (Block14Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data14_->_ref_count_)) {
		DinoEntityInfo* self;
		self = _data14_->self;
		_g_object_unref0 (_data14_->account);
		_g_object_unref0 (self);
		g_slice_free (Block14Data, _data14_);
	}
}

static void
__lambda31_ (Block14Data* _data14_,
             XmppXmppStream* stream,
             XmppPresenceStanza* presence)
{
	DinoEntityInfo* self;
	self = _data14_->self;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (presence != NULL);
	dino_entity_info_on_received_available_presence (self, _data14_->account, presence);
}

static void
___lambda31__xmpp_presence_module_received_available (XmppPresenceModule* _sender,
                                                      XmppXmppStream* stream,
                                                      XmppPresenceStanza* presence,
                                                      gpointer self)
{
	__lambda31_ (self, stream, presence);
}

static void
dino_entity_info_on_account_added (DinoEntityInfo* self,
                                   DinoEntitiesAccount* account)
{
	Block14Data* _data14_;
	DinoEntitiesAccount* _tmp0_;
	DinoCapsCacheImpl* cache = NULL;
	DinoCapsCacheImpl* _tmp1_;
	DinoStreamInteractor* _tmp2_;
	DinoModuleManager* _tmp3_;
	XmppModuleIdentity* _tmp4_;
	gpointer _tmp5_;
	XmppXepServiceDiscoveryModule* _tmp6_;
	XmppXepServiceDiscoveryCapsCache* _tmp7_;
	DinoStreamInteractor* _tmp8_;
	DinoModuleManager* _tmp9_;
	XmppModuleIdentity* _tmp10_;
	gpointer _tmp11_;
	XmppPresenceModule* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_data14_ = g_slice_new0 (Block14Data);
	_data14_->_ref_count_ = 1;
	_data14_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (_data14_->account);
	_data14_->account = _tmp0_;
	_tmp1_ = dino_caps_cache_impl_new (_data14_->account, self);
	cache = _tmp1_;
	_tmp2_ = self->priv->stream_interactor;
	_tmp3_ = _tmp2_->module_manager;
	_tmp4_ = xmpp_xep_service_discovery_module_IDENTITY;
	_tmp5_ = dino_module_manager_get_module (_tmp3_, XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data14_->account, _tmp4_);
	_tmp6_ = (XmppXepServiceDiscoveryModule*) _tmp5_;
	_tmp7_ = _g_object_ref0 ((XmppXepServiceDiscoveryCapsCache*) cache);
	_g_object_unref0 (_tmp6_->cache);
	_tmp6_->cache = _tmp7_;
	_g_object_unref0 (_tmp6_);
	_tmp8_ = self->priv->stream_interactor;
	_tmp9_ = _tmp8_->module_manager;
	_tmp10_ = xmpp_presence_module_IDENTITY;
	_tmp11_ = dino_module_manager_get_module (_tmp9_, XMPP_PRESENCE_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data14_->account, _tmp10_);
	_tmp12_ = (XmppPresenceModule*) _tmp11_;
	g_signal_connect_data (_tmp12_, "received-available", (GCallback) ___lambda31__xmpp_presence_module_received_available, block14_data_ref (_data14_), (GClosureNotify) block14_data_unref, 0);
	_g_object_unref0 (_tmp12_);
	_g_object_unref0 (cache);
	block14_data_unref (_data14_);
	_data14_ = NULL;
}

static void
dino_entity_info_initialize_modules (DinoEntityInfo* self,
                                     DinoEntitiesAccount* account,
                                     GeeArrayList* modules)
{
	DinoEntityCapabilitiesStorage* _tmp0_;
	XmppXepEntityCapabilitiesModule* _tmp1_;
	XmppXepEntityCapabilitiesModule* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (modules != NULL);
	_tmp0_ = self->priv->entity_capabilities_storage;
	_tmp1_ = xmpp_xep_entity_capabilities_module_new ((XmppXepEntityCapabilitiesStorage*) _tmp0_);
	_tmp2_ = _tmp1_;
	gee_abstract_collection_add ((GeeAbstractCollection*) modules, (XmppXmppStreamModule*) _tmp2_);
	_g_object_unref0 (_tmp2_);
}

static const gchar*
dino_entity_info_real_get_id (DinoStreamInteractionModule* base)
{
	const gchar* result;
	DinoEntityInfo* self;
	DinoModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (DinoEntityInfo*) base;
	_tmp0_ = dino_entity_info_IDENTITY;
	_tmp1_ = dino_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
dino_entity_info_class_init (DinoEntityInfoClass * klass,
                             gpointer klass_data)
{
	DinoModuleIdentity* _tmp0_;
	dino_entity_info_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoEntityInfo_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_entity_info_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_entity_info_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_ENTITY_INFO_ID_PROPERTY, dino_entity_info_properties[DINO_ENTITY_INFO_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = dino_module_identity_new (DINO_TYPE_ENTITY_INFO, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, "entity_info");
	dino_entity_info_IDENTITY = _tmp0_;
}

static void
dino_entity_info_dino_stream_interaction_module_interface_init (DinoStreamInteractionModuleIface * iface,
                                                                gpointer iface_data)
{
	dino_entity_info_dino_stream_interaction_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = dino_entity_info_real_get_id;
}

static void
dino_entity_info_instance_init (DinoEntityInfo * self,
                                gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	GeeHashMap* _tmp3_;
	GeeHashMap* _tmp4_;
	self->priv = dino_entity_info_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _xmpp_jid_hash_func_gee_hash_data_func, NULL, NULL, _xmpp_jid_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->entity_caps_hashes = _tmp0_;
	_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, GEE_TYPE_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->entity_features = _tmp1_;
	_tmp2_ = gee_hash_map_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, GEE_TYPE_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _xmpp_jid_hash_func_gee_hash_data_func, NULL, NULL, _xmpp_jid_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->jid_features = _tmp2_;
	_tmp3_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, GEE_TYPE_SET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->entity_identity = _tmp3_;
	_tmp4_ = gee_hash_map_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, GEE_TYPE_SET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _xmpp_jid_hash_func_gee_hash_data_func, NULL, NULL, _xmpp_jid_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->jid_identity = _tmp4_;
}

static void
dino_entity_info_finalize (GObject * obj)
{
	DinoEntityInfo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_ENTITY_INFO, DinoEntityInfo);
	_g_object_unref0 (self->priv->stream_interactor);
	_qlite_database_unref0 (self->priv->db);
	_g_object_unref0 (self->priv->entity_capabilities_storage);
	_g_object_unref0 (self->priv->entity_caps_hashes);
	_g_object_unref0 (self->priv->entity_features);
	_g_object_unref0 (self->priv->jid_features);
	_g_object_unref0 (self->priv->entity_identity);
	_g_object_unref0 (self->priv->jid_identity);
	G_OBJECT_CLASS (dino_entity_info_parent_class)->finalize (obj);
}

static GType
dino_entity_info_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoEntityInfoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_entity_info_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoEntityInfo), 0, (GInstanceInitFunc) dino_entity_info_instance_init, NULL };
	static const GInterfaceInfo dino_stream_interaction_module_info = { (GInterfaceInitFunc) dino_entity_info_dino_stream_interaction_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_entity_info_type_id;
	dino_entity_info_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoEntityInfo", &g_define_type_info, 0);
	g_type_add_interface_static (dino_entity_info_type_id, DINO_TYPE_STREAM_INTERACTION_MODULE, &dino_stream_interaction_module_info);
	DinoEntityInfo_private_offset = g_type_add_instance_private (dino_entity_info_type_id, sizeof (DinoEntityInfoPrivate));
	return dino_entity_info_type_id;
}

GType
dino_entity_info_get_type (void)
{
	static volatile gsize dino_entity_info_type_id__once = 0;
	if (g_once_init_enter (&dino_entity_info_type_id__once)) {
		GType dino_entity_info_type_id;
		dino_entity_info_type_id = dino_entity_info_get_type_once ();
		g_once_init_leave (&dino_entity_info_type_id__once, dino_entity_info_type_id);
	}
	return dino_entity_info_type_id__once;
}

static void
_vala_dino_entity_info_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	DinoEntityInfo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_ENTITY_INFO, DinoEntityInfo);
	switch (property_id) {
		case DINO_ENTITY_INFO_ID_PROPERTY:
		g_value_set_string (value, dino_stream_interaction_module_get_id ((DinoStreamInteractionModule*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
dino_caps_cache_impl_get_instance_private (DinoCapsCacheImpl* self)
{
	return G_STRUCT_MEMBER_P (self, DinoCapsCacheImpl_private_offset);
}

DinoCapsCacheImpl*
dino_caps_cache_impl_construct (GType object_type,
                                DinoEntitiesAccount* account,
                                DinoEntityInfo* entity_info)
{
	DinoCapsCacheImpl * self = NULL;
	DinoEntitiesAccount* _tmp0_;
	DinoEntityInfo* _tmp1_;
	g_return_val_if_fail (account != NULL, NULL);
	g_return_val_if_fail (entity_info != NULL, NULL);
	self = (DinoCapsCacheImpl*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (self->priv->account);
	self->priv->account = _tmp0_;
	_tmp1_ = _g_object_ref0 (entity_info);
	_g_object_unref0 (self->priv->entity_info);
	self->priv->entity_info = _tmp1_;
	return self;
}

DinoCapsCacheImpl*
dino_caps_cache_impl_new (DinoEntitiesAccount* account,
                          DinoEntityInfo* entity_info)
{
	return dino_caps_cache_impl_construct (DINO_TYPE_CAPS_CACHE_IMPL, account, entity_info);
}

static void
dino_caps_cache_impl_real_has_entity_feature_data_free (gpointer _data)
{
	DinoCapsCacheImplHasEntityFeatureData* _data_;
	_data_ = _data;
	_xmpp_jid_unref0 (_data_->jid);
	_g_free0 (_data_->feature);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoCapsCacheImplHasEntityFeatureData, _data_);
}

static void
dino_caps_cache_impl_real_has_entity_feature (XmppXepServiceDiscoveryCapsCache* base,
                                              XmppJid* jid,
                                              const gchar* feature,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	DinoCapsCacheImpl * self;
	DinoCapsCacheImplHasEntityFeatureData* _data_;
	DinoCapsCacheImpl* _tmp0_;
	XmppJid* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (jid != NULL);
	g_return_if_fail (feature != NULL);
	self = (DinoCapsCacheImpl*) base;
	_data_ = g_slice_new0 (DinoCapsCacheImplHasEntityFeatureData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_caps_cache_impl_real_has_entity_feature_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp1_;
	_tmp2_ = g_strdup (feature);
	_g_free0 (_data_->feature);
	_data_->feature = _tmp2_;
	dino_caps_cache_impl_real_has_entity_feature_co (_data_);
}

static gboolean
dino_caps_cache_impl_has_entity_feature_finish (XmppXepServiceDiscoveryCapsCache* base,
                                                GAsyncResult* _res_)
{
	gboolean result;
	DinoCapsCacheImplHasEntityFeatureData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
dino_caps_cache_impl_has_entity_feature_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_)
{
	DinoCapsCacheImplHasEntityFeatureData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_caps_cache_impl_real_has_entity_feature_co (_data_);
}

static gboolean
dino_caps_cache_impl_real_has_entity_feature_co (DinoCapsCacheImplHasEntityFeatureData* _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->entity_info;
	_data_->_tmp1_ = _data_->self->priv->account;
	_data_->_state_ = 1;
	dino_entity_info_has_feature (_data_->_tmp0_, _data_->_tmp1_, _data_->jid, _data_->feature, dino_caps_cache_impl_has_entity_feature_ready, _data_);
	return FALSE;
	_state_1:
	_data_->result = dino_entity_info_has_feature_finish (_data_->_tmp0_, _data_->_res_);
	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_caps_cache_impl_real_get_entity_identities_data_free (gpointer _data)
{
	DinoCapsCacheImplGetEntityIdentitiesData* _data_;
	_data_ = _data;
	_xmpp_jid_unref0 (_data_->jid);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoCapsCacheImplGetEntityIdentitiesData, _data_);
}

static void
dino_caps_cache_impl_real_get_entity_identities (XmppXepServiceDiscoveryCapsCache* base,
                                                 XmppJid* jid,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_)
{
	DinoCapsCacheImpl * self;
	DinoCapsCacheImplGetEntityIdentitiesData* _data_;
	DinoCapsCacheImpl* _tmp0_;
	XmppJid* _tmp1_;
	g_return_if_fail (jid != NULL);
	self = (DinoCapsCacheImpl*) base;
	_data_ = g_slice_new0 (DinoCapsCacheImplGetEntityIdentitiesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_caps_cache_impl_real_get_entity_identities_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp1_;
	dino_caps_cache_impl_real_get_entity_identities_co (_data_);
}

static GeeSet*
dino_caps_cache_impl_get_entity_identities_finish (XmppXepServiceDiscoveryCapsCache* base,
                                                   GAsyncResult* _res_)
{
	GeeSet* result;
	DinoCapsCacheImplGetEntityIdentitiesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dino_caps_cache_impl_get_entity_identities_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_)
{
	DinoCapsCacheImplGetEntityIdentitiesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_caps_cache_impl_real_get_entity_identities_co (_data_);
}

static gboolean
dino_caps_cache_impl_real_get_entity_identities_co (DinoCapsCacheImplGetEntityIdentitiesData* _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->entity_info;
	_data_->_tmp1_ = _data_->self->priv->account;
	_data_->_state_ = 1;
	dino_entity_info_get_identities (_data_->_tmp0_, _data_->_tmp1_, _data_->jid, dino_caps_cache_impl_get_entity_identities_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = dino_entity_info_get_identities_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp2_;
	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_caps_cache_impl_class_init (DinoCapsCacheImplClass * klass,
                                 gpointer klass_data)
{
	dino_caps_cache_impl_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoCapsCacheImpl_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dino_caps_cache_impl_finalize;
}

static void
dino_caps_cache_impl_xmpp_xep_service_discovery_caps_cache_interface_init (XmppXepServiceDiscoveryCapsCacheIface * iface,
                                                                           gpointer iface_data)
{
	dino_caps_cache_impl_xmpp_xep_service_discovery_caps_cache_parent_iface = g_type_interface_peek_parent (iface);
	iface->has_entity_feature = (void (*) (XmppXepServiceDiscoveryCapsCache*, XmppJid*, const gchar*, GAsyncReadyCallback, gpointer)) dino_caps_cache_impl_real_has_entity_feature;
	iface->has_entity_feature_finish = (gboolean (*) (XmppXepServiceDiscoveryCapsCache*, GAsyncResult*)) dino_caps_cache_impl_has_entity_feature_finish;
	iface->get_entity_identities = (void (*) (XmppXepServiceDiscoveryCapsCache*, XmppJid*, GAsyncReadyCallback, gpointer)) dino_caps_cache_impl_real_get_entity_identities;
	iface->get_entity_identities_finish = (GeeSet* (*) (XmppXepServiceDiscoveryCapsCache*, GAsyncResult*)) dino_caps_cache_impl_get_entity_identities_finish;
}

static void
dino_caps_cache_impl_instance_init (DinoCapsCacheImpl * self,
                                    gpointer klass)
{
	self->priv = dino_caps_cache_impl_get_instance_private (self);
}

static void
dino_caps_cache_impl_finalize (GObject * obj)
{
	DinoCapsCacheImpl * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_CAPS_CACHE_IMPL, DinoCapsCacheImpl);
	_g_object_unref0 (self->priv->account);
	_g_object_unref0 (self->priv->entity_info);
	G_OBJECT_CLASS (dino_caps_cache_impl_parent_class)->finalize (obj);
}

static GType
dino_caps_cache_impl_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoCapsCacheImplClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_caps_cache_impl_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoCapsCacheImpl), 0, (GInstanceInitFunc) dino_caps_cache_impl_instance_init, NULL };
	static const GInterfaceInfo xmpp_xep_service_discovery_caps_cache_info = { (GInterfaceInitFunc) dino_caps_cache_impl_xmpp_xep_service_discovery_caps_cache_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_caps_cache_impl_type_id;
	dino_caps_cache_impl_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoCapsCacheImpl", &g_define_type_info, 0);
	g_type_add_interface_static (dino_caps_cache_impl_type_id, XMPP_XEP_SERVICE_DISCOVERY_TYPE_CAPS_CACHE, &xmpp_xep_service_discovery_caps_cache_info);
	DinoCapsCacheImpl_private_offset = g_type_add_instance_private (dino_caps_cache_impl_type_id, sizeof (DinoCapsCacheImplPrivate));
	return dino_caps_cache_impl_type_id;
}

GType
dino_caps_cache_impl_get_type (void)
{
	static volatile gsize dino_caps_cache_impl_type_id__once = 0;
	if (g_once_init_enter (&dino_caps_cache_impl_type_id__once)) {
		GType dino_caps_cache_impl_type_id;
		dino_caps_cache_impl_type_id = dino_caps_cache_impl_get_type_once ();
		g_once_init_leave (&dino_caps_cache_impl_type_id__once, dino_caps_cache_impl_type_id);
	}
	return dino_caps_cache_impl_type_id__once;
}

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

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

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

