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

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

#define XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI "urn:xmpp:extdisco:2"
#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_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_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))
#define _xmpp_xep_external_service_discovery_service_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_external_service_discovery_service_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
typedef struct _XmppXepExternalServiceDiscoveryRequestServicesData XmppXepExternalServiceDiscoveryRequestServicesData;
typedef struct _XmppXepExternalServiceDiscoveryParamSpecService XmppXepExternalServiceDiscoveryParamSpecService;

struct _XmppXepExternalServiceDiscoveryRequestServicesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXmppStream* stream;
	GeeList* result;
	XmppIqStanza* request_iq;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppJid* _tmp4_;
	XmppJid* _tmp5_;
	XmppIqStanza* _tmp6_;
	XmppIqStanza* _tmp7_;
	XmppIqStanza* response_iq;
	XmppModuleIdentity* _tmp8_;
	gpointer _tmp9_;
	XmppIqModule* _tmp10_;
	XmppIqStanza* _tmp11_;
	XmppIqStanza* _tmp12_;
	XmppIqStanza* _tmp13_;
	GeeArrayList* ret;
	GeeArrayList* _tmp14_;
	XmppIqStanza* _tmp15_;
	XmppStanzaNode* services_node;
	XmppIqStanza* _tmp16_;
	XmppStanzaNode* _tmp17_;
	XmppStanzaNode* _tmp18_;
	XmppStanzaNode* _tmp19_;
	GeeList* service_nodes;
	XmppStanzaNode* _tmp20_;
	GeeList* _tmp21_;
	GeeList* _service_node_list;
	GeeList* _tmp22_;
	gint _service_node_size;
	GeeList* _tmp23_;
	gint _tmp24_;
	gint _tmp25_;
	gint _service_node_index;
	gint _tmp26_;
	gint _tmp27_;
	XmppStanzaNode* service_node;
	GeeList* _tmp28_;
	gpointer _tmp29_;
	XmppXepExternalServiceDiscoveryService* service;
	XmppXepExternalServiceDiscoveryService* _tmp30_;
	XmppXepExternalServiceDiscoveryService* _tmp31_;
	XmppStanzaNode* _tmp32_;
	const gchar* _tmp33_;
	gchar* port_str;
	XmppStanzaNode* _tmp34_;
	const gchar* _tmp35_;
	gchar* _tmp36_;
	const gchar* _tmp37_;
	XmppXepExternalServiceDiscoveryService* _tmp38_;
	const gchar* _tmp39_;
	XmppXepExternalServiceDiscoveryService* _tmp40_;
	XmppStanzaNode* _tmp41_;
	const gchar* _tmp42_;
	gboolean _tmp43_;
	gboolean _tmp44_;
	XmppXepExternalServiceDiscoveryService* _tmp45_;
	const gchar* _tmp46_;
	const gchar* _tmp47_;
	XmppXepExternalServiceDiscoveryService* _tmp48_;
	const gchar* _tmp49_;
	const gchar* _tmp50_;
	const gchar* _tmp51_;
	XmppXepExternalServiceDiscoveryService* _tmp52_;
	XmppStanzaNode* _tmp53_;
	const gchar* _tmp54_;
	XmppXepExternalServiceDiscoveryService* _tmp55_;
	XmppStanzaNode* _tmp56_;
	const gchar* _tmp57_;
	gchar* expires_str;
	XmppStanzaNode* _tmp58_;
	const gchar* _tmp59_;
	gchar* _tmp60_;
	const gchar* _tmp61_;
	XmppXepExternalServiceDiscoveryService* _tmp62_;
	const gchar* _tmp63_;
	GDateTime* _tmp64_;
	GDateTime* _tmp65_;
	XmppXepExternalServiceDiscoveryService* _tmp66_;
	XmppStanzaNode* _tmp67_;
	const gchar* _tmp68_;
	XmppXepExternalServiceDiscoveryService* _tmp69_;
	XmppStanzaNode* _tmp70_;
	const gchar* _tmp71_;
	gchar* restricted_str;
	XmppStanzaNode* _tmp72_;
	const gchar* _tmp73_;
	gchar* _tmp74_;
	const gchar* _tmp75_;
	XmppXepExternalServiceDiscoveryService* _tmp76_;
	const gchar* _tmp77_;
	GeeArrayList* _tmp78_;
	XmppXepExternalServiceDiscoveryService* _tmp79_;
	GError* _inner_error0_;
};

