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

#include "xmpp-vala.h"
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gio/gio.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  {
	XMPP_XEP_SERVICE_DISCOVERY_MODULE_0_PROPERTY,
	XMPP_XEP_SERVICE_DISCOVERY_MODULE_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_service_discovery_module_properties[XMPP_XEP_SERVICE_DISCOVERY_MODULE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_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_free0(var) (var = (g_free (var), NULL))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
typedef struct _XmppXepServiceDiscoveryModuleHasEntityFeatureData XmppXepServiceDiscoveryModuleHasEntityFeatureData;
typedef struct _XmppXepServiceDiscoveryModuleGetEntityIdentitiesData XmppXepServiceDiscoveryModuleGetEntityIdentitiesData;
#define _xmpp_xep_service_discovery_info_result_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_service_discovery_info_result_unref (var), NULL)))
#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
#define _gee_promise_unref0(var) ((var == NULL) ? NULL : (var = (gee_promise_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _XmppXepServiceDiscoveryModuleRequestInfoData XmppXepServiceDiscoveryModuleRequestInfoData;
#define _xmpp_xep_service_discovery_items_result_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_service_discovery_items_result_unref (var), NULL)))
typedef struct _XmppXepServiceDiscoveryModuleRequestItemsData XmppXepServiceDiscoveryModuleRequestItemsData;
typedef struct _XmppXepServiceDiscoveryModuleOnIqGetData XmppXepServiceDiscoveryModuleOnIqGetData;

struct _XmppXepServiceDiscoveryModulePrivate {
	GeeHashMap* active_info_requests;
};

struct _XmppXepServiceDiscoveryModuleHasEntityFeatureData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepServiceDiscoveryModule* self;
	XmppXmppStream* stream;
	XmppJid* jid;
	gchar* feature;
	gboolean result;
	XmppXepServiceDiscoveryCapsCache* _tmp0_;
};

struct _XmppXepServiceDiscoveryModuleGetEntityIdentitiesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepServiceDiscoveryModule* self;
	XmppXmppStream* stream;
	XmppJid* jid;
	GeeSet* result;
	XmppXepServiceDiscoveryCapsCache* _tmp0_;
	GeeSet* _tmp1_;
};

struct _XmppXepServiceDiscoveryModuleRequestInfoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepServiceDiscoveryModule* self;
	XmppXmppStream* stream;
	XmppJid* jid;
	XmppXepServiceDiscoveryInfoResult* result;
	GeeFuture* future;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GeeFuture* _tmp2_;
	GeePromise* promise;
	GeePromise* _tmp3_;
	GeePromise* _tmp4_;
	GeeFuture* _tmp5_;
	GeeFuture* _tmp6_;
	GeeFuture* _tmp7_;
	GeeHashMap* _tmp8_;
	GeeFuture* _tmp9_;
	XmppIqStanza* iq;
	XmppStanzaNode* _tmp10_;
	XmppStanzaNode* _tmp11_;
	XmppStanzaNode* _tmp12_;
	XmppStanzaNode* _tmp13_;
	XmppJid* _tmp14_;
	XmppIqStanza* _tmp15_;
	XmppIqStanza* _tmp16_;
	XmppIqStanza* iq_response;
	XmppModuleIdentity* _tmp17_;
	gpointer _tmp18_;
	XmppIqModule* _tmp19_;
	XmppIqStanza* _tmp20_;
	XmppIqStanza* _tmp21_;
	XmppIqStanza* _tmp22_;
	XmppXepServiceDiscoveryInfoResult* _result_;
	XmppIqStanza* _tmp23_;
	XmppXepServiceDiscoveryInfoResult* _tmp24_;
	GeePromise* _tmp25_;
	XmppXepServiceDiscoveryInfoResult* _tmp26_;
	XmppXepServiceDiscoveryInfoResult* _tmp27_;
	GeeHashMap* _tmp28_;
	XmppXepServiceDiscoveryInfoResult* res;
	GeeFuture* _tmp29_;
	gconstpointer _tmp30_;
	XmppXepServiceDiscoveryInfoResult* _tmp31_;
	GError* _error_;
	GError* _tmp32_;
	const gchar* _tmp33_;
	GError* _inner_error0_;
};

struct _XmppXepServiceDiscoveryModuleRequestItemsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepServiceDiscoveryModule* self;
	XmppXmppStream* stream;
	XmppJid* jid;
	XmppXepServiceDiscoveryItemsResult* result;
	XmppStanzaNode* query_node;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppIqStanza* iq;
	XmppJid* _tmp4_;
	XmppIqStanza* _tmp5_;
	XmppIqStanza* iq_result;
	XmppModuleIdentity* _tmp6_;
	gpointer _tmp7_;
	XmppIqModule* _tmp8_;
	XmppIqStanza* _tmp9_;
	XmppIqStanza* _tmp10_;
	XmppXepServiceDiscoveryItemsResult* _result_;
	XmppXepServiceDiscoveryItemsResult* _tmp11_;
	GError* _inner_error0_;
};

struct _XmppXepServiceDiscoveryModuleOnIqGetData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepServiceDiscoveryModule* self;
	XmppXmppStream* stream;
	XmppIqStanza* iq;
	XmppStanzaNode* query_node;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
};

