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

#include "http-files.h"
#include "libdino.h"
#include <libsoup/soup.h>
#include <gee.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "xmpp-vala.h"
#include <gio/gio.h>
#include <float.h>
#include <math.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_PLUGINS_HTTP_FILES_HTTP_FILE_SENDER_0_PROPERTY,
	DINO_PLUGINS_HTTP_FILES_HTTP_FILE_SENDER_NUM_PROPERTIES
};
static GParamSpec* dino_plugins_http_files_http_file_sender_properties[DINO_PLUGINS_HTTP_FILES_HTTP_FILE_SENDER_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 _dino_file_meta_unref0(var) ((var == NULL) ? NULL : (var = (dino_file_meta_unref (var), NULL)))
#define _dino_file_send_data_unref0(var) ((var == NULL) ? NULL : (var = (dino_file_send_data_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData;
typedef struct _Block3Data Block3Data;
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
typedef struct _DinoPluginsHttpFilesHttpFileSenderSendFileData DinoPluginsHttpFilesHttpFileSenderSendFileData;
typedef struct _DinoPluginsHttpFilesHttpFileSenderCanSendData DinoPluginsHttpFilesHttpFileSenderCanSendData;
typedef struct _DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData;
typedef struct _DinoPluginsHttpFilesHttpFileSenderCanEncryptData DinoPluginsHttpFilesHttpFileSenderCanEncryptData;
typedef struct _DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData;
typedef struct _Block4Data Block4Data;
#define _g_uri_unref0(var) ((var == NULL) ? NULL : (var = (g_uri_unref (var), NULL)))
typedef struct _DinoPluginsHttpFilesHttpFileSenderUploadData DinoPluginsHttpFilesHttpFileSenderUploadData;
typedef struct _Block5Data Block5Data;
#define _xmpp_xep_file_metadata_element_file_metadata_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_file_metadata_element_file_metadata_unref (var), NULL)))

struct _DinoPluginsHttpFilesHttpFileSenderPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoDatabase* db;
	SoupSession* session;
	GeeHashMap* max_file_sizes;
	GRecMutex __lock_max_file_sizes;
};

struct _DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsHttpFilesHttpFileSender* self;
	DinoEntitiesConversation* conversation;
	DinoEntitiesFileTransfer* file_transfer;
	DinoFileMeta* file_meta;
	DinoFileSendData* result;
	DinoHttpFileSendData* send_data;
	DinoHttpFileSendData* _tmp0_;
	DinoHttpFileSendData* _tmp1_;
	XmppXmppStream* stream;
	DinoStreamInteractor* _tmp2_;
	DinoEntitiesAccount* _tmp3_;
	DinoEntitiesAccount* _tmp4_;
	XmppXmppStream* _tmp5_;
	XmppXmppStream* _tmp6_;
	XmppXepHttpFileUploadModuleSlotResult slot_result;
	DinoStreamInteractor* _tmp7_;
	DinoModuleManager* _tmp8_;
	DinoEntitiesAccount* _tmp9_;
	DinoEntitiesAccount* _tmp10_;
	XmppModuleIdentity* _tmp11_;
	gpointer _tmp12_;
	XmppXepHttpFileUploadModule* _tmp13_;
	XmppXmppStream* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	XmppXepHttpFileUploadModuleSlotResult _tmp18_;
	XmppXepHttpFileUploadModuleSlotResult _tmp19_;
	DinoHttpFileSendData* _tmp20_;
	XmppXepHttpFileUploadModuleSlotResult _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	DinoHttpFileSendData* _tmp24_;
	XmppXepHttpFileUploadModuleSlotResult _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	DinoHttpFileSendData* _tmp28_;
	XmppXepHttpFileUploadModuleSlotResult _tmp29_;
	GeeHashMap* _tmp30_;
	GeeHashMap* _tmp31_;
	GError* e;
	GError* _tmp32_;
	const gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	GError* _tmp36_;
	GError* _tmp37_;
	GError* _inner_error0_;
};

struct _Block3Data {
	int _ref_count_;
	DinoPluginsHttpFilesHttpFileSender* self;
	gpointer _async_data_;
};

struct _DinoPluginsHttpFilesHttpFileSenderSendFileData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsHttpFilesHttpFileSender* self;
	DinoEntitiesConversation* conversation;
	DinoEntitiesFileTransfer* file_transfer;
	DinoFileSendData* file_send_data;
	DinoFileMeta* file_meta;
	Block3Data* _data3_;
	DinoHttpFileSendData* send_data;
	DinoHttpFileSendData* _tmp0_;
	DinoHttpFileSendData* _tmp1_;
	gboolean _tmp2_;
	DinoEntitiesConversationType _tmp3_;
	DinoEntitiesConversationType _tmp4_;
	gboolean _tmp5_;
	DinoStreamInteractor* _tmp6_;
	DinoModuleIdentity* _tmp7_;
	gpointer _tmp8_;
	DinoEntityInfo* _tmp9_;
	DinoEntitiesAccount* _tmp10_;
	DinoEntitiesAccount* _tmp11_;
	XmppJid* _tmp12_;
	XmppJid* _tmp13_;
	gboolean _tmp14_;
	DinoStreamInteractor* _tmp15_;
	DinoModuleIdentity* _tmp16_;
	gpointer _tmp17_;
	DinoEntityInfo* _tmp18_;
	DinoEntitiesAccount* _tmp19_;
	DinoEntitiesAccount* _tmp20_;
	XmppJid* _tmp21_;
	XmppJid* _tmp22_;
	gboolean can_reference_element;
	gboolean _tmp23_;
	DinoEntitiesEncryption _tmp24_;
	DinoEntitiesEncryption _tmp25_;
	DinoEntitiesMessage* file_share_message;
	DinoStreamInteractor* _tmp26_;
	DinoModuleIdentity* _tmp27_;
	gpointer _tmp28_;
	DinoMessageProcessor* _tmp29_;
	DinoEntitiesMessage* _tmp30_;
	DinoEntitiesMessage* _tmp31_;
	DinoEntitiesMessage* _tmp32_;
	gint _tmp33_;
	gint _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	DinoStreamInteractor* _tmp39_;
	DinoModuleIdentity* _tmp40_;
	gpointer _tmp41_;
	DinoMessageProcessor* _tmp42_;
	DinoEntitiesMessage* _tmp43_;
	DinoHttpFileSendData* _tmp44_;
	DinoEntitiesConversationType _tmp45_;
	DinoEntitiesConversationType _tmp46_;
	DinoEntitiesMessage* _tmp47_;
	const gchar* _tmp48_;
	const gchar* _tmp49_;
	gulong server_id_notify_id;
	DinoEntitiesMessage* _tmp50_;
	gulong _tmp51_;
	DinoEntitiesMessage* _tmp52_;
	GeeList* _tmp53_;
	DinoHttpFileSendData* _tmp54_;
	const gchar* _tmp55_;
	const gchar* _tmp56_;
	gchar* _tmp57_;
	XmppXepStatelessFileSharingHttpSource* _tmp58_;
	XmppXepStatelessFileSharingHttpSource* _tmp59_;
	const gchar* _tmp60_;
	DinoEntitiesConversationType _tmp61_;
	DinoEntitiesConversationType _tmp62_;
	XmppMessageStanza* stanza;
	XmppJid* _tmp63_;
	XmppJid* _tmp64_;
	XmppJid* _tmp65_;
	gchar* _tmp66_;
	XmppMessageStanza* _tmp67_;
	XmppMessageStanza* _tmp68_;
	DinoHttpFileSendData* _tmp69_;
	const gchar* _tmp70_;
	const gchar* _tmp71_;
	XmppMessageStanza* _tmp72_;
	DinoHttpFileSendData* _tmp73_;
	const gchar* _tmp74_;
	const gchar* _tmp75_;
	GeeArrayList* sources;
	GeeArrayList* _tmp76_;
	GeeArrayList* _tmp77_;
	DinoHttpFileSendData* _tmp78_;
	const gchar* _tmp79_;
	const gchar* _tmp80_;
	gchar* _tmp81_;
	XmppXepStatelessFileSharingHttpSource* _tmp82_;
	XmppXepStatelessFileSharingHttpSource* _tmp83_;
	gchar* attach_to_id;
	DinoEntitiesMessage* _tmp84_;
	gchar* _tmp85_;
	XmppMessageStanza* _tmp86_;
	const gchar* _tmp87_;
	const gchar* _tmp88_;
	const gchar* _tmp89_;
	GeeArrayList* _tmp90_;
	XmppXmppStream* stream;
	DinoStreamInteractor* _tmp91_;
	DinoEntitiesAccount* _tmp92_;
	DinoEntitiesAccount* _tmp93_;
	XmppXmppStream* _tmp94_;
	XmppXmppStream* _tmp95_;
	GError* _tmp96_;
	XmppXmppStream* _tmp97_;
	XmppModuleIdentity* _tmp98_;
	gpointer _tmp99_;
	XmppMessageModule* _tmp100_;
	XmppXmppStream* _tmp101_;
	XmppMessageStanza* _tmp102_;
	DinoHttpFileSendData* _tmp103_;
	DinoEntitiesMessage* message;
	DinoStreamInteractor* _tmp104_;
	DinoModuleIdentity* _tmp105_;
	gpointer _tmp106_;
	DinoMessageProcessor* _tmp107_;
	DinoHttpFileSendData* _tmp108_;
	const gchar* _tmp109_;
	const gchar* _tmp110_;
	DinoEntitiesMessage* _tmp111_;
	DinoEntitiesMessage* _tmp112_;
	DinoEntitiesMessage* _tmp113_;
	gint _tmp114_;
	gint _tmp115_;
	gchar* _tmp116_;
	gchar* _tmp117_;
	DinoEntitiesEncryption _tmp118_;
	DinoHttpFileSendData* _tmp119_;
	gboolean _tmp120_;
	gboolean _tmp121_;
	DinoEntitiesEncryption _tmp122_;
	DinoEntitiesEncryption _tmp123_;
	DinoEntitiesMessage* _tmp124_;
	DinoStreamInteractor* _tmp125_;
	DinoModuleIdentity* _tmp126_;
	gpointer _tmp127_;
	DinoMessageProcessor* _tmp128_;
	DinoEntitiesMessage* _tmp129_;
	GError* _inner_error0_;
};

struct _DinoPluginsHttpFilesHttpFileSenderCanSendData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsHttpFilesHttpFileSender* self;
	DinoEntitiesConversation* conversation;
	DinoEntitiesFileTransfer* file_transfer;
	gboolean result;
	GeeHashMap* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	DinoEntitiesAccount* _tmp2_;
	gint64 _tmp3_;
	gint64 _tmp4_;
	GeeHashMap* _tmp5_;
	DinoEntitiesAccount* _tmp6_;
	DinoEntitiesAccount* _tmp7_;
	gpointer _tmp8_;
};

