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

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

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

enum  {
	DINO_STREAM_INTERACTOR_0_PROPERTY,
	DINO_STREAM_INTERACTOR_NUM_PROPERTIES
};
static GParamSpec* dino_stream_interactor_properties[DINO_STREAM_INTERACTOR_NUM_PROPERTIES];
#define _dino_module_manager_unref0(var) ((var == NULL) ? NULL : (var = (dino_module_manager_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _DinoStreamInteractorDisconnectAccountData DinoStreamInteractorDisconnectAccountData;
typedef struct _Block45Data Block45Data;
enum  {
	DINO_STREAM_INTERACTOR_ACCOUNT_ADDED_SIGNAL,
	DINO_STREAM_INTERACTOR_ACCOUNT_REMOVED_SIGNAL,
	DINO_STREAM_INTERACTOR_STREAM_RESUMED_SIGNAL,
	DINO_STREAM_INTERACTOR_STREAM_NEGOTIATED_SIGNAL,
	DINO_STREAM_INTERACTOR_STREAM_ATTACHED_MODULES_SIGNAL,
	DINO_STREAM_INTERACTOR_NUM_SIGNALS
};
static guint dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_NUM_SIGNALS] = {0};
enum  {
	DINO_MODULE_IDENTITY_0_PROPERTY,
	DINO_MODULE_IDENTITY_T_TYPE,
	DINO_MODULE_IDENTITY_T_DUP_FUNC,
	DINO_MODULE_IDENTITY_T_DESTROY_FUNC,
	DINO_MODULE_IDENTITY_ID_PROPERTY,
	DINO_MODULE_IDENTITY_NUM_PROPERTIES
};
static GParamSpec* dino_module_identity_properties[DINO_MODULE_IDENTITY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _DinoStreamInteractorPrivate {
	GeeArrayList* modules;
};

struct _DinoStreamInteractorDisconnectAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoStreamInteractor* self;
	DinoEntitiesAccount* account;
	DinoConnectionManager* _tmp0_;
};

struct _Block45Data {
	int _ref_count_;
	DinoStreamInteractor* self;
	DinoEntitiesAccount* account;
};

struct _DinoModuleIdentityPrivate {
	GType t_type;
	GBoxedCopyFunc t_dup_func;
	GDestroyNotify t_destroy_func;
	gchar* _id;
};

static gint DinoStreamInteractor_private_offset;
static gpointer dino_stream_interactor_parent_class = NULL;
static gint DinoModuleIdentity_private_offset;
static gpointer dino_module_identity_parent_class = NULL;

static void dino_stream_interactor_on_stream_opened (DinoStreamInteractor* self,
                                              DinoEntitiesAccount* account,
                                              XmppXmppStream* stream);
static void _dino_stream_interactor_on_stream_opened_dino_connection_manager_stream_opened (DinoConnectionManager* _sender,
                                                                                     DinoEntitiesAccount* account,
                                                                                     XmppXmppStream* stream,
                                                                                     gpointer self);
static void __lambda15_ (DinoStreamInteractor* self,
                  DinoEntitiesAccount* account,
                  XmppXmppStream* stream);
static void ___lambda15__dino_connection_manager_stream_attached_modules (DinoConnectionManager* _sender,
                                                                   DinoEntitiesAccount* account,
                                                                   XmppXmppStream* stream,
                                                                   gpointer self);
static void dino_stream_interactor_disconnect_account_data_free (gpointer _data);
static gboolean dino_stream_interactor_disconnect_account_co (DinoStreamInteractorDisconnectAccountData* _data_);
static void dino_stream_interactor_disconnect_account_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static gboolean _dino_entities_account_equals_func_gee_equal_data_func (gconstpointer a,
                                                                 gconstpointer b,
                                                                 gpointer self);
static Block45Data* block45_data_ref (Block45Data* _data45_);
static void block45_data_unref (void * _userdata_);
static void __lambda14_ (Block45Data* _data45_,
                  XmppXmppStream* stream);
