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

#include "libdino.h"
#include <gee.h>
#include <glib-object.h>
#include <glib.h>
#include "xmpp-vala.h"
#include "qlite.h"
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.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  {
	DINO_CHAT_INTERACTION_0_PROPERTY,
	DINO_CHAT_INTERACTION_ID_PROPERTY,
	DINO_CHAT_INTERACTION_NUM_PROPERTIES
};
static GParamSpec* dino_chat_interaction_properties[DINO_CHAT_INTERACTION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER (dino_chat_interaction_received_message_listener_get_type ())
#define DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER, DinoChatInteractionReceivedMessageListener))
#define DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER, DinoChatInteractionReceivedMessageListenerClass))
#define DINO_CHAT_INTERACTION_IS_RECEIVED_MESSAGE_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER))
#define DINO_CHAT_INTERACTION_IS_RECEIVED_MESSAGE_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER))
#define DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER, DinoChatInteractionReceivedMessageListenerClass))

typedef struct _DinoChatInteractionReceivedMessageListener DinoChatInteractionReceivedMessageListener;
typedef struct _DinoChatInteractionReceivedMessageListenerClass DinoChatInteractionReceivedMessageListenerClass;
#define _qlite_statement_builder_unref0(var) ((var == NULL) ? NULL : (var = (qlite_statement_builder_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _qlite_database_unref0(var) ((var == NULL) ? NULL : (var = (qlite_database_unref (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
typedef struct _DinoChatInteractionReceivedMessageListenerPrivate DinoChatInteractionReceivedMessageListenerPrivate;
enum  {
	DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_0_PROPERTY,
	DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY,
	DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_AFTER_ACTIONS_PROPERTY,
	DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_NUM_PROPERTIES
};
static GParamSpec* dino_chat_interaction_received_message_listener_properties[DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_NUM_PROPERTIES];
typedef struct _DinoChatInteractionReceivedMessageListenerRunData DinoChatInteractionReceivedMessageListenerRunData;
enum  {
	DINO_CHAT_INTERACTION_FOCUSED_IN_SIGNAL,
	DINO_CHAT_INTERACTION_FOCUSED_OUT_SIGNAL,
	DINO_CHAT_INTERACTION_NUM_SIGNALS
};
static guint dino_chat_interaction_signals[DINO_CHAT_INTERACTION_NUM_SIGNALS] = {0};

struct _DinoChatInteractionPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoEntitiesConversation* selected_conversation;
	GeeHashMap* last_input_interaction;
	GeeHashMap* last_interface_interaction;
	gboolean focus_in;
};

struct _DinoChatInteractionReceivedMessageListener {
	DinoMessageListener parent_instance;
	DinoChatInteractionReceivedMessageListenerPrivate * priv;
	gchar** after_actions_const;
	gint after_actions_const_length1;
	gint _after_actions_const_size_;
};

struct _DinoChatInteractionReceivedMessageListenerClass {
	DinoMessageListenerClass parent_class;
};

struct _DinoChatInteractionReceivedMessageListenerPrivate {
	DinoStreamInteractor* stream_interactor;
};

struct _DinoChatInteractionReceivedMessageListenerRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoChatInteractionReceivedMessageListener* self;
	DinoEntitiesMessage* message;
	XmppMessageStanza* stanza;
	DinoEntitiesConversation* conversation;
	gboolean result;
	XmppMessageArchiveManagementMessageFlag* _tmp0_;
	XmppMessageArchiveManagementMessageFlag* _tmp1_;
	gboolean _tmp2_;
	DinoChatInteraction* outer;
	DinoStreamInteractor* _tmp3_;
	DinoModuleIdentity* _tmp4_;
	gpointer _tmp5_;
	DinoChatInteraction* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	DinoChatInteraction* _tmp9_;
	DinoChatInteraction* _tmp10_;
	DinoChatInteraction* _tmp11_;
	DinoChatInteraction* _tmp12_;
};

static gint DinoChatInteraction_private_offset;
static gpointer dino_chat_interaction_parent_class = NULL;
DinoModuleIdentity* dino_chat_interaction_IDENTITY = NULL;
static gint DinoChatInteractionReceivedMessageListener_private_offset;
static gpointer dino_chat_interaction_received_message_listener_parent_class = NULL;
static DinoStreamInteractionModuleIface * dino_chat_interaction_dino_stream_interaction_module_parent_iface = NULL;

static guint _dino_entities_conversation_hash_func_gee_hash_data_func (gconstpointer v,
                                                                gpointer self);
static gboolean _dino_entities_conversation_equals_func_gee_equal_data_func (gconstpointer a,
                                                                      gconstpointer b,
                                                                      gpointer self);
static DinoChatInteraction* dino_chat_interaction_new (DinoStreamInteractor* stream_interactor);
static DinoChatInteraction* dino_chat_interaction_construct (GType object_type,
                                                      DinoStreamInteractor* stream_interactor);
static gboolean dino_chat_interaction_update_interactions (DinoChatInteraction* self);
static gboolean _dino_chat_interaction_update_interactions_gsource_func (gpointer self);
static DinoChatInteractionReceivedMessageListener* dino_chat_interaction_received_message_listener_new (DinoStreamInteractor* stream_interactor);
static DinoChatInteractionReceivedMessageListener* dino_chat_interaction_received_message_listener_construct (GType object_type,
                                                                                                       DinoStreamInteractor* stream_interactor);
static GType dino_chat_interaction_received_message_listener_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void dino_chat_interaction_on_message_sent (DinoChatInteraction* self,
                                            DinoEntitiesMessage* message,
                                            DinoEntitiesConversation* conversation);
static void _dino_chat_interaction_on_message_sent_dino_message_processor_message_sent (DinoMessageProcessor* _sender,
                                                                                 DinoEntitiesMessage* message,
                                                                                 DinoEntitiesConversation* conversation,
                                                                                 gpointer self);
static void dino_chat_interaction_new_item (DinoChatInteraction* self,
                                     DinoContentItem* item,
                                     DinoEntitiesConversation* conversation);
static void _dino_chat_interaction_new_item_dino_content_item_store_new_item (DinoContentItemStore* _sender,
                                                                       DinoContentItem* item,
                                                                       DinoEntitiesConversation* conversation,
                                                                       gpointer self);
static void dino_chat_interaction_on_conversation_focused (DinoChatInteraction* self,
                                                    DinoEntitiesConversation* conversation);
static void dino_chat_interaction_on_conversation_unfocused (DinoChatInteraction* self,
                                                      DinoEntitiesConversation* conversation);
static void dino_chat_interaction_send_chat_state_notification (DinoChatInteraction* self,
                                                         DinoEntitiesConversation* conversation,
                                                         const gchar* state);
static void dino_chat_interaction_check_send_read (DinoChatInteraction* self);
static void dino_chat_interaction_send_chat_marker (DinoChatInteraction* self,
                                             DinoEntitiesMessage* message,
                                             XmppMessageStanza* stanza,
                                             DinoEntitiesConversation* conversation,
                                             const gchar* marker);
static void dino_chat_interaction_send_delivery_receipt (DinoChatInteraction* self,
                                                  DinoEntitiesMessage* message,
                                                  XmppMessageStanza* stanza,
                                                  DinoEntitiesConversation* conversation);
static void dino_chat_interaction_received_message_listener_real_run_data_free (gpointer _data);
static void dino_chat_interaction_received_message_listener_real_run (DinoMessageListener* base,
                                                               DinoEntitiesMessage* message,
                                                               XmppMessageStanza* stanza,
                                                               DinoEntitiesConversation* conversation,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_);
static gboolean dino_chat_interaction_received_message_listener_real_run_co (DinoChatInteractionReceivedMessageListenerRunData* _data_);
static void dino_chat_interaction_received_message_listener_finalize (GObject * obj);
static GType dino_chat_interaction_received_message_listener_get_type_once (void);
static void _vala_dino_chat_interaction_received_message_listener_get_property (GObject * object,
                                                                         guint property_id,
                                                                         GValue * value,
                                                                         GParamSpec * pspec);
static void dino_chat_interaction_finalize (GObject * obj);
static GType dino_chat_interaction_get_type_once (void);
static void _vala_dino_chat_interaction_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_chat_interaction_get_instance_private (DinoChatInteraction* self)
{
	return G_STRUCT_MEMBER_P (self, DinoChatInteraction_private_offset);
}