struct _XmppXepExternalServiceDiscoveryServicePrivate {
	gchar* _host;
	guint _port;
	gchar* _ty;
	gchar* _username;
	gchar* _password;
	GDateTime* _expires;
	gchar* _transport;
	gchar* _name;
	gboolean _restricted;
};

struct _XmppXepExternalServiceDiscoveryParamSpecService {
	GParamSpec parent_instance;
};

static gint XmppXepExternalServiceDiscoveryService_private_offset;
static gpointer xmpp_xep_external_service_discovery_service_parent_class = NULL;

static void xmpp_xep_external_service_discovery_request_services_data_free (gpointer _data);
static gboolean xmpp_xep_external_service_discovery_request_services_co (XmppXepExternalServiceDiscoveryRequestServicesData* _data_);
static void xmpp_xep_external_service_discovery_request_services_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_);
static void xmpp_xep_external_service_discovery_service_finalize (XmppXepExternalServiceDiscoveryService * obj);
static GType xmpp_xep_external_service_discovery_service_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
xmpp_xep_external_service_discovery_request_services_data_free (gpointer _data)
{
	XmppXepExternalServiceDiscoveryRequestServicesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_g_object_unref0 (_data_->result);
	g_slice_free (XmppXepExternalServiceDiscoveryRequestServicesData, _data_);
}

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

void
xmpp_xep_external_service_discovery_request_services (XmppXmppStream* stream,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	XmppXepExternalServiceDiscoveryRequestServicesData* _data_;
	XmppXmppStream* _tmp0_;
	g_return_if_fail (stream != NULL);
	_data_ = g_slice_new0 (XmppXepExternalServiceDiscoveryRequestServicesData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_external_service_discovery_request_services_data_free);
	_tmp0_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp0_;
	xmpp_xep_external_service_discovery_request_services_co (_data_);
}

GeeList*
xmpp_xep_external_service_discovery_request_services_finish (GAsyncResult* _res_)
{
	GeeList* result;
	XmppXepExternalServiceDiscoveryRequestServicesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

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

static void
xmpp_xep_external_service_discovery_request_services_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_)
{
	XmppXepExternalServiceDiscoveryRequestServicesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_external_service_discovery_request_services_co (_data_);
}

static gboolean
bool_parse (const gchar* str)
{
	gboolean result;
	g_return_val_if_fail (str != NULL, FALSE);
	if (g_strcmp0 (str, "true") == 0) {
		result = TRUE;
		return result;
	} else {
		result = FALSE;
		return result;
	}
}

