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

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

enum  {
	DINO_STATELESS_FILE_SHARING_0_PROPERTY,
	DINO_STATELESS_FILE_SHARING_ID_PROPERTY,
	DINO_STATELESS_FILE_SHARING_STREAM_INTERACTOR_PROPERTY,
	DINO_STATELESS_FILE_SHARING_FILE_MANAGER_PROPERTY,
	DINO_STATELESS_FILE_SHARING_DB_PROPERTY,
	DINO_STATELESS_FILE_SHARING_NUM_PROPERTIES
};
static GParamSpec* dino_stateless_file_sharing_properties[DINO_STATELESS_FILE_SHARING_NUM_PROPERTIES];

#define DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER (dino_stateless_file_sharing_received_message_listener_get_type ())
#define DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER, DinoStatelessFileSharingReceivedMessageListener))
#define DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER, DinoStatelessFileSharingReceivedMessageListenerClass))
#define DINO_STATELESS_FILE_SHARING_IS_RECEIVED_MESSAGE_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER))
#define DINO_STATELESS_FILE_SHARING_IS_RECEIVED_MESSAGE_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER))
#define DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER, DinoStatelessFileSharingReceivedMessageListenerClass))

typedef struct _DinoStatelessFileSharingReceivedMessageListener DinoStatelessFileSharingReceivedMessageListener;
typedef struct _DinoStatelessFileSharingReceivedMessageListenerClass DinoStatelessFileSharingReceivedMessageListenerClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _xmpp_xep_file_metadata_element_file_metadata_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_file_metadata_element_file_metadata_unref (var), NULL)))
typedef struct _DinoStatelessFileSharingCreateFileTransferData DinoStatelessFileSharingCreateFileTransferData;
typedef struct _DinoStatelessFileSharingReceivedMessageListenerPrivate DinoStatelessFileSharingReceivedMessageListenerPrivate;
enum  {
	DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_0_PROPERTY,
	DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY,
	DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_AFTER_ACTIONS_PROPERTY,
	DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_NUM_PROPERTIES
};
static GParamSpec* dino_stateless_file_sharing_received_message_listener_properties[DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_NUM_PROPERTIES];
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
typedef struct _DinoStatelessFileSharingReceivedMessageListenerRunData DinoStatelessFileSharingReceivedMessageListenerRunData;

struct _DinoStatelessFileSharingCreateFileTransferData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoStatelessFileSharing* self;
	DinoEntitiesConversation* conversation;
	DinoEntitiesMessage* message;
	gchar* file_sharing_id;
	XmppXepFileMetadataElementFileMetadata* metadata;
	GeeList* sources;
	DinoEntitiesFileTransfer* file_transfer;
	DinoEntitiesFileTransfer* _tmp0_;
	DinoEntitiesFileTransfer* _tmp1_;
	DinoEntitiesFileTransfer* _tmp2_;
	DinoEntitiesAccount* _tmp3_;
	DinoEntitiesAccount* _tmp4_;
	DinoEntitiesFileTransfer* _tmp5_;
	XmppJid* _tmp6_;
	XmppJid* _tmp7_;
	DinoEntitiesFileTransfer* _tmp8_;
	XmppJid* _tmp9_;
	XmppJid* _tmp10_;
	DinoEntitiesFileTransfer* _tmp11_;
	gboolean _tmp12_;
	gboolean _tmp13_;
	DinoEntitiesFileTransfer* _tmp14_;
	GDateTime* _tmp15_;
	GDateTime* _tmp16_;
	DinoEntitiesFileTransfer* _tmp17_;
	GDateTime* _tmp18_;
	GDateTime* _tmp19_;
	DinoEntitiesFileTransfer* _tmp20_;
	DinoEntitiesFileTransfer* _tmp21_;
	DinoEntitiesFileTransfer* _tmp22_;
	gint _tmp23_;
	gint _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	DinoEntitiesFileTransfer* _tmp27_;
	GeeList* _tmp28_;
	DinoStreamInteractor* _tmp29_;
	DinoStreamInteractor* _tmp30_;
	DinoStreamInteractor* _tmp31_;
	DinoModuleIdentity* _tmp32_;
	gpointer _tmp33_;
	DinoFileTransferStorage* _tmp34_;
	DinoEntitiesFileTransfer* _tmp35_;
	DinoEntitiesFileTransfer* _tmp36_;
	GDateTime* _tmp37_;
	GDateTime* _tmp38_;
	DinoFileManager* _tmp39_;
	DinoFileManager* _tmp40_;
	DinoFileManager* _tmp41_;
	DinoEntitiesFileTransfer* _tmp42_;
};

struct _DinoStatelessFileSharingReceivedMessageListener {
	DinoMessageListener parent_instance;
	DinoStatelessFileSharingReceivedMessageListenerPrivate * priv;
	gchar** after_actions_const;
	gint after_actions_const_length1;
	gint _after_actions_const_size_;
};

struct _DinoStatelessFileSharingReceivedMessageListenerClass {
	DinoMessageListenerClass parent_class;
};

struct _DinoStatelessFileSharingReceivedMessageListenerPrivate {
	DinoStatelessFileSharing* outer;
	DinoStreamInteractor* stream_interactor;
};

struct _DinoStatelessFileSharingReceivedMessageListenerRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoStatelessFileSharingReceivedMessageListener* self;
	DinoEntitiesMessage* message;
	XmppMessageStanza* stanza;
	DinoEntitiesConversation* conversation;
	gboolean result;
	GeeList* file_shares;
	GeeList* _tmp0_;
	GeeList* _tmp1_;
	GeeList* _file_share_list;
	GeeList* _tmp2_;
	gint _file_share_size;
	GeeList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gint _file_share_index;
	gint _tmp6_;
	gint _tmp7_;
	XmppXepStatelessFileSharingFileShare* file_share;
	GeeList* _tmp8_;
	gpointer _tmp9_;
	XmppXepStatelessFileSharingFileShare* _tmp10_;
	XmppXepFileMetadataElementFileMetadata* _tmp11_;
	XmppXepFileMetadataElementFileMetadata* _tmp12_;
	GeeList* _tmp13_;
	GeeList* _vala1__file_share_list;
	GeeList* _tmp14_;
	gint _vala1__file_share_size;
	GeeList* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	gint _vala1__file_share_index;
	gint _tmp18_;
	gint _tmp19_;
	XmppXepStatelessFileSharingFileShare* _vala1_file_share;
	GeeList* _tmp20_;
	gpointer _tmp21_;
	DinoStatelessFileSharing* _tmp22_;
	XmppXepStatelessFileSharingFileShare* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	XmppXepStatelessFileSharingFileShare* _tmp26_;
	XmppXepFileMetadataElementFileMetadata* _tmp27_;
	XmppXepFileMetadataElementFileMetadata* _tmp28_;
	XmppXepStatelessFileSharingFileShare* _tmp29_;
	GeeList* _tmp30_;
	GeeList* _tmp31_;
	GeeList* source_attachments;
	GeeList* _tmp32_;
	GeeList* _tmp33_;
	GeeList* _source_attachment_list;
	GeeList* _tmp34_;
	gint _source_attachment_size;
	GeeList* _tmp35_;
	gint _tmp36_;
	gint _tmp37_;
	gint _source_attachment_index;
	gint _tmp38_;
	gint _tmp39_;
	XmppXepStatelessFileSharingSourceAttachment* source_attachment;
	GeeList* _tmp40_;
	gpointer _tmp41_;
	DinoStatelessFileSharing* _tmp42_;
	XmppJid* _tmp43_;
	XmppJid* _tmp44_;
	XmppJid* _tmp45_;
	XmppXepStatelessFileSharingSourceAttachment* _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	XmppXepStatelessFileSharingSourceAttachment* _tmp49_;
	const gchar* _tmp50_;
	const gchar* _tmp51_;
	XmppXepStatelessFileSharingSourceAttachment* _tmp52_;
	GeeList* _tmp53_;
	GeeList* _tmp54_;
};