static guint
_dino_entities_conversation_hash_func_gee_hash_data_func (gconstpointer v,
                                                          gpointer self)
{
	guint result;
	result = dino_entities_conversation_hash_func ((DinoEntitiesConversation*) v);
	return result;
}

static gboolean
_dino_entities_conversation_equals_func_gee_equal_data_func (gconstpointer a,
                                                             gconstpointer b,
                                                             gpointer self)
{
	gboolean result;
	result = dino_entities_conversation_equals_func ((DinoEntitiesConversation*) a, (DinoEntitiesConversation*) b);
	return result;
}

void
dino_chat_interaction_start (DinoStreamInteractor* stream_interactor)
{
	DinoChatInteraction* m = NULL;
	DinoChatInteraction* _tmp0_;
	g_return_if_fail (stream_interactor != NULL);
	_tmp0_ = dino_chat_interaction_new (stream_interactor);
	m = _tmp0_;
	dino_stream_interactor_add_module (stream_interactor, (DinoStreamInteractionModule*) m);
	_g_object_unref0 (m);
}

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

static gboolean
_dino_chat_interaction_update_interactions_gsource_func (gpointer self)
{
	gboolean result;
	result = dino_chat_interaction_update_interactions ((DinoChatInteraction*) self);
	return result;
}

static void
_dino_chat_interaction_on_message_sent_dino_message_processor_message_sent (DinoMessageProcessor* _sender,
                                                                            DinoEntitiesMessage* message,
                                                                            DinoEntitiesConversation* conversation,
                                                                            gpointer self)
{
	dino_chat_interaction_on_message_sent ((DinoChatInteraction*) self, message, conversation);
}

static void
_dino_chat_interaction_new_item_dino_content_item_store_new_item (DinoContentItemStore* _sender,
                                                                  DinoContentItem* item,
                                                                  DinoEntitiesConversation* conversation,
                                                                  gpointer self)
{
	dino_chat_interaction_new_item ((DinoChatInteraction*) self, item, conversation);
}

static DinoChatInteraction*
dino_chat_interaction_construct (GType object_type,
                                 DinoStreamInteractor* stream_interactor)
{
	DinoChatInteraction * self = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoMessageProcessor* _tmp3_;
	DinoMessageListenerHolder* _tmp4_;
	DinoChatInteractionReceivedMessageListener* _tmp5_;
	DinoChatInteractionReceivedMessageListener* _tmp6_;
	DinoModuleIdentity* _tmp7_;
	gpointer _tmp8_;
	DinoMessageProcessor* _tmp9_;
	DinoModuleIdentity* _tmp10_;
	gpointer _tmp11_;
	DinoContentItemStore* _tmp12_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	self = (DinoChatInteraction*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 30, _dino_chat_interaction_update_interactions_gsource_func, g_object_ref (self), g_object_unref);
	_tmp1_ = dino_message_processor_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoMessageProcessor*) _tmp2_;
	_tmp4_ = _tmp3_->received_pipeline;
	_tmp5_ = dino_chat_interaction_received_message_listener_new (stream_interactor);
	_tmp6_ = _tmp5_;
	xmpp_listener_holder_connect ((XmppListenerHolder*) _tmp4_, (XmppOrderedListener*) _tmp6_);
	_g_object_unref0 (_tmp6_);
	_g_object_unref0 (_tmp3_);
	_tmp7_ = dino_message_processor_IDENTITY;
	_tmp8_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp7_);
	_tmp9_ = (DinoMessageProcessor*) _tmp8_;
	g_signal_connect_object (_tmp9_, "message-sent", (GCallback) _dino_chat_interaction_on_message_sent_dino_message_processor_message_sent, self, 0);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = dino_content_item_store_IDENTITY;
	_tmp11_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_CONTENT_ITEM_STORE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp10_);
	_tmp12_ = (DinoContentItemStore*) _tmp11_;
	g_signal_connect_object (_tmp12_, "new-item", (GCallback) _dino_chat_interaction_new_item_dino_content_item_store_new_item, self, 0);
	_g_object_unref0 (_tmp12_);
	return self;
}

static DinoChatInteraction*
dino_chat_interaction_new (DinoStreamInteractor* stream_interactor)
{
	return dino_chat_interaction_construct (DINO_TYPE_CHAT_INTERACTION, stream_interactor);
}

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