static void ___lambda14__xmpp_xmpp_stream_stream_negotiated (XmppXmppStream* _sender,
                                                      XmppXmppStream* stream,
                                                      gpointer self);
static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT (GClosure * closure,
                                                  GValue * return_value,
                                                  guint n_param_values,
                                                  const GValue * param_values,
                                                  gpointer invocation_hint,
                                                  gpointer marshal_data);
static void dino_stream_interactor_finalize (GObject * obj);
static GType dino_stream_interactor_get_type_once (void);
static void dino_module_identity_set_id (DinoModuleIdentity* self,
                                  const gchar* value);
static void dino_module_identity_finalize (GObject * obj);
static GType dino_module_identity_get_type_once (void);
static void _vala_dino_module_identity_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_dino_module_identity_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);
static GType dino_stream_interaction_module_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_stream_interactor_get_instance_private (DinoStreamInteractor* self)
{
	return G_STRUCT_MEMBER_P (self, DinoStreamInteractor_private_offset);
}

static void
_dino_stream_interactor_on_stream_opened_dino_connection_manager_stream_opened (DinoConnectionManager* _sender,
                                                                                DinoEntitiesAccount* account,
                                                                                XmppXmppStream* stream,
                                                                                gpointer self)
{
	dino_stream_interactor_on_stream_opened ((DinoStreamInteractor*) self, account, stream);
}

static void
__lambda15_ (DinoStreamInteractor* self,
             DinoEntitiesAccount* account,
             XmppXmppStream* stream)
{
	g_return_if_fail (account != NULL);
	g_return_if_fail (stream != NULL);
	g_signal_emit (self, dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_STREAM_ATTACHED_MODULES_SIGNAL], 0, account, stream);
}

static void
___lambda15__dino_connection_manager_stream_attached_modules (DinoConnectionManager* _sender,
                                                              DinoEntitiesAccount* account,
                                                              XmppXmppStream* stream,
                                                              gpointer self)
{
	__lambda15_ ((DinoStreamInteractor*) self, account, stream);
}

DinoStreamInteractor*
dino_stream_interactor_construct (GType object_type,
                                  DinoDatabase* db)
{
	DinoStreamInteractor * self = NULL;
	DinoModuleManager* _tmp0_;
	DinoModuleManager* _tmp1_;
	DinoConnectionManager* _tmp2_;
	DinoConnectionManager* _tmp3_;
	DinoConnectionManager* _tmp4_;
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoStreamInteractor*) g_object_new (object_type, NULL);
	_tmp0_ = dino_module_manager_new ();
	_dino_module_manager_unref0 (self->module_manager);
	self->module_manager = _tmp0_;
	_tmp1_ = self->module_manager;
	_tmp2_ = dino_connection_manager_new (_tmp1_);
	_g_object_unref0 (self->connection_manager);
	self->connection_manager = _tmp2_;
	_tmp3_ = self->connection_manager;
	g_signal_connect_object (_tmp3_, "stream-opened", (GCallback) _dino_stream_interactor_on_stream_opened_dino_connection_manager_stream_opened, self, 0);
	_tmp4_ = self->connection_manager;
	g_signal_connect_object (_tmp4_, "stream-attached-modules", (GCallback) ___lambda15__dino_connection_manager_stream_attached_modules, self, 0);
	return self;
}

DinoStreamInteractor*
dino_stream_interactor_new (DinoDatabase* db)
{
	return dino_stream_interactor_construct (DINO_TYPE_STREAM_INTERACTOR, db);
}

void
dino_stream_interactor_connect_account (DinoStreamInteractor* self,
                                        DinoEntitiesAccount* account)
{
	DinoModuleManager* _tmp0_;
	DinoConnectionManager* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_tmp0_ = self->module_manager;
	dino_module_manager_initialize (_tmp0_, account);
	g_signal_emit (self, dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_ACCOUNT_ADDED_SIGNAL], 0, account);
	_tmp1_ = self->connection_manager;
	dino_connection_manager_connect_account (_tmp1_, account);
}

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

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