static gint XmppXepServiceDiscoveryModule_private_offset;
static gpointer xmpp_xep_service_discovery_module_parent_class = NULL;
XmppModuleIdentity* xmpp_xep_service_discovery_module_IDENTITY = NULL;
static XmppIqHandlerIface * xmpp_xep_service_discovery_module_xmpp_iq_handler_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 void xmpp_xep_service_discovery_module_has_entity_feature_data_free (gpointer _data);
static gboolean xmpp_xep_service_discovery_module_has_entity_feature_co (XmppXepServiceDiscoveryModuleHasEntityFeatureData* _data_);
static void xmpp_xep_service_discovery_module_has_entity_feature_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_);
static void xmpp_xep_service_discovery_module_get_entity_identities_data_free (gpointer _data);
static gboolean xmpp_xep_service_discovery_module_get_entity_identities_co (XmppXepServiceDiscoveryModuleGetEntityIdentitiesData* _data_);
static void xmpp_xep_service_discovery_module_get_entity_identities_ready (GObject* source_object,
                                                                    GAsyncResult* _res_,
                                                                    gpointer _user_data_);
static void xmpp_xep_service_discovery_module_request_info_data_free (gpointer _data);
static gboolean xmpp_xep_service_discovery_module_request_info_co (XmppXepServiceDiscoveryModuleRequestInfoData* _data_);
static void xmpp_xep_service_discovery_module_request_info_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_);
static void xmpp_xep_service_discovery_module_request_items_data_free (gpointer _data);
static gboolean xmpp_xep_service_discovery_module_request_items_co (XmppXepServiceDiscoveryModuleRequestItemsData* _data_);
static void xmpp_xep_service_discovery_module_request_items_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static void xmpp_xep_service_discovery_module_real_on_iq_get_data_free (gpointer _data);
static void xmpp_xep_service_discovery_module_real_on_iq_get (XmppIqHandler* base,
                                                       XmppXmppStream* stream,
                                                       XmppIqStanza* iq,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static gboolean xmpp_xep_service_discovery_module_real_on_iq_get_co (XmppXepServiceDiscoveryModuleOnIqGetData* _data_);
static void xmpp_xep_service_discovery_module_send_query_result (XmppXepServiceDiscoveryModule* self,
                                                          XmppXmppStream* stream,
                                                          XmppIqStanza* iq_request);
static void xmpp_xep_service_discovery_module_real_attach (XmppXmppStreamModule* base,
                                                    XmppXmppStream* stream);
static void xmpp_xep_service_discovery_module_real_detach (XmppXmppStreamModule* base,
                                                    XmppXmppStream* stream);
static gchar* xmpp_xep_service_discovery_module_real_get_ns (XmppXmppStreamModule* base);
static gchar* xmpp_xep_service_discovery_module_real_get_id (XmppXmppStreamModule* base);
static void xmpp_xep_service_discovery_module_finalize (GObject * obj);
static GType xmpp_xep_service_discovery_module_get_type_once (void);
static GType xmpp_xep_service_discovery_caps_cache_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
xmpp_xep_service_discovery_module_get_instance_private (XmppXepServiceDiscoveryModule* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepServiceDiscoveryModule_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;
}

XmppXepServiceDiscoveryModule*
xmpp_xep_service_discovery_module_construct_with_identity (GType object_type,
                                                           const gchar* category,
                                                           const gchar* type,
                                                           const gchar* name)
{
	XmppXepServiceDiscoveryModule * self = NULL;
	XmppXepServiceDiscoveryIdentity* _tmp0_;
	g_return_val_if_fail (category != NULL, NULL);
	g_return_val_if_fail (type != NULL, NULL);
	self = (XmppXepServiceDiscoveryModule*) xmpp_xmpp_stream_module_construct (object_type);
	_tmp0_ = xmpp_xep_service_discovery_identity_new (category, type, name);
	_xmpp_xep_service_discovery_identity_unref0 (self->own_identity);
	self->own_identity = _tmp0_;
	return self;
}

XmppXepServiceDiscoveryModule*
xmpp_xep_service_discovery_module_new_with_identity (const gchar* category,
                                                     const gchar* type,
                                                     const gchar* name)
{
	return xmpp_xep_service_discovery_module_construct_with_identity (XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE, category, type, name);
}

void
xmpp_xep_service_discovery_module_add_feature (XmppXepServiceDiscoveryModule* self,
                                               XmppXmppStream* stream,
                                               const gchar* feature)
{
	XmppFlagIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppXepServiceDiscoveryFlag* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (feature != NULL);
	_tmp0_ = xmpp_xep_service_discovery_flag_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppXepServiceDiscoveryFlag*) _tmp1_;
	xmpp_xep_service_discovery_flag_add_own_feature (_tmp2_, feature);
	_g_object_unref0 (_tmp2_);
}

void
xmpp_xep_service_discovery_module_remove_feature (XmppXepServiceDiscoveryModule* self,
                                                  XmppXmppStream* stream,
                                                  const gchar* feature)
{
	XmppXepServiceDiscoveryFlag* flag = NULL;
	XmppFlagIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppXepServiceDiscoveryFlag* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (feature != NULL);
	_tmp0_ = xmpp_xep_service_discovery_flag_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	flag = (XmppXepServiceDiscoveryFlag*) _tmp1_;
	_tmp2_ = flag;
	if (_tmp2_ != NULL) {
		XmppXepServiceDiscoveryFlag* _tmp3_;
		_tmp3_ = flag;
		xmpp_xep_service_discovery_flag_remove_own_feature (_tmp3_, feature);
	}
	_g_object_unref0 (flag);
}