gint
dino_chat_interaction_get_num_unread (DinoChatInteraction* self,
                                      DinoEntitiesConversation* conversation)
{
	DinoDatabase* db = NULL;
	DinoApplication* _tmp0_;
	DinoDatabase* _tmp1_;
	DinoDatabase* _tmp2_;
	DinoDatabase* _tmp3_;
	QliteQueryBuilder* query = NULL;
	DinoDatabase* _tmp4_;
	DinoDatabaseContentItemTable* _tmp5_;
	DinoDatabaseContentItemTable* _tmp6_;
	QliteQueryBuilder* _tmp7_;
	QliteQueryBuilder* _tmp8_;
	DinoDatabase* _tmp9_;
	DinoDatabaseContentItemTable* _tmp10_;
	DinoDatabaseContentItemTable* _tmp11_;
	QliteColumn* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	QliteQueryBuilder* _tmp15_;
	QliteQueryBuilder* _tmp16_;
	DinoDatabase* _tmp17_;
	DinoDatabaseContentItemTable* _tmp18_;
	DinoDatabaseContentItemTable* _tmp19_;
	QliteColumn* _tmp20_;
	QliteQueryBuilder* _tmp21_;
	QliteQueryBuilder* _tmp22_;
	DinoContentItem* read_up_to_item = NULL;
	DinoStreamInteractor* _tmp23_;
	DinoModuleIdentity* _tmp24_;
	gpointer _tmp25_;
	DinoContentItemStore* _tmp26_;
	gint _tmp27_;
	gint _tmp28_;
	DinoContentItem* _tmp29_;
	DinoContentItem* _tmp30_;
	DinoContentItem* _tmp31_;
	QliteQueryBuilder* _tmp51_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (conversation != NULL, -1);
	_tmp0_ = dino_application_get_default ();
	_tmp1_ = dino_application_get_db (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _qlite_database_ref0 (_tmp2_);
	db = _tmp3_;
	_tmp4_ = db;
	_tmp5_ = dino_database_get_content_item (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = qlite_table_select ((QliteTable*) _tmp6_, NULL, (gint) 0);
	_tmp8_ = _tmp7_;
	_tmp9_ = db;
	_tmp10_ = dino_database_get_content_item (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = _tmp11_->conversation_id;
	_tmp13_ = dino_entities_conversation_get_id (conversation);
	_tmp14_ = _tmp13_;
	_tmp15_ = qlite_query_builder_with (_tmp8_, G_TYPE_INT, NULL, NULL, _tmp12_, "=", (gpointer) ((gintptr) _tmp14_));
	_tmp16_ = _tmp15_;
	_tmp17_ = db;
	_tmp18_ = dino_database_get_content_item (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = _tmp19_->hide;
	_tmp21_ = qlite_query_builder_with (_tmp16_, G_TYPE_BOOLEAN, NULL, NULL, _tmp20_, "=", (gpointer) ((gintptr) FALSE));
	_tmp22_ = _tmp21_;
	_qlite_statement_builder_unref0 (_tmp16_);
	_qlite_statement_builder_unref0 (_tmp8_);
	query = _tmp22_;
	_tmp23_ = self->priv->stream_interactor;
	_tmp24_ = dino_content_item_store_IDENTITY;
	_tmp25_ = dino_stream_interactor_get_module (_tmp23_, DINO_TYPE_CONTENT_ITEM_STORE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp24_);
	_tmp26_ = (DinoContentItemStore*) _tmp25_;
	_tmp27_ = dino_entities_conversation_get_read_up_to_item (conversation);
	_tmp28_ = _tmp27_;
	_tmp29_ = dino_content_item_store_get_item_by_id (_tmp26_, conversation, _tmp28_);
	_tmp30_ = _tmp29_;
	_g_object_unref0 (_tmp26_);
	read_up_to_item = _tmp30_;
	_tmp31_ = read_up_to_item;
	if (_tmp31_ != NULL) {
		gchar* time = NULL;
		DinoContentItem* _tmp32_;
		GDateTime* _tmp33_;
		GDateTime* _tmp34_;
		gchar* _tmp35_;
		gchar* id = NULL;
		DinoContentItem* _tmp36_;
		gint _tmp37_;
		gint _tmp38_;
		gchar* _tmp39_;
		QliteQueryBuilder* _tmp40_;
		const gchar* _tmp41_;
		gchar* _tmp42_;
		const gchar* _tmp43_;
		gchar* _tmp44_;
		const gchar* _tmp45_;
		gchar* _tmp46_;
		gchar** _tmp47_;
		gchar** _tmp48_;
		gint _tmp48__length1;
		QliteQueryBuilder* _tmp49_;
		QliteQueryBuilder* _tmp50_;
		_tmp32_ = read_up_to_item;
		_tmp33_ = dino_content_item_get_time (_tmp32_);
		_tmp34_ = _tmp33_;
		_tmp35_ = g_strdup_printf ("%" G_GINT64_FORMAT, g_date_time_to_unix (_tmp34_));
		time = _tmp35_;
		_tmp36_ = read_up_to_item;
		_tmp37_ = dino_content_item_get_id (_tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = g_strdup_printf ("%i", _tmp38_);
		id = _tmp39_;
		_tmp40_ = query;
		_tmp41_ = time;
		_tmp42_ = g_strdup (_tmp41_);
		_tmp43_ = time;
		_tmp44_ = g_strdup (_tmp43_);
		_tmp45_ = id;
		_tmp46_ = g_strdup (_tmp45_);
		_tmp47_ = g_new0 (gchar*, 3 + 1);
		_tmp47_[0] = _tmp42_;
		_tmp47_[1] = _tmp44_;
		_tmp47_[2] = _tmp46_;
		_tmp48_ = _tmp47_;
		_tmp48__length1 = 3;
		_tmp49_ = qlite_query_builder_where (_tmp40_, "time > ? OR (time = ? AND id > ?)", _tmp48_, (gint) 3);
		_tmp50_ = _tmp49_;
		_qlite_statement_builder_unref0 (_tmp50_);
		_tmp48_ = (_vala_array_free (_tmp48_, _tmp48__length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (id);
		_g_free0 (time);
	}
	_tmp51_ = query;
	result = (gint) qlite_query_builder_count (_tmp51_);
	_g_object_unref0 (read_up_to_item);
	_qlite_statement_builder_unref0 (query);
	_qlite_database_unref0 (db);
	return result;
}

gboolean
dino_chat_interaction_is_active_focus (DinoChatInteraction* self,
                                       DinoEntitiesConversation* conversation)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (conversation != NULL) {
		gboolean _tmp0_ = FALSE;
		if (self->priv->focus_in) {
			DinoEntitiesConversation* _tmp1_;
			_tmp1_ = self->priv->selected_conversation;
			_tmp0_ = dino_entities_conversation_equals (conversation, _tmp1_);
		} else {
			_tmp0_ = FALSE;
		}
		result = _tmp0_;
		return result;
	} else {
		result = self->priv->focus_in;
		return result;
	}
}

void
dino_chat_interaction_on_window_focus_in (DinoChatInteraction* self,
                                          DinoEntitiesConversation* conversation)
{
	g_return_if_fail (self != NULL);
	dino_chat_interaction_on_conversation_focused (self, conversation);
}

void
dino_chat_interaction_on_window_focus_out (DinoChatInteraction* self,
                                           DinoEntitiesConversation* conversation)
{
	g_return_if_fail (self != NULL);
	dino_chat_interaction_on_conversation_unfocused (self, conversation);
}

void
dino_chat_interaction_on_message_entered (DinoChatInteraction* self,
                                          DinoEntitiesConversation* conversation)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	GDateTime* _tmp2_;
	GDateTime* _tmp3_;
	GeeHashMap* _tmp4_;
	GDateTime* _tmp5_;
	GDateTime* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->last_input_interaction;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, conversation)) {
		dino_chat_interaction_send_chat_state_notification (self, conversation, XMPP_XEP_CHAT_STATE_NOTIFICATIONS_STATE_COMPOSING);
	}
	_tmp1_ = self->priv->last_input_interaction;
	_tmp2_ = g_date_time_new_now_utc ();
	_tmp3_ = _tmp2_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, conversation, _tmp3_);
	_g_date_time_unref0 (_tmp3_);
	_tmp4_ = self->priv->last_interface_interaction;
	_tmp5_ = g_date_time_new_now_utc ();
	_tmp6_ = _tmp5_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp4_, conversation, _tmp6_);
	_g_date_time_unref0 (_tmp6_);
}

void
dino_chat_interaction_on_message_cleared (DinoChatInteraction* self,
                                          DinoEntitiesConversation* conversation)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->last_input_interaction;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, conversation)) {
		GeeHashMap* _tmp1_;
		_tmp1_ = self->priv->last_input_interaction;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp1_, conversation, NULL);
		dino_chat_interaction_send_chat_state_notification (self, conversation, XMPP_XEP_CHAT_STATE_NOTIFICATIONS_STATE_ACTIVE);
	}
}

void
dino_chat_interaction_on_conversation_selected (DinoChatInteraction* self,
                                                DinoEntitiesConversation* conversation)
{
	DinoEntitiesConversation* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = self->priv->selected_conversation;
	dino_chat_interaction_on_conversation_unfocused (self, _tmp0_);
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (self->priv->selected_conversation);
	self->priv->selected_conversation = _tmp1_;
	dino_chat_interaction_on_conversation_focused (self, conversation);
}

static void
dino_chat_interaction_new_item (DinoChatInteraction* self,
                                DinoContentItem* item,
                                DinoEntitiesConversation* conversation)
{
	gboolean mark_read = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	g_return_if_fail (conversation != NULL);
	mark_read = dino_chat_interaction_is_active_focus (self, conversation);
	if (!mark_read) {
		DinoMessageItem* message_item = NULL;
		DinoMessageItem* _tmp0_;
		DinoMessageItem* _tmp1_;
		DinoMessageItem* _tmp6_;
		_tmp0_ = _g_object_ref0 (DINO_IS_MESSAGE_ITEM (item) ? ((DinoMessageItem*) item) : NULL);
		message_item = _tmp0_;
		_tmp1_ = message_item;
		if (_tmp1_ != NULL) {
			DinoMessageItem* _tmp2_;
			DinoEntitiesMessage* _tmp3_;
			gboolean _tmp4_;
			gboolean _tmp5_;
			_tmp2_ = message_item;
			_tmp3_ = _tmp2_->message;
			_tmp4_ = dino_entities_message_get_direction (_tmp3_);
			_tmp5_ = _tmp4_;
			if (_tmp5_ == DINO_ENTITIES_MESSAGE_DIRECTION_SENT) {
				mark_read = TRUE;
			}
		}
		_tmp6_ = message_item;
		if (_tmp6_ == NULL) {
			DinoFileItem* file_item = NULL;
			DinoFileItem* _tmp7_;
			DinoFileItem* _tmp8_;
			_tmp7_ = _g_object_ref0 (DINO_IS_FILE_ITEM (item) ? ((DinoFileItem*) item) : NULL);
			file_item = _tmp7_;
			_tmp8_ = file_item;
			if (_tmp8_ != NULL) {
				DinoFileItem* _tmp9_;
				DinoEntitiesFileTransfer* _tmp10_;
				gboolean _tmp11_;
				gboolean _tmp12_;
				_tmp9_ = file_item;
				_tmp10_ = _tmp9_->file_transfer;
				_tmp11_ = dino_entities_file_transfer_get_direction (_tmp10_);
				_tmp12_ = _tmp11_;
				if (_tmp12_ == DINO_ENTITIES_FILE_TRANSFER_DIRECTION_SENT) {
					mark_read = TRUE;
				}
			}
			_g_object_unref0 (file_item);
		}
		_g_object_unref0 (message_item);
	}
	if (mark_read) {
		DinoContentItem* read_up_to = NULL;
		DinoStreamInteractor* _tmp13_;
		DinoModuleIdentity* _tmp14_;
		gpointer _tmp15_;
		DinoContentItemStore* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		DinoContentItem* _tmp19_;
		DinoContentItem* _tmp20_;
		DinoContentItem* _tmp21_;
		_tmp13_ = self->priv->stream_interactor;
		_tmp14_ = dino_content_item_store_IDENTITY;
		_tmp15_ = dino_stream_interactor_get_module (_tmp13_, DINO_TYPE_CONTENT_ITEM_STORE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp14_);
		_tmp16_ = (DinoContentItemStore*) _tmp15_;
		_tmp17_ = dino_entities_conversation_get_read_up_to_item (conversation);
		_tmp18_ = _tmp17_;
		_tmp19_ = dino_content_item_store_get_item_by_id (_tmp16_, conversation, _tmp18_);
		_tmp20_ = _tmp19_;
		_g_object_unref0 (_tmp16_);
		read_up_to = _tmp20_;
		_tmp21_ = read_up_to;
		if (_tmp21_ != NULL) {
			DinoContentItem* _tmp22_;
			_tmp22_ = read_up_to;
			if (dino_content_item_compare (_tmp22_, item) < 0) {
				gint _tmp23_;
				gint _tmp24_;
				_tmp23_ = dino_content_item_get_id (item);
				_tmp24_ = _tmp23_;
				dino_entities_conversation_set_read_up_to_item (conversation, _tmp24_);
			}
		} else {
			gint _tmp25_;
			gint _tmp26_;
			_tmp25_ = dino_content_item_get_id (item);
			_tmp26_ = _tmp25_;
			dino_entities_conversation_set_read_up_to_item (conversation, _tmp26_);
		}
		_g_object_unref0 (read_up_to);
	}
}