static gboolean
xmpp_xep_external_service_discovery_request_services_co (XmppXepExternalServiceDiscoveryRequestServicesData* _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 ("services", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI, NULL, NULL);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = xmpp_stanza_node_add_self_xmlns (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = _data_->stream->remote_name;
	_data_->_tmp5_ = _xmpp_jid_ref0 (_data_->_tmp4_);
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = xmpp_iq_stanza_new_get (_data_->_tmp3_, NULL);
	xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp6_, _data_->_tmp5_);
	_xmpp_jid_unref0 (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_xmpp_stanza_entry_unref0 (_data_->_tmp3_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp1_);
	_data_->request_iq = _data_->_tmp7_;
	_data_->_tmp8_ = xmpp_iq_module_IDENTITY;
	_data_->_tmp9_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp8_);
	_data_->_tmp10_ = (XmppIqModule*) _data_->_tmp9_;
	_data_->_tmp11_ = _data_->request_iq;
	_data_->_state_ = 1;
	xmpp_iq_module_send_iq_async (_data_->_tmp10_, _data_->stream, _data_->_tmp11_, G_PRIORITY_DEFAULT, NULL, xmpp_xep_external_service_discovery_request_services_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp12_ = xmpp_iq_module_send_iq_finish (_data_->_tmp10_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp13_ = _data_->_tmp12_;
	_g_object_unref0 (_data_->_tmp10_);
	_data_->response_iq = _data_->_tmp13_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->request_iq);
		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_->_tmp14_ = gee_array_list_new (XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_TYPE_SERVICE, (GBoxedCopyFunc) xmpp_xep_external_service_discovery_service_ref, (GDestroyNotify) xmpp_xep_external_service_discovery_service_unref, NULL, NULL, NULL);
	_data_->ret = _data_->_tmp14_;
	_data_->_tmp15_ = _data_->response_iq;
	if (xmpp_stanza_is_error ((XmppStanza*) _data_->_tmp15_)) {
		_data_->result = (GeeList*) _data_->ret;
		_g_object_unref0 (_data_->response_iq);
		_g_object_unref0 (_data_->request_iq);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp16_ = _data_->response_iq;
	_data_->_tmp17_ = ((XmppStanza*) _data_->_tmp16_)->stanza;
	_data_->_tmp18_ = xmpp_stanza_node_get_subnode (_data_->_tmp17_, "services", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI, FALSE);
	_data_->services_node = _data_->_tmp18_;
	_data_->_tmp19_ = _data_->services_node;
	if (_data_->_tmp19_ == NULL) {
		_data_->result = (GeeList*) _data_->ret;
		_xmpp_stanza_entry_unref0 (_data_->services_node);
		_g_object_unref0 (_data_->response_iq);
		_g_object_unref0 (_data_->request_iq);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp20_ = _data_->services_node;
	_data_->_tmp21_ = xmpp_stanza_node_get_subnodes (_data_->_tmp20_, "service", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI, FALSE);
	_data_->service_nodes = _data_->_tmp21_;
	{
		_data_->_tmp22_ = _data_->service_nodes;
		_data_->_service_node_list = _data_->_tmp22_;
		_data_->_tmp23_ = _data_->_service_node_list;
		_data_->_tmp24_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp23_);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_service_node_size = _data_->_tmp25_;
		_data_->_service_node_index = -1;
		while (TRUE) {
			_data_->_service_node_index = _data_->_service_node_index + 1;
			_data_->_tmp26_ = _data_->_service_node_index;
			_data_->_tmp27_ = _data_->_service_node_size;
			if (!(_data_->_tmp26_ < _data_->_tmp27_)) {
				break;
			}
			_data_->_tmp28_ = _data_->_service_node_list;
			_data_->_tmp29_ = gee_list_get (_data_->_tmp28_, _data_->_service_node_index);
			_data_->service_node = (XmppStanzaNode*) _data_->_tmp29_;
			_data_->_tmp30_ = xmpp_xep_external_service_discovery_service_new ();
			_data_->service = _data_->_tmp30_;
			_data_->_tmp31_ = _data_->service;
			_data_->_tmp32_ = _data_->service_node;
			_data_->_tmp33_ = xmpp_stanza_node_get_attribute (_data_->_tmp32_, "host", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			xmpp_xep_external_service_discovery_service_set_host (_data_->_tmp31_, _data_->_tmp33_);
			_data_->_tmp34_ = _data_->service_node;
			_data_->_tmp35_ = xmpp_stanza_node_get_attribute (_data_->_tmp34_, "port", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			_data_->_tmp36_ = g_strdup (_data_->_tmp35_);
			_data_->port_str = _data_->_tmp36_;
			_data_->_tmp37_ = _data_->port_str;
			if (_data_->_tmp37_ != NULL) {
				_data_->_tmp38_ = _data_->service;
				_data_->_tmp39_ = _data_->port_str;
				xmpp_xep_external_service_discovery_service_set_port (_data_->_tmp38_, (guint) atoi (_data_->_tmp39_));
			}
			_data_->_tmp40_ = _data_->service;
			_data_->_tmp41_ = _data_->service_node;
			_data_->_tmp42_ = xmpp_stanza_node_get_attribute (_data_->_tmp41_, "type", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			xmpp_xep_external_service_discovery_service_set_ty (_data_->_tmp40_, _data_->_tmp42_);
			_data_->_tmp45_ = _data_->service;
			_data_->_tmp46_ = xmpp_xep_external_service_discovery_service_get_host (_data_->_tmp45_);
			_data_->_tmp47_ = _data_->_tmp46_;
			if (_data_->_tmp47_ == NULL) {
				_data_->_tmp44_ = TRUE;
			} else {
				_data_->_tmp48_ = _data_->service;
				_data_->_tmp49_ = xmpp_xep_external_service_discovery_service_get_ty (_data_->_tmp48_);
				_data_->_tmp50_ = _data_->_tmp49_;
				_data_->_tmp44_ = _data_->_tmp50_ == NULL;
			}
			if (_data_->_tmp44_) {
				_data_->_tmp43_ = TRUE;
			} else {
				_data_->_tmp51_ = _data_->port_str;
				_data_->_tmp43_ = _data_->_tmp51_ == NULL;
			}
			if (_data_->_tmp43_) {
				_g_free0 (_data_->port_str);
				_xmpp_xep_external_service_discovery_service_unref0 (_data_->service);
				_xmpp_stanza_entry_unref0 (_data_->service_node);
				continue;
			}
			_data_->_tmp52_ = _data_->service;
			_data_->_tmp53_ = _data_->service_node;
			_data_->_tmp54_ = xmpp_stanza_node_get_attribute (_data_->_tmp53_, "username", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			xmpp_xep_external_service_discovery_service_set_username (_data_->_tmp52_, _data_->_tmp54_);
			_data_->_tmp55_ = _data_->service;
			_data_->_tmp56_ = _data_->service_node;
			_data_->_tmp57_ = xmpp_stanza_node_get_attribute (_data_->_tmp56_, "password", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			xmpp_xep_external_service_discovery_service_set_password (_data_->_tmp55_, _data_->_tmp57_);
			_data_->_tmp58_ = _data_->service_node;
			_data_->_tmp59_ = xmpp_stanza_node_get_attribute (_data_->_tmp58_, "expires", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			_data_->_tmp60_ = g_strdup (_data_->_tmp59_);
			_data_->expires_str = _data_->_tmp60_;
			_data_->_tmp61_ = _data_->expires_str;
			if (_data_->_tmp61_ != NULL) {
				_data_->_tmp62_ = _data_->service;
				_data_->_tmp63_ = _data_->expires_str;
				_data_->_tmp64_ = xmpp_xep_date_time_profiles_parse_string (_data_->_tmp63_);
				_data_->_tmp65_ = _data_->_tmp64_;
				xmpp_xep_external_service_discovery_service_set_expires (_data_->_tmp62_, _data_->_tmp65_);
				_g_date_time_unref0 (_data_->_tmp65_);
			}
			_data_->_tmp66_ = _data_->service;
			_data_->_tmp67_ = _data_->service_node;
			_data_->_tmp68_ = xmpp_stanza_node_get_attribute (_data_->_tmp67_, "transport", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			xmpp_xep_external_service_discovery_service_set_transport (_data_->_tmp66_, _data_->_tmp68_);
			_data_->_tmp69_ = _data_->service;
			_data_->_tmp70_ = _data_->service_node;
			_data_->_tmp71_ = xmpp_stanza_node_get_attribute (_data_->_tmp70_, "name", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			xmpp_xep_external_service_discovery_service_set_name (_data_->_tmp69_, _data_->_tmp71_);
			_data_->_tmp72_ = _data_->service_node;
			_data_->_tmp73_ = xmpp_stanza_node_get_attribute (_data_->_tmp72_, "restricted", XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_NS_URI);
			_data_->_tmp74_ = g_strdup (_data_->_tmp73_);
			_data_->restricted_str = _data_->_tmp74_;
			_data_->_tmp75_ = _data_->restricted_str;
			if (_data_->_tmp75_ != NULL) {
				_data_->_tmp76_ = _data_->service;
				_data_->_tmp77_ = _data_->restricted_str;
				xmpp_xep_external_service_discovery_service_set_restricted (_data_->_tmp76_, bool_parse (_data_->_tmp77_));
			}
			_data_->_tmp78_ = _data_->ret;
			_data_->_tmp79_ = _data_->service;
			gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp78_, _data_->_tmp79_);
			_g_free0 (_data_->restricted_str);
			_g_free0 (_data_->expires_str);
			_g_free0 (_data_->port_str);
			_xmpp_xep_external_service_discovery_service_unref0 (_data_->service);
			_xmpp_stanza_entry_unref0 (_data_->service_node);
		}
	}
	_data_->result = (GeeList*) _data_->ret;
	_g_object_unref0 (_data_->service_nodes);
	_xmpp_stanza_entry_unref0 (_data_->services_node);
	_g_object_unref0 (_data_->response_iq);
	_g_object_unref0 (_data_->request_iq);
	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 inline gpointer
xmpp_xep_external_service_discovery_service_get_instance_private (XmppXepExternalServiceDiscoveryService* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepExternalServiceDiscoveryService_private_offset);
}

XmppXepExternalServiceDiscoveryService*
xmpp_xep_external_service_discovery_service_construct (GType object_type)
{
	XmppXepExternalServiceDiscoveryService* self = NULL;
	self = (XmppXepExternalServiceDiscoveryService*) g_type_create_instance (object_type);
	return self;
}

XmppXepExternalServiceDiscoveryService*
xmpp_xep_external_service_discovery_service_new (void)
{
	return xmpp_xep_external_service_discovery_service_construct (XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_TYPE_SERVICE);
}

const gchar*
xmpp_xep_external_service_discovery_service_get_host (XmppXepExternalServiceDiscoveryService* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_host;
	result = _tmp0_;
	return result;
}

void
xmpp_xep_external_service_discovery_service_set_host (XmppXepExternalServiceDiscoveryService* self,
                                                      const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_host);
	self->priv->_host = _tmp0_;
}

guint
xmpp_xep_external_service_discovery_service_get_port (XmppXepExternalServiceDiscoveryService* self)
{
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_port;
	return result;
}

void
xmpp_xep_external_service_discovery_service_set_port (XmppXepExternalServiceDiscoveryService* self,
                                                      guint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_port = value;
}

const gchar*
xmpp_xep_external_service_discovery_service_get_ty (XmppXepExternalServiceDiscoveryService* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_ty;
	result = _tmp0_;
	return result;
}

void
xmpp_xep_external_service_discovery_service_set_ty (XmppXepExternalServiceDiscoveryService* self,
                                                    const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_ty);
	self->priv->_ty = _tmp0_;
}

const gchar*
xmpp_xep_external_service_discovery_service_get_username (XmppXepExternalServiceDiscoveryService* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_username;
	result = _tmp0_;
	return result;
}

void
xmpp_xep_external_service_discovery_service_set_username (XmppXepExternalServiceDiscoveryService* self,
                                                          const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_username);
	self->priv->_username = _tmp0_;
}

const gchar*
xmpp_xep_external_service_discovery_service_get_password (XmppXepExternalServiceDiscoveryService* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_password;
	result = _tmp0_;
	return result;
}

void
xmpp_xep_external_service_discovery_service_set_password (XmppXepExternalServiceDiscoveryService* self,
                                                          const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_password);
	self->priv->_password = _tmp0_;
}

GDateTime*
xmpp_xep_external_service_discovery_service_get_expires (XmppXepExternalServiceDiscoveryService* self)
{
	GDateTime* result;
	GDateTime* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_expires;
	result = _tmp0_;
	return result;
}

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

void
xmpp_xep_external_service_discovery_service_set_expires (XmppXepExternalServiceDiscoveryService* self,
                                                         GDateTime* value)
{
	GDateTime* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_date_time_ref0 (value);
	_g_date_time_unref0 (self->priv->_expires);
	self->priv->_expires = _tmp0_;
}

const gchar*
xmpp_xep_external_service_discovery_service_get_transport (XmppXepExternalServiceDiscoveryService* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_transport;
	result = _tmp0_;
	return result;
}

void
xmpp_xep_external_service_discovery_service_set_transport (XmppXepExternalServiceDiscoveryService* self,
                                                           const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_transport);
	self->priv->_transport = _tmp0_;
}

const gchar*
xmpp_xep_external_service_discovery_service_get_name (XmppXepExternalServiceDiscoveryService* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

void
xmpp_xep_external_service_discovery_service_set_name (XmppXepExternalServiceDiscoveryService* self,
                                                      const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_name);
	self->priv->_name = _tmp0_;
}

gboolean
xmpp_xep_external_service_discovery_service_get_restricted (XmppXepExternalServiceDiscoveryService* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_restricted;
	return result;
}

void
xmpp_xep_external_service_discovery_service_set_restricted (XmppXepExternalServiceDiscoveryService* self,
                                                            gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_restricted = value;
}

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

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

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

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

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

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

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

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

void
xmpp_xep_external_service_discovery_value_set_service (GValue* value,
                                                       gpointer v_object)
{
	XmppXepExternalServiceDiscoveryService * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_TYPE_SERVICE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_TYPE_SERVICE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		xmpp_xep_external_service_discovery_service_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_external_service_discovery_service_unref (old);
	}
}

void
xmpp_xep_external_service_discovery_value_take_service (GValue* value,
                                                        gpointer v_object)
{
	XmppXepExternalServiceDiscoveryService * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_TYPE_SERVICE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_TYPE_SERVICE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_external_service_discovery_service_unref (old);
	}
}

static void
xmpp_xep_external_service_discovery_service_class_init (XmppXepExternalServiceDiscoveryServiceClass * klass,
                                                        gpointer klass_data)
{
	xmpp_xep_external_service_discovery_service_parent_class = g_type_class_peek_parent (klass);
	((XmppXepExternalServiceDiscoveryServiceClass *) klass)->finalize = xmpp_xep_external_service_discovery_service_finalize;
	g_type_class_adjust_private_offset (klass, &XmppXepExternalServiceDiscoveryService_private_offset);
}

static void
xmpp_xep_external_service_discovery_service_instance_init (XmppXepExternalServiceDiscoveryService * self,
                                                           gpointer klass)
{
	self->priv = xmpp_xep_external_service_discovery_service_get_instance_private (self);
	self->ref_count = 1;
}

static void
xmpp_xep_external_service_discovery_service_finalize (XmppXepExternalServiceDiscoveryService * obj)
{
	XmppXepExternalServiceDiscoveryService * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_TYPE_SERVICE, XmppXepExternalServiceDiscoveryService);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->_host);
	_g_free0 (self->priv->_ty);
	_g_free0 (self->priv->_username);
	_g_free0 (self->priv->_password);
	_g_date_time_unref0 (self->priv->_expires);
	_g_free0 (self->priv->_transport);
	_g_free0 (self->priv->_name);
}