struct _DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsHttpFilesHttpFileSender* self;
	DinoEntitiesConversation* conversation;
	glong result;
	glong* max_size;
	GeeHashMap* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	DinoEntitiesAccount* _tmp2_;
	gpointer _tmp3_;
	glong _tmp4_;
	glong* _tmp5_;
	glong* _tmp6_;
	glong* _tmp7_;
	glong _tmp8_;
};

struct _DinoPluginsHttpFilesHttpFileSenderCanEncryptData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsHttpFilesHttpFileSender* self;
	DinoEntitiesConversation* conversation;
	DinoEntitiesFileTransfer* file_transfer;
	gboolean result;
};

struct _DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsHttpFilesHttpFileSender* self;
	DinoEntitiesConversation* conversation;
	gboolean result;
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	DinoEntitiesAccount* _tmp2_;
	DinoEntitiesAccount* _tmp3_;
	GeeHashMap* _tmp4_;
	GeeHashMap* _tmp5_;
	GError* _inner_error0_;
};

struct _Block4Data {
	int _ref_count_;
	DinoPluginsHttpFilesHttpFileSender* self;
	gchar* transfer_host;
	gpointer _async_data_;
};

struct _DinoPluginsHttpFilesHttpFileSenderUploadData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsHttpFilesHttpFileSender* self;
	DinoEntitiesFileTransfer* file_transfer;
	DinoHttpFileSendData* file_send_data;
	DinoFileMeta* file_meta;
	Block4Data* _data4_;
	XmppXmppStream* stream;
	DinoStreamInteractor* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	DinoEntitiesAccount* _tmp2_;
	XmppXmppStream* _tmp3_;
	XmppXmppStream* _tmp4_;
	SoupMessage* put_message;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	SoupMessage* _tmp7_;
	GUri* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	GUri* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	SoupMessage* _tmp14_;
	SoupMessage* _tmp15_;
	const gchar* _tmp16_;
	GInputStream* _tmp17_;
	GInputStream* _tmp18_;
	GeeIterator* _entry_it;
	GeeHashMap* _tmp19_;
	GeeHashMap* _tmp20_;
	GeeSet* _tmp21_;
	GeeSet* _tmp22_;
	GeeSet* _tmp23_;
	GeeIterator* _tmp24_;
	GeeIterator* _tmp25_;
	GeeIterator* _tmp26_;
	GeeMapEntry* entry;
	GeeIterator* _tmp27_;
	gpointer _tmp28_;
	SoupMessage* _tmp29_;
	SoupMessageHeaders* _tmp30_;
	SoupMessageHeaders* _tmp31_;
	GeeMapEntry* _tmp32_;
	gconstpointer _tmp33_;
	gconstpointer _tmp34_;
	GeeMapEntry* _tmp35_;
	gconstpointer _tmp36_;
	gconstpointer _tmp37_;
	SoupSession* _tmp38_;
	SoupMessage* _tmp39_;
	GCancellable* _tmp40_;
	GCancellable* _tmp41_;
	GInputStream* _tmp42_;
	GInputStream* _tmp43_;
	gboolean _tmp44_;
	SoupMessage* _tmp45_;
	guint _tmp46_;
	guint _tmp47_;
	SoupMessage* _tmp48_;
	guint _tmp49_;
	guint _tmp50_;
	SoupMessage* _tmp51_;
	guint _tmp52_;
	guint _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_;
	GError* _tmp58_;
	GError* _tmp59_;
	GError* e;
	GError* _tmp60_;
	const gchar* _tmp61_;
	gchar* _tmp62_;
	gchar* _tmp63_;
	GError* _tmp64_;
	GError* _tmp65_;
	GError* _inner_error0_;
};

struct _Block5Data {
	int _ref_count_;
	DinoPluginsHttpFilesHttpFileSender* self;
	DinoEntitiesAccount* account;
};

static gint DinoPluginsHttpFilesHttpFileSender_private_offset;
static gpointer dino_plugins_http_files_http_file_sender_parent_class = NULL;
static DinoFileSenderIface * dino_plugins_http_files_http_file_sender_dino_file_sender_parent_iface = NULL;

static guint _dino_entities_account_hash_func_gee_hash_data_func (gconstpointer v,
                                                           gpointer self);
static gboolean _dino_entities_account_equals_func_gee_equal_data_func (gconstpointer a,
                                                                 gconstpointer b,
                                                                 gpointer self);
static void dino_plugins_http_files_http_file_sender_on_stream_negotiated (DinoPluginsHttpFilesHttpFileSender* self,
                                                                    DinoEntitiesAccount* account,
                                                                    XmppXmppStream* stream);
static void _dino_plugins_http_files_http_file_sender_on_stream_negotiated_dino_stream_interactor_stream_negotiated (DinoStreamInteractor* _sender,
                                                                                                              DinoEntitiesAccount* account,
                                                                                                              XmppXmppStream* stream,
                                                                                                              gpointer self);
static void dino_plugins_http_files_http_file_sender_check_add_sfs_element (DinoPluginsHttpFilesHttpFileSender* self,
                                                                     DinoEntitiesMessage* message,
                                                                     XmppMessageStanza* message_stanza,
                                                                     DinoEntitiesConversation* conversation);
static void _dino_plugins_http_files_http_file_sender_check_add_sfs_element_dino_message_processor_build_message_stanza (DinoMessageProcessor* _sender,
                                                                                                                  DinoEntitiesMessage* message,
                                                                                                                  XmppMessageStanza* message_stanza,
                                                                                                                  DinoEntitiesConversation* conversation,
                                                                                                                  gpointer self);
static void dino_plugins_http_files_http_file_sender_real_prepare_send_file_data_free (gpointer _data);
static void dino_plugins_http_files_http_file_sender_real_prepare_send_file (DinoFileSender* base,
                                                                      DinoEntitiesConversation* conversation,
                                                                      DinoEntitiesFileTransfer* file_transfer,
                                                                      DinoFileMeta* file_meta,
                                                                      GAsyncReadyCallback _callback_,
                                                                      gpointer _user_data_);
static gboolean dino_plugins_http_files_http_file_sender_real_prepare_send_file_co (DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData* _data_);
static void dino_plugins_http_files_http_file_sender_prepare_send_file_ready (GObject* source_object,
                                                                       GAsyncResult* _res_,
                                                                       gpointer _user_data_);
static void dino_plugins_http_files_http_file_sender_real_send_file_data_free (gpointer _data);
static void dino_plugins_http_files_http_file_sender_real_send_file (DinoFileSender* base,
                                                              DinoEntitiesConversation* conversation,
                                                              DinoEntitiesFileTransfer* file_transfer,
                                                              DinoFileSendData* file_send_data,
                                                              DinoFileMeta* file_meta,
                                                              GAsyncReadyCallback _callback_,
                                                              gpointer _user_data_);
static gboolean dino_plugins_http_files_http_file_sender_real_send_file_co (DinoPluginsHttpFilesHttpFileSenderSendFileData* _data_);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void dino_plugins_http_files_http_file_sender_upload (DinoPluginsHttpFilesHttpFileSender* self,
                                                      DinoEntitiesFileTransfer* file_transfer,
                                                      DinoHttpFileSendData* file_send_data,
                                                      DinoFileMeta* file_meta,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_);
static void dino_plugins_http_files_http_file_sender_upload_finish (DinoPluginsHttpFilesHttpFileSender* self,
                                                             GAsyncResult* _res_,
                                                             GError** error);
static void dino_plugins_http_files_http_file_sender_send_file_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_);
static void _____lambda9_ (Block3Data* _data3_);
static gboolean _dino_plugins_http_files_http_file_sender_real_send_file_co_gsource_func (gpointer self);
static void ______lambda9__g_object_notify (GObject* _sender,
                                     GParamSpec* pspec,
                                     gpointer self);