static void
dino_chat_interaction_on_message_sent (DinoChatInteraction* self,
                                       DinoEntitiesMessage* message,
                                       DinoEntitiesConversation* conversation)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = self->priv->last_input_interaction;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, conversation, NULL);
	_tmp1_ = self->priv->last_interface_interaction;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp1_, conversation, NULL);
}

static void
dino_chat_interaction_on_conversation_focused (DinoChatInteraction* self,
                                               DinoEntitiesConversation* conversation)
{
	DinoContentItem* latest_item = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoContentItemStore* _tmp3_;
	DinoContentItem* _tmp4_;
	DinoContentItem* _tmp5_;
	DinoContentItem* _tmp6_;
	g_return_if_fail (self != NULL);
	self->priv->focus_in = TRUE;
	if (conversation == NULL) {
		return;
	}
	g_signal_emit (self, dino_chat_interaction_signals[DINO_CHAT_INTERACTION_FOCUSED_IN_SIGNAL], 0, conversation);
	dino_chat_interaction_check_send_read (self);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_content_item_store_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (_tmp0_, DINO_TYPE_CONTENT_ITEM_STORE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoContentItemStore*) _tmp2_;
	_tmp4_ = dino_content_item_store_get_latest (_tmp3_, conversation);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp3_);
	latest_item = _tmp5_;
	_tmp6_ = latest_item;
	if (_tmp6_ != NULL) {
		DinoContentItem* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		_tmp7_ = latest_item;
		_tmp8_ = dino_content_item_get_id (_tmp7_);
		_tmp9_ = _tmp8_;
		dino_entities_conversation_set_read_up_to_item (conversation, _tmp9_);
	}
	_g_object_unref0 (latest_item);
}

static void
dino_chat_interaction_on_conversation_unfocused (DinoChatInteraction* self,
                                                 DinoEntitiesConversation* conversation)
{
	GeeHashMap* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->focus_in = FALSE;
	if (conversation == NULL) {
		return;
	}
	g_signal_emit (self, dino_chat_interaction_signals[DINO_CHAT_INTERACTION_FOCUSED_OUT_SIGNAL], 0, conversation);
	_tmp0_ = self->priv->last_input_interaction;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, conversation)) {
		GeeHashMap* _tmp1_;
		dino_chat_interaction_send_chat_state_notification (self, conversation, XMPP_XEP_CHAT_STATE_NOTIFICATIONS_STATE_PAUSED);
		_tmp1_ = self->priv->last_input_interaction;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp1_, conversation, NULL);
	}
}

static void
dino_chat_interaction_check_send_read (DinoChatInteraction* self)
{
	DinoEntitiesConversation* _tmp0_;
	DinoEntitiesMessage* message = NULL;
	DinoStreamInteractor* _tmp1_;
	DinoModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	DinoMessageStorage* _tmp4_;
	DinoEntitiesConversation* _tmp5_;
	DinoEntitiesMessage* _tmp6_;
	DinoEntitiesMessage* _tmp7_;
	gboolean _tmp8_ = FALSE;
	DinoEntitiesMessage* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->selected_conversation;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = dino_message_storage_IDENTITY;
	_tmp3_ = dino_stream_interactor_get_module (_tmp1_, DINO_TYPE_MESSAGE_STORAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (DinoMessageStorage*) _tmp3_;
	_tmp5_ = self->priv->selected_conversation;
	_tmp6_ = dino_message_storage_get_last_message (_tmp4_, _tmp5_);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp4_);
	message = _tmp7_;
	_tmp9_ = message;
	if (_tmp9_ != NULL) {
		DinoEntitiesMessage* _tmp10_;
		gboolean _tmp11_;
		gboolean _tmp12_;
		_tmp10_ = message;
		_tmp11_ = dino_entities_message_get_direction (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp8_ = _tmp12_ == DINO_ENTITIES_MESSAGE_DIRECTION_RECEIVED;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		DinoEntitiesMessage* _tmp13_;
		DinoEntitiesConversation* _tmp14_;
		_tmp13_ = message;
		_tmp14_ = self->priv->selected_conversation;
		dino_chat_interaction_send_chat_marker (self, _tmp13_, NULL, _tmp14_, XMPP_XEP_CHAT_MARKERS_MARKER_DISPLAYED);
	}
	_g_object_unref0 (message);
}

static gboolean
dino_chat_interaction_update_interactions (DinoChatInteraction* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		GeeMapIterator* iter = NULL;
		GeeHashMap* _tmp0_;
		GeeMapIterator* _tmp1_;
		_tmp0_ = self->priv->last_input_interaction;
		_tmp1_ = gee_abstract_map_map_iterator ((GeeAbstractMap*) _tmp0_);
		iter = _tmp1_;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				GeeMapIterator* _tmp4_;
				gboolean _tmp5_ = FALSE;
				GeeMapIterator* _tmp6_;
				gboolean _tmp7_;
				gboolean _tmp8_;
				DinoEntitiesConversation* conversation = NULL;
				GeeMapIterator* _tmp11_;
				gpointer _tmp12_;
				gboolean _tmp13_ = FALSE;
				GeeHashMap* _tmp14_;
				DinoEntitiesConversation* _tmp15_;
				if (!_tmp2_) {
					GeeMapIterator* _tmp3_;
					_tmp3_ = iter;
					gee_map_iterator_next (_tmp3_);
				}
				_tmp2_ = FALSE;
				_tmp4_ = iter;
				if (!gee_map_iterator_has_next (_tmp4_)) {
					break;
				}
				_tmp6_ = iter;
				_tmp7_ = gee_map_iterator_get_valid (_tmp6_);
				_tmp8_ = _tmp7_;
				if (!_tmp8_) {
					GeeMapIterator* _tmp9_;
					_tmp9_ = iter;
					_tmp5_ = gee_map_iterator_has_next (_tmp9_);
				} else {
					_tmp5_ = FALSE;
				}
				if (_tmp5_) {
					GeeMapIterator* _tmp10_;
					_tmp10_ = iter;
					gee_map_iterator_next (_tmp10_);
				}
				_tmp11_ = iter;
				_tmp12_ = gee_map_iterator_get_key (_tmp11_);
				conversation = (DinoEntitiesConversation*) _tmp12_;
				_tmp14_ = self->priv->last_input_interaction;
				_tmp15_ = conversation;
				if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp14_, _tmp15_)) {
					GDateTime* _tmp16_;
					GDateTime* _tmp17_;
					GeeHashMap* _tmp18_;
					DinoEntitiesConversation* _tmp19_;
					gpointer _tmp20_;
					GDateTime* _tmp21_;
					_tmp16_ = g_date_time_new_now_utc ();
					_tmp17_ = _tmp16_;
					_tmp18_ = self->priv->last_input_interaction;
					_tmp19_ = conversation;
					_tmp20_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp18_, _tmp19_);
					_tmp21_ = (GDateTime*) _tmp20_;
					_tmp13_ = g_date_time_difference (_tmp17_, _tmp21_) >= (15 * G_TIME_SPAN_SECOND);
					_g_date_time_unref0 (_tmp21_);
					_g_date_time_unref0 (_tmp17_);
				} else {
					_tmp13_ = FALSE;
				}
				if (_tmp13_) {
					GeeMapIterator* _tmp22_;
					DinoEntitiesConversation* _tmp23_;
					_tmp22_ = iter;
					gee_map_iterator_unset (_tmp22_);
					_tmp23_ = conversation;
					dino_chat_interaction_send_chat_state_notification (self, _tmp23_, XMPP_XEP_CHAT_STATE_NOTIFICATIONS_STATE_PAUSED);
				}
				_g_object_unref0 (conversation);
			}
		}
		_g_object_unref0 (iter);
	}
	{
		GeeMapIterator* iter = NULL;
		GeeHashMap* _tmp24_;
		GeeMapIterator* _tmp25_;
		_tmp24_ = self->priv->last_interface_interaction;
		_tmp25_ = gee_abstract_map_map_iterator ((GeeAbstractMap*) _tmp24_);
		iter = _tmp25_;
		{
			gboolean _tmp26_ = FALSE;
			_tmp26_ = TRUE;
			while (TRUE) {
				GeeMapIterator* _tmp28_;
				gboolean _tmp29_ = FALSE;
				GeeMapIterator* _tmp30_;
				gboolean _tmp31_;
				gboolean _tmp32_;
				DinoEntitiesConversation* conversation = NULL;
				GeeMapIterator* _tmp35_;
				gpointer _tmp36_;
				gboolean _tmp37_ = FALSE;
				GeeHashMap* _tmp38_;
				DinoEntitiesConversation* _tmp39_;
				if (!_tmp26_) {
					GeeMapIterator* _tmp27_;
					_tmp27_ = iter;
					gee_map_iterator_next (_tmp27_);
				}
				_tmp26_ = FALSE;
				_tmp28_ = iter;
				if (!gee_map_iterator_has_next (_tmp28_)) {
					break;
				}
				_tmp30_ = iter;
				_tmp31_ = gee_map_iterator_get_valid (_tmp30_);
				_tmp32_ = _tmp31_;
				if (!_tmp32_) {
					GeeMapIterator* _tmp33_;
					_tmp33_ = iter;
					_tmp29_ = gee_map_iterator_has_next (_tmp33_);
				} else {
					_tmp29_ = FALSE;
				}
				if (_tmp29_) {
					GeeMapIterator* _tmp34_;
					_tmp34_ = iter;
					gee_map_iterator_next (_tmp34_);
				}
				_tmp35_ = iter;
				_tmp36_ = gee_map_iterator_get_key (_tmp35_);
				conversation = (DinoEntitiesConversation*) _tmp36_;
				_tmp38_ = self->priv->last_interface_interaction;
				_tmp39_ = conversation;
				if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp38_, _tmp39_)) {
					GDateTime* _tmp40_;
					GDateTime* _tmp41_;
					GeeHashMap* _tmp42_;
					DinoEntitiesConversation* _tmp43_;
					gpointer _tmp44_;
					GDateTime* _tmp45_;
					_tmp40_ = g_date_time_new_now_utc ();
					_tmp41_ = _tmp40_;
					_tmp42_ = self->priv->last_interface_interaction;
					_tmp43_ = conversation;
					_tmp44_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp42_, _tmp43_);
					_tmp45_ = (GDateTime*) _tmp44_;
					_tmp37_ = ((gdouble) g_date_time_difference (_tmp41_, _tmp45_)) >= (1.5 * G_TIME_SPAN_MINUTE);
					_g_date_time_unref0 (_tmp45_);
					_g_date_time_unref0 (_tmp41_);
				} else {
					_tmp37_ = FALSE;
				}
				if (_tmp37_) {
					GeeMapIterator* _tmp46_;
					DinoEntitiesConversation* _tmp47_;
					_tmp46_ = iter;
					gee_map_iterator_unset (_tmp46_);
					_tmp47_ = conversation;
					dino_chat_interaction_send_chat_state_notification (self, _tmp47_, XMPP_XEP_CHAT_STATE_NOTIFICATIONS_STATE_GONE);
				}
				_g_object_unref0 (conversation);
			}
		}
		_g_object_unref0 (iter);
	}
	result = TRUE;
	return result;
}