static gpointer dino_stateless_file_sharing_parent_class = NULL;
DinoModuleIdentity* dino_stateless_file_sharing_IDENTITY = NULL;
static gint DinoStatelessFileSharingReceivedMessageListener_private_offset;
static gpointer dino_stateless_file_sharing_received_message_listener_parent_class = NULL;
static DinoStreamInteractionModuleIface * dino_stateless_file_sharing_dino_stream_interaction_module_parent_iface = NULL;

static DinoStatelessFileSharing* dino_stateless_file_sharing_new (DinoStreamInteractor* stream_interactor,
                                                           DinoDatabase* db);
static DinoStatelessFileSharing* dino_stateless_file_sharing_construct (GType object_type,
                                                                 DinoStreamInteractor* stream_interactor,
                                                                 DinoDatabase* db);
static void dino_stateless_file_sharing_set_stream_interactor (DinoStatelessFileSharing* self,
                                                        DinoStreamInteractor* value);
static void dino_stateless_file_sharing_set_db (DinoStatelessFileSharing* self,
                                         DinoDatabase* value);
static DinoStatelessFileSharingReceivedMessageListener* dino_stateless_file_sharing_received_message_listener_new (DinoStatelessFileSharing* outer);
static DinoStatelessFileSharingReceivedMessageListener* dino_stateless_file_sharing_received_message_listener_construct (GType object_type,
                                                                                                                  DinoStatelessFileSharing* outer);
static GType dino_stateless_file_sharing_received_message_listener_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void dino_stateless_file_sharing_create_file_transfer_data_free (gpointer _data);
static gboolean dino_stateless_file_sharing_create_file_transfer_co (DinoStatelessFileSharingCreateFileTransferData* _data_);
static void dino_stateless_file_sharing_set_file_manager (DinoStatelessFileSharing* self,
                                                   DinoFileManager* value);
static void dino_stateless_file_sharing_received_message_listener_real_run_data_free (gpointer _data);
static void dino_stateless_file_sharing_received_message_listener_real_run (DinoMessageListener* base,
                                                                     DinoEntitiesMessage* message,
                                                                     XmppMessageStanza* stanza,
                                                                     DinoEntitiesConversation* conversation,
                                                                     GAsyncReadyCallback _callback_,
                                                                     gpointer _user_data_);
static gboolean dino_stateless_file_sharing_received_message_listener_real_run_co (DinoStatelessFileSharingReceivedMessageListenerRunData* _data_);
static void dino_stateless_file_sharing_received_message_listener_finalize (GObject * obj);
static GType dino_stateless_file_sharing_received_message_listener_get_type_once (void);
static void _vala_dino_stateless_file_sharing_received_message_listener_get_property (GObject * object,
                                                                               guint property_id,
                                                                               GValue * value,
                                                                               GParamSpec * pspec);
static void dino_stateless_file_sharing_finalize (GObject * obj);
static GType dino_stateless_file_sharing_get_type_once (void);
static void _vala_dino_stateless_file_sharing_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_dino_stateless_file_sharing_set_property (GObject * object,
                                                     guint property_id,
                                                     const 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 DinoStatelessFileSharing*
dino_stateless_file_sharing_construct (GType object_type,
                                       DinoStreamInteractor* stream_interactor,
                                       DinoDatabase* db)
{
	DinoStatelessFileSharing * self = NULL;
	DinoModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	DinoMessageProcessor* _tmp2_;
	DinoMessageListenerHolder* _tmp3_;
	DinoStatelessFileSharingReceivedMessageListener* _tmp4_;
	DinoStatelessFileSharingReceivedMessageListener* _tmp5_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoStatelessFileSharing*) g_object_new (object_type, NULL);
	dino_stateless_file_sharing_set_stream_interactor (self, stream_interactor);
	dino_stateless_file_sharing_set_db (self, db);
	_tmp0_ = dino_message_processor_IDENTITY;
	_tmp1_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (DinoMessageProcessor*) _tmp1_;
	_tmp3_ = _tmp2_->received_pipeline;
	_tmp4_ = dino_stateless_file_sharing_received_message_listener_new (self);
	_tmp5_ = _tmp4_;
	xmpp_listener_holder_connect ((XmppListenerHolder*) _tmp3_, (XmppOrderedListener*) _tmp5_);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp2_);
	return self;
}

static DinoStatelessFileSharing*
dino_stateless_file_sharing_new (DinoStreamInteractor* stream_interactor,
                                 DinoDatabase* db)
{
	return dino_stateless_file_sharing_construct (DINO_TYPE_STATELESS_FILE_SHARING, stream_interactor, db);
}

void
dino_stateless_file_sharing_start (DinoStreamInteractor* stream_interactor,
                                   DinoDatabase* db)
{
	DinoStatelessFileSharing* m = NULL;
	DinoStatelessFileSharing* _tmp0_;
	g_return_if_fail (stream_interactor != NULL);
	g_return_if_fail (db != NULL);
	_tmp0_ = dino_stateless_file_sharing_new (stream_interactor, db);
	m = _tmp0_;
	dino_stream_interactor_add_module (stream_interactor, (DinoStreamInteractionModule*) m);
	_g_object_unref0 (m);
}

static void
dino_stateless_file_sharing_create_file_transfer_data_free (gpointer _data)
{
	DinoStatelessFileSharingCreateFileTransferData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->message);
	_g_free0 (_data_->file_sharing_id);
	_xmpp_xep_file_metadata_element_file_metadata_unref0 (_data_->metadata);
	_g_object_unref0 (_data_->sources);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoStatelessFileSharingCreateFileTransferData, _data_);
}

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

