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

#include "libdino.h"
#include <glib-object.h>
#include <glib.h>
#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gee.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

#define DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER (dino_fallback_body_received_message_listener_get_type ())
#define DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER, DinoFallbackBodyReceivedMessageListener))
#define DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER, DinoFallbackBodyReceivedMessageListenerClass))
#define DINO_FALLBACK_BODY_IS_RECEIVED_MESSAGE_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER))
#define DINO_FALLBACK_BODY_IS_RECEIVED_MESSAGE_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER))
#define DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER, DinoFallbackBodyReceivedMessageListenerClass))

typedef struct _DinoFallbackBodyReceivedMessageListener DinoFallbackBodyReceivedMessageListener;
typedef struct _DinoFallbackBodyReceivedMessageListenerClass DinoFallbackBodyReceivedMessageListenerClass;
enum  {
	DINO_FALLBACK_BODY_0_PROPERTY,
	DINO_FALLBACK_BODY_ID_PROPERTY,
	DINO_FALLBACK_BODY_NUM_PROPERTIES
};
static GParamSpec* dino_fallback_body_properties[DINO_FALLBACK_BODY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _qlite_database_unref0(var) ((var == NULL) ? NULL : (var = (qlite_database_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _DinoFallbackBodyReceivedMessageListenerPrivate DinoFallbackBodyReceivedMessageListenerPrivate;
enum  {
	DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_0_PROPERTY,
	DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY,
	DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_AFTER_ACTIONS_PROPERTY,
	DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_NUM_PROPERTIES
};
static GParamSpec* dino_fallback_body_received_message_listener_properties[DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_NUM_PROPERTIES];
#define _xmpp_xep_fallback_indication_fallback_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_fallback_indication_fallback_unref (var), NULL)))
typedef struct _DinoFallbackBodyReceivedMessageListenerRunData DinoFallbackBodyReceivedMessageListenerRunData;

struct _DinoFallbackBodyPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoDatabase* db;
	DinoFallbackBodyReceivedMessageListener* received_message_listener;
};

struct _DinoFallbackBodyReceivedMessageListener {
	DinoMessageListener parent_instance;
	DinoFallbackBodyReceivedMessageListenerPrivate * priv;
	gchar** after_actions_const;
	gint after_actions_const_length1;
	gint _after_actions_const_size_;
};

struct _DinoFallbackBodyReceivedMessageListenerClass {
	DinoMessageListenerClass parent_class;
};

struct _DinoFallbackBodyReceivedMessageListenerPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoDatabase* db;
};

struct _DinoFallbackBodyReceivedMessageListenerRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoFallbackBodyReceivedMessageListener* self;
	DinoEntitiesMessage* message;
	XmppMessageStanza* stanza;
	DinoEntitiesConversation* conversation;
	gboolean result;
	GeeList* fallbacks;
	GeeList* _tmp0_;
	GeeList* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GeeList* _fallback_list;
	GeeList* _tmp4_;
	gint _fallback_size;
	GeeList* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	gint _fallback_index;
	gint _tmp8_;
	gint _tmp9_;
	XmppXepFallbackIndicationFallback* fallback;
	GeeList* _tmp10_;
	gpointer _tmp11_;
	XmppXepFallbackIndicationFallback* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	GeeList* _tmp15_;
};

static gint DinoFallbackBody_private_offset;
static gpointer dino_fallback_body_parent_class = NULL;
DinoModuleIdentity* dino_fallback_body_IDENTITY = NULL;
static gint DinoFallbackBodyReceivedMessageListener_private_offset;
static gpointer dino_fallback_body_received_message_listener_parent_class = NULL;
static DinoStreamInteractionModuleIface * dino_fallback_body_dino_stream_interaction_module_parent_iface = NULL;

static GType dino_fallback_body_received_message_listener_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static DinoFallbackBody* dino_fallback_body_new (DinoStreamInteractor* stream_interactor,
                                          DinoDatabase* db);
static DinoFallbackBody* dino_fallback_body_construct (GType object_type,
                                                DinoStreamInteractor* stream_interactor,
                                                DinoDatabase* db);
static DinoFallbackBodyReceivedMessageListener* dino_fallback_body_received_message_listener_new (DinoStreamInteractor* stream_interactor,
                                                                                           DinoDatabase* db);
static DinoFallbackBodyReceivedMessageListener* dino_fallback_body_received_message_listener_construct (GType object_type,
                                                                                                 DinoStreamInteractor* stream_interactor,
                                                                                                 DinoDatabase* db);
static void dino_fallback_body_received_message_listener_real_run_data_free (gpointer _data);
static void dino_fallback_body_received_message_listener_real_run (DinoMessageListener* base,
                                                            DinoEntitiesMessage* message,
                                                            XmppMessageStanza* stanza,
                                                            DinoEntitiesConversation* conversation,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
static gboolean dino_fallback_body_received_message_listener_real_run_co (DinoFallbackBodyReceivedMessageListenerRunData* _data_);
static void dino_fallback_body_received_message_listener_finalize (GObject * obj);
static GType dino_fallback_body_received_message_listener_get_type_once (void);
static void _vala_dino_fallback_body_received_message_listener_get_property (GObject * object,
                                                                      guint property_id,
                                                                      GValue * value,
                                                                      GParamSpec * pspec);
static void dino_fallback_body_finalize (GObject * obj);
static GType dino_fallback_body_get_type_once (void);
static void _vala_dino_fallback_body_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_fallback_body_get_instance_private (DinoFallbackBody* self)
{
	return G_STRUCT_MEMBER_P (self, DinoFallbackBody_private_offset);
}

void
dino_fallback_body_start (DinoStreamInteractor* stream_interactor,
                          DinoDatabase* db)
{
	DinoFallbackBody* m = NULL;
	DinoFallbackBody* _tmp0_;
	g_return_if_fail (stream_interactor != NULL);
	g_return_if_fail (db != NULL);
	_tmp0_ = dino_fallback_body_new (stream_interactor, db);
	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 gpointer
_qlite_database_ref0 (gpointer self)
{
	return self ? qlite_database_ref (self) : NULL;
}

static DinoFallbackBody*
dino_fallback_body_construct (GType object_type,
                              DinoStreamInteractor* stream_interactor,
                              DinoDatabase* db)
{
	DinoFallbackBody * self = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoDatabase* _tmp1_;
	DinoFallbackBodyReceivedMessageListener* _tmp2_;
	DinoModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	DinoMessageProcessor* _tmp5_;
	DinoMessageListenerHolder* _tmp6_;
	DinoFallbackBodyReceivedMessageListener* _tmp7_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoFallbackBody*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = _qlite_database_ref0 (db);
	_qlite_database_unref0 (self->priv->db);
	self->priv->db = _tmp1_;
	_tmp2_ = dino_fallback_body_received_message_listener_new (stream_interactor, db);
	_g_object_unref0 (self->priv->received_message_listener);
	self->priv->received_message_listener = _tmp2_;
	_tmp3_ = dino_message_processor_IDENTITY;
	_tmp4_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp3_);
	_tmp5_ = (DinoMessageProcessor*) _tmp4_;
	_tmp6_ = _tmp5_->received_pipeline;
	_tmp7_ = self->priv->received_message_listener;
	xmpp_listener_holder_connect ((XmppListenerHolder*) _tmp6_, (XmppOrderedListener*) _tmp7_);
	_g_object_unref0 (_tmp5_);
	return self;
}

static DinoFallbackBody*
dino_fallback_body_new (DinoStreamInteractor* stream_interactor,
                        DinoDatabase* db)
{
	return dino_fallback_body_construct (DINO_TYPE_FALLBACK_BODY, stream_interactor, db);
}

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

gchar*
dino_fallback_body_get_quoted_fallback_body (DinoContentItem* content_item)
{
	gchar* fallback = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* result;
	g_return_val_if_fail (content_item != NULL, NULL);
	_tmp0_ = g_strdup ("> ");
	fallback = _tmp0_;
	_tmp1_ = dino_content_item_get_type_ (content_item);
	_tmp2_ = _tmp1_;
	if (g_strcmp0 (_tmp2_, DINO_MESSAGE_ITEM_TYPE) == 0) {
		DinoEntitiesMessage* quoted_message = NULL;
		DinoEntitiesMessage* _tmp3_;
		DinoEntitiesMessage* _tmp4_;
		const gchar* _tmp5_;
		DinoEntitiesMessage* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp3_ = G_TYPE_CHECK_INSTANCE_CAST (content_item, DINO_TYPE_MESSAGE_ITEM, DinoMessageItem)->message;
		_tmp4_ = _g_object_ref0 (_tmp3_);
		quoted_message = _tmp4_;
		_tmp5_ = fallback;
		_tmp6_ = quoted_message;
		_tmp7_ = dino_message_body_without_reply_fallback (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strconcat (_tmp5_, _tmp8_, NULL);
		_g_free0 (fallback);
		fallback = _tmp9_;
		_g_free0 (_tmp8_);
		_tmp10_ = fallback;
		_tmp11_ = string_replace (_tmp10_, "\n", "\n> ");
		_g_free0 (fallback);
		fallback = _tmp11_;
		_g_object_unref0 (quoted_message);
	} else {
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		_tmp12_ = dino_content_item_get_type_ (content_item);
		_tmp13_ = _tmp12_;
		if (g_strcmp0 (_tmp13_, DINO_FILE_ITEM_TYPE) == 0) {
			DinoEntitiesFileTransfer* quoted_file = NULL;
			DinoEntitiesFileTransfer* _tmp14_;
			DinoEntitiesFileTransfer* _tmp15_;
			const gchar* _tmp16_;
			DinoEntitiesFileTransfer* _tmp17_;
			const gchar* _tmp18_;
			const gchar* _tmp19_;
			gchar* _tmp20_;
			_tmp14_ = G_TYPE_CHECK_INSTANCE_CAST (content_item, DINO_TYPE_FILE_ITEM, DinoFileItem)->file_transfer;
			_tmp15_ = _g_object_ref0 (_tmp14_);
			quoted_file = _tmp15_;
			_tmp16_ = fallback;
			_tmp17_ = quoted_file;
			_tmp18_ = dino_entities_file_transfer_get_file_name (_tmp17_);
			_tmp19_ = _tmp18_;
			_tmp20_ = g_strconcat (_tmp16_, _tmp19_, NULL);
			_g_free0 (fallback);
			fallback = _tmp20_;
			_g_object_unref0 (quoted_file);
		}
	}
	_tmp21_ = fallback;
	_tmp22_ = g_strconcat (_tmp21_, "\n", NULL);
	_g_free0 (fallback);
	fallback = _tmp22_;
	result = fallback;
	return result;
}

static const gchar*
dino_fallback_body_real_get_id (DinoStreamInteractionModule* base)
{
	const gchar* result;
	DinoFallbackBody* self;
	DinoModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (DinoFallbackBody*) base;
	_tmp0_ = dino_fallback_body_IDENTITY;
	_tmp1_ = dino_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static inline gpointer
dino_fallback_body_received_message_listener_get_instance_private (DinoFallbackBodyReceivedMessageListener* self)
{
	return G_STRUCT_MEMBER_P (self, DinoFallbackBodyReceivedMessageListener_private_offset);
}

static DinoFallbackBodyReceivedMessageListener*
dino_fallback_body_received_message_listener_construct (GType object_type,
                                                        DinoStreamInteractor* stream_interactor,
                                                        DinoDatabase* db)
{
	DinoFallbackBodyReceivedMessageListener * self = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoDatabase* _tmp1_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoFallbackBodyReceivedMessageListener*) dino_message_listener_construct (object_type);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = _qlite_database_ref0 (db);
	_qlite_database_unref0 (self->priv->db);
	self->priv->db = _tmp1_;
	return self;
}

static DinoFallbackBodyReceivedMessageListener*
dino_fallback_body_received_message_listener_new (DinoStreamInteractor* stream_interactor,
                                                  DinoDatabase* db)
{
	return dino_fallback_body_received_message_listener_construct (DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER, stream_interactor, db);
}

static void
dino_fallback_body_received_message_listener_real_run_data_free (gpointer _data)
{
	DinoFallbackBodyReceivedMessageListenerRunData* _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 (DinoFallbackBodyReceivedMessageListenerRunData, _data_);
}

static void
dino_fallback_body_received_message_listener_real_run (DinoMessageListener* base,
                                                       DinoEntitiesMessage* message,
                                                       XmppMessageStanza* stanza,
                                                       DinoEntitiesConversation* conversation,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	DinoFallbackBodyReceivedMessageListener * self;
	DinoFallbackBodyReceivedMessageListenerRunData* _data_;
	DinoFallbackBodyReceivedMessageListener* _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 = (DinoFallbackBodyReceivedMessageListener*) base;
	_data_ = g_slice_new0 (DinoFallbackBodyReceivedMessageListenerRunData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_fallback_body_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_fallback_body_received_message_listener_real_run_co (_data_);
}

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

static gboolean
dino_fallback_body_received_message_listener_real_run_co (DinoFallbackBodyReceivedMessageListenerRunData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = xmpp_xep_fallback_indication_get_fallbacks (_data_->stanza);
	_data_->fallbacks = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->fallbacks;
	_data_->_tmp2_ = gee_collection_get_is_empty ((GeeCollection*) _data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	if (_data_->_tmp3_) {
		_data_->result = FALSE;
		_g_object_unref0 (_data_->fallbacks);
		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_->_tmp4_ = _data_->fallbacks;
		_data_->_fallback_list = _data_->_tmp4_;
		_data_->_tmp5_ = _data_->_fallback_list;
		_data_->_tmp6_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp5_);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_fallback_size = _data_->_tmp7_;
		_data_->_fallback_index = -1;
		while (TRUE) {
			_data_->_fallback_index = _data_->_fallback_index + 1;
			_data_->_tmp8_ = _data_->_fallback_index;
			_data_->_tmp9_ = _data_->_fallback_size;
			if (!(_data_->_tmp8_ < _data_->_tmp9_)) {
				break;
			}
			_data_->_tmp10_ = _data_->_fallback_list;
			_data_->_tmp11_ = gee_list_get (_data_->_tmp10_, _data_->_fallback_index);
			_data_->fallback = (XmppXepFallbackIndicationFallback*) _data_->_tmp11_;
			_data_->_tmp12_ = _data_->fallback;
			_data_->_tmp13_ = xmpp_xep_fallback_indication_fallback_get_ns_uri (_data_->_tmp12_);
			_data_->_tmp14_ = _data_->_tmp13_;
			if (g_strcmp0 (_data_->_tmp14_, XMPP_XEP_REPLIES_NS_URI) != 0) {
				_xmpp_xep_fallback_indication_fallback_unref0 (_data_->fallback);
				continue;
			}
			_xmpp_xep_fallback_indication_fallback_unref0 (_data_->fallback);
		}
	}
	_data_->_tmp15_ = _data_->fallbacks;
	dino_entities_message_set_fallbacks (_data_->message, _data_->_tmp15_);
	_data_->result = FALSE;
	_g_object_unref0 (_data_->fallbacks);
	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_fallback_body_received_message_listener_real_get_action_group (XmppOrderedListener* base)
{
	const gchar* result;
	DinoFallbackBodyReceivedMessageListener* self;
	self = (DinoFallbackBodyReceivedMessageListener*) base;
	result = "Quote";
	return result;
}

static gchar**
dino_fallback_body_received_message_listener_real_get_after_actions (XmppOrderedListener* base,
                                                                     gint* result_length1)
{
	gchar** result;
	DinoFallbackBodyReceivedMessageListener* self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	self = (DinoFallbackBodyReceivedMessageListener*) 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_fallback_body_received_message_listener_class_init (DinoFallbackBodyReceivedMessageListenerClass * klass,
                                                         gpointer klass_data)
{
	dino_fallback_body_received_message_listener_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoFallbackBodyReceivedMessageListener_private_offset);
	((DinoMessageListenerClass *) klass)->run = (void (*) (DinoMessageListener*, DinoEntitiesMessage*, XmppMessageStanza*, DinoEntitiesConversation*, GAsyncReadyCallback, gpointer)) dino_fallback_body_received_message_listener_real_run;
	((DinoMessageListenerClass *) klass)->run_finish = (gboolean (*) (DinoMessageListener*, GAsyncResult*)) dino_fallback_body_received_message_listener_run_finish;
	XMPP_ORDERED_LISTENER_CLASS (klass)->get_action_group = (const gchar* (*) (XmppOrderedListener*)) dino_fallback_body_received_message_listener_real_get_action_group;
	XMPP_ORDERED_LISTENER_CLASS (klass)->get_after_actions = (gchar** (*) (XmppOrderedListener*, gint*)) dino_fallback_body_received_message_listener_real_get_after_actions;
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_fallback_body_received_message_listener_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_fallback_body_received_message_listener_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY, dino_fallback_body_received_message_listener_properties[DINO_FALLBACK_BODY_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_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_AFTER_ACTIONS_PROPERTY, dino_fallback_body_received_message_listener_properties[DINO_FALLBACK_BODY_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_fallback_body_received_message_listener_instance_init (DinoFallbackBodyReceivedMessageListener * self,
                                                            gpointer klass)
{
	gchar* _tmp0_;
	gchar** _tmp1_;
	self->priv = dino_fallback_body_received_message_listener_get_instance_private (self);
	_tmp0_ = g_strdup ("STORE");
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	self->after_actions_const = _tmp1_;
	self->after_actions_const_length1 = 1;
	self->_after_actions_const_size_ = self->after_actions_const_length1;
}

static void
dino_fallback_body_received_message_listener_finalize (GObject * obj)
{
	DinoFallbackBodyReceivedMessageListener * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER, DinoFallbackBodyReceivedMessageListener);
	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);
	_qlite_database_unref0 (self->priv->db);
	G_OBJECT_CLASS (dino_fallback_body_received_message_listener_parent_class)->finalize (obj);
}

static GType
dino_fallback_body_received_message_listener_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoFallbackBodyReceivedMessageListenerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_fallback_body_received_message_listener_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoFallbackBodyReceivedMessageListener), 0, (GInstanceInitFunc) dino_fallback_body_received_message_listener_instance_init, NULL };
	GType dino_fallback_body_received_message_listener_type_id;
	dino_fallback_body_received_message_listener_type_id = g_type_register_static (DINO_TYPE_MESSAGE_LISTENER, "DinoFallbackBodyReceivedMessageListener", &g_define_type_info, 0);
	DinoFallbackBodyReceivedMessageListener_private_offset = g_type_add_instance_private (dino_fallback_body_received_message_listener_type_id, sizeof (DinoFallbackBodyReceivedMessageListenerPrivate));
	return dino_fallback_body_received_message_listener_type_id;
}

static GType
dino_fallback_body_received_message_listener_get_type (void)
{
	static volatile gsize dino_fallback_body_received_message_listener_type_id__once = 0;
	if (g_once_init_enter (&dino_fallback_body_received_message_listener_type_id__once)) {
		GType dino_fallback_body_received_message_listener_type_id;
		dino_fallback_body_received_message_listener_type_id = dino_fallback_body_received_message_listener_get_type_once ();
		g_once_init_leave (&dino_fallback_body_received_message_listener_type_id__once, dino_fallback_body_received_message_listener_type_id);
	}
	return dino_fallback_body_received_message_listener_type_id__once;
}

static void
_vala_dino_fallback_body_received_message_listener_get_property (GObject * object,
                                                                 guint property_id,
                                                                 GValue * value,
                                                                 GParamSpec * pspec)
{
	DinoFallbackBodyReceivedMessageListener * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_FALLBACK_BODY_TYPE_RECEIVED_MESSAGE_LISTENER, DinoFallbackBodyReceivedMessageListener);
	switch (property_id) {
		case DINO_FALLBACK_BODY_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY:
		g_value_set_string (value, xmpp_ordered_listener_get_action_group ((XmppOrderedListener*) self));
		break;
		case DINO_FALLBACK_BODY_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_fallback_body_class_init (DinoFallbackBodyClass * klass,
                               gpointer klass_data)
{
	DinoModuleIdentity* _tmp0_;
	dino_fallback_body_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoFallbackBody_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_fallback_body_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_fallback_body_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_FALLBACK_BODY_ID_PROPERTY, dino_fallback_body_properties[DINO_FALLBACK_BODY_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = dino_module_identity_new (DINO_TYPE_FALLBACK_BODY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, "fallback-body");
	dino_fallback_body_IDENTITY = _tmp0_;
}

static void
dino_fallback_body_dino_stream_interaction_module_interface_init (DinoStreamInteractionModuleIface * iface,
                                                                  gpointer iface_data)
{
	dino_fallback_body_dino_stream_interaction_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = dino_fallback_body_real_get_id;
}

static void
dino_fallback_body_instance_init (DinoFallbackBody * self,
                                  gpointer klass)
{
	self->priv = dino_fallback_body_get_instance_private (self);
}

static void
dino_fallback_body_finalize (GObject * obj)
{
	DinoFallbackBody * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_FALLBACK_BODY, DinoFallbackBody);
	_g_object_unref0 (self->priv->stream_interactor);
	_qlite_database_unref0 (self->priv->db);
	_g_object_unref0 (self->priv->received_message_listener);
	G_OBJECT_CLASS (dino_fallback_body_parent_class)->finalize (obj);
}

static GType
dino_fallback_body_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoFallbackBodyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_fallback_body_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoFallbackBody), 0, (GInstanceInitFunc) dino_fallback_body_instance_init, NULL };
	static const GInterfaceInfo dino_stream_interaction_module_info = { (GInterfaceInitFunc) dino_fallback_body_dino_stream_interaction_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_fallback_body_type_id;
	dino_fallback_body_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoFallbackBody", &g_define_type_info, 0);
	g_type_add_interface_static (dino_fallback_body_type_id, DINO_TYPE_STREAM_INTERACTION_MODULE, &dino_stream_interaction_module_info);
	DinoFallbackBody_private_offset = g_type_add_instance_private (dino_fallback_body_type_id, sizeof (DinoFallbackBodyPrivate));
	return dino_fallback_body_type_id;
}

GType
dino_fallback_body_get_type (void)
{
	static volatile gsize dino_fallback_body_type_id__once = 0;
	if (g_once_init_enter (&dino_fallback_body_type_id__once)) {
		GType dino_fallback_body_type_id;
		dino_fallback_body_type_id = dino_fallback_body_get_type_once ();
		g_once_init_leave (&dino_fallback_body_type_id__once, dino_fallback_body_type_id);
	}
	return dino_fallback_body_type_id__once;
}

static void
_vala_dino_fallback_body_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	DinoFallbackBody * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_FALLBACK_BODY, DinoFallbackBody);
	switch (property_id) {
		case DINO_FALLBACK_BODY_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;
}