static void
dino_chat_interaction_send_chat_marker (DinoChatInteraction* self,
                                        DinoEntitiesMessage* message,
                                        XmppMessageStanza* stanza,
                                        DinoEntitiesConversation* conversation,
                                        const gchar* marker)
{
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	DinoEntitiesAccount* _tmp2_;
	XmppXmppStream* _tmp3_;
	XmppXmppStream* _tmp4_;
	const gchar* _tmp5_;
	GQuark _tmp7_ = 0U;
	static GQuark _tmp6_label0 = 0;
	static GQuark _tmp6_label1 = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (marker != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_entities_conversation_get_account (conversation);
	_tmp2_ = _tmp1_;
	_tmp3_ = dino_stream_interactor_get_stream (_tmp0_, _tmp2_);
	stream = _tmp3_;
	_tmp4_ = stream;
	if (_tmp4_ == NULL) {
		_g_object_unref0 (stream);
		return;
	}
	_tmp5_ = marker;
	_tmp7_ = (NULL == _tmp5_) ? 0 : g_quark_from_string (_tmp5_);
	if (_tmp7_ == ((0 != _tmp6_label0) ? _tmp6_label0 : (_tmp6_label0 = g_quark_from_static_string (XMPP_XEP_CHAT_MARKERS_MARKER_RECEIVED)))) {
		switch (0) {
			default:
			{
				gboolean _tmp8_ = FALSE;
				gboolean _tmp9_ = FALSE;
				if (stanza != NULL) {
					_tmp9_ = xmpp_xep_chat_markers_module_requests_marking (stanza);
				} else {
					_tmp9_ = FALSE;
				}
				if (_tmp9_) {
					DinoEntitiesMessageType _tmp10_;
					DinoEntitiesMessageType _tmp11_;
					_tmp10_ = dino_entities_message_get_type_ (message);
					_tmp11_ = _tmp10_;
					_tmp8_ = _tmp11_ != DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT;
				} else {
					_tmp8_ = FALSE;
				}
				if (_tmp8_) {
					const gchar* _tmp12_;
					const gchar* _tmp13_;
					XmppXmppStream* _tmp14_;
					XmppModuleIdentity* _tmp15_;
					gpointer _tmp16_;
					XmppXepChatMarkersModule* _tmp17_;
					XmppXmppStream* _tmp18_;
					XmppJid* _tmp19_;
					XmppJid* _tmp20_;
					const gchar* _tmp21_;
					const gchar* _tmp22_;
					gchar* _tmp23_;
					gchar* _tmp24_;
					_tmp12_ = dino_entities_message_get_stanza_id (message);
					_tmp13_ = _tmp12_;
					if (_tmp13_ == NULL) {
						_g_object_unref0 (stream);
						return;
					}
					_tmp14_ = stream;
					_tmp15_ = xmpp_xep_chat_markers_module_IDENTITY;
					_tmp16_ = xmpp_xmpp_stream_get_module (_tmp14_, XMPP_XEP_CHAT_MARKERS_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp15_);
					_tmp17_ = (XmppXepChatMarkersModule*) _tmp16_;
					_tmp18_ = stream;
					_tmp19_ = dino_entities_message_get_from (message);
					_tmp20_ = _tmp19_;
					_tmp21_ = dino_entities_message_get_stanza_id (message);
					_tmp22_ = _tmp21_;
					_tmp23_ = dino_entities_message_get_type_string (message);
					_tmp24_ = _tmp23_;
					xmpp_xep_chat_markers_module_send_marker (_tmp17_, _tmp18_, _tmp20_, _tmp22_, _tmp24_, XMPP_XEP_CHAT_MARKERS_MARKER_RECEIVED);
					_g_free0 (_tmp24_);
					_g_object_unref0 (_tmp17_);
				}
				break;
			}
		}
	} else if (_tmp7_ == ((0 != _tmp6_label1) ? _tmp6_label1 : (_tmp6_label1 = g_quark_from_static_string (XMPP_XEP_CHAT_MARKERS_MARKER_DISPLAYED)))) {
		switch (0) {
			default:
			{
				DinoStreamInteractor* _tmp25_;
				_tmp25_ = self->priv->stream_interactor;
				if (dino_entities_conversation_get_send_marker_setting (conversation, _tmp25_) == DINO_ENTITIES_CONVERSATION_SETTING_ON) {
					DinoEntitiesMessage* _tmp26_;
					DinoEntitiesMessage* _tmp27_;
					gboolean _tmp28_ = FALSE;
					DinoEntitiesMessageType _tmp29_;
					DinoEntitiesMessageType _tmp30_;
					_tmp26_ = dino_entities_conversation_get_read_up_to (conversation);
					_tmp27_ = _tmp26_;
					if (dino_entities_message_equals (message, _tmp27_)) {
						_g_object_unref0 (stream);
						return;
					}
					dino_entities_conversation_set_read_up_to (conversation, message);
					_tmp29_ = dino_entities_message_get_type_ (message);
					_tmp30_ = _tmp29_;
					if (_tmp30_ == DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT) {
						_tmp28_ = TRUE;
					} else {
						DinoEntitiesMessageType _tmp31_;
						DinoEntitiesMessageType _tmp32_;
						_tmp31_ = dino_entities_message_get_type_ (message);
						_tmp32_ = _tmp31_;
						_tmp28_ = _tmp32_ == DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT_PM;
					}
					if (_tmp28_) {
						const gchar* _tmp33_;
						const gchar* _tmp34_;
						XmppXmppStream* _tmp35_;
						XmppModuleIdentity* _tmp36_;
						gpointer _tmp37_;
						XmppXepChatMarkersModule* _tmp38_;
						XmppXmppStream* _tmp39_;
						XmppJid* _tmp40_;
						XmppJid* _tmp41_;
						XmppJid* _tmp42_;
						XmppJid* _tmp43_;
						XmppJid* _tmp44_;
						const gchar* _tmp45_;
						const gchar* _tmp46_;
						gchar* _tmp47_;
						gchar* _tmp48_;
						_tmp33_ = dino_entities_message_get_server_id (message);
						_tmp34_ = _tmp33_;
						if (_tmp34_ == NULL) {
							_g_object_unref0 (stream);
							return;
						}
						_tmp35_ = stream;
						_tmp36_ = xmpp_xep_chat_markers_module_IDENTITY;
						_tmp37_ = xmpp_xmpp_stream_get_module (_tmp35_, XMPP_XEP_CHAT_MARKERS_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp36_);
						_tmp38_ = (XmppXepChatMarkersModule*) _tmp37_;
						_tmp39_ = stream;
						_tmp40_ = dino_entities_message_get_from (message);
						_tmp41_ = _tmp40_;
						_tmp42_ = xmpp_jid_get_bare_jid (_tmp41_);
						_tmp43_ = _tmp42_;
						_tmp44_ = _tmp43_;
						_tmp45_ = dino_entities_message_get_server_id (message);
						_tmp46_ = _tmp45_;
						_tmp47_ = dino_entities_message_get_type_string (message);
						_tmp48_ = _tmp47_;
						xmpp_xep_chat_markers_module_send_marker (_tmp38_, _tmp39_, _tmp44_, _tmp46_, _tmp48_, XMPP_XEP_CHAT_MARKERS_MARKER_DISPLAYED);
						_g_free0 (_tmp48_);
						_xmpp_jid_unref0 (_tmp44_);
						_g_object_unref0 (_tmp38_);
					} else {
						const gchar* _tmp49_;
						const gchar* _tmp50_;
						XmppXmppStream* _tmp51_;
						XmppModuleIdentity* _tmp52_;
						gpointer _tmp53_;
						XmppXepChatMarkersModule* _tmp54_;
						XmppXmppStream* _tmp55_;
						XmppJid* _tmp56_;
						XmppJid* _tmp57_;
						const gchar* _tmp58_;
						const gchar* _tmp59_;
						gchar* _tmp60_;
						gchar* _tmp61_;
						_tmp49_ = dino_entities_message_get_stanza_id (message);
						_tmp50_ = _tmp49_;
						if (_tmp50_ == NULL) {
							_g_object_unref0 (stream);
							return;
						}
						_tmp51_ = stream;
						_tmp52_ = xmpp_xep_chat_markers_module_IDENTITY;
						_tmp53_ = xmpp_xmpp_stream_get_module (_tmp51_, XMPP_XEP_CHAT_MARKERS_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp52_);
						_tmp54_ = (XmppXepChatMarkersModule*) _tmp53_;
						_tmp55_ = stream;
						_tmp56_ = dino_entities_message_get_from (message);
						_tmp57_ = _tmp56_;
						_tmp58_ = dino_entities_message_get_stanza_id (message);
						_tmp59_ = _tmp58_;
						_tmp60_ = dino_entities_message_get_type_string (message);
						_tmp61_ = _tmp60_;
						xmpp_xep_chat_markers_module_send_marker (_tmp54_, _tmp55_, _tmp57_, _tmp59_, _tmp61_, XMPP_XEP_CHAT_MARKERS_MARKER_DISPLAYED);
						_g_free0 (_tmp61_);
						_g_object_unref0 (_tmp54_);
					}
				}
				break;
			}
		}
	}
	_g_object_unref0 (stream);
}

static void
dino_chat_interaction_send_delivery_receipt (DinoChatInteraction* self,
                                             DinoEntitiesMessage* message,
                                             XmppMessageStanza* stanza,
                                             DinoEntitiesConversation* conversation)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	DinoEntitiesConversationType _tmp2_;
	DinoEntitiesConversationType _tmp3_;
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp4_;
	DinoEntitiesAccount* _tmp5_;
	DinoEntitiesAccount* _tmp6_;
	XmppXmppStream* _tmp7_;
	XmppXmppStream* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	g_return_if_fail (stanza != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = dino_entities_message_get_direction (message);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == DINO_ENTITIES_MESSAGE_DIRECTION_SENT) {
		return;
	}
	if (!xmpp_xep_message_delivery_receipts_module_requests_receipt (stanza)) {
		return;
	}
	_tmp2_ = dino_entities_conversation_get_type_ (conversation);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT) {
		return;
	}
	_tmp4_ = self->priv->stream_interactor;
	_tmp5_ = dino_entities_conversation_get_account (conversation);
	_tmp6_ = _tmp5_;
	_tmp7_ = dino_stream_interactor_get_stream (_tmp4_, _tmp6_);
	stream = _tmp7_;
	_tmp8_ = stream;
	if (_tmp8_ != NULL) {
		XmppXmppStream* _tmp9_;
		XmppModuleIdentity* _tmp10_;
		gpointer _tmp11_;
		XmppXepMessageDeliveryReceiptsModule* _tmp12_;
		XmppXmppStream* _tmp13_;
		XmppJid* _tmp14_;
		XmppJid* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		_tmp9_ = stream;
		_tmp10_ = xmpp_xep_message_delivery_receipts_module_IDENTITY;
		_tmp11_ = xmpp_xmpp_stream_get_module (_tmp9_, XMPP_XEP_MESSAGE_DELIVERY_RECEIPTS_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp10_);
		_tmp12_ = (XmppXepMessageDeliveryReceiptsModule*) _tmp11_;
		_tmp13_ = stream;
		_tmp14_ = dino_entities_message_get_from (message);
		_tmp15_ = _tmp14_;
		_tmp16_ = dino_entities_message_get_stanza_id (message);
		_tmp17_ = _tmp16_;
		xmpp_xep_message_delivery_receipts_module_send_received (_tmp12_, _tmp13_, _tmp15_, _tmp17_);
		_g_object_unref0 (_tmp12_);
	}
	_g_object_unref0 (stream);
}