static void dino_plugins_http_files_http_file_sender_real_can_send_data_free (gpointer _data);
static void dino_plugins_http_files_http_file_sender_real_can_send (DinoFileSender* base,
                                                             DinoEntitiesConversation* conversation,
                                                             DinoEntitiesFileTransfer* file_transfer,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static gboolean dino_plugins_http_files_http_file_sender_real_can_send_co (DinoPluginsHttpFilesHttpFileSenderCanSendData* _data_);
static void dino_plugins_http_files_http_file_sender_real_get_file_size_limit_data_free (gpointer _data);
static void dino_plugins_http_files_http_file_sender_real_get_file_size_limit (DinoFileSender* base,
                                                                        DinoEntitiesConversation* conversation,
                                                                        GAsyncReadyCallback _callback_,
                                                                        gpointer _user_data_);
static gboolean dino_plugins_http_files_http_file_sender_real_get_file_size_limit_co (DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData* _data_);
static glong* _long_dup (glong* self);
static void dino_plugins_http_files_http_file_sender_real_can_encrypt_data_free (gpointer _data);
static void dino_plugins_http_files_http_file_sender_real_can_encrypt (DinoFileSender* base,
                                                                DinoEntitiesConversation* conversation,
                                                                DinoEntitiesFileTransfer* file_transfer,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
static gboolean dino_plugins_http_files_http_file_sender_real_can_encrypt_co (DinoPluginsHttpFilesHttpFileSenderCanEncryptData* _data_);
static void dino_plugins_http_files_http_file_sender_real_is_upload_available_data_free (gpointer _data);
static void dino_plugins_http_files_http_file_sender_real_is_upload_available (DinoFileSender* base,
                                                                        DinoEntitiesConversation* conversation,
                                                                        GAsyncReadyCallback _callback_,
                                                                        gpointer _user_data_);
static gboolean dino_plugins_http_files_http_file_sender_real_is_upload_available_co (DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData* _data_);
static void dino_plugins_http_files_http_file_sender_upload_data_free (gpointer _data);
static gboolean dino_plugins_http_files_http_file_sender_upload_co (DinoPluginsHttpFilesHttpFileSenderUploadData* _data_);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static gboolean __lambda8_ (Block4Data* _data4_,
                     GTlsCertificate* peer_cert,
                     GTlsCertificateFlags errors);
static gboolean ___lambda8__soup_message_accept_certificate (SoupMessage* _sender,
                                                      GTlsCertificate* tls_peer_certificate,
                                                      GTlsCertificateFlags tls_peer_errors,
                                                      gpointer self);
static void dino_plugins_http_files_http_file_sender_upload_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static void __lambda7_ (Block5Data* _data5_,
                 XmppXmppStream* stream,
                 glong max_file_size);
static void ___lambda7__xmpp_xep_http_file_upload_module_feature_available (XmppXepHttpFileUploadModule* _sender,
                                                                     XmppXmppStream* stream,
                                                                     glong max_file_size,
                                                                     gpointer self);
static gint dino_plugins_http_files_http_file_sender_real_get_id (DinoFileSender* base);
static gfloat dino_plugins_http_files_http_file_sender_real_get_priority (DinoFileSender* base);
static void dino_plugins_http_files_http_file_sender_finalize (GObject * obj);
static GType dino_plugins_http_files_http_file_sender_get_type_once (void);

static inline gpointer
dino_plugins_http_files_http_file_sender_get_instance_private (DinoPluginsHttpFilesHttpFileSender* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsHttpFilesHttpFileSender_private_offset);
}

static guint
_dino_entities_account_hash_func_gee_hash_data_func (gconstpointer v,
                                                     gpointer self)
{
	guint result;
	result = dino_entities_account_hash_func ((DinoEntitiesAccount*) v);
	return result;
}

static gboolean
_dino_entities_account_equals_func_gee_equal_data_func (gconstpointer a,
                                                        gconstpointer b,
                                                        gpointer self)
{
	gboolean result;
	result = dino_entities_account_equals_func ((DinoEntitiesAccount*) a, (DinoEntitiesAccount*) b);
	return result;
}

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 const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static void
_dino_plugins_http_files_http_file_sender_on_stream_negotiated_dino_stream_interactor_stream_negotiated (DinoStreamInteractor* _sender,
                                                                                                         DinoEntitiesAccount* account,
                                                                                                         XmppXmppStream* stream,
                                                                                                         gpointer self)
{
	dino_plugins_http_files_http_file_sender_on_stream_negotiated ((DinoPluginsHttpFilesHttpFileSender*) self, account, stream);
}

static void
_dino_plugins_http_files_http_file_sender_check_add_sfs_element_dino_message_processor_build_message_stanza (DinoMessageProcessor* _sender,
                                                                                                             DinoEntitiesMessage* message,
                                                                                                             XmppMessageStanza* message_stanza,
                                                                                                             DinoEntitiesConversation* conversation,
                                                                                                             gpointer self)
{
	dino_plugins_http_files_http_file_sender_check_add_sfs_element ((DinoPluginsHttpFilesHttpFileSender*) self, message, message_stanza, conversation);
}

DinoPluginsHttpFilesHttpFileSender*
dino_plugins_http_files_http_file_sender_construct (GType object_type,
                                                    DinoStreamInteractor* stream_interactor,
                                                    DinoDatabase* db)
{
	DinoPluginsHttpFilesHttpFileSender * self = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoDatabase* _tmp1_;
	SoupSession* _tmp2_;
	SoupSession* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	DinoModuleIdentity* _tmp9_;
	gpointer _tmp10_;
	DinoMessageProcessor* _tmp11_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoPluginsHttpFilesHttpFileSender*) 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_ = soup_session_new ();
	_g_object_unref0 (self->priv->session);
	self->priv->session = _tmp2_;
	_tmp3_ = self->priv->session;
	_tmp4_ = dino_get_short_version ();
	_tmp5_ = _tmp4_;
	_tmp6_ = string_to_string (_tmp5_);
	_tmp7_ = g_strconcat ("Dino/", _tmp6_, " ", NULL);
	_tmp8_ = _tmp7_;
	soup_session_set_user_agent (_tmp3_, _tmp8_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp5_);
	g_signal_connect_object (stream_interactor, "stream-negotiated", (GCallback) _dino_plugins_http_files_http_file_sender_on_stream_negotiated_dino_stream_interactor_stream_negotiated, self, 0);
	_tmp9_ = dino_message_processor_IDENTITY;
	_tmp10_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp9_);
	_tmp11_ = (DinoMessageProcessor*) _tmp10_;
	g_signal_connect_object (_tmp11_, "build-message-stanza", (GCallback) _dino_plugins_http_files_http_file_sender_check_add_sfs_element_dino_message_processor_build_message_stanza, self, 0);
	_g_object_unref0 (_tmp11_);
	return self;
}

DinoPluginsHttpFilesHttpFileSender*
dino_plugins_http_files_http_file_sender_new (DinoStreamInteractor* stream_interactor,
                                              DinoDatabase* db)
{
	return dino_plugins_http_files_http_file_sender_construct (DINO_PLUGINS_HTTP_FILES_TYPE_HTTP_FILE_SENDER, stream_interactor, db);
}

static void
dino_plugins_http_files_http_file_sender_real_prepare_send_file_data_free (gpointer _data)
{
	DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->file_transfer);
	_dino_file_meta_unref0 (_data_->file_meta);
	_dino_file_send_data_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData, _data_);
}

static gpointer
_dino_file_meta_ref0 (gpointer self)
{
	return self ? dino_file_meta_ref (self) : NULL;
}

static void
dino_plugins_http_files_http_file_sender_real_prepare_send_file (DinoFileSender* base,
                                                                 DinoEntitiesConversation* conversation,
                                                                 DinoEntitiesFileTransfer* file_transfer,
                                                                 DinoFileMeta* file_meta,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData* _data_;
	DinoPluginsHttpFilesHttpFileSender* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	DinoEntitiesFileTransfer* _tmp2_;
	DinoFileMeta* _tmp3_;
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (file_transfer != NULL);
	g_return_if_fail (file_meta != NULL);
	self = (DinoPluginsHttpFilesHttpFileSender*) base;
	_data_ = g_slice_new0 (DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_http_files_http_file_sender_real_prepare_send_file_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 (file_transfer);
	_g_object_unref0 (_data_->file_transfer);
	_data_->file_transfer = _tmp2_;
	_tmp3_ = _dino_file_meta_ref0 (file_meta);
	_dino_file_meta_unref0 (_data_->file_meta);
	_data_->file_meta = _tmp3_;
	dino_plugins_http_files_http_file_sender_real_prepare_send_file_co (_data_);
}

static DinoFileSendData*
dino_plugins_http_files_http_file_sender_prepare_send_file_finish (DinoFileSender* base,
                                                                   GAsyncResult* _res_,
                                                                   GError** error)
{
	DinoFileSendData* result;
	DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
dino_plugins_http_files_http_file_sender_prepare_send_file_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_http_files_http_file_sender_real_prepare_send_file_co (_data_);
}

static gboolean
dino_plugins_http_files_http_file_sender_real_prepare_send_file_co (DinoPluginsHttpFilesHttpFileSenderPrepareSendFileData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = dino_http_file_send_data_new ();
	_data_->send_data = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->send_data;
	if (_data_->_tmp1_ == NULL) {
		_data_->result = NULL;
		_dino_file_send_data_unref0 (_data_->send_data);
		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_->_tmp2_ = _data_->self->priv->stream_interactor;
	_data_->_tmp3_ = dino_entities_file_transfer_get_account (_data_->file_transfer);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = dino_stream_interactor_get_stream (_data_->_tmp2_, _data_->_tmp4_);
	_data_->stream = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->stream;
	if (_data_->_tmp6_ == NULL) {
		_data_->result = NULL;
		_g_object_unref0 (_data_->stream);
		_dino_file_send_data_unref0 (_data_->send_data);
		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_->_tmp7_ = _data_->self->priv->stream_interactor;
		_data_->_tmp8_ = _data_->_tmp7_->module_manager;
		_data_->_tmp9_ = dino_entities_file_transfer_get_account (_data_->file_transfer);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = xmpp_xep_http_file_upload_module_IDENTITY;
		_data_->_tmp12_ = dino_module_manager_get_module (_data_->_tmp8_, XMPP_XEP_HTTP_FILE_UPLOAD_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp10_, _data_->_tmp11_);
		_data_->_tmp13_ = (XmppXepHttpFileUploadModule*) _data_->_tmp12_;
		_data_->_tmp14_ = _data_->stream;
		_data_->_tmp15_ = dino_entities_file_transfer_get_server_file_name (_data_->file_transfer);
		_data_->_tmp16_ = _data_->_tmp15_;
		_data_->_tmp17_ = _data_->file_meta->mime_type;
		memset (&_data_->_tmp18_, 0, sizeof (XmppXepHttpFileUploadModuleSlotResult));
		_data_->_state_ = 1;
		xmpp_xep_http_file_upload_module_request_slot (_data_->_tmp13_, _data_->_tmp14_, _data_->_tmp16_, _data_->file_meta->size, _data_->_tmp17_, dino_plugins_http_files_http_file_sender_prepare_send_file_ready, _data_);
		return FALSE;
		_state_1:
		xmpp_xep_http_file_upload_module_request_slot_finish (_data_->_tmp13_, _data_->_res_, &_data_->_tmp18_, &_data_->_inner_error0_);
		_data_->_tmp19_ = _data_->_tmp18_;
		_g_object_unref0 (_data_->_tmp13_);
		_data_->slot_result = _data_->_tmp19_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == XMPP_XEP_HTTP_FILE_UPLOAD_HTTP_FILE_TRANSFER_ERROR) {
				goto __catch0_xmpp_xep_http_file_upload_http_file_transfer_error;
			}
			_g_object_unref0 (_data_->stream);
			_dino_file_send_data_unref0 (_data_->send_data);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp20_ = _data_->send_data;
		_data_->_tmp21_ = _data_->slot_result;
		_data_->_tmp22_ = xmpp_xep_http_file_upload_module_slot_result_get_url_get (&_data_->_tmp21_);
		_data_->_tmp23_ = _data_->_tmp22_;
		dino_http_file_send_data_set_url_down (_data_->_tmp20_, _data_->_tmp23_);
		_data_->_tmp24_ = _data_->send_data;
		_data_->_tmp25_ = _data_->slot_result;
		_data_->_tmp26_ = xmpp_xep_http_file_upload_module_slot_result_get_url_put (&_data_->_tmp25_);
		_data_->_tmp27_ = _data_->_tmp26_;
		dino_http_file_send_data_set_url_up (_data_->_tmp24_, _data_->_tmp27_);
		_data_->_tmp28_ = _data_->send_data;
		_data_->_tmp29_ = _data_->slot_result;
		_data_->_tmp30_ = xmpp_xep_http_file_upload_module_slot_result_get_headers (&_data_->_tmp29_);
		_data_->_tmp31_ = _data_->_tmp30_;
		dino_http_file_send_data_set_headers (_data_->_tmp28_, _data_->_tmp31_);
		xmpp_xep_http_file_upload_module_slot_result_destroy (&_data_->slot_result);
	}
	goto __finally0;
	__catch0_xmpp_xep_http_file_upload_http_file_transfer_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp32_ = _data_->e;
		_data_->_tmp33_ = _data_->_tmp32_->message;
		_data_->_tmp34_ = g_strdup_printf ("Http file upload XMPP error: %s", _data_->_tmp33_);
		_data_->_tmp35_ = _data_->_tmp34_;
		_data_->_tmp36_ = g_error_new_literal (DINO_FILE_SEND_ERROR, DINO_FILE_SEND_ERROR_UPLOAD_FAILED, _data_->_tmp35_);
		_data_->_tmp37_ = _data_->_tmp36_;
		_g_free0 (_data_->_tmp35_);
		_data_->_inner_error0_ = _data_->_tmp37_;
		_g_error_free0 (_data_->e);
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		if (_data_->_inner_error0_->domain == DINO_FILE_SEND_ERROR) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->stream);
			_dino_file_send_data_unref0 (_data_->send_data);
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->stream);
			_dino_file_send_data_unref0 (_data_->send_data);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->result = (DinoFileSendData*) _data_->send_data;
	_g_object_unref0 (_data_->stream);
	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 void