static gpointer
_xmpp_xep_file_metadata_element_file_metadata_ref0 (gpointer self)
{
	return self ? xmpp_xep_file_metadata_element_file_metadata_ref (self) : NULL;
}

void
dino_stateless_file_sharing_create_file_transfer (DinoStatelessFileSharing* self,
                                                  DinoEntitiesConversation* conversation,
                                                  DinoEntitiesMessage* message,
                                                  const gchar* file_sharing_id,
                                                  XmppXepFileMetadataElementFileMetadata* metadata,
                                                  GeeList* sources,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	DinoStatelessFileSharingCreateFileTransferData* _data_;
	DinoStatelessFileSharing* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	DinoEntitiesMessage* _tmp2_;
	gchar* _tmp3_;
	XmppXepFileMetadataElementFileMetadata* _tmp4_;
	GeeList* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (message != NULL);
	g_return_if_fail (metadata != NULL);
	_data_ = g_slice_new0 (DinoStatelessFileSharingCreateFileTransferData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_stateless_file_sharing_create_file_transfer_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp1_;
	_tmp2_ = _g_object_ref0 (message);
	_g_object_unref0 (_data_->message);
	_data_->message = _tmp2_;
	_tmp3_ = g_strdup (file_sharing_id);
	_g_free0 (_data_->file_sharing_id);
	_data_->file_sharing_id = _tmp3_;
	_tmp4_ = _xmpp_xep_file_metadata_element_file_metadata_ref0 (metadata);
	_xmpp_xep_file_metadata_element_file_metadata_unref0 (_data_->metadata);
	_data_->metadata = _tmp4_;
	_tmp5_ = _g_object_ref0 (sources);
	_g_object_unref0 (_data_->sources);
	_data_->sources = _tmp5_;
	dino_stateless_file_sharing_create_file_transfer_co (_data_);
}

void
dino_stateless_file_sharing_create_file_transfer_finish (DinoStatelessFileSharing* self,
                                                         GAsyncResult* _res_)
{
	DinoStatelessFileSharingCreateFileTransferData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
dino_stateless_file_sharing_create_file_transfer_co (DinoStatelessFileSharingCreateFileTransferData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = dino_entities_file_transfer_new ();
	_data_->file_transfer = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->file_transfer;
	dino_entities_file_transfer_set_file_sharing_id (_data_->_tmp1_, _data_->file_sharing_id);
	_data_->_tmp2_ = _data_->file_transfer;
	_data_->_tmp3_ = dino_entities_message_get_account (_data_->message);
	_data_->_tmp4_ = _data_->_tmp3_;
	dino_entities_file_transfer_set_account (_data_->_tmp2_, _data_->_tmp4_);
	_data_->_tmp5_ = _data_->file_transfer;
	_data_->_tmp6_ = dino_entities_message_get_counterpart (_data_->message);
	_data_->_tmp7_ = _data_->_tmp6_;
	dino_entities_file_transfer_set_counterpart (_data_->_tmp5_, _data_->_tmp7_);
	_data_->_tmp8_ = _data_->file_transfer;
	_data_->_tmp9_ = dino_entities_message_get_ourpart (_data_->message);
	_data_->_tmp10_ = _data_->_tmp9_;
	dino_entities_file_transfer_set_ourpart (_data_->_tmp8_, _data_->_tmp10_);
	_data_->_tmp11_ = _data_->file_transfer;
	_data_->_tmp12_ = dino_entities_message_get_direction (_data_->message);
	_data_->_tmp13_ = _data_->_tmp12_;
	dino_entities_file_transfer_set_direction (_data_->_tmp11_, _data_->_tmp13_);
	_data_->_tmp14_ = _data_->file_transfer;
	_data_->_tmp15_ = dino_entities_message_get_time (_data_->message);
	_data_->_tmp16_ = _data_->_tmp15_;
	dino_entities_file_transfer_set_time (_data_->_tmp14_, _data_->_tmp16_);
	_data_->_tmp17_ = _data_->file_transfer;
	_data_->_tmp18_ = dino_entities_message_get_local_time (_data_->message);
	_data_->_tmp19_ = _data_->_tmp18_;
	dino_entities_file_transfer_set_local_time (_data_->_tmp17_, _data_->_tmp19_);
	_data_->_tmp20_ = _data_->file_transfer;
	dino_entities_file_transfer_set_provider (_data_->_tmp20_, DINO_STATELESS_FILE_SHARING_SFS_PROVIDER_ID);
	_data_->_tmp21_ = _data_->file_transfer;
	dino_entities_file_transfer_set_file_metadata (_data_->_tmp21_, _data_->metadata);
	_data_->_tmp22_ = _data_->file_transfer;
	_data_->_tmp23_ = dino_entities_message_get_id (_data_->message);
	_data_->_tmp24_ = _data_->_tmp23_;
	_data_->_tmp25_ = g_strdup_printf ("%i", _data_->_tmp24_);
	_data_->_tmp26_ = _data_->_tmp25_;
	dino_entities_file_transfer_set_info (_data_->_tmp22_, _data_->_tmp26_);
	_g_free0 (_data_->_tmp26_);
	if (_data_->sources != NULL) {
		_data_->_tmp27_ = _data_->file_transfer;
		_data_->_tmp28_ = _g_object_ref0 (_data_->sources);
		_g_object_unref0 (_data_->_tmp27_->sfs_sources);
		_data_->_tmp27_->sfs_sources = _data_->_tmp28_;
	}
	_data_->_tmp29_ = dino_stateless_file_sharing_get_stream_interactor (_data_->self);
	_data_->_tmp30_ = _data_->_tmp29_;
	_data_->_tmp31_ = _data_->_tmp30_;
	_data_->_tmp32_ = dino_file_transfer_storage_IDENTITY;
	_data_->_tmp33_ = dino_stream_interactor_get_module (_data_->_tmp31_, DINO_TYPE_FILE_TRANSFER_STORAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp32_);
	_data_->_tmp34_ = (DinoFileTransferStorage*) _data_->_tmp33_;
	_data_->_tmp35_ = _data_->file_transfer;
	dino_file_transfer_storage_add_file (_data_->_tmp34_, _data_->_tmp35_);
	_g_object_unref0 (_data_->_tmp34_);
	_g_object_unref0 (_data_->_tmp31_);
	_data_->_tmp36_ = _data_->file_transfer;
	_data_->_tmp37_ = dino_entities_file_transfer_get_time (_data_->_tmp36_);
	_data_->_tmp38_ = _data_->_tmp37_;
	dino_entities_conversation_set_last_active (_data_->conversation, _data_->_tmp38_);
	_data_->_tmp39_ = dino_stateless_file_sharing_get_file_manager (_data_->self);
	_data_->_tmp40_ = _data_->_tmp39_;
	_data_->_tmp41_ = _data_->_tmp40_;
	_data_->_tmp42_ = _data_->file_transfer;
	g_signal_emit_by_name (_data_->_tmp41_, "received-file", _data_->_tmp42_, _data_->conversation);
	_g_object_unref0 (_data_->_tmp41_);
	_g_object_unref0 (_data_->file_transfer);
	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;
}

void
dino_stateless_file_sharing_on_received_sources (DinoStatelessFileSharing* self,
                                                 XmppJid* from,
                                                 DinoEntitiesConversation* conversation,
                                                 const gchar* attach_to_message_id,
                                                 const gchar* attach_to_file_id,
                                                 GeeList* sources)
{
	DinoEntitiesMessage* message = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	DinoStreamInteractor* _tmp2_;
	DinoModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	DinoMessageStorage* _tmp5_;
	DinoEntitiesMessage* _tmp6_;
	DinoEntitiesMessage* _tmp7_;
	DinoEntitiesMessage* _tmp8_;
	DinoEntitiesFileTransfer* file_transfer = NULL;
	DinoEntitiesFileTransfer* _tmp29_;
	gboolean _tmp30_ = FALSE;
	DinoEntitiesFileTransfer* _tmp31_;
	XmppJid* _tmp32_;
	XmppJid* _tmp33_;
	gboolean _tmp49_ = FALSE;
	gboolean _tmp50_ = FALSE;
	gboolean _tmp51_ = FALSE;
	DinoFileManager* _tmp52_;
	DinoFileManager* _tmp53_;
	DinoFileManager* _tmp54_;
	DinoEntitiesFileTransfer* _tmp55_;
	gboolean _tmp56_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (from != NULL);
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (attach_to_message_id != NULL);
	g_return_if_fail (sources != NULL);
	_tmp0_ = dino_stateless_file_sharing_get_stream_interactor (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = dino_message_storage_IDENTITY;
	_tmp4_ = dino_stream_interactor_get_module (_tmp2_, DINO_TYPE_MESSAGE_STORAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp3_);
	_tmp5_ = (DinoMessageStorage*) _tmp4_;
	_tmp6_ = dino_message_storage_get_message_by_referencing_id (_tmp5_, attach_to_message_id, conversation);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp2_);
	message = _tmp7_;
	_tmp8_ = message;
	if (_tmp8_ == NULL) {
		_g_object_unref0 (message);
		return;
	}
	file_transfer = NULL;
	if (attach_to_file_id != NULL) {
		DinoStreamInteractor* _tmp9_;
		DinoStreamInteractor* _tmp10_;
		DinoStreamInteractor* _tmp11_;
		DinoModuleIdentity* _tmp12_;
		gpointer _tmp13_;
		DinoFileTransferStorage* _tmp14_;
		DinoEntitiesMessage* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		DinoEntitiesFileTransfer* _tmp18_;
		_tmp9_ = dino_stateless_file_sharing_get_stream_interactor (self);
		_tmp10_ = _tmp9_;
		_tmp11_ = _tmp10_;
		_tmp12_ = dino_file_transfer_storage_IDENTITY;
		_tmp13_ = dino_stream_interactor_get_module (_tmp11_, DINO_TYPE_FILE_TRANSFER_STORAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp12_);
		_tmp14_ = (DinoFileTransferStorage*) _tmp13_;
		_tmp15_ = message;
		_tmp16_ = dino_entities_message_get_id (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = dino_file_transfer_storage_get_files_by_message_and_file_id (_tmp14_, _tmp17_, attach_to_file_id, conversation);
		_g_object_unref0 (file_transfer);
		file_transfer = _tmp18_;
		_g_object_unref0 (_tmp14_);
		_g_object_unref0 (_tmp11_);
	} else {
		DinoStreamInteractor* _tmp19_;
		DinoStreamInteractor* _tmp20_;
		DinoStreamInteractor* _tmp21_;
		DinoModuleIdentity* _tmp22_;
		gpointer _tmp23_;
		DinoFileTransferStorage* _tmp24_;
		DinoEntitiesMessage* _tmp25_;
		gint _tmp26_;
		gint _tmp27_;
		DinoEntitiesFileTransfer* _tmp28_;
		_tmp19_ = dino_stateless_file_sharing_get_stream_interactor (self);
		_tmp20_ = _tmp19_;
		_tmp21_ = _tmp20_;
		_tmp22_ = dino_file_transfer_storage_IDENTITY;
		_tmp23_ = dino_stream_interactor_get_module (_tmp21_, DINO_TYPE_FILE_TRANSFER_STORAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp22_);
		_tmp24_ = (DinoFileTransferStorage*) _tmp23_;
		_tmp25_ = message;
		_tmp26_ = dino_entities_message_get_id (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = dino_file_transfer_storage_get_file_by_message_id (_tmp24_, _tmp27_, conversation);
		_g_object_unref0 (file_transfer);
		file_transfer = _tmp28_;
		_g_object_unref0 (_tmp24_);
		_g_object_unref0 (_tmp21_);
	}
	_tmp29_ = file_transfer;
	if (_tmp29_ == NULL) {
		_g_object_unref0 (file_transfer);
		_g_object_unref0 (message);
		return;
	}
	_tmp31_ = file_transfer;
	_tmp32_ = dino_entities_file_transfer_get_from (_tmp31_);
	_tmp33_ = _tmp32_;
	if (xmpp_jid_equals (from, _tmp33_)) {
		DinoEntitiesFileTransfer* _tmp34_;
		GeeList* _tmp35_;
		GeeList* _tmp36_;
		GeeList* _tmp37_;
		gboolean _tmp38_;
		gboolean _tmp39_;
		_tmp34_ = file_transfer;
		_tmp35_ = _tmp34_->hashes;
		_tmp36_ = xmpp_xep_cryptographic_hashes_get_supported_hashes (_tmp35_);
		_tmp37_ = _tmp36_;
		_tmp38_ = gee_collection_get_is_empty ((GeeCollection*) _tmp37_);
		_tmp39_ = _tmp38_;
		_tmp30_ = _tmp39_;
		_g_object_unref0 (_tmp37_);
	} else {
		_tmp30_ = FALSE;
	}
	if (_tmp30_) {
		g_warning ("stateless_file_sharing.vala:79: Ignoring sfs source: Not from original" \
" sender or no known file hashes");
		_g_object_unref0 (file_transfer);
		_g_object_unref0 (message);
		return;
	}
	{
		GeeList* _source_list = NULL;
		gint _source_size = 0;
		GeeList* _tmp40_;
		gint _tmp41_;
		gint _tmp42_;
		gint _source_index = 0;
		_source_list = sources;
		_tmp40_ = _source_list;
		_tmp41_ = gee_collection_get_size ((GeeCollection*) _tmp40_);
		_tmp42_ = _tmp41_;
		_source_size = _tmp42_;
		_source_index = -1;
		while (TRUE) {
			gint _tmp43_;
			gint _tmp44_;
			XmppXepStatelessFileSharingSource* source = NULL;
			GeeList* _tmp45_;
			gpointer _tmp46_;
			DinoEntitiesFileTransfer* _tmp47_;
			XmppXepStatelessFileSharingSource* _tmp48_;
			_source_index = _source_index + 1;
			_tmp43_ = _source_index;
			_tmp44_ = _source_size;
			if (!(_tmp43_ < _tmp44_)) {
				break;
			}
			_tmp45_ = _source_list;
			_tmp46_ = gee_list_get (_tmp45_, _source_index);
			source = (XmppXepStatelessFileSharingSource*) _tmp46_;
			_tmp47_ = file_transfer;
			_tmp48_ = source;
			dino_entities_file_transfer_add_sfs_source (_tmp47_, _tmp48_);
			_g_object_unref0 (source);
		}
	}
	_tmp52_ = dino_stateless_file_sharing_get_file_manager (self);
	_tmp53_ = _tmp52_;
	_tmp54_ = _tmp53_;
	_tmp55_ = file_transfer;
	_tmp56_ = dino_file_manager_is_sender_trustworthy (_tmp54_, _tmp55_, conversation);
	_g_object_unref0 (_tmp54_);
	if (_tmp56_) {
		DinoEntitiesFileTransfer* _tmp57_;
		DinoEntitiesFileTransferState _tmp58_;
		DinoEntitiesFileTransferState _tmp59_;
		_tmp57_ = file_transfer;
		_tmp58_ = dino_entities_file_transfer_get_state (_tmp57_);
		_tmp59_ = _tmp58_;
		_tmp51_ = _tmp59_ == DINO_ENTITIES_FILE_TRANSFER_STATE_NOT_STARTED;
	} else {
		_tmp51_ = FALSE;
	}
	if (_tmp51_) {
		DinoEntitiesFileTransfer* _tmp60_;
		gint64 _tmp61_;
		gint64 _tmp62_;
		_tmp60_ = file_transfer;
		_tmp61_ = dino_entities_file_transfer_get_size (_tmp60_);
		_tmp62_ = _tmp61_;
		_tmp50_ = _tmp62_ >= ((gint64) 0);
	} else {
		_tmp50_ = FALSE;
	}
	if (_tmp50_) {
		DinoEntitiesFileTransfer* _tmp63_;
		gint64 _tmp64_;
		gint64 _tmp65_;
		_tmp63_ = file_transfer;
		_tmp64_ = dino_entities_file_transfer_get_size (_tmp63_);
		_tmp65_ = _tmp64_;
		_tmp49_ = _tmp65_ < ((gint64) 5000000);
	} else {
		_tmp49_ = FALSE;
	}
	if (_tmp49_) {
		DinoFileManager* _tmp66_;
		DinoFileManager* _tmp67_;
		DinoFileManager* _tmp68_;
		DinoEntitiesFileTransfer* _tmp69_;
		_tmp66_ = dino_stateless_file_sharing_get_file_manager (self);
		_tmp67_ = _tmp66_;
		_tmp68_ = _tmp67_;
		_tmp69_ = file_transfer;
		dino_file_manager_download_file (_tmp68_, _tmp69_, NULL, NULL);
		_g_object_unref0 (_tmp68_);
	}
	_g_object_unref0 (file_transfer);
	_g_object_unref0 (message);
}

static const gchar*
dino_stateless_file_sharing_real_get_id (DinoStreamInteractionModule* base)
{
	const gchar* result;
	DinoStatelessFileSharing* self;
	DinoModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (DinoStatelessFileSharing*) base;
	_tmp0_ = dino_stateless_file_sharing_IDENTITY;
	_tmp1_ = dino_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

DinoStreamInteractor*
dino_stateless_file_sharing_get_stream_interactor (DinoStatelessFileSharing* self)
{
	DinoStreamInteractor* result;
	DinoApplication* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	DinoStreamInteractor* _tmp2_;
	DinoStreamInteractor* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dino_application_get_default ();
	_tmp1_ = dino_application_get_stream_interactor (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static void
dino_stateless_file_sharing_set_stream_interactor (DinoStatelessFileSharing* self,
                                                   DinoStreamInteractor* value)
{
	g_return_if_fail (self != NULL);
	g_object_notify_by_pspec ((GObject *) self, dino_stateless_file_sharing_properties[DINO_STATELESS_FILE_SHARING_STREAM_INTERACTOR_PROPERTY]);
}

DinoFileManager*
dino_stateless_file_sharing_get_file_manager (DinoStatelessFileSharing* self)
{
	DinoFileManager* result;
	DinoStreamInteractor* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	DinoStreamInteractor* _tmp2_;
	DinoModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	DinoFileManager* _tmp5_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dino_stateless_file_sharing_get_stream_interactor (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = dino_file_manager_IDENTITY;
	_tmp4_ = dino_stream_interactor_get_module (_tmp2_, DINO_TYPE_FILE_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp3_);
	_tmp5_ = (DinoFileManager*) _tmp4_;
	_g_object_unref0 (_tmp2_);
	result = _tmp5_;
	return result;
}

static void
dino_stateless_file_sharing_set_file_manager (DinoStatelessFileSharing* self,
                                              DinoFileManager* value)
{
	g_return_if_fail (self != NULL);
	g_object_notify_by_pspec ((GObject *) self, dino_stateless_file_sharing_properties[DINO_STATELESS_FILE_SHARING_FILE_MANAGER_PROPERTY]);
}

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

DinoDatabase*
dino_stateless_file_sharing_get_db (DinoStatelessFileSharing* self)
{
	DinoDatabase* result;
	DinoApplication* _tmp0_;
	DinoDatabase* _tmp1_;
	DinoDatabase* _tmp2_;
	DinoDatabase* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = dino_application_get_default ();
	_tmp1_ = dino_application_get_db (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _qlite_database_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static void
dino_stateless_file_sharing_set_db (DinoStatelessFileSharing* self,
                                    DinoDatabase* value)
{
	g_return_if_fail (self != NULL);
	g_object_notify_by_pspec ((GObject *) self, dino_stateless_file_sharing_properties[DINO_STATELESS_FILE_SHARING_DB_PROPERTY]);
}

static inline gpointer
dino_stateless_file_sharing_received_message_listener_get_instance_private (DinoStatelessFileSharingReceivedMessageListener* self)
{
	return G_STRUCT_MEMBER_P (self, DinoStatelessFileSharingReceivedMessageListener_private_offset);
}

static DinoStatelessFileSharingReceivedMessageListener*
dino_stateless_file_sharing_received_message_listener_construct (GType object_type,
                                                                 DinoStatelessFileSharing* outer)
{
	DinoStatelessFileSharingReceivedMessageListener * self = NULL;
	DinoStatelessFileSharing* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	DinoStreamInteractor* _tmp2_;
	g_return_val_if_fail (outer != NULL, NULL);
	self = (DinoStatelessFileSharingReceivedMessageListener*) dino_message_listener_construct (object_type);
	_tmp0_ = _g_object_ref0 (outer);
	_g_object_unref0 (self->priv->outer);
	self->priv->outer = _tmp0_;
	_tmp1_ = dino_stateless_file_sharing_get_stream_interactor (outer);
	_tmp2_ = _tmp1_;
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp2_;
	return self;
}

static DinoStatelessFileSharingReceivedMessageListener*
dino_stateless_file_sharing_received_message_listener_new (DinoStatelessFileSharing* outer)
{
	return dino_stateless_file_sharing_received_message_listener_construct (DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER, outer);
}

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

static void
dino_stateless_file_sharing_received_message_listener_real_run (DinoMessageListener* base,
                                                                DinoEntitiesMessage* message,
                                                                XmppMessageStanza* stanza,
                                                                DinoEntitiesConversation* conversation,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_)
{
	DinoStatelessFileSharingReceivedMessageListener * self;
	DinoStatelessFileSharingReceivedMessageListenerRunData* _data_;
	DinoStatelessFileSharingReceivedMessageListener* _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 = (DinoStatelessFileSharingReceivedMessageListener*) base;
	_data_ = g_slice_new0 (DinoStatelessFileSharingReceivedMessageListenerRunData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_stateless_file_sharing_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_stateless_file_sharing_received_message_listener_real_run_co (_data_);
}

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

static gboolean
dino_stateless_file_sharing_received_message_listener_real_run_co (DinoStatelessFileSharingReceivedMessageListenerRunData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = xmpp_xep_stateless_file_sharing_get_file_shares (_data_->stanza);
	_data_->file_shares = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->file_shares;
	if (_data_->_tmp1_ != NULL) {
		{
			_data_->_tmp2_ = _data_->file_shares;
			_data_->_file_share_list = _data_->_tmp2_;
			_data_->_tmp3_ = _data_->_file_share_list;
			_data_->_tmp4_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp3_);
			_data_->_tmp5_ = _data_->_tmp4_;
			_data_->_file_share_size = _data_->_tmp5_;
			_data_->_file_share_index = -1;
			while (TRUE) {
				_data_->_file_share_index = _data_->_file_share_index + 1;
				_data_->_tmp6_ = _data_->_file_share_index;
				_data_->_tmp7_ = _data_->_file_share_size;
				if (!(_data_->_tmp6_ < _data_->_tmp7_)) {
					break;
				}
				_data_->_tmp8_ = _data_->_file_share_list;
				_data_->_tmp9_ = gee_list_get (_data_->_tmp8_, _data_->_file_share_index);
				_data_->file_share = (XmppXepStatelessFileSharingFileShare*) _data_->_tmp9_;
				_data_->_tmp10_ = _data_->file_share;
				_data_->_tmp11_ = xmpp_xep_stateless_file_sharing_file_share_get_metadata (_data_->_tmp10_);
				_data_->_tmp12_ = _data_->_tmp11_;
				_data_->_tmp13_ = _data_->_tmp12_->hashes;
				if (!xmpp_xep_cryptographic_hashes_has_supported_hashes (_data_->_tmp13_)) {
					_data_->result = FALSE;
					_g_object_unref0 (_data_->file_share);
					_g_object_unref0 (_data_->file_shares);
					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;
				}
				_g_object_unref0 (_data_->file_share);
			}
		}
		{
			_data_->_tmp14_ = _data_->file_shares;
			_data_->_vala1__file_share_list = _data_->_tmp14_;
			_data_->_tmp15_ = _data_->_vala1__file_share_list;
			_data_->_tmp16_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp15_);
			_data_->_tmp17_ = _data_->_tmp16_;
			_data_->_vala1__file_share_size = _data_->_tmp17_;
			_data_->_vala1__file_share_index = -1;
			while (TRUE) {
				_data_->_vala1__file_share_index = _data_->_vala1__file_share_index + 1;
				_data_->_tmp18_ = _data_->_vala1__file_share_index;
				_data_->_tmp19_ = _data_->_vala1__file_share_size;
				if (!(_data_->_tmp18_ < _data_->_tmp19_)) {
					break;
				}
				_data_->_tmp20_ = _data_->_vala1__file_share_list;
				_data_->_tmp21_ = gee_list_get (_data_->_tmp20_, _data_->_vala1__file_share_index);
				_data_->_vala1_file_share = (XmppXepStatelessFileSharingFileShare*) _data_->_tmp21_;
				_data_->_tmp22_ = _data_->self->priv->outer;
				_data_->_tmp23_ = _data_->_vala1_file_share;
				_data_->_tmp24_ = xmpp_xep_stateless_file_sharing_file_share_get_id (_data_->_tmp23_);
				_data_->_tmp25_ = _data_->_tmp24_;
				_data_->_tmp26_ = _data_->_vala1_file_share;
				_data_->_tmp27_ = xmpp_xep_stateless_file_sharing_file_share_get_metadata (_data_->_tmp26_);
				_data_->_tmp28_ = _data_->_tmp27_;
				_data_->_tmp29_ = _data_->_vala1_file_share;
				_data_->_tmp30_ = xmpp_xep_stateless_file_sharing_file_share_get_sources (_data_->_tmp29_);
				_data_->_tmp31_ = _data_->_tmp30_;
				dino_stateless_file_sharing_create_file_transfer (_data_->_tmp22_, _data_->conversation, _data_->message, _data_->_tmp25_, _data_->_tmp28_, _data_->_tmp31_, NULL, NULL);
				_g_object_unref0 (_data_->_vala1_file_share);
			}
		}
		_data_->result = TRUE;
		_g_object_unref0 (_data_->file_shares);
		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_->_tmp32_ = xmpp_xep_stateless_file_sharing_get_source_attachments (_data_->stanza);
	_data_->source_attachments = _data_->_tmp32_;
	_data_->_tmp33_ = _data_->source_attachments;
	if (_data_->_tmp33_ != NULL) {
		{
			_data_->_tmp34_ = _data_->source_attachments;
			_data_->_source_attachment_list = _data_->_tmp34_;
			_data_->_tmp35_ = _data_->_source_attachment_list;
			_data_->_tmp36_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp35_);
			_data_->_tmp37_ = _data_->_tmp36_;
			_data_->_source_attachment_size = _data_->_tmp37_;
			_data_->_source_attachment_index = -1;
			while (TRUE) {
				_data_->_source_attachment_index = _data_->_source_attachment_index + 1;
				_data_->_tmp38_ = _data_->_source_attachment_index;
				_data_->_tmp39_ = _data_->_source_attachment_size;
				if (!(_data_->_tmp38_ < _data_->_tmp39_)) {
					break;
				}
				_data_->_tmp40_ = _data_->_source_attachment_list;
				_data_->_tmp41_ = gee_list_get (_data_->_tmp40_, _data_->_source_attachment_index);
				_data_->source_attachment = (XmppXepStatelessFileSharingSourceAttachment*) _data_->_tmp41_;
				_data_->_tmp42_ = _data_->self->priv->outer;
				_data_->_tmp43_ = xmpp_stanza_get_from ((XmppStanza*) _data_->stanza);
				_data_->_tmp44_ = _data_->_tmp43_;
				_data_->_tmp45_ = _data_->_tmp44_;
				_data_->_tmp46_ = _data_->source_attachment;
				_data_->_tmp47_ = xmpp_xep_stateless_file_sharing_source_attachment_get_to_message_id (_data_->_tmp46_);
				_data_->_tmp48_ = _data_->_tmp47_;
				_data_->_tmp49_ = _data_->source_attachment;
				_data_->_tmp50_ = xmpp_xep_stateless_file_sharing_source_attachment_get_to_file_transfer_id (_data_->_tmp49_);
				_data_->_tmp51_ = _data_->_tmp50_;
				_data_->_tmp52_ = _data_->source_attachment;
				_data_->_tmp53_ = xmpp_xep_stateless_file_sharing_source_attachment_get_sources (_data_->_tmp52_);
				_data_->_tmp54_ = _data_->_tmp53_;
				dino_stateless_file_sharing_on_received_sources (_data_->_tmp42_, _data_->_tmp45_, _data_->conversation, _data_->_tmp48_, _data_->_tmp51_, _data_->_tmp54_);
				_xmpp_jid_unref0 (_data_->_tmp45_);
				_data_->result = TRUE;
				_g_object_unref0 (_data_->source_attachment);
				_g_object_unref0 (_data_->source_attachments);
				_g_object_unref0 (_data_->file_shares);
				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;
			}
		}
	}
	if (xmpp_xep_stateless_file_sharing_is_sfs_fallback_message (_data_->stanza)) {
		_data_->result = TRUE;
		_g_object_unref0 (_data_->source_attachments);
		_g_object_unref0 (_data_->file_shares);
		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_->result = FALSE;
	_g_object_unref0 (_data_->source_attachments);
	_g_object_unref0 (_data_->file_shares);
	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_stateless_file_sharing_received_message_listener_real_get_action_group (XmppOrderedListener* base)
{
	const gchar* result;
	DinoStatelessFileSharingReceivedMessageListener* self;
	self = (DinoStatelessFileSharingReceivedMessageListener*) base;
	result = "MESSAGE_REINTERPRETING";
	return result;
}

static gchar**
dino_stateless_file_sharing_received_message_listener_real_get_after_actions (XmppOrderedListener* base,
                                                                              gint* result_length1)
{
	gchar** result;
	DinoStatelessFileSharingReceivedMessageListener* self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	self = (DinoStatelessFileSharingReceivedMessageListener*) 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_stateless_file_sharing_received_message_listener_class_init (DinoStatelessFileSharingReceivedMessageListenerClass * klass,
                                                                  gpointer klass_data)
{
	dino_stateless_file_sharing_received_message_listener_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoStatelessFileSharingReceivedMessageListener_private_offset);
	((DinoMessageListenerClass *) klass)->run = (void (*) (DinoMessageListener*, DinoEntitiesMessage*, XmppMessageStanza*, DinoEntitiesConversation*, GAsyncReadyCallback, gpointer)) dino_stateless_file_sharing_received_message_listener_real_run;
	((DinoMessageListenerClass *) klass)->run_finish = (gboolean (*) (DinoMessageListener*, GAsyncResult*)) dino_stateless_file_sharing_received_message_listener_run_finish;
	XMPP_ORDERED_LISTENER_CLASS (klass)->get_action_group = (const gchar* (*) (XmppOrderedListener*)) dino_stateless_file_sharing_received_message_listener_real_get_action_group;
	XMPP_ORDERED_LISTENER_CLASS (klass)->get_after_actions = (gchar** (*) (XmppOrderedListener*, gint*)) dino_stateless_file_sharing_received_message_listener_real_get_after_actions;
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_stateless_file_sharing_received_message_listener_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_stateless_file_sharing_received_message_listener_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY, dino_stateless_file_sharing_received_message_listener_properties[DINO_STATELESS_FILE_SHARING_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_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_AFTER_ACTIONS_PROPERTY, dino_stateless_file_sharing_received_message_listener_properties[DINO_STATELESS_FILE_SHARING_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_stateless_file_sharing_received_message_listener_instance_init (DinoStatelessFileSharingReceivedMessageListener * self,
                                                                     gpointer klass)
{
	gchar* _tmp0_;
	gchar** _tmp1_;
	self->priv = dino_stateless_file_sharing_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_stateless_file_sharing_received_message_listener_finalize (GObject * obj)
{
	DinoStatelessFileSharingReceivedMessageListener * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER, DinoStatelessFileSharingReceivedMessageListener);
	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->outer);
	_g_object_unref0 (self->priv->stream_interactor);
	G_OBJECT_CLASS (dino_stateless_file_sharing_received_message_listener_parent_class)->finalize (obj);
}

static GType
dino_stateless_file_sharing_received_message_listener_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoStatelessFileSharingReceivedMessageListenerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_stateless_file_sharing_received_message_listener_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoStatelessFileSharingReceivedMessageListener), 0, (GInstanceInitFunc) dino_stateless_file_sharing_received_message_listener_instance_init, NULL };
	GType dino_stateless_file_sharing_received_message_listener_type_id;
	dino_stateless_file_sharing_received_message_listener_type_id = g_type_register_static (DINO_TYPE_MESSAGE_LISTENER, "DinoStatelessFileSharingReceivedMessageListener", &g_define_type_info, 0);
	DinoStatelessFileSharingReceivedMessageListener_private_offset = g_type_add_instance_private (dino_stateless_file_sharing_received_message_listener_type_id, sizeof (DinoStatelessFileSharingReceivedMessageListenerPrivate));
	return dino_stateless_file_sharing_received_message_listener_type_id;
}

static GType
dino_stateless_file_sharing_received_message_listener_get_type (void)
{
	static volatile gsize dino_stateless_file_sharing_received_message_listener_type_id__once = 0;
	if (g_once_init_enter (&dino_stateless_file_sharing_received_message_listener_type_id__once)) {
		GType dino_stateless_file_sharing_received_message_listener_type_id;
		dino_stateless_file_sharing_received_message_listener_type_id = dino_stateless_file_sharing_received_message_listener_get_type_once ();
		g_once_init_leave (&dino_stateless_file_sharing_received_message_listener_type_id__once, dino_stateless_file_sharing_received_message_listener_type_id);
	}
	return dino_stateless_file_sharing_received_message_listener_type_id__once;
}

static void
_vala_dino_stateless_file_sharing_received_message_listener_get_property (GObject * object,
                                                                          guint property_id,
                                                                          GValue * value,
                                                                          GParamSpec * pspec)
{
	DinoStatelessFileSharingReceivedMessageListener * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_STATELESS_FILE_SHARING_TYPE_RECEIVED_MESSAGE_LISTENER, DinoStatelessFileSharingReceivedMessageListener);
	switch (property_id) {
		case DINO_STATELESS_FILE_SHARING_RECEIVED_MESSAGE_LISTENER_ACTION_GROUP_PROPERTY:
		g_value_set_string (value, xmpp_ordered_listener_get_action_group ((XmppOrderedListener*) self));
		break;
		case DINO_STATELESS_FILE_SHARING_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_stateless_file_sharing_class_init (DinoStatelessFileSharingClass * klass,
                                        gpointer klass_data)
{
	DinoModuleIdentity* _tmp0_;
	dino_stateless_file_sharing_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_stateless_file_sharing_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dino_stateless_file_sharing_set_property;
	G_OBJECT_CLASS (klass)->finalize = dino_stateless_file_sharing_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_STATELESS_FILE_SHARING_ID_PROPERTY, dino_stateless_file_sharing_properties[DINO_STATELESS_FILE_SHARING_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_STATELESS_FILE_SHARING_STREAM_INTERACTOR_PROPERTY, dino_stateless_file_sharing_properties[DINO_STATELESS_FILE_SHARING_STREAM_INTERACTOR_PROPERTY] = g_param_spec_object ("stream-interactor", "stream-interactor", "stream-interactor", DINO_TYPE_STREAM_INTERACTOR, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_STATELESS_FILE_SHARING_FILE_MANAGER_PROPERTY, dino_stateless_file_sharing_properties[DINO_STATELESS_FILE_SHARING_FILE_MANAGER_PROPERTY] = g_param_spec_object ("file-manager", "file-manager", "file-manager", DINO_TYPE_FILE_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_STATELESS_FILE_SHARING_DB_PROPERTY, dino_stateless_file_sharing_properties[DINO_STATELESS_FILE_SHARING_DB_PROPERTY] = qlite_param_spec_database ("db", "db", "db", DINO_TYPE_DATABASE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = dino_module_identity_new (DINO_TYPE_STATELESS_FILE_SHARING, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, "sfs");
	dino_stateless_file_sharing_IDENTITY = _tmp0_;
}

static void
dino_stateless_file_sharing_dino_stream_interaction_module_interface_init (DinoStreamInteractionModuleIface * iface,
                                                                           gpointer iface_data)
{
	dino_stateless_file_sharing_dino_stream_interaction_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = dino_stateless_file_sharing_real_get_id;
}

static void
dino_stateless_file_sharing_instance_init (DinoStatelessFileSharing * self,
                                           gpointer klass)
{
}

static void
dino_stateless_file_sharing_finalize (GObject * obj)
{
	DinoStatelessFileSharing * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_STATELESS_FILE_SHARING, DinoStatelessFileSharing);
	G_OBJECT_CLASS (dino_stateless_file_sharing_parent_class)->finalize (obj);
}

static GType
dino_stateless_file_sharing_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoStatelessFileSharingClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_stateless_file_sharing_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoStatelessFileSharing), 0, (GInstanceInitFunc) dino_stateless_file_sharing_instance_init, NULL };
	static const GInterfaceInfo dino_stream_interaction_module_info = { (GInterfaceInitFunc) dino_stateless_file_sharing_dino_stream_interaction_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_stateless_file_sharing_type_id;
	dino_stateless_file_sharing_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoStatelessFileSharing", &g_define_type_info, 0);
	g_type_add_interface_static (dino_stateless_file_sharing_type_id, DINO_TYPE_STREAM_INTERACTION_MODULE, &dino_stream_interaction_module_info);
	return dino_stateless_file_sharing_type_id;
}

GType
dino_stateless_file_sharing_get_type (void)
{
	static volatile gsize dino_stateless_file_sharing_type_id__once = 0;
	if (g_once_init_enter (&dino_stateless_file_sharing_type_id__once)) {
		GType dino_stateless_file_sharing_type_id;
		dino_stateless_file_sharing_type_id = dino_stateless_file_sharing_get_type_once ();
		g_once_init_leave (&dino_stateless_file_sharing_type_id__once, dino_stateless_file_sharing_type_id);
	}
	return dino_stateless_file_sharing_type_id__once;
}

static void
_vala_dino_stateless_file_sharing_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	DinoStatelessFileSharing * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_STATELESS_FILE_SHARING, DinoStatelessFileSharing);
	switch (property_id) {
		case DINO_STATELESS_FILE_SHARING_ID_PROPERTY:
		g_value_set_string (value, dino_stream_interaction_module_get_id ((DinoStreamInteractionModule*) self));
		break;
		case DINO_STATELESS_FILE_SHARING_STREAM_INTERACTOR_PROPERTY:
		g_value_take_object (value, dino_stateless_file_sharing_get_stream_interactor (self));
		break;
		case DINO_STATELESS_FILE_SHARING_FILE_MANAGER_PROPERTY:
		g_value_take_object (value, dino_stateless_file_sharing_get_file_manager (self));
		break;
		case DINO_STATELESS_FILE_SHARING_DB_PROPERTY:
		qlite_value_take_database (value, dino_stateless_file_sharing_get_db (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dino_stateless_file_sharing_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	DinoStatelessFileSharing * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_STATELESS_FILE_SHARING, DinoStatelessFileSharing);
	switch (property_id) {
		case DINO_STATELESS_FILE_SHARING_STREAM_INTERACTOR_PROPERTY:
		dino_stateless_file_sharing_set_stream_interactor (self, g_value_get_object (value));
		break;
		case DINO_STATELESS_FILE_SHARING_FILE_MANAGER_PROPERTY:
		dino_stateless_file_sharing_set_file_manager (self, g_value_get_object (value));
		break;
		case DINO_STATELESS_FILE_SHARING_DB_PROPERTY:
		dino_stateless_file_sharing_set_db (self, qlite_value_get_database (value));
		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;
}

