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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "xmpp-vala.h"
#include <glib-object.h>
#include <gee.h>

#define XMPP_XEP_ENTITY_CAPABILITIES_NS_URI "http://jabber.org/protocol/caps"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	XMPP_XEP_ENTITY_CAPABILITIES_MODULE_0_PROPERTY,
	XMPP_XEP_ENTITY_CAPABILITIES_MODULE_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_entity_capabilities_module_properties[XMPP_XEP_ENTITY_CAPABILITIES_MODULE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _xmpp_xep_data_forms_data_form_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_data_forms_data_form_unref (var), NULL)))
#define _xmpp_xep_service_discovery_identity_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_service_discovery_identity_unref (var), NULL)))
#define _g_checksum_free0(var) ((var == NULL) ? NULL : (var = (g_checksum_free (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

struct _XmppXepEntityCapabilitiesModulePrivate {
	gchar* own_ver_hash;
	XmppXepEntityCapabilitiesStorage* storage;
};

VALA_EXTERN GRegex* xmpp_xep_entity_capabilities_sha1_base64_regex;
GRegex* xmpp_xep_entity_capabilities_sha1_base64_regex = NULL;
static gint XmppXepEntityCapabilitiesModule_private_offset;
static gpointer xmpp_xep_entity_capabilities_module_parent_class = NULL;
XmppModuleIdentity* xmpp_xep_entity_capabilities_module_IDENTITY = NULL;

VALA_EXTERN GRegex* xmpp_xep_entity_capabilities_get_sha1_base64_regex (void);
static gchar* xmpp_xep_entity_capabilities_module_get_own_hash (XmppXepEntityCapabilitiesModule* self,
                                                         XmppXmppStream* stream);
static void xmpp_xep_entity_capabilities_module_real_attach (XmppXmppStreamModule* base,
                                                      XmppXmppStream* stream);
static void xmpp_xep_entity_capabilities_module_on_pre_send_presence_stanza (XmppXepEntityCapabilitiesModule* self,
                                                                      XmppXmppStream* stream,
                                                                      XmppPresenceStanza* presence);
static void _xmpp_xep_entity_capabilities_module_on_pre_send_presence_stanza_xmpp_presence_module_pre_send_presence_stanza (XmppPresenceModule* _sender,
                                                                                                                     XmppXmppStream* stream,
                                                                                                                     XmppPresenceStanza* presence,
                                                                                                                     gpointer self);
static void xmpp_xep_entity_capabilities_module_real_detach (XmppXmppStreamModule* base,
                                                      XmppXmppStream* stream);
static gchar* xmpp_xep_entity_capabilities_module_real_get_ns (XmppXmppStreamModule* base);
static gchar* xmpp_xep_entity_capabilities_module_real_get_id (XmppXmppStreamModule* base);
static gint xmpp_xep_entity_capabilities_module_compare_identities (XmppXepServiceDiscoveryIdentity* a,
                                                             XmppXepServiceDiscoveryIdentity* b);
static gint _xmpp_xep_entity_capabilities_module_compare_identities_gcompare_data_func (gconstpointer a,
                                                                                 gconstpointer b,
                                                                                 gpointer self);
static gchar* xmpp_xep_entity_capabilities_module_sanitize (const gchar* s);
static gint xmpp_xep_entity_capabilities_module_compare_data_forms (XmppXepDataFormsDataForm* a,
                                                             XmppXepDataFormsDataForm* b);
static gint _xmpp_xep_entity_capabilities_module_compare_data_forms_gcompare_data_func (gconstpointer a,
                                                                                 gconstpointer b,
                                                                                 gpointer self);
static gint xmpp_xep_entity_capabilities_module_compare_data_fields (XmppXepDataFormsDataFormField* a,
                                                              XmppXepDataFormsDataFormField* b);
static gint _xmpp_xep_entity_capabilities_module_compare_data_fields_gcompare_data_func (gconstpointer a,
                                                                                  gconstpointer b,
                                                                                  gpointer self);
VALA_EXTERN GeeList* xmpp_xep_data_forms_data_form_field_get_values (XmppXepDataFormsDataFormField* self);
static void xmpp_xep_entity_capabilities_module_finalize (GObject * obj);
static GType xmpp_xep_entity_capabilities_module_get_type_once (void);
static GType xmpp_xep_entity_capabilities_storage_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GRegex* _tmp_regex_0 = NULL;

static inline GRegex*
_thread_safe_regex_init (GRegex** re,
                         const gchar * pattern,
                         GRegexCompileFlags compile_flags)
{
	if (g_once_init_enter ((volatile gsize*) re)) {
		GRegex* val = g_regex_new (pattern, compile_flags, 0, NULL);
		g_once_init_leave ((volatile gsize*) re, (gsize) val);
	}
	return *re;
}

static gpointer
_g_regex_ref0 (gpointer self)
{
	return self ? g_regex_ref (self) : NULL;
}

GRegex*
xmpp_xep_entity_capabilities_get_sha1_base64_regex (void)
{
	GRegex* _tmp0_;
	GRegex* _tmp2_;
	GRegex* _tmp3_;
	GRegex* result;
	_tmp0_ = xmpp_xep_entity_capabilities_sha1_base64_regex;
	if (_tmp0_ == NULL) {
		GRegex* _tmp1_;
		_tmp1_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_0, "^[A-Za-z0-9+\\/]{27}=$", 0));
		_g_regex_unref0 (xmpp_xep_entity_capabilities_sha1_base64_regex);
		xmpp_xep_entity_capabilities_sha1_base64_regex = _tmp1_;
	}
	_tmp2_ = xmpp_xep_entity_capabilities_sha1_base64_regex;
	_tmp3_ = _g_regex_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