void
dino_stream_interactor_disconnect_account (DinoStreamInteractor* self,
                                           DinoEntitiesAccount* account,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	DinoStreamInteractorDisconnectAccountData* _data_;
	DinoStreamInteractor* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_data_ = g_slice_new0 (DinoStreamInteractorDisconnectAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_stream_interactor_disconnect_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	dino_stream_interactor_disconnect_account_co (_data_);
}

void
dino_stream_interactor_disconnect_account_finish (DinoStreamInteractor* self,
                                                  GAsyncResult* _res_)
{
	DinoStreamInteractorDisconnectAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dino_stream_interactor_disconnect_account_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	DinoStreamInteractorDisconnectAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_stream_interactor_disconnect_account_co (_data_);
}

static gboolean
dino_stream_interactor_disconnect_account_co (DinoStreamInteractorDisconnectAccountData* _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->connection_manager;
	_data_->_state_ = 1;
	dino_connection_manager_disconnect_account (_data_->_tmp0_, _data_->account, dino_stream_interactor_disconnect_account_ready, _data_);
	return FALSE;
	_state_1:
	dino_connection_manager_disconnect_account_finish (_data_->_tmp0_, _data_->_res_);
	g_signal_emit (_data_->self, dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_ACCOUNT_REMOVED_SIGNAL], 0, _data_->account);
	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 gboolean
_dino_entities_account_equals_func_gee_equal_data_func (gconstpointer a,
                                                        gconstpointer b,
                                                        gpointer self)
{
	gboolean result;
	result = dino_entities_account_equals_func ((DinoEntitiesAccount*) a, (DinoEntitiesAccount*) b);
	return result;
}

GeeArrayList*
dino_stream_interactor_get_accounts (DinoStreamInteractor* self)
{
	GeeArrayList* ret = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (DINO_ENTITIES_TYPE_ACCOUNT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _dino_entities_account_equals_func_gee_equal_data_func, NULL, NULL);
	ret = _tmp0_;
	{
		GeeIterator* _account_it = NULL;
		DinoConnectionManager* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp1_ = self->connection_manager;
		_tmp2_ = dino_connection_manager_get_managed_accounts (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_account_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			DinoEntitiesAccount* account = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GeeArrayList* _tmp9_;
			DinoEntitiesAccount* _tmp10_;
			_tmp6_ = _account_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _account_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			account = (DinoEntitiesAccount*) _tmp8_;
			_tmp9_ = ret;
			_tmp10_ = account;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp10_);
			_g_object_unref0 (account);
		}
		_g_object_unref0 (_account_it);
	}
	result = ret;
	return result;
}

XmppXmppStream*
dino_stream_interactor_get_stream (DinoStreamInteractor* self,
                                   DinoEntitiesAccount* account)
{
	DinoConnectionManager* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppXmppStream* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	_tmp0_ = self->connection_manager;
	_tmp1_ = dino_connection_manager_get_stream (_tmp0_, account);
	result = _tmp1_;
	return result;
}

void
dino_stream_interactor_add_module (DinoStreamInteractor* self,
                                   DinoStreamInteractionModule* module)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (module != NULL);
	_tmp0_ = self->priv->modules;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, module);
}

gpointer
dino_stream_interactor_get_module (DinoStreamInteractor* self,
                                   GType t_type,
                                   GBoxedCopyFunc t_dup_func,
                                   GDestroyNotify t_destroy_func,
                                   DinoModuleIdentity* identity)
{
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	if (identity == NULL) {
		result = NULL;
		return result;
	}
	{
		GeeArrayList* _module_list = NULL;
		GeeArrayList* _tmp0_;
		gint _module_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _module_index = 0;
		_tmp0_ = self->priv->modules;
		_module_list = _tmp0_;
		_tmp1_ = _module_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_module_size = _tmp3_;
		_module_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			DinoStreamInteractionModule* module = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			DinoStreamInteractionModule* _tmp8_;
			_module_index = _module_index + 1;
			_tmp4_ = _module_index;
			_tmp5_ = _module_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _module_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _module_index);
			module = (DinoStreamInteractionModule*) _tmp7_;
			_tmp8_ = module;
			if (dino_module_identity_matches (identity, _tmp8_)) {
				DinoStreamInteractionModule* _tmp9_;
				gpointer _tmp10_;
				_tmp9_ = module;
				_tmp10_ = dino_module_identity_cast (identity, _tmp9_);
				result = _tmp10_;
				_g_object_unref0 (module);
				return result;
			}
			_g_object_unref0 (module);
		}
	}
	result = NULL;
	return result;
}