static void
dino_chat_interaction_send_chat_state_notification (DinoChatInteraction* self,
                                                    DinoEntitiesConversation* conversation,
                                                    const gchar* state)
{
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp1_;
	DinoEntitiesAccount* _tmp2_;
	DinoEntitiesAccount* _tmp3_;
	XmppXmppStream* _tmp4_;
	XmppXmppStream* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (state != NULL);
	_tmp0_ = self->priv->stream_interactor;
	if (dino_entities_conversation_get_send_typing_setting (conversation, _tmp0_) != DINO_ENTITIES_CONVERSATION_SETTING_ON) {
		return;
	}
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = dino_entities_conversation_get_account (conversation);
	_tmp3_ = _tmp2_;
	_tmp4_ = dino_stream_interactor_get_stream (_tmp1_, _tmp3_);
	stream = _tmp4_;
	_tmp5_ = stream;
	if (_tmp5_ != NULL) {
		const gchar* _tmp6_ = NULL;
		DinoEntitiesConversationType _tmp7_;
		DinoEntitiesConversationType _tmp8_;
		gchar* message_type = NULL;
		gchar* _tmp9_;
		XmppXmppStream* _tmp10_;
		XmppModuleIdentity* _tmp11_;
		gpointer _tmp12_;
		XmppXepChatStateNotificationsModule* _tmp13_;
		XmppXmppStream* _tmp14_;
		XmppJid* _tmp15_;
		XmppJid* _tmp16_;
		const gchar* _tmp17_;
		_tmp7_ = dino_entities_conversation_get_type_ (conversation);
		_tmp8_ = _tmp7_;
		if (_tmp8_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT) {
			_tmp6_ = XMPP_MESSAGE_STANZA_TYPE_GROUPCHAT;
		} else {
			_tmp6_ = XMPP_MESSAGE_STANZA_TYPE_CHAT;
		}
		_tmp9_ = g_strdup (_tmp6_);
		message_type = _tmp9_;
		_tmp10_ = stream;
		_tmp11_ = xmpp_xep_chat_state_notifications_module_IDENTITY;
		_tmp12_ = xmpp_xmpp_stream_get_module (_tmp10_, XMPP_XEP_CHAT_STATE_NOTIFICATIONS_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp11_);
		_tmp13_ = (XmppXepChatStateNotificationsModule*) _tmp12_;
		_tmp14_ = stream;
		_tmp15_ = dino_entities_conversation_get_counterpart (conversation);
		_tmp16_ = _tmp15_;
		_tmp17_ = message_type;
		xmpp_xep_chat_state_notifications_module_send_state (_tmp13_, _tmp14_, _tmp16_, _tmp17_, state);
		_g_object_unref0 (_tmp13_);
		_g_free0 (message_type);
	}
	_g_object_unref0 (stream);
}