gchar*
xmpp_xep_entity_capabilities_get_caps_hash (XmppPresenceStanza* presence)
{
	GRegex* sha1_base64_regex = NULL;
	GRegex* _tmp0_;
	XmppStanzaNode* c_node = NULL;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	gchar* ver_attribute = NULL;
	XmppStanzaNode* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	const gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (presence != NULL, NULL);
	_tmp0_ = xmpp_xep_entity_capabilities_get_sha1_base64_regex ();
	sha1_base64_regex = _tmp0_;
	_tmp1_ = ((XmppStanza*) presence)->stanza;
	_tmp2_ = xmpp_stanza_node_get_subnode (_tmp1_, "c", XMPP_XEP_ENTITY_CAPABILITIES_NS_URI, FALSE);
	c_node = _tmp2_;
	_tmp3_ = c_node;
	if (_tmp3_ == NULL) {
		result = NULL;
		_xmpp_stanza_entry_unref0 (c_node);
		_g_regex_unref0 (sha1_base64_regex);
		return result;
	}
	_tmp4_ = c_node;
	_tmp5_ = xmpp_stanza_node_get_attribute (_tmp4_, "ver", XMPP_XEP_ENTITY_CAPABILITIES_NS_URI);
	_tmp6_ = g_strdup (_tmp5_);
	ver_attribute = _tmp6_;
	_tmp8_ = ver_attribute;
	if (_tmp8_ == NULL) {
		_tmp7_ = TRUE;
	} else {
		GRegex* _tmp9_;
		const gchar* _tmp10_;
		_tmp9_ = sha1_base64_regex;
		_tmp10_ = ver_attribute;
		_tmp7_ = !g_regex_match (_tmp9_, _tmp10_, 0, NULL);
	}
	if (_tmp7_) {
		result = NULL;
		_g_free0 (ver_attribute);
		_xmpp_stanza_entry_unref0 (c_node);
		_g_regex_unref0 (sha1_base64_regex);
		return result;
	}
	result = ver_attribute;
	_xmpp_stanza_entry_unref0 (c_node);
	_g_regex_unref0 (sha1_base64_regex);
	return result;
}

gchar*
xmpp_xep_entity_capabilities_get_server_caps_hash (XmppXmppStream* stream)
{
	XmppStanzaNode* node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	gchar* ver_attribute = NULL;
	XmppStanzaNode* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (stream != NULL, NULL);
	_tmp0_ = xmpp_xmpp_stream_get_features (stream);
	_tmp1_ = _tmp0_;
	_tmp2_ = xmpp_stanza_node_get_subnode (_tmp1_, "c", XMPP_XEP_ENTITY_CAPABILITIES_NS_URI, FALSE);
	node = _tmp2_;
	_tmp3_ = node;
	if (_tmp3_ == NULL) {
		result = NULL;
		_xmpp_stanza_entry_unref0 (node);
		return result;
	}
	_tmp4_ = node;
	_tmp5_ = xmpp_stanza_node_get_attribute (_tmp4_, "ver", XMPP_XEP_ENTITY_CAPABILITIES_NS_URI);
	_tmp6_ = g_strdup (_tmp5_);
	ver_attribute = _tmp6_;
	_tmp7_ = ver_attribute;
	if (_tmp7_ == NULL) {
		result = NULL;
		_g_free0 (ver_attribute);
		_xmpp_stanza_entry_unref0 (node);
		return result;
	}
	result = ver_attribute;
	_xmpp_stanza_entry_unref0 (node);
	return result;
}

static inline gpointer
xmpp_xep_entity_capabilities_module_get_instance_private (XmppXepEntityCapabilitiesModule* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepEntityCapabilitiesModule_private_offset);
}

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

XmppXepEntityCapabilitiesModule*
xmpp_xep_entity_capabilities_module_construct (GType object_type,
                                               XmppXepEntityCapabilitiesStorage* storage)
{
	XmppXepEntityCapabilitiesModule * self = NULL;
	XmppXepEntityCapabilitiesStorage* _tmp0_;
	g_return_val_if_fail (storage != NULL, NULL);
	self = (XmppXepEntityCapabilitiesModule*) xmpp_xmpp_stream_module_construct (object_type);
	_tmp0_ = _g_object_ref0 (storage);
	_g_object_unref0 (self->priv->storage);
	self->priv->storage = _tmp0_;
	return self;
}

XmppXepEntityCapabilitiesModule*
xmpp_xep_entity_capabilities_module_new (XmppXepEntityCapabilitiesStorage* storage)
{
	return xmpp_xep_entity_capabilities_module_construct (XMPP_XEP_ENTITY_CAPABILITIES_TYPE_MODULE, storage);
}

static gchar*
xmpp_xep_entity_capabilities_module_get_own_hash (XmppXepEntityCapabilitiesModule* self,
                                                  XmppXmppStream* stream)
{
	const gchar* _tmp0_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stream != NULL, NULL);
	_tmp0_ = self->priv->own_ver_hash;
	if (_tmp0_ == NULL) {
		XmppFlagIdentity* _tmp1_;
		gpointer _tmp2_;
		XmppXepServiceDiscoveryFlag* _tmp3_;
		GeeSet* _tmp4_;
		GeeSet* _tmp5_;
		GeeSet* _tmp6_;
		XmppFlagIdentity* _tmp7_;
		gpointer _tmp8_;
		XmppXepServiceDiscoveryFlag* _tmp9_;
		GeeList* _tmp10_;
		GeeList* _tmp11_;
		GeeList* _tmp12_;
		GeeArrayList* _tmp13_;
		GeeArrayList* _tmp14_;
		gchar* _tmp15_;
		_tmp1_ = xmpp_xep_service_discovery_flag_IDENTITY;
		_tmp2_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
		_tmp3_ = (XmppXepServiceDiscoveryFlag*) _tmp2_;
		_tmp4_ = xmpp_xep_service_discovery_flag_get_own_identities (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = _tmp5_;
		_tmp7_ = xmpp_xep_service_discovery_flag_IDENTITY;
		_tmp8_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp7_);
		_tmp9_ = (XmppXepServiceDiscoveryFlag*) _tmp8_;
		_tmp10_ = xmpp_xep_service_discovery_flag_get_own_features (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = _tmp11_;
		_tmp13_ = gee_array_list_new (XMPP_XEP_DATA_FORMS_TYPE_DATA_FORM, (GBoxedCopyFunc) xmpp_xep_data_forms_data_form_ref, (GDestroyNotify) xmpp_xep_data_forms_data_form_unref, NULL, NULL, NULL);
		_tmp14_ = _tmp13_;
		_tmp15_ = xmpp_xep_entity_capabilities_module_compute_hash (_tmp6_, _tmp12_, (GeeList*) _tmp14_);
		_g_free0 (self->priv->own_ver_hash);
		self->priv->own_ver_hash = _tmp15_;
		_g_object_unref0 (_tmp14_);
		_g_object_unref0 (_tmp12_);
		_g_object_unref0 (_tmp9_);
		_g_object_unref0 (_tmp6_);
		_g_object_unref0 (_tmp3_);
	}
	_tmp16_ = self->priv->own_ver_hash;
	_tmp17_ = g_strdup (_tmp16_);
	result = _tmp17_;
	return result;
}