gpointer
dino_stream_interactor_get (DinoStreamInteractor* self,
                            GType t_type,
                            GBoxedCopyFunc t_dup_func,
                            GDestroyNotify t_destroy_func)
{
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	{
		GeeArrayList* _module_list = NULL;
		GeeArrayList* _tmp0_;
		gint _module_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _module_index = 0;
		_tmp0_ = self->priv->modules;
		_module_list = _tmp0_;
		_tmp1_ = _module_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_module_size = _tmp3_;
		_module_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			DinoStreamInteractionModule* module = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			DinoStreamInteractionModule* _tmp8_;
			_module_index = _module_index + 1;
			_tmp4_ = _module_index;
			_tmp5_ = _module_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _module_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _module_index);
			module = (DinoStreamInteractionModule*) _tmp7_;
			_tmp8_ = module;
			if (G_TYPE_FROM_INSTANCE ((GObject*) _tmp8_) == t_type) {
				DinoStreamInteractionModule* _tmp9_;
				gpointer _tmp10_;
				_tmp9_ = module;
				_tmp10_ = ((((gconstpointer) _tmp9_) != NULL) && (t_dup_func != NULL)) ? t_dup_func ((gpointer) ((gconstpointer) _tmp9_)) : ((gpointer) ((gconstpointer) _tmp9_));
				result = _tmp10_;
				_g_object_unref0 (module);
				return result;
			}
			_g_object_unref0 (module);
		}
	}
	result = NULL;
	return result;
}

static Block45Data*
block45_data_ref (Block45Data* _data45_)
{
	g_atomic_int_inc (&_data45_->_ref_count_);
	return _data45_;
}

static void
block45_data_unref (void * _userdata_)
{
	Block45Data* _data45_;
	_data45_ = (Block45Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data45_->_ref_count_)) {
		DinoStreamInteractor* self;
		self = _data45_->self;
		_g_object_unref0 (_data45_->account);
		_g_object_unref0 (self);
		g_slice_free (Block45Data, _data45_);
	}
}

static void
__lambda14_ (Block45Data* _data45_,
             XmppXmppStream* stream)
{
	DinoStreamInteractor* self;
	XmppXepStreamManagementFlag* flag = NULL;
	XmppFlagIdentity* _tmp0_;
	gpointer _tmp1_;
	gboolean _tmp2_ = FALSE;
	XmppXepStreamManagementFlag* _tmp3_;
	self = _data45_->self;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_xep_stream_management_flag_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_STREAM_MANAGEMENT_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	flag = (XmppXepStreamManagementFlag*) _tmp1_;
	_tmp3_ = flag;
	if (_tmp3_ == NULL) {
		_tmp2_ = TRUE;
	} else {
		XmppXepStreamManagementFlag* _tmp4_;
		_tmp4_ = flag;
		_tmp2_ = _tmp4_->resumed == FALSE;
	}
	if (_tmp2_) {
		g_signal_emit (self, dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_STREAM_NEGOTIATED_SIGNAL], 0, _data45_->account, stream);
	} else {
		gboolean _tmp5_ = FALSE;
		XmppXepStreamManagementFlag* _tmp6_;
		_tmp6_ = flag;
		if (_tmp6_ != NULL) {
			XmppXepStreamManagementFlag* _tmp7_;
			_tmp7_ = flag;
			_tmp5_ = _tmp7_->resumed == TRUE;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			g_signal_emit (self, dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_STREAM_RESUMED_SIGNAL], 0, _data45_->account, stream);
		}
	}
	_g_object_unref0 (flag);
}