void
xmpp_xep_service_discovery_module_add_feature_notify (XmppXepServiceDiscoveryModule* self,
                                                      XmppXmppStream* stream,
                                                      const gchar* feature)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (feature != NULL);
	_tmp0_ = g_strconcat (feature, "+notify", NULL);
	_tmp1_ = _tmp0_;
	xmpp_xep_service_discovery_module_add_feature (self, stream, _tmp1_);
	_g_free0 (_tmp1_);
}

void
xmpp_xep_service_discovery_module_remove_feature_notify (XmppXepServiceDiscoveryModule* self,
                                                         XmppXmppStream* stream,
                                                         const gchar* feature)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (feature != NULL);
	_tmp0_ = g_strconcat (feature, "+notify", NULL);
	_tmp1_ = _tmp0_;
	xmpp_xep_service_discovery_module_remove_feature (self, stream, _tmp1_);
	_g_free0 (_tmp1_);
}

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

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

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

void
xmpp_xep_service_discovery_module_has_entity_feature (XmppXepServiceDiscoveryModule* self,
                                                      XmppXmppStream* stream,
                                                      XmppJid* jid,
                                                      const gchar* feature,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	XmppXepServiceDiscoveryModuleHasEntityFeatureData* _data_;
	XmppXepServiceDiscoveryModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppJid* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (feature != NULL);
	_data_ = g_slice_new0 (XmppXepServiceDiscoveryModuleHasEntityFeatureData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_service_discovery_module_has_entity_feature_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _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_;
	xmpp_xep_service_discovery_module_has_entity_feature_co (_data_);
}

gboolean
xmpp_xep_service_discovery_module_has_entity_feature_finish (XmppXepServiceDiscoveryModule* self,
                                                             GAsyncResult* _res_)
{
	gboolean result;
	XmppXepServiceDiscoveryModuleHasEntityFeatureData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
xmpp_xep_service_discovery_module_has_entity_feature_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_)
{
	XmppXepServiceDiscoveryModuleHasEntityFeatureData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_service_discovery_module_has_entity_feature_co (_data_);
}

static gboolean
xmpp_xep_service_discovery_module_has_entity_feature_co (XmppXepServiceDiscoveryModuleHasEntityFeatureData* _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->cache;
	_data_->_state_ = 1;
	xmpp_xep_service_discovery_caps_cache_has_entity_feature (_data_->_tmp0_, _data_->jid, _data_->feature, xmpp_xep_service_discovery_module_has_entity_feature_ready, _data_);
	return FALSE;
	_state_1:
	_data_->result = xmpp_xep_service_discovery_caps_cache_has_entity_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
xmpp_xep_service_discovery_module_get_entity_identities_data_free (gpointer _data)
{
	XmppXepServiceDiscoveryModuleGetEntityIdentitiesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_xmpp_jid_unref0 (_data_->jid);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepServiceDiscoveryModuleGetEntityIdentitiesData, _data_);
}

void
xmpp_xep_service_discovery_module_get_entity_identities (XmppXepServiceDiscoveryModule* self,
                                                         XmppXmppStream* stream,
                                                         XmppJid* jid,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_)
{
	XmppXepServiceDiscoveryModuleGetEntityIdentitiesData* _data_;
	XmppXepServiceDiscoveryModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppJid* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	_data_ = g_slice_new0 (XmppXepServiceDiscoveryModuleGetEntityIdentitiesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_service_discovery_module_get_entity_identities_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	xmpp_xep_service_discovery_module_get_entity_identities_co (_data_);
}

GeeSet*
xmpp_xep_service_discovery_module_get_entity_identities_finish (XmppXepServiceDiscoveryModule* self,
                                                                GAsyncResult* _res_)
{
	GeeSet* result;
	XmppXepServiceDiscoveryModuleGetEntityIdentitiesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
xmpp_xep_service_discovery_module_get_entity_identities_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_)
{
	XmppXepServiceDiscoveryModuleGetEntityIdentitiesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_service_discovery_module_get_entity_identities_co (_data_);
}

static gboolean
xmpp_xep_service_discovery_module_get_entity_identities_co (XmppXepServiceDiscoveryModuleGetEntityIdentitiesData* _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->cache;
	_data_->_state_ = 1;
	xmpp_xep_service_discovery_caps_cache_get_entity_identities (_data_->_tmp0_, _data_->jid, xmpp_xep_service_discovery_module_get_entity_identities_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = xmpp_xep_service_discovery_caps_cache_get_entity_identities_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	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
xmpp_xep_service_discovery_module_request_info_data_free (gpointer _data)
{
	XmppXepServiceDiscoveryModuleRequestInfoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_xmpp_jid_unref0 (_data_->jid);
	_xmpp_xep_service_discovery_info_result_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepServiceDiscoveryModuleRequestInfoData, _data_);
}

void
xmpp_xep_service_discovery_module_request_info (XmppXepServiceDiscoveryModule* self,
                                                XmppXmppStream* stream,
                                                XmppJid* jid,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	XmppXepServiceDiscoveryModuleRequestInfoData* _data_;
	XmppXepServiceDiscoveryModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppJid* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	_data_ = g_slice_new0 (XmppXepServiceDiscoveryModuleRequestInfoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_service_discovery_module_request_info_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	xmpp_xep_service_discovery_module_request_info_co (_data_);
}

XmppXepServiceDiscoveryInfoResult*
xmpp_xep_service_discovery_module_request_info_finish (XmppXepServiceDiscoveryModule* self,
                                                       GAsyncResult* _res_)
{
	XmppXepServiceDiscoveryInfoResult* result;
	XmppXepServiceDiscoveryModuleRequestInfoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
xmpp_xep_service_discovery_module_request_info_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_)
{
	XmppXepServiceDiscoveryModuleRequestInfoData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_service_discovery_module_request_info_co (_data_);
}

static gpointer
_xmpp_xep_service_discovery_info_result_ref0 (gpointer self)
{
	return self ? xmpp_xep_service_discovery_info_result_ref (self) : NULL;
}

static gboolean
xmpp_xep_service_discovery_module_request_info_co (XmppXepServiceDiscoveryModuleRequestInfoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->active_info_requests;
	_data_->_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp0_, _data_->jid);
	_data_->future = (GeeFuture*) _data_->_tmp1_;
	_data_->_tmp2_ = _data_->future;
	if (_data_->_tmp2_ == NULL) {
		_data_->_tmp3_ = gee_promise_new (XMPP_XEP_SERVICE_DISCOVERY_TYPE_INFO_RESULT, (GBoxedCopyFunc) xmpp_xep_service_discovery_info_result_ref, (GDestroyNotify) xmpp_xep_service_discovery_info_result_unref);
		_data_->promise = _data_->_tmp3_;
		_data_->_tmp4_ = _data_->promise;
		_data_->_tmp5_ = gee_promise_get_future (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = _g_object_ref0 (_data_->_tmp6_);
		_g_object_unref0 (_data_->future);
		_data_->future = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->self->priv->active_info_requests;
		_data_->_tmp9_ = _data_->future;
		gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp8_, _data_->jid, _data_->_tmp9_);
		_data_->_tmp10_ = xmpp_stanza_node_new_build ("query", XMPP_XEP_SERVICE_DISCOVERY_NS_URI_INFO, NULL, NULL);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = xmpp_stanza_node_add_self_xmlns (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = _xmpp_jid_ref0 (_data_->jid);
		_data_->_tmp15_ = NULL;
		_data_->_tmp15_ = xmpp_iq_stanza_new_get (_data_->_tmp13_, NULL);
		xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp15_, _data_->_tmp14_);
		_xmpp_jid_unref0 (_data_->_tmp14_);
		_data_->_tmp16_ = _data_->_tmp15_;
		_xmpp_stanza_entry_unref0 (_data_->_tmp13_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp11_);
		_data_->iq = _data_->_tmp16_;
		_data_->_tmp17_ = xmpp_iq_module_IDENTITY;
		_data_->_tmp18_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp17_);
		_data_->_tmp19_ = (XmppIqModule*) _data_->_tmp18_;
		_data_->_tmp20_ = _data_->iq;
		_data_->_state_ = 1;
		xmpp_iq_module_send_iq_async (_data_->_tmp19_, _data_->stream, _data_->_tmp20_, G_PRIORITY_DEFAULT, NULL, xmpp_xep_service_discovery_module_request_info_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp21_ = xmpp_iq_module_send_iq_finish (_data_->_tmp19_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp22_ = _data_->_tmp21_;
		_g_object_unref0 (_data_->_tmp19_);
		_data_->iq_response = _data_->_tmp22_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->iq);
			_gee_promise_unref0 (_data_->promise);
			_g_object_unref0 (_data_->future);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp23_ = _data_->iq_response;
		_data_->_tmp24_ = xmpp_xep_service_discovery_info_result_create_from_iq (_data_->_tmp23_);
		_data_->_result_ = _data_->_tmp24_;
		_data_->_tmp25_ = _data_->promise;
		_data_->_tmp26_ = _data_->_result_;
		_data_->_tmp27_ = _xmpp_xep_service_discovery_info_result_ref0 (_data_->_tmp26_);
		gee_promise_set_value (_data_->_tmp25_, _data_->_tmp27_);
		_data_->_tmp28_ = _data_->self->priv->active_info_requests;
		gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp28_, _data_->jid, NULL);
		_xmpp_xep_service_discovery_info_result_unref0 (_data_->_result_);
		_g_object_unref0 (_data_->iq_response);
		_g_object_unref0 (_data_->iq);
		_gee_promise_unref0 (_data_->promise);
	}
	{
		_data_->_tmp29_ = _data_->future;
		_data_->_state_ = 2;
		gee_future_wait_async (_data_->_tmp29_, xmpp_xep_service_discovery_module_request_info_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp30_ = gee_future_wait_finish (_data_->_tmp29_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp31_ = _xmpp_xep_service_discovery_info_result_ref0 ((XmppXepServiceDiscoveryInfoResult*) _data_->_tmp30_);
		_data_->res = _data_->_tmp31_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == GEE_FUTURE_ERROR) {
				goto __catch0_gee_future_error;
			}
			_g_object_unref0 (_data_->future);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->result = _data_->res;
		_g_object_unref0 (_data_->future);
		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;
	}
	goto __finally0;
	__catch0_gee_future_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp32_ = _data_->_error_;
		_data_->_tmp33_ = _data_->_tmp32_->message;
		g_warning ("module.vala:67: Future error when waiting for info request result: %s", _data_->_tmp33_);
		_data_->result = NULL;
		_g_error_free0 (_data_->_error_);
		_g_object_unref0 (_data_->future);
		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;
	}
	__finally0:
	_g_object_unref0 (_data_->future);
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
	g_clear_error (&_data_->_inner_error0_);
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
xmpp_xep_service_discovery_module_request_items_data_free (gpointer _data)
{
	XmppXepServiceDiscoveryModuleRequestItemsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_xmpp_jid_unref0 (_data_->jid);
	_xmpp_xep_service_discovery_items_result_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepServiceDiscoveryModuleRequestItemsData, _data_);
}

void
xmpp_xep_service_discovery_module_request_items (XmppXepServiceDiscoveryModule* self,
                                                 XmppXmppStream* stream,
                                                 XmppJid* jid,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_)
{
	XmppXepServiceDiscoveryModuleRequestItemsData* _data_;
	XmppXepServiceDiscoveryModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppJid* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	_data_ = g_slice_new0 (XmppXepServiceDiscoveryModuleRequestItemsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_service_discovery_module_request_items_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	xmpp_xep_service_discovery_module_request_items_co (_data_);
}

XmppXepServiceDiscoveryItemsResult*
xmpp_xep_service_discovery_module_request_items_finish (XmppXepServiceDiscoveryModule* self,
                                                        GAsyncResult* _res_)
{
	XmppXepServiceDiscoveryItemsResult* result;
	XmppXepServiceDiscoveryModuleRequestItemsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
xmpp_xep_service_discovery_module_request_items_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	XmppXepServiceDiscoveryModuleRequestItemsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_service_discovery_module_request_items_co (_data_);
}

static gboolean
xmpp_xep_service_discovery_module_request_items_co (XmppXepServiceDiscoveryModuleRequestItemsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = xmpp_stanza_node_new_build ("query", XMPP_XEP_SERVICE_DISCOVERY_NS_URI_ITEMS, NULL, NULL);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = xmpp_stanza_node_add_self_xmlns (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_xmpp_stanza_entry_unref0 (_data_->_tmp1_);
	_data_->query_node = _data_->_tmp3_;
	_data_->_tmp4_ = _xmpp_jid_ref0 (_data_->jid);
	_data_->_tmp5_ = NULL;
	_data_->_tmp5_ = xmpp_iq_stanza_new_get (_data_->query_node, NULL);
	xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp5_, _data_->_tmp4_);
	_xmpp_jid_unref0 (_data_->_tmp4_);
	_data_->iq = _data_->_tmp5_;
	_data_->_tmp6_ = xmpp_iq_module_IDENTITY;
	_data_->_tmp7_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp6_);
	_data_->_tmp8_ = (XmppIqModule*) _data_->_tmp7_;
	_data_->_state_ = 1;
	xmpp_iq_module_send_iq_async (_data_->_tmp8_, _data_->stream, _data_->iq, G_PRIORITY_DEFAULT, NULL, xmpp_xep_service_discovery_module_request_items_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp9_ = xmpp_iq_module_send_iq_finish (_data_->_tmp8_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp10_ = _data_->_tmp9_;
	_g_object_unref0 (_data_->_tmp8_);
	_data_->iq_result = _data_->_tmp10_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->iq);
		_xmpp_stanza_entry_unref0 (_data_->query_node);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp11_ = xmpp_xep_service_discovery_items_result_create_from_iq (_data_->iq_result);
	_data_->_result_ = _data_->_tmp11_;
	_data_->result = _data_->_result_;
	_g_object_unref0 (_data_->iq_result);
	_g_object_unref0 (_data_->iq);
	_xmpp_stanza_entry_unref0 (_data_->query_node);
	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
xmpp_xep_service_discovery_module_real_on_iq_get_data_free (gpointer _data)
{
	XmppXepServiceDiscoveryModuleOnIqGetData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_g_object_unref0 (_data_->iq);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepServiceDiscoveryModuleOnIqGetData, _data_);
}

static void
xmpp_xep_service_discovery_module_real_on_iq_get (XmppIqHandler* base,
                                                  XmppXmppStream* stream,
                                                  XmppIqStanza* iq,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	XmppXepServiceDiscoveryModule * self;
	XmppXepServiceDiscoveryModuleOnIqGetData* _data_;
	XmppXepServiceDiscoveryModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppIqStanza* _tmp2_;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (iq != NULL);
	self = (XmppXepServiceDiscoveryModule*) base;
	_data_ = g_slice_new0 (XmppXepServiceDiscoveryModuleOnIqGetData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_service_discovery_module_real_on_iq_get_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp1_;
	_tmp2_ = _g_object_ref0 (iq);
	_g_object_unref0 (_data_->iq);
	_data_->iq = _tmp2_;
	xmpp_xep_service_discovery_module_real_on_iq_get_co (_data_);
}

static void
xmpp_xep_service_discovery_module_on_iq_get_finish (XmppIqHandler* base,
                                                    GAsyncResult* _res_)
{
	XmppXepServiceDiscoveryModuleOnIqGetData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
xmpp_xep_service_discovery_module_real_on_iq_get_co (XmppXepServiceDiscoveryModuleOnIqGetData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ((XmppStanza*) _data_->iq)->stanza;
	_data_->_tmp1_ = xmpp_stanza_node_get_subnode (_data_->_tmp0_, "query", XMPP_XEP_SERVICE_DISCOVERY_NS_URI_INFO, FALSE);
	_data_->query_node = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->query_node;
	if (_data_->_tmp2_ != NULL) {
		xmpp_xep_service_discovery_module_send_query_result (_data_->self, _data_->stream, _data_->iq);
	}
	_xmpp_stanza_entry_unref0 (_data_->query_node);
	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
xmpp_xep_service_discovery_module_real_attach (XmppXmppStreamModule* base,
                                               XmppXmppStream* stream)
{
	XmppXepServiceDiscoveryModule * self;
	XmppXepServiceDiscoveryFlag* _tmp0_;
	XmppXepServiceDiscoveryFlag* _tmp1_;
	XmppFlagIdentity* _tmp2_;
	gpointer _tmp3_;
	XmppXepServiceDiscoveryFlag* _tmp4_;
	XmppXepServiceDiscoveryIdentity* _tmp5_;
	XmppModuleIdentity* _tmp6_;
	gpointer _tmp7_;
	XmppIqModule* _tmp8_;
	self = (XmppXepServiceDiscoveryModule*) base;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_xep_service_discovery_flag_new ();
	_tmp1_ = _tmp0_;
	xmpp_xmpp_stream_add_flag (stream, (XmppXmppStreamFlag*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = xmpp_xep_service_discovery_flag_IDENTITY;
	_tmp3_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (XmppXepServiceDiscoveryFlag*) _tmp3_;
	_tmp5_ = self->own_identity;
	xmpp_xep_service_discovery_flag_add_own_identity (_tmp4_, _tmp5_);
	_g_object_unref0 (_tmp4_);
	_tmp6_ = xmpp_iq_module_IDENTITY;
	_tmp7_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp6_);
	_tmp8_ = (XmppIqModule*) _tmp7_;
	xmpp_iq_module_register_for_namespace (_tmp8_, XMPP_XEP_SERVICE_DISCOVERY_NS_URI_INFO, (XmppIqHandler*) self);
	_g_object_unref0 (_tmp8_);
	xmpp_xep_service_discovery_module_add_feature (self, stream, XMPP_XEP_SERVICE_DISCOVERY_NS_URI_INFO);
}

static void
xmpp_xep_service_discovery_module_real_detach (XmppXmppStreamModule* base,
                                               XmppXmppStream* stream)
{
	XmppXepServiceDiscoveryModule * self;
	GeeHashMap* _tmp0_;
	XmppXepServiceDiscoveryFlag* flag = NULL;
	XmppFlagIdentity* _tmp1_;
	gpointer _tmp2_;
	XmppXepServiceDiscoveryFlag* _tmp3_;
	XmppModuleIdentity* _tmp6_;
	gpointer _tmp7_;
	XmppIqModule* _tmp8_;
	self = (XmppXepServiceDiscoveryModule*) base;
	g_return_if_fail (stream != NULL);
	_tmp0_ = self->priv->active_info_requests;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp0_);
	_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_);
	flag = (XmppXepServiceDiscoveryFlag*) _tmp2_;
	_tmp3_ = flag;
	if (_tmp3_ != NULL) {
		XmppXepServiceDiscoveryFlag* _tmp4_;
		XmppXepServiceDiscoveryIdentity* _tmp5_;
		_tmp4_ = flag;
		_tmp5_ = self->own_identity;
		xmpp_xep_service_discovery_flag_remove_own_identity (_tmp4_, _tmp5_);
	}
	_tmp6_ = xmpp_iq_module_IDENTITY;
	_tmp7_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp6_);
	_tmp8_ = (XmppIqModule*) _tmp7_;
	xmpp_iq_module_unregister_from_namespace (_tmp8_, XMPP_XEP_SERVICE_DISCOVERY_NS_URI_INFO, (XmppIqHandler*) self);
	_g_object_unref0 (_tmp8_);
	xmpp_xep_service_discovery_module_remove_feature (self, stream, XMPP_XEP_SERVICE_DISCOVERY_NS_URI_INFO);
	_g_object_unref0 (flag);
}

void
xmpp_xep_service_discovery_module_require (XmppXmppStream* stream)
{
	XmppModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppXepServiceDiscoveryModule* _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_xep_service_discovery_module_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppXepServiceDiscoveryModule*) _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		XmppXepServiceDiscoveryModule* _tmp4_;
		XmppXepServiceDiscoveryModule* _tmp5_;
		XmppXmppStream* _tmp6_;
		XmppXmppStream* _tmp7_;
		_tmp4_ = xmpp_xep_service_discovery_module_new ();
		_tmp5_ = _tmp4_;
		_tmp6_ = xmpp_xmpp_stream_add_module (stream, (XmppXmppStreamModule*) _tmp5_);
		_tmp7_ = _tmp6_;
		_g_object_unref0 (_tmp7_);
		_g_object_unref0 (_tmp5_);
	}
}

static gchar*
xmpp_xep_service_discovery_module_real_get_ns (XmppXmppStreamModule* base)
{
	XmppXepServiceDiscoveryModule * self;
	gchar* _tmp0_;
	gchar* result;
	self = (XmppXepServiceDiscoveryModule*) base;
	_tmp0_ = g_strdup (XMPP_XEP_SERVICE_DISCOVERY_NS_URI);
	result = _tmp0_;
	return result;
}

static gchar*
xmpp_xep_service_discovery_module_real_get_id (XmppXmppStreamModule* base)
{
	XmppXepServiceDiscoveryModule * self;
	XmppModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (XmppXepServiceDiscoveryModule*) base;
	_tmp0_ = xmpp_xep_service_discovery_module_IDENTITY;
	_tmp1_ = xmpp_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

static void
xmpp_xep_service_discovery_module_send_query_result (XmppXepServiceDiscoveryModule* self,
                                                     XmppXmppStream* stream,
                                                     XmppIqStanza* iq_request)
{
	XmppXepServiceDiscoveryInfoResult* query_result = NULL;
	XmppXepServiceDiscoveryInfoResult* _tmp0_;
	XmppFlagIdentity* _tmp1_;
	gpointer _tmp2_;
	XmppXepServiceDiscoveryFlag* _tmp3_;
	GeeList* _tmp4_;
	GeeList* _tmp5_;
	GeeList* _tmp6_;
	XmppFlagIdentity* _tmp7_;
	gpointer _tmp8_;
	XmppXepServiceDiscoveryFlag* _tmp9_;
	GeeSet* _tmp10_;
	GeeSet* _tmp11_;
	GeeSet* _tmp12_;
	XmppModuleIdentity* _tmp13_;
	gpointer _tmp14_;
	XmppIqModule* _tmp15_;
	XmppIqStanza* _tmp16_;
	XmppIqStanza* _tmp17_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (iq_request != NULL);
	_tmp0_ = xmpp_xep_service_discovery_info_result_new (iq_request);
	query_result = _tmp0_;
	_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_features (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	xmpp_xep_service_discovery_info_result_set_features (query_result, _tmp6_);
	_g_object_unref0 (_tmp6_);
	_g_object_unref0 (_tmp3_);
	_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_identities (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = _tmp11_;
	xmpp_xep_service_discovery_info_result_set_identities (query_result, _tmp12_);
	_g_object_unref0 (_tmp12_);
	_g_object_unref0 (_tmp9_);
	_tmp13_ = xmpp_iq_module_IDENTITY;
	_tmp14_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp13_);
	_tmp15_ = (XmppIqModule*) _tmp14_;
	_tmp16_ = xmpp_xep_service_discovery_info_result_get_iq (query_result);
	_tmp17_ = _tmp16_;
	xmpp_iq_module_send_iq (_tmp15_, stream, _tmp17_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
	_g_object_unref0 (_tmp15_);
	_xmpp_xep_service_discovery_info_result_unref0 (query_result);
}

XmppXepServiceDiscoveryModule*
xmpp_xep_service_discovery_module_construct (GType object_type)
{
	XmppXepServiceDiscoveryModule * self = NULL;
	self = (XmppXepServiceDiscoveryModule*) xmpp_xmpp_stream_module_construct (object_type);
	return self;
}

XmppXepServiceDiscoveryModule*
xmpp_xep_service_discovery_module_new (void)
{
	return xmpp_xep_service_discovery_module_construct (XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE);
}

static void
xmpp_xep_service_discovery_module_class_init (XmppXepServiceDiscoveryModuleClass * klass,
                                              gpointer klass_data)
{
	XmppModuleIdentity* _tmp0_;
	xmpp_xep_service_discovery_module_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXepServiceDiscoveryModule_private_offset);
	((XmppXmppStreamModuleClass *) klass)->attach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) xmpp_xep_service_discovery_module_real_attach;
	((XmppXmppStreamModuleClass *) klass)->detach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) xmpp_xep_service_discovery_module_real_detach;
	((XmppXmppStreamModuleClass *) klass)->get_ns = (gchar* (*) (XmppXmppStreamModule*)) xmpp_xep_service_discovery_module_real_get_ns;
	((XmppXmppStreamModuleClass *) klass)->get_id = (gchar* (*) (XmppXmppStreamModule*)) xmpp_xep_service_discovery_module_real_get_id;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_service_discovery_module_finalize;
	_tmp0_ = xmpp_module_identity_new (XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, XMPP_XEP_SERVICE_DISCOVERY_NS_URI, "0030_service_discovery_module");
	xmpp_xep_service_discovery_module_IDENTITY = _tmp0_;
}

static void
xmpp_xep_service_discovery_module_xmpp_iq_handler_interface_init (XmppIqHandlerIface * iface,
                                                                  gpointer iface_data)
{
	xmpp_xep_service_discovery_module_xmpp_iq_handler_parent_iface = g_type_interface_peek_parent (iface);
	iface->on_iq_get = (void (*) (XmppIqHandler*, XmppXmppStream*, XmppIqStanza*, GAsyncReadyCallback, gpointer)) xmpp_xep_service_discovery_module_real_on_iq_get;
	iface->on_iq_get_finish = (void (*) (XmppIqHandler*, GAsyncResult*)) xmpp_xep_service_discovery_module_on_iq_get_finish;
}

static void
xmpp_xep_service_discovery_module_instance_init (XmppXepServiceDiscoveryModule * self,
                                                 gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = xmpp_xep_service_discovery_module_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, GEE_TYPE_FUTURE, (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->active_info_requests = _tmp0_;
}

static void
xmpp_xep_service_discovery_module_finalize (GObject * obj)
{
	XmppXepServiceDiscoveryModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_SERVICE_DISCOVERY_TYPE_MODULE, XmppXepServiceDiscoveryModule);
	_g_object_unref0 (self->priv->active_info_requests);
	_xmpp_xep_service_discovery_identity_unref0 (self->own_identity);
	_g_object_unref0 (self->cache);
	G_OBJECT_CLASS (xmpp_xep_service_discovery_module_parent_class)->finalize (obj);
}

static GType
xmpp_xep_service_discovery_module_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepServiceDiscoveryModuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_service_discovery_module_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepServiceDiscoveryModule), 0, (GInstanceInitFunc) xmpp_xep_service_discovery_module_instance_init, NULL };
	static const GInterfaceInfo xmpp_iq_handler_info = { (GInterfaceInitFunc) xmpp_xep_service_discovery_module_xmpp_iq_handler_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType xmpp_xep_service_discovery_module_type_id;
	xmpp_xep_service_discovery_module_type_id = g_type_register_static (XMPP_TYPE_XMPP_STREAM_MODULE, "XmppXepServiceDiscoveryModule", &g_define_type_info, 0);
	g_type_add_interface_static (xmpp_xep_service_discovery_module_type_id, XMPP_IQ_TYPE_HANDLER, &xmpp_iq_handler_info);
	XmppXepServiceDiscoveryModule_private_offset = g_type_add_instance_private (xmpp_xep_service_discovery_module_type_id, sizeof (XmppXepServiceDiscoveryModulePrivate));
	return xmpp_xep_service_discovery_module_type_id;
}