static void
_xmpp_xep_entity_capabilities_module_on_pre_send_presence_stanza_xmpp_presence_module_pre_send_presence_stanza (XmppPresenceModule* _sender,
                                                                                                                XmppXmppStream* stream,
                                                                                                                XmppPresenceStanza* presence,
                                                                                                                gpointer self)
{
	xmpp_xep_entity_capabilities_module_on_pre_send_presence_stanza ((XmppXepEntityCapabilitiesModule*) self, stream, presence);
}

static void
xmpp_xep_entity_capabilities_module_real_attach (XmppXmppStreamModule* base,
                                                 XmppXmppStream* stream)
{
	XmppXepEntityCapabilitiesModule * self;
	XmppModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppPresenceModule* _tmp2_;
	XmppModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	XmppXepServiceDiscoveryModule* _tmp5_;
	self = (XmppXepEntityCapabilitiesModule*) base;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_presence_module_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_module (stream, XMPP_PRESENCE_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppPresenceModule*) _tmp1_;
	g_signal_connect_object (_tmp2_, "pre-send-presence-stanza", (GCallback) _xmpp_xep_entity_capabilities_module_on_pre_send_presence_stanza_xmpp_presence_module_pre_send_presence_stanza, self, 0);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = xmpp_xep_service_discovery_module_IDENTITY;
	_tmp4_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp3_);
	_tmp5_ = (XmppXepServiceDiscoveryModule*) _tmp4_;
	xmpp_xep_service_discovery_module_add_feature (_tmp5_, stream, XMPP_XEP_ENTITY_CAPABILITIES_NS_URI);
	_g_object_unref0 (_tmp5_);
}

static void
xmpp_xep_entity_capabilities_module_real_detach (XmppXmppStreamModule* base,
                                                 XmppXmppStream* stream)
{
	XmppXepEntityCapabilitiesModule * self;
	XmppModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppPresenceModule* _tmp2_;
	guint _tmp3_;
	XmppModuleIdentity* _tmp4_;
	gpointer _tmp5_;
	XmppXepServiceDiscoveryModule* _tmp6_;
	self = (XmppXepEntityCapabilitiesModule*) base;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_presence_module_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_module (stream, XMPP_PRESENCE_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppPresenceModule*) _tmp1_;
	g_signal_parse_name ("pre-send-presence-stanza", XMPP_PRESENCE_TYPE_MODULE, &_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _xmpp_xep_entity_capabilities_module_on_pre_send_presence_stanza_xmpp_presence_module_pre_send_presence_stanza, self);
	_g_object_unref0 (_tmp2_);
	_tmp4_ = xmpp_xep_service_discovery_module_IDENTITY;
	_tmp5_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp4_);
	_tmp6_ = (XmppXepServiceDiscoveryModule*) _tmp5_;
	xmpp_xep_service_discovery_module_remove_feature (_tmp6_, stream, XMPP_XEP_ENTITY_CAPABILITIES_NS_URI);
	_g_object_unref0 (_tmp6_);
}

static gchar*
xmpp_xep_entity_capabilities_module_real_get_ns (XmppXmppStreamModule* base)
{
	XmppXepEntityCapabilitiesModule * self;
	gchar* _tmp0_;
	gchar* result;
	self = (XmppXepEntityCapabilitiesModule*) base;
	_tmp0_ = g_strdup (XMPP_XEP_ENTITY_CAPABILITIES_NS_URI);
	result = _tmp0_;
	return result;
}