static void
___lambda14__xmpp_xmpp_stream_stream_negotiated (XmppXmppStream* _sender,
                                                 XmppXmppStream* stream,
                                                 gpointer self)
{
	__lambda14_ (self, stream);
}

static void
dino_stream_interactor_on_stream_opened (DinoStreamInteractor* self,
                                         DinoEntitiesAccount* account,
                                         XmppXmppStream* stream)
{
	Block45Data* _data45_;
	DinoEntitiesAccount* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (stream != NULL);
	_data45_ = g_slice_new0 (Block45Data);
	_data45_->_ref_count_ = 1;
	_data45_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (_data45_->account);
	_data45_->account = _tmp0_;
	g_signal_connect_data (stream, "stream-negotiated", (GCallback) ___lambda14__xmpp_xmpp_stream_stream_negotiated, block45_data_ref (_data45_), (GClosureNotify) block45_data_unref, 0);
	block45_data_unref (_data45_);
	_data45_ = NULL;
}

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

static void
dino_stream_interactor_class_init (DinoStreamInteractorClass * klass,
                                   gpointer klass_data)
{
	dino_stream_interactor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoStreamInteractor_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dino_stream_interactor_finalize;
	dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_ACCOUNT_ADDED_SIGNAL] = g_signal_new ("account-added", DINO_TYPE_STREAM_INTERACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DINO_ENTITIES_TYPE_ACCOUNT);
	dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_ACCOUNT_REMOVED_SIGNAL] = g_signal_new ("account-removed", DINO_TYPE_STREAM_INTERACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DINO_ENTITIES_TYPE_ACCOUNT);
	dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_STREAM_RESUMED_SIGNAL] = g_signal_new ("stream-resumed", DINO_TYPE_STREAM_INTERACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, DINO_ENTITIES_TYPE_ACCOUNT, XMPP_TYPE_XMPP_STREAM);
	dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_STREAM_NEGOTIATED_SIGNAL] = g_signal_new ("stream-negotiated", DINO_TYPE_STREAM_INTERACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, DINO_ENTITIES_TYPE_ACCOUNT, XMPP_TYPE_XMPP_STREAM);
	dino_stream_interactor_signals[DINO_STREAM_INTERACTOR_STREAM_ATTACHED_MODULES_SIGNAL] = g_signal_new ("stream-attached-modules", DINO_TYPE_STREAM_INTERACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, DINO_ENTITIES_TYPE_ACCOUNT, XMPP_TYPE_XMPP_STREAM);
}

static void
dino_stream_interactor_instance_init (DinoStreamInteractor * self,
                                      gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = dino_stream_interactor_get_instance_private (self);
	_tmp0_ = gee_array_list_new (DINO_TYPE_STREAM_INTERACTION_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->modules = _tmp0_;
}

static void
dino_stream_interactor_finalize (GObject * obj)
{
	DinoStreamInteractor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_STREAM_INTERACTOR, DinoStreamInteractor);
	_dino_module_manager_unref0 (self->module_manager);
	_g_object_unref0 (self->connection_manager);
	_g_object_unref0 (self->priv->modules);
	G_OBJECT_CLASS (dino_stream_interactor_parent_class)->finalize (obj);
}

static GType
dino_stream_interactor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoStreamInteractorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_stream_interactor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoStreamInteractor), 0, (GInstanceInitFunc) dino_stream_interactor_instance_init, NULL };
	GType dino_stream_interactor_type_id;
	dino_stream_interactor_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoStreamInteractor", &g_define_type_info, 0);
	DinoStreamInteractor_private_offset = g_type_add_instance_private (dino_stream_interactor_type_id, sizeof (DinoStreamInteractorPrivate));
	return dino_stream_interactor_type_id;
}

GType
dino_stream_interactor_get_type (void)
{
	static volatile gsize dino_stream_interactor_type_id__once = 0;
	if (g_once_init_enter (&dino_stream_interactor_type_id__once)) {
		GType dino_stream_interactor_type_id;
		dino_stream_interactor_type_id = dino_stream_interactor_get_type_once ();
		g_once_init_leave (&dino_stream_interactor_type_id__once, dino_stream_interactor_type_id);
	}
	return dino_stream_interactor_type_id__once;
}