static const gchar*
dino_chat_interaction_real_get_id (DinoStreamInteractionModule* base)
{
	const gchar* result;
	DinoChatInteraction* self;
	DinoModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (DinoChatInteraction*) base;
	_tmp0_ = dino_chat_interaction_IDENTITY;
	_tmp1_ = dino_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static inline gpointer
dino_chat_interaction_received_message_listener_get_instance_private (DinoChatInteractionReceivedMessageListener* self)
{
	return G_STRUCT_MEMBER_P (self, DinoChatInteractionReceivedMessageListener_private_offset);
}

static DinoChatInteractionReceivedMessageListener*
dino_chat_interaction_received_message_listener_construct (GType object_type,
                                                           DinoStreamInteractor* stream_interactor)
{
	DinoChatInteractionReceivedMessageListener * self = NULL;
	DinoStreamInteractor* _tmp0_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	self = (DinoChatInteractionReceivedMessageListener*) dino_message_listener_construct (object_type);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	return self;
}

static DinoChatInteractionReceivedMessageListener*
dino_chat_interaction_received_message_listener_new (DinoStreamInteractor* stream_interactor)
{
	return dino_chat_interaction_received_message_listener_construct (DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER, stream_interactor);
}

static void
dino_chat_interaction_received_message_listener_real_run_data_free (gpointer _data)
{
	DinoChatInteractionReceivedMessageListenerRunData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->message);
	_g_object_unref0 (_data_->stanza);
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoChatInteractionReceivedMessageListenerRunData, _data_);
}