static gchar*
xmpp_xep_entity_capabilities_module_real_get_id (XmppXmppStreamModule* base)
{
	XmppXepEntityCapabilitiesModule * self;
	XmppModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (XmppXepEntityCapabilitiesModule*) base;
	_tmp0_ = xmpp_xep_entity_capabilities_module_IDENTITY;
	_tmp1_ = xmpp_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

static void
xmpp_xep_entity_capabilities_module_on_pre_send_presence_stanza (XmppXepEntityCapabilitiesModule* self,
                                                                 XmppXmppStream* stream,
                                                                 XmppPresenceStanza* presence)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (presence != NULL);
	_tmp0_ = xmpp_stanza_get_type_ ((XmppStanza*) presence);
	_tmp1_ = _tmp0_;
	if (g_strcmp0 (_tmp1_, XMPP_PRESENCE_STANZA_TYPE_AVAILABLE) == 0) {
		XmppStanzaNode* _tmp2_;
		XmppStanzaNode* _tmp3_;
		XmppStanzaNode* _tmp4_;
		XmppStanzaNode* _tmp5_;
		XmppStanzaNode* _tmp6_;
		XmppStanzaNode* _tmp7_;
		XmppStanzaNode* _tmp8_;
		XmppStanzaNode* _tmp9_;
		XmppStanzaNode* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		XmppStanzaNode* _tmp13_;
		XmppStanzaNode* _tmp14_;
		XmppStanzaNode* _tmp15_;
		XmppStanzaNode* _tmp16_;
		_tmp2_ = ((XmppStanza*) presence)->stanza;
		_tmp3_ = xmpp_stanza_node_new_build ("c", XMPP_XEP_ENTITY_CAPABILITIES_NS_URI, NULL, NULL);
		_tmp4_ = _tmp3_;
		_tmp5_ = xmpp_stanza_node_add_self_xmlns (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = xmpp_stanza_node_put_attribute (_tmp6_, "hash", "sha-1", NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = xmpp_stanza_node_put_attribute (_tmp8_, "node", "https://dino.im", NULL);
		_tmp10_ = _tmp9_;
		_tmp11_ = xmpp_xep_entity_capabilities_module_get_own_hash (self, stream);
		_tmp12_ = _tmp11_;
		_tmp13_ = xmpp_stanza_node_put_attribute (_tmp10_, "ver", _tmp12_, NULL);
		_tmp14_ = _tmp13_;
		_tmp15_ = xmpp_stanza_node_put_node (_tmp2_, _tmp14_);
		_tmp16_ = _tmp15_;
		_xmpp_stanza_entry_unref0 (_tmp16_);
		_xmpp_stanza_entry_unref0 (_tmp14_);
		_g_free0 (_tmp12_);
		_xmpp_stanza_entry_unref0 (_tmp10_);
		_xmpp_stanza_entry_unref0 (_tmp8_);
		_xmpp_stanza_entry_unref0 (_tmp6_);
		_xmpp_stanza_entry_unref0 (_tmp4_);
	}
}

gchar*
xmpp_xep_entity_capabilities_module_compute_hash_for_info_result (XmppXepServiceDiscoveryInfoResult* info_result)
{
	GeeList* data_forms = NULL;
	GeeArrayList* _tmp0_;
	GeeSet* _tmp16_;
	GeeSet* _tmp17_;
	GeeSet* _tmp18_;
	GeeList* _tmp19_;
	GeeList* _tmp20_;
	GeeList* _tmp21_;
	GeeList* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* result;
	g_return_val_if_fail (info_result != NULL, NULL);
	_tmp0_ = gee_array_list_new (XMPP_XEP_DATA_FORMS_TYPE_DATA_FORM, (GBoxedCopyFunc) xmpp_xep_data_forms_data_form_ref, (GDestroyNotify) xmpp_xep_data_forms_data_form_unref, NULL, NULL, NULL);
	data_forms = (GeeList*) _tmp0_;
	{
		GeeList* _node_list = NULL;
		XmppIqStanza* _tmp1_;
		XmppIqStanza* _tmp2_;
		XmppStanzaNode* _tmp3_;
		GeeList* _tmp4_;
		gint _node_size = 0;
		GeeList* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		gint _node_index = 0;
		_tmp1_ = xmpp_xep_service_discovery_info_result_get_iq (info_result);
		_tmp2_ = _tmp1_;
		_tmp3_ = ((XmppStanza*) _tmp2_)->stanza;
		_tmp4_ = xmpp_stanza_node_get_deep_subnodes (_tmp3_, XMPP_XEP_SERVICE_DISCOVERY_NS_URI_INFO ":query", XMPP_XEP_DATA_FORMS_NS_URI ":x", NULL);
		_node_list = _tmp4_;
		_tmp5_ = _node_list;
		_tmp6_ = gee_collection_get_size ((GeeCollection*) _tmp5_);
		_tmp7_ = _tmp6_;
		_node_size = _tmp7_;
		_node_index = -1;
		while (TRUE) {
			gint _tmp8_;
			gint _tmp9_;
			XmppStanzaNode* node = NULL;
			GeeList* _tmp10_;
			gpointer _tmp11_;
			GeeList* _tmp12_;
			XmppStanzaNode* _tmp13_;
			XmppXepDataFormsDataForm* _tmp14_;
			XmppXepDataFormsDataForm* _tmp15_;
			_node_index = _node_index + 1;
			_tmp8_ = _node_index;
			_tmp9_ = _node_size;
			if (!(_tmp8_ < _tmp9_)) {
				break;
			}
			_tmp10_ = _node_list;
			_tmp11_ = gee_list_get (_tmp10_, _node_index);
			node = (XmppStanzaNode*) _tmp11_;
			_tmp12_ = data_forms;
			_tmp13_ = node;
			_tmp14_ = xmpp_xep_data_forms_data_form_create_from_node (_tmp13_);
			_tmp15_ = _tmp14_;
			gee_collection_add ((GeeCollection*) _tmp12_, _tmp15_);
			_xmpp_xep_data_forms_data_form_unref0 (_tmp15_);
			_xmpp_stanza_entry_unref0 (node);
		}
		_g_object_unref0 (_node_list);
	}
	_tmp16_ = xmpp_xep_service_discovery_info_result_get_identities (info_result);
	_tmp17_ = _tmp16_;
	_tmp18_ = _tmp17_;
	_tmp19_ = xmpp_xep_service_discovery_info_result_get_features (info_result);
	_tmp20_ = _tmp19_;
	_tmp21_ = _tmp20_;
	_tmp22_ = data_forms;
	_tmp23_ = xmpp_xep_entity_capabilities_module_compute_hash (_tmp18_, _tmp21_, _tmp22_);
	_tmp24_ = _tmp23_;
	_g_object_unref0 (_tmp21_);
	_g_object_unref0 (_tmp18_);
	result = _tmp24_;
	_g_object_unref0 (data_forms);
	return result;
}

static gint
_xmpp_xep_entity_capabilities_module_compare_identities_gcompare_data_func (gconstpointer a,
                                                                            gconstpointer b,
                                                                            gpointer self)
{
	gint result;
	result = xmpp_xep_entity_capabilities_module_compare_identities ((XmppXepServiceDiscoveryIdentity*) a, (XmppXepServiceDiscoveryIdentity*) b);
	return result;
}

static gint
_xmpp_xep_entity_capabilities_module_compare_data_forms_gcompare_data_func (gconstpointer a,
                                                                            gconstpointer b,
                                                                            gpointer self)
{
	gint result;
	result = xmpp_xep_entity_capabilities_module_compare_data_forms ((XmppXepDataFormsDataForm*) a, (XmppXepDataFormsDataForm*) b);
	return result;
}

static gint
_xmpp_xep_entity_capabilities_module_compare_data_fields_gcompare_data_func (gconstpointer a,
                                                                             gconstpointer b,
                                                                             gpointer self)
{
	gint result;
	result = xmpp_xep_entity_capabilities_module_compare_data_fields ((XmppXepDataFormsDataFormField*) a, (XmppXepDataFormsDataFormField*) b);
	return result;
}

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

gchar*
xmpp_xep_entity_capabilities_module_compute_hash (GeeSet* identities_set,
                                                  GeeList* features,
                                                  GeeList* data_forms)
{
	GeeArrayList* identities = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp7_;
	GString* sb = NULL;
	GString* _tmp8_;
	GChecksum* c = NULL;
	GChecksum* _tmp103_;
	GString* _tmp104_;
	const gchar* _tmp105_;
	guint8* _tmp106_;
	gint _tmp106__length1;
	gint _tmp107_ = 0;
	guint8* _tmp108_;
	gint _tmp108__length1;
	gsize size = 0UL;
	guint8* buf = NULL;
	guint8* _tmp109_;
	gint buf_length1;
	gint _buf_size_;
	gchar* _tmp110_;
	gchar* result;
	g_return_val_if_fail (identities_set != NULL, NULL);
	g_return_val_if_fail (features != NULL, NULL);
	g_return_val_if_fail (data_forms != NULL, NULL);
	_tmp0_ = gee_array_list_new (XMPP_XEP_SERVICE_DISCOVERY_TYPE_IDENTITY, (GBoxedCopyFunc) xmpp_xep_service_discovery_identity_ref, (GDestroyNotify) xmpp_xep_service_discovery_identity_unref, NULL, NULL, NULL);
	identities = _tmp0_;
	{
		GeeIterator* _identity_it = NULL;
		GeeIterator* _tmp1_;
		_tmp1_ = gee_iterable_iterator ((GeeIterable*) identities_set);
		_identity_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			XmppXepServiceDiscoveryIdentity* identity = NULL;
			GeeIterator* _tmp3_;
			gpointer _tmp4_;
			GeeArrayList* _tmp5_;
			XmppXepServiceDiscoveryIdentity* _tmp6_;
			_tmp2_ = _identity_it;
			if (!gee_iterator_next (_tmp2_)) {
				break;
			}
			_tmp3_ = _identity_it;
			_tmp4_ = gee_iterator_get (_tmp3_);
			identity = (XmppXepServiceDiscoveryIdentity*) _tmp4_;
			_tmp5_ = identities;
			_tmp6_ = identity;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp5_, _tmp6_);
			_xmpp_xep_service_discovery_identity_unref0 (identity);
		}
		_g_object_unref0 (_identity_it);
	}
	_tmp7_ = identities;
	gee_list_sort ((GeeList*) _tmp7_, _xmpp_xep_entity_capabilities_module_compare_identities_gcompare_data_func, NULL, NULL);
	gee_list_sort (features, NULL, NULL, NULL);
	_tmp8_ = g_string_new ("");
	sb = _tmp8_;
	{
		GeeArrayList* _identity_list = NULL;
		GeeArrayList* _tmp9_;
		gint _identity_size = 0;
		GeeArrayList* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		gint _identity_index = 0;
		_tmp9_ = identities;
		_identity_list = _tmp9_;
		_tmp10_ = _identity_list;
		_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		_identity_size = _tmp12_;
		_identity_index = -1;
		while (TRUE) {
			gint _tmp13_;
			gint _tmp14_;
			XmppXepServiceDiscoveryIdentity* identity = NULL;
			GeeArrayList* _tmp15_;
			gpointer _tmp16_;
			GString* _tmp17_;
			XmppXepServiceDiscoveryIdentity* _tmp18_;
			const gchar* _tmp19_;
			const gchar* _tmp20_;
			gchar* _tmp21_;
			gchar* _tmp22_;
			GString* _tmp23_;
			GString* _tmp24_;
			XmppXepServiceDiscoveryIdentity* _tmp25_;
			const gchar* _tmp26_;
			const gchar* _tmp27_;
			gchar* _tmp28_;
			gchar* _tmp29_;
			GString* _tmp30_;
			XmppXepServiceDiscoveryIdentity* _tmp31_;
			const gchar* _tmp32_;
			const gchar* _tmp33_;
			GString* _tmp40_;
			_identity_index = _identity_index + 1;
			_tmp13_ = _identity_index;
			_tmp14_ = _identity_size;
			if (!(_tmp13_ < _tmp14_)) {
				break;
			}
			_tmp15_ = _identity_list;
			_tmp16_ = gee_abstract_list_get ((GeeAbstractList*) _tmp15_, _identity_index);
			identity = (XmppXepServiceDiscoveryIdentity*) _tmp16_;
			_tmp17_ = sb;
			_tmp18_ = identity;
			_tmp19_ = xmpp_xep_service_discovery_identity_get_category (_tmp18_);
			_tmp20_ = _tmp19_;
			_tmp21_ = xmpp_xep_entity_capabilities_module_sanitize (_tmp20_);
			_tmp22_ = _tmp21_;
			_tmp23_ = g_string_append (_tmp17_, _tmp22_);
			_tmp24_ = g_string_append (_tmp23_, "/");
			_tmp25_ = identity;
			_tmp26_ = xmpp_xep_service_discovery_identity_get_type_ (_tmp25_);
			_tmp27_ = _tmp26_;
			_tmp28_ = xmpp_xep_entity_capabilities_module_sanitize (_tmp27_);
			_tmp29_ = _tmp28_;
			_tmp30_ = g_string_append (_tmp24_, _tmp29_);
			g_string_append (_tmp30_, "//");
			_g_free0 (_tmp29_);
			_g_free0 (_tmp22_);
			_tmp31_ = identity;
			_tmp32_ = xmpp_xep_service_discovery_identity_get_name (_tmp31_);
			_tmp33_ = _tmp32_;
			if (_tmp33_ != NULL) {
				GString* _tmp34_;
				XmppXepServiceDiscoveryIdentity* _tmp35_;
				const gchar* _tmp36_;
				const gchar* _tmp37_;
				gchar* _tmp38_;
				gchar* _tmp39_;
				_tmp34_ = sb;
				_tmp35_ = identity;
				_tmp36_ = xmpp_xep_service_discovery_identity_get_name (_tmp35_);
				_tmp37_ = _tmp36_;
				_tmp38_ = xmpp_xep_entity_capabilities_module_sanitize (_tmp37_);
				_tmp39_ = _tmp38_;
				g_string_append (_tmp34_, _tmp39_);
				_g_free0 (_tmp39_);
			}
			_tmp40_ = sb;
			g_string_append (_tmp40_, "<");
			_xmpp_xep_service_discovery_identity_unref0 (identity);
		}
	}
	{
		GeeList* _feature_list = NULL;
		gint _feature_size = 0;
		GeeList* _tmp41_;
		gint _tmp42_;
		gint _tmp43_;
		gint _feature_index = 0;
		_feature_list = features;
		_tmp41_ = _feature_list;
		_tmp42_ = gee_collection_get_size ((GeeCollection*) _tmp41_);
		_tmp43_ = _tmp42_;
		_feature_size = _tmp43_;
		_feature_index = -1;
		while (TRUE) {
			gint _tmp44_;
			gint _tmp45_;
			gchar* feature = NULL;
			GeeList* _tmp46_;
			gpointer _tmp47_;
			GString* _tmp48_;
			const gchar* _tmp49_;
			gchar* _tmp50_;
			gchar* _tmp51_;
			GString* _tmp52_;
			_feature_index = _feature_index + 1;
			_tmp44_ = _feature_index;
			_tmp45_ = _feature_size;
			if (!(_tmp44_ < _tmp45_)) {
				break;
			}
			_tmp46_ = _feature_list;
			_tmp47_ = gee_list_get (_tmp46_, _feature_index);
			feature = (gchar*) _tmp47_;
			_tmp48_ = sb;
			_tmp49_ = feature;
			_tmp50_ = xmpp_xep_entity_capabilities_module_sanitize (_tmp49_);
			_tmp51_ = _tmp50_;
			_tmp52_ = g_string_append (_tmp48_, _tmp51_);
			g_string_append (_tmp52_, "<");
			_g_free0 (_tmp51_);
			_g_free0 (feature);
		}
	}
	gee_list_sort (data_forms, _xmpp_xep_entity_capabilities_module_compare_data_forms_gcompare_data_func, NULL, NULL);
	{
		GeeList* _data_form_list = NULL;
		gint _data_form_size = 0;
		GeeList* _tmp53_;
		gint _tmp54_;
		gint _tmp55_;
		gint _data_form_index = 0;
		_data_form_list = data_forms;
		_tmp53_ = _data_form_list;
		_tmp54_ = gee_collection_get_size ((GeeCollection*) _tmp53_);
		_tmp55_ = _tmp54_;
		_data_form_size = _tmp55_;
		_data_form_index = -1;
		while (TRUE) {
			gint _tmp56_;
			gint _tmp57_;
			XmppXepDataFormsDataForm* data_form = NULL;
			GeeList* _tmp58_;
			gpointer _tmp59_;
			XmppXepDataFormsDataForm* _tmp60_;
			const gchar* _tmp61_;
			GString* _tmp62_;
			XmppXepDataFormsDataForm* _tmp63_;
			const gchar* _tmp64_;
			gchar* _tmp65_;
			gchar* _tmp66_;
			GString* _tmp67_;
			XmppXepDataFormsDataForm* _tmp68_;
			GeeList* _tmp69_;
			_data_form_index = _data_form_index + 1;
			_tmp56_ = _data_form_index;
			_tmp57_ = _data_form_size;
			if (!(_tmp56_ < _tmp57_)) {
				break;
			}
			_tmp58_ = _data_form_list;
			_tmp59_ = gee_list_get (_tmp58_, _data_form_index);
			data_form = (XmppXepDataFormsDataForm*) _tmp59_;
			_tmp60_ = data_form;
			_tmp61_ = _tmp60_->form_type;
			if (_tmp61_ == NULL) {
				_xmpp_xep_data_forms_data_form_unref0 (data_form);
				continue;
			}
			_tmp62_ = sb;
			_tmp63_ = data_form;
			_tmp64_ = _tmp63_->form_type;
			_tmp65_ = xmpp_xep_entity_capabilities_module_sanitize (_tmp64_);
			_tmp66_ = _tmp65_;
			_tmp67_ = g_string_append (_tmp62_, _tmp66_);
			g_string_append (_tmp67_, "<");
			_g_free0 (_tmp66_);
			_tmp68_ = data_form;
			_tmp69_ = _tmp68_->fields;
			gee_list_sort (_tmp69_, _xmpp_xep_entity_capabilities_module_compare_data_fields_gcompare_data_func, NULL, NULL);
			{
				GeeList* _field_list = NULL;
				XmppXepDataFormsDataForm* _tmp70_;
				GeeList* _tmp71_;
				gint _field_size = 0;
				GeeList* _tmp72_;
				gint _tmp73_;
				gint _tmp74_;
				gint _field_index = 0;
				_tmp70_ = data_form;
				_tmp71_ = _tmp70_->fields;
				_field_list = _tmp71_;
				_tmp72_ = _field_list;
				_tmp73_ = gee_collection_get_size ((GeeCollection*) _tmp72_);
				_tmp74_ = _tmp73_;
				_field_size = _tmp74_;
				_field_index = -1;
				while (TRUE) {
					gint _tmp75_;
					gint _tmp76_;
					XmppXepDataFormsDataFormField* field = NULL;
					GeeList* _tmp77_;
					gpointer _tmp78_;
					GString* _tmp79_;
					XmppXepDataFormsDataFormField* _tmp80_;
					const gchar* _tmp81_;
					const gchar* _tmp82_;
					gchar* _tmp83_;
					gchar* _tmp84_;
					GString* _tmp85_;
					GeeList* values = NULL;
					XmppXepDataFormsDataFormField* _tmp86_;
					GeeList* _tmp87_;
					GeeList* _tmp88_;
					_field_index = _field_index + 1;
					_tmp75_ = _field_index;
					_tmp76_ = _field_size;
					if (!(_tmp75_ < _tmp76_)) {
						break;
					}
					_tmp77_ = _field_list;
					_tmp78_ = gee_list_get (_tmp77_, _field_index);
					field = (XmppXepDataFormsDataFormField*) _tmp78_;
					_tmp79_ = sb;
					_tmp80_ = field;
					_tmp81_ = xmpp_xep_data_forms_data_form_field_get_var (_tmp80_);
					_tmp82_ = _tmp81_;
					_tmp83_ = xmpp_xep_entity_capabilities_module_sanitize (_tmp82_);
					_tmp84_ = _tmp83_;
					_tmp85_ = g_string_append (_tmp79_, _tmp84_);
					g_string_append (_tmp85_, "<");
					_g_free0 (_tmp84_);
					_tmp86_ = field;
					_tmp87_ = xmpp_xep_data_forms_data_form_field_get_values (_tmp86_);
					values = _tmp87_;
					_tmp88_ = values;
					gee_list_sort (_tmp88_, NULL, NULL, NULL);
					{
						GeeList* _value_list = NULL;
						GeeList* _tmp89_;
						gint _value_size = 0;
						GeeList* _tmp90_;
						gint _tmp91_;
						gint _tmp92_;
						gint _value_index = 0;
						_tmp89_ = values;
						_value_list = _tmp89_;
						_tmp90_ = _value_list;
						_tmp91_ = gee_collection_get_size ((GeeCollection*) _tmp90_);
						_tmp92_ = _tmp91_;
						_value_size = _tmp92_;
						_value_index = -1;
						while (TRUE) {
							gint _tmp93_;
							gint _tmp94_;
							gchar* value = NULL;
							GeeList* _tmp95_;
							gpointer _tmp96_;
							const gchar* _tmp97_ = NULL;
							const gchar* _tmp98_;
							GString* _tmp99_;
							gchar* _tmp100_;
							gchar* _tmp101_;
							GString* _tmp102_;
							_value_index = _value_index + 1;
							_tmp93_ = _value_index;
							_tmp94_ = _value_size;
							if (!(_tmp93_ < _tmp94_)) {
								break;
							}
							_tmp95_ = _value_list;
							_tmp96_ = gee_list_get (_tmp95_, _value_index);
							value = (gchar*) _tmp96_;
							_tmp98_ = value;
							_tmp97_ = _tmp98_;
							if (_tmp97_ == NULL) {
								_tmp97_ = "";
							}
							_tmp99_ = sb;
							_tmp100_ = xmpp_xep_entity_capabilities_module_sanitize (_tmp97_);
							_tmp101_ = _tmp100_;
							_tmp102_ = g_string_append (_tmp99_, _tmp101_);
							g_string_append (_tmp102_, "<");
							_g_free0 (_tmp101_);
							_g_free0 (value);
						}
					}
					_g_object_unref0 (values);
					_g_object_unref0 (field);
				}
			}
			_xmpp_xep_data_forms_data_form_unref0 (data_form);
		}
	}
	_tmp103_ = g_checksum_new (G_CHECKSUM_SHA1);
	c = _tmp103_;
	_tmp104_ = sb;
	_tmp105_ = _tmp104_->str;
	_tmp106_ = string_get_data (_tmp105_, &_tmp107_);
	_tmp106__length1 = _tmp107_;
	_tmp108_ = _tmp106_;
	_tmp108__length1 = _tmp106__length1;
	g_checksum_update (c, _tmp108_, (gsize) -1);
	size = (gsize) 20;
	_tmp109_ = g_new0 (guint8, size);
	buf = _tmp109_;
	buf_length1 = size;
	_buf_size_ = buf_length1;
	g_checksum_get_digest (c, buf, &size);
	_tmp110_ = g_base64_encode (buf, (gint) buf_length1);
	result = _tmp110_;
	buf = (g_free (buf), NULL);
	_g_checksum_free0 (c);
	_g_string_free0 (sb);
	_g_object_unref0 (identities);
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static gchar*
xmpp_xep_entity_capabilities_module_sanitize (const gchar* s)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (s != NULL, NULL);
	_tmp0_ = string_replace (s, "<", "&lt;");
	result = _tmp0_;
	return result;
}