dino_plugins_http_files_http_file_sender_real_send_file_data_free (gpointer _data)
{
	DinoPluginsHttpFilesHttpFileSenderSendFileData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->file_transfer);
	_dino_file_send_data_unref0 (_data_->file_send_data);
	_dino_file_meta_unref0 (_data_->file_meta);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsHttpFilesHttpFileSenderSendFileData, _data_);
}

static gpointer
_dino_file_send_data_ref0 (gpointer self)
{
	return self ? dino_file_send_data_ref (self) : NULL;
}

static void
dino_plugins_http_files_http_file_sender_real_send_file (DinoFileSender* base,
                                                         DinoEntitiesConversation* conversation,
                                                         DinoEntitiesFileTransfer* file_transfer,
                                                         DinoFileSendData* file_send_data,
                                                         DinoFileMeta* file_meta,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	DinoPluginsHttpFilesHttpFileSenderSendFileData* _data_;
	DinoPluginsHttpFilesHttpFileSender* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	DinoEntitiesFileTransfer* _tmp2_;
	DinoFileSendData* _tmp3_;
	DinoFileMeta* _tmp4_;
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (file_transfer != NULL);
	g_return_if_fail (file_send_data != NULL);
	g_return_if_fail (file_meta != NULL);
	self = (DinoPluginsHttpFilesHttpFileSender*) base;
	_data_ = g_slice_new0 (DinoPluginsHttpFilesHttpFileSenderSendFileData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_http_files_http_file_sender_real_send_file_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 (file_transfer);
	_g_object_unref0 (_data_->file_transfer);
	_data_->file_transfer = _tmp2_;
	_tmp3_ = _dino_file_send_data_ref0 (file_send_data);
	_dino_file_send_data_unref0 (_data_->file_send_data);
	_data_->file_send_data = _tmp3_;
	_tmp4_ = _dino_file_meta_ref0 (file_meta);
	_dino_file_meta_unref0 (_data_->file_meta);
	_data_->file_meta = _tmp4_;
	dino_plugins_http_files_http_file_sender_real_send_file_co (_data_);
}

static void
dino_plugins_http_files_http_file_sender_send_file_finish (DinoFileSender* base,
                                                           GAsyncResult* _res_,
                                                           GError** error)
{
	DinoPluginsHttpFilesHttpFileSenderSendFileData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		DinoPluginsHttpFilesHttpFileSender* self;
		self = _data3_->self;
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static void
dino_plugins_http_files_http_file_sender_send_file_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSenderSendFileData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_http_files_http_file_sender_real_send_file_co (_data_);
}

static gboolean
_dino_plugins_http_files_http_file_sender_real_send_file_co_gsource_func (gpointer self)
{
	gboolean result;
	result = dino_plugins_http_files_http_file_sender_real_send_file_co (self);
	return result;
}

static void
_____lambda9_ (Block3Data* _data3_)
{
	DinoPluginsHttpFilesHttpFileSender* self;
	self = _data3_->self;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _dino_plugins_http_files_http_file_sender_real_send_file_co_gsource_func, _data3_->_async_data_, NULL);
}

static void
______lambda9__g_object_notify (GObject* _sender,
                                GParamSpec* pspec,
                                gpointer self)
{
	_____lambda9_ (self);
}

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