static GType
xmpp_xep_external_service_discovery_service_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_xep_external_service_discovery_value_service_init, xmpp_xep_external_service_discovery_value_service_free_value, xmpp_xep_external_service_discovery_value_service_copy_value, xmpp_xep_external_service_discovery_value_service_peek_pointer, "p", xmpp_xep_external_service_discovery_value_service_collect_value, "p", xmpp_xep_external_service_discovery_value_service_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepExternalServiceDiscoveryServiceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_external_service_discovery_service_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepExternalServiceDiscoveryService), 0, (GInstanceInitFunc) xmpp_xep_external_service_discovery_service_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType xmpp_xep_external_service_discovery_service_type_id;
	xmpp_xep_external_service_discovery_service_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppXepExternalServiceDiscoveryService", &g_define_type_info, &g_define_type_fundamental_info, 0);
	XmppXepExternalServiceDiscoveryService_private_offset = g_type_add_instance_private (xmpp_xep_external_service_discovery_service_type_id, sizeof (XmppXepExternalServiceDiscoveryServicePrivate));
	return xmpp_xep_external_service_discovery_service_type_id;
}

GType
xmpp_xep_external_service_discovery_service_get_type (void)
{
	static volatile gsize xmpp_xep_external_service_discovery_service_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_external_service_discovery_service_type_id__once)) {
		GType xmpp_xep_external_service_discovery_service_type_id;
		xmpp_xep_external_service_discovery_service_type_id = xmpp_xep_external_service_discovery_service_get_type_once ();
		g_once_init_leave (&xmpp_xep_external_service_discovery_service_type_id__once, xmpp_xep_external_service_discovery_service_type_id);
	}
	return xmpp_xep_external_service_discovery_service_type_id__once;
}

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

void
xmpp_xep_external_service_discovery_service_unref (gpointer instance)
{
	XmppXepExternalServiceDiscoveryService * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_XEP_EXTERNAL_SERVICE_DISCOVERY_SERVICE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