static gint
xmpp_xep_entity_capabilities_module_compare_identities (XmppXepServiceDiscoveryIdentity* a,
                                                        XmppXepServiceDiscoveryIdentity* b)
{
	gint category_comp = 0;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gint type_comp = 0;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp0_ = xmpp_xep_service_discovery_identity_get_category (a);
	_tmp1_ = _tmp0_;
	_tmp2_ = xmpp_xep_service_discovery_identity_get_category (b);
	_tmp3_ = _tmp2_;
	category_comp = g_utf8_collate (_tmp1_, _tmp3_);
	if (category_comp != 0) {
		result = category_comp;
		return result;
	}
	_tmp4_ = xmpp_xep_service_discovery_identity_get_type_ (a);
	_tmp5_ = _tmp4_;
	_tmp6_ = xmpp_xep_service_discovery_identity_get_type_ (b);
	_tmp7_ = _tmp6_;
	type_comp = g_utf8_collate (_tmp5_, _tmp7_);
	if (type_comp != 0) {
		result = type_comp;
		return result;
	}
	result = 0;
	return result;
}

static gint
xmpp_xep_entity_capabilities_module_compare_data_forms (XmppXepDataFormsDataForm* a,
                                                        XmppXepDataFormsDataForm* b)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp1_ = a->form_type;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		_tmp2_ = b->form_type;
		_tmp0_ = _tmp2_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = a->form_type;
		_tmp4_ = b->form_type;
		result = g_utf8_collate (_tmp3_, _tmp4_);
		return result;
	}
	result = 0;
	return result;
}