static inline gpointer
dino_module_identity_get_instance_private (DinoModuleIdentity* self)
{
	return G_STRUCT_MEMBER_P (self, DinoModuleIdentity_private_offset);
}

DinoModuleIdentity*
dino_module_identity_construct (GType object_type,
                                GType t_type,
                                GBoxedCopyFunc t_dup_func,
                                GDestroyNotify t_destroy_func,
                                const gchar* id)
{
	DinoModuleIdentity * self = NULL;
	g_return_val_if_fail (id != NULL, NULL);
	self = (DinoModuleIdentity*) g_object_new (object_type, "t-type", t_type, "t-dup-func", t_dup_func, "t-destroy-func", t_destroy_func, NULL);
	self->priv->t_type = t_type;
	self->priv->t_dup_func = t_dup_func;
	self->priv->t_destroy_func = t_destroy_func;
	dino_module_identity_set_id (self, id);
	return self;
}

DinoModuleIdentity*
dino_module_identity_new (GType t_type,
                          GBoxedCopyFunc t_dup_func,
                          GDestroyNotify t_destroy_func,
                          const gchar* id)
{
	return dino_module_identity_construct (DINO_TYPE_MODULE_IDENTITY, t_type, t_dup_func, t_destroy_func, id);
}

gpointer
dino_module_identity_cast (DinoModuleIdentity* self,
                           DinoStreamInteractionModule* module)
{
	gconstpointer _tmp0_ = NULL;
	gpointer _tmp1_;
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (module != NULL, NULL);
	if (g_type_is_a (G_TYPE_FROM_INSTANCE ((GObject*) module), self->priv->t_type)) {
		_tmp0_ = (gconstpointer) module;
	} else {
		_tmp0_ = NULL;
	}
	_tmp1_ = ((_tmp0_ != NULL) && (self->priv->t_dup_func != NULL)) ? self->priv->t_dup_func ((gpointer) _tmp0_) : ((gpointer) _tmp0_);
	result = _tmp1_;
	return result;
}

gboolean
dino_module_identity_matches (DinoModuleIdentity* self,
                              DinoStreamInteractionModule* module)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (module != NULL, FALSE);
	_tmp0_ = dino_stream_interaction_module_get_id (module);
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->_id;
	result = g_strcmp0 (_tmp1_, _tmp2_) == 0;
	return result;
}

const gchar*
dino_module_identity_get_id (DinoModuleIdentity* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_id;
	result = _tmp0_;
	return result;
}

static void
dino_module_identity_set_id (DinoModuleIdentity* self,
                             const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = dino_module_identity_get_id (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_id);
		self->priv->_id = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dino_module_identity_properties[DINO_MODULE_IDENTITY_ID_PROPERTY]);
	}
}

static void
dino_module_identity_class_init (DinoModuleIdentityClass * klass,
                                 gpointer klass_data)
{
	dino_module_identity_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoModuleIdentity_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_module_identity_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dino_module_identity_set_property;
	G_OBJECT_CLASS (klass)->finalize = dino_module_identity_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_MODULE_IDENTITY_T_TYPE, g_param_spec_gtype ("t-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_MODULE_IDENTITY_T_DUP_FUNC, g_param_spec_pointer ("t-dup-func", "dup func", "dup func", G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_MODULE_IDENTITY_T_DESTROY_FUNC, g_param_spec_pointer ("t-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_MODULE_IDENTITY_ID_PROPERTY, dino_module_identity_properties[DINO_MODULE_IDENTITY_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dino_module_identity_instance_init (DinoModuleIdentity * self,
                                    gpointer klass)
{
	self->priv = dino_module_identity_get_instance_private (self);
}

static void
dino_module_identity_finalize (GObject * obj)
{
	DinoModuleIdentity * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_MODULE_IDENTITY, DinoModuleIdentity);
	_g_free0 (self->priv->_id);
	G_OBJECT_CLASS (dino_module_identity_parent_class)->finalize (obj);
}

static GType
dino_module_identity_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoModuleIdentityClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_module_identity_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoModuleIdentity), 0, (GInstanceInitFunc) dino_module_identity_instance_init, NULL };
	GType dino_module_identity_type_id;
	dino_module_identity_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoModuleIdentity", &g_define_type_info, 0);
	DinoModuleIdentity_private_offset = g_type_add_instance_private (dino_module_identity_type_id, sizeof (DinoModuleIdentityPrivate));
	return dino_module_identity_type_id;
}