GType
xmpp_xep_service_discovery_module_get_type (void)
{
	static volatile gsize xmpp_xep_service_discovery_module_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_service_discovery_module_type_id__once)) {
		GType xmpp_xep_service_discovery_module_type_id;
		xmpp_xep_service_discovery_module_type_id = xmpp_xep_service_discovery_module_get_type_once ();
		g_once_init_leave (&xmpp_xep_service_discovery_module_type_id__once, xmpp_xep_service_discovery_module_type_id);
	}
	return xmpp_xep_service_discovery_module_type_id__once;
}

void
xmpp_xep_service_discovery_caps_cache_has_entity_feature (XmppXepServiceDiscoveryCapsCache* self,
                                                          XmppJid* jid,
                                                          const gchar* feature,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	XmppXepServiceDiscoveryCapsCacheIface* _iface_;
	_iface_ = XMPP_XEP_SERVICE_DISCOVERY_CAPS_CACHE_GET_INTERFACE (self);
	if (_iface_->has_entity_feature) {
		_iface_->has_entity_feature (self, jid, feature, _callback_, _user_data_);
	}
}

gboolean
xmpp_xep_service_discovery_caps_cache_has_entity_feature_finish (XmppXepServiceDiscoveryCapsCache* self,
                                                                 GAsyncResult* _res_)
{
	XmppXepServiceDiscoveryCapsCacheIface* _iface_;
	_iface_ = XMPP_XEP_SERVICE_DISCOVERY_CAPS_CACHE_GET_INTERFACE (self);
	if (_iface_->has_entity_feature_finish) {
		return _iface_->has_entity_feature_finish (self, _res_);
	}
	return FALSE;
}