static gint
xmpp_xep_entity_capabilities_module_compare_data_fields (XmppXepDataFormsDataFormField* a,
                                                         XmppXepDataFormsDataFormField* b)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp1_ = xmpp_xep_data_forms_data_form_field_get_var (a);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = xmpp_xep_data_forms_data_form_field_get_var (b);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp5_ = xmpp_xep_data_forms_data_form_field_get_var (a);
		_tmp6_ = _tmp5_;
		_tmp7_ = xmpp_xep_data_forms_data_form_field_get_var (b);
		_tmp8_ = _tmp7_;
		result = g_utf8_collate (_tmp6_, _tmp8_);
		return result;
	}
	result = 0;
	return result;
}

static void
xmpp_xep_entity_capabilities_module_class_init (XmppXepEntityCapabilitiesModuleClass * klass,
                                                gpointer klass_data)
{
	XmppModuleIdentity* _tmp0_;
	xmpp_xep_entity_capabilities_module_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXepEntityCapabilitiesModule_private_offset);
	((XmppXmppStreamModuleClass *) klass)->attach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) xmpp_xep_entity_capabilities_module_real_attach;
	((XmppXmppStreamModuleClass *) klass)->detach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) xmpp_xep_entity_capabilities_module_real_detach;
	((XmppXmppStreamModuleClass *) klass)->get_ns = (gchar* (*) (XmppXmppStreamModule*)) xmpp_xep_entity_capabilities_module_real_get_ns;
	((XmppXmppStreamModuleClass *) klass)->get_id = (gchar* (*) (XmppXmppStreamModule*)) xmpp_xep_entity_capabilities_module_real_get_id;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_entity_capabilities_module_finalize;
	_tmp0_ = xmpp_module_identity_new (XMPP_XEP_ENTITY_CAPABILITIES_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, XMPP_XEP_ENTITY_CAPABILITIES_NS_URI, "0115_entity_capabilities");
	xmpp_xep_entity_capabilities_module_IDENTITY = _tmp0_;
}