GType
dino_module_identity_get_type (void)
{
	static volatile gsize dino_module_identity_type_id__once = 0;
	if (g_once_init_enter (&dino_module_identity_type_id__once)) {
		GType dino_module_identity_type_id;
		dino_module_identity_type_id = dino_module_identity_get_type_once ();
		g_once_init_leave (&dino_module_identity_type_id__once, dino_module_identity_type_id);
	}
	return dino_module_identity_type_id__once;
}

static void
_vala_dino_module_identity_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	DinoModuleIdentity * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_MODULE_IDENTITY, DinoModuleIdentity);
	switch (property_id) {
		case DINO_MODULE_IDENTITY_ID_PROPERTY:
		g_value_set_string (value, dino_module_identity_get_id (self));
		break;
		case DINO_MODULE_IDENTITY_T_TYPE:
		g_value_set_gtype (value, self->priv->t_type);
		break;
		case DINO_MODULE_IDENTITY_T_DUP_FUNC:
		g_value_set_pointer (value, self->priv->t_dup_func);
		break;
		case DINO_MODULE_IDENTITY_T_DESTROY_FUNC:
		g_value_set_pointer (value, self->priv->t_destroy_func);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dino_module_identity_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	DinoModuleIdentity * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_MODULE_IDENTITY, DinoModuleIdentity);
	switch (property_id) {
		case DINO_MODULE_IDENTITY_ID_PROPERTY:
		dino_module_identity_set_id (self, g_value_get_string (value));
		break;
		case DINO_MODULE_IDENTITY_T_TYPE:
		self->priv->t_type = g_value_get_gtype (value);
		break;
		case DINO_MODULE_IDENTITY_T_DUP_FUNC:
		self->priv->t_dup_func = g_value_get_pointer (value);
		break;
		case DINO_MODULE_IDENTITY_T_DESTROY_FUNC:
		self->priv->t_destroy_func = g_value_get_pointer (value);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

const gchar*
dino_stream_interaction_module_get_id (DinoStreamInteractionModule* self)
{
	DinoStreamInteractionModuleIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = DINO_STREAM_INTERACTION_MODULE_GET_INTERFACE (self);
	if (_iface_->get_id) {
		return _iface_->get_id (self);
	}
	return NULL;
}

static void
dino_stream_interaction_module_default_init (DinoStreamInteractionModuleIface * iface,
                                             gpointer iface_data)
{
	g_object_interface_install_property (iface, g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static GType
dino_stream_interaction_module_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoStreamInteractionModuleIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_stream_interaction_module_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType dino_stream_interaction_module_type_id;
	dino_stream_interaction_module_type_id = g_type_register_static (G_TYPE_INTERFACE, "DinoStreamInteractionModule", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (dino_stream_interaction_module_type_id, G_TYPE_OBJECT);
	return dino_stream_interaction_module_type_id;
}

GType
dino_stream_interaction_module_get_type (void)
{
	static volatile gsize dino_stream_interaction_module_type_id__once = 0;
	if (g_once_init_enter (&dino_stream_interaction_module_type_id__once)) {
		GType dino_stream_interaction_module_type_id;
		dino_stream_interaction_module_type_id = dino_stream_interaction_module_get_type_once ();
		g_once_init_leave (&dino_stream_interaction_module_type_id__once, dino_stream_interaction_module_type_id);
	}
	return dino_stream_interaction_module_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;
}