void
xmpp_xep_service_discovery_caps_cache_get_entity_identities (XmppXepServiceDiscoveryCapsCache* self,
                                                             XmppJid* jid,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	XmppXepServiceDiscoveryCapsCacheIface* _iface_;
	_iface_ = XMPP_XEP_SERVICE_DISCOVERY_CAPS_CACHE_GET_INTERFACE (self);
	if (_iface_->get_entity_identities) {
		_iface_->get_entity_identities (self, jid, _callback_, _user_data_);
	}
}

GeeSet*
xmpp_xep_service_discovery_caps_cache_get_entity_identities_finish (XmppXepServiceDiscoveryCapsCache* self,
                                                                    GAsyncResult* _res_)
{
	XmppXepServiceDiscoveryCapsCacheIface* _iface_;
	_iface_ = XMPP_XEP_SERVICE_DISCOVERY_CAPS_CACHE_GET_INTERFACE (self);
	if (_iface_->get_entity_identities_finish) {
		return _iface_->get_entity_identities_finish (self, _res_);
	}
	return NULL;
}

static void
xmpp_xep_service_discovery_caps_cache_default_init (XmppXepServiceDiscoveryCapsCacheIface * iface,
                                                    gpointer iface_data)
{
}

static GType
xmpp_xep_service_discovery_caps_cache_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepServiceDiscoveryCapsCacheIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_service_discovery_caps_cache_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType xmpp_xep_service_discovery_caps_cache_type_id;
	xmpp_xep_service_discovery_caps_cache_type_id = g_type_register_static (G_TYPE_INTERFACE, "XmppXepServiceDiscoveryCapsCache", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (xmpp_xep_service_discovery_caps_cache_type_id, G_TYPE_OBJECT);
	return xmpp_xep_service_discovery_caps_cache_type_id;
}

GType
xmpp_xep_service_discovery_caps_cache_get_type (void)
{
	static volatile gsize xmpp_xep_service_discovery_caps_cache_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_service_discovery_caps_cache_type_id__once)) {
		GType xmpp_xep_service_discovery_caps_cache_type_id;
		xmpp_xep_service_discovery_caps_cache_type_id = xmpp_xep_service_discovery_caps_cache_get_type_once ();
		g_once_init_leave (&xmpp_xep_service_discovery_caps_cache_type_id__once, xmpp_xep_service_discovery_caps_cache_type_id);
	}
	return xmpp_xep_service_discovery_caps_cache_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;
}