static void
xmpp_xep_entity_capabilities_module_instance_init (XmppXepEntityCapabilitiesModule * self,
                                                   gpointer klass)
{
	self->priv = xmpp_xep_entity_capabilities_module_get_instance_private (self);
}

static void
xmpp_xep_entity_capabilities_module_finalize (GObject * obj)
{
	XmppXepEntityCapabilitiesModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_ENTITY_CAPABILITIES_TYPE_MODULE, XmppXepEntityCapabilitiesModule);
	_g_free0 (self->priv->own_ver_hash);
	_g_object_unref0 (self->priv->storage);
	G_OBJECT_CLASS (xmpp_xep_entity_capabilities_module_parent_class)->finalize (obj);
}

static GType
xmpp_xep_entity_capabilities_module_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepEntityCapabilitiesModuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_entity_capabilities_module_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepEntityCapabilitiesModule), 0, (GInstanceInitFunc) xmpp_xep_entity_capabilities_module_instance_init, NULL };
	GType xmpp_xep_entity_capabilities_module_type_id;
	xmpp_xep_entity_capabilities_module_type_id = g_type_register_static (XMPP_TYPE_XMPP_STREAM_MODULE, "XmppXepEntityCapabilitiesModule", &g_define_type_info, 0);
	XmppXepEntityCapabilitiesModule_private_offset = g_type_add_instance_private (xmpp_xep_entity_capabilities_module_type_id, sizeof (XmppXepEntityCapabilitiesModulePrivate));
	return xmpp_xep_entity_capabilities_module_type_id;
}