static gboolean
dino_plugins_http_files_http_file_sender_real_send_file_co (DinoPluginsHttpFilesHttpFileSenderSendFileData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data3_ = g_slice_new0 (Block3Data);
	_data_->_data3_->_ref_count_ = 1;
	_data_->_data3_->self = g_object_ref (_data_->self);
	_data_->_data3_->_async_data_ = _data_;
	_data_->_tmp0_ = _dino_file_send_data_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->file_send_data, DINO_TYPE_HTTP_FILE_SEND_DATA) ? ((DinoHttpFileSendData*) _data_->file_send_data) : NULL);
	_data_->send_data = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->send_data;
	if (_data_->_tmp1_ == NULL) {
		_dino_file_send_data_unref0 (_data_->send_data);
		block3_data_unref (_data_->_data3_);
		_data_->_data3_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = dino_entities_conversation_get_type_ (_data_->conversation);
	_data_->_tmp4_ = _data_->_tmp3_;
	if (_data_->_tmp4_ == DINO_ENTITIES_CONVERSATION_TYPE_CHAT) {
		_data_->_tmp2_ = TRUE;
	} else {
		_data_->_tmp6_ = _data_->self->priv->stream_interactor;
		_data_->_tmp7_ = dino_entity_info_IDENTITY;
		_data_->_tmp8_ = dino_stream_interactor_get_module (_data_->_tmp6_, DINO_TYPE_ENTITY_INFO, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp7_);
		_data_->_tmp9_ = (DinoEntityInfo*) _data_->_tmp8_;
		_data_->_tmp10_ = dino_entities_conversation_get_account (_data_->conversation);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = dino_entity_info_has_feature_cached (_data_->_tmp9_, _data_->_tmp11_, _data_->_tmp13_, XMPP_XEP_UNIQUE_STABLE_STANZA_IDS_NS_URI);
		_g_object_unref0 (_data_->_tmp9_);
		if (_data_->_tmp14_) {
			_data_->_tmp15_ = _data_->self->priv->stream_interactor;
			_data_->_tmp16_ = dino_entity_info_IDENTITY;
			_data_->_tmp17_ = dino_stream_interactor_get_module (_data_->_tmp15_, DINO_TYPE_ENTITY_INFO, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp16_);
			_data_->_tmp18_ = (DinoEntityInfo*) _data_->_tmp17_;
			_data_->_tmp19_ = dino_entities_conversation_get_account (_data_->conversation);
			_data_->_tmp20_ = _data_->_tmp19_;
			_data_->_tmp21_ = dino_entities_conversation_get_counterpart (_data_->conversation);
			_data_->_tmp22_ = _data_->_tmp21_;
			_data_->_tmp5_ = dino_entity_info_has_feature_cached (_data_->_tmp18_, _data_->_tmp20_, _data_->_tmp22_, XMPP_MESSAGE_ARCHIVE_MANAGEMENT_NS_URI);
			_g_object_unref0 (_data_->_tmp18_);
		} else {
			_data_->_tmp5_ = FALSE;
		}
		_data_->_tmp2_ = _data_->_tmp5_;
	}
	_data_->can_reference_element = _data_->_tmp2_;
	_data_->_tmp24_ = dino_entities_conversation_get_encryption (_data_->conversation);
	_data_->_tmp25_ = _data_->_tmp24_;
	if (_data_->_tmp25_ == DINO_ENTITIES_ENCRYPTION_NONE) {
		_data_->_tmp23_ = _data_->can_reference_element;
	} else {
		_data_->_tmp23_ = FALSE;
	}
	if (_data_->_tmp23_) {
		_data_->_tmp26_ = _data_->self->priv->stream_interactor;
		_data_->_tmp27_ = dino_message_processor_IDENTITY;
		_data_->_tmp28_ = dino_stream_interactor_get_module (_data_->_tmp26_, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp27_);
		_data_->_tmp29_ = (DinoMessageProcessor*) _data_->_tmp28_;
		_data_->_tmp30_ = dino_message_processor_create_out_message (_data_->_tmp29_, NULL, _data_->conversation);
		_data_->_tmp31_ = _data_->_tmp30_;
		_g_object_unref0 (_data_->_tmp29_);
		_data_->file_share_message = _data_->_tmp31_;
		_data_->_tmp32_ = _data_->file_share_message;
		_data_->_tmp33_ = dino_entities_message_get_id (_data_->_tmp32_);
		_data_->_tmp34_ = _data_->_tmp33_;
		_data_->_tmp35_ = g_strdup_printf ("%i", _data_->_tmp34_);
		_data_->_tmp36_ = _data_->_tmp35_;
		dino_entities_file_transfer_set_info (_data_->file_transfer, _data_->_tmp36_);
		_g_free0 (_data_->_tmp36_);
		_data_->_tmp37_ = xmpp_random_uuid ();
		_data_->_tmp38_ = _data_->_tmp37_;
		dino_entities_file_transfer_set_file_sharing_id (_data_->file_transfer, _data_->_tmp38_);
		_g_free0 (_data_->_tmp38_);
		_data_->_tmp39_ = _data_->self->priv->stream_interactor;
		_data_->_tmp40_ = dino_message_processor_IDENTITY;
		_data_->_tmp41_ = dino_stream_interactor_get_module (_data_->_tmp39_, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp40_);
		_data_->_tmp42_ = (DinoMessageProcessor*) _data_->_tmp41_;
		_data_->_tmp43_ = _data_->file_share_message;
		dino_message_processor_send_xmpp_message (_data_->_tmp42_, _data_->_tmp43_, _data_->conversation, FALSE);
		_g_object_unref0 (_data_->_tmp42_);
		_data_->_tmp44_ = _data_->send_data;
		_data_->_state_ = 1;
		dino_plugins_http_files_http_file_sender_upload (_data_->self, _data_->file_transfer, _data_->_tmp44_, _data_->file_meta, dino_plugins_http_files_http_file_sender_send_file_ready, _data_);
		return FALSE;
		_state_1:
		dino_plugins_http_files_http_file_sender_upload_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == DINO_FILE_SEND_ERROR) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->file_share_message);
				_dino_file_send_data_unref0 (_data_->send_data);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				g_object_unref (_data_->_async_result);
				return FALSE;
			} else {
				_g_object_unref0 (_data_->file_share_message);
				_dino_file_send_data_unref0 (_data_->send_data);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
				g_clear_error (&_data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
		_data_->_tmp45_ = dino_entities_conversation_get_type_ (_data_->conversation);
		_data_->_tmp46_ = _data_->_tmp45_;
		if (dino_entities_conversation_type_is_muc_semantic (_data_->_tmp46_)) {
			_data_->_tmp47_ = _data_->file_share_message;
			_data_->_tmp48_ = dino_entities_message_get_server_id (_data_->_tmp47_);
			_data_->_tmp49_ = _data_->_tmp48_;
			if (_data_->_tmp49_ == NULL) {
				_data_->_tmp50_ = _data_->file_share_message;
				_data_->_tmp51_ = g_signal_connect_data ((GObject*) _data_->_tmp50_, "notify::server-id", (GCallback) ______lambda9__g_object_notify, block3_data_ref (_data_->_data3_), (GClosureNotify) block3_data_unref, 0);
				_data_->server_id_notify_id = _data_->_tmp51_;
				_data_->_state_ = 2;
				return FALSE;
				_state_2:
				;
				_data_->_tmp52_ = _data_->file_share_message;
				g_signal_handler_disconnect ((GObject*) _data_->_tmp52_, _data_->server_id_notify_id);
			}
		}
		_data_->_tmp53_ = _data_->file_transfer->sfs_sources;
		_data_->_tmp54_ = _data_->send_data;
		_data_->_tmp55_ = dino_http_file_send_data_get_url_down (_data_->_tmp54_);
		_data_->_tmp56_ = _data_->_tmp55_;
		_data_->_tmp57_ = g_strdup (_data_->_tmp56_);
		_data_->_tmp58_ = NULL;
		_data_->_tmp58_ = xmpp_xep_stateless_file_sharing_http_source_new ();
		xmpp_xep_stateless_file_sharing_http_source_set_url (_data_->_tmp58_, _data_->_tmp57_);
		_g_free0 (_data_->_tmp57_);
		_data_->_tmp59_ = _data_->_tmp58_;
		gee_collection_add ((GeeCollection*) _data_->_tmp53_, (XmppXepStatelessFileSharingSource*) _data_->_tmp59_);
		_g_object_unref0 (_data_->_tmp59_);
		_data_->_tmp61_ = dino_entities_conversation_get_type_ (_data_->conversation);
		_data_->_tmp62_ = _data_->_tmp61_;
		if (_data_->_tmp62_ == DINO_ENTITIES_CONVERSATION_TYPE_GROUPCHAT) {
			_data_->_tmp60_ = XMPP_MESSAGE_STANZA_TYPE_GROUPCHAT;
		} else {
			_data_->_tmp60_ = XMPP_MESSAGE_STANZA_TYPE_CHAT;
		}
		_data_->_tmp63_ = dino_entities_conversation_get_counterpart (_data_->conversation);
		_data_->_tmp64_ = _data_->_tmp63_;
		_data_->_tmp65_ = _xmpp_jid_ref0 (_data_->_tmp64_);
		_data_->_tmp66_ = g_strdup (_data_->_tmp60_);
		_data_->_tmp67_ = NULL;
		_data_->_tmp67_ = xmpp_message_stanza_new (NULL);
		xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp67_, _data_->_tmp65_);
		_xmpp_jid_unref0 (_data_->_tmp65_);
		xmpp_stanza_set_type_ ((XmppStanza*) _data_->_tmp67_, _data_->_tmp66_);
		_g_free0 (_data_->_tmp66_);
		_data_->stanza = _data_->_tmp67_;
		_data_->_tmp68_ = _data_->stanza;
		_data_->_tmp69_ = _data_->send_data;
		_data_->_tmp70_ = dino_http_file_send_data_get_url_down (_data_->_tmp69_);
		_data_->_tmp71_ = _data_->_tmp70_;
		xmpp_message_stanza_set_body (_data_->_tmp68_, _data_->_tmp71_);
		_data_->_tmp72_ = _data_->stanza;
		_data_->_tmp73_ = _data_->send_data;
		_data_->_tmp74_ = dino_http_file_send_data_get_url_down (_data_->_tmp73_);
		_data_->_tmp75_ = _data_->_tmp74_;
		xmpp_xep_out_of_band_data_add_url_to_message (_data_->_tmp72_, _data_->_tmp75_, NULL);
		_data_->_tmp76_ = gee_array_list_new (XMPP_XEP_STATELESS_FILE_SHARING_TYPE_SOURCE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_data_->sources = _data_->_tmp76_;
		_data_->_tmp77_ = _data_->sources;
		_data_->_tmp78_ = _data_->send_data;
		_data_->_tmp79_ = dino_http_file_send_data_get_url_down (_data_->_tmp78_);
		_data_->_tmp80_ = _data_->_tmp79_;
		_data_->_tmp81_ = g_strdup (_data_->_tmp80_);
		_data_->_tmp82_ = NULL;
		_data_->_tmp82_ = xmpp_xep_stateless_file_sharing_http_source_new ();
		xmpp_xep_stateless_file_sharing_http_source_set_url (_data_->_tmp82_, _data_->_tmp81_);
		_g_free0 (_data_->_tmp81_);
		_data_->_tmp83_ = _data_->_tmp82_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp77_, (XmppXepStatelessFileSharingSource*) _data_->_tmp83_);
		_g_object_unref0 (_data_->_tmp83_);
		_data_->_tmp84_ = _data_->file_share_message;
		_data_->_tmp85_ = dino_message_storage_get_reference_id (_data_->_tmp84_);
		_data_->attach_to_id = _data_->_tmp85_;
		_data_->_tmp86_ = _data_->stanza;
		_data_->_tmp87_ = _data_->attach_to_id;
		_data_->_tmp88_ = dino_entities_file_transfer_get_file_sharing_id (_data_->file_transfer);
		_data_->_tmp89_ = _data_->_tmp88_;
		_data_->_tmp90_ = _data_->sources;
		xmpp_xep_stateless_file_sharing_set_sfs_attachment (_data_->_tmp86_, _data_->_tmp87_, _data_->_tmp89_, (GeeList*) _data_->_tmp90_);
		_data_->_tmp91_ = _data_->self->priv->stream_interactor;
		_data_->_tmp92_ = dino_entities_conversation_get_account (_data_->conversation);
		_data_->_tmp93_ = _data_->_tmp92_;
		_data_->_tmp94_ = dino_stream_interactor_get_stream (_data_->_tmp91_, _data_->_tmp93_);
		_data_->stream = _data_->_tmp94_;
		_data_->_tmp95_ = _data_->stream;
		if (_data_->_tmp95_ == NULL) {
			_data_->_tmp96_ = g_error_new_literal (DINO_FILE_SEND_ERROR, DINO_FILE_SEND_ERROR_UPLOAD_FAILED, "No stream");
			_data_->_inner_error0_ = _data_->_tmp96_;
			if (_data_->_inner_error0_->domain == DINO_FILE_SEND_ERROR) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->stream);
				_g_free0 (_data_->attach_to_id);
				_g_object_unref0 (_data_->sources);
				_g_object_unref0 (_data_->stanza);
				_g_object_unref0 (_data_->file_share_message);
				_dino_file_send_data_unref0 (_data_->send_data);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				g_object_unref (_data_->_async_result);
				return FALSE;
			} else {
				_g_object_unref0 (_data_->stream);
				_g_free0 (_data_->attach_to_id);
				_g_object_unref0 (_data_->sources);
				_g_object_unref0 (_data_->stanza);
				_g_object_unref0 (_data_->file_share_message);
				_dino_file_send_data_unref0 (_data_->send_data);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
				g_clear_error (&_data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
		_data_->_tmp97_ = _data_->stream;
		_data_->_tmp98_ = xmpp_message_module_IDENTITY;
		_data_->_tmp99_ = xmpp_xmpp_stream_get_module (_data_->_tmp97_, XMPP_TYPE_MESSAGE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp98_);
		_data_->_tmp100_ = (XmppMessageModule*) _data_->_tmp99_;
		_data_->_tmp101_ = _data_->stream;
		_data_->_tmp102_ = _data_->stanza;
		xmpp_message_module_send_message (_data_->_tmp100_, _data_->_tmp101_, _data_->_tmp102_, NULL, NULL);
		_g_object_unref0 (_data_->_tmp100_);
		_g_object_unref0 (_data_->stream);
		_g_free0 (_data_->attach_to_id);
		_g_object_unref0 (_data_->sources);
		_g_object_unref0 (_data_->stanza);
		_g_object_unref0 (_data_->file_share_message);
	} else {
		_data_->_tmp103_ = _data_->send_data;
		_data_->_state_ = 3;
		dino_plugins_http_files_http_file_sender_upload (_data_->self, _data_->file_transfer, _data_->_tmp103_, _data_->file_meta, dino_plugins_http_files_http_file_sender_send_file_ready, _data_);
		return FALSE;
		_state_3:
		dino_plugins_http_files_http_file_sender_upload_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == DINO_FILE_SEND_ERROR) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_dino_file_send_data_unref0 (_data_->send_data);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				g_object_unref (_data_->_async_result);
				return FALSE;
			} else {
				_dino_file_send_data_unref0 (_data_->send_data);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
				g_clear_error (&_data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
		_data_->_tmp104_ = _data_->self->priv->stream_interactor;
		_data_->_tmp105_ = dino_message_processor_IDENTITY;
		_data_->_tmp106_ = dino_stream_interactor_get_module (_data_->_tmp104_, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp105_);
		_data_->_tmp107_ = (DinoMessageProcessor*) _data_->_tmp106_;
		_data_->_tmp108_ = _data_->send_data;
		_data_->_tmp109_ = dino_http_file_send_data_get_url_down (_data_->_tmp108_);
		_data_->_tmp110_ = _data_->_tmp109_;
		_data_->_tmp111_ = dino_message_processor_create_out_message (_data_->_tmp107_, _data_->_tmp110_, _data_->conversation);
		_data_->_tmp112_ = _data_->_tmp111_;
		_g_object_unref0 (_data_->_tmp107_);
		_data_->message = _data_->_tmp112_;
		_data_->_tmp113_ = _data_->message;
		_data_->_tmp114_ = dino_entities_message_get_id (_data_->_tmp113_);
		_data_->_tmp115_ = _data_->_tmp114_;
		_data_->_tmp116_ = g_strdup_printf ("%i", _data_->_tmp115_);
		_data_->_tmp117_ = _data_->_tmp116_;
		dino_entities_file_transfer_set_info (_data_->file_transfer, _data_->_tmp117_);
		_g_free0 (_data_->_tmp117_);
		_data_->_tmp119_ = _data_->send_data;
		_data_->_tmp120_ = dino_http_file_send_data_get_encrypt_message (_data_->_tmp119_);
		_data_->_tmp121_ = _data_->_tmp120_;
		if (_data_->_tmp121_) {
			_data_->_tmp122_ = dino_entities_conversation_get_encryption (_data_->conversation);
			_data_->_tmp123_ = _data_->_tmp122_;
			_data_->_tmp118_ = _data_->_tmp123_;
		} else {
			_data_->_tmp118_ = DINO_ENTITIES_ENCRYPTION_NONE;
		}
		_data_->_tmp124_ = _data_->message;
		dino_entities_message_set_encryption (_data_->_tmp124_, _data_->_tmp118_);
		_data_->_tmp125_ = _data_->self->priv->stream_interactor;
		_data_->_tmp126_ = dino_message_processor_IDENTITY;
		_data_->_tmp127_ = dino_stream_interactor_get_module (_data_->_tmp125_, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp126_);
		_data_->_tmp128_ = (DinoMessageProcessor*) _data_->_tmp127_;
		_data_->_tmp129_ = _data_->message;
		dino_message_processor_send_xmpp_message (_data_->_tmp128_, _data_->_tmp129_, _data_->conversation, FALSE);
		_g_object_unref0 (_data_->_tmp128_);
		_g_object_unref0 (_data_->message);
	}
	_dino_file_send_data_unref0 (_data_->send_data);
	block3_data_unref (_data_->_data3_);
	_data_->_data3_ = NULL;
	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 void
dino_plugins_http_files_http_file_sender_real_can_send_data_free (gpointer _data)
{
	DinoPluginsHttpFilesHttpFileSenderCanSendData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->file_transfer);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsHttpFilesHttpFileSenderCanSendData, _data_);
}