static void
dino_chat_interaction_received_message_listener_real_run (DinoMessageListener* base,
                                                          DinoEntitiesMessage* message,
                                                          XmppMessageStanza* stanza,
                                                          DinoEntitiesConversation* conversation,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	DinoChatInteractionReceivedMessageListener * self;
	DinoChatInteractionReceivedMessageListenerRunData* _data_;
	DinoChatInteractionReceivedMessageListener* _tmp0_;
	DinoEntitiesMessage* _tmp1_;
	XmppMessageStanza* _tmp2_;
	DinoEntitiesConversation* _tmp3_;
	g_return_if_fail (message != NULL);
	g_return_if_fail (stanza != NULL);
	g_return_if_fail (conversation != NULL);
	self = (DinoChatInteractionReceivedMessageListener*) base;
	_data_ = g_slice_new0 (DinoChatInteractionReceivedMessageListenerRunData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_chat_interaction_received_message_listener_real_run_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (message);
	_g_object_unref0 (_data_->message);
	_data_->message = _tmp1_;
	_tmp2_ = _g_object_ref0 (stanza);
	_g_object_unref0 (_data_->stanza);
	_data_->stanza = _tmp2_;
	_tmp3_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp3_;
	dino_chat_interaction_received_message_listener_real_run_co (_data_);
}

static gboolean
dino_chat_interaction_received_message_listener_run_finish (DinoMessageListener* base,
                                                            GAsyncResult* _res_)
{
	gboolean result;
	DinoChatInteractionReceivedMessageListenerRunData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static gboolean
dino_chat_interaction_received_message_listener_real_run_co (DinoChatInteractionReceivedMessageListenerRunData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = xmpp_message_archive_management_message_flag_get_flag (_data_->stanza);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = _data_->_tmp1_ != NULL;
	_g_object_unref0 (_data_->_tmp1_);
	if (_data_->_tmp2_) {
		_data_->result = FALSE;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = _data_->self->priv->stream_interactor;
	_data_->_tmp4_ = dino_chat_interaction_IDENTITY;
	_data_->_tmp5_ = dino_stream_interactor_get_module (_data_->_tmp3_, DINO_TYPE_CHAT_INTERACTION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp4_);
	_data_->outer = (DinoChatInteraction*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->outer;
	dino_chat_interaction_send_delivery_receipt (_data_->_tmp6_, _data_->message, _data_->stanza, _data_->conversation);
	_data_->_tmp7_ = dino_entities_message_get_direction (_data_->message);
	_data_->_tmp8_ = _data_->_tmp7_;
	if (_data_->_tmp8_ == DINO_ENTITIES_MESSAGE_DIRECTION_SENT) {
		_data_->result = FALSE;
		_g_object_unref0 (_data_->outer);
		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_->_tmp9_ = _data_->outer;
	if (dino_chat_interaction_is_active_focus (_data_->_tmp9_, _data_->conversation)) {
		_data_->_tmp10_ = _data_->outer;
		dino_chat_interaction_check_send_read (_data_->_tmp10_);
		_data_->_tmp11_ = _data_->outer;
		dino_chat_interaction_send_chat_marker (_data_->_tmp11_, _data_->message, _data_->stanza, _data_->conversation, XMPP_XEP_CHAT_MARKERS_MARKER_DISPLAYED);
	} else {
		_data_->_tmp12_ = _data_->outer;
		dino_chat_interaction_send_chat_marker (_data_->_tmp12_, _data_->message, _data_->stanza, _data_->conversation, XMPP_XEP_CHAT_MARKERS_MARKER_RECEIVED);
	}
	_data_->result = FALSE;
	_g_object_unref0 (_data_->outer);
	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 const gchar*
dino_chat_interaction_received_message_listener_real_get_action_group (XmppOrderedListener* base)
{
	const gchar* result;
	DinoChatInteractionReceivedMessageListener* self;
	self = (DinoChatInteractionReceivedMessageListener*) base;
	result = "OTHER_NODES";
	return result;
}

static gchar**
dino_chat_interaction_received_message_listener_real_get_after_actions (XmppOrderedListener* base,
                                                                        gint* result_length1)
{
	gchar** result;
	DinoChatInteractionReceivedMessageListener* self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	self = (DinoChatInteractionReceivedMessageListener*) base;
	_tmp0_ = self->after_actions_const;
	_tmp0__length1 = self->after_actions_const_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

static void
dino_chat_interaction_received_message_listener_class_init (DinoChatInteractionReceivedMessageListenerClass * klass,
                                                            gpointer klass_data)
{
	dino_chat_interaction_received_message_listener_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoChatInteractionReceivedMessageListener_private_offset);
	((DinoMessageListenerClass *) klass)->run = (void (*) (DinoMessageListener*, DinoEntitiesMessage*, XmppMessageStanza*, DinoEntitiesConversation*, GAsyncReadyCallback, gpointer)) dino_chat_interaction_received_message_listener_real_run;
	((DinoMessageListenerClass *) klass)->run_finish = (gboolean (*) (DinoMessageListener*, GAsyncResult*)) dino_chat_interaction_received_message_listener_run_finish;
	XMPP_ORDERED_LISTENER_CLASS (klass)->get_action_group = (const gchar* (*) (XmppOrderedListener*)) dino_chat_interaction_received_message_listener_real_get_action_group;
	XMPP_ORDERED_LISTENER_CLASS (klass)->get_after_actions = (gchar** (*) (XmppOrderedListener*, gint*)) dino_chat_interaction_received_message_listener_real_get_after_actions;
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_chat_interaction_received_message_listener_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_chat_interaction_received_message_listener_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY, dino_chat_interaction_received_message_listener_properties[DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY] = g_param_spec_string ("action-group", "action-group", "action-group", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_AFTER_ACTIONS_PROPERTY, dino_chat_interaction_received_message_listener_properties[DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_AFTER_ACTIONS_PROPERTY] = g_param_spec_boxed ("after-actions", "after-actions", "after-actions", G_TYPE_STRV, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dino_chat_interaction_received_message_listener_instance_init (DinoChatInteractionReceivedMessageListener * self,
                                                               gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	self->priv = dino_chat_interaction_received_message_listener_get_instance_private (self);
	_tmp0_ = g_strdup ("DEDUPLICATE");
	_tmp1_ = g_strdup ("FILTER_EMPTY");
	_tmp2_ = g_strdup ("STORE_CONTENT_ITEM");
	_tmp3_ = g_new0 (gchar*, 3 + 1);
	_tmp3_[0] = _tmp0_;
	_tmp3_[1] = _tmp1_;
	_tmp3_[2] = _tmp2_;
	self->after_actions_const = _tmp3_;
	self->after_actions_const_length1 = 3;
	self->_after_actions_const_size_ = self->after_actions_const_length1;
}

static void
dino_chat_interaction_received_message_listener_finalize (GObject * obj)
{
	DinoChatInteractionReceivedMessageListener * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER, DinoChatInteractionReceivedMessageListener);
	self->after_actions_const = (_vala_array_free (self->after_actions_const, self->after_actions_const_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (self->priv->stream_interactor);
	G_OBJECT_CLASS (dino_chat_interaction_received_message_listener_parent_class)->finalize (obj);
}

static GType
dino_chat_interaction_received_message_listener_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoChatInteractionReceivedMessageListenerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_chat_interaction_received_message_listener_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoChatInteractionReceivedMessageListener), 0, (GInstanceInitFunc) dino_chat_interaction_received_message_listener_instance_init, NULL };
	GType dino_chat_interaction_received_message_listener_type_id;
	dino_chat_interaction_received_message_listener_type_id = g_type_register_static (DINO_TYPE_MESSAGE_LISTENER, "DinoChatInteractionReceivedMessageListener", &g_define_type_info, 0);
	DinoChatInteractionReceivedMessageListener_private_offset = g_type_add_instance_private (dino_chat_interaction_received_message_listener_type_id, sizeof (DinoChatInteractionReceivedMessageListenerPrivate));
	return dino_chat_interaction_received_message_listener_type_id;
}

static GType
dino_chat_interaction_received_message_listener_get_type (void)
{
	static volatile gsize dino_chat_interaction_received_message_listener_type_id__once = 0;
	if (g_once_init_enter (&dino_chat_interaction_received_message_listener_type_id__once)) {
		GType dino_chat_interaction_received_message_listener_type_id;
		dino_chat_interaction_received_message_listener_type_id = dino_chat_interaction_received_message_listener_get_type_once ();
		g_once_init_leave (&dino_chat_interaction_received_message_listener_type_id__once, dino_chat_interaction_received_message_listener_type_id);
	}
	return dino_chat_interaction_received_message_listener_type_id__once;
}

static void
_vala_dino_chat_interaction_received_message_listener_get_property (GObject * object,
                                                                    guint property_id,
                                                                    GValue * value,
                                                                    GParamSpec * pspec)
{
	DinoChatInteractionReceivedMessageListener * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_CHAT_INTERACTION_TYPE_RECEIVED_MESSAGE_LISTENER, DinoChatInteractionReceivedMessageListener);
	switch (property_id) {
		case DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY:
		g_value_set_string (value, xmpp_ordered_listener_get_action_group ((XmppOrderedListener*) self));
		break;
		case DINO_CHAT_INTERACTION_RECEIVED_MESSAGE_LISTENER_AFTER_ACTIONS_PROPERTY:
		{
			int length;
			g_value_set_boxed (value, xmpp_ordered_listener_get_after_actions ((XmppOrderedListener*) self, &length));
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
dino_chat_interaction_class_init (DinoChatInteractionClass * klass,
                                  gpointer klass_data)
{
	DinoModuleIdentity* _tmp0_;
	dino_chat_interaction_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoChatInteraction_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_chat_interaction_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_chat_interaction_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_CHAT_INTERACTION_ID_PROPERTY, dino_chat_interaction_properties[DINO_CHAT_INTERACTION_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	dino_chat_interaction_signals[DINO_CHAT_INTERACTION_FOCUSED_IN_SIGNAL] = g_signal_new ("focused-in", DINO_TYPE_CHAT_INTERACTION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DINO_ENTITIES_TYPE_CONVERSATION);
	dino_chat_interaction_signals[DINO_CHAT_INTERACTION_FOCUSED_OUT_SIGNAL] = g_signal_new ("focused-out", DINO_TYPE_CHAT_INTERACTION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, DINO_ENTITIES_TYPE_CONVERSATION);
	_tmp0_ = dino_module_identity_new (DINO_TYPE_CHAT_INTERACTION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, "chat_interaction");
	dino_chat_interaction_IDENTITY = _tmp0_;
}

static void
dino_chat_interaction_dino_stream_interaction_module_interface_init (DinoStreamInteractionModuleIface * iface,
                                                                     gpointer iface_data)
{
	dino_chat_interaction_dino_stream_interaction_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = dino_chat_interaction_real_get_id;
}

static void
dino_chat_interaction_instance_init (DinoChatInteraction * self,
                                     gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	self->priv = dino_chat_interaction_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (DINO_ENTITIES_TYPE_CONVERSATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_DATE_TIME, (GBoxedCopyFunc) g_date_time_ref, (GDestroyNotify) g_date_time_unref, _dino_entities_conversation_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_conversation_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->last_input_interaction = _tmp0_;
	_tmp1_ = gee_hash_map_new (DINO_ENTITIES_TYPE_CONVERSATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_DATE_TIME, (GBoxedCopyFunc) g_date_time_ref, (GDestroyNotify) g_date_time_unref, _dino_entities_conversation_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_conversation_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->last_interface_interaction = _tmp1_;
	self->priv->focus_in = FALSE;
}

static void
dino_chat_interaction_finalize (GObject * obj)
{
	DinoChatInteraction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_CHAT_INTERACTION, DinoChatInteraction);
	_g_object_unref0 (self->priv->stream_interactor);
	_g_object_unref0 (self->priv->selected_conversation);
	_g_object_unref0 (self->priv->last_input_interaction);
	_g_object_unref0 (self->priv->last_interface_interaction);
	G_OBJECT_CLASS (dino_chat_interaction_parent_class)->finalize (obj);
}

static GType
dino_chat_interaction_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoChatInteractionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_chat_interaction_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoChatInteraction), 0, (GInstanceInitFunc) dino_chat_interaction_instance_init, NULL };
	static const GInterfaceInfo dino_stream_interaction_module_info = { (GInterfaceInitFunc) dino_chat_interaction_dino_stream_interaction_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_chat_interaction_type_id;
	dino_chat_interaction_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoChatInteraction", &g_define_type_info, 0);
	g_type_add_interface_static (dino_chat_interaction_type_id, DINO_TYPE_STREAM_INTERACTION_MODULE, &dino_stream_interaction_module_info);
	DinoChatInteraction_private_offset = g_type_add_instance_private (dino_chat_interaction_type_id, sizeof (DinoChatInteractionPrivate));
	return dino_chat_interaction_type_id;
}

GType
dino_chat_interaction_get_type (void)
{
	static volatile gsize dino_chat_interaction_type_id__once = 0;
	if (g_once_init_enter (&dino_chat_interaction_type_id__once)) {
		GType dino_chat_interaction_type_id;
		dino_chat_interaction_type_id = dino_chat_interaction_get_type_once ();
		g_once_init_leave (&dino_chat_interaction_type_id__once, dino_chat_interaction_type_id);
	}
	return dino_chat_interaction_type_id__once;
}

static void
_vala_dino_chat_interaction_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	DinoChatInteraction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_CHAT_INTERACTION, DinoChatInteraction);
	switch (property_id) {
		case DINO_CHAT_INTERACTION_ID_PROPERTY:
		g_value_set_string (value, dino_stream_interaction_module_get_id ((DinoStreamInteractionModule*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

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

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