GType
xmpp_xep_entity_capabilities_module_get_type (void)
{
	static volatile gsize xmpp_xep_entity_capabilities_module_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_entity_capabilities_module_type_id__once)) {
		GType xmpp_xep_entity_capabilities_module_type_id;
		xmpp_xep_entity_capabilities_module_type_id = xmpp_xep_entity_capabilities_module_get_type_once ();
		g_once_init_leave (&xmpp_xep_entity_capabilities_module_type_id__once, xmpp_xep_entity_capabilities_module_type_id);
	}
	return xmpp_xep_entity_capabilities_module_type_id__once;
}

void
xmpp_xep_entity_capabilities_storage_store_identities (XmppXepEntityCapabilitiesStorage* self,
                                                       const gchar* entity,
                                                       GeeSet* identities)
{
	XmppXepEntityCapabilitiesStorageIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = XMPP_XEP_ENTITY_CAPABILITIES_STORAGE_GET_INTERFACE (self);
	if (_iface_->store_identities) {
		_iface_->store_identities (self, entity, identities);
	}
}

void
xmpp_xep_entity_capabilities_storage_store_features (XmppXepEntityCapabilitiesStorage* self,
                                                     const gchar* entity,
                                                     GeeList* capabilities)
{
	XmppXepEntityCapabilitiesStorageIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = XMPP_XEP_ENTITY_CAPABILITIES_STORAGE_GET_INTERFACE (self);
	if (_iface_->store_features) {
		_iface_->store_features (self, entity, capabilities);
	}
}

XmppXepServiceDiscoveryIdentity*
xmpp_xep_entity_capabilities_storage_get_identities (XmppXepEntityCapabilitiesStorage* self,
                                                     const gchar* entity)
{
	XmppXepEntityCapabilitiesStorageIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = XMPP_XEP_ENTITY_CAPABILITIES_STORAGE_GET_INTERFACE (self);
	if (_iface_->get_identities) {
		return _iface_->get_identities (self, entity);
	}
	return NULL;
}

GeeList*
xmpp_xep_entity_capabilities_storage_get_features (XmppXepEntityCapabilitiesStorage* self,
                                                   const gchar* entity)
{
	XmppXepEntityCapabilitiesStorageIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = XMPP_XEP_ENTITY_CAPABILITIES_STORAGE_GET_INTERFACE (self);
	if (_iface_->get_features) {
		return _iface_->get_features (self, entity);
	}
	return NULL;
}

static void
xmpp_xep_entity_capabilities_storage_default_init (XmppXepEntityCapabilitiesStorageIface * iface,
                                                   gpointer iface_data)
{
}

static GType
xmpp_xep_entity_capabilities_storage_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepEntityCapabilitiesStorageIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_entity_capabilities_storage_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType xmpp_xep_entity_capabilities_storage_type_id;
	xmpp_xep_entity_capabilities_storage_type_id = g_type_register_static (G_TYPE_INTERFACE, "XmppXepEntityCapabilitiesStorage", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (xmpp_xep_entity_capabilities_storage_type_id, G_TYPE_OBJECT);
	return xmpp_xep_entity_capabilities_storage_type_id;
}

GType
xmpp_xep_entity_capabilities_storage_get_type (void)
{
	static volatile gsize xmpp_xep_entity_capabilities_storage_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_entity_capabilities_storage_type_id__once)) {
		GType xmpp_xep_entity_capabilities_storage_type_id;
		xmpp_xep_entity_capabilities_storage_type_id = xmpp_xep_entity_capabilities_storage_get_type_once ();
		g_once_init_leave (&xmpp_xep_entity_capabilities_storage_type_id__once, xmpp_xep_entity_capabilities_storage_type_id);
	}
	return xmpp_xep_entity_capabilities_storage_type_id__once;
}

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