static void
dino_plugins_http_files_http_file_sender_real_can_send (DinoFileSender* base,
                                                        DinoEntitiesConversation* conversation,
                                                        DinoEntitiesFileTransfer* file_transfer,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	DinoPluginsHttpFilesHttpFileSenderCanSendData* _data_;
	DinoPluginsHttpFilesHttpFileSender* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	DinoEntitiesFileTransfer* _tmp2_;
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (file_transfer != NULL);
	self = (DinoPluginsHttpFilesHttpFileSender*) base;
	_data_ = g_slice_new0 (DinoPluginsHttpFilesHttpFileSenderCanSendData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_http_files_http_file_sender_real_can_send_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 (file_transfer);
	_g_object_unref0 (_data_->file_transfer);
	_data_->file_transfer = _tmp2_;
	dino_plugins_http_files_http_file_sender_real_can_send_co (_data_);
}

static gboolean
dino_plugins_http_files_http_file_sender_can_send_finish (DinoFileSender* base,
                                                          GAsyncResult* _res_)
{
	gboolean result;
	DinoPluginsHttpFilesHttpFileSenderCanSendData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static gboolean
dino_plugins_http_files_http_file_sender_real_can_send_co (DinoPluginsHttpFilesHttpFileSenderCanSendData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->max_file_sizes;
	_data_->_tmp1_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp2_ = _data_->_tmp1_;
	if (!gee_abstract_map_has_key ((GeeAbstractMap*) _data_->_tmp0_, _data_->_tmp2_)) {
		_data_->result = FALSE;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = dino_entities_file_transfer_get_size (_data_->file_transfer);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = _data_->self->priv->max_file_sizes;
	_data_->_tmp6_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp5_, _data_->_tmp7_);
	_data_->result = _data_->_tmp4_ < ((gint64) ((glong) ((gintptr) _data_->_tmp8_)));
	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 void
dino_plugins_http_files_http_file_sender_real_get_file_size_limit_data_free (gpointer _data)
{
	DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData, _data_);
}

static void
dino_plugins_http_files_http_file_sender_real_get_file_size_limit (DinoFileSender* base,
                                                                   DinoEntitiesConversation* conversation,
                                                                   GAsyncReadyCallback _callback_,
                                                                   gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData* _data_;
	DinoPluginsHttpFilesHttpFileSender* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	g_return_if_fail (conversation != NULL);
	self = (DinoPluginsHttpFilesHttpFileSender*) base;
	_data_ = g_slice_new0 (DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_http_files_http_file_sender_real_get_file_size_limit_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp1_;
	dino_plugins_http_files_http_file_sender_real_get_file_size_limit_co (_data_);
}

static glong
dino_plugins_http_files_http_file_sender_get_file_size_limit_finish (DinoFileSender* base,
                                                                     GAsyncResult* _res_)
{
	glong result;
	DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static glong*
_long_dup (glong* self)
{
	glong* dup;
	dup = g_new0 (glong, 1);
	memcpy (dup, self, sizeof (glong));
	return dup;
}

static gpointer
__long_dup0 (gpointer self)
{
	return self ? _long_dup (self) : NULL;
}

static gboolean
dino_plugins_http_files_http_file_sender_real_get_file_size_limit_co (DinoPluginsHttpFilesHttpFileSenderGetFileSizeLimitData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->max_file_sizes;
	_data_->_tmp1_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp0_, _data_->_tmp2_);
	_data_->_tmp4_ = (glong) ((gintptr) _data_->_tmp3_);
	_data_->_tmp5_ = __long_dup0 (&_data_->_tmp4_);
	_data_->max_size = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->max_size;
	if (_data_->_tmp6_ != NULL) {
		_data_->_tmp7_ = _data_->max_size;
		_data_->_tmp8_ = *_data_->_tmp7_;
		_g_free0 (_data_->_tmp7_);
		_data_->result = _data_->_tmp8_;
		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 = (glong) -1;
	_g_free0 (_data_->max_size);
	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 void
dino_plugins_http_files_http_file_sender_real_can_encrypt_data_free (gpointer _data)
{
	DinoPluginsHttpFilesHttpFileSenderCanEncryptData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->file_transfer);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsHttpFilesHttpFileSenderCanEncryptData, _data_);
}

static void
dino_plugins_http_files_http_file_sender_real_can_encrypt (DinoFileSender* base,
                                                           DinoEntitiesConversation* conversation,
                                                           DinoEntitiesFileTransfer* file_transfer,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	DinoPluginsHttpFilesHttpFileSenderCanEncryptData* _data_;
	DinoPluginsHttpFilesHttpFileSender* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	DinoEntitiesFileTransfer* _tmp2_;
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (file_transfer != NULL);
	self = (DinoPluginsHttpFilesHttpFileSender*) base;
	_data_ = g_slice_new0 (DinoPluginsHttpFilesHttpFileSenderCanEncryptData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_http_files_http_file_sender_real_can_encrypt_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 (file_transfer);
	_g_object_unref0 (_data_->file_transfer);
	_data_->file_transfer = _tmp2_;
	dino_plugins_http_files_http_file_sender_real_can_encrypt_co (_data_);
}

static gboolean
dino_plugins_http_files_http_file_sender_can_encrypt_finish (DinoFileSender* base,
                                                             GAsyncResult* _res_)
{
	gboolean result;
	DinoPluginsHttpFilesHttpFileSenderCanEncryptData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static gboolean
dino_plugins_http_files_http_file_sender_real_can_encrypt_co (DinoPluginsHttpFilesHttpFileSenderCanEncryptData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->result = FALSE;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dino_plugins_http_files_http_file_sender_real_is_upload_available_data_free (gpointer _data)
{
	DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData, _data_);
}

static void
dino_plugins_http_files_http_file_sender_real_is_upload_available (DinoFileSender* base,
                                                                   DinoEntitiesConversation* conversation,
                                                                   GAsyncReadyCallback _callback_,
                                                                   gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData* _data_;
	DinoPluginsHttpFilesHttpFileSender* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	g_return_if_fail (conversation != NULL);
	self = (DinoPluginsHttpFilesHttpFileSender*) base;
	_data_ = g_slice_new0 (DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_http_files_http_file_sender_real_is_upload_available_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp1_;
	dino_plugins_http_files_http_file_sender_real_is_upload_available_co (_data_);
}

static gboolean
dino_plugins_http_files_http_file_sender_is_upload_available_finish (DinoFileSender* base,
                                                                     GAsyncResult* _res_)
{
	gboolean result;
	DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static gboolean
dino_plugins_http_files_http_file_sender_real_is_upload_available_co (DinoPluginsHttpFilesHttpFileSenderIsUploadAvailableData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->max_file_sizes;
		g_rec_mutex_lock (&_data_->self->priv->__lock_max_file_sizes);
		{
			_data_->_tmp1_ = _data_->self->priv->max_file_sizes;
			_data_->_tmp2_ = dino_entities_conversation_get_account (_data_->conversation);
			_data_->_tmp3_ = _data_->_tmp2_;
			_data_->result = gee_abstract_map_has_key ((GeeAbstractMap*) _data_->_tmp1_, _data_->_tmp3_);
			{
				_data_->_tmp4_ = _data_->self->priv->max_file_sizes;
				g_rec_mutex_unlock (&_data_->self->priv->__lock_max_file_sizes);
			}
			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;
		}
		__finally0:
		{
			_data_->_tmp5_ = _data_->self->priv->max_file_sizes;
			g_rec_mutex_unlock (&_data_->self->priv->__lock_max_file_sizes);
		}
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
}

static void
dino_plugins_http_files_http_file_sender_upload_data_free (gpointer _data)
{
	DinoPluginsHttpFilesHttpFileSenderUploadData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->file_transfer);
	_dino_file_send_data_unref0 (_data_->file_send_data);
	_dino_file_meta_unref0 (_data_->file_meta);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsHttpFilesHttpFileSenderUploadData, _data_);
}

static void
dino_plugins_http_files_http_file_sender_upload (DinoPluginsHttpFilesHttpFileSender* self,
                                                 DinoEntitiesFileTransfer* file_transfer,
                                                 DinoHttpFileSendData* file_send_data,
                                                 DinoFileMeta* file_meta,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSenderUploadData* _data_;
	DinoPluginsHttpFilesHttpFileSender* _tmp0_;
	DinoEntitiesFileTransfer* _tmp1_;
	DinoHttpFileSendData* _tmp2_;
	DinoFileMeta* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file_transfer != NULL);
	g_return_if_fail (file_send_data != NULL);
	g_return_if_fail (file_meta != NULL);
	_data_ = g_slice_new0 (DinoPluginsHttpFilesHttpFileSenderUploadData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_http_files_http_file_sender_upload_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (file_transfer);
	_g_object_unref0 (_data_->file_transfer);
	_data_->file_transfer = _tmp1_;
	_tmp2_ = _dino_file_send_data_ref0 (file_send_data);
	_dino_file_send_data_unref0 (_data_->file_send_data);
	_data_->file_send_data = _tmp2_;
	_tmp3_ = _dino_file_meta_ref0 (file_meta);
	_dino_file_meta_unref0 (_data_->file_meta);
	_data_->file_meta = _tmp3_;
	dino_plugins_http_files_http_file_sender_upload_co (_data_);
}

static void
dino_plugins_http_files_http_file_sender_upload_finish (DinoPluginsHttpFilesHttpFileSender* self,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	DinoPluginsHttpFilesHttpFileSenderUploadData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		DinoPluginsHttpFilesHttpFileSender* self;
		self = _data4_->self;
		_g_free0 (_data4_->transfer_host);
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

static gboolean
__lambda8_ (Block4Data* _data4_,
            GTlsCertificate* peer_cert,
            GTlsCertificateFlags errors)
{
	DinoPluginsHttpFilesHttpFileSender* self;
	const gchar* _tmp0_;
	gboolean result;
	self = _data4_->self;
	g_return_val_if_fail (peer_cert != NULL, FALSE);
	_tmp0_ = _data4_->transfer_host;
	result = dino_connection_manager_on_invalid_certificate (_tmp0_, peer_cert, errors);
	return result;
}

static gboolean
___lambda8__soup_message_accept_certificate (SoupMessage* _sender,
                                             GTlsCertificate* tls_peer_certificate,
                                             GTlsCertificateFlags tls_peer_errors,
                                             gpointer self)
{
	gboolean result;
	result = __lambda8_ (self, tls_peer_certificate, tls_peer_errors);
	return result;
}

static void
dino_plugins_http_files_http_file_sender_upload_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	DinoPluginsHttpFilesHttpFileSenderUploadData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_http_files_http_file_sender_upload_co (_data_);
}

static gboolean
dino_plugins_http_files_http_file_sender_upload_co (DinoPluginsHttpFilesHttpFileSenderUploadData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data4_ = g_slice_new0 (Block4Data);
	_data_->_data4_->_ref_count_ = 1;
	_data_->_data4_->self = g_object_ref (_data_->self);
	_data_->_data4_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->stream_interactor;
	_data_->_tmp1_ = dino_entities_file_transfer_get_account (_data_->file_transfer);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = dino_stream_interactor_get_stream (_data_->_tmp0_, _data_->_tmp2_);
	_data_->stream = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->stream;
	if (_data_->_tmp4_ == NULL) {
		_g_object_unref0 (_data_->stream);
		block4_data_unref (_data_->_data4_);
		_data_->_data4_ = NULL;
		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_->_tmp5_ = dino_http_file_send_data_get_url_up (_data_->file_send_data);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = soup_message_new ("PUT", _data_->_tmp6_);
	_data_->put_message = _data_->_tmp7_;
	_data_->_tmp9_ = dino_http_file_send_data_get_url_up (_data_->file_send_data);
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_tmp11_ = g_uri_parse (_data_->_tmp10_, G_URI_FLAGS_NONE, &_data_->_inner_error0_);
	_data_->_tmp8_ = _data_->_tmp11_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		if (_data_->_inner_error0_->domain == DINO_FILE_SEND_ERROR) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->put_message);
			_g_object_unref0 (_data_->stream);
			block4_data_unref (_data_->_data4_);
			_data_->_data4_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->put_message);
			_g_object_unref0 (_data_->stream);
			block4_data_unref (_data_->_data4_);
			_data_->_data4_ = NULL;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->_tmp12_ = g_uri_get_host (_data_->_tmp8_);
	_data_->_tmp13_ = g_strdup (_data_->_tmp12_);
	_data_->_data4_->transfer_host = _data_->_tmp13_;
	_data_->_tmp14_ = _data_->put_message;
	g_signal_connect_data (_data_->_tmp14_, "accept-certificate", (GCallback) ___lambda8__soup_message_accept_certificate, block4_data_ref (_data_->_data4_), (GClosureNotify) block4_data_unref, 0);
	_data_->_tmp15_ = _data_->put_message;
	_data_->_tmp16_ = _data_->file_meta->mime_type;
	_data_->_tmp17_ = dino_entities_file_transfer_get_input_stream (_data_->file_transfer);
	_data_->_tmp18_ = _data_->_tmp17_;
	soup_message_set_request_body (_data_->_tmp15_, _data_->_tmp16_, _data_->_tmp18_, (gssize) _data_->file_meta->size);
	{
		_data_->_tmp19_ = dino_http_file_send_data_get_headers (_data_->file_send_data);
		_data_->_tmp20_ = _data_->_tmp19_;
		_data_->_tmp21_ = gee_abstract_map_get_entries ((GeeAbstractMap*) _data_->_tmp20_);
		_data_->_tmp22_ = _data_->_tmp21_;
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_tmp24_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp23_);
		_data_->_tmp25_ = _data_->_tmp24_;
		_g_object_unref0 (_data_->_tmp23_);
		_data_->_entry_it = _data_->_tmp25_;
		while (TRUE) {
			_data_->_tmp26_ = _data_->_entry_it;
			if (!gee_iterator_next (_data_->_tmp26_)) {
				break;
			}
			_data_->_tmp27_ = _data_->_entry_it;
			_data_->_tmp28_ = gee_iterator_get (_data_->_tmp27_);
			_data_->entry = (GeeMapEntry*) _data_->_tmp28_;
			_data_->_tmp29_ = _data_->put_message;
			_data_->_tmp30_ = soup_message_get_request_headers (_data_->_tmp29_);
			_data_->_tmp31_ = _data_->_tmp30_;
			_data_->_tmp32_ = _data_->entry;
			_data_->_tmp33_ = gee_map_entry_get_key (_data_->_tmp32_);
			_data_->_tmp34_ = _data_->_tmp33_;
			_data_->_tmp35_ = _data_->entry;
			_data_->_tmp36_ = gee_map_entry_get_value (_data_->_tmp35_);
			_data_->_tmp37_ = _data_->_tmp36_;
			soup_message_headers_append (_data_->_tmp31_, (const gchar*) _data_->_tmp34_, (const gchar*) _data_->_tmp37_);
			_g_object_unref0 (_data_->entry);
		}
		_g_object_unref0 (_data_->_entry_it);
	}
	{
		_data_->_tmp38_ = _data_->self->priv->session;
		_data_->_tmp39_ = _data_->put_message;
		_data_->_tmp40_ = dino_entities_file_transfer_get_cancellable (_data_->file_transfer);
		_data_->_tmp41_ = _data_->_tmp40_;
		_data_->_state_ = 1;
		soup_session_send_async (_data_->_tmp38_, _data_->_tmp39_, G_PRIORITY_LOW, _data_->_tmp41_, dino_plugins_http_files_http_file_sender_upload_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp42_ = soup_session_send_finish (_data_->_tmp38_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp43_ = _data_->_tmp42_;
		_g_object_unref0 (_data_->_tmp43_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp45_ = _data_->put_message;
		g_object_get (_data_->_tmp45_, "status-code", &_data_->_tmp46_, NULL);
		_data_->_tmp47_ = _data_->_tmp46_;
		if (_data_->_tmp47_ < ((guint) 200)) {
			_data_->_tmp44_ = TRUE;
		} else {
			_data_->_tmp48_ = _data_->put_message;
			g_object_get (_data_->_tmp48_, "status-code", &_data_->_tmp49_, NULL);
			_data_->_tmp50_ = _data_->_tmp49_;
			_data_->_tmp44_ = _data_->_tmp50_ >= ((guint) 300);
		}
		if (_data_->_tmp44_) {
			_data_->_tmp51_ = _data_->put_message;
			g_object_get (_data_->_tmp51_, "status-code", &_data_->_tmp52_, NULL);
			_data_->_tmp53_ = _data_->_tmp52_;
			_data_->_tmp54_ = g_strdup_printf ("%u", _data_->_tmp53_);
			_data_->_tmp55_ = _data_->_tmp54_;
			_data_->_tmp56_ = g_strdup_printf ("HTTP status code %s", _data_->_tmp55_);
			_data_->_tmp57_ = _data_->_tmp56_;
			_data_->_tmp58_ = g_error_new_literal (DINO_FILE_SEND_ERROR, DINO_FILE_SEND_ERROR_UPLOAD_FAILED, _data_->_tmp57_);
			_data_->_tmp59_ = _data_->_tmp58_;
			_g_free0 (_data_->_tmp57_);
			_g_free0 (_data_->_tmp55_);
			_data_->_inner_error0_ = _data_->_tmp59_;
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp60_ = _data_->e;
		_data_->_tmp61_ = _data_->_tmp60_->message;
		_data_->_tmp62_ = g_strdup_printf ("HTTP upload error: %s", _data_->_tmp61_);
		_data_->_tmp63_ = _data_->_tmp62_;
		_data_->_tmp64_ = g_error_new_literal (DINO_FILE_SEND_ERROR, DINO_FILE_SEND_ERROR_UPLOAD_FAILED, _data_->_tmp63_);
		_data_->_tmp65_ = _data_->_tmp64_;
		_g_free0 (_data_->_tmp63_);
		_data_->_inner_error0_ = _data_->_tmp65_;
		_g_error_free0 (_data_->e);
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		if (_data_->_inner_error0_->domain == DINO_FILE_SEND_ERROR) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_uri_unref0 (_data_->_tmp8_);
			_g_object_unref0 (_data_->put_message);
			_g_object_unref0 (_data_->stream);
			block4_data_unref (_data_->_data4_);
			_data_->_data4_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_uri_unref0 (_data_->_tmp8_);
			_g_object_unref0 (_data_->put_message);
			_g_object_unref0 (_data_->stream);
			block4_data_unref (_data_->_data4_);
			_data_->_data4_ = NULL;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_g_uri_unref0 (_data_->_tmp8_);
	_g_object_unref0 (_data_->put_message);
	_g_object_unref0 (_data_->stream);
	block4_data_unref (_data_->_data4_);
	_data_->_data4_ = NULL;
	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 Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

static void
block5_data_unref (void * _userdata_)
{
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		DinoPluginsHttpFilesHttpFileSender* self;
		self = _data5_->self;
		_g_object_unref0 (_data5_->account);
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}

static void
__lambda7_ (Block5Data* _data5_,
            XmppXmppStream* stream,
            glong max_file_size)
{
	DinoPluginsHttpFilesHttpFileSender* self;
	GError* _inner_error0_ = NULL;
	self = _data5_->self;
	g_return_if_fail (stream != NULL);
	{
		GeeHashMap* _tmp0_;
		_tmp0_ = self->priv->max_file_sizes;
		g_rec_mutex_lock (&self->priv->__lock_max_file_sizes);
		{
			GeeHashMap* _tmp1_;
			_tmp1_ = self->priv->max_file_sizes;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, _data5_->account, (gpointer) ((gintptr) max_file_size));
		}
		__finally0:
		{
			GeeHashMap* _tmp2_;
			_tmp2_ = self->priv->max_file_sizes;
			g_rec_mutex_unlock (&self->priv->__lock_max_file_sizes);
		}
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			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;
		}
	}
	g_signal_emit_by_name ((DinoFileSender*) self, "upload-available", _data5_->account);
}

static void
___lambda7__xmpp_xep_http_file_upload_module_feature_available (XmppXepHttpFileUploadModule* _sender,
                                                                XmppXmppStream* stream,
                                                                glong max_file_size,
                                                                gpointer self)
{
	__lambda7_ (self, stream, max_file_size);
}

static void
dino_plugins_http_files_http_file_sender_on_stream_negotiated (DinoPluginsHttpFilesHttpFileSender* self,
                                                               DinoEntitiesAccount* account,
                                                               XmppXmppStream* stream)
{
	Block5Data* _data5_;
	DinoEntitiesAccount* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	DinoModuleManager* _tmp2_;
	XmppModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	XmppXepHttpFileUploadModule* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (stream != NULL);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_data5_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (_data5_->account);
	_data5_->account = _tmp0_;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = _tmp1_->module_manager;
	_tmp3_ = xmpp_xep_http_file_upload_module_IDENTITY;
	_tmp4_ = dino_module_manager_get_module (_tmp2_, XMPP_XEP_HTTP_FILE_UPLOAD_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data5_->account, _tmp3_);
	_tmp5_ = (XmppXepHttpFileUploadModule*) _tmp4_;
	g_signal_connect_data (_tmp5_, "feature-available", (GCallback) ___lambda7__xmpp_xep_http_file_upload_module_feature_available, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
	_g_object_unref0 (_tmp5_);
	block5_data_unref (_data5_);
	_data5_ = NULL;
}

static void
dino_plugins_http_files_http_file_sender_check_add_sfs_element (DinoPluginsHttpFilesHttpFileSender* self,
                                                                DinoEntitiesMessage* message,
                                                                XmppMessageStanza* message_stanza,
                                                                DinoEntitiesConversation* conversation)
{
	DinoEntitiesEncryption _tmp0_;
	DinoEntitiesEncryption _tmp1_;
	DinoEntitiesFileTransfer* file_transfer = NULL;
	DinoStreamInteractor* _tmp2_;
	DinoModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	DinoFileTransferStorage* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	DinoEntitiesFileTransfer* _tmp8_;
	DinoEntitiesFileTransfer* _tmp9_;
	DinoEntitiesFileTransfer* _tmp10_;
	DinoEntitiesFileTransfer* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	DinoEntitiesFileTransfer* _tmp14_;
	XmppXepFileMetadataElementFileMetadata* _tmp15_;
	XmppXepFileMetadataElementFileMetadata* _tmp16_;
	XmppXepFileMetadataElementFileMetadata* _tmp17_;
	DinoEntitiesFileTransfer* _tmp18_;
	GeeList* _tmp19_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	g_return_if_fail (message_stanza != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = dino_entities_message_get_encryption (message);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != DINO_ENTITIES_ENCRYPTION_NONE) {
		return;
	}
	_tmp2_ = self->priv->stream_interactor;
	_tmp3_ = dino_file_transfer_storage_IDENTITY;
	_tmp4_ = dino_stream_interactor_get_module (_tmp2_, DINO_TYPE_FILE_TRANSFER_STORAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp3_);
	_tmp5_ = (DinoFileTransferStorage*) _tmp4_;
	_tmp6_ = dino_entities_message_get_id (message);
	_tmp7_ = _tmp6_;
	_tmp8_ = dino_file_transfer_storage_get_file_by_message_id (_tmp5_, _tmp7_, conversation);
	_tmp9_ = _tmp8_;
	_g_object_unref0 (_tmp5_);
	file_transfer = _tmp9_;
	_tmp10_ = file_transfer;
	if (_tmp10_ == NULL) {
		_g_object_unref0 (file_transfer);
		return;
	}
	_tmp11_ = file_transfer;
	_tmp12_ = dino_entities_file_transfer_get_file_sharing_id (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = file_transfer;
	_tmp15_ = dino_entities_file_transfer_get_file_metadata (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp18_ = file_transfer;
	_tmp19_ = _tmp18_->sfs_sources;
	xmpp_xep_stateless_file_sharing_set_sfs_element (message_stanza, _tmp13_, _tmp17_, _tmp19_);
	_xmpp_xep_file_metadata_element_file_metadata_unref0 (_tmp17_);
	xmpp_xep_message_processing_hints_set_message_hint (message_stanza, XMPP_XEP_MESSAGE_PROCESSING_HINTS_HINT_STORE);
	_g_object_unref0 (file_transfer);
}

static gint
dino_plugins_http_files_http_file_sender_real_get_id (DinoFileSender* base)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	gint result;
	self = (DinoPluginsHttpFilesHttpFileSender*) base;
	result = 0;
	return result;
}

static gfloat
dino_plugins_http_files_http_file_sender_real_get_priority (DinoFileSender* base)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	gfloat result;
	self = (DinoPluginsHttpFilesHttpFileSender*) base;
	result = (gfloat) 100;
	return result;
}

static void
dino_plugins_http_files_http_file_sender_class_init (DinoPluginsHttpFilesHttpFileSenderClass * klass,
                                                     gpointer klass_data)
{
	dino_plugins_http_files_http_file_sender_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoPluginsHttpFilesHttpFileSender_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dino_plugins_http_files_http_file_sender_finalize;
}

static void
dino_plugins_http_files_http_file_sender_dino_file_sender_interface_init (DinoFileSenderIface * iface,
                                                                          gpointer iface_data)
{
	dino_plugins_http_files_http_file_sender_dino_file_sender_parent_iface = g_type_interface_peek_parent (iface);
	iface->prepare_send_file = (void (*) (DinoFileSender*, DinoEntitiesConversation*, DinoEntitiesFileTransfer*, DinoFileMeta*, GAsyncReadyCallback, gpointer)) dino_plugins_http_files_http_file_sender_real_prepare_send_file;
	iface->prepare_send_file_finish = (DinoFileSendData* (*) (DinoFileSender*, GAsyncResult*, GError**)) dino_plugins_http_files_http_file_sender_prepare_send_file_finish;
	iface->send_file = (void (*) (DinoFileSender*, DinoEntitiesConversation*, DinoEntitiesFileTransfer*, DinoFileSendData*, DinoFileMeta*, GAsyncReadyCallback, gpointer)) dino_plugins_http_files_http_file_sender_real_send_file;
	iface->send_file_finish = (void (*) (DinoFileSender*, GAsyncResult*, GError**)) dino_plugins_http_files_http_file_sender_send_file_finish;
	iface->can_send = (void (*) (DinoFileSender*, DinoEntitiesConversation*, DinoEntitiesFileTransfer*, GAsyncReadyCallback, gpointer)) dino_plugins_http_files_http_file_sender_real_can_send;
	iface->can_send_finish = (gboolean (*) (DinoFileSender*, GAsyncResult*)) dino_plugins_http_files_http_file_sender_can_send_finish;
	iface->get_file_size_limit = (void (*) (DinoFileSender*, DinoEntitiesConversation*, GAsyncReadyCallback, gpointer)) dino_plugins_http_files_http_file_sender_real_get_file_size_limit;
	iface->get_file_size_limit_finish = (glong (*) (DinoFileSender*, GAsyncResult*)) dino_plugins_http_files_http_file_sender_get_file_size_limit_finish;
	iface->can_encrypt = (void (*) (DinoFileSender*, DinoEntitiesConversation*, DinoEntitiesFileTransfer*, GAsyncReadyCallback, gpointer)) dino_plugins_http_files_http_file_sender_real_can_encrypt;
	iface->can_encrypt_finish = (gboolean (*) (DinoFileSender*, GAsyncResult*)) dino_plugins_http_files_http_file_sender_can_encrypt_finish;
	iface->is_upload_available = (void (*) (DinoFileSender*, DinoEntitiesConversation*, GAsyncReadyCallback, gpointer)) dino_plugins_http_files_http_file_sender_real_is_upload_available;
	iface->is_upload_available_finish = (gboolean (*) (DinoFileSender*, GAsyncResult*)) dino_plugins_http_files_http_file_sender_is_upload_available_finish;
	iface->get_id = (gint (*) (DinoFileSender*)) dino_plugins_http_files_http_file_sender_real_get_id;
	iface->get_priority = (gfloat (*) (DinoFileSender*)) dino_plugins_http_files_http_file_sender_real_get_priority;
}

static void
dino_plugins_http_files_http_file_sender_instance_init (DinoPluginsHttpFilesHttpFileSender * self,
                                                        gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = dino_plugins_http_files_http_file_sender_get_instance_private (self);
	g_rec_mutex_init (&self->priv->__lock_max_file_sizes);
	_tmp0_ = gee_hash_map_new (DINO_ENTITIES_TYPE_ACCOUNT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_LONG, NULL, NULL, _dino_entities_account_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_account_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->max_file_sizes = _tmp0_;
}

static void
dino_plugins_http_files_http_file_sender_finalize (GObject * obj)
{
	DinoPluginsHttpFilesHttpFileSender * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_HTTP_FILES_TYPE_HTTP_FILE_SENDER, DinoPluginsHttpFilesHttpFileSender);
	_g_object_unref0 (self->priv->stream_interactor);
	_qlite_database_unref0 (self->priv->db);
	_g_object_unref0 (self->priv->session);
	g_rec_mutex_clear (&self->priv->__lock_max_file_sizes);
	_g_object_unref0 (self->priv->max_file_sizes);
	G_OBJECT_CLASS (dino_plugins_http_files_http_file_sender_parent_class)->finalize (obj);
}

static GType
dino_plugins_http_files_http_file_sender_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsHttpFilesHttpFileSenderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_http_files_http_file_sender_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsHttpFilesHttpFileSender), 0, (GInstanceInitFunc) dino_plugins_http_files_http_file_sender_instance_init, NULL };
	static const GInterfaceInfo dino_file_sender_info = { (GInterfaceInitFunc) dino_plugins_http_files_http_file_sender_dino_file_sender_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_plugins_http_files_http_file_sender_type_id;
	dino_plugins_http_files_http_file_sender_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoPluginsHttpFilesHttpFileSender", &g_define_type_info, 0);
	g_type_add_interface_static (dino_plugins_http_files_http_file_sender_type_id, DINO_TYPE_FILE_SENDER, &dino_file_sender_info);
	DinoPluginsHttpFilesHttpFileSender_private_offset = g_type_add_instance_private (dino_plugins_http_files_http_file_sender_type_id, sizeof (DinoPluginsHttpFilesHttpFileSenderPrivate));
	return dino_plugins_http_files_http_file_sender_type_id;
}

GType
dino_plugins_http_files_http_file_sender_get_type (void)
{
	static volatile gsize dino_plugins_http_files_http_file_sender_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_http_files_http_file_sender_type_id__once)) {
		GType dino_plugins_http_files_http_file_sender_type_id;
		dino_plugins_http_files_http_file_sender_type_id = dino_plugins_http_files_http_file_sender_get_type_once ();
		g_once_init_leave (&dino_plugins_http_files_http_file_sender_type_id__once, dino_plugins_http_files_http_file_sender_type_id);
	}
	return dino_plugins_http_files_http_file_sender_type_id__once;
}

